@gbasin/agentboard-darwin-x64 0.4.10 → 0.4.12
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.
|
@@ -193,7 +193,7 @@ ${s.join(`
|
|
|
193
193
|
`)),e.length=0)},3e3),nV=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var rV=class{constructor(e){this._size=0,this._options=e,this._leakageMon=KB>0||this._options?.leakWarningThreshold?new JB(e?.onListenerError??sB,this._options?.leakWarningThreshold??KB):void 0,this._perfMon=this._options?._profName?new GB(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(VB){let e=this._listeners;queueMicrotask(()=>{tV(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new ZB(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||sB)(n),FB.None}if(this._disposed)return FB.None;t&&(e=e.bind(t));let r=new $B(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=YB.create(),i=this._leakageMon.check(r.stack,this._size+1)),VB&&(r.stack=YB.create()),this._listeners?this._listeners instanceof $B?(this._deliveryQueue??=new iV,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=MB(()=>{nV?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof PB?n.add(a):Array.isArray(n)&&n.push(a),nV){let e=Error().stack.split(`
|
|
194
194
|
`).slice(2,3).join(`
|
|
195
195
|
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);nV.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*eV<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||sB;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof $B)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},iV=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},aV=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),oV;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof sV?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:UB.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:aV})})(oV||={});var sV=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?aV:(this._emitter||=new rV,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},cV=`en`,lV=!1,uV=!1,dV=cV,fV,pV=globalThis,mV;typeof pV.vscode<`u`&&typeof pV.vscode.process<`u`?mV=pV.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(mV=process);var hV=typeof mV?.versions?.electron==`string`&&mV?.type===`renderer`;if(typeof mV==`object`){mV.platform,mV.platform,lV=mV.platform===`linux`,lV&&mV.env.SNAP&&mV.env.SNAP_REVISION,mV.env.CI||mV.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dV=cV;let e=mV.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,dV=t.resolvedLanguage||cV,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!hV?(fV=navigator.userAgent,fV.indexOf(`Windows`),fV.indexOf(`Macintosh`),(fV.indexOf(`Macintosh`)>=0||fV.indexOf(`iPad`)>=0||fV.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,lV=fV.indexOf(`Linux`)>=0,fV?.indexOf(`Mobi`),uV=!0,dV=globalThis._VSCODE_NLS_LANGUAGE||cV,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);uV&&typeof pV.importScripts==`function`&&pV.origin;var gV=fV,_V=dV,vV;(e=>{function t(){return _V}e.value=t;function n(){return _V.length===2?_V===`en`:_V.length>=3?_V[0]===`e`&&_V[1]===`n`&&_V[2]===`-`:!1}e.isDefaultVariant=n;function r(){return _V===`en`}e.isDefault=r})(vV||={});var yV=typeof pV.postMessage==`function`&&!pV.importScripts;(()=>{if(yV){let e=[];pV.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),pV.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var bV=!!(gV&&gV.indexOf(`Chrome`)>=0);gV&&gV.indexOf(`Firefox`),!bV&&gV&&gV.indexOf(`Safari`),gV&&gV.indexOf(`Edg/`),gV&&gV.indexOf(`Android`);function xV(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=MB(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var SV;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(SV||={});var CV=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new rV,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await UB.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};CV.EMPTY=CV.fromArray([]);var wV=class extends FB{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new IB),this._linesCacheDisposables=this._register(new IB),this._register(MB(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=jB(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=xV(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},TV=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},EV=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},DV=class extends FB{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(MB(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){AB(n)}}}clearHighlightDecorations(){AB(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>AB(e))),s.push(i)}}return s.length===0?void 0:s}},OV=class extends FB{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new rV)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},kV=class extends FB{constructor(e){super(),this._highlightTimeout=this._register(new IB),this._lineCache=this._register(new IB),this._state=new TV,this._resultTracker=this._register(new OV),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new wV(e),this._engine=new EV(e,this._lineCache.value),this._decorationManager=new DV(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(MB(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=xV(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},AV=0,jV=0,MV=0,NV=0,PV;(e=>{function t(e,t,n,r){return r===void 0?`#${zV(e)}${zV(t)}${zV(n)}`:`#${zV(e)}${zV(t)}${zV(n)}${zV(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(PV||={});var FV;(e=>{function t(e,t){if(NV=(t.rgba&255)/255,NV===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return AV=a+Math.round((n-a)*NV),jV=o+Math.round((r-o)*NV),MV=s+Math.round((i-s)*NV),{css:PV.toCss(AV,jV,MV),rgba:PV.toRgba(AV,jV,MV)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=RV.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return PV.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[AV,jV,MV]=RV.toChannels(t),{css:PV.toCss(AV,jV,MV),rgba:t}}e.opaque=i;function a(e,t){return NV=Math.round(t*255),[AV,jV,MV]=RV.toChannels(e.rgba),{css:PV.toCss(AV,jV,MV,NV),rgba:PV.toRgba(AV,jV,MV,NV)}}e.opacity=a;function o(e,t){return NV=e.rgba&255,a(e,NV*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(FV||={});var IV;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return AV=parseInt(e.slice(1,2).repeat(2),16),jV=parseInt(e.slice(2,3).repeat(2),16),MV=parseInt(e.slice(3,4).repeat(2),16),PV.toColor(AV,jV,MV);case 5:return AV=parseInt(e.slice(1,2).repeat(2),16),jV=parseInt(e.slice(2,3).repeat(2),16),MV=parseInt(e.slice(3,4).repeat(2),16),NV=parseInt(e.slice(4,5).repeat(2),16),PV.toColor(AV,jV,MV,NV);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return AV=parseInt(r[1]),jV=parseInt(r[2]),MV=parseInt(r[3]),NV=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),PV.toColor(AV,jV,MV,NV);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[AV,jV,MV,NV]=t.getImageData(0,0,1,1).data,NV!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:PV.toRgba(AV,jV,MV,NV),css:e}}e.toColor=r})(IV||={});var LV;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(LV||={});var RV;(e=>{function t(e,t){if(NV=(t&255)/255,NV===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return AV=a+Math.round((n-a)*NV),jV=o+Math.round((r-o)*NV),MV=s+Math.round((i-s)*NV),PV.toRgba(AV,jV,MV)}e.blend=t;function n(e,t,n){let a=LV.relativeLuminance(e>>8),o=LV.relativeLuminance(t>>8);if(BV(a,o)<n){if(o<a){let o=r(e,t,n),s=BV(a,LV.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>BV(a,LV.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=BV(a,LV.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>BV(a,LV.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(RV||={});function zV(e){let t=e.toString(16);return t.length<2?`0`+t:t}function BV(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var VV=Object.freeze((()=>{let e=[IV.toColor(`#2e3436`),IV.toColor(`#cc0000`),IV.toColor(`#4e9a06`),IV.toColor(`#c4a000`),IV.toColor(`#3465a4`),IV.toColor(`#75507b`),IV.toColor(`#06989a`),IV.toColor(`#d3d7cf`),IV.toColor(`#555753`),IV.toColor(`#ef2929`),IV.toColor(`#8ae234`),IV.toColor(`#fce94f`),IV.toColor(`#729fcf`),IV.toColor(`#ad7fa8`),IV.toColor(`#34e2e2`),IV.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:PV.toCss(r,i,a),rgba:PV.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:PV.toCss(n,n,n),rgba:PV.toRgba(n,n,n)})}return e})());function HV(e,t,n){return Math.max(t,Math.min(e,n))}function UV(e){switch(e){case`&`:return`&`;case`<`:return`<`}return e}var WV=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),r=this._buffer.getNullCell(),i=n,a=e.start.y,o=e.end.y,s=e.start.x,c=e.end.x;this._beforeSerialize(o-a,a,o);for(let t=a;t<=o;t++){let a=this._buffer.getLine(t);if(a){let o=t===e.start.y?s:0,l=t===e.end.y?c:a.length;for(let e=o;e<l;e++){let o=a.getCell(e,i===n?r:n);if(!o){console.warn(`Can't get cell at row=${t}, col=${e}`);continue}this._nextCell(o,i,t,e),i=o}}this._rowEnd(t,t===o)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,n,r){}_rowEnd(e,t){}_beforeSerialize(e,t,n){}_afterSerialize(){}_serializeString(e){return``}};function GV(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function KV(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function qV(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var JV=class extends WV{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow=``,this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,n){this._allRows=Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){this._nullCellCount>0&&!KV(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n=``;if(!t){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let t=this._buffer.getLine(e),r=this._buffer.getLine(e+1);if(!r.isWrapped)n=`\r
|
|
196
|
-
`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n=``;let i=t.getCell(t.length-1,this._thisRowLastChar),a=t.getCell(t.length-2,this._thisRowLastSecondChar),o=r.getCell(0,this._nextRowFirstChar),s=o.getWidth()>1,c=!1;(o.getChars()&&s?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||i.getWidth()===0)&&KV(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&KV(i,o)&&KV(a,o)&&(c=!0)),c||(n=`-`.repeat(this._nullCellCount+1),n+=`\x1B[1D\x1B[1X`,this._nullCellCount>0&&(n+=`\x1B[A`,n+=`\x1B[${t.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${t.length-this._nullCellCount}D`,n+=`\x1B[B`),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow=``,this._nullCellCount=0}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(r){let t=e.getFgColor();e.isFgRGB()?n.push(38,2,t>>>16&255,t>>>8&255,t&255):e.isFgPalette()?t>=16?n.push(38,5,t):n.push(t&8?90+(t&7):30+(t&7)):n.push(39)}if(i){let t=e.getBgColor();e.isBgRGB()?n.push(48,2,t>>>16&255,t>>>8&255,t&255):e.isBgPalette()?t>=16?n.push(48,5,t):n.push(t&8?100+(t&7):40+(t&7)):n.push(49)}a&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,this._cursorStyle);if(i?!KV(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`\x1B[${a.join(`;`)}m`;let e=this._buffer.getLine(n);e!==void 0&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=r)}i?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n=``;for(let e=0;e<t;e++)n+=this._allRows[e],e+1<t&&(n+=this._allRowSeparators[e]);if(!e){let e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX;(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((e=>{e>0?n+=`\x1B[${e}B`:e<0&&(n+=`\x1B[${-e}A`)})(e-this._lastCursorRow),(e=>{e>0?n+=`\x1B[${e}C`:e<0&&(n+=`\x1B[${-e}D`)})(t-this._lastCursorCol))}let r=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(r,this._cursorStyle);return i.length>0&&(n+=`\x1B[${i.join(`;`)}m`),n}},YV=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:HV(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new JV(t,e).serialize({start:{x:0,y:typeof n.start==`number`?n.start:n.start.line},end:{x:e.cols,y:typeof n.end==`number`?n.end:n.end.line}},r)}_serializeBufferAsHTML(e,t){let n=e.buffer.active,r=new XV(n,e,t),i=t.onlySelection??!1,a=t.range;if(a)return r.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!i){let i=n.length,a=t.scrollback,o=a===void 0?i:HV(a+e.rows,0,i);return r.serialize({start:{x:0,y:i-o},end:{x:e.cols,y:i-1}})}let o=this._terminal?.getSelectionPosition();return o===void 0?``:r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}})}_serializeModes(e){let t=``,n=e.modes;if(n.applicationCursorKeysMode&&(t+=`\x1B[?1h`),n.applicationKeypadMode&&(t+=`\x1B[?66h`),n.bracketedPasteMode&&(t+=`\x1B[?2004h`),n.insertMode&&(t+=`\x1B[4h`),n.originMode&&(t+=`\x1B[?6h`),n.reverseWraparoundMode&&(t+=`\x1B[?45h`),n.sendFocusMode&&(t+=`\x1B[?1004h`),n.wraparoundMode===!1&&(t+=`\x1B[?7l`),n.mouseTrackingMode!==`none`)switch(n.mouseTrackingMode){case`x10`:t+=`\x1B[?9h`;break;case`vt200`:t+=`\x1B[?1000h`;break;case`drag`:t+=`\x1B[?1002h`;break;case`any`:t+=`\x1B[?1003h`;break}return t}serialize(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type===`alternate`){let e=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${e}`}return e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},XV=class extends WV{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow=``,this._htmlContent=``,t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=VV}_padStart(e,t,n){return t>>=0,n??=` `,e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){this._htmlContent+=`<html><body><!--StartFragment--><pre>`;let r=`#000000`,i=`#ffffff`;(this._options.includeGlobalBackground??!1)&&(r=this._terminal.options.theme?.foreground??`#ffffff`,i=this._terminal.options.theme?.background??`#000000`);let a=[];a.push(`color: `+r+`;`),a.push(`background-color: `+i+`;`),a.push(`font-family: `+this._terminal.options.fontFamily+`;`),a.push(`font-size: `+this._terminal.options.fontSize+`px;`),this._htmlContent+=`<div style='`+a.join(` `)+`'>`}_afterSerialize(){this._htmlContent+=`</div>`,this._htmlContent+=`</pre><!--EndFragment--></body></html>`}_rowEnd(e,t){this._htmlContent+=`<div><span>`+this._currentRow+`</span></div>`,this._currentRow=``}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return`#`+[n>>16&255,n>>8&255,n&255].map(e=>this._padStart(e.toString(16),2,`0`)).join(``);if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a){let t=this._getHexColor(e,!0);t&&n.push(`color: `+t+`;`);let r=this._getHexColor(e,!1);return r&&n.push(`background-color: `+r+`;`),e.isInverse()&&n.push(`color: #000000; background-color: #BFBFBF;`),e.isBold()&&n.push(`font-weight: bold;`),e.isUnderline()&&e.isOverline()?n.push(`text-decoration: overline underline;`):e.isUnderline()?n.push(`text-decoration: underline;`):e.isOverline()&&n.push(`text-decoration: overline;`),e.isBlink()&&n.push(`text-decoration: blink;`),e.isInvisible()&&n.push(`visibility: hidden;`),e.isItalic()&&n.push(`font-style: italic;`),e.isDim()&&n.push(`opacity: 0.5;`),e.isStrikethrough()&&n.push(`text-decoration: line-through;`),n}}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,t);a&&(this._currentRow+=a.length===0?`</span><span>`:`</span><span style='`+a.join(` `)+`'>`),i?this._currentRow+=` `:this._currentRow+=UV(e.getChars())}_serializeString(){return this._htmlContent}};function ZV(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var QV=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,e=>{if(!e.startsWith(`4;`))return!1;let t=e.split(`;`);if(t.length>3)return!0;t.length===2&&t.push(``);let n=ZV(t[1]),r=ZV(t[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(r<0)return!0;this.progress={state:n,value:r};break;case 2:case 4:if(r<0)return!0;this.progress={state:n,value:r||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn(`progress state out of bounds, not applied`);return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function $V(e){return`\x1b[200~${e}\x1b[201~`}function eH(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function tH(e,t){let n=eH(e);return t===`codex`?n:$V(n)}var nH=new Map,rH=20;function iH(e){nH.delete(e)}function aH(){nH.clear()}var oH=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,sH=/[.,;:!?]+$/,cH=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],lH=(e,t)=>e.split(t).length-1;function uH(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(sH,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of cH){if(!t.endsWith(n))continue;let i=lH(t,e);lH(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var dH=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),fH=`\x1B[200~\x1B[201~`,pH=``,mH=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,hH=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;async function gH(e){try{let t=(e.type.split(`/`)[1]||`png`).toLowerCase(),n=new FormData;n.append(`image`,e,`paste.${t}`);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(!r.ok)return null;let i=await r.json();return typeof i.path==`string`?i.path:null}catch{return null}}async function _H(){try{let e=await fetch(`/api/clipboard-file-path`);if(!e.ok)return null;let t=await e.json();return t.isImage===!0&&typeof t.path==`string`?t.path:null}catch{return null}}async function vH(e,t){if(e===`codex`)return pH;let n=t.path??null;return!n&&t.blob&&(n=await gH(t.blob)),n||=await _H(),n?$V(eH(n)):fH}var yH=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function bH(e){return yH.test(e)}function xH(e){if(!e)return!1;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return!0;for(let t of Array.from(e.items??[]))if(t?.type?.startsWith(`image/`))return!0;return!1}function SH(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return t;for(let t of Array.from(e.items??[]))if(t?.kind===`file`&&t.type?.startsWith(`image/`)){let e=t.getAsFile?.();if(e)return e}return null}var CH=class{constructor(e={}){this.callbacks=e}async readText(e){if(e!==`c`)return``;try{return await navigator.clipboard.readText()}catch{return``}}async writeText(e,t){if(e!==`c`||!t?.trim())return;let n=performance.now();try{if(!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText unavailable`);await navigator.clipboard.writeText(t),QT(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){QT(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},wH=`︎`,TH=[`⏺`],EH=new RegExp(TH.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function DH(e){for(let t of TH)if(e.indexOf(t)!==-1)return e.replace(EH,`$&${wH}`);return e}function OH({sessionId:e,tmuxTarget:t,agentType:n,allowAttach:r=!0,connectionStatus:i=`connected`,connectionEpoch:a=0,sendMessage:o,subscribe:s,theme:c,fontSize:l,lineHeight:u,letterSpacing:d,fontFamily:f,useWebGL:p,onScrollChange:m}){let h=Ue(),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(!1),y=(0,x.useRef)(null),b=(0,x.useRef)(null),S=(0,x.useRef)(null),C=(0,x.useRef)(null),w=(0,x.useRef)(null),T=(0,x.useRef)(null),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(0),j=(0,x.useRef)(!1),M=(0,x.useRef)(!1),N=(0,x.useRef)(!1),P=(0,x.useRef)(null),F=(0,x.useRef)(0),[I,L]=(0,x.useState)(null),ee=(0,x.useCallback)((e,t)=>{e?.trim()&&(F.current+=1,L({id:F.current,text:e,source:t}))},[]),R=(0,x.useCallback)(()=>{I&&(Rm(I.text),QT(`clipboard_manual_copy`,{source:I.source,chars:I.text.length},`info`),L(null))},[I]),z=(0,x.useCallback)(()=>{L(null)},[]),B=(0,x.useRef)(null),V=(0,x.useRef)(null),H=(0,x.useRef)(null),te=(0,x.useRef)(-1),U=(0,x.useRef)(null),ne=(0,x.useRef)(null),W=(0,x.useRef)(o),re=(0,x.useRef)(n),ie=(0,x.useRef)(m),ae=(0,x.useRef)(p),oe=(0,x.useRef)([]),se=(0,x.useRef)(null),ce=(0,x.useRef)(null),le=(0,x.useRef)(!1),[ue,de]=(0,x.useState)(!1),fe=(0,x.useRef)(null),pe=(0,x.useRef)(null),me=(0,x.useRef)(null),he=()=>{if(fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null),pe.current!==null&&(cancelAnimationFrame(pe.current),pe.current=null),me.current!==null){let e=g.current;e&&(e.style.display=me.current),me.current=null}},ge=(e,t)=>{let n=g.current;n&&(he(),QT(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:V.current}),fe.current=window.setTimeout(()=>{fe.current=null;let e=_.current;e&&e.refresh(0,e.rows-1),QT(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:V.current}),me.current=n.style.display,n.style.display=`none`,pe.current=requestAnimationFrame(()=>{pe.current=requestAnimationFrame(()=>{pe.current=null,n.style.display=me.current??``,me.current=null})})},e))};(0,x.useEffect)(()=>{W.current=o},[o]),(0,x.useEffect)(()=>{re.current=n},[n]),(0,x.useEffect)(()=>{ie.current=m},[m]);let _e=(0,x.useCallback)(()=>{let e=_.current;if(!e||!ie.current)return;let t=e.buffer.active,n=!j.current&&t.viewportY>=t.baseY;ie.current(n)},[]),ve=(0,x.useCallback)(e=>{if(e&&M.current||j.current===e)return;j.current=e;let t=_.current;t&&e&&t.write(hH),_e()},[_e]),ye=(0,x.useCallback)(()=>{let e=V.current;e&&(P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,W.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),be=(0,x.useCallback)(()=>{let e=_.current,t=y.current;if(!e||!t)return;t.fit();let n=V.current;n&&W.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})},[]);return(0,x.useEffect)(()=>{let t=g.current;if(!t||_.current)return;let n=!1;t.innerHTML=``;let r=new SP({fontFamily:f,fontSize:l,lineHeight:((e,t)=>Math.round(e*t)/e)(l,u),letterSpacing:d,scrollback:0,cursorBlink:!1,cursorStyle:`underline`,convertEol:!0,theme:c,screenReaderMode:h,minimumContrastRatio:4.5}),i=new TP;r.loadAddon(i),r.loadAddon(new rB(void 0,new CH({onWriteFailed:ee})));let a=new kV;r.loadAddon(a),w.current=a;let o=new YV;r.loadAddon(o),T.current=o;let s=new QV;r.loadAddon(s),E.current=s;let p=()=>{if(!n){if(ae.current)try{let t=new pz;t.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:e},`info`);try{t.dispose()}catch{}b.current=null}),r.loadAddon(t),b.current=t}catch{}r.open(t),i.fit(),v.current||(v.current=!0,QT(`terminal_init`,{isiOS:h,useWebGL:ae.current,hasWebGL:!!b.current,userAgent:navigator.userAgent.slice(0,120),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},`info`)),m&&r.element&&r.element.appendChild(m)}};document.fonts?.ready?document.fonts.ready.then(p).catch(p):p();let m=null,x=null,D=null;typeof document<`u`&&document.createElement&&(m=document.createElement(`div`),m.className=`xterm-hover`,m.style.cssText=`
|
|
196
|
+
`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n=``;let i=t.getCell(t.length-1,this._thisRowLastChar),a=t.getCell(t.length-2,this._thisRowLastSecondChar),o=r.getCell(0,this._nextRowFirstChar),s=o.getWidth()>1,c=!1;(o.getChars()&&s?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||i.getWidth()===0)&&KV(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&KV(i,o)&&KV(a,o)&&(c=!0)),c||(n=`-`.repeat(this._nullCellCount+1),n+=`\x1B[1D\x1B[1X`,this._nullCellCount>0&&(n+=`\x1B[A`,n+=`\x1B[${t.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${t.length-this._nullCellCount}D`,n+=`\x1B[B`),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow=``,this._nullCellCount=0}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(r){let t=e.getFgColor();e.isFgRGB()?n.push(38,2,t>>>16&255,t>>>8&255,t&255):e.isFgPalette()?t>=16?n.push(38,5,t):n.push(t&8?90+(t&7):30+(t&7)):n.push(39)}if(i){let t=e.getBgColor();e.isBgRGB()?n.push(48,2,t>>>16&255,t>>>8&255,t&255):e.isBgPalette()?t>=16?n.push(48,5,t):n.push(t&8?100+(t&7):40+(t&7)):n.push(49)}a&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,this._cursorStyle);if(i?!KV(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`\x1B[${a.join(`;`)}m`;let e=this._buffer.getLine(n);e!==void 0&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=r)}i?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n=``;for(let e=0;e<t;e++)n+=this._allRows[e],e+1<t&&(n+=this._allRowSeparators[e]);if(!e){let e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX;(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((e=>{e>0?n+=`\x1B[${e}B`:e<0&&(n+=`\x1B[${-e}A`)})(e-this._lastCursorRow),(e=>{e>0?n+=`\x1B[${e}C`:e<0&&(n+=`\x1B[${-e}D`)})(t-this._lastCursorCol))}let r=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(r,this._cursorStyle);return i.length>0&&(n+=`\x1B[${i.join(`;`)}m`),n}},YV=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:HV(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new JV(t,e).serialize({start:{x:0,y:typeof n.start==`number`?n.start:n.start.line},end:{x:e.cols,y:typeof n.end==`number`?n.end:n.end.line}},r)}_serializeBufferAsHTML(e,t){let n=e.buffer.active,r=new XV(n,e,t),i=t.onlySelection??!1,a=t.range;if(a)return r.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!i){let i=n.length,a=t.scrollback,o=a===void 0?i:HV(a+e.rows,0,i);return r.serialize({start:{x:0,y:i-o},end:{x:e.cols,y:i-1}})}let o=this._terminal?.getSelectionPosition();return o===void 0?``:r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}})}_serializeModes(e){let t=``,n=e.modes;if(n.applicationCursorKeysMode&&(t+=`\x1B[?1h`),n.applicationKeypadMode&&(t+=`\x1B[?66h`),n.bracketedPasteMode&&(t+=`\x1B[?2004h`),n.insertMode&&(t+=`\x1B[4h`),n.originMode&&(t+=`\x1B[?6h`),n.reverseWraparoundMode&&(t+=`\x1B[?45h`),n.sendFocusMode&&(t+=`\x1B[?1004h`),n.wraparoundMode===!1&&(t+=`\x1B[?7l`),n.mouseTrackingMode!==`none`)switch(n.mouseTrackingMode){case`x10`:t+=`\x1B[?9h`;break;case`vt200`:t+=`\x1B[?1000h`;break;case`drag`:t+=`\x1B[?1002h`;break;case`any`:t+=`\x1B[?1003h`;break}return t}serialize(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type===`alternate`){let e=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${e}`}return e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},XV=class extends WV{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow=``,this._htmlContent=``,t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=VV}_padStart(e,t,n){return t>>=0,n??=` `,e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){this._htmlContent+=`<html><body><!--StartFragment--><pre>`;let r=`#000000`,i=`#ffffff`;(this._options.includeGlobalBackground??!1)&&(r=this._terminal.options.theme?.foreground??`#ffffff`,i=this._terminal.options.theme?.background??`#000000`);let a=[];a.push(`color: `+r+`;`),a.push(`background-color: `+i+`;`),a.push(`font-family: `+this._terminal.options.fontFamily+`;`),a.push(`font-size: `+this._terminal.options.fontSize+`px;`),this._htmlContent+=`<div style='`+a.join(` `)+`'>`}_afterSerialize(){this._htmlContent+=`</div>`,this._htmlContent+=`</pre><!--EndFragment--></body></html>`}_rowEnd(e,t){this._htmlContent+=`<div><span>`+this._currentRow+`</span></div>`,this._currentRow=``}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return`#`+[n>>16&255,n>>8&255,n&255].map(e=>this._padStart(e.toString(16),2,`0`)).join(``);if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a){let t=this._getHexColor(e,!0);t&&n.push(`color: `+t+`;`);let r=this._getHexColor(e,!1);return r&&n.push(`background-color: `+r+`;`),e.isInverse()&&n.push(`color: #000000; background-color: #BFBFBF;`),e.isBold()&&n.push(`font-weight: bold;`),e.isUnderline()&&e.isOverline()?n.push(`text-decoration: overline underline;`):e.isUnderline()?n.push(`text-decoration: underline;`):e.isOverline()&&n.push(`text-decoration: overline;`),e.isBlink()&&n.push(`text-decoration: blink;`),e.isInvisible()&&n.push(`visibility: hidden;`),e.isItalic()&&n.push(`font-style: italic;`),e.isDim()&&n.push(`opacity: 0.5;`),e.isStrikethrough()&&n.push(`text-decoration: line-through;`),n}}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,t);a&&(this._currentRow+=a.length===0?`</span><span>`:`</span><span style='`+a.join(` `)+`'>`),i?this._currentRow+=` `:this._currentRow+=UV(e.getChars())}_serializeString(){return this._htmlContent}};function ZV(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var QV=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,e=>{if(!e.startsWith(`4;`))return!1;let t=e.split(`;`);if(t.length>3)return!0;t.length===2&&t.push(``);let n=ZV(t[1]),r=ZV(t[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(r<0)return!0;this.progress={state:n,value:r};break;case 2:case 4:if(r<0)return!0;this.progress={state:n,value:r||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn(`progress state out of bounds, not applied`);return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function $V(e){return`\x1b[200~${e}\x1b[201~`}function eH(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function tH(e,t){let n=eH(e);return t===`codex`?n:$V(n)}var nH=new Map,rH=20;function iH(e){nH.delete(e)}function aH(){nH.clear()}var oH=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,sH=/[.,;:!?]+$/,cH=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],lH=(e,t)=>e.split(t).length-1;function uH(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(sH,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of cH){if(!t.endsWith(n))continue;let i=lH(t,e);lH(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var dH=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),fH=`\x1B[200~\x1B[201~`,pH=``,mH=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,hH=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;async function gH(e){try{let t=(e.type.split(`/`)[1]||`png`).toLowerCase(),n=new FormData;n.append(`image`,e,`paste.${t}`);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(!r.ok)return null;let i=await r.json();return typeof i.path==`string`?i.path:null}catch{return null}}async function _H(){try{let e=await fetch(`/api/clipboard-file-path`);if(!e.ok)return null;let t=await e.json();return t.isImage===!0&&typeof t.path==`string`?t.path:null}catch{return null}}async function vH(e,t){if(e===`codex`)return pH;let n=t.path??null;return!n&&t.blob&&(n=await gH(t.blob)),n||=await _H(),n?$V(eH(n)):fH}var yH=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function bH(e){return yH.test(e)}function xH(e){if(!e)return!1;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return!0;for(let t of Array.from(e.items??[]))if(t?.type?.startsWith(`image/`))return!0;return!1}function SH(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return t;for(let t of Array.from(e.items??[]))if(t?.kind===`file`&&t.type?.startsWith(`image/`)){let e=t.getAsFile?.();if(e)return e}return null}var CH=class{constructor(e={}){this.callbacks=e}async readText(e){if(e!==`c`)return``;try{return await navigator.clipboard.readText()}catch{return``}}async writeText(e,t){if(e!==`c`||!t?.trim())return;let n=performance.now();try{if(!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText unavailable`);await navigator.clipboard.writeText(t),QT(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){QT(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},wH=`︎`,TH=[`⏺`],EH=new RegExp(TH.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function DH(e){for(let t of TH)if(e.indexOf(t)!==-1)return e.replace(EH,`$&${wH}`);return e}function OH({sessionId:e,tmuxTarget:t,agentType:n,allowAttach:r=!0,connectionStatus:i=`connected`,connectionEpoch:a=0,sendMessage:o,subscribe:s,theme:c,fontSize:l,lineHeight:u,letterSpacing:d,fontFamily:f,useWebGL:p,onScrollChange:m}){let h=Ue(),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(!1),y=(0,x.useRef)(null),b=(0,x.useRef)(null),S=(0,x.useRef)(null),C=(0,x.useRef)(null),w=(0,x.useRef)(null),T=(0,x.useRef)(null),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(0),j=(0,x.useRef)(!1),M=(0,x.useRef)(!1),N=(0,x.useRef)(!1),P=(0,x.useRef)(null),F=(0,x.useRef)(0),[I,L]=(0,x.useState)(null),ee=(0,x.useCallback)((e,t)=>{e?.trim()&&(F.current+=1,L({id:F.current,text:e,source:t}))},[]),R=(0,x.useCallback)(()=>{I&&(Rm(I.text),QT(`clipboard_manual_copy`,{source:I.source,chars:I.text.length},`info`),L(null))},[I]),z=(0,x.useCallback)(()=>{L(null)},[]),B=(0,x.useRef)(null),V=(0,x.useRef)(null),H=(0,x.useRef)(e&&r&&i===`connected`?e:null),te=(0,x.useRef)(null),U=(0,x.useRef)(-1),ne=(0,x.useRef)(null),W=(0,x.useRef)(null),re=(0,x.useRef)(o),ie=(0,x.useRef)(n),ae=(0,x.useRef)(m),oe=(0,x.useRef)(p),se=(0,x.useRef)([]),ce=(0,x.useRef)(null),le=(0,x.useRef)(null),ue=(0,x.useRef)(!1),[de,fe]=(0,x.useState)(!1),pe=(0,x.useRef)(null),me=(0,x.useRef)(null),he=(0,x.useRef)(null),ge=()=>{if(pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null),me.current!==null&&(cancelAnimationFrame(me.current),me.current=null),he.current!==null){let e=g.current;e&&(e.style.display=he.current),he.current=null}},_e=(e,t)=>{let n=g.current;n&&(ge(),QT(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:V.current}),pe.current=window.setTimeout(()=>{pe.current=null;let e=_.current;e&&e.refresh(0,e.rows-1),QT(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:V.current}),he.current=n.style.display,n.style.display=`none`,me.current=requestAnimationFrame(()=>{me.current=requestAnimationFrame(()=>{me.current=null,n.style.display=he.current??``,he.current=null})})},e))};(0,x.useEffect)(()=>{re.current=o},[o]),(0,x.useEffect)(()=>{ie.current=n},[n]),(0,x.useEffect)(()=>{ae.current=m},[m]);let ve=(0,x.useCallback)(()=>{let e=_.current;if(!e||!ae.current)return;let t=e.buffer.active,n=!j.current&&t.viewportY>=t.baseY;ae.current(n)},[]),ye=(0,x.useCallback)(e=>{if(e&&M.current||j.current===e)return;j.current=e;let t=_.current;t&&e&&t.write(hH),ve()},[ve]),be=(0,x.useCallback)(()=>{let e=H.current;e&&(P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,re.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),xe=(0,x.useCallback)(()=>{let e=_.current,t=y.current;if(!e||!t)return;t.fit();let n=V.current;n&&re.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})},[]);return(0,x.useEffect)(()=>{let t=g.current;if(!t||_.current)return;let n=!1;t.innerHTML=``;let r=new SP({fontFamily:f,fontSize:l,lineHeight:((e,t)=>Math.round(e*t)/e)(l,u),letterSpacing:d,scrollback:0,cursorBlink:!1,cursorStyle:`underline`,convertEol:!0,theme:c,screenReaderMode:h,minimumContrastRatio:4.5}),i=new TP;r.loadAddon(i),r.loadAddon(new rB(void 0,new CH({onWriteFailed:ee})));let a=new kV;r.loadAddon(a),w.current=a;let o=new YV;r.loadAddon(o),T.current=o;let s=new QV;r.loadAddon(s),E.current=s;let p=()=>{if(!n){if(oe.current)try{let t=new pz;t.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:e},`info`);try{t.dispose()}catch{}b.current=null}),r.loadAddon(t),b.current=t}catch{}r.open(t),i.fit(),v.current||(v.current=!0,QT(`terminal_init`,{isiOS:h,useWebGL:oe.current,hasWebGL:!!b.current,userAgent:navigator.userAgent.slice(0,120),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},`info`)),m&&r.element&&r.element.appendChild(m)}};document.fonts?.ready?document.fonts.ready.then(p).catch(p):p();let m=null,x=null,D=null;typeof document<`u`&&document.createElement&&(m=document.createElement(`div`),m.className=`xterm-hover`,m.style.cssText=`
|
|
197
197
|
position: absolute;
|
|
198
198
|
display: none;
|
|
199
199
|
z-index: 20;
|
|
@@ -207,7 +207,7 @@ ${s.join(`
|
|
|
207
207
|
pointer-events: none;
|
|
208
208
|
max-width: 400px;
|
|
209
209
|
word-break: break-all;
|
|
210
|
-
`,x=document.createElement(`div`),m.appendChild(x),D=document.createElement(`div`),D.style.color=`var(--text-muted)`,D.style.marginTop=`2px`,D.style.fontSize=`11px`,m.appendChild(D),C.current=m);let k=(e,t)=>{if(!r.element||!m||!x||!D)return;let n=uH(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;x.textContent=a,D.textContent=`${dH()?`⌘`:`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`},N=()=>{m&&(m.style.display=`none`)},F=null,I=!1,L=null,R={activate:(e,t)=>{if(!I&&(e.metaKey||e.ctrlKey)){let e=uH(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{F=uH(t)||null,k(e,t)},leave:()=>{F=null,N()}},z=e=>{F&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.stopPropagation(),I=!0,window.open(F,`_blank`,`noopener`),L&&clearTimeout(L),L=setTimeout(()=>{I=!1},100))};t.addEventListener(`mousedown`,z,!0),r.options.linkHandler=R;let B=new yz((e,t)=>R.activate(e,t),{urlRegex:oH,hover:(e,t)=>R.hover(e,t),leave:()=>R.leave()});r.loadAddon(B),S.current=B;let H=null,te=null,U=dH()?`metaKey`:`ctrlKey`,ne=(e,t)=>{t&&V.current===e&&W.current({type:`terminal-input`,sessionId:e,data:t})};r.attachCustomKeyEventHandler(e=>{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(dH()&&!h&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`){let e=V.current;return e&&(j.current&&(W.current({type:`tmux-cancel-copy-mode`,sessionId:e}),ve(!1)),(async()=>{ne(e,await vH(re.current,{}))})()),!e}if(e[U]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){te!==null&&(clearTimeout(te),te=null),H=null;let e=new Promise(e=>{te=setTimeout(()=>{te=null,H=null,e(null)},100),H=t=>{te!==null&&(clearTimeout(te),te=null),e(t)}});return(async()=>{try{let t=V.current;if(!t)return;let n=await e,r=n?.text??null;if(r===null)try{r=await navigator.clipboard.readText()}catch{r=``}if(n?.hasImage&&dH()&&!h){ne(t,await vH(re.current,{blob:n.imageBlob}));return}if(!r&&dH()&&!h)try{let e=await fetch(`/api/clipboard-file-path`);if(e.ok){let{path:n,isImage:r}=await e.json();if(n){if(r){ne(t,await vH(re.current,{path:n}));return}ne(t,n);return}}}catch{}if(r&&!bH(r)){V.current===t&&(j.current&&(W.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ve(!1)),W.current({type:`terminal-paste`,sessionId:t,data:r}));return}dH()&&!h&&ne(t,await vH(re.current,{}))}finally{H=null}})(),!1}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=V.current;return e&&W.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ie=e=>{if(!H)return;e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=SH(e.clipboardData),r=n!==null||xH(e.clipboardData),i=H;H=null,i({text:t,hasImage:r,imageBlob:n})};return t.addEventListener(`paste`,ie,{capture:!0}),r.onData(e=>{let t=V.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(j.current&&n)return;j.current&&(W.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ve(!1)),W.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=V.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;A.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(A.current)>=30;){c=!0;let e=A.current>0;A.current+=e?-30:30;let n=e?65:64;e||(s=!0),W.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!M.current&&ve(!0),c&&!M.current&&ye(),!1}),_.current=r,y.current=i,()=>{if(n=!0,L&&clearTimeout(L),F=null,t.removeEventListener(`mousedown`,z,!0),t.removeEventListener(`paste`,ie,!0),te!==null&&(clearTimeout(te),te=null),H=null,C.current&&=(C.current.remove(),null),S.current){try{S.current.dispose()}catch{}S.current=null}if(b.current){try{b.current.dispose()}catch{}b.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),_.current=null,y.current=null,w.current=null,T.current=null,E.current=null,O.current&&window.clearTimeout(O.current),P.current!==null&&window.clearTimeout(P.current)}},[be]),(0,x.useEffect)(()=>{_.current&&(_.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=_.current,t=y.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=V.current;n&&W.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=_.current;if(!e)return;let t=ae.current;if(ae.current=p,t!==p){if(p){if(!b.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}b.current=null}),e.loadAddon(t),b.current=t}catch{}}else if(b.current){try{b.current.dispose()}catch{}b.current=null}}},[p]),(0,x.useEffect)(()=>{let n=_.current;if(!n)return;let o=V.current,s=H.current;if(!r){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(W.current({type:`terminal-detach`,sessionId:o}),V.current=null,H.current=null,te.current=-1,U.current=null,j.current=!1),n.reset(),le.current=!1,de(!1);return}if(i!==`connected`){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(QT(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),V.current=null,H.current=null,te.current=-1,U.current=null,j.current=!1),aH(),le.current=!1,de(!1);return}if(o&&o!==e){try{let e=T.current?.serialize();if(e&&(nH.set(o,e),nH.size>rH)){let e=nH.keys().next().value;e&&nH.delete(e)}}catch{}W.current({type:`terminal-detach`,sessionId:o}),V.current=null,H.current=null,te.current=-1,U.current=null,j.current=!1}let c=te.current,l=a!==c;if(e&&(e!==o||t!==s||l)){QT(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();oe.current=[],se.current!==null&&(window.clearTimeout(se.current),se.current=null),ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null),le.current=!0,de(!0);let l=nH.get(e);l&&(n.reset(),n.write(l));let u=y.current;u&&u.fit();let d=performance.now();V.current=e,H.current=t??null,te.current=a,U.current=e,ne.current=r,k.current!==null&&(window.clearTimeout(k.current),k.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(()=>{V.current===t&&(W.current(f),W.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else k.current=window.setTimeout(()=>{k.current=null,W.current(f),W.current({type:`tmux-check-copy-mode`,sessionId:e})},50);QT(`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&&QT(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(k.current!==null&&(window.clearTimeout(k.current),k.current=null),V.current=null,H.current=null,te.current=-1,U.current=null),()=>{k.current!==null&&(QT(`attach_debounce_cancelled`,{sessionId:e,attachedSession:V.current},`info`),window.clearTimeout(k.current),k.current=null)}},[e,t,r,i,a,_e]),(0,x.useEffect)(()=>{if(B.current!==null&&(globalThis.clearInterval(B.current),B.current=null),!(!e||!r||i!==`connected`))return B.current=globalThis.setInterval(()=>{V.current===e&&W.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{B.current!==null&&(globalThis.clearInterval(B.current),B.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{se.current!==null&&(window.clearTimeout(se.current),se.current=null),ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null);let e=_.current,t=oe.current;if(!e||t.length===0)return;oe.current=[];let n=t.join(``);le.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&QT(`switch_write_slow`,{sessionId:V.current,writeMs:e,bytes:i}),h&&e>50&&QT(`ios_write_slow`,{sessionId:V.current,writeMs:e,bytes:i}),_e()})},t=()=>{se.current!==null&&window.clearTimeout(se.current),se.current=window.setTimeout(e,2),ce.current===null&&(ce.current=window.setTimeout(e,16))},n=s(n=>{let r=V.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&QT(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:ne.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=ne.current;e&&(QT(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),ne.current=null),oe.current.push(h?DH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){le.current&&oe.current.length>0?e():le.current&&=(_.current?.reset(),!1),de(!1);let t=ne.current;t&&(QT(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),ne.current=null),U.current===n.sessionId&&(_.current?.focus(),U.current=null),h&&(e(),ge(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(le.current=!1,de(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!h&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{QT(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{QT(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),ee(e,n.source)})}else ee(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0,t=M.current;M.current=e,N.current=n.altScreen===!0,!t&&e&&_.current?.write(mH),ve(e?!1:n.inCopyMode)}});return()=>{n(),e(),he()}},[s,_e,ve,ee]),(0,x.useEffect)(()=>{let e=g.current,t=_.current,n=y.current;if(!e||!t||!n)return;let r=()=>{D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{be()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),D.current&&window.clearTimeout(D.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&QT(`terminal_visibility_resume`,{isiOS:h,hasWebGL:!!b.current,useWebGL:ae.current,hasTerminal:!!_.current,bufferLines:_.current?.buffer.active.length??0,sessionId:V.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!h)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=_.current;if(t&&b.current&&ae.current){try{b.current.dispose()}catch{}b.current=null;try{let n=new pz;n.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:V.current},`info`);try{n.dispose()}catch{}b.current=null}),t.loadAddon(n),b.current=n,QT(`ios_webgl_recreated`,{trigger:e},`info`)}catch{QT(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),ge(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),ge(200,`pageshow`))},i=()=>{t(`focus`),ge(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),he()}},[]),{containerRef:g,terminalRef:_,searchAddonRef:w,serializeAddonRef:T,progressAddonRef:E,inTmuxCopyModeRef:j,appMouseRef:M,setTmuxCopyMode:ve,isSwitching:ue,pendingClipboardOffer:I,copyPendingClipboardOffer:R,dismissPendingClipboardOffer:z}}function kH(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 AH(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 jH(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 MH({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 NH=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)})),PH={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`}},FH=new WeakSet;function IH(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 LH=!1,RH=null,zH=null;function BH(){LH||(LH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(RH=IH(Node.prototype,`textContent`),zH=IH(HTMLElement.prototype,`innerText`)))}function VH(e){if(FH.has(e))return;FH.add(e);let t=RH?.get;if(t)for(let[n,r]of[[`textContent`,RH],[`innerText`,zH]])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 HH(e){BH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&VH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}var UH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},WH=150,GH=250,KH=400,qH=1500,JH=15,YH=70;function XH(e=10){`vibrate`in navigator&&navigator.vibrate(e)}function ZH(e,t){let n=Math.sqrt(e*e+t*t);if(n<JH)return{direction:null,distance:0};let r=180/Math.PI*Math.atan2(t,e),i;return i=r>=-45&&r<45?`right`:r>=45&&r<135?`down`:r>=-135&&r<-45?`up`:`left`,{direction:i,distance:n}}function QH(e){let t=YH-20;return qH-Math.min(e/t,1)*(qH-KH)}function $H({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,d]=(0,x.useState)({x:0,y:0}),f=(0,x.useRef)(null),p=(0,x.useRef)(null),m=(0,x.useRef)(null),h=(0,x.useRef)(!1),g=(0,x.useRef)(null),_=(0,x.useRef)(0),v=(0,x.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null),p.current&&=(clearTimeout(p.current),null),m.current&&=(clearInterval(m.current),null)},[]),y=(0,x.useCallback)(()=>{p.current&&=(clearTimeout(p.current),null),m.current&&=(clearInterval(m.current),null)},[]),b=(0,x.useCallback)(t=>{let n=QH(_.current);m.current=setTimeout(()=>{g.current&&(XH(5),e(t),b(t))},n)},[e]),S=(0,x.useCallback)((n,r)=>{if(!n||t)return;let i=UH[n];_.current=r,XH(8),e(i),y(),p.current=setTimeout(()=>{b(i)},GH)},[t,e,y,b]),C=(0,x.useCallback)((e,t)=>{let n=e-c.x,r=t-c.y,i=Math.sqrt(n*n+r*r),a=Math.min(i,YH-20),o=i>0?a/i:0;d({x:n*o,y:r*o});let{direction:l,distance:u}=ZH(n,r);_.current=u,l!==g.current&&(g.current=l,s(l),y(),l&&S(l,u))},[c,y,S]),w=(0,x.useCallback)(()=>{a(!1),s(null),d({x:0,y:0}),y(),g.current=null,h.current&&n?.()},[y,n]),T=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];h.current=r?.()??!1,f.current=setTimeout(()=>{XH(15),l({x:n.clientX,y:n.clientY-80}),d({x:0,y:0}),a(!0)},WH)},[t,r]),E=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0];C(t.clientX,t.clientY)},[i,C]),D=(0,x.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),f.current&&=(clearTimeout(f.current),null),i&&w()},[i,w]),O=(0,x.useCallback)(e=>{e.preventDefault(),v(),w()},[v,w]);return(0,x.useEffect)(()=>()=>{v()},[v]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Arrow keys`,className:`
|
|
210
|
+
`,x=document.createElement(`div`),m.appendChild(x),D=document.createElement(`div`),D.style.color=`var(--text-muted)`,D.style.marginTop=`2px`,D.style.fontSize=`11px`,m.appendChild(D),C.current=m);let k=(e,t)=>{if(!r.element||!m||!x||!D)return;let n=uH(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;x.textContent=a,D.textContent=`${dH()?`⌘`:`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`},N=()=>{m&&(m.style.display=`none`)},F=null,I=!1,L=null,R={activate:(e,t)=>{if(!I&&(e.metaKey||e.ctrlKey)){let e=uH(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{F=uH(t)||null,k(e,t)},leave:()=>{F=null,N()}},z=e=>{F&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.stopPropagation(),I=!0,window.open(F,`_blank`,`noopener`),L&&clearTimeout(L),L=setTimeout(()=>{I=!1},100))};t.addEventListener(`mousedown`,z,!0),r.options.linkHandler=R;let B=new yz((e,t)=>R.activate(e,t),{urlRegex:oH,hover:(e,t)=>R.hover(e,t),leave:()=>R.leave()});r.loadAddon(B),S.current=B;let te=null,U=null,ne=dH()?`metaKey`:`ctrlKey`,W=(e,t)=>{t&&V.current===e&&H.current===e&&re.current({type:`terminal-input`,sessionId:e,data:t})};r.attachCustomKeyEventHandler(e=>{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(dH()&&!h&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`){let e=H.current;return e&&(j.current&&(re.current({type:`tmux-cancel-copy-mode`,sessionId:e}),ye(!1)),(async()=>{W(e,await vH(ie.current,{}))})()),!e}if(e[ne]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){U!==null&&(clearTimeout(U),U=null),te=null;let e=new Promise(e=>{U=setTimeout(()=>{U=null,te=null,e(null)},100),te=t=>{U!==null&&(clearTimeout(U),U=null),e(t)}});return(async()=>{try{let t=H.current;if(!t)return;let n=await e,r=n?.text??null;if(r===null)try{r=await navigator.clipboard.readText()}catch{r=``}if(n?.hasImage&&dH()&&!h){W(t,await vH(ie.current,{blob:n.imageBlob}));return}if(!r&&dH()&&!h)try{let e=await fetch(`/api/clipboard-file-path`);if(e.ok){let{path:n,isImage:r}=await e.json();if(n){if(r){W(t,await vH(ie.current,{path:n}));return}W(t,n);return}}}catch{}if(r&&!bH(r)){V.current===t&&H.current===t&&(j.current&&(re.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ye(!1)),re.current({type:`terminal-paste`,sessionId:t,data:r}));return}dH()&&!h&&W(t,await vH(ie.current,{}))}finally{te=null}})(),!1}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=H.current;return e&&re.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ae=e=>{if(!te)return;e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=SH(e.clipboardData),r=n!==null||xH(e.clipboardData),i=te;te=null,i({text:t,hasImage:r,imageBlob:n})};return t.addEventListener(`paste`,ae,{capture:!0}),r.onData(e=>{let t=H.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(j.current&&n)return;j.current&&(re.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ye(!1)),re.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=H.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;A.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(A.current)>=30;){c=!0;let e=A.current>0;A.current+=e?-30:30;let n=e?65:64;e||(s=!0),re.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!M.current&&ye(!0),c&&!M.current&&be(),!1}),_.current=r,y.current=i,()=>{if(n=!0,L&&clearTimeout(L),F=null,t.removeEventListener(`mousedown`,z,!0),t.removeEventListener(`paste`,ae,!0),U!==null&&(clearTimeout(U),U=null),te=null,C.current&&=(C.current.remove(),null),S.current){try{S.current.dispose()}catch{}S.current=null}if(b.current){try{b.current.dispose()}catch{}b.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),_.current=null,y.current=null,w.current=null,T.current=null,E.current=null,O.current&&window.clearTimeout(O.current),P.current!==null&&window.clearTimeout(P.current)}},[xe]),(0,x.useEffect)(()=>{_.current&&(_.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=_.current,t=y.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=V.current;n&&re.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=_.current;if(!e)return;let t=oe.current;if(oe.current=p,t!==p){if(p){if(!b.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}b.current=null}),e.loadAddon(t),b.current=t}catch{}}else if(b.current){try{b.current.dispose()}catch{}b.current=null}}},[p]),(0,x.useLayoutEffect)(()=>{(H.current!==e||!r||i!==`connected`||U.current>=0&&U.current!==a)&&(H.current=null,e&&r&&i===`connected`&&fe(!0))},[e,r,i,a]),(0,x.useEffect)(()=>{let n=_.current;if(!n)return;let o=V.current,s=te.current;if(!r){H.current=null,k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(re.current({type:`terminal-detach`,sessionId:o}),V.current=null,te.current=null,U.current=-1,ne.current=null,j.current=!1),n.reset(),ue.current=!1,fe(!1);return}if(i!==`connected`){H.current=null,k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(QT(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),V.current=null,te.current=null,U.current=-1,ne.current=null,j.current=!1),aH(),ue.current=!1,fe(!1);return}if(o&&o!==e){H.current=null;try{let e=T.current?.serialize();if(e&&(nH.set(o,e),nH.size>rH)){let e=nH.keys().next().value;e&&nH.delete(e)}}catch{}re.current({type:`terminal-detach`,sessionId:o}),V.current=null,te.current=null,U.current=-1,ne.current=null,j.current=!1}let c=U.current,l=a!==c;if(e&&(e!==o||t!==s||l)){QT(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();se.current=[],ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null),le.current!==null&&(window.clearTimeout(le.current),le.current=null),ue.current=!0,fe(!0),o!==null&&(H.current=null);let l=nH.get(e);l&&(n.reset(),n.write(l));let u=y.current;u&&u.fit();let d=performance.now();V.current=e,te.current=t??null,U.current=a,ne.current=e,W.current=r,k.current!==null&&(window.clearTimeout(k.current),k.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(()=>{V.current===t&&(re.current(f),re.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else k.current=window.setTimeout(()=>{k.current=null,re.current(f),re.current({type:`tmux-check-copy-mode`,sessionId:e})},50);QT(`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&&QT(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(k.current!==null&&(window.clearTimeout(k.current),k.current=null),V.current=null,te.current=null,U.current=-1,ne.current=null,H.current=null),()=>{k.current!==null&&(QT(`attach_debounce_cancelled`,{sessionId:e,attachedSession:V.current},`info`),window.clearTimeout(k.current),k.current=null)}},[e,t,r,i,a,ve]),(0,x.useEffect)(()=>{if(B.current!==null&&(globalThis.clearInterval(B.current),B.current=null),!(!e||!r||i!==`connected`))return B.current=globalThis.setInterval(()=>{V.current===e&&re.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{B.current!==null&&(globalThis.clearInterval(B.current),B.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null),le.current!==null&&(window.clearTimeout(le.current),le.current=null);let e=_.current,t=se.current;if(!e||t.length===0)return;se.current=[];let n=t.join(``);ue.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&QT(`switch_write_slow`,{sessionId:V.current,writeMs:e,bytes:i}),h&&e>50&&QT(`ios_write_slow`,{sessionId:V.current,writeMs:e,bytes:i}),ve()})},t=()=>{ce.current!==null&&window.clearTimeout(ce.current),ce.current=window.setTimeout(e,2),le.current===null&&(le.current=window.setTimeout(e,16))},n=s(n=>{let r=V.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&QT(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:W.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=W.current;e&&(QT(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),W.current=null),se.current.push(h?DH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){H.current=n.sessionId,ue.current&&se.current.length>0?e():ue.current&&=(_.current?.reset(),!1),fe(!1);let t=W.current;t&&(QT(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),W.current=null),ne.current===n.sessionId&&(_.current?.focus(),ne.current=null),h&&(e(),_e(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(H.current=null,ue.current=!1,fe(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!h&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{QT(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{QT(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),ee(e,n.source)})}else ee(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0,t=M.current;M.current=e,N.current=n.altScreen===!0,!t&&e&&_.current?.write(mH),ye(e?!1:n.inCopyMode)}});return()=>{n(),e(),ge()}},[s,ve,ye,ee]),(0,x.useEffect)(()=>{let e=g.current,t=_.current,n=y.current;if(!e||!t||!n)return;let r=()=>{D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{xe()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),D.current&&window.clearTimeout(D.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&QT(`terminal_visibility_resume`,{isiOS:h,hasWebGL:!!b.current,useWebGL:oe.current,hasTerminal:!!_.current,bufferLines:_.current?.buffer.active.length??0,sessionId:V.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!h)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=_.current;if(t&&b.current&&oe.current){try{b.current.dispose()}catch{}b.current=null;try{let n=new pz;n.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:V.current},`info`);try{n.dispose()}catch{}b.current=null}),t.loadAddon(n),b.current=n,QT(`ios_webgl_recreated`,{trigger:e},`info`)}catch{QT(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),_e(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),_e(200,`pageshow`))},i=()=>{t(`focus`),_e(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),ge()}},[]),{containerRef:g,terminalRef:_,searchAddonRef:w,serializeAddonRef:T,progressAddonRef:E,inTmuxCopyModeRef:j,appMouseRef:M,setTmuxCopyMode:ye,isSwitching:de,isInputReady:!!e&&r&&i===`connected`&&H.current===e,pendingClipboardOffer:I,copyPendingClipboardOffer:R,dismissPendingClipboardOffer:z}}function kH(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 AH(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 jH(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 MH({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 NH=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)})),PH={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`}},FH=new WeakSet;function IH(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 LH=!1,RH=null,zH=null;function BH(){LH||(LH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(RH=IH(Node.prototype,`textContent`),zH=IH(HTMLElement.prototype,`innerText`)))}function VH(e){if(FH.has(e))return;FH.add(e);let t=RH?.get;if(t)for(let[n,r]of[[`textContent`,RH],[`innerText`,zH]])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 HH(e){BH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&VH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}var UH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},WH=150,GH=250,KH=400,qH=1500,JH=15,YH=70;function XH(e=10){`vibrate`in navigator&&navigator.vibrate(e)}function ZH(e,t){let n=Math.sqrt(e*e+t*t);if(n<JH)return{direction:null,distance:0};let r=180/Math.PI*Math.atan2(t,e),i;return i=r>=-45&&r<45?`right`:r>=45&&r<135?`down`:r>=-135&&r<-45?`up`:`left`,{direction:i,distance:n}}function QH(e){let t=YH-20;return qH-Math.min(e/t,1)*(qH-KH)}function $H({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,d]=(0,x.useState)({x:0,y:0}),f=(0,x.useRef)(null),p=(0,x.useRef)(null),m=(0,x.useRef)(null),h=(0,x.useRef)(!1),g=(0,x.useRef)(null),_=(0,x.useRef)(0),v=(0,x.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null),p.current&&=(clearTimeout(p.current),null),m.current&&=(clearInterval(m.current),null)},[]),y=(0,x.useCallback)(()=>{p.current&&=(clearTimeout(p.current),null),m.current&&=(clearInterval(m.current),null)},[]),b=(0,x.useCallback)(t=>{let n=QH(_.current);m.current=setTimeout(()=>{g.current&&(XH(5),e(t),b(t))},n)},[e]),S=(0,x.useCallback)((n,r)=>{if(!n||t)return;let i=UH[n];_.current=r,XH(8),e(i),y(),p.current=setTimeout(()=>{b(i)},GH)},[t,e,y,b]),C=(0,x.useCallback)((e,t)=>{let n=e-c.x,r=t-c.y,i=Math.sqrt(n*n+r*r),a=Math.min(i,YH-20),o=i>0?a/i:0;d({x:n*o,y:r*o});let{direction:l,distance:u}=ZH(n,r);_.current=u,l!==g.current&&(g.current=l,s(l),y(),l&&S(l,u))},[c,y,S]),w=(0,x.useCallback)(()=>{a(!1),s(null),d({x:0,y:0}),y(),g.current=null,h.current&&n?.()},[y,n]),T=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];h.current=r?.()??!1,f.current=setTimeout(()=>{XH(15),l({x:n.clientX,y:n.clientY-80}),d({x:0,y:0}),a(!0)},WH)},[t,r]),E=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0];C(t.clientX,t.clientY)},[i,C]),D=(0,x.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),f.current&&=(clearTimeout(f.current),null),i&&w()},[i,w]),O=(0,x.useCallback)(e=>{e.preventDefault(),v(),w()},[v,w]);return(0,x.useEffect)(()=>()=>{v()},[v]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Arrow keys`,className:`
|
|
211
211
|
terminal-key
|
|
212
212
|
flex items-center justify-center
|
|
213
213
|
size-[44px] p-0
|
|
@@ -314,11 +314,11 @@ ${s.join(`
|
|
|
314
314
|
select-none touch-manipulation
|
|
315
315
|
text-secondary
|
|
316
316
|
${n?`opacity-50`:``}
|
|
317
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchStart:I(P),onClick:L(P),disabled:n,children:mU})]}),d&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,G.jsxs)(`div`,{ref:C,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,G.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,G.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),_?(0,G.jsx)(`div`,{className:`w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary`,children:`Uploading image...`}):(0,G.jsx)(`input`,{ref:S,type:`text`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),j()):e.key===`Escape`&&(e.preventDefault(),M())},placeholder:`Paste here...`,className:`w-full h-11 px-3 text-[16px] bg-surface border border-border rounded-md text-primary placeholder:text-muted outline-none focus:border-accent`,style:{fontSize:`16px`}}),h&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:h}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M,className:`px-4 py-2 text-sm font-medium text-secondary bg-surface border border-border rounded-md active:scale-95 transition-transform`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:j,disabled:_,className:`px-4 py-2 text-sm font-medium bg-accent text-white rounded-md active:scale-95 transition-transform disabled:opacity-50`,children:`Send`})]})]})})]})}function SU({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=fd(),_=(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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,G.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,G.jsx)(KT,{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,G.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,G.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var CU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},wU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},TU={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`},EU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function DU(){`vibrate`in navigator&&navigator.vibrate(10)}function OU({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=PH[NH(e=>e.theme)],C=U(e=>e.useWebGL),w=U(e=>e.fontSize),T=U(e=>e.lineHeight),E=U(e=>e.letterSpacing),D=ee(U(e=>e.fontOption),U(e=>e.customFontFamily)),O=Je(Ke(U(e=>e.shortcutModifier))),k=Ue(),A=kH(),[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),[V,H]=(0,x.useState)(!1),[te,ne]=(0,x.useState)(``),W=(0,x.useRef)(!1),re=(0,x.useRef)(null),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=e?.remote===!0,le=Km(e=>e.remoteAllowControl),de=Km(e=>e.remoteAllowAttach),fe=Km(e=>e.preferWindowName),pe=ce&&!de,he=!ce||le&&e?.source===`managed`,_e=n?n.displayName||Fm(n.projectPath)||n.sessionId.slice(0,8):``,ve=n?Fm(n.projectPath):``,ye=n?Pm(n.lastActivityAt):``,be=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:xe,terminalRef:Se,inTmuxCopyModeRef:Ce,appMouseRef:Te,setTmuxCopyMode:De,isSwitching:Oe,pendingClipboardOffer:ke,copyPendingClipboardOffer:Ae,dismissPendingClipboardOffer:je}=OH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,allowAttach:!pe,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),Ne=(0,x.useCallback)(()=>{!e||pe||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1),Se.current?.scrollToBottom())},[e,pe,s,De,Se]),Pe=(0,x.useCallback)(()=>{B(!0),DU()},[]),Fe=MH({enabled:A||k,isOpen:z,onOpen:Pe});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),AH(ae,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{V&&oe.current&&(oe.current.focus(),oe.current.select())},[V]),(0,x.useEffect)(()=>{F&&se.current&&se.current.focus()},[F]),jH(F,(0,x.useCallback)(()=>I(!1),[]));let Le=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Re=()=>{!e||!be||(g?.(e.agentSessionId.trim()),R(!1))},ze=()=>{e&&(ne(e.agentSessionName||e.name),H(!0),R(!1))},Be=()=>{if(!e)return;let t=te.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),H(!1)},Ve=e=>{e.key===`Enter`?(e.preventDefault(),Be()):e.key===`Escape`&&(e.preventDefault(),H(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=xe.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=()=>{W.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Se.current?.clearSelection(),r(),P(!1)};re.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){W.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&W.current){i();return}W.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),re.current=null,W.current=!1}},[xe,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=xe.current;if(!t)return;let n=null,r=()=>{let e=Se.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||=HH(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&&QT(`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?.()}},[xe,w,k,e?.id,Se]);let We=(0,x.useRef)(N);(0,x.useEffect)(()=>{We.current=N},[N]);let Ge=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Ge.current=e?.id},[e?.id]);let qe=(0,x.useRef)(s);(0,x.useEffect)(()=>{qe.current=s},[s]);let Ye=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=xe.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=Se.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(Ce.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=Ge.current;return r?(qe.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Ge.current;if(!t||e===0)return!1;let n=Se.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++)qe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Te.current&&De(!0),l},E=e=>{let t=Ge.current,n=g(e);return!t||!n?!1:(qe.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||!Te.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),DU(),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||!W.current||N()||re.current?.()},F=e=>{if(b(),P(),Fe.current||z){M();return}if(We.current){M();return}if(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&&Te.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Fe.current||z)&&(We.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Fe.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(We.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(),Fe.current||z)return;let a=N();if(We.current&&!a&&re.current?.(),We.current||a){Ce.current&&(Ye.current=!0);return}if(!i){if(k&&n>=350)return;if(Te.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Ce.current){e.preventDefault(),e.stopPropagation(),Ye.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=>{Ye.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},V={passive:!1,capture:!0},H={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,V),t.addEventListener(`mousedown`,ee,H),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,V),t.removeEventListener(`mousedown`,ee,H),x();let e=h();e&&(e.disabled=!1)}},[e?.id,xe,Se,k,A,z,w,T]);let Xe=(0,x.useCallback)(t=>{!e||pe||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,pe,s]),Ze=(0,x.useCallback)(t=>{!e||pe||(Ce.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,pe,s,Ce,De]),Qe=(0,x.useCallback)(()=>{let e=xe.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[xe]),$e=(0,x.useCallback)(()=>{if(!e||pe)return;Ce.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1));let t=xe.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,pe,s,xe,Ce,De]),et=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=xe.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`)},[xe]);(0,x.useEffect)(()=>{if(!k)return;let e=xe.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&&!We.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)}},[xe,k,N]),(0,x.useEffect)(()=>{let e=xe.current;e&&(e.inert=!!n)},[xe,n]);let tt=(0,x.useMemo)(()=>{if(!fe||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},[fe,t]);return(0,G.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`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,G.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,G.jsx)(we,{width:16,height:16})}),e&&he&&(0,G.jsx)(`button`,{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`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,G.jsx)(He,{width:16,height:16})}),be&&(0,G.jsx)(`button`,{onClick:Re,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,G.jsx)(Ee,{width:16,height:16})}),e?(0,G.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:[V?(0,G.jsx)(`input`,{ref:oe,type:`text`,value:te,onChange:e=>ne(e.target.value),onBlur:Be,onKeyDown:Ve,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,G.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?wU[e.status]:`text-approval`}`,children:a===`connected`?CU[e.status]:a}),(0,G.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${wU[e.status]}`,children:CU[e.status]})]}):n?(0,G.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,G.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:_e}),(0,G.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,G.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,G.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,G.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,G.jsx)(Me,{width:16,height:16})}),e&&he&&(0,G.jsx)(`button`,{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 md:hidden`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,G.jsx)(He,{width:16,height:16})}),be&&(0,G.jsx)(`button`,{onClick:Re,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,G.jsx)(Ee,{width:16,height:16})}),n&&(0,G.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,G.jsxs)(`div`,{className:`relative md:hidden`,ref:ae,children:[(0,G.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,G.jsx)(me,{width:16,height:16})}),L&&(0,G.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:[he&&(0,G.jsxs)(`button`,{onClick:ze,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,G.jsx)(ge,{width:14,height:14}),`Rename`]}),be&&(0,G.jsxs)(`button`,{onClick:Re,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,G.jsx)(Ee,{width:14,height:14}),`Hibernate`]}),(0,G.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,G.jsx)(Ie,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,G.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,G.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,G.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=tt?t.name.trim():n+1;return(0,G.jsx)(`button`,{type:`button`,className:`
|
|
317
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchStart:I(P),onClick:L(P),disabled:n,children:mU})]}),d&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,G.jsxs)(`div`,{ref:C,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,G.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,G.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),_?(0,G.jsx)(`div`,{className:`w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary`,children:`Uploading image...`}):(0,G.jsx)(`input`,{ref:S,type:`text`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),j()):e.key===`Escape`&&(e.preventDefault(),M())},placeholder:`Paste here...`,className:`w-full h-11 px-3 text-[16px] bg-surface border border-border rounded-md text-primary placeholder:text-muted outline-none focus:border-accent`,style:{fontSize:`16px`}}),h&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:h}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M,className:`px-4 py-2 text-sm font-medium text-secondary bg-surface border border-border rounded-md active:scale-95 transition-transform`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:j,disabled:_,className:`px-4 py-2 text-sm font-medium bg-accent text-white rounded-md active:scale-95 transition-transform disabled:opacity-50`,children:`Send`})]})]})})]})}function SU({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=fd(),_=(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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,G.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,G.jsx)(KT,{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,G.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,G.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var CU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},wU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},TU={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`},EU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function DU(){`vibrate`in navigator&&navigator.vibrate(10)}function OU({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=PH[NH(e=>e.theme)],C=U(e=>e.useWebGL),w=U(e=>e.fontSize),T=U(e=>e.lineHeight),E=U(e=>e.letterSpacing),D=ee(U(e=>e.fontOption),U(e=>e.customFontFamily)),O=Je(Ke(U(e=>e.shortcutModifier))),k=Ue(),A=kH(),[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),[V,H]=(0,x.useState)(!1),[te,ne]=(0,x.useState)(``),W=(0,x.useRef)(!1),re=(0,x.useRef)(null),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=e?.remote===!0,le=Km(e=>e.remoteAllowControl),de=Km(e=>e.remoteAllowAttach),fe=Km(e=>e.preferWindowName),pe=ce&&!de,he=!ce||le&&e?.source===`managed`,_e=n?n.displayName||Fm(n.projectPath)||n.sessionId.slice(0,8):``,ve=n?Fm(n.projectPath):``,ye=n?Pm(n.lastActivityAt):``,be=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:xe,terminalRef:Se,inTmuxCopyModeRef:Ce,appMouseRef:Te,setTmuxCopyMode:De,isSwitching:Oe,isInputReady:ke,pendingClipboardOffer:Ae,copyPendingClipboardOffer:je,dismissPendingClipboardOffer:Ne}=OH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,allowAttach:!pe,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),Pe=(0,x.useCallback)(()=>{!e||pe||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1),Se.current?.scrollToBottom())},[e,pe,s,De,Se]),Fe=(0,x.useCallback)(()=>{B(!0),DU()},[]),Le=MH({enabled:A||k,isOpen:z,onOpen:Fe});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),AH(ae,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{V&&oe.current&&(oe.current.focus(),oe.current.select())},[V]),(0,x.useEffect)(()=>{F&&se.current&&se.current.focus()},[F]),jH(F,(0,x.useCallback)(()=>I(!1),[]));let Re=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},ze=()=>{!e||!be||(g?.(e.agentSessionId.trim()),R(!1))},Be=()=>{e&&(ne(e.agentSessionName||e.name),H(!0),R(!1))},Ve=()=>{if(!e)return;let t=te.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),H(!1)},We=e=>{e.key===`Enter`?(e.preventDefault(),Ve()):e.key===`Escape`&&(e.preventDefault(),H(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=xe.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=()=>{W.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Se.current?.clearSelection(),r(),P(!1)};re.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){W.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&W.current){i();return}W.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),re.current=null,W.current=!1}},[xe,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=xe.current;if(!t)return;let n=null,r=()=>{let e=Se.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||=HH(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&&QT(`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?.()}},[xe,w,k,e?.id,Se]);let Ge=(0,x.useRef)(N);(0,x.useEffect)(()=>{Ge.current=N},[N]);let qe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{qe.current=e?.id},[e?.id]);let Ye=(0,x.useRef)(s);(0,x.useEffect)(()=>{Ye.current=s},[s]);let Xe=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=xe.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=Se.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(Ce.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?(Ye.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=Se.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++)Ye.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Te.current&&De(!0),l},E=e=>{let t=qe.current,n=g(e);return!t||!n?!1:(Ye.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||!Te.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),DU(),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||!W.current||N()||re.current?.()},F=e=>{if(b(),P(),Le.current||z){M();return}if(Ge.current){M();return}if(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&&Te.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Le.current||z)&&(Ge.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Le.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(Ge.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(),Le.current||z)return;let a=N();if(Ge.current&&!a&&re.current?.(),Ge.current||a){Ce.current&&(Xe.current=!0);return}if(!i){if(k&&n>=350)return;if(Te.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Ce.current){e.preventDefault(),e.stopPropagation(),Xe.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=>{Xe.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},V={passive:!1,capture:!0},H={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,V),t.addEventListener(`mousedown`,ee,H),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,V),t.removeEventListener(`mousedown`,ee,H),x();let e=h();e&&(e.disabled=!1)}},[e?.id,xe,Se,k,A,z,w,T]);let Ze=(0,x.useCallback)(t=>{!e||pe||!ke||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,pe,ke,s]),Qe=(0,x.useCallback)(t=>{!e||pe||!ke||(Ce.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,pe,ke,s,Ce,De]),$e=(0,x.useCallback)(()=>{let e=xe.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[xe]),et=(0,x.useCallback)(()=>{if(!e||pe||!ke)return;Ce.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),De(!1));let t=xe.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,pe,ke,s,xe,Ce,De]),tt=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=xe.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`)},[xe]);(0,x.useEffect)(()=>{if(!k)return;let e=xe.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&&!Ge.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)}},[xe,k,N]),(0,x.useEffect)(()=>{let e=xe.current;e&&(e.inert=!!n)},[xe,n]);let nt=(0,x.useMemo)(()=>{if(!fe||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},[fe,t]);return(0,G.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`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,G.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,G.jsx)(we,{width:16,height:16})}),e&&he&&(0,G.jsx)(`button`,{disabled:Oe,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,G.jsx)(He,{width:16,height:16})}),be&&(0,G.jsx)(`button`,{onClick:ze,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,G.jsx)(Ee,{width:16,height:16})}),e?(0,G.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:[V?(0,G.jsx)(`input`,{ref:oe,type:`text`,value:te,onChange:e=>ne(e.target.value),onBlur:Ve,onKeyDown:We,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,G.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?wU[e.status]:`text-approval`}`,children:a===`connected`?CU[e.status]:a}),(0,G.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${wU[e.status]}`,children:CU[e.status]})]}):n?(0,G.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,G.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:_e}),(0,G.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,G.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,G.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,G.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,G.jsx)(Me,{width:16,height:16})}),e&&he&&(0,G.jsx)(`button`,{disabled:Oe,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,G.jsx)(He,{width:16,height:16})}),be&&(0,G.jsx)(`button`,{onClick:ze,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,G.jsx)(Ee,{width:16,height:16})}),n&&(0,G.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,G.jsxs)(`div`,{className:`relative md:hidden`,ref:ae,children:[(0,G.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,G.jsx)(me,{width:16,height:16})}),L&&(0,G.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:[he&&(0,G.jsxs)(`button`,{onClick:Be,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,G.jsx)(ge,{width:14,height:14}),`Rename`]}),be&&(0,G.jsxs)(`button`,{onClick:ze,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,G.jsx)(Ee,{width:14,height:14}),`Hibernate`]}),(0,G.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,G.jsx)(Ie,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,G.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,G.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,G.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=nt?t.name.trim():n+1;return(0,G.jsx)(`button`,{type:`button`,className:`
|
|
318
318
|
flex items-center justify-center shrink-0 snap-start
|
|
319
|
-
h-[44px] ${
|
|
319
|
+
h-[44px] ${nt?`min-w-[44px] px-2.5 max-w-[8rem] truncate`:`w-[44px]`}
|
|
320
320
|
text-sm font-extrabold rounded-lg
|
|
321
321
|
active:scale-95 transition-all duration-75
|
|
322
322
|
select-none touch-manipulation
|
|
323
323
|
${r?EU[t.status]:TU[t.status]}
|
|
324
|
-
`,onClick:()=>{DU(),u(t.id)},title:tt?t.name:void 0,children:i},t.id)})})]}),(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(`div`,{ref:xe,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Oe&&e&&(0,G.jsxs)(`div`,{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,G.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,G.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,G.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),ke&&e&&(0,G.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,G.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,G.jsxs)(`button`,{type:`button`,onClick:Ae,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,G.jsx)(ue,{width:14,height:14}),`Copy`]}),(0,G.jsx)(`button`,{type:`button`,onClick:je,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,G.jsx)(He,{width:14,height:14})})]}),!e&&(0,G.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&&pe&&(0,G.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,G.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,G.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,G.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:_e}),(0,G.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`}),ve&&(0,G.jsx)(`span`,{className:`text-muted`,children:ve}),(0,G.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,ye]})]}),n.lastResumeError&&(0,G.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,G.jsx)(ie,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,G.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,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,G.jsx)(VT,{session:n})]})}),j&&e&&!N&&(0,G.jsxs)(`button`,{onClick:Ne,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,G.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,G.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,G.jsx)(xU,{onSendKey:Xe,onPasteText:Ze,disabled:a!==`connected`||pe,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:Qe,isKeyboardVisible:et,onEnterTextMode:$e}),(A||k)&&(0,G.jsx)(SU,{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,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,G.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,G.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,G.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,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,G.jsx)(`button`,{ref:se,onClick:Le,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=U(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,G.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,G.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,G.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,G.jsx)(`p`,{className:`text-danger`,children:s}),(0,G.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,G.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,G.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,G.jsx)(be,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,G.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,G.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,G.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,G.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,G.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function AU({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=>V(e)===t);e?(v(e.id),b(V(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(V(e))):i.length>0?(v(i[0].id),b(V(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(V(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,G.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,G.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,G.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,G.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,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,G.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,G.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,G.jsx)($m,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,G.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.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,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,G.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,G.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 MU={};function NU(e,t){let n=x.useRef(MU);return n.current===MU&&(n.current=e(t)),n}var PU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],FU=PU&&PU!==x.useLayoutEffect?PU:e=>e();function IU(e){let t=NU(LU).current;return t.next=e,FU(t.effect),t.trampoline}function LU(){let e={next:void 0,callback:RU,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function RU(){}function zU(e,t,n,r){let i=NU(VU).current;return HU(i,e,t,n,r)&&WU(i,[e,t,n,r]),i.callback}function BU(e){let t=NU(VU).current;return UU(t,e)&&WU(t,e),t.callback}function VU(){return{callback:null,cleanup:null,refs:[]}}function HU(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function UU(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function WU(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 GU=typeof document<`u`?x.useLayoutEffect:()=>{},KU={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},qU={...KU,position:`fixed`,top:0,left:0},JU={...KU,position:`absolute`};function YU(){}Object.freeze([]);var XU=Object.freeze({});function ZU(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 QU=18;function $U(e){return QU>=e}function eW(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return($U(19)?n?.ref:t.ref)??null}function tW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function nW(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 rW(e,t){return typeof e==`function`?e(t):e}function iW(e,t){return typeof e==`function`?e(t):e}var aW={};function oW(e,t,n,r,i){let a={...fW(e,aW)};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 aW;if(e.length===1)return fW(e[0],aW);let t={...fW(e[0],aW)};for(let n=1;n<e.length;n+=1)t=cW(t,e[n]);return t}function cW(e,t){return dW(t)?t(e):lW(e,t)}function lW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=tW(e.style,r);break;case`className`:e[n]=hW(e.className,r);break;default:uW(n,r)?e[n]=pW(e[n],r):e[n]=r}}return e}function uW(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 dW(e){return typeof e==`function`}function fW(e,t){return dW(e)?e(t):e??aW}function pW(e,t){return t?e?n=>{if(gW(n)){let r=n;mW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function mW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function hW(e,t){return t?e?t+` `+e:t:e}function gW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function _W(e,t,n={}){let r=t.render,i=vW(t,n);return n.enabled===!1?null:bW(e,r,i,n.state??XU)}function vW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=XU,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?rW(n,a):void 0,d=l?iW(r,a):void 0,f=l?nW(a,c):XU,p=l?tW(f,Array.isArray(s)?sW(s):s)??XU:XU;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=BU([p.ref,eW(i),...o]):p.ref=zU(p.ref,eW(i),o):zU(null,null)),l?(u!==void 0&&(p.className=hW(p.className,u)),d!==void 0&&(p.style=tW(p.style,d)),p):XU}var yW=Symbol.for(`react.lazy`);function bW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=oW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===yW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return xW(e,n);throw Error(ZU(8))}function xW(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 SW={...x},CW=0;function wW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(CW+=1,r(`${t}-${CW}`))},[n,t]),i}var TW=SW.useId;function EW(e,t){if(TW!==void 0){let n=TW();return e??(t?`${t}-${n}`:n)}return wW(e,t)}function DW(e){return EW(e,`base-ui`)}function OW(){return typeof window<`u`}function kW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function AW(e){return OW()?e instanceof Element||e instanceof kW(e).Element:!1}function jW(e){return OW()?e instanceof HTMLElement||e instanceof kW(e).HTMLElement:!1}function MW(e){return!OW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof kW(e).ShadowRoot}var NW=x.createContext(void 0);function PW(e=!1){let t=x.useContext(NW);if(t===void 0&&!e)throw Error(ZU(16));return t}function FW(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 IW(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=PW(!0)!==void 0,s=IU(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=FW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;LW(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return GU(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return oW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(mW(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||(mW(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:IU(e=>{a.current=e,l()})}}function LW(e){return jW(e)&&e.tagName===`BUTTON`}var RW=x.createContext(void 0);function zW(){let e=x.useContext(RW);if(e===void 0)throw Error(ZU(63));return e}var BW=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}({}),VW={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},HW={valid(e){return e===null?null:e?{[BW.valid]:``}:{[BW.invalid]:``}}},UW=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}({}),WW={...HW,checked(e){return e?{[UW.checked]:``}:{[UW.unchecked]:``}}};function GW(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var KW=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:YU,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function qW(){return x.useContext(KW)}var JW=x.createContext({invalid:void 0,name:void 0,validityData:{state:VW,errors:[],error:``,value:``,initialValue:null},setValidityData:YU,disabled:void 0,touched:!1,setTouched:YU,dirty:!1,setDirty:YU,filled:!1,setFilled:YU,focused:!1,setFocused:YU,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=XU)=>e,getInputValidationProps:(e=XU)=>e,inputRef:{current:null},commit:async()=>{}}});function YW(e=!0){let t=x.useContext(JW);if(t.setValidityData===YU&&!e)throw Error(ZU(28));return t}function XW(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=qW(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=YW(),f=IU(e.getValue);GU(()=>{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]),GU(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:GW(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?W.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),GU(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var ZW=x.createContext({controlId:void 0,registerControlId:YU,labelId:void 0,setLabelId:YU,messageIds:[],setMessageIds:YU,getDescriptionProps:e=>e});function QW(){return x.useContext(ZW)}function $W(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=QW(),o=DW(t),s=n?i:void 0,c=NU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=IU(()=>{!l.current||a===YU||(l.current=!1,a(c.current,void 0))});return GU(()=>{if(a===YU)return;let e;if(n){let n=r?.current;e=AW(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 eG=`none`;function tG(e,t,n,r){let i=!1,a=!1,o=r??XU;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 nG(e,t){let n=x.useRef(e),r=IU(t);GU(()=>{n.current!==e&&r(n.current)},[e,r]),GU(()=>{n.current=e},[e])}var rG=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:_}=qW(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=YW(),{labelId:A}=QW(),j=D||f,M=O??s,N=IU(l),P=x.useRef(null),F=zU(P,o,k.inputRef),I=x.useRef(null),L=DW(),ee=$W({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=jU({controlled:n,default:!!i,name:`Switch`,state:`checked`});XW({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),GU(()=>{P.current&&C(P.current.checked)},[P,C]),nG(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:V,buttonRef:H}=IW({disabled:j,native:c}),te={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})))}},U=x.useMemo(()=>oW({checked:z,disabled:j,id:R,name:M,required:d,style:M?JU:qU,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=tG(eG,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?XU:{value:h}),[z,j,F,R,M,N,d,B,k,h]),ne=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),W=_W(`span`,e,{state:ne,ref:[t,I,H],props:[te,k.getValidationProps,g,V],stateAttributesMapping:WW});return(0,G.jsxs)(RW.Provider,{value:ne,children:[W,!z&&M&&m!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,G.jsx)(`input`,{...U})]})}),iG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=YW(),o=zW();return _W(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:WW,props:i})});function aG(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=aG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function oG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=aG(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}),lG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),uG=`-`,dG=[],fG=`arbitrary..`,pG=e=>{let t=gG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return hG(e);let n=e.split(uG);return mG(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||dG}return n[e]||dG}}},mG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=mG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(uG):e.slice(t).join(uG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},hG=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?fG+r:void 0})(),gG=e=>{let{theme:t,classGroups:n}=e;return _G(n,t)},_G=(e,t)=>{let n=lG();for(let r in e){let i=e[r];vG(i,n,r,t)}return n},vG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];yG(i,t,n,r)}},yG=(e,t,n,r)=>{if(typeof e==`string`){bG(e,t,n);return}if(typeof e==`function`){xG(e,t,n,r);return}SG(e,t,n,r)},bG=(e,t,n)=>{let r=e===``?t:CG(t,e);r.classGroupId=n},xG=(e,t,n,r)=>{if(wG(e)){vG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(cG(n,e))},SG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];vG(o,CG(t,a),n,r)}},CG=(e,t)=>{let n=e,r=t.split(uG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=lG(),n.nextPart.set(t,i)),n=i}return n},wG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,TG=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)}}},EG=`!`,DG=`:`,OG=[],kG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),AG=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===DG){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(EG)?(c=s.slice(0,-1),l=!0):s.startsWith(EG)&&(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+DG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):kG(OG,!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}},MG=e=>({cache:TG(e.cacheSize),parseClassName:AG(e),sortModifiers:jG(e),...pG(e)}),NG=/\s+/,PG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(NG),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+EG: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},FG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=IG(n))&&(i&&(i+=` `),i+=r);return i},IG=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=IG(e[r]))&&(n&&(n+=` `),n+=t);return n},LG=(e,...t)=>{let n,r,i,a,o=o=>(n=MG(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=PG(e,n);return i(e,a),a};return a=o,(...e)=>a(FG(...e))},RG=[],zG=e=>{let t=t=>t[e]||RG;return t.isThemeGetter=!0,t},BG=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,VG=/^\((?:(\w[\w-]*):)?(.+)\)$/i,HG=/^\d+\/\d+$/,UG=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WG=/\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$/,GG=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,KG=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,qG=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,JG=e=>HG.test(e),YG=e=>!!e&&!Number.isNaN(Number(e)),XG=e=>!!e&&Number.isInteger(Number(e)),ZG=e=>e.endsWith(`%`)&&YG(e.slice(0,-1)),QG=e=>UG.test(e),$G=()=>!0,eK=e=>WG.test(e)&&!GG.test(e),tK=()=>!1,nK=e=>KG.test(e),rK=e=>qG.test(e),iK=e=>!Q(e)&&!$(e),aK=e=>_K(e,xK,tK),Q=e=>BG.test(e),oK=e=>_K(e,SK,eK),sK=e=>_K(e,CK,YG),cK=e=>_K(e,yK,tK),lK=e=>_K(e,bK,rK),uK=e=>_K(e,TK,nK),$=e=>VG.test(e),dK=e=>vK(e,SK),fK=e=>vK(e,wK),pK=e=>vK(e,yK),mK=e=>vK(e,xK),hK=e=>vK(e,bK),gK=e=>vK(e,TK,!0),_K=(e,t,n)=>{let r=BG.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},vK=(e,t,n=!1)=>{let r=VG.exec(e);return r?r[1]?t(r[1]):n:!1},yK=e=>e===`position`||e===`percentage`,bK=e=>e===`image`||e===`url`,xK=e=>e===`length`||e===`size`||e===`bg-size`,SK=e=>e===`length`,CK=e=>e===`number`,wK=e=>e===`family-name`,TK=e=>e===`shadow`,EK=LG(()=>{let e=zG(`color`),t=zG(`font`),n=zG(`text`),r=zG(`font-weight`),i=zG(`tracking`),a=zG(`leading`),o=zG(`breakpoint`),s=zG(`container`),c=zG(`spacing`),l=zG(`radius`),u=zG(`shadow`),d=zG(`inset-shadow`),f=zG(`text-shadow`),p=zG(`drop-shadow`),m=zG(`blur`),h=zG(`perspective`),g=zG(`aspect`),_=zG(`ease`),v=zG(`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=()=>[JG,`full`,`auto`,...w()],E=()=>[XG,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,XG,$,Q]},XG,$,Q],O=()=>[XG,`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=()=>[JG,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),pK,cK,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,mK,aK,{size:[$,Q]}],ee=()=>[ZG,dK,oK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,YG,dK,oK],B=()=>[`solid`,`dashed`,`dotted`,`double`],V=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],H=()=>[YG,ZG,pK,cK],te=()=>[``,`none`,m,$,Q],U=()=>[`none`,YG,$,Q],ne=()=>[`none`,YG,$,Q],W=()=>[YG,$,Q],re=()=>[JG,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[QG],breakpoint:[QG],color:[$G],container:[QG],"drop-shadow":[QG],ease:[`in`,`out`,`in-out`],font:[iK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[QG],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[QG],shadow:[QG],spacing:[`px`,YG],text:[QG],"text-shadow":[QG],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,JG,Q,$,g]}],container:[`container`],columns:[{columns:[YG,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:[XG,`auto`,$,Q]}],basis:[{basis:[JG,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[YG,JG,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,YG,$,Q]}],shrink:[{shrink:[``,YG,$,Q]}],order:[{order:[XG,`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,dK,oK]}],"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`,ZG,Q]}],"font-family":[{font:[fK,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":[YG,`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:[YG,`from-font`,`auto`,$,oK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[YG,`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`]},XG,$,Q],radial:[``,$,Q],conic:[XG,$,Q]},hK,lK]}],"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":[YG,$,Q]}],"outline-w":[{outline:[``,YG,dK,oK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,gK,uK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,gK,uK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[YG,oK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,gK,uK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[YG,$,Q]}],"mix-blend":[{"mix-blend":[...V(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":V()}],"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":[YG]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"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":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"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":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"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":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"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":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"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":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"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":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"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":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"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":[YG]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"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:te()}],brightness:[{brightness:[YG,$,Q]}],contrast:[{contrast:[YG,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,gK,uK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,YG,$,Q]}],"hue-rotate":[{"hue-rotate":[YG,$,Q]}],invert:[{invert:[``,YG,$,Q]}],saturate:[{saturate:[YG,$,Q]}],sepia:[{sepia:[``,YG,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[YG,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[YG,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,YG,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[YG,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,YG,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[YG,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[YG,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,YG,$,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:[YG,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[YG,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:U()}],"rotate-x":[{"rotate-x":U()}],"rotate-y":[{"rotate-y":U()}],"rotate-z":[{"rotate-z":U()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":[`scale-3d`],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:re()}],"translate-x":[{"translate-x":re()}],"translate-y":[{"translate-y":re()}],"translate-z":[{"translate-z":re()}],"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:[YG,dK,oK,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 DK(...e){return EK(oG(e))}function OK({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,G.jsx)(rG,{checked:e,onCheckedChange:t,disabled:n,className:DK(`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,G.jsx)(iG,{className:DK(`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,AK=!1,jK={},MK=500;function NK(){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 PK(){kK&&=(kK.close().catch(()=>{}),null),NK()}function FK(){return AK}function IK(){kK&&(PK(),AK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&IK()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&IK()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&IK(),e=t},5e3)}async function LK(){let e=NK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),AK=!1}async function RK(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function zK(e){let t=NK();if(!t||(await RK(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 BK(){let e=Date.now();if(!(e-(jK.permission||0)<MK)){jK.permission=e;try{await zK({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function VK(){let e=Date.now();if(!(e-(jK.idle||0)<MK)){jK.idle=e;try{await zK({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function HK({isOpen:e,onClose:t}){let n=U(e=>e.defaultProjectDir),r=U(e=>e.setDefaultProjectDir),i=U(e=>e.commandPresets),a=U(e=>e.setCommandPresets),o=U(e=>e.defaultPresetId),s=U(e=>e.setDefaultPresetId),c=U(e=>e.sessionSortMode),l=U(e=>e.setSessionSortMode),u=U(e=>e.sessionSortDirection),d=U(e=>e.setSessionSortDirection),f=U(e=>e.useWebGL),p=U(e=>e.setUseWebGL),m=U(e=>e.fontSize),h=U(e=>e.setFontSize),g=U(e=>e.lineHeight),_=U(e=>e.setLineHeight),v=U(e=>e.letterSpacing),y=U(e=>e.setLetterSpacing),b=U(e=>e.fontOption),S=U(e=>e.setFontOption),C=U(e=>e.customFontFamily),w=U(e=>e.setCustomFontFamily),T=U(e=>e.shortcutModifier),E=U(e=>e.setShortcutModifier),D=U(e=>e.showProjectName),O=U(e=>e.setShowProjectName),k=U(e=>e.showLastUserMessage),A=U(e=>e.setShowLastUserMessage),j=U(e=>e.showSessionIdPrefix),M=U(e=>e.setShowSessionIdPrefix),N=NH(e=>e.theme),F=NH(e=>e.setTheme),I=U(e=>e.soundOnPermission),ee=U(e=>e.setSoundOnPermission),R=U(e=>e.soundOnIdle),z=U(e=>e.setSoundOnIdle),[B,V]=(0,x.useState)(n),[H,te]=(0,x.useState)(i),[ne,W]=(0,x.useState)(o),[re,ie]=(0,x.useState)(c),[ae,oe]=(0,x.useState)(u),[se,ce]=(0,x.useState)(f),[le,ue]=(0,x.useState)(m),[de,fe]=(0,x.useState)(g),[pe,me]=(0,x.useState)(v),[he,ge]=(0,x.useState)(b),[_e,ve]=(0,x.useState)(C),[ye,be]=(0,x.useState)(T),[xe,Se]=(0,x.useState)(D),[Ce,we]=(0,x.useState)(k),[Te,Ee]=(0,x.useState)(j),[De,Oe]=(0,x.useState)(N),[ke,Ae]=(0,x.useState)(I),[je,Me]=(0,x.useState)(R),[Ne,Pe]=(0,x.useState)(!0),[Fe,Ie]=(0,x.useState)(!1),[Le,Re]=(0,x.useState)(!1),[ze,Be]=(0,x.useState)(!1),[Ve,He]=(0,x.useState)(24),[Ue,We]=(0,x.useState)(!1),[Ge,qe]=(0,x.useState)(!1),[Ye,Xe]=(0,x.useState)(``),[Ze,Qe]=(0,x.useState)(``),[$e,et]=(0,x.useState)(``),tt=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(tt.current&&=(clearTimeout(tt.current),null),e){if(V(n),te(i),W(o),ie(c),oe(u),ce(f),ue(m),fe(g),me(v),ge(b),ve(C),be(T),Se(D),we(k),Ee(j),Oe(N),Ae(I),Me(R),qe(!1),Xe(``),Qe(``),et(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Pe(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>He(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Re(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`&&(tt.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{tt.current&&=(clearTimeout(tt.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 nt=e=>{e.preventDefault();let n=B.trim(),i=se!==f;r(n||`~/Documents/GitHub`),a(H),s(ne),l(re),d(ae),p(se),h(le),_(de),y(pe),S(he),w(_e),E(ye),O(xe),A(Ce),M(Te),F(De),ee(ke),z(je),t({webglChanged:i})},rt=(e,t)=>{te(n=>n.map(n=>n.id===e?{...n,...t}:n))},it=e=>{let t=H.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=H.filter(t=>t.id!==e);te(n),e===ne&&W(n[0]?.id||`claude`)},at=()=>{if(!Ye.trim()||!Ze.trim()||H.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Ye.trim(),command:Ze.trim(),isBuiltIn:!1,agentType:$e||void 0};te([...H,e]),qe(!1),Xe(``),Qe(``),et(``)},ot=H.length<50,st=e=>{Ie(!0),Pe(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(()=>Pe(!e)).finally(()=>Ie(!1))},ct=e=>{Be(!0),Re(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(()=>Re(!e)).finally(()=>Be(!1))},lt=e=>{let t=Ve;We(!0),He(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(()=>He(t)).finally(()=>We(!1))};return(0,G.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,G.jsxs)(`form`,{onSubmit:nt,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,G.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,G.jsx)(`input`,{value:B,onChange:e=>V(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,G.jsx)(`select`,{value:ne,onChange:e=>W(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:H.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,G.jsx)(`div`,{className:`space-y-3`,children:H.map(e=>(0,G.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`input`,{value:e.label,onChange:t=>rt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>it(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,G.jsx)(`input`,{value:e.command,onChange:t=>rt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,G.jsxs)(`select`,{value:e.agentType||``,onChange:t=>rt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,G.jsx)(`option`,{value:``,children:`Terminal`}),(0,G.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,G.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Ge?(0,G.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,G.jsx)(`input`,{value:Ye,onChange:e=>Xe(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,G.jsx)(`input`,{value:Ze,onChange:e=>Qe(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`select`,{value:$e,onChange:e=>et(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,G.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,G.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,G.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>qe(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:at,disabled:!Ye.trim()||!Ze.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>qe(!0),disabled:!ot,className:`btn text-xs mt-3 w-full`,children:ot?`+ Add Preset`:`Max 50 presets`})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`created`?`btn-primary`:``}`,onClick:()=>ie(`created`),children:`Created`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`status`?`btn-primary`:``}`,onClick:()=>ie(`status`),children:`Status`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`manual`?`btn-primary`:``}`,onClick:()=>ie(`manual`),children:`Manual`})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:re===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:re===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),re===`created`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ae===`desc`?`btn-primary`:``}`,onClick:()=>oe(`desc`),children:`Newest First`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ae===`asc`?`btn-primary`:``}`,onClick:()=>oe(`asc`),children:`Oldest First`})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,G.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,G.jsx)(OK,{checked:xe,onCheckedChange:Se})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,G.jsx)(OK,{checked:Ce,onCheckedChange:we})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,G.jsx)(OK,{checked:Te,onCheckedChange:Ee})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:168,value:Ve,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&<(t)},disabled:Ue,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,G.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void BK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,G.jsx)(OK,{checked:ke,onCheckedChange:e=>{Ae(e),e&&LK()}})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void VK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,G.jsx)(OK,{checked:je,onCheckedChange:e=>{Me(e),e&&LK()}})]})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,G.jsx)(OK,{checked:se,onCheckedChange:ce})]}),se!==f&&(0,G.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,G.jsx)(OK,{checked:Ne,onCheckedChange:st,disabled:Fe})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,G.jsx)(OK,{checked:Le,onCheckedChange:ct,disabled:ze})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>ue(Math.max(6,le-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,G.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,G.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:le}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ue(Math.min(24,le+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,G.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:de,onChange:e=>fe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,G.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:de.toFixed(1)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:pe,onChange:e=>me(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,G.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[pe,`px`]})]})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,G.jsx)(`select`,{value:he,onChange:e=>ge(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),he===`custom`&&(0,G.jsx)(`input`,{value:_e,onChange:e=>ve(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,G.jsx)(OK,{checked:De===`dark`,onCheckedChange:e=>Oe(e?`dark`:`light`)})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,G.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,G.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${ye===e?`btn-primary`:``}`,onClick:()=>be(e),children:e===`auto`?`Auto`:Je(e)},e))}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ye===`auto`?`Platform default: ${Je(Ke(`auto`))}`:`Shortcuts: ${Je(ye)}+[N/X/[/]]`})]})]})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var UK=[];function WK(e){x.useEffect(e,UK)}var GK=x.createContext(void 0);function KK(){let e=x.useContext(GK);if(!e)throw Error(ZU(73));return e}var qK=Symbol(`NOT_FOUND`);function JK(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function YK(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function XK(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 ZK=e=>Array.isArray(e)?e:[e];function QK(e){let t=Array.isArray(e[0])?e[0]:e;return XK(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function $K(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function eq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:qK},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function tq(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 qK}function i(t,i){r(t)===qK&&(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 nq=(e,t)=>e===t;function rq(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 iq(e,t){let{equalityCheck:n=nq,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=rq(n),o=0,s=r<=1?eq(a):tq(r,a);function c(){let t=s.get(arguments);if(t===qK){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 aq=class{constructor(e){this.value=e}deref(){return this.value}},oq=typeof WeakRef<`u`?WeakRef:aq,sq=0,cq=1;function lq(){return{s:sq,v:void 0,o:null,p:null}}function uq(e,t={}){let n=lq(),{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=lq(),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=lq(),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 oq(c):c}return s.s=cq,s.v=c,c}return o.clearCache=()=>{n=lq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function dq(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()),JK(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=uq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=ZK(c),p=ZK(u),m=QK(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=$K(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 fq=dq(uq),pq=Object.assign((e,t=fq)=>{YK(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:()=>pq}),mq=dq({memoize:iq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),hq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(ZU(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},gq=(...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(ZU(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(ZU(2))}u=mq(...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`)}}},_q=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})),vq=s(((e,t)=>{t.exports=_q()})),yq=s((e=>{var t=p(),n=vq();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}})),bq=s(((e,t)=>{t.exports=yq()})),xq=[],Sq=void 0;function Cq(){return Sq}function wq(e){xq.push(e)}var Tq=vq(),Eq=bq(),Dq=$U(19)?Aq:jq;function Oq(e,t,n,r,i){return Dq(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,Tq.useSyncExternalStore)(e.subscribe,a,a)}wq({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,Tq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Aq(e,t,n,r,i){let a=Cq();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,Eq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Mq=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 Oq(this,e,t,n,r)}},Nq=class extends Mq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),GU(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;GU(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;GU(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;GU(()=>{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),Oq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=IU(t??YU);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)}})}},Pq=null;globalThis.requestAnimationFrame;var Fq=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)}},Iq=class e{static create(){return new e}static request(e){return Fq.request(e)}static cancel(e){return Fq.cancel(e)}currentId=Pq;request(e){this.cancel(),this.currentId=Fq.request(()=>{this.currentId=Pq,e()})}cancel=()=>{this.currentId!==Pq&&(Fq.cancel(this.currentId),this.currentId=Pq)};disposeEffect=()=>this.cancel};function Lq(){let e=NU(Iq.create).current;return WK(e.disposeEffect),e}var Rq=0,zq=class e{static create(){return new e}currentId=Rq;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rq,t()},e)}isStarted(){return this.currentId!==Rq}clear=()=>{this.currentId!==Rq&&(clearTimeout(this.currentId),this.currentId=Rq)};disposeEffect=()=>this.clear};function Bq(){let e=NU(zq.create).current;return WK(e.disposeEffect),e}var Vq=0;function Hq(e){return Vq+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Vq}`}function Uq(e){return e?.ownerDocument||document}function Wq(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 Gq=typeof navigator<`u`,Kq=Zq(),qq=$q(),Jq=Qq();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),Kq.platform===`MacIntel`&&Kq.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Kq.platform),Gq&&/firefox/i.test(Jq);var Yq=Gq&&/apple/i.test(navigator.vendor);Gq&&/Edg/i.test(Jq),Gq&&/android/i.test(qq)||/android/i.test(Jq),Gq&&qq.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var Xq=Jq.includes(`jsdom/`);function Zq(){if(!Gq)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 Qq(){if(!Gq)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function $q(){if(!Gq)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function eJ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function tJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&MW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function nJ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function rJ(e){if(!e||Xq)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var iJ=gq(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}),aJ={toasts:hq(e=>e.toasts),isEmpty:hq(e=>e.toasts.length===0),toast:hq(iJ,(e,t)=>e.get(t)?.value),toastIndex:hq(iJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:hq(iJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:hq(iJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:hq(e=>e.hovering),focused:hq(e=>e.focused),expanded:hq(e=>e.hovering||e.focused),expandedOrOutOfFocus:hq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:hq(e=>e.prevFocusElement)},oJ=class extends Nq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},aJ)}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=aJ.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||Hq(`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)),aJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=aJ.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)),aJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{aJ.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=Wq(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=Wq(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=Wq(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??=zq.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=nJ(e);tJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!aJ.expandedOrOutOfFocus(this.state),a=i?zq.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=eJ(Uq(this.state.viewport));if(!this.state.viewport||!tJ(this.state.viewport,t)||!rJ(t))return;let n=aJ.toasts(this.state),r=aJ.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=NU(()=>new oJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return WK(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,G.jsx)(GK.Provider,{value:a,children:t})},cJ=x.forwardRef(function(e,t){let[n,r]=x.useState();GU(()=>{Yq&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,G.jsx)(`span`,{...e,ref:t,style:qU,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),lJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),uJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=KK(),s=Bq(),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(eJ(Uq(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=nJ(n),i=eJ(Uq(e));(!tJ(e,r)||!rJ(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=Uq(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||rJ(Uq(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||tJ(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=_W(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[lJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,G.jsxs)(x.Fragment,{children:[!u&&m&&(0,G.jsx)(cJ,{onFocus:_}),i,!u&&m&&(0,G.jsx)(cJ,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,G.jsxs)(x.Fragment,{children:[!u&&m&&(0,G.jsx)(cJ,{onFocus:_}),E,!f&&D.length>0&&(0,G.jsx)(`div`,{style:qU,children:D.map(e=>(0,G.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,G.jsx)(`div`,{children:e.title}),(0,G.jsx)(`div`,{children:e.description})]},e.id))})]})});function dJ(e){return $U(19)?e:e?`true`:void 0}var fJ=x.createContext(void 0);function pJ(){let e=x.useContext(fJ);if(!e)throw Error(ZU(66));return e}var mJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),hJ={[mJ.startingStyle]:``},gJ={[mJ.endingStyle]:``},_J={transitionStatus(e){return e===`starting`?hJ:e===`ending`?gJ:null}};function vJ(e){return e==null?e:`current`in e?e.current:e}function yJ(e,t=!1,n=!0){let r=Lq();return IU((i,a=null)=>{r.cancel();function o(){W.flushSync(i)}let s=vJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=mJ.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 bJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=IU(i),o=yJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var xJ=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}({}),SJ={..._J,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},CJ=40,wJ=10,TJ=.5,EJ=1;function DJ(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 OJ(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=KK(),[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`),V=u.useState(`expanded`);bJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=IU((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?W.flushSync(a):a()});GU(H,[H]);function te(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**TJ:-(Math.abs(e)**TJ):(!c.includes(`right`)&&e>0&&(n=e**TJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**TJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**TJ:-(Math.abs(t)**TJ):(!c.includes(`down`)&&t>0&&(r=t**TJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**TJ))),{x:n,y:r}}function U(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=nJ(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=OJ(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 ne(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)>=EJ&&(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=DJ(u,a,o),f(u));else{let e=N.current,t=DJ(e,l,s);t>CJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=wJ&&(F.current=!0)}let d=te(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 re(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>CJ&&(t=!0,a=`right`);break;case`left`:r<-CJ&&(t=!0,a=`left`);break;case`down`:i>CJ&&(t=!0,a=`down`);break;case`up`:i<-CJ&&(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 ie(e){if(e.key===`Escape`){if(!A.current||!tJ(A.current,eJ(Uq(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){tJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function ae(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[xJ.swipeMovementX]:`0px`,[xJ.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,[xJ.swipeMovementX]:`${e}px`,[xJ.swipeMovementY]:`${t}px`}}let oe=n.priority===`high`,se={role:oe?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":oe&&!B?!0:void 0,onPointerDown:l?U:void 0,onPointerMove:l?ne:void 0,onPointerUp:l?re:void 0,onKeyDown:ie,inert:dJ(n.limited),style:{...ae(),[xJ.index]:n.transitionStatus===`ending`?ee:R,[xJ.offsetY]:`${z}px`,[xJ.height]:n.height?`${n.height}px`:void 0}},ce=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:H,index:ee,visibleIndex:R,expanded:V}),[n,w,E,p,d,H,ee,R,V]),le={transitionStatus:n.transitionStatus,expanded:V,limited:n.limited||!1,type:n.type,swiping:ce.swiping,swipeDirection:ce.swipeDirection},ue=_W(`div`,e,{ref:[t,ce.rootRef],state:le,stateAttributesMapping:SJ,props:[se,o]});return(0,G.jsx)(fJ.Provider,{value:ce,children:ue})}),AJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=pJ(),l=a??s.description,u=!!l,d=EW(i);GU(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=_W(`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}=pJ(),l=a??s.title,u=!!l,d=EW(i);GU(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=_W(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),MJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=KK(),{toast:c}=pJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=IW({disabled:i,native:a}),m={type:c.type};return _W(`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 NJ(){let e=x.useContext(GK);if(!e)throw Error(ZU(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 PJ(){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||Hq(`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 FJ=5e3,IJ=PJ();function LJ({toast:e}){return(0,G.jsxs)(kJ,{toast:e,className:DK(`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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(jJ,{className:DK(`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,G.jsx)(AJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,G.jsx)(MJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,G.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,G.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,G.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function RJ(){let{toasts:e}=NJ();return(0,G.jsx)(G.Fragment,{children:e.map(e=>(0,G.jsx)(LJ,{toast:e},e.id))})}function zJ(){return(0,G.jsxs)(sJ,{timeout:FJ,toastManager:IJ,children:[(0,G.jsx)(RJ,{}),(0,G.jsx)(uJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var BJ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],VJ=3e3,HJ=8e3,UJ=15e3,WJ=5e3,GJ=2e4,KJ=1e4,qJ=1500,JJ=5e3,YJ=750,XJ=4,ZJ=5e3,QJ=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(QT(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,QT(`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=>{QT(`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?BJ[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`){QT(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){QT(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}QT(`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`;QT(`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?HJ:VJ;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(QT(`ws_connect_timeout`,{wsState:BJ[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){QT(`ws_onopen_stale`,this.wsSnap(),`info`);return}QT(`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(),QT(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(JJ)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(QT(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){QT(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}QT(`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>UJ&&(QT(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},WJ))}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 QT(`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(QT(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){QT(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(QT(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},qJ)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){QT(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){QT(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){QT(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,QT(`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()},YJ)):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,QT(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},KJ)))};e!==void 0&&e<GJ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,GJ)},e):this.heartbeatTimer=window.setInterval(t,GJ)}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()){QT(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=XJ){QT(`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()},ZJ);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);QT(`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){QT(`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 $J(){let e=Km(e=>e.setConnectionState);return(0,x.useEffect)(()=>{QJ.connect(),QJ.startLifecycleListeners();let t=QJ.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),QJ.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{QJ.send(e)},[]),subscribe:(0,x.useMemo)(()=>QJ.subscribe.bind(QJ),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>QJ.getConnectionEpoch(),[])}}var eY=100;function tY({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>eY?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function nY(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 rY(){(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=()=>{tY({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(),nY(document)}},[])}function iY(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 aY(){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=Km(e=>e.sessions),_=Km(e=>e.agentSessions),v=Km(e=>e.agentSessionsEpoch),y=Km(e=>e.selectedSessionId),b=Km(e=>e.selectedHibernatingSessionId),S=Km(e=>e.setSessions),C=Km(e=>e.setAgentSessions),w=Km(e=>e.setActiveAgentSessions),T=Km(e=>e.setHostStatuses),E=Km(e=>e.updateSession),D=Km(e=>e.setSelectedSessionId),O=Km(e=>e.setSelectedHibernatingSessionId),k=Km(e=>e.hasLoaded),A=Km(e=>e.connectionStatus),j=Km(e=>e.connectionError),M=Km(e=>e.clearExitingSession),N=Km(e=>e.markSessionExiting),P=Km(e=>e.setRemoteAllowControl),F=Km(e=>e.setRemoteAllowAttach),I=Km(e=>e.setHostLabel),L=Km(e=>e.setPreferWindowName),ee=Km(e=>e.hostStatuses),R=Km(e=>e.remoteAllowControl),z=Km(e=>e.hostLabel),B=NH(e=>e.theme),V=ne(),H=U(e=>e.defaultProjectDir),te=U(e=>e.commandPresets),re=U(e=>e.defaultPresetId),ie=U(e=>e.lastProjectPath),ae=U(e=>e.setLastProjectPath),oe=U(e=>e.addRecentPath),se=U(e=>e.shortcutModifier),ce=U(e=>e.sidebarWidth),le=U(e=>e.setSidebarWidth),ue=U(e=>e.projectFilters),de=U(e=>e.hostFilters),fe=U(e=>e.soundOnPermission),pe=U(e=>e.soundOnIdle),me=Km(e=>e.connectionEpoch),{sendMessage:he,subscribe:ge,getConnectionEpoch:_e}=$J();rY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!FK()||(e=!0,LK())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[fe,pe]);let ve=(0,x.useRef)(!1),ye=(0,x.useCallback)(e=>{e.preventDefault(),ve.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(!ve.current)return;let t=e.clientX;le(Math.max(180,Math.min(400,t)))},t=()=>{ve.current&&(ve.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[le]),(0,x.useEffect)(()=>{let e=ge(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Km.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=U.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&&BK(),e.status===`working`&&i.status===`waiting`&&r&&VK())}if(Fe.current.size>0){let e=_e();for(let[t,n]of Fe.current)n.epoch!==e&&Fe.current.delete(t)}let i=Fe.current.size>0?e.sessions.filter(e=>!Fe.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Km.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(je.current=s),S(i);let c=Me.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Km.getState(),{projectFilters:d,hostFilters:f}=U.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Me.current=null,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&&ZT(e.clientLogLevel)),e.type===`session-update`){let t=Km.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=U.getState();t!==`permission`&&n===`permission`&&e&&BK(),t===`working`&&n===`waiting`&&r&&VK()}}if(e.type===`session-created`){let t=Km.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),oe(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=U.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){iH(e.sessionId);let t=Km.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}=Km.getState(),a=je.current;i&&!n.some(e=>e.sessionId===i)&&(Me.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)?(je.current=null,O(a)):a&&(je.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Km.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=Km.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=Km.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=Fe.current.get(e.sessionId);if(t){let n=Km.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Fe.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,oe,M,he,D,O,h,S,C,w,T,P,F,I,L,ge,E]);let be=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),xe=_.hibernating??[],Se=_.history??[],Ce=(0,x.useMemo)(()=>iY(xe,ue,de),[xe,ue,de]),we=(0,x.useMemo)(()=>Ce.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[Ce,m,b]);(0,x.useEffect)(()=>{be?.projectPath&&!be.remote&&ae(be.projectPath)},[be?.projectPath,be?.remote,ae]);let Te=U(e=>e.sessionSortMode),Ee=U(e=>e.sessionSortDirection),De=U(e=>e.manualSessionOrder),Oe=(0,x.useMemo)(()=>jm(g,{mode:Te,direction:Ee,manualOrder:De}),[g,Te,Ee,De]),ke=(0,x.useMemo)(()=>{let e=Oe;return ue.length>0&&(e=e.filter(e=>ue.includes(e.projectPath))),de.length>0&&(e=e.filter(e=>de.includes(e.host??``))),e},[Oe,ue,de]),Ae=(0,x.useRef)(b),je=(0,x.useRef)(null),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(me),Pe=(0,x.useCallback)(()=>ke.length>0?(D(ke[0].id),!0):Ce.length>0?(O(Ce[0].sessionId),!0):!1,[ke,Ce,D,O]);(0,x.useEffect)(()=>{let e=Ae.current;e&&b===null&&!xe.some(t=>t.sessionId===e)?Me.current=e:b!==null&&(Me.current=null),Ae.current=b},[xe,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Ne.current!==me&&(Ne.current=me,je.current=null,Me.current=null,h(null))},[me]),(0,x.useEffect)(()=>{k&&(b||y&&(ke.some(e=>e.id===y)||Pe()||D(null)))},[k,y,b,Pe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==me||Ce.some(e=>e.sessionId===b))return;let e=ke.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Pe()||O(null)},[Ce,ke,v,m,b,Pe,D,O,me]),(0,x.useEffect)(()=>{let e=Me.current;if(!e)return;if(b!==null){Me.current=null;return}let t=ke.find(t=>t.agentSessionId?.trim()===e);if(t){Me.current=null,D(t.id);return}if(y!==null){Me.current=null;return}Pe()&&(Me.current=null)},[ke,y,b,Pe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(ke.length>0||Ce.length>0)&&Pe()},[Ce.length,ke.length,k,Pe,y,b]);let Fe=(0,x.useRef)(new Map),Ie=(0,x.useCallback)((e,t=`unknown`)=>{iH(e);let{sessions:n,selectedSessionId:r}=Km.getState(),i=n.find(t=>t.id===e);i&&Fe.current.set(e,{session:i,wasSelected:r===e,epoch:_e()}),(0,W.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),he({type:`session-kill`,sessionId:e,source:t})},[N,S,he]);(0,x.useEffect)(()=>{let n=Ke(se),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Ye(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=ke;if(t.length===0){let t=Ce;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){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&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,ke,Ce,Ie,se,V]);let Le=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Re=()=>l(!0),ze=(e,t,n,r)=>{he({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||ae(e)},Be=e=>{he({type:`session-wake`,sessionId:e})},Ve=(0,x.useCallback)(e=>{he({type:`session-hibernate`,sessionId:e})},[he]),He=(e,t)=>{he({type:`session-rename`,sessionId:e,newName:t})},Ue=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&he({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,he]),We=(0,x.useCallback)(e=>{he({type:`session-move-to-history`,sessionId:e})},[he]);(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 Ge=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,G.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:ce},children:[(0,G.jsx)(Qe,{connectionStatus:A,onNewSession:Le,onOpenSettings:Re,tailscaleIp:f?.tailscaleIp??null}),(0,G.jsx)(KT,{sessions:g,hibernatingSessions:xe,historySessions:Se,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:He,onResume:Be,onHibernate:Ve,onKill:Ie,onDuplicate:Ue,onMoveToHistory:We,onNewSession:Le,loading:!k,error:j||u})]}),(0,G.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:ye}),(0,G.jsx)(OU,{session:be,sessions:ke,hibernatingSession:we,hibernatingSessions:xe,connectionStatus:A,connectionEpoch:me,sendMessage:he,subscribe:ge,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Le,onKillSession:Ie,onRenameSession:He,onOpenSettings:Re,onResumeSession:Be,onHibernateSession:Ve,onMoveToHistory:We,historySessions:Se,loading:!k,error:j||u}),(0,G.jsx)(AU,{isOpen:e,onClose:()=>t(!1),onCreate:ze,defaultProjectDir:H,commandPresets:te,defaultPresetId:re,lastProjectPath:ie,activeProjectPath:be&&!be.remote?be.projectPath:void 0,remoteHosts:Ge,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,G.jsx)(HK,{isOpen:c,onClose:()=>l(!1)}),(0,G.jsx)(zJ,{})]})}var oY=`modulepreload`,sY=function(e){return`/`+e},cY={},lY=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`:oY,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)})},uY=`true`,dY=`false`,fY=uY===`true`,pY=dY===`true`;function mY(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,fY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await lY(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()},!pY)if(fY)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}Ue()&&document.documentElement.classList.add(`ios`),We()&&document.documentElement.classList.add(`ios-pwa`),mY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var hY=document.getElementById(`root`);if(!hY)throw Error(`Root element not found`);(0,E.createRoot)(hY).render((0,G.jsx)(x.StrictMode,{children:(0,G.jsx)(aY,{})}));
|
|
324
|
+
`,onClick:()=>{DU(),u(t.id)},title:nt?t.name:void 0,children:i},t.id)})})]}),(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(`div`,{ref:xe,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Oe&&e&&(0,G.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,G.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,G.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,G.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),Ae&&e&&(0,G.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,G.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,G.jsxs)(`button`,{type:`button`,onClick:je,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,G.jsx)(ue,{width:14,height:14}),`Copy`]}),(0,G.jsx)(`button`,{type:`button`,onClick:Ne,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,G.jsx)(He,{width:14,height:14})})]}),!e&&(0,G.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&&pe&&(0,G.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,G.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,G.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,G.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:_e}),(0,G.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`}),ve&&(0,G.jsx)(`span`,{className:`text-muted`,children:ve}),(0,G.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,ye]})]}),n.lastResumeError&&(0,G.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,G.jsx)(ie,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,G.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,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,G.jsx)(VT,{session:n})]})}),j&&e&&!N&&(0,G.jsxs)(`button`,{onClick:Pe,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,G.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,G.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,G.jsx)(xU,{onSendKey:Ze,onPasteText:Qe,disabled:a!==`connected`||pe||!ke,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:$e,isKeyboardVisible:tt,onEnterTextMode:et}),(A||k)&&(0,G.jsx)(SU,{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,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,G.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,G.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,G.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,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,G.jsx)(`button`,{ref:se,onClick:Re,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=U(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,G.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,G.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,G.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,G.jsx)(`p`,{className:`text-danger`,children:s}),(0,G.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,G.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,G.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,G.jsx)(be,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,G.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,G.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,G.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,G.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,G.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function AU({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=>V(e)===t);e?(v(e.id),b(V(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(V(e))):i.length>0?(v(i[0].id),b(V(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(V(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,G.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,G.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,G.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,G.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,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,G.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,G.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,G.jsx)($m,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,G.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.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,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,G.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,G.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 MU={};function NU(e,t){let n=x.useRef(MU);return n.current===MU&&(n.current=e(t)),n}var PU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],FU=PU&&PU!==x.useLayoutEffect?PU:e=>e();function IU(e){let t=NU(LU).current;return t.next=e,FU(t.effect),t.trampoline}function LU(){let e={next:void 0,callback:RU,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function RU(){}function zU(e,t,n,r){let i=NU(VU).current;return HU(i,e,t,n,r)&&WU(i,[e,t,n,r]),i.callback}function BU(e){let t=NU(VU).current;return UU(t,e)&&WU(t,e),t.callback}function VU(){return{callback:null,cleanup:null,refs:[]}}function HU(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function UU(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function WU(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 GU=typeof document<`u`?x.useLayoutEffect:()=>{},KU={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},qU={...KU,position:`fixed`,top:0,left:0},JU={...KU,position:`absolute`};function YU(){}Object.freeze([]);var XU=Object.freeze({});function ZU(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 QU=18;function $U(e){return QU>=e}function eW(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return($U(19)?n?.ref:t.ref)??null}function tW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function nW(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 rW(e,t){return typeof e==`function`?e(t):e}function iW(e,t){return typeof e==`function`?e(t):e}var aW={};function oW(e,t,n,r,i){let a={...fW(e,aW)};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 aW;if(e.length===1)return fW(e[0],aW);let t={...fW(e[0],aW)};for(let n=1;n<e.length;n+=1)t=cW(t,e[n]);return t}function cW(e,t){return dW(t)?t(e):lW(e,t)}function lW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=tW(e.style,r);break;case`className`:e[n]=hW(e.className,r);break;default:uW(n,r)?e[n]=pW(e[n],r):e[n]=r}}return e}function uW(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 dW(e){return typeof e==`function`}function fW(e,t){return dW(e)?e(t):e??aW}function pW(e,t){return t?e?n=>{if(gW(n)){let r=n;mW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function mW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function hW(e,t){return t?e?t+` `+e:t:e}function gW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function _W(e,t,n={}){let r=t.render,i=vW(t,n);return n.enabled===!1?null:bW(e,r,i,n.state??XU)}function vW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=XU,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?rW(n,a):void 0,d=l?iW(r,a):void 0,f=l?nW(a,c):XU,p=l?tW(f,Array.isArray(s)?sW(s):s)??XU:XU;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=BU([p.ref,eW(i),...o]):p.ref=zU(p.ref,eW(i),o):zU(null,null)),l?(u!==void 0&&(p.className=hW(p.className,u)),d!==void 0&&(p.style=tW(p.style,d)),p):XU}var yW=Symbol.for(`react.lazy`);function bW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=oW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===yW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return xW(e,n);throw Error(ZU(8))}function xW(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 SW={...x},CW=0;function wW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(CW+=1,r(`${t}-${CW}`))},[n,t]),i}var TW=SW.useId;function EW(e,t){if(TW!==void 0){let n=TW();return e??(t?`${t}-${n}`:n)}return wW(e,t)}function DW(e){return EW(e,`base-ui`)}function OW(){return typeof window<`u`}function kW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function AW(e){return OW()?e instanceof Element||e instanceof kW(e).Element:!1}function jW(e){return OW()?e instanceof HTMLElement||e instanceof kW(e).HTMLElement:!1}function MW(e){return!OW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof kW(e).ShadowRoot}var NW=x.createContext(void 0);function PW(e=!1){let t=x.useContext(NW);if(t===void 0&&!e)throw Error(ZU(16));return t}function FW(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 IW(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=PW(!0)!==void 0,s=IU(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=FW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;LW(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return GU(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return oW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(mW(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||(mW(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:IU(e=>{a.current=e,l()})}}function LW(e){return jW(e)&&e.tagName===`BUTTON`}var RW=x.createContext(void 0);function zW(){let e=x.useContext(RW);if(e===void 0)throw Error(ZU(63));return e}var BW=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}({}),VW={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},HW={valid(e){return e===null?null:e?{[BW.valid]:``}:{[BW.invalid]:``}}},UW=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}({}),WW={...HW,checked(e){return e?{[UW.checked]:``}:{[UW.unchecked]:``}}};function GW(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var KW=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:YU,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function qW(){return x.useContext(KW)}var JW=x.createContext({invalid:void 0,name:void 0,validityData:{state:VW,errors:[],error:``,value:``,initialValue:null},setValidityData:YU,disabled:void 0,touched:!1,setTouched:YU,dirty:!1,setDirty:YU,filled:!1,setFilled:YU,focused:!1,setFocused:YU,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=XU)=>e,getInputValidationProps:(e=XU)=>e,inputRef:{current:null},commit:async()=>{}}});function YW(e=!0){let t=x.useContext(JW);if(t.setValidityData===YU&&!e)throw Error(ZU(28));return t}function XW(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=qW(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=YW(),f=IU(e.getValue);GU(()=>{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]),GU(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:GW(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?W.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),GU(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var ZW=x.createContext({controlId:void 0,registerControlId:YU,labelId:void 0,setLabelId:YU,messageIds:[],setMessageIds:YU,getDescriptionProps:e=>e});function QW(){return x.useContext(ZW)}function $W(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=QW(),o=DW(t),s=n?i:void 0,c=NU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=IU(()=>{!l.current||a===YU||(l.current=!1,a(c.current,void 0))});return GU(()=>{if(a===YU)return;let e;if(n){let n=r?.current;e=AW(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 eG=`none`;function tG(e,t,n,r){let i=!1,a=!1,o=r??XU;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 nG(e,t){let n=x.useRef(e),r=IU(t);GU(()=>{n.current!==e&&r(n.current)},[e,r]),GU(()=>{n.current=e},[e])}var rG=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:_}=qW(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=YW(),{labelId:A}=QW(),j=D||f,M=O??s,N=IU(l),P=x.useRef(null),F=zU(P,o,k.inputRef),I=x.useRef(null),L=DW(),ee=$W({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=jU({controlled:n,default:!!i,name:`Switch`,state:`checked`});XW({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),GU(()=>{P.current&&C(P.current.checked)},[P,C]),nG(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:V,buttonRef:H}=IW({disabled:j,native:c}),te={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})))}},U=x.useMemo(()=>oW({checked:z,disabled:j,id:R,name:M,required:d,style:M?JU:qU,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=tG(eG,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?XU:{value:h}),[z,j,F,R,M,N,d,B,k,h]),ne=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),W=_W(`span`,e,{state:ne,ref:[t,I,H],props:[te,k.getValidationProps,g,V],stateAttributesMapping:WW});return(0,G.jsxs)(RW.Provider,{value:ne,children:[W,!z&&M&&m!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,G.jsx)(`input`,{...U})]})}),iG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=YW(),o=zW();return _W(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:WW,props:i})});function aG(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=aG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function oG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=aG(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}),lG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),uG=`-`,dG=[],fG=`arbitrary..`,pG=e=>{let t=gG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return hG(e);let n=e.split(uG);return mG(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||dG}return n[e]||dG}}},mG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=mG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(uG):e.slice(t).join(uG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},hG=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?fG+r:void 0})(),gG=e=>{let{theme:t,classGroups:n}=e;return _G(n,t)},_G=(e,t)=>{let n=lG();for(let r in e){let i=e[r];vG(i,n,r,t)}return n},vG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];yG(i,t,n,r)}},yG=(e,t,n,r)=>{if(typeof e==`string`){bG(e,t,n);return}if(typeof e==`function`){xG(e,t,n,r);return}SG(e,t,n,r)},bG=(e,t,n)=>{let r=e===``?t:CG(t,e);r.classGroupId=n},xG=(e,t,n,r)=>{if(wG(e)){vG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(cG(n,e))},SG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];vG(o,CG(t,a),n,r)}},CG=(e,t)=>{let n=e,r=t.split(uG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=lG(),n.nextPart.set(t,i)),n=i}return n},wG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,TG=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)}}},EG=`!`,DG=`:`,OG=[],kG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),AG=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===DG){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(EG)?(c=s.slice(0,-1),l=!0):s.startsWith(EG)&&(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+DG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):kG(OG,!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}},MG=e=>({cache:TG(e.cacheSize),parseClassName:AG(e),sortModifiers:jG(e),...pG(e)}),NG=/\s+/,PG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(NG),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+EG: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},FG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=IG(n))&&(i&&(i+=` `),i+=r);return i},IG=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=IG(e[r]))&&(n&&(n+=` `),n+=t);return n},LG=(e,...t)=>{let n,r,i,a,o=o=>(n=MG(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=PG(e,n);return i(e,a),a};return a=o,(...e)=>a(FG(...e))},RG=[],zG=e=>{let t=t=>t[e]||RG;return t.isThemeGetter=!0,t},BG=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,VG=/^\((?:(\w[\w-]*):)?(.+)\)$/i,HG=/^\d+\/\d+$/,UG=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WG=/\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$/,GG=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,KG=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,qG=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,JG=e=>HG.test(e),YG=e=>!!e&&!Number.isNaN(Number(e)),XG=e=>!!e&&Number.isInteger(Number(e)),ZG=e=>e.endsWith(`%`)&&YG(e.slice(0,-1)),QG=e=>UG.test(e),$G=()=>!0,eK=e=>WG.test(e)&&!GG.test(e),tK=()=>!1,nK=e=>KG.test(e),rK=e=>qG.test(e),iK=e=>!Q(e)&&!$(e),aK=e=>_K(e,xK,tK),Q=e=>BG.test(e),oK=e=>_K(e,SK,eK),sK=e=>_K(e,CK,YG),cK=e=>_K(e,yK,tK),lK=e=>_K(e,bK,rK),uK=e=>_K(e,TK,nK),$=e=>VG.test(e),dK=e=>vK(e,SK),fK=e=>vK(e,wK),pK=e=>vK(e,yK),mK=e=>vK(e,xK),hK=e=>vK(e,bK),gK=e=>vK(e,TK,!0),_K=(e,t,n)=>{let r=BG.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},vK=(e,t,n=!1)=>{let r=VG.exec(e);return r?r[1]?t(r[1]):n:!1},yK=e=>e===`position`||e===`percentage`,bK=e=>e===`image`||e===`url`,xK=e=>e===`length`||e===`size`||e===`bg-size`,SK=e=>e===`length`,CK=e=>e===`number`,wK=e=>e===`family-name`,TK=e=>e===`shadow`,EK=LG(()=>{let e=zG(`color`),t=zG(`font`),n=zG(`text`),r=zG(`font-weight`),i=zG(`tracking`),a=zG(`leading`),o=zG(`breakpoint`),s=zG(`container`),c=zG(`spacing`),l=zG(`radius`),u=zG(`shadow`),d=zG(`inset-shadow`),f=zG(`text-shadow`),p=zG(`drop-shadow`),m=zG(`blur`),h=zG(`perspective`),g=zG(`aspect`),_=zG(`ease`),v=zG(`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=()=>[JG,`full`,`auto`,...w()],E=()=>[XG,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,XG,$,Q]},XG,$,Q],O=()=>[XG,`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=()=>[JG,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),pK,cK,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,mK,aK,{size:[$,Q]}],ee=()=>[ZG,dK,oK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,YG,dK,oK],B=()=>[`solid`,`dashed`,`dotted`,`double`],V=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],H=()=>[YG,ZG,pK,cK],te=()=>[``,`none`,m,$,Q],U=()=>[`none`,YG,$,Q],ne=()=>[`none`,YG,$,Q],W=()=>[YG,$,Q],re=()=>[JG,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[QG],breakpoint:[QG],color:[$G],container:[QG],"drop-shadow":[QG],ease:[`in`,`out`,`in-out`],font:[iK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[QG],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[QG],shadow:[QG],spacing:[`px`,YG],text:[QG],"text-shadow":[QG],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,JG,Q,$,g]}],container:[`container`],columns:[{columns:[YG,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:[XG,`auto`,$,Q]}],basis:[{basis:[JG,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[YG,JG,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,YG,$,Q]}],shrink:[{shrink:[``,YG,$,Q]}],order:[{order:[XG,`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,dK,oK]}],"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`,ZG,Q]}],"font-family":[{font:[fK,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":[YG,`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:[YG,`from-font`,`auto`,$,oK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[YG,`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`]},XG,$,Q],radial:[``,$,Q],conic:[XG,$,Q]},hK,lK]}],"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":[YG,$,Q]}],"outline-w":[{outline:[``,YG,dK,oK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,gK,uK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,gK,uK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[YG,oK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,gK,uK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[YG,$,Q]}],"mix-blend":[{"mix-blend":[...V(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":V()}],"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":[YG]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"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":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"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":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"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":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"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":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"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":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"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":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"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":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"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":[YG]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"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:te()}],brightness:[{brightness:[YG,$,Q]}],contrast:[{contrast:[YG,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,gK,uK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,YG,$,Q]}],"hue-rotate":[{"hue-rotate":[YG,$,Q]}],invert:[{invert:[``,YG,$,Q]}],saturate:[{saturate:[YG,$,Q]}],sepia:[{sepia:[``,YG,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[YG,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[YG,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,YG,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[YG,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,YG,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[YG,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[YG,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,YG,$,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:[YG,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[YG,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:U()}],"rotate-x":[{"rotate-x":U()}],"rotate-y":[{"rotate-y":U()}],"rotate-z":[{"rotate-z":U()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":[`scale-3d`],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:re()}],"translate-x":[{"translate-x":re()}],"translate-y":[{"translate-y":re()}],"translate-z":[{"translate-z":re()}],"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:[YG,dK,oK,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 DK(...e){return EK(oG(e))}function OK({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,G.jsx)(rG,{checked:e,onCheckedChange:t,disabled:n,className:DK(`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,G.jsx)(iG,{className:DK(`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,AK=!1,jK={},MK=500;function NK(){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 PK(){kK&&=(kK.close().catch(()=>{}),null),NK()}function FK(){return AK}function IK(){kK&&(PK(),AK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&IK()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&IK()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&IK(),e=t},5e3)}async function LK(){let e=NK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),AK=!1}async function RK(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function zK(e){let t=NK();if(!t||(await RK(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 BK(){let e=Date.now();if(!(e-(jK.permission||0)<MK)){jK.permission=e;try{await zK({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function VK(){let e=Date.now();if(!(e-(jK.idle||0)<MK)){jK.idle=e;try{await zK({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function HK({isOpen:e,onClose:t}){let n=U(e=>e.defaultProjectDir),r=U(e=>e.setDefaultProjectDir),i=U(e=>e.commandPresets),a=U(e=>e.setCommandPresets),o=U(e=>e.defaultPresetId),s=U(e=>e.setDefaultPresetId),c=U(e=>e.sessionSortMode),l=U(e=>e.setSessionSortMode),u=U(e=>e.sessionSortDirection),d=U(e=>e.setSessionSortDirection),f=U(e=>e.useWebGL),p=U(e=>e.setUseWebGL),m=U(e=>e.fontSize),h=U(e=>e.setFontSize),g=U(e=>e.lineHeight),_=U(e=>e.setLineHeight),v=U(e=>e.letterSpacing),y=U(e=>e.setLetterSpacing),b=U(e=>e.fontOption),S=U(e=>e.setFontOption),C=U(e=>e.customFontFamily),w=U(e=>e.setCustomFontFamily),T=U(e=>e.shortcutModifier),E=U(e=>e.setShortcutModifier),D=U(e=>e.showProjectName),O=U(e=>e.setShowProjectName),k=U(e=>e.showLastUserMessage),A=U(e=>e.setShowLastUserMessage),j=U(e=>e.showSessionIdPrefix),M=U(e=>e.setShowSessionIdPrefix),N=NH(e=>e.theme),F=NH(e=>e.setTheme),I=U(e=>e.soundOnPermission),ee=U(e=>e.setSoundOnPermission),R=U(e=>e.soundOnIdle),z=U(e=>e.setSoundOnIdle),[B,V]=(0,x.useState)(n),[H,te]=(0,x.useState)(i),[ne,W]=(0,x.useState)(o),[re,ie]=(0,x.useState)(c),[ae,oe]=(0,x.useState)(u),[se,ce]=(0,x.useState)(f),[le,ue]=(0,x.useState)(m),[de,fe]=(0,x.useState)(g),[pe,me]=(0,x.useState)(v),[he,ge]=(0,x.useState)(b),[_e,ve]=(0,x.useState)(C),[ye,be]=(0,x.useState)(T),[xe,Se]=(0,x.useState)(D),[Ce,we]=(0,x.useState)(k),[Te,Ee]=(0,x.useState)(j),[De,Oe]=(0,x.useState)(N),[ke,Ae]=(0,x.useState)(I),[je,Me]=(0,x.useState)(R),[Ne,Pe]=(0,x.useState)(!0),[Fe,Ie]=(0,x.useState)(!1),[Le,Re]=(0,x.useState)(!1),[ze,Be]=(0,x.useState)(!1),[Ve,He]=(0,x.useState)(24),[Ue,We]=(0,x.useState)(!1),[Ge,qe]=(0,x.useState)(!1),[Ye,Xe]=(0,x.useState)(``),[Ze,Qe]=(0,x.useState)(``),[$e,et]=(0,x.useState)(``),tt=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(tt.current&&=(clearTimeout(tt.current),null),e){if(V(n),te(i),W(o),ie(c),oe(u),ce(f),ue(m),fe(g),me(v),ge(b),ve(C),be(T),Se(D),we(k),Ee(j),Oe(N),Ae(I),Me(R),qe(!1),Xe(``),Qe(``),et(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Pe(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>He(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Re(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`&&(tt.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{tt.current&&=(clearTimeout(tt.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 nt=e=>{e.preventDefault();let n=B.trim(),i=se!==f;r(n||`~/Documents/GitHub`),a(H),s(ne),l(re),d(ae),p(se),h(le),_(de),y(pe),S(he),w(_e),E(ye),O(xe),A(Ce),M(Te),F(De),ee(ke),z(je),t({webglChanged:i})},rt=(e,t)=>{te(n=>n.map(n=>n.id===e?{...n,...t}:n))},it=e=>{let t=H.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=H.filter(t=>t.id!==e);te(n),e===ne&&W(n[0]?.id||`claude`)},at=()=>{if(!Ye.trim()||!Ze.trim()||H.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Ye.trim(),command:Ze.trim(),isBuiltIn:!1,agentType:$e||void 0};te([...H,e]),qe(!1),Xe(``),Qe(``),et(``)},ot=H.length<50,st=e=>{Ie(!0),Pe(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(()=>Pe(!e)).finally(()=>Ie(!1))},ct=e=>{Be(!0),Re(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(()=>Re(!e)).finally(()=>Be(!1))},lt=e=>{let t=Ve;We(!0),He(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(()=>He(t)).finally(()=>We(!1))};return(0,G.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,G.jsxs)(`form`,{onSubmit:nt,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,G.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,G.jsx)(`input`,{value:B,onChange:e=>V(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,G.jsx)(`select`,{value:ne,onChange:e=>W(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:H.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,G.jsx)(`div`,{className:`space-y-3`,children:H.map(e=>(0,G.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`input`,{value:e.label,onChange:t=>rt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>it(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,G.jsx)(`input`,{value:e.command,onChange:t=>rt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,G.jsxs)(`select`,{value:e.agentType||``,onChange:t=>rt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,G.jsx)(`option`,{value:``,children:`Terminal`}),(0,G.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,G.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Ge?(0,G.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,G.jsx)(`input`,{value:Ye,onChange:e=>Xe(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,G.jsx)(`input`,{value:Ze,onChange:e=>Qe(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`select`,{value:$e,onChange:e=>et(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,G.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,G.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,G.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>qe(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:at,disabled:!Ye.trim()||!Ze.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>qe(!0),disabled:!ot,className:`btn text-xs mt-3 w-full`,children:ot?`+ Add Preset`:`Max 50 presets`})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`created`?`btn-primary`:``}`,onClick:()=>ie(`created`),children:`Created`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`status`?`btn-primary`:``}`,onClick:()=>ie(`status`),children:`Status`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`manual`?`btn-primary`:``}`,onClick:()=>ie(`manual`),children:`Manual`})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:re===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:re===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),re===`created`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ae===`desc`?`btn-primary`:``}`,onClick:()=>oe(`desc`),children:`Newest First`}),(0,G.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ae===`asc`?`btn-primary`:``}`,onClick:()=>oe(`asc`),children:`Oldest First`})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,G.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,G.jsx)(OK,{checked:xe,onCheckedChange:Se})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,G.jsx)(OK,{checked:Ce,onCheckedChange:we})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,G.jsx)(OK,{checked:Te,onCheckedChange:Ee})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:168,value:Ve,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&<(t)},disabled:Ue,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,G.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void BK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,G.jsx)(OK,{checked:ke,onCheckedChange:e=>{Ae(e),e&&LK()}})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void VK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,G.jsx)(OK,{checked:je,onCheckedChange:e=>{Me(e),e&&LK()}})]})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,G.jsx)(OK,{checked:se,onCheckedChange:ce})]}),se!==f&&(0,G.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,G.jsx)(OK,{checked:Ne,onCheckedChange:st,disabled:Fe})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,G.jsx)(OK,{checked:Le,onCheckedChange:ct,disabled:ze})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>ue(Math.max(6,le-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,G.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,G.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:le}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ue(Math.min(24,le+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,G.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:de,onChange:e=>fe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,G.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:de.toFixed(1)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:pe,onChange:e=>me(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,G.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[pe,`px`]})]})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,G.jsx)(`select`,{value:he,onChange:e=>ge(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),he===`custom`&&(0,G.jsx)(`input`,{value:_e,onChange:e=>ve(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,G.jsx)(OK,{checked:De===`dark`,onCheckedChange:e=>Oe(e?`dark`:`light`)})]})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,G.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,G.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${ye===e?`btn-primary`:``}`,onClick:()=>be(e),children:e===`auto`?`Auto`:Je(e)},e))}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ye===`auto`?`Platform default: ${Je(Ke(`auto`))}`:`Shortcuts: ${Je(ye)}+[N/X/[/]]`})]})]})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var UK=[];function WK(e){x.useEffect(e,UK)}var GK=x.createContext(void 0);function KK(){let e=x.useContext(GK);if(!e)throw Error(ZU(73));return e}var qK=Symbol(`NOT_FOUND`);function JK(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function YK(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function XK(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 ZK=e=>Array.isArray(e)?e:[e];function QK(e){let t=Array.isArray(e[0])?e[0]:e;return XK(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function $K(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function eq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:qK},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function tq(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 qK}function i(t,i){r(t)===qK&&(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 nq=(e,t)=>e===t;function rq(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 iq(e,t){let{equalityCheck:n=nq,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=rq(n),o=0,s=r<=1?eq(a):tq(r,a);function c(){let t=s.get(arguments);if(t===qK){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 aq=class{constructor(e){this.value=e}deref(){return this.value}},oq=typeof WeakRef<`u`?WeakRef:aq,sq=0,cq=1;function lq(){return{s:sq,v:void 0,o:null,p:null}}function uq(e,t={}){let n=lq(),{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=lq(),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=lq(),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 oq(c):c}return s.s=cq,s.v=c,c}return o.clearCache=()=>{n=lq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function dq(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()),JK(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=uq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=ZK(c),p=ZK(u),m=QK(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=$K(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 fq=dq(uq),pq=Object.assign((e,t=fq)=>{YK(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:()=>pq}),mq=dq({memoize:iq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),hq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(ZU(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},gq=(...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(ZU(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(ZU(2))}u=mq(...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`)}}},_q=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})),vq=s(((e,t)=>{t.exports=_q()})),yq=s((e=>{var t=p(),n=vq();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}})),bq=s(((e,t)=>{t.exports=yq()})),xq=[],Sq=void 0;function Cq(){return Sq}function wq(e){xq.push(e)}var Tq=vq(),Eq=bq(),Dq=$U(19)?Aq:jq;function Oq(e,t,n,r,i){return Dq(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,Tq.useSyncExternalStore)(e.subscribe,a,a)}wq({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,Tq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Aq(e,t,n,r,i){let a=Cq();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,Eq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Mq=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 Oq(this,e,t,n,r)}},Nq=class extends Mq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),GU(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;GU(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;GU(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;GU(()=>{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),Oq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=IU(t??YU);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)}})}},Pq=null;globalThis.requestAnimationFrame;var Fq=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)}},Iq=class e{static create(){return new e}static request(e){return Fq.request(e)}static cancel(e){return Fq.cancel(e)}currentId=Pq;request(e){this.cancel(),this.currentId=Fq.request(()=>{this.currentId=Pq,e()})}cancel=()=>{this.currentId!==Pq&&(Fq.cancel(this.currentId),this.currentId=Pq)};disposeEffect=()=>this.cancel};function Lq(){let e=NU(Iq.create).current;return WK(e.disposeEffect),e}var Rq=0,zq=class e{static create(){return new e}currentId=Rq;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rq,t()},e)}isStarted(){return this.currentId!==Rq}clear=()=>{this.currentId!==Rq&&(clearTimeout(this.currentId),this.currentId=Rq)};disposeEffect=()=>this.clear};function Bq(){let e=NU(zq.create).current;return WK(e.disposeEffect),e}var Vq=0;function Hq(e){return Vq+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Vq}`}function Uq(e){return e?.ownerDocument||document}function Wq(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 Gq=typeof navigator<`u`,Kq=Zq(),qq=$q(),Jq=Qq();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),Kq.platform===`MacIntel`&&Kq.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Kq.platform),Gq&&/firefox/i.test(Jq);var Yq=Gq&&/apple/i.test(navigator.vendor);Gq&&/Edg/i.test(Jq),Gq&&/android/i.test(qq)||/android/i.test(Jq),Gq&&qq.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var Xq=Jq.includes(`jsdom/`);function Zq(){if(!Gq)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 Qq(){if(!Gq)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function $q(){if(!Gq)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function eJ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function tJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&MW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function nJ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function rJ(e){if(!e||Xq)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var iJ=gq(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}),aJ={toasts:hq(e=>e.toasts),isEmpty:hq(e=>e.toasts.length===0),toast:hq(iJ,(e,t)=>e.get(t)?.value),toastIndex:hq(iJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:hq(iJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:hq(iJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:hq(e=>e.hovering),focused:hq(e=>e.focused),expanded:hq(e=>e.hovering||e.focused),expandedOrOutOfFocus:hq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:hq(e=>e.prevFocusElement)},oJ=class extends Nq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},aJ)}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=aJ.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||Hq(`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)),aJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=aJ.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)),aJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{aJ.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=Wq(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=Wq(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=Wq(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??=zq.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=nJ(e);tJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!aJ.expandedOrOutOfFocus(this.state),a=i?zq.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=eJ(Uq(this.state.viewport));if(!this.state.viewport||!tJ(this.state.viewport,t)||!rJ(t))return;let n=aJ.toasts(this.state),r=aJ.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=NU(()=>new oJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return WK(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,G.jsx)(GK.Provider,{value:a,children:t})},cJ=x.forwardRef(function(e,t){let[n,r]=x.useState();GU(()=>{Yq&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,G.jsx)(`span`,{...e,ref:t,style:qU,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),lJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),uJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=KK(),s=Bq(),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(eJ(Uq(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=nJ(n),i=eJ(Uq(e));(!tJ(e,r)||!rJ(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=Uq(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||rJ(Uq(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||tJ(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=_W(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[lJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,G.jsxs)(x.Fragment,{children:[!u&&m&&(0,G.jsx)(cJ,{onFocus:_}),i,!u&&m&&(0,G.jsx)(cJ,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,G.jsxs)(x.Fragment,{children:[!u&&m&&(0,G.jsx)(cJ,{onFocus:_}),E,!f&&D.length>0&&(0,G.jsx)(`div`,{style:qU,children:D.map(e=>(0,G.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,G.jsx)(`div`,{children:e.title}),(0,G.jsx)(`div`,{children:e.description})]},e.id))})]})});function dJ(e){return $U(19)?e:e?`true`:void 0}var fJ=x.createContext(void 0);function pJ(){let e=x.useContext(fJ);if(!e)throw Error(ZU(66));return e}var mJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),hJ={[mJ.startingStyle]:``},gJ={[mJ.endingStyle]:``},_J={transitionStatus(e){return e===`starting`?hJ:e===`ending`?gJ:null}};function vJ(e){return e==null?e:`current`in e?e.current:e}function yJ(e,t=!1,n=!0){let r=Lq();return IU((i,a=null)=>{r.cancel();function o(){W.flushSync(i)}let s=vJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=mJ.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 bJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=IU(i),o=yJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var xJ=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}({}),SJ={..._J,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},CJ=40,wJ=10,TJ=.5,EJ=1;function DJ(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 OJ(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=KK(),[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`),V=u.useState(`expanded`);bJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let H=IU((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?W.flushSync(a):a()});GU(H,[H]);function te(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**TJ:-(Math.abs(e)**TJ):(!c.includes(`right`)&&e>0&&(n=e**TJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**TJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**TJ:-(Math.abs(t)**TJ):(!c.includes(`down`)&&t>0&&(r=t**TJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**TJ))),{x:n,y:r}}function U(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=nJ(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=OJ(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 ne(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)>=EJ&&(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=DJ(u,a,o),f(u));else{let e=N.current,t=DJ(e,l,s);t>CJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=wJ&&(F.current=!0)}let d=te(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 re(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>CJ&&(t=!0,a=`right`);break;case`left`:r<-CJ&&(t=!0,a=`left`);break;case`down`:i>CJ&&(t=!0,a=`down`);break;case`up`:i<-CJ&&(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 ie(e){if(e.key===`Escape`){if(!A.current||!tJ(A.current,eJ(Uq(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){tJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function ae(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[xJ.swipeMovementX]:`0px`,[xJ.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,[xJ.swipeMovementX]:`${e}px`,[xJ.swipeMovementY]:`${t}px`}}let oe=n.priority===`high`,se={role:oe?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":oe&&!B?!0:void 0,onPointerDown:l?U:void 0,onPointerMove:l?ne:void 0,onPointerUp:l?re:void 0,onKeyDown:ie,inert:dJ(n.limited),style:{...ae(),[xJ.index]:n.transitionStatus===`ending`?ee:R,[xJ.offsetY]:`${z}px`,[xJ.height]:n.height?`${n.height}px`:void 0}},ce=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:H,index:ee,visibleIndex:R,expanded:V}),[n,w,E,p,d,H,ee,R,V]),le={transitionStatus:n.transitionStatus,expanded:V,limited:n.limited||!1,type:n.type,swiping:ce.swiping,swipeDirection:ce.swipeDirection},ue=_W(`div`,e,{ref:[t,ce.rootRef],state:le,stateAttributesMapping:SJ,props:[se,o]});return(0,G.jsx)(fJ.Provider,{value:ce,children:ue})}),AJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=pJ(),l=a??s.description,u=!!l,d=EW(i);GU(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=_W(`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}=pJ(),l=a??s.title,u=!!l,d=EW(i);GU(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=_W(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),MJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=KK(),{toast:c}=pJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=IW({disabled:i,native:a}),m={type:c.type};return _W(`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 NJ(){let e=x.useContext(GK);if(!e)throw Error(ZU(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 PJ(){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||Hq(`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 FJ=5e3,IJ=PJ();function LJ({toast:e}){return(0,G.jsxs)(kJ,{toast:e,className:DK(`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,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(jJ,{className:DK(`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,G.jsx)(AJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,G.jsx)(MJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,G.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,G.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,G.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function RJ(){let{toasts:e}=NJ();return(0,G.jsx)(G.Fragment,{children:e.map(e=>(0,G.jsx)(LJ,{toast:e},e.id))})}function zJ(){return(0,G.jsxs)(sJ,{timeout:FJ,toastManager:IJ,children:[(0,G.jsx)(RJ,{}),(0,G.jsx)(uJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var BJ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],VJ=3e3,HJ=8e3,UJ=15e3,WJ=5e3,GJ=2e4,KJ=1e4,qJ=1500,JJ=5e3,YJ=750,XJ=4,ZJ=5e3,QJ=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(QT(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,QT(`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=>{QT(`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?BJ[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`){QT(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){QT(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}QT(`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`;QT(`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?HJ:VJ;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(QT(`ws_connect_timeout`,{wsState:BJ[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){QT(`ws_onopen_stale`,this.wsSnap(),`info`);return}QT(`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(),QT(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(JJ)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(QT(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){QT(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}QT(`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>UJ&&(QT(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},WJ))}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 QT(`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(QT(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){QT(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(QT(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},qJ)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){QT(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){QT(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){QT(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,QT(`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()},YJ)):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,QT(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},KJ)))};e!==void 0&&e<GJ?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,GJ)},e):this.heartbeatTimer=window.setInterval(t,GJ)}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()){QT(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=XJ){QT(`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()},ZJ);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);QT(`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){QT(`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 $J(){let e=Km(e=>e.setConnectionState);return(0,x.useEffect)(()=>{QJ.connect(),QJ.startLifecycleListeners();let t=QJ.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),QJ.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{QJ.send(e)},[]),subscribe:(0,x.useMemo)(()=>QJ.subscribe.bind(QJ),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>QJ.getConnectionEpoch(),[])}}var eY=100;function tY({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>eY?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function nY(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 rY(){(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=()=>{tY({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(),nY(document)}},[])}function iY(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 aY(){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=Km(e=>e.sessions),_=Km(e=>e.agentSessions),v=Km(e=>e.agentSessionsEpoch),y=Km(e=>e.selectedSessionId),b=Km(e=>e.selectedHibernatingSessionId),S=Km(e=>e.setSessions),C=Km(e=>e.setAgentSessions),w=Km(e=>e.setActiveAgentSessions),T=Km(e=>e.setHostStatuses),E=Km(e=>e.updateSession),D=Km(e=>e.setSelectedSessionId),O=Km(e=>e.setSelectedHibernatingSessionId),k=Km(e=>e.hasLoaded),A=Km(e=>e.connectionStatus),j=Km(e=>e.connectionError),M=Km(e=>e.clearExitingSession),N=Km(e=>e.markSessionExiting),P=Km(e=>e.setRemoteAllowControl),F=Km(e=>e.setRemoteAllowAttach),I=Km(e=>e.setHostLabel),L=Km(e=>e.setPreferWindowName),ee=Km(e=>e.hostStatuses),R=Km(e=>e.remoteAllowControl),z=Km(e=>e.hostLabel),B=NH(e=>e.theme),V=ne(),H=U(e=>e.defaultProjectDir),te=U(e=>e.commandPresets),re=U(e=>e.defaultPresetId),ie=U(e=>e.lastProjectPath),ae=U(e=>e.setLastProjectPath),oe=U(e=>e.addRecentPath),se=U(e=>e.shortcutModifier),ce=U(e=>e.sidebarWidth),le=U(e=>e.setSidebarWidth),ue=U(e=>e.projectFilters),de=U(e=>e.hostFilters),fe=U(e=>e.soundOnPermission),pe=U(e=>e.soundOnIdle),me=Km(e=>e.connectionEpoch),{sendMessage:he,subscribe:ge,getConnectionEpoch:_e}=$J();rY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!fe&&!pe)return;let e=!1,t=()=>{e&&!FK()||(e=!0,LK())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[fe,pe]);let ve=(0,x.useRef)(!1),ye=(0,x.useCallback)(e=>{e.preventDefault(),ve.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(!ve.current)return;let t=e.clientX;le(Math.max(180,Math.min(400,t)))},t=()=>{ve.current&&(ve.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[le]),(0,x.useEffect)(()=>{let e=ge(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Km.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=U.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&&BK(),e.status===`working`&&i.status===`waiting`&&r&&VK())}if(Fe.current.size>0){let e=_e();for(let[t,n]of Fe.current)n.epoch!==e&&Fe.current.delete(t)}let i=Fe.current.size>0?e.sessions.filter(e=>!Fe.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Km.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(je.current=s),S(i);let c=Me.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Km.getState(),{projectFilters:d,hostFilters:f}=U.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Me.current=null,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&&ZT(e.clientLogLevel)),e.type===`session-update`){let t=Km.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=U.getState();t!==`permission`&&n===`permission`&&e&&BK(),t===`working`&&n===`waiting`&&r&&VK()}}if(e.type===`session-created`){let t=Km.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),oe(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=U.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){iH(e.sessionId);let t=Km.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}=Km.getState(),a=je.current;i&&!n.some(e=>e.sessionId===i)&&(Me.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)?(je.current=null,O(a)):a&&(je.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Km.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=Km.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=Km.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=Fe.current.get(e.sessionId);if(t){let n=Km.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Fe.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,oe,M,he,D,O,h,S,C,w,T,P,F,I,L,ge,E]);let be=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),xe=_.hibernating??[],Se=_.history??[],Ce=(0,x.useMemo)(()=>iY(xe,ue,de),[xe,ue,de]),we=(0,x.useMemo)(()=>Ce.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[Ce,m,b]);(0,x.useEffect)(()=>{be?.projectPath&&!be.remote&&ae(be.projectPath)},[be?.projectPath,be?.remote,ae]);let Te=U(e=>e.sessionSortMode),Ee=U(e=>e.sessionSortDirection),De=U(e=>e.manualSessionOrder),Oe=(0,x.useMemo)(()=>jm(g,{mode:Te,direction:Ee,manualOrder:De}),[g,Te,Ee,De]),ke=(0,x.useMemo)(()=>{let e=Oe;return ue.length>0&&(e=e.filter(e=>ue.includes(e.projectPath))),de.length>0&&(e=e.filter(e=>de.includes(e.host??``))),e},[Oe,ue,de]),Ae=(0,x.useRef)(b),je=(0,x.useRef)(null),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(me),Pe=(0,x.useCallback)(()=>ke.length>0?(D(ke[0].id),!0):Ce.length>0?(O(Ce[0].sessionId),!0):!1,[ke,Ce,D,O]);(0,x.useEffect)(()=>{let e=Ae.current;e&&b===null&&!xe.some(t=>t.sessionId===e)?Me.current=e:b!==null&&(Me.current=null),Ae.current=b},[xe,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Ne.current!==me&&(Ne.current=me,je.current=null,Me.current=null,h(null))},[me]),(0,x.useEffect)(()=>{k&&(b||y&&(ke.some(e=>e.id===y)||Pe()||D(null)))},[k,y,b,Pe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==me||Ce.some(e=>e.sessionId===b))return;let e=ke.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Pe()||O(null)},[Ce,ke,v,m,b,Pe,D,O,me]),(0,x.useEffect)(()=>{let e=Me.current;if(!e)return;if(b!==null){Me.current=null;return}let t=ke.find(t=>t.agentSessionId?.trim()===e);if(t){Me.current=null,D(t.id);return}if(y!==null){Me.current=null;return}Pe()&&(Me.current=null)},[ke,y,b,Pe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(ke.length>0||Ce.length>0)&&Pe()},[Ce.length,ke.length,k,Pe,y,b]);let Fe=(0,x.useRef)(new Map),Ie=(0,x.useCallback)((e,t=`unknown`)=>{iH(e);let{sessions:n,selectedSessionId:r}=Km.getState(),i=n.find(t=>t.id===e);i&&Fe.current.set(e,{session:i,wasSelected:r===e,epoch:_e()}),(0,W.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),he({type:`session-kill`,sessionId:e,source:t})},[N,S,he]);(0,x.useEffect)(()=>{let n=Ke(se),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Ye(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=ke;if(t.length===0){let t=Ce;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){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&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Ie(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,ke,Ce,Ie,se,V]);let Le=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Re=()=>l(!0),ze=(e,t,n,r)=>{he({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||ae(e)},Be=e=>{he({type:`session-wake`,sessionId:e})},Ve=(0,x.useCallback)(e=>{he({type:`session-hibernate`,sessionId:e})},[he]),He=(e,t)=>{he({type:`session-rename`,sessionId:e,newName:t})},Ue=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&he({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,he]),We=(0,x.useCallback)(e=>{he({type:`session-move-to-history`,sessionId:e})},[he]);(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 Ge=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,G.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:ce},children:[(0,G.jsx)(Qe,{connectionStatus:A,onNewSession:Le,onOpenSettings:Re,tailscaleIp:f?.tailscaleIp??null}),(0,G.jsx)(KT,{sessions:g,hibernatingSessions:xe,historySessions:Se,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:He,onResume:Be,onHibernate:Ve,onKill:Ie,onDuplicate:Ue,onMoveToHistory:We,onNewSession:Le,loading:!k,error:j||u})]}),(0,G.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:ye}),(0,G.jsx)(OU,{session:be,sessions:ke,hibernatingSession:we,hibernatingSessions:xe,connectionStatus:A,connectionEpoch:me,sendMessage:he,subscribe:ge,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Le,onKillSession:Ie,onRenameSession:He,onOpenSettings:Re,onResumeSession:Be,onHibernateSession:Ve,onMoveToHistory:We,historySessions:Se,loading:!k,error:j||u}),(0,G.jsx)(AU,{isOpen:e,onClose:()=>t(!1),onCreate:ze,defaultProjectDir:H,commandPresets:te,defaultPresetId:re,lastProjectPath:ie,activeProjectPath:be&&!be.remote?be.projectPath:void 0,remoteHosts:Ge,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,G.jsx)(HK,{isOpen:c,onClose:()=>l(!1)}),(0,G.jsx)(zJ,{})]})}var oY=`modulepreload`,sY=function(e){return`/`+e},cY={},lY=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`:oY,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)})},uY=`true`,dY=`false`,fY=uY===`true`,pY=dY===`true`;function mY(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,fY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await lY(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()},!pY)if(fY)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}Ue()&&document.documentElement.classList.add(`ios`),We()&&document.documentElement.classList.add(`ios-pwa`),mY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var hY=document.getElementById(`root`);if(!hY)throw Error(`Root element not found`);(0,E.createRoot)(hY).render((0,G.jsx)(x.StrictMode,{children:(0,G.jsx)(aY,{})}));
|