@gbasin/agentboard-linux-arm64 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,7 @@ out vec4 outColor;
98
98
  void main() {
99
99
  outColor = v_color;
100
100
  }`)),this.register((0,i.toDisposable)((()=>l.deleteProgram(this._program)))),this._projectionLocation=(0,r.throwIfFalsy)(l.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=l.createVertexArray(),l.bindVertexArray(this._vertexArrayObject);let u=new Float32Array([0,0,1,0,0,1,1,1]),d=l.createBuffer();this.register((0,i.toDisposable)((()=>l.deleteBuffer(d)))),l.bindBuffer(l.ARRAY_BUFFER,d),l.bufferData(l.ARRAY_BUFFER,u,l.STATIC_DRAW),l.enableVertexAttribArray(3),l.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let f=new Uint8Array([0,1,2,3]),p=l.createBuffer();this.register((0,i.toDisposable)((()=>l.deleteBuffer(p)))),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,p),l.bufferData(l.ELEMENT_ARRAY_BUFFER,f,l.STATIC_DRAW),this._attributesBuffer=(0,r.throwIfFalsy)(l.createBuffer()),this.register((0,i.toDisposable)((()=>l.deleteBuffer(this._attributesBuffer)))),l.bindBuffer(l.ARRAY_BUFFER,this._attributesBuffer),l.enableVertexAttribArray(0),l.vertexAttribPointer(0,2,l.FLOAT,!1,s,0),l.vertexAttribDivisor(0,1),l.enableVertexAttribArray(1),l.vertexAttribPointer(1,2,l.FLOAT,!1,s,2*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(1,1),l.enableVertexAttribArray(2),l.vertexAttribPointer(2,4,l.FLOAT,!1,s,4*Float32Array.BYTES_PER_ELEMENT),l.vertexAttribDivisor(2,1),this._updateCachedColors(a.colors),this.register(this._themeService.onChangeColors((e=>{this._updateCachedColors(e),this._updateViewportRectangle()})))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,o.PROJECTION_MATRIX),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r,i,o,s,c,l,u,d,f,p,m,h=1;for(r=0;r<t.rows;r++){for(o=-1,s=0,c=0,l=!1,i=0;i<t.cols;i++)u=(r*t.cols+i)*a.RENDER_MODEL_INDICIES_PER_CELL,d=e.cells[u+a.RENDER_MODEL_BG_OFFSET],f=e.cells[u+a.RENDER_MODEL_FG_OFFSET],p=!!(67108864&f),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=8*h++,this._updateRectangle(n,m,c,s,o,i,r)),o=i,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=8*h++,this._updateRectangle(n,m,c,s,o,t.cols,r))}n.count=h}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`)return void(t.count=0);let r,i=0;n.style!==`bar`&&n.style!==`outline`||(r=8*i++,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),n.style!==`underline`&&n.style!==`outline`||(r=8*i++,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=8*i++,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=8*i++,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,s){if(67108864&n)switch(50331648&n){case 16777216:case 33554432:l=this._themeService.colors.ansi[255&n].rgba;break;case 50331648:l=(16777215&n)<<8;break;default:l=this._themeService.colors.foreground.rgba}else switch(50331648&r){case 16777216:case 33554432:l=this._themeService.colors.ansi[255&r].rgba;break;case 50331648:l=(16777215&r)<<8;break;default:l=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=(0,o.expandFloat32Array)(e.attributes,this._terminal.rows*this._terminal.cols*8)),u=i*this._dimensions.device.cell.width,d=s*this._dimensions.device.cell.height,f=(l>>24&255)/255,p=(l>>16&255)/255,m=(l>>8&255)/255,h=1,this._addRectangle(e.attributes,t,u,d,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,f,p,m,h)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(255&e.rgba)/255])}}t.RectangleRenderer=g},310:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.RenderModel=t.COMBINED_CHAR_BIT_MASK=t.RENDER_MODEL_EXT_OFFSET=t.RENDER_MODEL_FG_OFFSET=t.RENDER_MODEL_BG_OFFSET=t.RENDER_MODEL_INDICIES_PER_CELL=void 0;let r=n(296);t.RENDER_MODEL_INDICIES_PER_CELL=4,t.RENDER_MODEL_BG_OFFSET=1,t.RENDER_MODEL_FG_OFFSET=2,t.RENDER_MODEL_EXT_OFFSET=3,t.COMBINED_CHAR_BIT_MASK=2147483648,t.RenderModel=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=(0,r.createSelectionRenderModel)()}resize(e,n){let r=e*n*t.RENDER_MODEL_INDICIES_PER_CELL;r!==this.cells.length&&(this.cells=new Uint32Array(r),this.lineLengths=new Uint32Array(n))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}}},666:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.JoinedCellData=t.WebglRenderer=void 0;let r=n(820),i=n(274),a=n(627),o=n(457),s=n(56),c=n(374),l=n(345),u=n(859),d=n(147),f=n(782),p=n(855),m=n(965),h=n(742),g=n(310),_=n(733);class v extends u.Disposable{constructor(e,t,n,o,d,p,m,h,v){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=o,this._coreService=d,this._decorationService=p,this._optionsService=m,this._themeService=h,this._cursorBlinkStateManager=new u.MutableDisposable,this._charAtlasDisposable=this.register(new u.MutableDisposable),this._observerDisposable=this.register(new u.MutableDisposable),this._model=new g.RenderModel,this._workCell=new f.CellData,this._workCell2=new f.CellData,this._rectangleRenderer=this.register(new u.MutableDisposable),this._glyphRenderer=this.register(new u.MutableDisposable),this._onChangeTextureAtlas=this.register(new l.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new l.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new l.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this.register(new l.EventEmitter),this.onContextLoss=this._onContextLoss.event,this.register(this._themeService.onChangeColors((()=>this._handleColorChange()))),this._cellColorResolver=new i.CellColorResolver(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new _.LinkRenderLayer(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,m,this._themeService)],this.dimensions=(0,c.createRenderDimensions)(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this.register(m.onOptionChange((()=>this._handleOptionsChanged()))),this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let y={antialias:!1,depth:!1,preserveDrawingBuffer:v};if(this._gl=this._canvas.getContext(`webgl2`,y),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this.register((0,r.addDisposableDomListener)(this._canvas,`webglcontextlost`,(e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout((()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)}),3e3)}))),this.register((0,r.addDisposableDomListener)(this._canvas,`webglcontextrestored`,(e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,(0,a.removeTerminalFromCache)(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()}))),this._observerDisposable.value=(0,s.observeDevicePixelDimensions)(this._canvas,this._coreBrowserService.window,((e,t)=>this._setCanvasDevicePixelDimensions(e,t))),this.register(this._coreBrowserService.onWindowChange((e=>{this._observerDisposable.value=(0,s.observeDevicePixelDimensions)(this._canvas,e,((e,t)=>this._setCanvasDevicePixelDimensions(e,t)))}))),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._coreBrowserService.window.document.body.contains(this._core.screenElement),this.register((0,u.toDisposable)((()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),(0,a.removeTerminalFromCache)(this._terminal)})))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new h.RectangleRenderer(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new m.GlyphRenderer(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);let e=(0,a.acquireTextureAtlas)(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=(0,u.getDisposeArrayDisposable)([(0,l.forwardEvent)(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),(0,l.forwardEvent)(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)])),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}registerCharacterJoiner(e){return-1}deregisterCharacterJoiner(e){return!1}renderRows(e,t){if(!this._isAttached){if(!(this._coreBrowserService.window.document.body.contains(this._core.screenElement)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);this._glyphRenderer.value&&this._rectangleRenderer.value&&(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),this._cursorBlinkStateManager.value&&!this._cursorBlinkStateManager.value.isCursorVisible||this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new o.CursorBlinkStateManager((()=>{this._requestRedrawCursor()}),this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r,i,a,o,s,c,l,u,d,f,m,h,_,v,x=this._workCell;e=b(e,n.rows-1,0),t=b(t,n.rows-1,0);let S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,C=S-n.buffer.ydisp,w=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),T=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let D=!1;for(i=e;i<=t;i++)for(a=i+n.buffer.ydisp,o=n.buffer.lines.get(a),this._model.lineLengths[i]=0,s=this._characterJoinerService.getJoinedCharacters(a),_=0;_<n.cols;_++)if(r=this._cellColorResolver.result.bg,o.loadCell(_,x),_===0&&(r=this._cellColorResolver.result.bg),c=!1,l=_,s.length>0&&_===s[0][0]&&(c=!0,u=s.shift(),x=new y(x,o.translateToString(!0,u[0],u[1]),u[1]-u[0]),l=u[1]-1),d=x.getChars(),f=x.getCode(),h=(i*n.cols+_)*g.RENDER_MODEL_INDICIES_PER_CELL,this._cellColorResolver.resolve(x,_,a,this.dimensions.device.cell.width),E&&a===S&&(_===w&&(this._model.cursor={x:w,y:C,width:x.getWidth(),style:this._coreBrowserService.isFocused?n.options.cursorStyle||`block`:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},T=w+x.getWidth()-1),_>=w&&_<=T&&(this._coreBrowserService.isFocused&&(n.options.cursorStyle||`block`)===`block`||!1===this._coreBrowserService.isFocused&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),f!==p.NULL_CELL_CODE&&(this._model.lineLengths[i]=_+1),(this._model.cells[h]!==f||this._model.cells[h+g.RENDER_MODEL_BG_OFFSET]!==this._cellColorResolver.result.bg||this._model.cells[h+g.RENDER_MODEL_FG_OFFSET]!==this._cellColorResolver.result.fg||this._model.cells[h+g.RENDER_MODEL_EXT_OFFSET]!==this._cellColorResolver.result.ext)&&(D=!0,d.length>1&&(f|=g.COMBINED_CHAR_BIT_MASK),this._model.cells[h]=f,this._model.cells[h+g.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[h+g.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[h+g.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext,m=x.getWidth(),this._glyphRenderer.value.updateCell(_,i,f,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,d,m,r),c))for(x=this._workCell,_++;_<l;_++)v=(i*n.cols+_)*g.RENDER_MODEL_INDICIES_PER_CELL,this._glyphRenderer.value.updateCell(_,i,p.NULL_CELL_CODE,0,0,0,p.NULL_CELL_CHAR,0,0),this._model.cells[v]=p.NULL_CELL_CODE,this._model.cells[v+g.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[v+g.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[v+g.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext;D&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){this._charSizeService.width&&this._charSizeService.height&&(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}}t.WebglRenderer=v;class y extends d.AttributeData{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}function b(e,t,n=0){return Math.max(Math.min(e,t),n)}t.JoinedCellData=y},381:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.GLTexture=t.expandFloat32Array=t.createShader=t.createProgram=t.PROJECTION_MATRIX=void 0;let r=n(374);function i(e,t,n){let i=(0,r.throwIfFalsy)(e.createShader(t));if(e.shaderSource(i,n),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))return i;console.error(e.getShaderInfoLog(i)),e.deleteShader(i)}t.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),t.createProgram=function(e,t,n){let a=(0,r.throwIfFalsy)(e.createProgram());if(e.attachShader(a,(0,r.throwIfFalsy)(i(e,e.VERTEX_SHADER,t))),e.attachShader(a,(0,r.throwIfFalsy)(i(e,e.FRAGMENT_SHADER,n))),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS))return a;console.error(e.getProgramInfoLog(a)),e.deleteProgram(a)},t.createShader=i,t.expandFloat32Array=function(e,t){let n=Math.min(2*e.length,t),r=new Float32Array(n);for(let t=0;t<e.length;t++)r[t]=e[t];return r},t.GLTexture=class{constructor(e){this.texture=e,this.version=-1}}},592:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.BaseRenderLayer=void 0;let r=n(627),i=n(237),a=n(374),o=n(859);class s extends o.Disposable{constructor(e,t,n,r,i,a,s,c){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=s,this._themeService=c,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this.register(this._themeService.onChangeColors((t=>{this._refreshCharAtlas(e,t),this.reset(e)}))),this.register((0,o.toDisposable)((()=>{this._canvas.remove()})))}_initCanvas(){this._ctx=(0,a.throwIfFalsy)(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=(0,r.acquireTextureAtlas)(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=i.TEXT_BASELINE,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){return`${n?`italic`:``} ${t?e.options.fontWeightBold:e.options.fontWeight} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}}t.BaseRenderLayer=s},733:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.LinkRenderLayer=void 0;let r=n(197),i=n(237),a=n(592);class o extends a.BaseRenderLayer{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this.register(r.onShowLinkUnderline((e=>this._handleShowLinkUnderline(e)))),this.register(r.onHideLinkUnderline((e=>this._handleHideLinkUnderline(e))))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===i.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&(0,r.is256Color)(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}}t.LinkRenderLayer=o},820:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,r){e.addEventListener(t,n,r);let i=!1;return{dispose:()=>{i||(i=!0,e.removeEventListener(t,n,r))}}}},274:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CellColorResolver=void 0;let r=n(855),i=n(160),a=n(374),o,s=0,c=0,l=!1,u=!1,d=!1,f=0;t.CellColorResolver=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,p){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=268435456&e.bg?e.extended.ext:0,c=0,s=0,u=!1,l=!1,d=!1,o=this._themeService.colors,f=0,e.getCode()!==r.NULL_CELL_CODE&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));f=t*p%(2*Math.round(e))}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,(e=>{e.backgroundColorRGB&&(c=e.backgroundColorRGB.rgba>>8&16777215,u=!0),e.foregroundColorRGB&&(s=e.foregroundColorRGB.rgba>>8&16777215,l=!0)})),d=this._selectionRenderModel.isCellSelected(this._terminal,t,n),d){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:c=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:c=(16777215&this.result.fg)<<8|255;break;default:c=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:c=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:c=(16777215&this.result.bg)<<8|255}c=i.rgba.blend(c,4294967040&(this._coreBrowserService.isFocused?o.selectionBackgroundOpaque:o.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else c=(this._coreBrowserService.isFocused?o.selectionBackgroundOpaque:o.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(u=!0,o.selectionForeground&&(s=o.selectionForeground.rgba>>8&16777215,l=!0),(0,a.treatGlyphAsBackgroundColor)(e.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))s=(this._coreBrowserService.isFocused?o.selectionBackgroundOpaque:o.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:s=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:s=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:s=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:s=(16777215&this.result.fg)<<8|255;break;default:s=this._themeService.colors.foreground.rgba}s=i.rgba.blend(s,4294967040&(this._coreBrowserService.isFocused?o.selectionBackgroundOpaque:o.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}l=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,(e=>{e.backgroundColorRGB&&(c=e.backgroundColorRGB.rgba>>8&16777215,u=!0),e.foregroundColorRGB&&(s=e.foregroundColorRGB.rgba>>8&16777215,l=!0)})),u&&(c=d?e.bg&-150994944|c|50331648:-16777216&e.bg|c|50331648),l&&(s=e.fg&-83886080|s|50331648),67108864&this.result.fg&&(u&&!l&&(s=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&o.background.rgba>>8|50331648,l=!0),!u&&l&&(c=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&o.foreground.rgba>>8|50331648,u=!0)),o=void 0,this.result.bg=u?c:this.result.bg,this.result.fg=l?s:this.result.fg,this.result.ext&=536870911,this.result.ext|=f<<29&3758096384}}},627:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.removeTerminalFromCache=t.acquireTextureAtlas=void 0;let r=n(509),i=n(197),a=[];t.acquireTextureAtlas=function(e,t,n,o,s,c,l,u){let d=(0,i.generateConfig)(o,s,c,l,t,n,u);for(let t=0;t<a.length;t++){let n=a[t],r=n.ownedBy.indexOf(e);if(r>=0){if((0,i.configEquals)(n.config,d))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),a.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t<a.length;t++){let n=a[t];if((0,i.configEquals)(n.config,d))return n.ownedBy.push(e),n.atlas}let f=e._core,p={atlas:new r.TextureAtlas(document,d,f.unicodeService),config:d,ownedBy:[e]};return a.push(p),p.atlas},t.removeTerminalFromCache=function(e){for(let t=0;t<a.length;t++){let n=a[t].ownedBy.indexOf(e);if(n!==-1){a[t].ownedBy.length===1?(a[t].atlas.dispose(),a.splice(t,1)):a[t].ownedBy.splice(n,1);break}}}},197:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.is256Color=t.configEquals=t.generateConfig=void 0;let r=n(160);t.generateConfig=function(e,t,n,i,a,o,s){let c={foreground:o.foreground,background:o.background,cursor:r.NULL_COLOR,cursorAccent:r.NULL_COLOR,selectionForeground:r.NULL_COLOR,selectionBackgroundTransparent:r.NULL_COLOR,selectionBackgroundOpaque:r.NULL_COLOR,selectionInactiveBackgroundTransparent:r.NULL_COLOR,selectionInactiveBackgroundOpaque:r.NULL_COLOR,ansi:o.ansi.slice(),contrastCache:o.contrastCache,halfContrastCache:o.halfContrastCache};return{customGlyphs:a.customGlyphs,devicePixelRatio:s,letterSpacing:a.letterSpacing,lineHeight:a.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:i,fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.fontWeight,fontWeightBold:a.fontWeightBold,allowTransparency:a.allowTransparency,drawBoldTextInBrightColors:a.drawBoldTextInBrightColors,minimumContrastRatio:a.minimumContrastRatio,colors:c}},t.configEquals=function(e,t){for(let n=0;n<e.colors.ansi.length;n++)if(e.colors.ansi[n].rgba!==t.colors.ansi[n].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba},t.is256Color=function(e){return(50331648&e)==16777216||(50331648&e)==33554432}},237:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;let r=n(399);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=r.isFirefox||r.isLegacyEdge?`bottom`:`ideographic`},457:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CursorBlinkStateManager=void 0,t.CursorBlinkStateManager=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(e=600){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout((()=>{if(this._animationTimeRestarted){let e=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0)return void this._restartInterval(e)}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._renderCallback(),this._animationFrame=void 0})),this._blinkInterval=this._coreBrowserService.window.setInterval((()=>{if(this._animationTimeRestarted){let e=600-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._renderCallback(),this._animationFrame=void 0}))}),600)}),e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}}},860:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.tryDrawCustomChar=t.powerlineDefinitions=t.boxDrawingDefinitions=t.blockElementDefinitions=void 0;let r=n(374);t.blockElementDefinitions={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]};let i={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]};t.boxDrawingDefinitions={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},t.powerlineDefinitions={"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}},t.powerlineDefinitions[``]=t.powerlineDefinitions[``],t.powerlineDefinitions[``]=t.powerlineDefinitions[``],t.tryDrawCustomChar=function(e,n,o,l,u,d,f,p){let m=t.blockElementDefinitions[n];if(m)return function(e,t,n,r,i,a){for(let o=0;o<t.length;o++){let s=t[o],c=i/8,l=a/8;e.fillRect(n+s.x*c,r+s.y*l,s.w*c,s.h*l)}}(e,m,o,l,u,d),!0;let h=i[n];if(h)return function(e,t,n,i,o,s){let c=a.get(t);c||(c=new Map,a.set(t,c));let l=e.fillStyle;if(typeof l!=`string`)throw Error(`Unexpected fillStyle type "${l}"`);let u=c.get(l);if(!u){let n=t[0].length,i=t.length,a=e.canvas.ownerDocument.createElement(`canvas`);a.width=n,a.height=i;let o=(0,r.throwIfFalsy)(a.getContext(`2d`)),s=new ImageData(n,i),d,f,p,m;if(l.startsWith(`#`))d=parseInt(l.slice(1,3),16),f=parseInt(l.slice(3,5),16),p=parseInt(l.slice(5,7),16),m=l.length>7&&parseInt(l.slice(7,9),16)||1;else{if(!l.startsWith(`rgba`))throw Error(`Unexpected fillStyle color format "${l}" when drawing pattern glyph`);[d,f,p,m]=l.substring(5,l.length-1).split(`,`).map((e=>parseFloat(e)))}for(let e=0;e<i;e++)for(let r=0;r<n;r++)s.data[4*(e*n+r)]=d,s.data[4*(e*n+r)+1]=f,s.data[4*(e*n+r)+2]=p,s.data[4*(e*n+r)+3]=t[e][r]*(255*m);o.putImageData(s,0,0),u=(0,r.throwIfFalsy)(e.createPattern(a,null)),c.set(l,u)}e.fillStyle=u,e.fillRect(n,i,o,s)}(e,h,o,l,u,d),!0;let g=t.boxDrawingDefinitions[n];if(g)return function(e,t,n,r,i,a,o){e.strokeStyle=e.fillStyle;for(let[l,u]of Object.entries(t)){let t;e.beginPath(),e.lineWidth=o*Number.parseInt(l),t=typeof u==`function`?u(.15,.15/a*i):u;for(let l of t.split(` `)){let t=l[0],u=s[t];if(!u){console.error(`Could not find drawing instructions for "${t}"`);continue}let d=l.substring(1).split(`,`);d[0]&&d[1]&&u(e,c(d,i,a,n,r,!0,o))}e.stroke(),e.closePath()}}(e,g,o,l,u,d,p),!0;let _=t.powerlineDefinitions[n];return!!_&&(function(e,t,n,r,i,a,o,l){let u=new Path2D;u.rect(n,r,i,a),e.clip(u),e.beginPath();let d=o/12;e.lineWidth=l*d;for(let o of t.d.split(` `)){let u=o[0],f=s[u];if(!f){console.error(`Could not find drawing instructions for "${u}"`);continue}let p=o.substring(1).split(`,`);p[0]&&p[1]&&f(e,c(p,i,a,n,r,!1,l,(t.leftPadding??0)*(d/2),(t.rightPadding??0)*(d/2)))}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}(e,_,o,l,u,d,f,p),!0)};let a=new Map;function o(e,t,n=0){return Math.max(Math.min(e,t),n)}let s={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function c(e,t,n,r,i,a,s,c=0,l=0){let u=e.map((e=>parseFloat(e)||parseInt(e)));if(u.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;e<u.length;e+=2)u[e]*=t-c*s-l*s,a&&u[e]!==0&&(u[e]=o(Math.round(u[e]+.5)-.5,t,0)),u[e]+=r+c*s;for(let e=1;e<u.length;e+=2)u[e]*=n,a&&u[e]!==0&&(u[e]=o(Math.round(u[e]+.5)-.5,n,0)),u[e]+=i;return u}},56:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.observeDevicePixelDimensions=void 0;let r=n(859);t.observeDevicePixelDimensions=function(e,t,n){let i=new t.ResizeObserver((t=>{let r=t.find((t=>t.target===e));if(!r)return;if(!(`devicePixelContentBoxSize`in r))return i?.disconnect(),void(i=void 0);let a=r.devicePixelContentBoxSize[0].inlineSize,o=r.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)}));try{i.observe(e,{box:[`device-pixel-content-box`]})}catch{i.disconnect(),i=void 0}return(0,r.toDisposable)((()=>i?.disconnect()))}},374:(e,t)=>{function n(e){return 57508<=e&&e<=57558}function r(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,`__esModule`,{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw Error(`value must not be falsy`);return e},t.isPowerlineGlyph=n,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=r,t.allowRescaling=function(e,t,i,a){return t===1&&i>Math.ceil(1.5*a)&&e!==void 0&&e>255&&!r(e)&&!n(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return n(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,n=0){return(e-(2*Math.round(t)-n))%(2*Math.round(t))}},296:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createSelectionRenderModel=void 0;class n{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1])return void this.clear();let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new n}},509:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TextureAtlas=void 0;let r=n(237),i=n(860),a=n(374),o=n(160),s=n(345),c=n(485),l=n(385),u=n(147),d=n(855),f={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},p;class m{get pages(){return this._pages}constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new c.FourKeyMap,this._cacheMapCombined=new c.FourKeyMap,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new u.AttributeData,this._textureSize=512,this._onAddTextureAtlasCanvas=new s.EventEmitter,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new s.EventEmitter,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=_(e,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=(0,a.throwIfFalsy)(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}dispose(){for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new l.IdleTaskQueue;for(let t=33;t<126;t++)e.enqueue((()=>{if(!this._cacheMap.get(t,d.DEFAULT_COLOR,d.DEFAULT_COLOR,d.DEFAULT_EXT)){let e=this._drawToCache(t,d.DEFAULT_COLOR,d.DEFAULT_COLOR,d.DEFAULT_EXT);this._cacheMap.set(t,d.DEFAULT_COLOR,d.DEFAULT_COLOR,d.DEFAULT_EXT,e)}}))}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(m.maxAtlasPages&&this._pages.length>=Math.max(4,m.maxAtlasPages)){let e=this._pages.filter((e=>2*e.canvas.width<=(m.maxTextureSize||4096))).sort(((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width)),t=-1,n=0;for(let r=0;r<e.length;r++)if(e[r].canvas.width!==n)t=r,n=e[r].canvas.width;else if(r-t==3)break;let r=e.slice(t,t+4),i=r.map((e=>e.glyphs[0].texturePage)).sort(((e,t)=>e>t?1:-1)),a=this.pages.length-r.length,o=this._mergePages(r,a);o.version++;for(let e=i.length-1;e>=0;e--)this._deletePage(i[e]);this.pages.push(o),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(o.canvas)}let e=new h(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,t){let n=2*e[0].canvas.width,r=new h(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,n,r,i){return this._getFromCacheMap(this._cacheMapCombined,e,t,n,r,i)}getRasterizedGlyph(e,t,n,r,i){return this._getFromCacheMap(this._cacheMap,e,t,n,r,i)}_getFromCacheMap(e,t,n,r,i,a=!1){return p=e.get(t,n,r,i),p||(p=this._drawToCache(t,n,r,i,a),e.set(t,n,r,i,p)),p}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return o.NULL_COLOR;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=u.AttributeData.toColorRGB(t);i=o.channels.toColor(e[0],e[1],e[2]);break;default:i=n?o.color.opaque(this._config.colors.foreground):this._config.colors.background}return i}_getForegroundColor(e,t,n,i,a,s,c,l,d,f){let p=this._getMinimumContrastColor(e,t,n,i,a,s,c,d,l,f);if(p)return p;let m;switch(a){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&d&&s<8&&(s+=8),m=this._getColorFromAnsiIndex(s);break;case 50331648:let e=u.AttributeData.toColorRGB(s);m=o.channels.toColor(e[0],e[1],e[2]);break;default:m=c?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(m=o.color.opaque(m)),l&&(m=o.color.multiplyOpacity(m,r.DIM_OPACITY)),m}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,s,c,l,u){if(this._config.minimumContrastRatio===1||u)return;let d=this._getContrastCache(l),f=d.getColor(e,r);if(f!==void 0)return f||void 0;let p=this._resolveBackgroundRgba(t,n,s),m=this._resolveForegroundRgba(i,a,s,c),h=o.rgba.ensureContrastRatio(p,m,this._config.minimumContrastRatio/(l?2:1));if(!h)return void d.setColor(e,r,null);let g=o.channels.toColor(h>>24&255,h>>16&255,h>>8&255);return d.setColor(e,r,g),g}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,t,n,o,s=!1){let c=typeof e==`number`?String.fromCharCode(e):e,l=Math.min(this._config.deviceCellWidth*Math.max(c.length,2)+4,this._textureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let d=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<d&&(this._tmpCanvas.height=d),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=t,this._workAttributeData.extended.ext=o,this._workAttributeData.isInvisible())return f;let p=!!this._workAttributeData.isBold(),h=!!this._workAttributeData.isInverse(),_=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),y=!!this._workAttributeData.isUnderline(),b=!!this._workAttributeData.isStrikethrough(),x=!!this._workAttributeData.isOverline(),S=this._workAttributeData.getFgColor(),C=this._workAttributeData.getFgColorMode(),w=this._workAttributeData.getBgColor(),T=this._workAttributeData.getBgColorMode();if(h){let e=S;S=w,w=e;let t=C;C=T,T=t}let E=this._getBackgroundColor(T,w,h,_);this._tmpCtx.globalCompositeOperation=`copy`,this._tmpCtx.fillStyle=E.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation=`source-over`;let D=p?this._config.fontWeightBold:this._config.fontWeight,O=v?`italic`:``;this._tmpCtx.font=`${O} ${D} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=r.TEXT_BASELINE;let k=c.length===1&&(0,a.isPowerlineGlyph)(c.charCodeAt(0)),A=c.length===1&&(0,a.isRestrictedPowerlineGlyph)(c.charCodeAt(0)),j=this._getForegroundColor(t,T,w,n,C,S,h,_,p,(0,a.treatGlyphAsBackgroundColor)(c.charCodeAt(0)));this._tmpCtx.fillStyle=j.css;let M=A?0:4,N=!1;!1!==this._config.customGlyphs&&(N=(0,i.tryDrawCustomChar)(this._tmpCtx,c,M,M,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let P,F=!k;if(P=typeof e==`number`?this._unicodeService.wcwidth(e):this._unicodeService.getStringCellWidth(e),y){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())F=!1,this._tmpCtx.strokeStyle=`rgb(${u.AttributeData.toColorRGB(this._workAttributeData.getUnderlineColor()).join(`,`)})`;else{F=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let n=M,r=Math.ceil(M+this._config.deviceCharHeight)-t-(s?2*e:0),i=r+e,o=r+2*e,l=this._workAttributeData.getUnderlineVariantOffset();for(let s=0;s<P;s++){this._tmpCtx.save();let c=n+s*this._config.deviceCellWidth,u=n+(s+1)*this._config.deviceCellWidth,d=c+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(c,r),this._tmpCtx.lineTo(u,r),this._tmpCtx.moveTo(c,o),this._tmpCtx.lineTo(u,o);break;case 3:let n=e<=1?o:Math.ceil(M+this._config.deviceCharHeight-e/2)-t,s=e<=1?r:Math.ceil(M+this._config.deviceCharHeight+e/2)-t,f=new Path2D;f.rect(c,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(f),this._tmpCtx.moveTo(c-this._config.deviceCellWidth/2,i),this._tmpCtx.bezierCurveTo(c-this._config.deviceCellWidth/2,s,c,s,c,i),this._tmpCtx.bezierCurveTo(c,n,d,n,d,i),this._tmpCtx.bezierCurveTo(d,s,u,s,u,i),this._tmpCtx.bezierCurveTo(u,n,u+this._config.deviceCellWidth/2,n,u+this._config.deviceCellWidth/2,i);break;case 4:let p=l===0?0:l>=e?2*e-l:e-l;!(l>=e)==0||p===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(c+p,r),this._tmpCtx.lineTo(u,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(c,r),this._tmpCtx.lineTo(c+p,r),this._tmpCtx.moveTo(c+p+e,r),this._tmpCtx.lineTo(u,r)),l=(0,a.computeNextVariantOffset)(u-c,e,l);break;case 5:let m=u-c,h=Math.floor(.6*m),g=Math.floor(.3*m),_=m-h-g;this._tmpCtx.setLineDash([h,g,_]),this._tmpCtx.moveTo(c,r),this._tmpCtx.lineTo(u,r);break;default:this._tmpCtx.moveTo(c,r),this._tmpCtx.lineTo(u,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!N&&this._config.fontSize>=12&&!this._config.allowTransparency&&c!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(c);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*P,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=E.css,this._tmpCtx.strokeText(c,M,M+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(x){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(M,M+t),this._tmpCtx.lineTo(M+this._config.deviceCharWidth*P,M+t),this._tmpCtx.stroke()}if(N||this._tmpCtx.fillText(c,M,M+this._config.deviceCharHeight),c===`_`&&!this._config.allowTransparency){let e=g(this._tmpCtx.getImageData(M,M,this._config.deviceCellWidth,this._config.deviceCellHeight),E,j,F);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=E.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(c,M,M+this._config.deviceCharHeight-t),e=g(this._tmpCtx.getImageData(M,M,this._config.deviceCellWidth,this._config.deviceCellHeight),E,j,F),e);t++);}if(b){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(M,M+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(M+this._config.deviceCharWidth*P,M+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let I=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),L;if(L=this._config.allowTransparency?function(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}(I):g(I,E,j,F),L)return f;let R=this._findGlyphBoundingBox(I,this._workBoundingBox,l,A,N,M),z,B;for(;;){if(this._activePages.length===0){let e=this._createNewPage();z=e,B=e.currentRow,B.height=R.size.y;break}z=this._activePages[this._activePages.length-1],B=z.currentRow;for(let e of this._activePages)R.size.y<=e.currentRow.height&&(z=e,B=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=B.height&&R.size.y<=t.height&&(z=this._activePages[e],B=t);if(B.y+R.size.y>=z.canvas.height||B.height>R.size.y+2){let e=!1;if(z.currentRow.y+z.currentRow.height+R.size.y>=z.canvas.height){let t;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+R.size.y<e.canvas.height){t=e;break}if(t)z=t;else if(m.maxAtlasPages&&this._pages.length>=m.maxAtlasPages&&B.y+R.size.y<=z.canvas.height&&B.height>=R.size.y&&B.x+R.size.x<=z.canvas.width)e=!0;else{let t=this._createNewPage();z=t,B=t.currentRow,B.height=R.size.y,e=!0}}e||(z.currentRow.height>0&&z.fixedRows.push(z.currentRow),B={x:0,y:z.currentRow.y+z.currentRow.height,height:R.size.y},z.fixedRows.push(B),z.currentRow={x:0,y:B.y+B.height,height:0})}if(B.x+R.size.x<=z.canvas.width)break;B===z.currentRow?(B.x=0,B.y+=B.height,B.height=0):z.fixedRows.splice(z.fixedRows.indexOf(B),1)}return R.texturePage=this._pages.indexOf(z),R.texturePosition.x=B.x,R.texturePosition.y=B.y,R.texturePositionClipSpace.x=B.x/z.canvas.width,R.texturePositionClipSpace.y=B.y/z.canvas.height,R.sizeClipSpace.x/=z.canvas.width,R.sizeClipSpace.y/=z.canvas.height,B.height=Math.max(B.height,R.size.y),B.x+=R.size.x,z.ctx.putImageData(I,R.texturePosition.x-this._workBoundingBox.left,R.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,R.size.x,R.size.y),z.addGlyph(R),z.version++,R}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n<o;n++){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+4*r+3;if(e.data[i]!==0){t.top=n,c=!0;break}}if(c)break}t.left=0,c=!1;for(let n=0;n<a+s;n++){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+4*n+3;if(e.data[i]!==0){t.left=n,c=!0;break}}if(c)break}t.right=s,c=!1;for(let n=a+s-1;n>=a;n--){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+4*n+3;if(e.data[i]!==0){t.right=n,c=!0;break}}if(c)break}t.bottom=o,c=!1;for(let n=o-1;n>=0;n--){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+4*r+3;if(e.data[i]!==0){t.bottom=n,c=!0;break}}if(c)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+a+(r||i?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+a+(r||i?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}}t.TextureAtlas=m;class h{get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.size.y}constructor(e,t,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let e of n)this._glyphs.push(...e.glyphs),this._usedPixels+=e._usedPixels;this.canvas=_(e,t,t),this.ctx=(0,a.throwIfFalsy)(this.canvas.getContext(`2d`,{alpha:!0}))}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}}function g(e,t,n,r){let i=t.rgba>>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t<e.data.length;t+=4)e.data[t]===i&&e.data[t+1]===a&&e.data[t+2]===o||r&&Math.abs(e.data[t]-i)+Math.abs(e.data[t+1]-a)+Math.abs(e.data[t+2]-o)<u?e.data[t+3]=0:d=!1;return d}function _(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}},160:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let n=0,r=0,i=0,a=0;var o,s,c,l,u;function d(e){let t=e.toString(16);return t.length<2?`0`+t:t}function f(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:`#00000000`,rgba:0},function(e){e.toCss=function(e,t,n,r){return r===void 0?`#${d(e)}${d(t)}${d(n)}`:`#${d(e)}${d(t)}${d(n)}${d(r)}`},e.toRgba=function(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0},e.toColor=function(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}}(o||(t.channels=o={})),function(e){function t(e,t){return a=Math.round(255*t),[n,r,i]=u.toChannels(e.rgba),{css:o.toCss(n,r,i,a),rgba:o.toRgba(n,r,i,a)}}e.blend=function(e,t){if(a=(255&t.rgba)/255,a===1)return{css:t.css,rgba:t.rgba};let s=t.rgba>>24&255,c=t.rgba>>16&255,l=t.rgba>>8&255,u=e.rgba>>24&255,d=e.rgba>>16&255,f=e.rgba>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),{css:o.toCss(n,r,i),rgba:o.toRgba(n,r,i)}},e.isOpaque=function(e){return(255&e.rgba)==255},e.ensureContrastRatio=function(e,t,n){let r=u.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return o.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[n,r,i]=u.toChannels(t),{css:o.toCss(n,r,i),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,n){return a=255&e.rgba,t(e,a*n/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(s||(t.color=s={})),function(e){let t,s;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let n=e.getContext(`2d`,{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation=`copy`,s=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),o.toColor(n,r,i);case 5:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),a=parseInt(e.slice(4,5).repeat(2),16),o.toColor(n,r,i,a);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 c=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(c)return n=parseInt(c[1]),r=parseInt(c[2]),i=parseInt(c[3]),a=Math.round(255*(c[5]===void 0?1:parseFloat(c[5]))),o.toColor(n,r,i,a);if(!t||!s||(t.fillStyle=s,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[n,r,i,a]=t.getImageData(0,0,1,1).data,a!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:o.toRgba(n,r,i,a),css:e}}}(c||(t.css=c={})),function(e){function t(e,t,n){let r=e/255,i=t/255,a=n/255;return .2126*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.7152*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)+.0722*(a<=.03928?a/12.92:((a+.055)/1.055)**2.4)}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(l||(t.rgb=l={})),function(e){function t(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,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),s-=Math.max(0,Math.ceil(.1*s)),c-=Math.max(0,Math.ceil(.1*c)),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}function s(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,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),s=Math.min(255,s+Math.ceil(.1*(255-s))),c=Math.min(255,c+Math.ceil(.1*(255-c))),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.blend=function(e,t){if(a=(255&t)/255,a===1)return t;let s=t>>24&255,c=t>>16&255,l=t>>8&255,u=e>>24&255,d=e>>16&255,f=e>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),o.toRgba(n,r,i)},e.ensureContrastRatio=function(e,n,r){let i=l.relativeLuminance(e>>8),a=l.relativeLuminance(n>>8);if(f(i,a)<r){if(a<i){let a=t(e,n,r),o=f(i,l.relativeLuminance(a>>8));if(o<r){let t=s(e,n,r);return o>f(i,l.relativeLuminance(t>>8))?a:t}return a}let o=s(e,n,r),c=f(i,l.relativeLuminance(o>>8));if(c<r){let a=t(e,n,r);return c>f(i,l.relativeLuminance(a>>8))?o:a}return o}},e.reduceLuminance=t,e.increaseLuminance=s,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(u||(t.rgba=u={})),t.toPaddedHex=d,t.contrastRatio=f},345:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,`__esModule`,{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}},485:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=n,t.FourKeyMap=class{constructor(){this._data=new n}set(e,t,r,i,a){this._data.get(e,t)||this._data.set(e,t,new n),this._data.get(e,t).set(r,i,a)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}}},399:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.getSafariVersion=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.isNode=typeof process<`u`&&`title`in process;let n=t.isNode?`node`:navigator.userAgent,r=t.isNode?`node`:navigator.platform;t.isFirefox=n.includes(`Firefox`),t.isLegacyEdge=n.includes(`Edge`),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.getSafariVersion=function(){if(!t.isSafari)return 0;let e=n.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])},t.isMac=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(r),t.isIpad=r===`iPad`,t.isIphone=r===`iPhone`,t.isWindows=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(r),t.isLinux=r.indexOf(`Linux`)>=0,t.isChromeOS=/\bCrOS\b/.test(n)},385:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let r=n(399);class i{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=Date.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,Date.now()-t),n=Math.max(t,n),i=e.timeRemaining(),1.5*n>i)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=i}this.clear()}}class a extends i{_requestCallback(e){return setTimeout((()=>e(this._createDeadline(16))))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=Date.now()+e;return{timeRemaining:()=>Math.max(0,t-Date.now())}}}t.PriorityTaskQueue=a,t.IdleTaskQueue=!r.isNode&&`requestIdleCallback`in window?class extends i{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:a,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}}},147:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new r}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let e=new n;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t.AttributeData=n;class r{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}clone(){return new r(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=r},782:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CellData=void 0;let r=n(133),i=n(855),a=n(147);class o extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=``}static fromCharData(e){let t=new o;return t.setFromCharData(e),t}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,r.stringFromCodePoint)(2097151&this.content):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[i.CHAR_DATA_ATTR_INDEX],this.bg=0;let t=!1;if(e[i.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(e[i.CHAR_DATA_CHAR_INDEX].length===2){let n=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(n-55296)+r-56320+65536|e[i.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[i.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[i.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[i.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=o},855:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR=``,t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=` `,t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},133:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=1024*(this._interim-55296)+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=1024*(i-55296)+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r,i,a,o,s=0,c=0,l=0;if(this.interim[0]){let r=!1,i=this.interim[0];i&=(224&i)==192?31:(240&i)==224?15:7;let a,o=0;for(;(a=63&this.interim[++o])&&o<4;)i<<=6,i|=a;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(a=e[l++],(192&a)!=128){l--,r=!0;break}this.interim[o++]=a,i<<=6,i|=63&a}r||(c===2?i<128?l--:t[s++]=i:c===3?i<2048||i>=55296&&i<=57343||i===65279||(t[s++]=i):i<65536||i>1114111||(t[s++]=i)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;!(!(d<u)||128&(r=e[d])||128&(i=e[d+1])||128&(a=e[d+2])||128&(o=e[d+3]));)t[s++]=r,t[s++]=i,t[s++]=a,t[s++]=o,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((224&r)==192){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(c=(31&r)<<6|63&i,c<128){d--;continue}t[s++]=c}else if((240&r)==224){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(c=(15&r)<<12|(63&i)<<6|63&a,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((248&r)==240){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,this.interim[2]=a,s;if(o=e[d++],(192&o)!=128){d--;continue}if(c=(7&r)<<18|(63&i)<<12|(63&a)<<6|63&o,c<65536||c>1114111)continue;t[s++]=c}}return s}}},776:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;let a=n(859),o=n(97),s={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF},c,l=t.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange(`logLevel`,(()=>this._updateLogLevel()))),c=this}_updateLogLevel(){this._logLevel=s[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:`xterm.js: `)+t,...n)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=r([i(0,o.IOptionsService)],l),t.setTraceLogger=function(e){c=e},t.traceCall=function(e,t,n){if(typeof n.value!=`function`)throw Error(`not supported`);let r=n.value;n.value=function(...e){if(c.logLevel!==o.LogLevelEnum.TRACE)return r.apply(this,e);c.trace(`GlyphRenderer#${r.name}(${e.map((e=>JSON.stringify(e))).join(`, `)})`);let t=r.apply(this,e);return c.trace(`GlyphRenderer#${r.name} return`,t),t}}},726:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;let n=`di$target`,r=`di$dependencies`;t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);let i=function(e,t,a){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);(function(e,t,i){t[n]===t?t[r].push({id:e,index:i}):(t[r]=[{id:e,index:i}],t[n]=t)})(i,e,a)};return i.toString=()=>e,t.serviceRegistry.set(e,i),i}},97:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let r=n(726);var i;t.IBufferService=(0,r.createDecorator)(`BufferService`),t.ICoreMouseService=(0,r.createDecorator)(`CoreMouseService`),t.ICoreService=(0,r.createDecorator)(`CoreService`),t.ICharsetService=(0,r.createDecorator)(`CharsetService`),t.IInstantiationService=(0,r.createDecorator)(`InstantiationService`),function(e){e[e.TRACE=0]=`TRACE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.OFF=5]=`OFF`}(i||(t.LogLevelEnum=i={})),t.ILogService=(0,r.createDecorator)(`LogService`),t.IOptionsService=(0,r.createDecorator)(`OptionsService`),t.IOscLinkService=(0,r.createDecorator)(`OscLinkService`),t.IUnicodeService=(0,r.createDecorator)(`UnicodeService`),t.IDecorationService=(0,r.createDecorator)(`DecorationService`)}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.WebglAddon=void 0;let t=n(345),i=n(859),a=n(399),o=n(666),s=n(776);class c extends i.Disposable{constructor(e){if(a.isSafari&&(0,a.getSafariVersion)()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this.register(new t.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new t.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new t.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this.register(new t.EventEmitter),this.onContextLoss=this._onContextLoss.event}activate(e){let n=e._core;if(!e.element)return void this.register(n.onWillOpen((()=>this.activate(e))));this._terminal=e;let r=n.coreService,a=n.optionsService,c=n,l=c._renderService,u=c._characterJoinerService,d=c._charSizeService,f=c._coreBrowserService,p=c._decorationService,m=c._logService,h=c._themeService;(0,s.setTraceLogger)(m),this._renderer=this.register(new o.WebglRenderer(e,u,d,f,r,p,a,h,this._preserveDrawingBuffer)),this.register((0,t.forwardEvent)(this._renderer.onContextLoss,this._onContextLoss)),this.register((0,t.forwardEvent)(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this.register((0,t.forwardEvent)(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this.register((0,t.forwardEvent)(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),l.setRenderer(this._renderer),this.register((0,i.toDisposable)((()=>{let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)})))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}}e.WebglAddon=c})(),r})()))}))(),tE=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=rE.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function nE(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var rE=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!nE(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},iE=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function aE(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var oE=class{constructor(e=aE,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||iE;this._linkProvider=this._terminal.registerLinkProvider(new tE(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},sE=`3.7.8`,cE=sE,lE=typeof Buffer==`function`,uE=typeof TextDecoder==`function`?new TextDecoder:void 0,dE=typeof TextEncoder==`function`?new TextEncoder:void 0,fE=Array.prototype.slice.call(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`),pE=(e=>{let t={};return e.forEach((e,n)=>t[e]=n),t})(fE),mE=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,hE=String.fromCharCode.bind(String),gE=typeof Uint8Array.from==`function`?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),_E=e=>e.replace(/=/g,``).replace(/[+\/]/g,e=>e==`+`?`-`:`_`),vE=e=>e.replace(/[^A-Za-z0-9\+\/]/g,``),yE=e=>{let t,n,r,i,a=``,o=e.length%3;for(let o=0;o<e.length;){if((n=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255)throw TypeError(`invalid character found`);t=n<<16|r<<8|i,a+=fE[t>>18&63]+fE[t>>12&63]+fE[t>>6&63]+fE[t&63]}return o?a.slice(0,o-3)+`===`.substring(o):a},bE=typeof btoa==`function`?e=>btoa(e):lE?e=>Buffer.from(e,`binary`).toString(`base64`):yE,xE=lE?e=>Buffer.from(e).toString(`base64`):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(hE.apply(null,e.subarray(n,n+4096)));return bE(t.join(``))},SE=(e,t=!1)=>t?_E(xE(e)):xE(e),CE=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?hE(192|t>>>6)+hE(128|t&63):hE(224|t>>>12&15)+hE(128|t>>>6&63)+hE(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return hE(240|t>>>18&7)+hE(128|t>>>12&63)+hE(128|t>>>6&63)+hE(128|t&63)}},wE=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,TE=e=>e.replace(wE,CE),EE=lE?e=>Buffer.from(e,`utf8`).toString(`base64`):dE?e=>xE(dE.encode(e)):e=>bE(TE(e)),DE=(e,t=!1)=>t?_E(EE(e)):EE(e),OE=e=>DE(e,!0),kE=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,AE=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return hE((t>>>10)+55296)+hE((t&1023)+56320);case 3:return hE((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return hE((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},jE=e=>e.replace(kE,AE),ME=e=>{if(e=e.replace(/\s+/g,``),!mE.test(e))throw TypeError(`malformed base64.`);e+=`==`.slice(2-(e.length&3));let t,n,r,i=[];for(let a=0;a<e.length;)t=pE[e.charAt(a++)]<<18|pE[e.charAt(a++)]<<12|(n=pE[e.charAt(a++)])<<6|(r=pE[e.charAt(a++)]),n===64?i.push(hE(t>>16&255)):r===64?i.push(hE(t>>16&255,t>>8&255)):i.push(hE(t>>16&255,t>>8&255,t&255));return i.join(``)},NE=typeof atob==`function`?e=>atob(vE(e)):lE?e=>Buffer.from(e,`base64`).toString(`binary`):ME,PE=lE?e=>gE(Buffer.from(e,`base64`)):e=>gE(NE(e).split(``).map(e=>e.charCodeAt(0))),FE=e=>PE(LE(e)),IE=lE?e=>Buffer.from(e,`base64`).toString(`utf8`):uE?e=>uE.decode(PE(e)):e=>jE(NE(e)),LE=e=>vE(e.replace(/[-_]/g,e=>e==`-`?`+`:`/`)),RE=e=>IE(LE(e)),zE=e=>{if(typeof e!=`string`)return!1;let t=e.replace(/\s+/g,``).replace(/={0,2}$/,``);return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},BE=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),VE=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,BE(t));e(`fromBase64`,function(){return RE(this)}),e(`toBase64`,function(e){return DE(this,e)}),e(`toBase64URI`,function(){return DE(this,!0)}),e(`toBase64URL`,function(){return DE(this,!0)}),e(`toUint8Array`,function(){return FE(this)})},HE=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,BE(t));e(`toBase64`,function(e){return SE(this,e)}),e(`toBase64URI`,function(){return SE(this,!0)}),e(`toBase64URL`,function(){return SE(this,!0)})},UE={version:sE,VERSION:cE,atob:NE,atobPolyfill:ME,btoa:bE,btoaPolyfill:yE,fromBase64:RE,toBase64:DE,encode:DE,encodeURI:OE,encodeURL:OE,utob:TE,btou:jE,decode:RE,isValid:zE,fromUint8Array:SE,toUint8Array:FE,extendString:VE,extendUint8Array:HE,extendBuiltins:()=>{VE(),HE()}},WE=class{constructor(e=new KE,t=new GE){this._base64=e,this._provider=t}activate(e){this._terminal=e,this._disposable=e.parser.registerOscHandler(52,e=>this._setOrReportClipboard(e))}dispose(){return this._disposable?.dispose()}_readText(e,t){let n=this._base64.encodeText(t);this._terminal?.input(`\x1B]52;${e};${n}\x07`,!1)}_setOrReportClipboard(e){let t=e.split(`;`);if(t.length<2)return!0;let n=t[0],r=t[1];if(r===`?`){let e=this._provider.readText(n);return e instanceof Promise?e.then(e=>(this._readText(n,e),!0)):(this._readText(n,e),!0)}let i=``;try{i=this._base64.decodeText(r)}catch{}let a=this._provider.writeText(n,i);return a instanceof Promise?a.then(()=>!0):!0}},GE=class{async readText(e){return e===`c`?navigator.clipboard.readText():Promise.resolve(``)}async writeText(e,t){return e===`c`?navigator.clipboard.writeText(t):Promise.resolve()}},KE=class{encodeText(e){return UE.encode(e)}decodeText(e){let t=UE.decode(e);return!UE.isValid(e)||UE.encode(t)!==e?``:t}},qE=s(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.SearchAddon=r():n.SearchAddon=r()})(self,(()=>(()=>{var e={345:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,`__esModule`,{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,`__esModule`,{value:!0}),e.SearchAddon=void 0;let t=n(345),i=n(859),a=` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`;class o extends i.Disposable{constructor(e){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new i.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new i.MutableDisposable,this._onDidChangeResults=this.register(new t.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=e?.highlightLimit??1e3}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,i.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(e){this._selectedDecoration.clear(),(0,i.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!e||e.length===0)return void this.clearDecorations();t||={},this.clearDecorations(!0);let n=[],r,i=this._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._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);for(let e of n){let n=this._createResultDecoration(e,t.decorations);n&&(this._highlightedLines.add(n.marker.line),this._highlightDecorations.push({decoration:n,match:e,dispose(){n.dispose()}}))}}_find(e,t,n,r){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let a={startRow:t,startCol:n};if(i=this._findInLine(e,a,r),!i)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,i=this._findInLine(e,a,r),!i);n++);return i}_findNextAndSelect(e,t){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,i=0;n&&(this._cachedSearchTerm===e?(r=n.end.x,i=n.end.y):(r=n.start.x,i=n.start.y)),this._initLinesCache();let a={startRow:i,startCol:r},o=this._findInLine(e,a,t);if(!o)for(let n=i+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);if(!o&&i!==0)for(let n=0;n<i&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);return!o&&n&&(a.startRow=n.start.y,a.startCol=0,o=this._findInLine(e,a,t)),this._selectResult(o,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_didOptionsChange(e,t){return!!t&&(e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord)}_fireResults(e){if(e?.decorations){let e=-1;if(this._selectedDecoration.value){let t=this._selectedDecoration.value.match;for(let n=0;n<this._highlightDecorations.length;n++){let r=this._highlightDecorations[n].match;if(r.row===t.row&&r.col===t.col&&r.size===t.size){e=n;break}}}this._onDidChangeResults.fire({resultIndex:e,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols;this._initLinesCache();let a={startRow:r,startCol:i},o;if(n&&(a.startRow=r=n.start.y,a.startCol=i=n.start.x,this._cachedSearchTerm!==e&&(o=this._findInLine(e,a,t,!1),o||(a.startRow=r=n.end.y,a.startCol=i=n.end.x))),o||=this._findInLine(e,a,t,!0),!o){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let n=r-1;n>=0&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);}if(!o&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=r&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);return this._selectResult(o,t?.decorations,t?.noScroll)}_initLinesCache(){let e=this._terminal;this._linesCache||(this._linesCache=Array(e.buffer.active.length),this._linesCacheDisposables.value=(0,i.getDisposeArrayDisposable)([e.onLineFeed((()=>this._destroyLinesCache())),e.onCursorMove((()=>this._destroyLinesCache())),e.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&=(window.clearTimeout(this._linesCacheTimeoutId),0)}_isWholeWord(e,t,n){return(e===0||a.includes(t[e-1]))&&(e+n.length===t.length||a.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=this._terminal,a=t.startRow,o=t.startCol;if(i.buffer.active.getLine(a)?.isWrapped)return r?void(t.startCol+=i.cols):(t.startRow--,t.startCol+=i.cols,this._findInLine(e,t,n));let s=this._linesCache?.[a];s||(s=this._translateBufferLineToStringWithWrap(a,!0),this._linesCache&&(this._linesCache[a]=s));let[c,l]=s,u=this._bufferColsToStringOffset(a,o),d=n.caseSensitive?e:e.toLowerCase(),f=n.caseSensitive?c:c.toLowerCase(),p=-1;if(n.regex){let t=RegExp(d,`g`),n;if(r)for(;n=t.exec(f.slice(0,u));)p=t.lastIndex-n[0].length,e=n[0],t.lastIndex-=e.length-1;else n=t.exec(f.slice(u)),n&&n[0].length>0&&(p=u+(t.lastIndex-n[0].length),e=n[0])}else r?u-d.length>=0&&(p=f.lastIndexOf(d,u-d.length)):p=f.indexOf(d,u);if(p>=0){if(n.wholeWord&&!this._isWholeWord(p,f,e))return;let t=0;for(;t<l.length-1&&p>=l[t+1];)t++;let r=t;for(;r<l.length-1&&p+e.length>=l[r+1];)r++;let o=p-l[t],s=p+e.length-l[r],c=this._stringLengthToBufferSize(a+t,o);return{term:e,col:c,row:a+t,size:this._stringLengthToBufferSize(a+r,s)-c+i.cols*(r-t)}}}_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=this._terminal,r=e,i=0,a=n.buffer.active.getLine(r);for(;t>0&&a;){for(let e=0;e<t&&e<n.cols;e++){let t=a.getCell(e);if(!t)break;t.getWidth()&&(i+=t.getCode()===0?1:t.getChars().length)}if(r++,a=n.buffer.active.getLine(r),a&&!a.isWrapped)break;t-=n.cols}return i}_translateBufferLineToStringWithWrap(e,t){let n=this._terminal,r=[],i=[0],a=n.buffer.active.getLine(e);for(;a;){let o=n.buffer.active.getLine(e+1),s=!!o&&o.isWrapped,c=a.translateToString(!s&&t);if(s&&o){let e=a.getCell(a.length-1);e&&e.getCode()===0&&e.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(c=c.slice(0,-1))}if(r.push(c),!s)break;i.push(i[i.length-1]+c.length),e++,a=o}return[r.join(``),i]}_selectResult(e,t,n){let r=this._terminal;if(this._selectedDecoration.clear(),!e)return r.clearSelection(),!1;if(r.select(e.col,e.row,e.size),t){let n=r.registerMarker(-r.buffer.active.baseY-r.buffer.active.cursorY+e.row);if(n){let a=r.registerDecoration({marker:n,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:`top`,overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(a){let r=[];r.push(n),r.push(a.onRender((e=>this._applyStyles(e,t.activeMatchBorder,!0)))),r.push(a.onDispose((()=>(0,i.disposeArray)(r)))),this._selectedDecoration.value={decoration:a,match:e,dispose(){a.dispose()}}}}}if(!n&&(e.row>=r.buffer.active.viewportY+r.rows||e.row<r.buffer.active.viewportY)){let t=e.row-r.buffer.active.viewportY;t-=Math.floor(r.rows/2),r.scrollLines(t)}return!0}_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`)}_createResultDecoration(e,t){let n=this._terminal,r=n.registerMarker(-n.buffer.active.baseY-n.buffer.active.cursorY+e.row);if(!r)return;let a=n.registerDecoration({marker:r,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:t.matchOverviewRuler,position:`center`}});if(a){let e=[];e.push(r),e.push(a.onRender((e=>this._applyStyles(e,t.matchBorder,!1)))),e.push(a.onDispose((()=>(0,i.disposeArray)(e))))}return a}}e.SearchAddon=o})(),r})()))}))(),JE=0,YE=0,XE=0,ZE=0,QE;(e=>{function t(e,t,n,r){return r===void 0?`#${rD(e)}${rD(t)}${rD(n)}`:`#${rD(e)}${rD(t)}${rD(n)}${rD(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})(QE||={});var $E;(e=>{function t(e,t){if(ZE=(t.rgba&255)/255,ZE===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 JE=a+Math.round((n-a)*ZE),YE=o+Math.round((r-o)*ZE),XE=s+Math.round((i-s)*ZE),{css:QE.toCss(JE,YE,XE),rgba:QE.toRgba(JE,YE,XE)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=nD.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return QE.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[JE,YE,XE]=nD.toChannels(t),{css:QE.toCss(JE,YE,XE),rgba:t}}e.opaque=i;function a(e,t){return ZE=Math.round(t*255),[JE,YE,XE]=nD.toChannels(e.rgba),{css:QE.toCss(JE,YE,XE,ZE),rgba:QE.toRgba(JE,YE,XE,ZE)}}e.opacity=a;function o(e,t){return ZE=e.rgba&255,a(e,ZE*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})($E||={});var eD;(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 JE=parseInt(e.slice(1,2).repeat(2),16),YE=parseInt(e.slice(2,3).repeat(2),16),XE=parseInt(e.slice(3,4).repeat(2),16),QE.toColor(JE,YE,XE);case 5:return JE=parseInt(e.slice(1,2).repeat(2),16),YE=parseInt(e.slice(2,3).repeat(2),16),XE=parseInt(e.slice(3,4).repeat(2),16),ZE=parseInt(e.slice(4,5).repeat(2),16),QE.toColor(JE,YE,XE,ZE);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 JE=parseInt(r[1]),YE=parseInt(r[2]),XE=parseInt(r[3]),ZE=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),QE.toColor(JE,YE,XE,ZE);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[JE,YE,XE,ZE]=t.getImageData(0,0,1,1).data,ZE!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:QE.toRgba(JE,YE,XE,ZE),css:e}}e.toColor=r})(eD||={});var tD;(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})(tD||={});var nD;(e=>{function t(e,t){if(ZE=(t&255)/255,ZE===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 JE=a+Math.round((n-a)*ZE),YE=o+Math.round((r-o)*ZE),XE=s+Math.round((i-s)*ZE),QE.toRgba(JE,YE,XE)}e.blend=t;function n(e,t,n){let a=tD.relativeLuminance(e>>8),o=tD.relativeLuminance(t>>8);if(iD(a,o)<n){if(o<a){let o=r(e,t,n),s=iD(a,tD.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>iD(a,tD.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=iD(a,tD.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>iD(a,tD.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=iD(tD.relativeLuminance2(o,s,c),tD.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=iD(tD.relativeLuminance2(o,s,c),tD.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=iD(tD.relativeLuminance2(o,s,c),tD.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=iD(tD.relativeLuminance2(o,s,c),tD.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})(nD||={});function rD(e){let t=e.toString(16);return t.length<2?`0`+t:t}function iD(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var aD=Object.freeze((()=>{let e=[eD.toColor(`#2e3436`),eD.toColor(`#cc0000`),eD.toColor(`#4e9a06`),eD.toColor(`#c4a000`),eD.toColor(`#3465a4`),eD.toColor(`#75507b`),eD.toColor(`#06989a`),eD.toColor(`#d3d7cf`),eD.toColor(`#555753`),eD.toColor(`#ef2929`),eD.toColor(`#8ae234`),eD.toColor(`#fce94f`),eD.toColor(`#729fcf`),eD.toColor(`#ad7fa8`),eD.toColor(`#34e2e2`),eD.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:QE.toCss(r,i,a),rgba:QE.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:QE.toCss(n,n,n),rgba:QE.toRgba(n,n,n)})}return e})());function oD(e,t,n){return Math.max(t,Math.min(e,n))}function sD(e){switch(e){case`&`:return`&amp;`;case`<`:return`&lt;`}return e}var cD=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 lD(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function uD(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function dD(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 fD=class extends cD{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&&!uD(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
101
- `,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)&&uD(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&uD(i,o)&&uD(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=!lD(e,t),i=!uD(e,t),a=!dD(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?!uD(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(uD(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&&(uD(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}},pD=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:oD(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new fD(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 mD(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:oD(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(){}},mD=class extends cD{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=aD}_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=!lD(e,t),i=!uD(e,t),a=!dD(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+=sD(e.getChars())}_serializeString(){return this._htmlContent}};function hD(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 gD=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=hD(t[1]),r=hD(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})}},_D=new Map,vD=20;function yD(e){_D.delete(e)}function bD(){_D.clear()}var xD=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,SD=/[.,;:!?]+$/,CD=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],wD=(e,t)=>e.split(t).length-1;function TD(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(SD,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of CD){if(!t.endsWith(n))continue;let i=wD(t,e);wD(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var ED=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),DD=`\x1B[200~\x1B[201~`,OD=``,kD=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,AD=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;function jD(e){return e===`codex`?OD:DD}var MD=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function ND(e){return MD.test(e)}function PD(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}var FD=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),Z(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){Z(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},ID=`︎`,LD=[`⏺`],RD=new RegExp(LD.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function zD(e){for(let t of LD)if(e.indexOf(t)!==-1)return e.replace(RD,`$&${ID}`);return e}function BD({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=Ve(),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),R=(0,x.useCallback)((e,t)=>{e?.trim()&&(F.current+=1,L({id:F.current,text:e,source:t}))},[]),z=(0,x.useCallback)(()=>{I&&(Im(I.text),Z(`clipboard_manual_copy`,{source:I.source,chars:I.text.length},`info`),L(null))},[I]),B=(0,x.useCallback)(()=>{L(null)},[]),V=(0,x.useRef)(null),H=(0,x.useRef)(null),U=(0,x.useRef)(null),W=(0,x.useRef)(-1),G=(0,x.useRef)(null),ee=(0,x.useRef)(null),K=(0,x.useRef)(o),te=(0,x.useRef)(n),ne=(0,x.useRef)(m),re=(0,x.useRef)(p),ie=(0,x.useRef)([]),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(!1),[ce,le]=(0,x.useState)(!1),ue=(0,x.useRef)(null),de=(0,x.useRef)(null),fe=(0,x.useRef)(null),pe=()=>{if(ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null),de.current!==null&&(cancelAnimationFrame(de.current),de.current=null),fe.current!==null){let e=g.current;e&&(e.style.display=fe.current),fe.current=null}},me=(e,t)=>{let n=g.current;n&&(pe(),Z(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:H.current}),ue.current=window.setTimeout(()=>{ue.current=null;let e=_.current;e&&e.refresh(0,e.rows-1),Z(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:H.current}),fe.current=n.style.display,n.style.display=`none`,de.current=requestAnimationFrame(()=>{de.current=requestAnimationFrame(()=>{de.current=null,n.style.display=fe.current??``,fe.current=null})})},e))};(0,x.useEffect)(()=>{K.current=o},[o]),(0,x.useEffect)(()=>{te.current=n},[n]),(0,x.useEffect)(()=>{ne.current=m},[m]);let he=(0,x.useCallback)(()=>{let e=_.current;if(!e||!ne.current)return;let t=e.buffer.active,n=!j.current&&t.viewportY>=t.baseY;ne.current(n)},[]),ge=(0,x.useCallback)(e=>{if(e&&M.current||j.current===e)return;j.current=e;let t=_.current;t&&e&&t.write(AD),he()},[he]),_e=(0,x.useCallback)(()=>{let e=H.current;e&&(P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,K.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),ve=(0,x.useCallback)(()=>{let e=_.current,t=y.current;if(!e||!t)return;t.fit();let n=H.current;n&&K.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 XT.Terminal({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 $T;r.loadAddon(i),r.loadAddon(new WE(void 0,new FD({onWriteFailed:R})));let a=new qE.SearchAddon;r.loadAddon(a),w.current=a;let o=new pD;r.loadAddon(o),T.current=o;let s=new gD;r.loadAddon(s),E.current=s;let p=()=>{if(!n){if(re.current)try{let t=new eE.WebglAddon;t.onContextLoss(()=>{Z(`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,Z(`terminal_init`,{isiOS:h,useWebGL:re.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=`
101
+ `,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)&&uD(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&uD(i,o)&&uD(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=!lD(e,t),i=!uD(e,t),a=!dD(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?!uD(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(uD(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&&(uD(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}},pD=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:oD(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new fD(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 mD(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:oD(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(){}},mD=class extends cD{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=aD}_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=!lD(e,t),i=!uD(e,t),a=!dD(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+=sD(e.getChars())}_serializeString(){return this._htmlContent}};function hD(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 gD=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=hD(t[1]),r=hD(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 _D(e){return`\x1b[200~${e}\x1b[201~`}function vD(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function yD(e,t){let n=vD(e);return t===`codex`?n:_D(n)}var bD=new Map,xD=20;function SD(e){bD.delete(e)}function CD(){bD.clear()}var wD=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,TD=/[.,;:!?]+$/,ED=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],DD=(e,t)=>e.split(t).length-1;function OD(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(TD,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of ED){if(!t.endsWith(n))continue;let i=DD(t,e);DD(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var kD=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),AD=`\x1B[200~\x1B[201~`,jD=``,MD=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,ND=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;async function PD(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 FD(){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 ID(e,t){if(e===`codex`)return jD;let n=t.path??null;return!n&&t.blob&&(n=await PD(t.blob)),n||=await FD(),n?_D(vD(n)):AD}var LD=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function RD(e){return LD.test(e)}function zD(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 BD(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 VD=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),Z(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){Z(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},HD=`︎`,UD=[`⏺`],WD=new RegExp(UD.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function GD(e){for(let t of UD)if(e.indexOf(t)!==-1)return e.replace(WD,`$&${HD}`);return e}function KD({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=Ve(),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),R=(0,x.useCallback)((e,t)=>{e?.trim()&&(F.current+=1,L({id:F.current,text:e,source:t}))},[]),z=(0,x.useCallback)(()=>{I&&(Im(I.text),Z(`clipboard_manual_copy`,{source:I.source,chars:I.text.length},`info`),L(null))},[I]),B=(0,x.useCallback)(()=>{L(null)},[]),V=(0,x.useRef)(null),H=(0,x.useRef)(null),U=(0,x.useRef)(null),W=(0,x.useRef)(-1),G=(0,x.useRef)(null),ee=(0,x.useRef)(null),K=(0,x.useRef)(o),te=(0,x.useRef)(n),ne=(0,x.useRef)(m),re=(0,x.useRef)(p),ie=(0,x.useRef)([]),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(!1),[ce,le]=(0,x.useState)(!1),ue=(0,x.useRef)(null),de=(0,x.useRef)(null),fe=(0,x.useRef)(null),pe=()=>{if(ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null),de.current!==null&&(cancelAnimationFrame(de.current),de.current=null),fe.current!==null){let e=g.current;e&&(e.style.display=fe.current),fe.current=null}},me=(e,t)=>{let n=g.current;n&&(pe(),Z(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:H.current}),ue.current=window.setTimeout(()=>{ue.current=null;let e=_.current;e&&e.refresh(0,e.rows-1),Z(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:H.current}),fe.current=n.style.display,n.style.display=`none`,de.current=requestAnimationFrame(()=>{de.current=requestAnimationFrame(()=>{de.current=null,n.style.display=fe.current??``,fe.current=null})})},e))};(0,x.useEffect)(()=>{K.current=o},[o]),(0,x.useEffect)(()=>{te.current=n},[n]),(0,x.useEffect)(()=>{ne.current=m},[m]);let he=(0,x.useCallback)(()=>{let e=_.current;if(!e||!ne.current)return;let t=e.buffer.active,n=!j.current&&t.viewportY>=t.baseY;ne.current(n)},[]),ge=(0,x.useCallback)(e=>{if(e&&M.current||j.current===e)return;j.current=e;let t=_.current;t&&e&&t.write(ND),he()},[he]),_e=(0,x.useCallback)(()=>{let e=H.current;e&&(P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,K.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),ve=(0,x.useCallback)(()=>{let e=_.current,t=y.current;if(!e||!t)return;t.fit();let n=H.current;n&&K.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 XT.Terminal({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 $T;r.loadAddon(i),r.loadAddon(new WE(void 0,new VD({onWriteFailed:R})));let a=new qE.SearchAddon;r.loadAddon(a),w.current=a;let o=new pD;r.loadAddon(o),T.current=o;let s=new gD;r.loadAddon(s),E.current=s;let p=()=>{if(!n){if(re.current)try{let t=new eE.WebglAddon;t.onContextLoss(()=>{Z(`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,Z(`terminal_init`,{isiOS:h,useWebGL:re.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=`
102
102
  position: absolute;
103
103
  display: none;
104
104
  z-index: 20;
@@ -112,7 +112,7 @@ void main() {
112
112
  pointer-events: none;
113
113
  max-width: 400px;
114
114
  word-break: break-all;
115
- `,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=TD(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;x.textContent=a,D.textContent=`${ED()?`⌘`:`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,z={activate:(e,t)=>{if(!I&&(e.metaKey||e.ctrlKey)){let e=TD(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{F=TD(t)||null,k(e,t)},leave:()=>{F=null,N()}},B=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`,B,!0),r.options.linkHandler=z;let V=new oE((e,t)=>z.activate(e,t),{urlRegex:xD,hover:(e,t)=>z.hover(e,t),leave:()=>z.leave()});r.loadAddon(V),S.current=V;let U=null,W=null,G=ED()?`metaKey`:`ctrlKey`;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(ED()&&!h&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`)return H.current&&(j.current&&(K.current({type:`tmux-cancel-copy-mode`,sessionId:H.current}),ge(!1)),K.current({type:`terminal-input`,sessionId:H.current,data:jD(te.current)})),!H.current;if(e[G]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){W!==null&&(clearTimeout(W),W=null),U=null;let e=new Promise(e=>{W=setTimeout(()=>{W=null,U=null,e(null)},100),U=t=>{W!==null&&(clearTimeout(W),W=null),e(t)}});return(async()=>{try{let t=H.current;if(!t)return;let n=await e,i=n?.text??null;if(i===null)try{i=await navigator.clipboard.readText()}catch{i=``}if(n?.hasImage&&ED()&&!h){K.current({type:`terminal-input`,sessionId:t,data:jD(te.current)});return}if(!i&&ED()&&!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){K.current({type:`terminal-input`,sessionId:t,data:jD(te.current)});return}K.current({type:`terminal-input`,sessionId:t,data:n});return}}}catch{}if(i&&!ND(i)){r.paste(i);return}ED()&&!h&&K.current({type:`terminal-input`,sessionId:t,data:jD(te.current)})}finally{U=null}})(),!1}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=H.current;return e&&K.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ee=e=>{if(!U)return;e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=PD(e.clipboardData),r=U;U=null,r({text:t,hasImage:n})};return t.addEventListener(`paste`,ee,{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&&(K.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ge(!1)),K.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),K.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!M.current&&ge(!0),c&&!M.current&&_e(),!1}),_.current=r,y.current=i,()=>{if(n=!0,L&&clearTimeout(L),F=null,t.removeEventListener(`mousedown`,B,!0),t.removeEventListener(`paste`,ee,!0),W!==null&&(clearTimeout(W),W=null),U=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)}},[ve]),(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=H.current;n&&K.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=re.current;if(re.current=p,t!==p){if(p){if(!b.current)try{let t=new eE.WebglAddon;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=H.current,s=U.current;if(!r){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(K.current({type:`terminal-detach`,sessionId:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1),n.reset(),se.current=!1,le(!1);return}if(i!==`connected`){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(Z(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1),bD(),se.current=!1,le(!1);return}if(o&&o!==e){try{let e=T.current?.serialize();if(e&&(_D.set(o,e),_D.size>vD)){let e=_D.keys().next().value;e&&_D.delete(e)}}catch{}K.current({type:`terminal-detach`,sessionId:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1}let c=W.current,l=a!==c;if(e&&(e!==o||t!==s||l)){Z(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ie.current=[],ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null),se.current=!0,le(!0);let l=_D.get(e);l&&(n.reset(),n.write(l));let u=y.current;u&&u.fit();let d=performance.now();H.current=e,U.current=t??null,W.current=a,G.current=e,ee.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(()=>{H.current===t&&(K.current(f),K.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else k.current=window.setTimeout(()=>{k.current=null,K.current(f),K.current({type:`tmux-check-copy-mode`,sessionId:e})},50);Z(`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&&Z(`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),H.current=null,U.current=null,W.current=-1,G.current=null),()=>{k.current!==null&&(Z(`attach_debounce_cancelled`,{sessionId:e,attachedSession:H.current},`info`),window.clearTimeout(k.current),k.current=null)}},[e,t,r,i,a,he]),(0,x.useEffect)(()=>{if(V.current!==null&&(globalThis.clearInterval(V.current),V.current=null),!(!e||!r||i!==`connected`))return V.current=globalThis.setInterval(()=>{H.current===e&&K.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{V.current!==null&&(globalThis.clearInterval(V.current),V.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null);let e=_.current,t=ie.current;if(!e||t.length===0)return;ie.current=[];let n=t.join(``);se.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&Z(`switch_write_slow`,{sessionId:H.current,writeMs:e,bytes:i}),h&&e>50&&Z(`ios_write_slow`,{sessionId:H.current,writeMs:e,bytes:i}),he()})},t=()=>{ae.current!==null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(e,2),oe.current===null&&(oe.current=window.setTimeout(e,16))},n=s(n=>{let r=H.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&Z(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:ee.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=ee.current;e&&(Z(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),ee.current=null),ie.current.push(h?zD(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current&&ie.current.length>0?e():se.current&&=(_.current?.reset(),!1),le(!1);let t=ee.current;t&&(Z(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),ee.current=null),G.current===n.sessionId&&(_.current?.focus(),G.current=null),h&&(e(),me(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=!1,le(!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(()=>{Z(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{Z(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),R(e,n.source)})}else R(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(kD),ge(e?!1:n.inCopyMode)}});return()=>{n(),e(),pe()}},[s,he,ge,R]),(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(()=>{ve()},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`&&Z(`terminal_visibility_resume`,{isiOS:h,hasWebGL:!!b.current,useWebGL:re.current,hasTerminal:!!_.current,bufferLines:_.current?.buffer.active.length??0,sessionId:H.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!h)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=_.current;if(t&&b.current&&re.current){try{b.current.dispose()}catch{}b.current=null;try{let n=new eE.WebglAddon;n.onContextLoss(()=>{Z(`webgl_context_loss`,{sessionId:H.current},`info`);try{n.dispose()}catch{}b.current=null}),t.loadAddon(n),b.current=n,Z(`ios_webgl_recreated`,{trigger:e},`info`)}catch{Z(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),me(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),me(200,`pageshow`))},i=()=>{t(`focus`),me(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),pe()}},[]),{containerRef:g,terminalRef:_,searchAddonRef:w,serializeAddonRef:T,progressAddonRef:E,inTmuxCopyModeRef:j,appMouseRef:M,setTmuxCopyMode:ge,isSwitching:ce,pendingClipboardOffer:I,copyPendingClipboardOffer:z,dismissPendingClipboardOffer:B}}function VD(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 HD(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 UD(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 WD({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 GD=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)})),KD={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`}},qD={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},JD=150,YD=250,XD=400,ZD=1500,QD=15,$D=70;function eO(e=10){`vibrate`in navigator&&navigator.vibrate(e)}function tO(e,t){let n=Math.sqrt(e*e+t*t);if(n<QD)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 nO(e){let t=$D-20;return ZD-Math.min(e/t,1)*(ZD-XD)}function rO({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=nO(_.current);m.current=setTimeout(()=>{g.current&&(eO(5),e(t),b(t))},n)},[e]),S=(0,x.useCallback)((n,r)=>{if(!n||t)return;let i=qD[n];_.current=r,eO(8),e(i),y(),p.current=setTimeout(()=>{b(i)},YD)},[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,$D-20),o=i>0?a/i:0;d({x:n*o,y:r*o});let{direction:l,distance:u}=tO(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(()=>{eO(15),l({x:n.clientX,y:n.clientY-80}),d({x:0,y:0}),a(!0)},JD)},[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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Arrow keys`,className:`
115
+ `,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=OD(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;x.textContent=a,D.textContent=`${kD()?`⌘`:`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,z={activate:(e,t)=>{if(!I&&(e.metaKey||e.ctrlKey)){let e=OD(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{F=OD(t)||null,k(e,t)},leave:()=>{F=null,N()}},B=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`,B,!0),r.options.linkHandler=z;let V=new oE((e,t)=>z.activate(e,t),{urlRegex:wD,hover:(e,t)=>z.hover(e,t),leave:()=>z.leave()});r.loadAddon(V),S.current=V;let U=null,W=null,G=kD()?`metaKey`:`ctrlKey`,ee=(e,t)=>{t&&H.current===e&&K.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(kD()&&!h&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`){let e=H.current;return e&&(j.current&&(K.current({type:`tmux-cancel-copy-mode`,sessionId:e}),ge(!1)),(async()=>{ee(e,await ID(te.current,{}))})()),!e}if(e[G]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){W!==null&&(clearTimeout(W),W=null),U=null;let e=new Promise(e=>{W=setTimeout(()=>{W=null,U=null,e(null)},100),U=t=>{W!==null&&(clearTimeout(W),W=null),e(t)}});return(async()=>{try{let t=H.current;if(!t)return;let n=await e,i=n?.text??null;if(i===null)try{i=await navigator.clipboard.readText()}catch{i=``}if(n?.hasImage&&kD()&&!h){ee(t,await ID(te.current,{blob:n.imageBlob}));return}if(!i&&kD()&&!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){ee(t,await ID(te.current,{path:n}));return}ee(t,n);return}}}catch{}if(i&&!RD(i)){r.paste(i);return}kD()&&!h&&ee(t,await ID(te.current,{}))}finally{U=null}})(),!1}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=H.current;return e&&K.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ne=e=>{if(!U)return;e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=BD(e.clipboardData),r=n!==null||zD(e.clipboardData),i=U;U=null,i({text:t,hasImage:r,imageBlob:n})};return t.addEventListener(`paste`,ne,{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&&(K.current({type:`tmux-cancel-copy-mode`,sessionId:t}),ge(!1)),K.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),K.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!M.current&&ge(!0),c&&!M.current&&_e(),!1}),_.current=r,y.current=i,()=>{if(n=!0,L&&clearTimeout(L),F=null,t.removeEventListener(`mousedown`,B,!0),t.removeEventListener(`paste`,ne,!0),W!==null&&(clearTimeout(W),W=null),U=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)}},[ve]),(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=H.current;n&&K.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=re.current;if(re.current=p,t!==p){if(p){if(!b.current)try{let t=new eE.WebglAddon;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=H.current,s=U.current;if(!r){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(K.current({type:`terminal-detach`,sessionId:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1),n.reset(),se.current=!1,le(!1);return}if(i!==`connected`){k.current!==null&&(window.clearTimeout(k.current),k.current=null),o&&(Z(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1),CD(),se.current=!1,le(!1);return}if(o&&o!==e){try{let e=T.current?.serialize();if(e&&(bD.set(o,e),bD.size>xD)){let e=bD.keys().next().value;e&&bD.delete(e)}}catch{}K.current({type:`terminal-detach`,sessionId:o}),H.current=null,U.current=null,W.current=-1,G.current=null,j.current=!1}let c=W.current,l=a!==c;if(e&&(e!==o||t!==s||l)){Z(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ie.current=[],ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null),se.current=!0,le(!0);let l=bD.get(e);l&&(n.reset(),n.write(l));let u=y.current;u&&u.fit();let d=performance.now();H.current=e,U.current=t??null,W.current=a,G.current=e,ee.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(()=>{H.current===t&&(K.current(f),K.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else k.current=window.setTimeout(()=>{k.current=null,K.current(f),K.current({type:`tmux-check-copy-mode`,sessionId:e})},50);Z(`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&&Z(`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),H.current=null,U.current=null,W.current=-1,G.current=null),()=>{k.current!==null&&(Z(`attach_debounce_cancelled`,{sessionId:e,attachedSession:H.current},`info`),window.clearTimeout(k.current),k.current=null)}},[e,t,r,i,a,he]),(0,x.useEffect)(()=>{if(V.current!==null&&(globalThis.clearInterval(V.current),V.current=null),!(!e||!r||i!==`connected`))return V.current=globalThis.setInterval(()=>{H.current===e&&K.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{V.current!==null&&(globalThis.clearInterval(V.current),V.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null);let e=_.current,t=ie.current;if(!e||t.length===0)return;ie.current=[];let n=t.join(``);se.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&Z(`switch_write_slow`,{sessionId:H.current,writeMs:e,bytes:i}),h&&e>50&&Z(`ios_write_slow`,{sessionId:H.current,writeMs:e,bytes:i}),he()})},t=()=>{ae.current!==null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(e,2),oe.current===null&&(oe.current=window.setTimeout(e,16))},n=s(n=>{let r=H.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&Z(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:ee.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=ee.current;e&&(Z(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),ee.current=null),ie.current.push(h?GD(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current&&ie.current.length>0?e():se.current&&=(_.current?.reset(),!1),le(!1);let t=ee.current;t&&(Z(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),ee.current=null),G.current===n.sessionId&&(_.current?.focus(),G.current=null),h&&(e(),me(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=!1,le(!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(()=>{Z(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{Z(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),R(e,n.source)})}else R(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(MD),ge(e?!1:n.inCopyMode)}});return()=>{n(),e(),pe()}},[s,he,ge,R]),(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(()=>{ve()},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`&&Z(`terminal_visibility_resume`,{isiOS:h,hasWebGL:!!b.current,useWebGL:re.current,hasTerminal:!!_.current,bufferLines:_.current?.buffer.active.length??0,sessionId:H.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!h)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=_.current;if(t&&b.current&&re.current){try{b.current.dispose()}catch{}b.current=null;try{let n=new eE.WebglAddon;n.onContextLoss(()=>{Z(`webgl_context_loss`,{sessionId:H.current},`info`);try{n.dispose()}catch{}b.current=null}),t.loadAddon(n),b.current=n,Z(`ios_webgl_recreated`,{trigger:e},`info`)}catch{Z(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),me(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),me(200,`pageshow`))},i=()=>{t(`focus`),me(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),pe()}},[]),{containerRef:g,terminalRef:_,searchAddonRef:w,serializeAddonRef:T,progressAddonRef:E,inTmuxCopyModeRef:j,appMouseRef:M,setTmuxCopyMode:ge,isSwitching:ce,pendingClipboardOffer:I,copyPendingClipboardOffer:z,dismissPendingClipboardOffer:B}}function qD(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 JD(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 YD(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 XD({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 ZD=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)})),QD={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`}},$D={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},eO=150,tO=250,nO=400,rO=1500,iO=15,aO=70;function oO(e=10){`vibrate`in navigator&&navigator.vibrate(e)}function sO(e,t){let n=Math.sqrt(e*e+t*t);if(n<iO)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 cO(e){let t=aO-20;return rO-Math.min(e/t,1)*(rO-nO)}function lO({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=cO(_.current);m.current=setTimeout(()=>{g.current&&(oO(5),e(t),b(t))},n)},[e]),S=(0,x.useCallback)((n,r)=>{if(!n||t)return;let i=$D[n];_.current=r,oO(8),e(i),y(),p.current=setTimeout(()=>{b(i)},tO)},[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,aO-20),o=i>0?a/i:0;d({x:n*o,y:r*o});let{direction:l,distance:u}=sO(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(()=>{oO(15),l({x:n.clientX,y:n.clientY-80}),d({x:0,y:0}),a(!0)},eO)},[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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Arrow keys`,className:`
116
116
  terminal-key
117
117
  flex items-center justify-center
118
118
  h-11 min-w-[2.75rem] px-2.5
@@ -124,21 +124,21 @@ void main() {
124
124
  text-secondary
125
125
  ${t?`opacity-50`:``}
126
126
  ${i?`bg-hover scale-95`:``}
127
- `,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:T,onTouchMove:E,onTouchEnd:D,onTouchCancel:O,disabled:t,children:(0,q.jsx)(Ee,{width:20,height:20})}),i&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-50`,style:{touchAction:`none`},onTouchMove:E,onTouchEnd:D,onTouchCancel:O,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,q.jsxs)(`div`,{className:`absolute`,style:{left:c.x,top:c.y,transform:`translate(-50%, -50%)`},children:[(0,q.jsxs)(`div`,{className:`relative rounded-full bg-black/40 backdrop-blur-md border-2 border-white/20`,style:{width:$D*2,height:$D*2},children:[[{dir:`up`,angle:-90,label:`↑`},{dir:`right`,angle:0,label:`→`},{dir:`down`,angle:90,label:`↓`},{dir:`left`,angle:180,label:`←`}].map(({dir:e,angle:t,label:n})=>(0,q.jsx)(`div`,{className:`
127
+ `,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:T,onTouchMove:E,onTouchEnd:D,onTouchCancel:O,disabled:t,children:(0,q.jsx)(Ee,{width:20,height:20})}),i&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-50`,style:{touchAction:`none`},onTouchMove:E,onTouchEnd:D,onTouchCancel:O,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,q.jsxs)(`div`,{className:`absolute`,style:{left:c.x,top:c.y,transform:`translate(-50%, -50%)`},children:[(0,q.jsxs)(`div`,{className:`relative rounded-full bg-black/40 backdrop-blur-md border-2 border-white/20`,style:{width:aO*2,height:aO*2},children:[[{dir:`up`,angle:-90,label:`↑`},{dir:`right`,angle:0,label:`→`},{dir:`down`,angle:90,label:`↓`},{dir:`left`,angle:180,label:`←`}].map(({dir:e,angle:t,label:n})=>(0,q.jsx)(`div`,{className:`
128
128
  absolute text-2xl font-bold
129
129
  transition-all duration-75
130
130
  ${o===e?`text-accent scale-125`:`text-white/60`}
131
131
  `,style:{left:`50%`,top:`50%`,transform:`
132
132
  translate(-50%, -50%)
133
133
  rotate(${t}deg)
134
- translateX(${$D-25}px)
134
+ translateX(${aO-25}px)
135
135
  rotate(${-t}deg)
136
136
  `},children:n},e)),(0,q.jsx)(`div`,{className:`
137
137
  absolute w-12 h-12 rounded-full
138
138
  bg-white/90 shadow-lg
139
139
  border-2 transition-colors duration-75
140
140
  ${o?`border-accent bg-accent/20`:`border-white/40`}
141
- `,style:{left:`50%`,top:`50%`,transform:`translate(calc(-50% + ${u.x}px), calc(-50% + ${u.y}px))`},children:(0,q.jsx)(`div`,{className:`absolute inset-2 rounded-full bg-white/50`})})]}),o&&(0,q.jsx)(`div`,{className:`absolute -bottom-8 left-1/2 -translate-x-1/2 text-white text-sm font-medium bg-black/50 px-3 py-1 rounded-full`,children:o.toUpperCase()})]})]})]})}var iO=150,aO=56,oO=48,sO=6,cO=8,lO=20+sO+2,uO=3*aO+2*sO+2*cO,dO=3*oO+2*sO+2*cO+lO;function fO(e=10){`vibrate`in navigator&&navigator.vibrate(e)}var pO=[[`7`,`8`,`9`],[`4`,`5`,`6`],[`1`,`2`,`3`]];function mO(e,t,n){let r=n.x-uO/2,i=n.y-dO/2,a=e-r-cO,o=t-i-cO,s=3*aO+2*sO,c=3*oO+2*sO;if(a<0||a>s||o<0||o>c)return null;let l=Math.floor(a/(aO+sO)),u=Math.floor(o/(oO+sO));if(l<0||l>2||u<0||u>2)return null;let d=l*(aO+sO),f=u*(oO+sO);return a>d+aO||o>f+oO?null:pO[u]?.[l]||null}function hO({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)({x:0,y:0}),u=(0,x.useRef)(null),d=(0,x.useRef)(!1),f=(0,x.useRef)(!1),p=(0,x.useCallback)(()=>{a(!1),s(null),f.current=!1,d.current&&n?.()},[n]),m=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];d.current=r?.()??!1,f.current=!1,u.current=setTimeout(()=>{fO(15);let e=n.clientX,t=n.clientY-120;e=Math.max(10+uO/2,Math.min(window.innerWidth-10-uO/2,e)),t=Math.max(10+dO/2,t),l({x:e,y:t}),a(!0)},iO)},[t,r]),h=(0,x.useCallback)((e,t)=>mO(e,t,c),[c]),g=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0],n=h(t.clientX,t.clientY);n!==o&&(s(n),n&&fO(5))},[i,o,h]),_=(0,x.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),u.current&&=(clearTimeout(u.current),null),i&&o&&!f.current&&(fO(10),e(o),f.current=!0),p()},[i,o,e,p]),v=(0,x.useCallback)(e=>{e.preventDefault(),u.current&&=(clearTimeout(u.current),null),p()},[p]);return(0,x.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`
141
+ `,style:{left:`50%`,top:`50%`,transform:`translate(calc(-50% + ${u.x}px), calc(-50% + ${u.y}px))`},children:(0,q.jsx)(`div`,{className:`absolute inset-2 rounded-full bg-white/50`})})]}),o&&(0,q.jsx)(`div`,{className:`absolute -bottom-8 left-1/2 -translate-x-1/2 text-white text-sm font-medium bg-black/50 px-3 py-1 rounded-full`,children:o.toUpperCase()})]})]})]})}var uO=150,dO=56,fO=48,pO=6,mO=8,hO=20+pO+2,gO=3*dO+2*pO+2*mO,_O=3*fO+2*pO+2*mO+hO;function vO(e=10){`vibrate`in navigator&&navigator.vibrate(e)}var yO=[[`7`,`8`,`9`],[`4`,`5`,`6`],[`1`,`2`,`3`]];function bO(e,t,n){let r=n.x-gO/2,i=n.y-_O/2,a=e-r-mO,o=t-i-mO,s=3*dO+2*pO,c=3*fO+2*pO;if(a<0||a>s||o<0||o>c)return null;let l=Math.floor(a/(dO+pO)),u=Math.floor(o/(fO+pO));if(l<0||l>2||u<0||u>2)return null;let d=l*(dO+pO),f=u*(fO+pO);return a>d+dO||o>f+fO?null:yO[u]?.[l]||null}function xO({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)({x:0,y:0}),u=(0,x.useRef)(null),d=(0,x.useRef)(!1),f=(0,x.useRef)(!1),p=(0,x.useCallback)(()=>{a(!1),s(null),f.current=!1,d.current&&n?.()},[n]),m=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];d.current=r?.()??!1,f.current=!1,u.current=setTimeout(()=>{vO(15);let e=n.clientX,t=n.clientY-120;e=Math.max(10+gO/2,Math.min(window.innerWidth-10-gO/2,e)),t=Math.max(10+_O/2,t),l({x:e,y:t}),a(!0)},uO)},[t,r]),h=(0,x.useCallback)((e,t)=>bO(e,t,c),[c]),g=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0],n=h(t.clientX,t.clientY);n!==o&&(s(n),n&&vO(5))},[i,o,h]),_=(0,x.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),u.current&&=(clearTimeout(u.current),null),i&&o&&!f.current&&(vO(10),e(o),f.current=!0),p()},[i,o,e,p]),v=(0,x.useCallback)(e=>{e.preventDefault(),u.current&&=(clearTimeout(u.current),null),p()},[p]);return(0,x.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`
142
142
  terminal-key
143
143
  flex items-center justify-center
144
144
  h-11 min-w-[2.75rem] px-2.5
@@ -150,19 +150,19 @@ void main() {
150
150
  text-secondary
151
151
  ${t?`opacity-50`:``}
152
152
  ${i?`bg-hover scale-95`:``}
153
- `,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,q.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x,top:c.y,transform:`translate(-50%, -50%)`,WebkitUserSelect:`none`,userSelect:`none`},children:(0,q.jsxs)(`div`,{className:`rounded-2xl bg-black/40 backdrop-blur-md border-2 border-white/20 select-none`,style:{padding:cO},children:[(0,q.jsx)(`div`,{className:`grid grid-cols-3 select-none`,style:{gap:sO},children:pO.flat().map((e,t)=>e?(0,q.jsx)(`div`,{className:`
153
+ `,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,q.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x,top:c.y,transform:`translate(-50%, -50%)`,WebkitUserSelect:`none`,userSelect:`none`},children:(0,q.jsxs)(`div`,{className:`rounded-2xl bg-black/40 backdrop-blur-md border-2 border-white/20 select-none`,style:{padding:mO},children:[(0,q.jsx)(`div`,{className:`grid grid-cols-3 select-none`,style:{gap:pO},children:yO.flat().map((e,t)=>e?(0,q.jsx)(`div`,{className:`
154
154
  flex items-center justify-center
155
155
  rounded-lg text-xl font-bold
156
156
  select-none
157
157
  transition-all duration-75
158
158
  ${o===e?`bg-accent text-white scale-110`:`bg-white/90 text-gray-800`}
159
- `,style:{width:aO,height:oO,WebkitUserSelect:`none`,userSelect:`none`},children:e},t):(0,q.jsx)(`div`,{style:{width:aO,height:oO}},t))}),(0,q.jsx)(`div`,{className:`text-center text-white text-sm font-medium select-none h-5`,style:{marginTop:sO+2},children:o?`Release to send "${o}"`:`\xA0`})]})})]})]})}var gO=(0,q.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,q.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`})}),_O=(0,q.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,q.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,q.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]}),vO=(0,q.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,q.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,ry:`2`}),(0,q.jsx)(`line`,{x1:`6`,y1:`8`,x2:`6`,y2:`8`}),(0,q.jsx)(`line`,{x1:`10`,y1:`8`,x2:`10`,y2:`8`}),(0,q.jsx)(`line`,{x1:`14`,y1:`8`,x2:`14`,y2:`8`}),(0,q.jsx)(`line`,{x1:`18`,y1:`8`,x2:`18`,y2:`8`}),(0,q.jsx)(`line`,{x1:`6`,y1:`12`,x2:`6`,y2:`12`}),(0,q.jsx)(`line`,{x1:`10`,y1:`12`,x2:`10`,y2:`12`}),(0,q.jsx)(`line`,{x1:`14`,y1:`12`,x2:`14`,y2:`12`}),(0,q.jsx)(`line`,{x1:`18`,y1:`12`,x2:`18`,y2:`12`}),(0,q.jsx)(`line`,{x1:`7`,y1:`16`,x2:`17`,y2:`16`})]}),yO=[{label:`esc`,key:`\x1B`},{label:`tab`,key:` `}],bO=[{label:gO,key:``,ariaLabel:`Delete word`},{label:(0,q.jsx)(ue,{width:18,height:18}),key:`\r`,grow:!0,className:`bg-accent/20 text-accent border-accent/40`,ariaLabel:`Enter`}];function xO(){`vibrate`in navigator&&navigator.vibrate(10)}function SO(e,t){if(!t||e.length!==1)return{output:e,consumeCtrl:!1};let n=e.toUpperCase().charCodeAt(0);return n>=65&&n<=90?{output:String.fromCharCode(n-64),consumeCtrl:!0}:{output:e,consumeCtrl:!0}}var CO={working:`bg-working`,waiting:`bg-waiting`,permission:`bg-approval`,unknown:`bg-muted`};async function wO(e,t){try{let n=new FormData;n.append(`image`,e,t);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(r.ok){let{path:e}=await r.json();return{path:e}}let i=`Image upload failed`;try{let e=await r.json();typeof e.error==`string`&&(i=e.error)}catch{}return{error:i}}catch{return{error:`Image upload failed`}}}function TO({onSendKey:e,disabled:t=!1,sessions:n,currentSessionId:r,onSelectSession:i,hideSessionSwitcher:a=!1,onRefocus:o,isKeyboardVisible:s,onEnterTextMode:c}){let[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(``),[p,m]=(0,x.useState)(null),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!1),y=(0,x.useRef)(null),b=(0,x.useRef)(null),S=(0,x.useRef)(0),C=(0,x.useRef)(null);(0,x.useEffect)(()=>{l&&y.current&&y.current.focus()},[l]),(0,x.useEffect)(()=>{let e=C.current;if(!e)return;let n=n=>{t||e.contains(n.target)&&s?.()&&n.preventDefault()};return e.addEventListener(`touchstart`,n,{passive:!1,capture:!0}),()=>{e.removeEventListener(`touchstart`,n,{capture:!0})}},[t,s]),(0,x.useEffect)(()=>{if(!_||t||typeof document>`u`)return;let n=t=>{let{output:n,consumeCtrl:r}=SO(t.key,!0);r&&(t.preventDefault(),t.stopPropagation(),xO(),e(n),v(!1))};return document.addEventListener(`keydown`,n,{capture:!0}),()=>{document.removeEventListener(`keydown`,n,{capture:!0})}},[_,t,e]),(0,x.useEffect)(()=>{if(!l)return;let t=b.current;if(!t)return;let n=async t=>{let n=t.clipboardData?.items;if(n){for(let r of n)if(r.type.startsWith(`image/`)){t.preventDefault();let n=r.getAsFile();if(!n)continue;g(!0),m(null);try{let t=await wO(n,`paste.${r.type.split(`/`)[1]||`png`}`);`path`in t?(e(t.path),u(!1),f(``),o?.()):m(t.error)}finally{g(!1)}return}}};return t.addEventListener(`paste`,n),()=>t.removeEventListener(`paste`,n)},[l,e,o]);let w=n=>{if(t)return;let r=s?.()??!1;xO();let{output:i,consumeCtrl:a}=SO(n,_);a&&v(!1),e(i),r&&o?.()},T=()=>{t||(xO(),v(!_))},E=t=>{let{output:n,consumeCtrl:r}=SO(t,_);r&&v(!1),e(n)},D=async()=>{if(t)return;let n=s?.()??!1;xO(),m(null);try{let t=await navigator.clipboard.read();for(let r of t){let t=r.types.find(e=>e.startsWith(`image/`));if(t){let i=await wO(await r.getType(t),`paste.${t.split(`/`)[1]||`png`}`);if(`path`in i){e(i.path),n&&o?.();return}m(i.error),u(!0),f(``);return}if(r.types.includes(`text/plain`)){let t=await(await r.getType(`text/plain`)).text();if(t){e(t),n&&o?.();return}}}}catch{try{let t=await navigator.clipboard.readText();if(t){e(t),n&&o?.();return}}catch{}}u(!0),f(``)},O=()=>{d&&(xO(),e(d)),u(!1),f(``),m(null),o?.()},k=()=>{u(!1),f(``),m(null),o?.()},A=e=>{xO(),i(e)},j=()=>{t||(xO(),s?.()?document.activeElement instanceof HTMLElement&&document.activeElement.blur():c?.())},M=n.length>1&&!a,N=e=>n=>{t||(n.preventDefault(),n.stopPropagation(),S.current=Date.now(),e())},P=e=>()=>{t||Date.now()-S.current<700||e()};return(0,q.jsxs)(`div`,{ref:C,className:`terminal-controls flex flex-col gap-1.5 px-2 py-2.5 bg-elevated border-t border-border ${Ve()?``:`md:hidden`}`,children:[M&&(0,q.jsxs)(`div`,{className:`relative -mx-2`,children:[(0,q.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-3 bg-gradient-to-r from-elevated to-transparent z-10 pointer-events-none`}),(0,q.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-3 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5 px-3 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:n.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:`
159
+ `,style:{width:dO,height:fO,WebkitUserSelect:`none`,userSelect:`none`},children:e},t):(0,q.jsx)(`div`,{style:{width:dO,height:fO}},t))}),(0,q.jsx)(`div`,{className:`text-center text-white text-sm font-medium select-none h-5`,style:{marginTop:pO+2},children:o?`Release to send "${o}"`:`\xA0`})]})})]})]})}var SO=(0,q.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,q.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`})}),CO=(0,q.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,q.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,q.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]}),wO=(0,q.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,q.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,ry:`2`}),(0,q.jsx)(`line`,{x1:`6`,y1:`8`,x2:`6`,y2:`8`}),(0,q.jsx)(`line`,{x1:`10`,y1:`8`,x2:`10`,y2:`8`}),(0,q.jsx)(`line`,{x1:`14`,y1:`8`,x2:`14`,y2:`8`}),(0,q.jsx)(`line`,{x1:`18`,y1:`8`,x2:`18`,y2:`8`}),(0,q.jsx)(`line`,{x1:`6`,y1:`12`,x2:`6`,y2:`12`}),(0,q.jsx)(`line`,{x1:`10`,y1:`12`,x2:`10`,y2:`12`}),(0,q.jsx)(`line`,{x1:`14`,y1:`12`,x2:`14`,y2:`12`}),(0,q.jsx)(`line`,{x1:`18`,y1:`12`,x2:`18`,y2:`12`}),(0,q.jsx)(`line`,{x1:`7`,y1:`16`,x2:`17`,y2:`16`})]}),TO=[{label:`esc`,key:`\x1B`},{label:`tab`,key:` `}],EO=[{label:SO,key:``,ariaLabel:`Delete word`},{label:(0,q.jsx)(ue,{width:18,height:18}),key:`\r`,grow:!0,className:`bg-accent/20 text-accent border-accent/40`,ariaLabel:`Enter`}];function DO(){`vibrate`in navigator&&navigator.vibrate(10)}function OO(e,t){if(!t||e.length!==1)return{output:e,consumeCtrl:!1};let n=e.toUpperCase().charCodeAt(0);return n>=65&&n<=90?{output:String.fromCharCode(n-64),consumeCtrl:!0}:{output:e,consumeCtrl:!0}}var kO={working:`bg-working`,waiting:`bg-waiting`,permission:`bg-approval`,unknown:`bg-muted`};async function AO(e,t){try{let n=new FormData;n.append(`image`,e,t);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(r.ok){let{path:e}=await r.json();return{path:e}}let i=`Image upload failed`;try{let e=await r.json();typeof e.error==`string`&&(i=e.error)}catch{}return{error:i}}catch{return{error:`Image upload failed`}}}function jO({onSendKey:e,disabled:t=!1,sessions:n,currentSessionId:r,agentType:i,onSelectSession:a,hideSessionSwitcher:o=!1,onRefocus:s,isKeyboardVisible:c,onEnterTextMode:l}){let[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(!1),b=(0,x.useRef)(null),S=(0,x.useRef)(null),C=(0,x.useRef)(0),w=(0,x.useRef)(null);(0,x.useEffect)(()=>{u&&b.current&&b.current.focus()},[u]),(0,x.useEffect)(()=>{let e=w.current;if(!e)return;let n=n=>{t||e.contains(n.target)&&c?.()&&n.preventDefault()};return e.addEventListener(`touchstart`,n,{passive:!1,capture:!0}),()=>{e.removeEventListener(`touchstart`,n,{capture:!0})}},[t,c]),(0,x.useEffect)(()=>{if(!v||t||typeof document>`u`)return;let n=t=>{let{output:n,consumeCtrl:r}=OO(t.key,!0);r&&(t.preventDefault(),t.stopPropagation(),DO(),e(n),y(!1))};return document.addEventListener(`keydown`,n,{capture:!0}),()=>{document.removeEventListener(`keydown`,n,{capture:!0})}},[v,t,e]),(0,x.useEffect)(()=>{if(!u)return;let t=S.current;if(!t)return;let n=async t=>{let n=t.clipboardData?.items;if(n){for(let r of n)if(r.type.startsWith(`image/`)){t.preventDefault();let n=r.getAsFile();if(!n)continue;_(!0),h(null);try{let t=await AO(n,`paste.${r.type.split(`/`)[1]||`png`}`);`path`in t?(e(yD(t.path,i)),d(!1),p(``),s?.()):h(t.error)}finally{_(!1)}return}}};return t.addEventListener(`paste`,n),()=>t.removeEventListener(`paste`,n)},[u,e,s,i]);let T=n=>{if(t)return;let r=c?.()??!1;DO();let{output:i,consumeCtrl:a}=OO(n,v);a&&y(!1),e(i),r&&s?.()},E=()=>{t||(DO(),y(!v))},D=t=>{let{output:n,consumeCtrl:r}=OO(t,v);r&&y(!1),e(n)},O=async()=>{if(t)return;let n=c?.()??!1;DO(),h(null);try{let t=await navigator.clipboard.read();for(let r of t){let t=r.types.find(e=>e.startsWith(`image/`));if(t){let a=await AO(await r.getType(t),`paste.${t.split(`/`)[1]||`png`}`);if(`path`in a){e(yD(a.path,i)),n&&s?.();return}h(a.error),d(!0),p(``);return}if(r.types.includes(`text/plain`)){let t=await(await r.getType(`text/plain`)).text();if(t){e(t),n&&s?.();return}}}}catch{try{let t=await navigator.clipboard.readText();if(t){e(t),n&&s?.();return}}catch{}}d(!0),p(``)},k=()=>{f&&(DO(),e(f)),d(!1),p(``),h(null),s?.()},A=()=>{d(!1),p(``),h(null),s?.()},j=e=>{DO(),a(e)},M=()=>{t||(DO(),c?.()?document.activeElement instanceof HTMLElement&&document.activeElement.blur():l?.())},N=n.length>1&&!o,P=e=>n=>{t||(n.preventDefault(),n.stopPropagation(),C.current=Date.now(),e())},F=e=>()=>{t||Date.now()-C.current<700||e()};return(0,q.jsxs)(`div`,{ref:w,className:`terminal-controls flex flex-col gap-1.5 px-2 py-2.5 bg-elevated border-t border-border ${Ve()?``:`md:hidden`}`,children:[N&&(0,q.jsxs)(`div`,{className:`relative -mx-2`,children:[(0,q.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-3 bg-gradient-to-r from-elevated to-transparent z-10 pointer-events-none`}),(0,q.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-3 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5 px-3 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:n.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:`
160
160
  terminal-key flex items-center justify-center gap-1.5 shrink-0 snap-start
161
161
  h-8 min-w-[3rem] px-2.5 text-xs font-medium rounded-md
162
162
  active:scale-95 transition-transform duration-75
163
163
  select-none touch-manipulation
164
164
  ${e.id===r?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
165
- `,onClick:()=>A(e.id),children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${CO[e.status]}`}),(0,q.jsx)(`span`,{className:`truncate`,children:t+1})]},e.id))})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,className:`
165
+ `,onClick:()=>j(e.id),children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${kO[e.status]}`}),(0,q.jsx)(`span`,{className:`truncate`,children:t+1})]},e.id))})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,className:`
166
166
  terminal-key
167
167
  flex items-center justify-center
168
168
  h-11 min-w-[2.75rem] px-2.5
@@ -171,9 +171,9 @@ void main() {
171
171
  active:scale-95
172
172
  transition-transform duration-75
173
173
  select-none touch-manipulation
174
- ${_?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
174
+ ${v?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
175
175
  ${t?`opacity-50`:``}
176
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:N(T),onClick:P(T),disabled:t,children:`ctrl`}),yO.map((e,n)=>(0,q.jsx)(`button`,{type:`button`,className:`
176
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:P(E),onClick:F(E),disabled:t,children:`ctrl`}),TO.map((e,n)=>(0,q.jsx)(`button`,{type:`button`,className:`
177
177
  terminal-key
178
178
  flex items-center justify-center
179
179
  h-11 min-w-[2.75rem] px-2.5
@@ -185,7 +185,7 @@ void main() {
185
185
  ${e.grow?`flex-1`:``}
186
186
  ${e.className??`text-secondary`}
187
187
  ${t?`opacity-50`:``}
188
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:N(()=>w(e.key)),onClick:P(()=>w(e.key)),disabled:t,children:e.label},`left-${n}`)),(0,q.jsx)(hO,{onSendKey:E,disabled:t,onRefocus:o,isKeyboardVisible:s}),(0,q.jsx)(rO,{onSendKey:E,disabled:t,onRefocus:o,isKeyboardVisible:s}),bO.map((e,n)=>(0,q.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel,className:`
188
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:P(()=>T(e.key)),onClick:F(()=>T(e.key)),disabled:t,children:e.label},`left-${n}`)),(0,q.jsx)(xO,{onSendKey:D,disabled:t,onRefocus:s,isKeyboardVisible:c}),(0,q.jsx)(lO,{onSendKey:D,disabled:t,onRefocus:s,isKeyboardVisible:c}),EO.map((e,n)=>(0,q.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel,className:`
189
189
  terminal-key
190
190
  flex items-center justify-center
191
191
  h-11 min-w-[2.75rem] px-2.5
@@ -197,7 +197,7 @@ void main() {
197
197
  ${e.grow?`flex-1`:``}
198
198
  ${e.className??`text-secondary`}
199
199
  ${t?`opacity-50`:``}
200
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:N(()=>w(e.key)),onClick:P(()=>w(e.key)),disabled:t,children:e.label},`right-${n}`)),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Paste`,className:`
200
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:P(()=>T(e.key)),onClick:F(()=>T(e.key)),disabled:t,children:e.label},`right-${n}`)),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Paste`,className:`
201
201
  terminal-key
202
202
  flex items-center justify-center
203
203
  h-11 min-w-[2.75rem] px-2.5
@@ -208,7 +208,7 @@ void main() {
208
208
  select-none touch-manipulation
209
209
  text-secondary
210
210
  ${t?`opacity-50`:``}
211
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:N(()=>{D()}),onClick:P(()=>{D()}),disabled:t,children:_O}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Show keyboard`,className:`
211
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:P(()=>{O()}),onClick:F(()=>{O()}),disabled:t,children:CO}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Show keyboard`,className:`
212
212
  terminal-key
213
213
  flex items-center justify-center
214
214
  h-11 min-w-[2.75rem] px-2.5
@@ -219,11 +219,11 @@ void main() {
219
219
  select-none touch-manipulation
220
220
  text-secondary
221
221
  ${t?`opacity-50`:``}
222
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:N(j),onClick:P(j),disabled:t,children:vO})]}),l&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,q.jsxs)(`div`,{ref:b,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,q.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),h?(0,q.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,q.jsx)(`input`,{ref:y,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),O()):e.key===`Escape`&&(e.preventDefault(),k())},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`}}),p&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:p}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:k,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,q.jsx)(`button`,{type:`button`,onClick:O,disabled:h,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 EO({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=ud(),_=(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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,q.jsx)(WT,{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,q.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,q.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var DO={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},OO={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},kO={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`},AO={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function jO(){`vibrate`in navigator&&navigator.vibrate(10)}function MO({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=KD[GD(e=>e.theme)],C=G(e=>e.useWebGL),w=G(e=>e.fontSize),T=G(e=>e.lineHeight),E=G(e=>e.letterSpacing),D=R(G(e=>e.fontOption),G(e=>e.customFontFamily)),O=Ke(We(G(e=>e.shortcutModifier))),k=Ve(),A=VD(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,ee]=(0,x.useState)(``),K=(0,x.useRef)(!1),te=(0,x.useRef)(null),re=(0,x.useRef)(null),ie=(0,x.useRef)(null),ae=(0,x.useRef)(null),oe=e?.remote===!0,se=Wm(e=>e.remoteAllowControl),le=Wm(e=>e.remoteAllowAttach),ue=Wm(e=>e.preferWindowName),de=oe&&!le,pe=!oe||se&&e?.source===`managed`,he=n?n.displayName||Nm(n.projectPath)||n.sessionId.slice(0,8):``,ge=n?Nm(n.projectPath):``,_e=n?Mm(n.lastActivityAt):``,ve=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:ye,terminalRef:be,inTmuxCopyModeRef:xe,appMouseRef:Ce,setTmuxCopyMode:Te,isSwitching:Ee,pendingClipboardOffer:De,copyPendingClipboardOffer:Oe,dismissPendingClipboardOffer:ke}=BD({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,allowAttach:!de,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),je=(0,x.useCallback)(()=>{!e||de||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),Te(!1),be.current?.scrollToBottom())},[e,de,s,Te,be]),Me=(0,x.useCallback)(()=>{V(!0),jO()},[]),Ne=WD({enabled:A||k,isOpen:B,onOpen:Me});(0,x.useEffect)(()=>{!A&&!k&&B&&V(!1)},[B,A,k]),HD(re,L,(0,x.useCallback)(()=>z(!1),[])),(0,x.useEffect)(()=>{H&&ie.current&&(ie.current.focus(),ie.current.select())},[H]),(0,x.useEffect)(()=>{F&&ae.current&&ae.current.focus()},[F]),UD(F,(0,x.useCallback)(()=>I(!1),[]));let Fe=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ie=()=>{!e||!ve||(g?.(e.agentSessionId.trim()),z(!1))},Le=()=>{e&&(ee(e.agentSessionName||e.name),U(!0),z(!1))},Re=()=>{if(!e)return;let t=W.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),U(!1)},ze=e=>{e.key===`Enter`?(e.preventDefault(),Re()):e.key===`Escape`&&(e.preventDefault(),U(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=ye.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=()=>{K.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}be.current?.clearSelection(),r(),P(!1)};te.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){K.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&K.current){i();return}K.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),te.current=null,K.current=!1}},[ye,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=ye.current;if(!t)return;let n=()=>{let e=be.current,n=t.querySelector(`.xterm`);if(!e||!n)return;let r=n.querySelector(`.xterm-screen`),i=n.querySelector(`.xterm-accessibility`),a=n.querySelector(`.xterm-accessibility-tree`);if(!r||!i||!a)return;let o=n.getBoundingClientRect(),s=r.getBoundingClientRect(),c=s.left-o.left,l=s.top-o.top;Object.assign(i.style,{left:`${c}px`,top:`${l}px`,right:`auto`,bottom:`auto`,width:`${s.width}px`,height:`${s.height}px`});let u=s.width/e.cols,d=s.height/e.rows,f=document.createElement(`span`);f.textContent=`0`.repeat(200),f.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,a.appendChild(f);let p=f.getBoundingClientRect().width/200;f.remove();let m=Math.max(-2,Math.min(2,u-p));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${d}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${m}px`)},r=performance.now();n();let i=Math.round(performance.now()-r);i>10&&Z(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:i});let a=window.requestAnimationFrame(n),o=window.setTimeout(n,100),s=()=>window.requestAnimationFrame(n);return window.visualViewport?.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),()=>{window.cancelAnimationFrame(a),window.clearTimeout(o),window.visualViewport?.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s)}},[ye,w,k,e?.id,be]);let He=(0,x.useRef)(N);(0,x.useEffect)(()=>{He.current=N},[N]);let Ue=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Ue.current=e?.id},[e?.id]);let Ge=(0,x.useRef)(s);(0,x.useEffect)(()=>{Ge.current=s},[s]);let qe=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=ye.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=be.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(xe.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=Ue.current;return r?(Ge.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Ue.current;if(!t||e===0)return!1;let n=be.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++)Ge.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ce.current&&Te(!0),l},E=e=>{let t=Ue.current,n=g(e);return!t||!n?!1:(Ge.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||!Ce.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),jO(),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||!K.current||N()||te.current?.()},F=e=>{if(b(),P(),Ne.current||B){M();return}if(He.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&&Ce.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ne.current||B)&&(He.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ne.current||B){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(He.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(),Ne.current||B)return;let a=N();if(He.current&&!a&&te.current?.(),He.current||a){xe.current&&(qe.current=!0);return}if(!i){if(k&&n>=350)return;if(Ce.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(xe.current){e.preventDefault(),e.stopPropagation(),qe.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)}},R=e=>{qe.current&&=(e.preventDefault(),e.stopPropagation(),!1)},z={passive:!0,capture:!0},V={passive:!1,capture:!0},H={passive:!1,capture:!0},U={capture:!0};return t.addEventListener(`touchstart`,F,z),t.addEventListener(`touchmove`,I,V),t.addEventListener(`touchend`,L,H),t.addEventListener(`mousedown`,R,U),()=>{t.removeEventListener(`touchstart`,F,z),t.removeEventListener(`touchmove`,I,V),t.removeEventListener(`touchend`,L,H),t.removeEventListener(`mousedown`,R,U),x();let e=h();e&&(e.disabled=!1)}},[e?.id,ye,be,k,A,B,w,T]);let Je=(0,x.useCallback)(t=>{!e||de||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,de,s]),Ye=(0,x.useCallback)(()=>{let e=ye.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[ye]),Xe=(0,x.useCallback)(()=>{if(!e||de)return;xe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),Te(!1));let t=ye.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,de,s,ye,xe,Te]),Ze=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=ye.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`)},[ye]);(0,x.useEffect)(()=>{if(!k)return;let e=ye.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&&!He.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)}},[ye,k,N]),(0,x.useEffect)(()=>{let e=ye.current;e&&(e.inert=!!n)},[ye,n]);let Qe=(0,x.useMemo)(()=>{if(!ue||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},[ue,t]);return(0,q.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,q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e||n?``:`md:hidden`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,q.jsx)(`button`,{onClick:()=>V(!0),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all md:hidden shrink-0`,"aria-label":`Open session menu`,children:(0,q.jsx)(Se,{width:16,height:16})}),e&&pe&&(0,q.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,q.jsx)(Be,{width:16,height:16})}),ve&&(0,q.jsx)(`button`,{onClick:Ie,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,q.jsx)(we,{width:16,height:16})}),e?(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3 min-w-0`,children:[H?(0,q.jsx)(`input`,{ref:ie,type:`text`,value:W,onChange:e=>ee(e.target.value),onBlur:Re,onKeyDown:ze,className:`w-full max-w-[200px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:e.agentSessionName||e.name}),(0,q.jsx)(`span`,{className:`text-xs shrink-0 ${OO[e.status]}`,children:DO[e.status]})]}):n?(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:he}),(0,q.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-400`,children:`Hibernating`})]}):(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[a!==`connected`&&(0,q.jsx)(`span`,{className:`text-xs text-approval`,children:a}),(0,q.jsx)(`button`,{onClick:f,className:`flex h-7 w-7 items-center justify-center rounded bg-accent text-white hover:bg-accent/90 active:scale-95 transition-all md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,q.jsx)(Ae,{width:16,height:16})}),e&&pe&&(0,q.jsx)(`button`,{onClick:()=>I(!0),className:`flex md:hidden 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`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,q.jsx)(Be,{width:16,height:16})}),ve&&(0,q.jsx)(`button`,{onClick:Ie,className:`flex md:hidden 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`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,q.jsx)(we,{width:16,height:16})}),n&&(0,q.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-7 px-2 text-xs md:hidden`,children:`Wake`}),e&&(0,q.jsxs)(`div`,{className:`relative md:hidden`,ref:re,children:[(0,q.jsx)(`button`,{onClick:()=>z(!L),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`More options`,"aria-label":`More options`,children:(0,q.jsx)(fe,{width:16,height:16})}),L&&(0,q.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:[pe&&(0,q.jsxs)(`button`,{onClick:Le,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(me,{width:14,height:14}),`Rename`]}),ve&&(0,q.jsxs)(`button`,{onClick:Ie,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(we,{width:14,height:14}),`Hibernate`]}),(0,q.jsxs)(`button`,{onClick:()=>{v(),z(!1)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(Pe,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,q.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,q.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,q.jsx)(`div`,{className:`flex items-center gap-1.5 pl-5 pr-3 py-1.5 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=Qe?t.name.trim():n+1;return(0,q.jsx)(`button`,{type:`button`,className:`
222
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:P(M),onClick:F(M),disabled:t,children:wO})]}),u&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,q.jsxs)(`div`,{ref:S,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,q.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),g?(0,q.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,q.jsx)(`input`,{ref:b,type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),k()):e.key===`Escape`&&(e.preventDefault(),A())},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`}}),m&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:m}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:A,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,q.jsx)(`button`,{type:`button`,onClick:k,disabled:g,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 MO({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=ud(),_=(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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,q.jsx)(WT,{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,q.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,q.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var NO={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},PO={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},FO={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`},IO={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function LO(){`vibrate`in navigator&&navigator.vibrate(10)}function RO({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=QD[ZD(e=>e.theme)],C=G(e=>e.useWebGL),w=G(e=>e.fontSize),T=G(e=>e.lineHeight),E=G(e=>e.letterSpacing),D=R(G(e=>e.fontOption),G(e=>e.customFontFamily)),O=Ke(We(G(e=>e.shortcutModifier))),k=Ve(),A=qD(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,ee]=(0,x.useState)(``),K=(0,x.useRef)(!1),te=(0,x.useRef)(null),re=(0,x.useRef)(null),ie=(0,x.useRef)(null),ae=(0,x.useRef)(null),oe=e?.remote===!0,se=Wm(e=>e.remoteAllowControl),le=Wm(e=>e.remoteAllowAttach),ue=Wm(e=>e.preferWindowName),de=oe&&!le,pe=!oe||se&&e?.source===`managed`,he=n?n.displayName||Nm(n.projectPath)||n.sessionId.slice(0,8):``,ge=n?Nm(n.projectPath):``,_e=n?Mm(n.lastActivityAt):``,ve=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:ye,terminalRef:be,inTmuxCopyModeRef:xe,appMouseRef:Ce,setTmuxCopyMode:Te,isSwitching:Ee,pendingClipboardOffer:De,copyPendingClipboardOffer:Oe,dismissPendingClipboardOffer:ke}=KD({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,allowAttach:!de,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),je=(0,x.useCallback)(()=>{!e||de||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),Te(!1),be.current?.scrollToBottom())},[e,de,s,Te,be]),Me=(0,x.useCallback)(()=>{V(!0),LO()},[]),Ne=XD({enabled:A||k,isOpen:B,onOpen:Me});(0,x.useEffect)(()=>{!A&&!k&&B&&V(!1)},[B,A,k]),JD(re,L,(0,x.useCallback)(()=>z(!1),[])),(0,x.useEffect)(()=>{H&&ie.current&&(ie.current.focus(),ie.current.select())},[H]),(0,x.useEffect)(()=>{F&&ae.current&&ae.current.focus()},[F]),YD(F,(0,x.useCallback)(()=>I(!1),[]));let Fe=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ie=()=>{!e||!ve||(g?.(e.agentSessionId.trim()),z(!1))},Le=()=>{e&&(ee(e.agentSessionName||e.name),U(!0),z(!1))},Re=()=>{if(!e)return;let t=W.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),U(!1)},ze=e=>{e.key===`Enter`?(e.preventDefault(),Re()):e.key===`Escape`&&(e.preventDefault(),U(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=ye.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=()=>{K.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}be.current?.clearSelection(),r(),P(!1)};te.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){K.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&K.current){i();return}K.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),te.current=null,K.current=!1}},[ye,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=ye.current;if(!t)return;let n=()=>{let e=be.current,n=t.querySelector(`.xterm`);if(!e||!n)return;let r=n.querySelector(`.xterm-screen`),i=n.querySelector(`.xterm-accessibility`),a=n.querySelector(`.xterm-accessibility-tree`);if(!r||!i||!a)return;let o=n.getBoundingClientRect(),s=r.getBoundingClientRect(),c=s.left-o.left,l=s.top-o.top;Object.assign(i.style,{left:`${c}px`,top:`${l}px`,right:`auto`,bottom:`auto`,width:`${s.width}px`,height:`${s.height}px`});let u=s.width/e.cols,d=s.height/e.rows,f=document.createElement(`span`);f.textContent=`0`.repeat(200),f.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,a.appendChild(f);let p=f.getBoundingClientRect().width/200;f.remove();let m=Math.max(-2,Math.min(2,u-p));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${d}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${m}px`)},r=performance.now();n();let i=Math.round(performance.now()-r);i>10&&Z(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:i});let a=window.requestAnimationFrame(n),o=window.setTimeout(n,100),s=()=>window.requestAnimationFrame(n);return window.visualViewport?.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),()=>{window.cancelAnimationFrame(a),window.clearTimeout(o),window.visualViewport?.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s)}},[ye,w,k,e?.id,be]);let He=(0,x.useRef)(N);(0,x.useEffect)(()=>{He.current=N},[N]);let Ue=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Ue.current=e?.id},[e?.id]);let Ge=(0,x.useRef)(s);(0,x.useEffect)(()=>{Ge.current=s},[s]);let qe=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=ye.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=be.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(xe.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=Ue.current;return r?(Ge.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Ue.current;if(!t||e===0)return!1;let n=be.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++)Ge.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ce.current&&Te(!0),l},E=e=>{let t=Ue.current,n=g(e);return!t||!n?!1:(Ge.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||!Ce.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),LO(),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||!K.current||N()||te.current?.()},F=e=>{if(b(),P(),Ne.current||B){M();return}if(He.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&&Ce.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ne.current||B)&&(He.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ne.current||B){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(He.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(),Ne.current||B)return;let a=N();if(He.current&&!a&&te.current?.(),He.current||a){xe.current&&(qe.current=!0);return}if(!i){if(k&&n>=350)return;if(Ce.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(xe.current){e.preventDefault(),e.stopPropagation(),qe.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)}},R=e=>{qe.current&&=(e.preventDefault(),e.stopPropagation(),!1)},z={passive:!0,capture:!0},V={passive:!1,capture:!0},H={passive:!1,capture:!0},U={capture:!0};return t.addEventListener(`touchstart`,F,z),t.addEventListener(`touchmove`,I,V),t.addEventListener(`touchend`,L,H),t.addEventListener(`mousedown`,R,U),()=>{t.removeEventListener(`touchstart`,F,z),t.removeEventListener(`touchmove`,I,V),t.removeEventListener(`touchend`,L,H),t.removeEventListener(`mousedown`,R,U),x();let e=h();e&&(e.disabled=!1)}},[e?.id,ye,be,k,A,B,w,T]);let Je=(0,x.useCallback)(t=>{!e||de||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,de,s]),Ye=(0,x.useCallback)(()=>{let e=ye.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[ye]),Xe=(0,x.useCallback)(()=>{if(!e||de)return;xe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),Te(!1));let t=ye.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,de,s,ye,xe,Te]),Ze=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=ye.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`)},[ye]);(0,x.useEffect)(()=>{if(!k)return;let e=ye.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&&!He.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)}},[ye,k,N]),(0,x.useEffect)(()=>{let e=ye.current;e&&(e.inert=!!n)},[ye,n]);let Qe=(0,x.useMemo)(()=>{if(!ue||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},[ue,t]);return(0,q.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,q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e||n?``:`md:hidden`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,q.jsx)(`button`,{onClick:()=>V(!0),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all md:hidden shrink-0`,"aria-label":`Open session menu`,children:(0,q.jsx)(Se,{width:16,height:16})}),e&&pe&&(0,q.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,q.jsx)(Be,{width:16,height:16})}),ve&&(0,q.jsx)(`button`,{onClick:Ie,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,q.jsx)(we,{width:16,height:16})}),e?(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3 min-w-0`,children:[H?(0,q.jsx)(`input`,{ref:ie,type:`text`,value:W,onChange:e=>ee(e.target.value),onBlur:Re,onKeyDown:ze,className:`w-full max-w-[200px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:e.agentSessionName||e.name}),(0,q.jsx)(`span`,{className:`text-xs shrink-0 ${PO[e.status]}`,children:NO[e.status]})]}):n?(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:he}),(0,q.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-400`,children:`Hibernating`})]}):(0,q.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[a!==`connected`&&(0,q.jsx)(`span`,{className:`text-xs text-approval`,children:a}),(0,q.jsx)(`button`,{onClick:f,className:`flex h-7 w-7 items-center justify-center rounded bg-accent text-white hover:bg-accent/90 active:scale-95 transition-all md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,q.jsx)(Ae,{width:16,height:16})}),e&&pe&&(0,q.jsx)(`button`,{onClick:()=>I(!0),className:`flex md:hidden 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`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,q.jsx)(Be,{width:16,height:16})}),ve&&(0,q.jsx)(`button`,{onClick:Ie,className:`flex md:hidden 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`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,q.jsx)(we,{width:16,height:16})}),n&&(0,q.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-7 px-2 text-xs md:hidden`,children:`Wake`}),e&&(0,q.jsxs)(`div`,{className:`relative md:hidden`,ref:re,children:[(0,q.jsx)(`button`,{onClick:()=>z(!L),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`More options`,"aria-label":`More options`,children:(0,q.jsx)(fe,{width:16,height:16})}),L&&(0,q.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:[pe&&(0,q.jsxs)(`button`,{onClick:Le,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(me,{width:14,height:14}),`Rename`]}),ve&&(0,q.jsxs)(`button`,{onClick:Ie,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(we,{width:14,height:14}),`Hibernate`]}),(0,q.jsxs)(`button`,{onClick:()=>{v(),z(!1)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,q.jsx)(Pe,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,q.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,q.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,q.jsx)(`div`,{className:`flex items-center gap-1.5 pl-5 pr-3 py-1.5 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=Qe?t.name.trim():n+1;return(0,q.jsx)(`button`,{type:`button`,className:`
223
223
  flex items-center justify-center shrink-0 snap-start
224
224
  h-8 ${Qe?`min-w-[2rem] px-2.5 max-w-[8rem] truncate`:`w-8`}
225
225
  text-sm font-extrabold rounded-lg
226
226
  active:scale-95 transition-all duration-75
227
227
  select-none touch-manipulation
228
- ${r?AO[t.status]:kO[t.status]}
229
- `,onClick:()=>{jO(),u(t.id)},title:Qe?t.name:void 0,children:i},t.id)})})]}),(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(`div`,{ref:ye,className:`absolute inset-0`}),Ee&&e&&(0,q.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,q.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,q.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,q.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),De&&e&&(0,q.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,q.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,q.jsxs)(`button`,{type:`button`,onClick:Oe,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,q.jsx)(ce,{width:14,height:14}),`Copy`]}),(0,q.jsx)(`button`,{type:`button`,onClick:ke,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,q.jsx)(Be,{width:14,height:14})})]}),!e&&(0,q.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&&de&&(0,q.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,q.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,q.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,q.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,q.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:he}),(0,q.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`}),ge&&(0,q.jsx)(`span`,{className:`text-muted`,children:ge}),(0,q.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,_e]})]}),n.lastResumeError&&(0,q.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,q.jsx)(ne,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,q.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,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,q.jsx)(zT,{session:n})]})}),j&&e&&!N&&(0,q.jsxs)(`button`,{onClick:je,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,q.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,q.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,q.jsx)(TO,{onSendKey:Je,disabled:a!==`connected`||de,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:Ye,isKeyboardVisible:Ze,onEnterTextMode:Xe}),(A||k)&&(0,q.jsx)(EO,{isOpen:B,onClose:()=>V(!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,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,q.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,q.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,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,q.jsx)(`button`,{ref:ae,onClick:Fe,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function NO({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=G(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,q.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,q.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,q.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,q.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,q.jsx)(`p`,{className:`text-danger`,children:s}),(0,q.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,q.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,q.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,q.jsx)(ve,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,q.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,q.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,q.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,q.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,q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function PO({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=>H(e)===t);e?(v(e.id),b(H(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(H(e))):i.length>0?(v(i[0].id),b(H(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(H(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,q.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,q.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,q.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,q.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,q.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,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,q.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,q.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,q.jsx)(Zm,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,q.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.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,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,q.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,q.jsx)(NO,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function FO({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 IO={};function LO(e,t){let n=x.useRef(IO);return n.current===IO&&(n.current=e(t)),n}var RO=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],zO=RO&&RO!==x.useLayoutEffect?RO:e=>e();function BO(e){let t=LO(VO).current;return t.next=e,zO(t.effect),t.trampoline}function VO(){let e={next:void 0,callback:HO,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function HO(){}function UO(e,t,n,r){let i=LO(GO).current;return KO(i,e,t,n,r)&&JO(i,[e,t,n,r]),i.callback}function WO(e){let t=LO(GO).current;return qO(t,e)&&JO(t,e),t.callback}function GO(){return{callback:null,cleanup:null,refs:[]}}function KO(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function qO(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function JO(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 YO=typeof document<`u`?x.useLayoutEffect:()=>{},XO={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},ZO={...XO,position:`fixed`,top:0,left:0},QO={...XO,position:`absolute`};function $O(){}Object.freeze([]);var ek=Object.freeze({});function tk(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 nk=18;function rk(e){return nk>=e}function ik(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(rk(19)?n?.ref:t.ref)??null}function ak(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function ok(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 sk(e,t){return typeof e==`function`?e(t):e}function ck(e,t){return typeof e==`function`?e(t):e}var lk={};function uk(e,t,n,r,i){let a={...gk(e,lk)};return t&&(a=fk(a,t)),n&&(a=fk(a,n)),r&&(a=fk(a,r)),i&&(a=fk(a,i)),a}function dk(e){if(e.length===0)return lk;if(e.length===1)return gk(e[0],lk);let t={...gk(e[0],lk)};for(let n=1;n<e.length;n+=1)t=fk(t,e[n]);return t}function fk(e,t){return hk(t)?t(e):pk(e,t)}function pk(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=ak(e.style,r);break;case`className`:e[n]=yk(e.className,r);break;default:mk(n,r)?e[n]=_k(e[n],r):e[n]=r}}return e}function mk(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 hk(e){return typeof e==`function`}function gk(e,t){return hk(e)?e(t):e??lk}function _k(e,t){return t?e?n=>{if(bk(n)){let r=n;vk(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function vk(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function yk(e,t){return t?e?t+` `+e:t:e}function bk(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function xk(e,t,n={}){let r=t.render,i=Sk(t,n);return n.enabled===!1?null:wk(e,r,i,n.state??ek)}function Sk(e,t={}){let{className:n,style:r,render:i}=e,{state:a=ek,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?sk(n,a):void 0,d=l?ck(r,a):void 0,f=l?ok(a,c):ek,p=l?ak(f,Array.isArray(s)?dk(s):s)??ek:ek;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=WO([p.ref,ik(i),...o]):p.ref=UO(p.ref,ik(i),o):UO(null,null)),l?(u!==void 0&&(p.className=yk(p.className,u)),d!==void 0&&(p.style=ak(p.style,d)),p):ek}var Ck=Symbol.for(`react.lazy`);function wk(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=uk(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Ck&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return Tk(e,n);throw Error(tk(8))}function Tk(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 Ek={...x},Dk=0;function Ok(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(Dk+=1,r(`${t}-${Dk}`))},[n,t]),i}var kk=Ek.useId;function Ak(e,t){if(kk!==void 0){let n=kk();return e??(t?`${t}-${n}`:n)}return Ok(e,t)}function jk(e){return Ak(e,`base-ui`)}function Mk(){return typeof window<`u`}function Nk(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pk(e){return Mk()?e instanceof Element||e instanceof Nk(e).Element:!1}function Fk(e){return Mk()?e instanceof HTMLElement||e instanceof Nk(e).HTMLElement:!1}function Ik(e){return!Mk()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Nk(e).ShadowRoot}var Lk=x.createContext(void 0);function Rk(e=!1){let t=x.useContext(Lk);if(t===void 0&&!e)throw Error(tk(16));return t}function zk(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 Bk(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=Rk(!0)!==void 0,s=BO(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=zk({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;Vk(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return YO(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return uk({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(vk(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||(vk(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:BO(e=>{a.current=e,l()})}}function Vk(e){return Fk(e)&&e.tagName===`BUTTON`}var Hk=x.createContext(void 0);function Uk(){let e=x.useContext(Hk);if(e===void 0)throw Error(tk(63));return e}var Wk=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}({}),Gk={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Kk={valid(e){return e===null?null:e?{[Wk.valid]:``}:{[Wk.invalid]:``}}},qk=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}({}),Jk={...Kk,checked(e){return e?{[qk.checked]:``}:{[qk.unchecked]:``}}};function Yk(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var Xk=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:$O,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Zk(){return x.useContext(Xk)}var Qk=x.createContext({invalid:void 0,name:void 0,validityData:{state:Gk,errors:[],error:``,value:``,initialValue:null},setValidityData:$O,disabled:void 0,touched:!1,setTouched:$O,dirty:!1,setDirty:$O,filled:!1,setFilled:$O,focused:!1,setFocused:$O,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=ek)=>e,getInputValidationProps:(e=ek)=>e,inputRef:{current:null},commit:async()=>{}}});function $k(e=!0){let t=x.useContext(Qk);if(t.setValidityData===$O&&!e)throw Error(tk(28));return t}function eA(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=Zk(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=$k(),f=BO(e.getValue);YO(()=>{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]),YO(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:Yk(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?K.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),YO(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var tA=x.createContext({controlId:void 0,registerControlId:$O,labelId:void 0,setLabelId:$O,messageIds:[],setMessageIds:$O,getDescriptionProps:e=>e});function nA(){return x.useContext(tA)}function rA(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=nA(),o=jk(t),s=n?i:void 0,c=LO(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=BO(()=>{!l.current||a===$O||(l.current=!1,a(c.current,void 0))});return YO(()=>{if(a===$O)return;let e;if(n){let n=r?.current;e=Pk(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 iA=`none`;function aA(e,t,n,r){let i=!1,a=!1,o=r??ek;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 oA(e,t){let n=x.useRef(e),r=BO(t);YO(()=>{n.current!==e&&r(n.current)},[e,r]),YO(()=>{n.current=e},[e])}var sA=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:_}=Zk(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=$k(),{labelId:A}=nA(),j=D||f,M=O??s,N=BO(l),P=x.useRef(null),F=UO(P,o,k.inputRef),I=x.useRef(null),L=jk(),R=rA({id:a,implicit:!1,controlRef:I}),z=c?void 0:R,[B,V]=FO({controlled:n,default:!!i,name:`Switch`,state:`checked`});eA({id:L,commit:k.commit,value:B,controlRef:I,name:M,getValue:()=>B}),YO(()=>{P.current&&C(P.current.checked)},[P,C]),oA(B,()=>{_(M),b(B!==S.initialValue),C(B),T()?k.commit(B):k.commit(B,!0)});let{getButtonProps:H,buttonRef:U}=Bk({disabled:j,native:c}),W={id:c?R:L,role:`switch`,"aria-checked":B,"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})))}},G=x.useMemo(()=>uk({checked:B,disabled:j,id:z,name:M,required:d,style:M?QO:ZO,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=aA(iA,e.nativeEvent);N?.(t,n),!n.isCanceled&&V(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?ek:{value:h}),[B,j,F,z,M,N,d,V,k,h]),ee=x.useMemo(()=>({...v,checked:B,disabled:j,readOnly:u,required:d}),[v,B,j,u,d]),K=xk(`span`,e,{state:ee,ref:[t,I,U],props:[W,k.getValidationProps,g,H],stateAttributesMapping:Jk});return(0,q.jsxs)(Hk.Provider,{value:ee,children:[K,!B&&M&&m!==void 0&&(0,q.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,q.jsx)(`input`,{...G})]})}),cA=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=$k(),o=Uk();return xk(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:Jk,props:i})});function lA(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=lA(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function uA(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=lA(e))&&(r&&(r+=` `),r+=t);return r}var dA=(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},fA=(e,t)=>({classGroupId:e,validator:t}),pA=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),mA=`-`,hA=[],gA=`arbitrary..`,_A=e=>{let t=bA(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return yA(e);let n=e.split(mA);return vA(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?dA(i,t):t:i||hA}return n[e]||hA}}},vA=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=vA(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(mA):e.slice(t).join(mA),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},yA=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?gA+r:void 0})(),bA=e=>{let{theme:t,classGroups:n}=e;return xA(n,t)},xA=(e,t)=>{let n=pA();for(let r in e){let i=e[r];SA(i,n,r,t)}return n},SA=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];CA(i,t,n,r)}},CA=(e,t,n,r)=>{if(typeof e==`string`){wA(e,t,n);return}if(typeof e==`function`){TA(e,t,n,r);return}EA(e,t,n,r)},wA=(e,t,n)=>{let r=e===``?t:DA(t,e);r.classGroupId=n},TA=(e,t,n,r)=>{if(OA(e)){SA(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(fA(n,e))},EA=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];SA(o,DA(t,a),n,r)}},DA=(e,t)=>{let n=e,r=t.split(mA),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=pA(),n.nextPart.set(t,i)),n=i}return n},OA=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,kA=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)}}},AA=`!`,jA=`:`,MA=[],NA=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),PA=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===jA){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(AA)?(c=s.slice(0,-1),l=!0):s.startsWith(AA)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return NA(t,l,c,u)};if(t){let e=t+jA,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):NA(MA,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},FA=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}},IA=e=>({cache:kA(e.cacheSize),parseClassName:PA(e),sortModifiers:FA(e),..._A(e)}),LA=/\s+/,RA=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(LA),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+AA: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},zA=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=BA(n))&&(i&&(i+=` `),i+=r);return i},BA=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=BA(e[r]))&&(n&&(n+=` `),n+=t);return n},VA=(e,...t)=>{let n,r,i,a,o=o=>(n=IA(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=RA(e,n);return i(e,a),a};return a=o,(...e)=>a(zA(...e))},HA=[],UA=e=>{let t=t=>t[e]||HA;return t.isThemeGetter=!0,t},WA=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,GA=/^\((?:(\w[\w-]*):)?(.+)\)$/i,KA=/^\d+\/\d+$/,qA=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,JA=/\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$/,YA=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,XA=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ZA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,QA=e=>KA.test(e),$A=e=>!!e&&!Number.isNaN(Number(e)),ej=e=>!!e&&Number.isInteger(Number(e)),tj=e=>e.endsWith(`%`)&&$A(e.slice(0,-1)),nj=e=>qA.test(e),rj=()=>!0,ij=e=>JA.test(e)&&!YA.test(e),aj=()=>!1,oj=e=>XA.test(e),sj=e=>ZA.test(e),cj=e=>!Q(e)&&!$(e),lj=e=>xj(e,Tj,aj),Q=e=>WA.test(e),uj=e=>xj(e,Ej,ij),dj=e=>xj(e,Dj,$A),fj=e=>xj(e,Cj,aj),pj=e=>xj(e,wj,sj),mj=e=>xj(e,kj,oj),$=e=>GA.test(e),hj=e=>Sj(e,Ej),gj=e=>Sj(e,Oj),_j=e=>Sj(e,Cj),vj=e=>Sj(e,Tj),yj=e=>Sj(e,wj),bj=e=>Sj(e,kj,!0),xj=(e,t,n)=>{let r=WA.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Sj=(e,t,n=!1)=>{let r=GA.exec(e);return r?r[1]?t(r[1]):n:!1},Cj=e=>e===`position`||e===`percentage`,wj=e=>e===`image`||e===`url`,Tj=e=>e===`length`||e===`size`||e===`bg-size`,Ej=e=>e===`length`,Dj=e=>e===`number`,Oj=e=>e===`family-name`,kj=e=>e===`shadow`,Aj=VA(()=>{let e=UA(`color`),t=UA(`font`),n=UA(`text`),r=UA(`font-weight`),i=UA(`tracking`),a=UA(`leading`),o=UA(`breakpoint`),s=UA(`container`),c=UA(`spacing`),l=UA(`radius`),u=UA(`shadow`),d=UA(`inset-shadow`),f=UA(`text-shadow`),p=UA(`drop-shadow`),m=UA(`blur`),h=UA(`perspective`),g=UA(`aspect`),_=UA(`ease`),v=UA(`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=()=>[QA,`full`,`auto`,...w()],E=()=>[ej,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,ej,$,Q]},ej,$,Q],O=()=>[ej,`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=()=>[QA,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),_j,fj,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,vj,lj,{size:[$,Q]}],R=()=>[tj,hj,uj],z=()=>[``,`none`,`full`,l,$,Q],B=()=>[``,$A,hj,uj],V=()=>[`solid`,`dashed`,`dotted`,`double`],H=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],U=()=>[$A,tj,_j,fj],W=()=>[``,`none`,m,$,Q],G=()=>[`none`,$A,$,Q],ee=()=>[`none`,$A,$,Q],K=()=>[$A,$,Q],te=()=>[QA,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[nj],breakpoint:[nj],color:[rj],container:[nj],"drop-shadow":[nj],ease:[`in`,`out`,`in-out`],font:[cj],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[nj],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[nj],shadow:[nj],spacing:[`px`,$A],text:[nj],"text-shadow":[nj],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,QA,Q,$,g]}],container:[`container`],columns:[{columns:[$A,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:[ej,`auto`,$,Q]}],basis:[{basis:[QA,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[$A,QA,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,$A,$,Q]}],shrink:[{shrink:[``,$A,$,Q]}],order:[{order:[ej,`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,hj,uj]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,dj]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,tj,Q]}],"font-family":[{font:[gj,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":[$A,`none`,$,dj]}],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:[...V(),`wavy`]}],"text-decoration-thickness":[{decoration:[$A,`from-font`,`auto`,$,uj]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[$A,`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`]},ej,$,Q],radial:[``,$,Q],conic:[ej,$,Q]},yj,pj]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":B()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...V(),`hidden`,`none`]}],"divide-style":[{divide:[...V(),`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:[...V(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[$A,$,Q]}],"outline-w":[{outline:[``,$A,hj,uj]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,bj,mj]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,bj,mj]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:B()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[$A,uj]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,bj,mj]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[$A,$,Q]}],"mix-blend":[{"mix-blend":[...H(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":H()}],"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":[$A]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"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":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"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":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"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":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"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":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"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":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"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":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"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":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"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":[$A]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"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:W()}],brightness:[{brightness:[$A,$,Q]}],contrast:[{contrast:[$A,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,bj,mj]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,$A,$,Q]}],"hue-rotate":[{"hue-rotate":[$A,$,Q]}],invert:[{invert:[``,$A,$,Q]}],saturate:[{saturate:[$A,$,Q]}],sepia:[{sepia:[``,$A,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":W()}],"backdrop-brightness":[{"backdrop-brightness":[$A,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[$A,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,$A,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$A,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,$A,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[$A,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[$A,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,$A,$,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:[$A,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[$A,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":[`scale-3d`],skew:[{skew:K()}],"skew-x":[{"skew-x":K()}],"skew-y":[{"skew-y":K()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"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:[$A,hj,uj,dj]}],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 jj(...e){return Aj(uA(e))}function Mj({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,q.jsx)(sA,{checked:e,onCheckedChange:t,disabled:n,className:jj(`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,q.jsx)(cA,{className:jj(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var Nj=null,Pj=!1,Fj={},Ij=500;function Lj(){if(typeof window>`u`)return null;if(Nj?.state===`closed`&&(Nj=null),!Nj){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Nj=new e}return Nj}function Rj(){Nj&&=(Nj.close().catch(()=>{}),null),Lj()}function zj(){return Pj}function Bj(){Nj&&(Rj(),Pj=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&Bj()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Bj()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&Bj(),e=t},5e3)}async function Vj(){let e=Lj();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),Pj=!1}async function Hj(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function Uj(e){let t=Lj();if(!t||(await Hj(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function Wj(){let e=Date.now();if(!(e-(Fj.permission||0)<Ij)){Fj.permission=e;try{await Uj({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function Gj(){let e=Date.now();if(!(e-(Fj.idle||0)<Ij)){Fj.idle=e;try{await Uj({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function Kj({isOpen:e,onClose:t}){let n=G(e=>e.defaultProjectDir),r=G(e=>e.setDefaultProjectDir),i=G(e=>e.commandPresets),a=G(e=>e.setCommandPresets),o=G(e=>e.defaultPresetId),s=G(e=>e.setDefaultPresetId),c=G(e=>e.sessionSortMode),l=G(e=>e.setSessionSortMode),u=G(e=>e.sessionSortDirection),d=G(e=>e.setSessionSortDirection),f=G(e=>e.useWebGL),p=G(e=>e.setUseWebGL),m=G(e=>e.fontSize),h=G(e=>e.setFontSize),g=G(e=>e.lineHeight),_=G(e=>e.setLineHeight),v=G(e=>e.letterSpacing),y=G(e=>e.setLetterSpacing),b=G(e=>e.fontOption),S=G(e=>e.setFontOption),C=G(e=>e.customFontFamily),w=G(e=>e.setCustomFontFamily),T=G(e=>e.shortcutModifier),E=G(e=>e.setShortcutModifier),D=G(e=>e.showProjectName),O=G(e=>e.setShowProjectName),k=G(e=>e.showLastUserMessage),A=G(e=>e.setShowLastUserMessage),j=G(e=>e.showSessionIdPrefix),M=G(e=>e.setShowSessionIdPrefix),N=GD(e=>e.theme),F=GD(e=>e.setTheme),I=G(e=>e.soundOnPermission),R=G(e=>e.setSoundOnPermission),z=G(e=>e.soundOnIdle),B=G(e=>e.setSoundOnIdle),[V,H]=(0,x.useState)(n),[U,W]=(0,x.useState)(i),[ee,K]=(0,x.useState)(o),[te,ne]=(0,x.useState)(c),[re,ie]=(0,x.useState)(u),[ae,oe]=(0,x.useState)(f),[se,ce]=(0,x.useState)(m),[le,ue]=(0,x.useState)(g),[de,fe]=(0,x.useState)(v),[pe,me]=(0,x.useState)(b),[he,ge]=(0,x.useState)(C),[_e,ve]=(0,x.useState)(T),[ye,be]=(0,x.useState)(D),[xe,Se]=(0,x.useState)(k),[Ce,we]=(0,x.useState)(j),[Te,Ee]=(0,x.useState)(N),[De,Oe]=(0,x.useState)(I),[ke,Ae]=(0,x.useState)(z),[je,Me]=(0,x.useState)(!0),[Ne,Pe]=(0,x.useState)(!1),[Fe,Ie]=(0,x.useState)(24),[Le,Re]=(0,x.useState)(!1),[ze,Be]=(0,x.useState)(!1),[Ve,He]=(0,x.useState)(``),[Ue,Ge]=(0,x.useState)(``),[qe,Je]=(0,x.useState)(``),Ye=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(Ye.current&&=(clearTimeout(Ye.current),null),e){if(H(n),W(i),K(o),ne(c),ie(u),oe(f),ce(m),ue(g),fe(v),me(b),ge(C),ve(T),be(D),Se(k),we(j),Ee(N),Oe(I),Ae(z),Be(!1),He(``),Ge(``),Je(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Me(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Ie(e.hours)).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`&&(Ye.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{Ye.current&&=(clearTimeout(Ye.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,z,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 Xe=e=>{e.preventDefault();let n=V.trim(),i=ae!==f;r(n||`~/Documents/GitHub`),a(U),s(ee),l(te),d(re),p(ae),h(se),_(le),y(de),S(pe),w(he),E(_e),O(ye),A(xe),M(Ce),F(Te),R(De),B(ke),t({webglChanged:i})},Ze=(e,t)=>{W(n=>n.map(n=>n.id===e?{...n,...t}:n))},Qe=e=>{let t=U.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=U.filter(t=>t.id!==e);W(n),e===ee&&K(n[0]?.id||`claude`)},$e=()=>{if(!Ve.trim()||!Ue.trim()||U.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Ve.trim(),command:Ue.trim(),isBuiltIn:!1,agentType:qe||void 0};W([...U,e]),Be(!1),He(``),Ge(``),Je(``)},et=U.length<50,tt=e=>{Pe(!0),Me(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).catch(()=>Me(!e)).finally(()=>Pe(!1))},nt=e=>{let t=Fe;Re(!0),Ie(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).catch(()=>Ie(t)).finally(()=>Re(!1))};return(0,q.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,q.jsxs)(`form`,{onSubmit:Xe,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,q.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,q.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,q.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,q.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,q.jsx)(`select`,{value:ee,onChange:e=>K(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:U.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:U.map(e=>(0,q.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(`input`,{value:e.label,onChange:t=>Ze(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>Qe(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,q.jsx)(`input`,{value:e.command,onChange:t=>Ze(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,q.jsxs)(`select`,{value:e.agentType||``,onChange:t=>Ze(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,q.jsx)(`option`,{value:``,children:`Terminal`}),(0,q.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,q.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),ze?(0,q.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,q.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,q.jsx)(`input`,{value:Ve,onChange:e=>He(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,q.jsx)(`input`,{value:Ue,onChange:e=>Ge(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`select`,{value:qe,onChange:e=>Je(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,q.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,q.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,q.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Be(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`button`,onClick:$e,disabled:!Ve.trim()||!Ue.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>Be(!0),disabled:!et,className:`btn text-xs mt-3 w-full`,children:et?`+ Add Preset`:`Max 50 presets`})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`created`?`btn-primary`:``}`,onClick:()=>ne(`created`),children:`Created`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`status`?`btn-primary`:``}`,onClick:()=>ne(`status`),children:`Status`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`manual`?`btn-primary`:``}`,onClick:()=>ne(`manual`),children:`Manual`})]}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:te===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:te===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),te===`created`&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`desc`?`btn-primary`:``}`,onClick:()=>ie(`desc`),children:`Newest First`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`asc`?`btn-primary`:``}`,onClick:()=>ie(`asc`),children:`Oldest First`})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,q.jsx)(Mj,{checked:ye,onCheckedChange:be})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,q.jsx)(Mj,{checked:xe,onCheckedChange:Se})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,q.jsx)(Mj,{checked:Ce,onCheckedChange:we})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,q.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`number`,min:1,max:168,value:Fe,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&nt(t)},disabled:Le,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,q.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>void Wj(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,q.jsx)(Mj,{checked:De,onCheckedChange:e=>{Oe(e),e&&Vj()}})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>void Gj(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,q.jsx)(Mj,{checked:ke,onCheckedChange:e=>{Ae(e),e&&Vj()}})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,q.jsx)(Mj,{checked:ae,onCheckedChange:oe})]}),ae!==f&&(0,q.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,q.jsx)(Mj,{checked:je,onCheckedChange:tt,disabled:Ne})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(Math.max(6,se-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,q.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,q.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:se}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(Math.min(24,se+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,q.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:le,onChange:e=>ue(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,q.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:le.toFixed(1)})]})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:de,onChange:e=>fe(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,q.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[de,`px`]})]})]}),(0,q.jsxs)(`div`,{className:`mt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,q.jsx)(`select`,{value:pe,onChange:e=>me(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),pe===`custom`&&(0,q.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,q.jsx)(Mj,{checked:Te===`dark`,onCheckedChange:e=>Ee(e?`dark`:`light`)})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,q.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,q.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${_e===e?`btn-primary`:``}`,onClick:()=>ve(e),children:e===`auto`?`Auto`:Ke(e)},e))}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:_e===`auto`?`Platform default: ${Ke(We(`auto`))}`:`Shortcuts: ${Ke(_e)}+[N/X/[/]]`})]})]})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var qj=[];function Jj(e){x.useEffect(e,qj)}var Yj=x.createContext(void 0);function Xj(){let e=x.useContext(Yj);if(!e)throw Error(tk(73));return e}var Zj=Symbol(`NOT_FOUND`);function Qj(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function $j(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function eM(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 tM=e=>Array.isArray(e)?e:[e];function nM(e){let t=Array.isArray(e[0])?e[0]:e;return eM(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function rM(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function iM(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Zj},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aM(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 Zj}function i(t,i){r(t)===Zj&&(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 oM=(e,t)=>e===t;function sM(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 cM(e,t){let{equalityCheck:n=oM,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=sM(n),o=0,s=r<=1?iM(a):aM(r,a);function c(){let t=s.get(arguments);if(t===Zj){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 lM=class{constructor(e){this.value=e}deref(){return this.value}},uM=typeof WeakRef<`u`?WeakRef:lM,dM=0,fM=1;function pM(){return{s:dM,v:void 0,o:null,p:null}}function mM(e,t={}){let n=pM(),{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=pM(),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=pM(),e.set(n,t)):t=r}}let s=t,c;if(t.s===fM)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 uM(c):c}return s.s=fM,s.v=c,c}return o.clearCache=()=>{n=pM(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function hM(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()),Qj(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=mM,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=tM(c),p=tM(u),m=nM(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=rM(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 gM=hM(mM),_M=Object.assign((e,t=gM)=>{$j(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:()=>_M}),vM=hM({memoize:cM,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),yM=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(tk(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},bM=(...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(tk(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(tk(2))}u=vM(...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`)}}},xM=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})),SM=s(((e,t)=>{t.exports=xM()})),CM=s((e=>{var t=p(),n=SM();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}})),wM=s(((e,t)=>{t.exports=CM()})),TM=[],EM=void 0;function DM(){return EM}function OM(e){TM.push(e)}var kM=SM(),AM=wM(),jM=rk(19)?PM:FM;function MM(e,t,n,r,i){return jM(e,t,n,r,i)}function NM(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,kM.useSyncExternalStore)(e.subscribe,a,a)}OM({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,kM.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function PM(e,t,n,r,i){let a=DM();if(!a)return NM(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 FM(e,t,n,r,i){return(0,AM.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var IM=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 MM(this,e,t,n,r)}},LM=class extends IM{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),YO(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;YO(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;YO(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;YO(()=>{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),MM(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=BO(t??$O);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)}})}},RM=null;globalThis.requestAnimationFrame;var zM=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)}},BM=class e{static create(){return new e}static request(e){return zM.request(e)}static cancel(e){return zM.cancel(e)}currentId=RM;request(e){this.cancel(),this.currentId=zM.request(()=>{this.currentId=RM,e()})}cancel=()=>{this.currentId!==RM&&(zM.cancel(this.currentId),this.currentId=RM)};disposeEffect=()=>this.cancel};function VM(){let e=LO(BM.create).current;return Jj(e.disposeEffect),e}var HM=0,UM=class e{static create(){return new e}currentId=HM;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=HM,t()},e)}isStarted(){return this.currentId!==HM}clear=()=>{this.currentId!==HM&&(clearTimeout(this.currentId),this.currentId=HM)};disposeEffect=()=>this.clear};function WM(){let e=LO(UM.create).current;return Jj(e.disposeEffect),e}var GM=0;function KM(e){return GM+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${GM}`}function qM(e){return e?.ownerDocument||document}function JM(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 YM=typeof navigator<`u`,XM=tN(),ZM=rN(),QM=nN();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),XM.platform===`MacIntel`&&XM.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(XM.platform),YM&&/firefox/i.test(QM);var $M=YM&&/apple/i.test(navigator.vendor);YM&&/Edg/i.test(QM),YM&&/android/i.test(ZM)||/android/i.test(QM),YM&&ZM.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var eN=QM.includes(`jsdom/`);function tN(){if(!YM)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 nN(){if(!YM)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function rN(){if(!YM)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function iN(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function aN(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Ik(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function oN(e){return`composedPath`in e?e.composedPath()[0]:e.target}function sN(e){if(!e||eN)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var cN=bM(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}),lN={toasts:yM(e=>e.toasts),isEmpty:yM(e=>e.toasts.length===0),toast:yM(cN,(e,t)=>e.get(t)?.value),toastIndex:yM(cN,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:yM(cN,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:yM(cN,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:yM(e=>e.hovering),focused:yM(e=>e.focused),expanded:yM(e=>e.hovering||e.focused),expandedOrOutOfFocus:yM(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:yM(e=>e.prevFocusElement)},uN=class extends LM{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},lN)}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=lN.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||KM(`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)),lN.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=lN.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)),lN.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{lN.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=JM(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=JM(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=JM(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??=UM.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=oN(e);aN(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!lN.expandedOrOutOfFocus(this.state),a=i?UM.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=iN(qM(this.state.viewport));if(!this.state.viewport||!aN(this.state.viewport,t)||!sN(t))return;let n=lN.toasts(this.state),r=lN.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()}},dN=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=LO(()=>new uN({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Jj(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,q.jsx)(Yj.Provider,{value:a,children:t})},fN=x.forwardRef(function(e,t){let[n,r]=x.useState();YO(()=>{$M&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,q.jsx)(`span`,{...e,ref:t,style:ZO,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),pN=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),mN=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=Xj(),s=WM(),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(iN(qM(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=Nk(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=Nk(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=oN(n),i=iN(qM(e));(!aN(e,r)||!sN(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=qM(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||sN(qM(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||aN(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=xk(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[pN.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,q.jsxs)(x.Fragment,{children:[!u&&m&&(0,q.jsx)(fN,{onFocus:_}),i,!u&&m&&(0,q.jsx)(fN,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,q.jsxs)(x.Fragment,{children:[!u&&m&&(0,q.jsx)(fN,{onFocus:_}),E,!f&&D.length>0&&(0,q.jsx)(`div`,{style:ZO,children:D.map(e=>(0,q.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,q.jsx)(`div`,{children:e.title}),(0,q.jsx)(`div`,{children:e.description})]},e.id))})]})});function hN(e){return rk(19)?e:e?`true`:void 0}var gN=x.createContext(void 0);function _N(){let e=x.useContext(gN);if(!e)throw Error(tk(66));return e}var vN=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),yN={[vN.startingStyle]:``},bN={[vN.endingStyle]:``},xN={transitionStatus(e){return e===`starting`?yN:e===`ending`?bN:null}};function SN(e){return e==null?e:`current`in e?e.current:e}function CN(e,t=!1,n=!0){let r=VM();return BO((i,a=null)=>{r.cancel();function o(){K.flushSync(i)}let s=SN(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=vN.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 wN(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=BO(i),o=CN(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var TN=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}({}),EN={...xN,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},DN=40,ON=10,kN=.5,AN=1;function jN(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 MN(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 NN=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=Xj(),[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),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),V=u.useState(`focused`),H=u.useState(`expanded`);wN({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let U=BO((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?K.flushSync(a):a()});YO(U,[U]);function W(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**kN:-(Math.abs(e)**kN):(!c.includes(`right`)&&e>0&&(n=e**kN),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**kN))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**kN:-(Math.abs(t)**kN):(!c.includes(`down`)&&t>0&&(r=t**kN),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**kN))),{x:n,y:r}}function G(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=oN(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=MN(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 ee(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)>=AN&&(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=jN(u,a,o),f(u));else{let e=N.current,t=jN(e,l,s);t>DN?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=ON&&(F.current=!0)}let d=W(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 te(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>DN&&(t=!0,a=`right`);break;case`left`:r<-DN&&(t=!0,a=`left`);break;case`down`:i>DN&&(t=!0,a=`down`);break;case`up`:i<-DN&&(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 ne(e){if(e.key===`Escape`){if(!A.current||!aN(A.current,iN(qM(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){aN(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function re(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[TN.swipeMovementX]:`0px`,[TN.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,[TN.swipeMovementX]:`${e}px`,[TN.swipeMovementY]:`${t}px`}}let ie=n.priority===`high`,ae={role:ie?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":ie&&!V?!0:void 0,onPointerDown:l?G:void 0,onPointerMove:l?ee:void 0,onPointerUp:l?te:void 0,onKeyDown:ne,inert:hN(n.limited),style:{...re(),[TN.index]:n.transitionStatus===`ending`?R:z,[TN.offsetY]:`${B}px`,[TN.height]:n.height?`${n.height}px`:void 0}},oe=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:U,index:R,visibleIndex:z,expanded:H}),[n,w,E,p,d,U,R,z,H]),se={transitionStatus:n.transitionStatus,expanded:H,limited:n.limited||!1,type:n.type,swiping:oe.swiping,swipeDirection:oe.swipeDirection},ce=xk(`div`,e,{ref:[t,oe.rootRef],state:se,stateAttributesMapping:EN,props:[ae,o]});return(0,q.jsx)(gN.Provider,{value:oe,children:ce})}),PN=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=_N(),l=a??s.description,u=!!l,d=Ak(i);YO(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=xk(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),FN=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=_N(),l=a??s.title,u=!!l,d=Ak(i);YO(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=xk(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),IN=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=Xj(),{toast:c}=_N(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=Bk({disabled:i,native:a}),m={type:c.type};return xk(`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 LN(){let e=x.useContext(Yj);if(!e)throw Error(tk(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 RN(){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||KM(`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 zN=5e3,BN=RN();function VN({toast:e}){return(0,q.jsxs)(NN,{toast:e,className:jj(`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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(FN,{className:jj(`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,q.jsx)(PN,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,q.jsx)(IN,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,q.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,q.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,q.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function HN(){let{toasts:e}=LN();return(0,q.jsx)(q.Fragment,{children:e.map(e=>(0,q.jsx)(VN,{toast:e},e.id))})}function UN(){return(0,q.jsxs)(dN,{timeout:zN,toastManager:BN,children:[(0,q.jsx)(HN,{}),(0,q.jsx)(mN,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var WN=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],GN=3e3,KN=8e3,qN=15e3,JN=5e3,YN=2e4,XN=1e4,ZN=1500,QN=5e3,$N=750,eP=4,tP=5e3,nP=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(Z(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,Z(`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=>{Z(`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?WN[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`){Z(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){Z(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}Z(`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`;Z(`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?KN:GN;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(Z(`ws_connect_timeout`,{wsState:WN[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){Z(`ws_onopen_stale`,this.wsSnap(),`info`);return}Z(`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(),Z(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(QN)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(Z(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){Z(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}Z(`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>qN&&(Z(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},JN))}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 Z(`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(Z(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){Z(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(Z(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},ZN)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){Z(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){Z(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){Z(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,Z(`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()},$N)):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,Z(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},XN)))};e!==void 0&&e<YN?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,YN)},e):this.heartbeatTimer=window.setInterval(t,YN)}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()){Z(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=eP){Z(`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()},tP);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Z(`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){Z(`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 rP(){let e=Wm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{nP.connect(),nP.startLifecycleListeners();let t=nP.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),nP.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{nP.send(e)},[]),subscribe:(0,x.useMemo)(()=>nP.subscribe.bind(nP),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>nP.getConnectionEpoch(),[])}}var iP=100;function aP({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>iP?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function oP(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 sP(){(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=()=>{aP({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(),oP(document)}},[])}function cP(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 lP(){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=Wm(e=>e.sessions),_=Wm(e=>e.agentSessions),v=Wm(e=>e.agentSessionsEpoch),y=Wm(e=>e.selectedSessionId),b=Wm(e=>e.selectedHibernatingSessionId),S=Wm(e=>e.setSessions),C=Wm(e=>e.setAgentSessions),w=Wm(e=>e.setActiveAgentSessions),T=Wm(e=>e.setHostStatuses),E=Wm(e=>e.updateSession),D=Wm(e=>e.setSelectedSessionId),O=Wm(e=>e.setSelectedHibernatingSessionId),k=Wm(e=>e.hasLoaded),A=Wm(e=>e.connectionStatus),j=Wm(e=>e.connectionError),M=Wm(e=>e.clearExitingSession),N=Wm(e=>e.markSessionExiting),P=Wm(e=>e.setRemoteAllowControl),F=Wm(e=>e.setRemoteAllowAttach),I=Wm(e=>e.setHostLabel),L=Wm(e=>e.setPreferWindowName),R=Wm(e=>e.hostStatuses),z=Wm(e=>e.remoteAllowControl),B=Wm(e=>e.hostLabel),V=GD(e=>e.theme),H=ee(),U=G(e=>e.defaultProjectDir),W=G(e=>e.commandPresets),te=G(e=>e.defaultPresetId),ne=G(e=>e.lastProjectPath),re=G(e=>e.setLastProjectPath),ie=G(e=>e.addRecentPath),ae=G(e=>e.shortcutModifier),oe=G(e=>e.sidebarWidth),se=G(e=>e.setSidebarWidth),ce=G(e=>e.projectFilters),le=G(e=>e.hostFilters),ue=G(e=>e.soundOnPermission),de=G(e=>e.soundOnIdle),fe=Wm(e=>e.connectionEpoch),{sendMessage:pe,subscribe:me,getConnectionEpoch:he}=rP();sP(),(0,x.useEffect)(()=>{if(typeof document>`u`||!ue&&!de)return;let e=!1,t=()=>{e&&!zj()||(e=!0,Vj())};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)}},[ue,de]);let ge=(0,x.useRef)(!1),_e=(0,x.useCallback)(e=>{e.preventDefault(),ge.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(!ge.current)return;let t=e.clientX;se(Math.max(180,Math.min(400,t)))},t=()=>{ge.current&&(ge.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)}},[se]),(0,x.useEffect)(()=>{let e=me(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Wm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=G.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&&Wj(),e.status===`working`&&i.status===`waiting`&&r&&Gj())}if(Ne.current.size>0){let e=he();for(let[t,n]of Ne.current)n.epoch!==e&&Ne.current.delete(t)}let i=Ne.current.size>0?e.sessions.filter(e=>!Ne.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Wm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(ke.current=s),S(i);let c=Ae.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Wm.getState(),{projectFilters:d,hostFilters:f}=G.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&&(Ae.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&&YT(e.clientLogLevel)),e.type===`session-update`){let t=Wm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=G.getState();t!==`permission`&&n===`permission`&&e&&Wj(),t===`working`&&n===`waiting`&&r&&Gj()}}if(e.type===`session-created`){let t=Wm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),ie(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=G.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){yD(e.sessionId);let t=Wm.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}=Wm.getState(),a=ke.current;i&&!n.some(e=>e.sessionId===i)&&(Ae.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)?(ke.current=null,O(a)):a&&(ke.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Wm.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=Wm.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=Wm.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=Ne.current.get(e.sessionId);if(t){let n=Wm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ne.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,ie,M,pe,D,O,h,S,C,w,T,P,F,I,L,me,E]);let ve=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),ye=_.hibernating??[],be=_.history??[],xe=(0,x.useMemo)(()=>cP(ye,ce,le),[ye,ce,le]),Se=(0,x.useMemo)(()=>xe.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[xe,m,b]);(0,x.useEffect)(()=>{ve?.projectPath&&!ve.remote&&re(ve.projectPath)},[ve?.projectPath,ve?.remote,re]);let Ce=G(e=>e.sessionSortMode),we=G(e=>e.sessionSortDirection),Te=G(e=>e.manualSessionOrder),Ee=(0,x.useMemo)(()=>km(g,{mode:Ce,direction:we,manualOrder:Te}),[g,Ce,we,Te]),De=(0,x.useMemo)(()=>{let e=Ee;return ce.length>0&&(e=e.filter(e=>ce.includes(e.projectPath))),le.length>0&&(e=e.filter(e=>le.includes(e.host??``))),e},[Ee,ce,le]),Oe=(0,x.useRef)(b),ke=(0,x.useRef)(null),Ae=(0,x.useRef)(null),je=(0,x.useRef)(fe),Me=(0,x.useCallback)(()=>De.length>0?(D(De[0].id),!0):xe.length>0?(O(xe[0].sessionId),!0):!1,[De,xe,D,O]);(0,x.useEffect)(()=>{let e=Oe.current;e&&b===null&&!ye.some(t=>t.sessionId===e)?Ae.current=e:b!==null&&(Ae.current=null),Oe.current=b},[ye,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{je.current!==fe&&(je.current=fe,ke.current=null,Ae.current=null,h(null))},[fe]),(0,x.useEffect)(()=>{k&&(b||y&&(De.some(e=>e.id===y)||Me()||D(null)))},[k,y,b,Me,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==fe||xe.some(e=>e.sessionId===b))return;let e=De.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Me()||O(null)},[xe,De,v,m,b,Me,D,O,fe]),(0,x.useEffect)(()=>{let e=Ae.current;if(!e)return;if(b!==null){Ae.current=null;return}let t=De.find(t=>t.agentSessionId?.trim()===e);if(t){Ae.current=null,D(t.id);return}if(y!==null){Ae.current=null;return}Me()&&(Ae.current=null)},[De,y,b,Me,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(De.length>0||xe.length>0)&&Me()},[xe.length,De.length,k,Me,y,b]);let Ne=(0,x.useRef)(new Map),Pe=(0,x.useCallback)((e,t=`unknown`)=>{yD(e);let{sessions:n,selectedSessionId:r}=Wm.getState(),i=n.find(t=>t.id===e);i&&Ne.current.set(e,{session:i,wasSelected:r===e,epoch:he()}),(0,K.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),pe({type:`session-kill`,sessionId:e,source:t})},[N,S,pe]);(0,x.useEffect)(()=>{let n=We(ae),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=qe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=De;if(t.length===0){let t=xe;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&&H&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Pe(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,De,xe,Pe,ae,H]);let Fe=()=>H?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Ie=()=>l(!0),Le=(e,t,n,r)=>{pe({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||re(e)},Re=e=>{pe({type:`session-wake`,sessionId:e})},ze=(0,x.useCallback)(e=>{pe({type:`session-hibernate`,sessionId:e})},[pe]),Be=(e,t)=>{pe({type:`session-rename`,sessionId:e,newName:t})},Ve=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&pe({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,pe]),He=(0,x.useCallback)(e=>{pe({type:`session-move-to-history`,sessionId:e})},[pe]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,V)},[V]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ue=(0,x.useMemo)(()=>B?R.filter(e=>e.host!==B):R,[R,B]);return(0,q.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:oe},children:[(0,q.jsx)(Xe,{connectionStatus:A,onNewSession:Fe,onOpenSettings:Ie,tailscaleIp:f?.tailscaleIp??null}),(0,q.jsx)(WT,{sessions:g,hibernatingSessions:ye,historySessions:be,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Be,onResume:Re,onHibernate:ze,onKill:Pe,onDuplicate:Ve,onMoveToHistory:He,onNewSession:Fe,loading:!k,error:j||u})]}),(0,q.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:_e}),(0,q.jsx)(MO,{session:ve,sessions:De,hibernatingSession:Se,hibernatingSessions:ye,connectionStatus:A,connectionEpoch:fe,sendMessage:pe,subscribe:me,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Fe,onKillSession:Pe,onRenameSession:Be,onOpenSettings:Ie,onResumeSession:Re,onHibernateSession:ze,onMoveToHistory:He,historySessions:be,loading:!k,error:j||u}),(0,q.jsx)(PO,{isOpen:e,onClose:()=>t(!1),onCreate:Le,defaultProjectDir:U,commandPresets:W,defaultPresetId:te,lastProjectPath:ne,activeProjectPath:ve&&!ve.remote?ve.projectPath:void 0,remoteHosts:Ue,remoteAllowControl:z,initialHost:n,initialPath:i,initialCommand:o}),(0,q.jsx)(Kj,{isOpen:c,onClose:()=>l(!1)}),(0,q.jsx)(UN,{})]})}var uP=`modulepreload`,dP=function(e){return`/`+e},fP={},pP=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=dP(t,n),t in fP)return;fP[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`:uP,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)})},mP=`true`,hP=`false`,gP=mP===`true`,_P=hP===`true`;function vP(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,gP||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await pP(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()},!_P)if(gP)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}Ve()&&document.documentElement.classList.add(`ios`),He()&&document.documentElement.classList.add(`ios-pwa`),vP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var yP=document.getElementById(`root`);if(!yP)throw Error(`Root element not found`);(0,E.createRoot)(yP).render((0,q.jsx)(x.StrictMode,{children:(0,q.jsx)(lP,{})}));
228
+ ${r?IO[t.status]:FO[t.status]}
229
+ `,onClick:()=>{LO(),u(t.id)},title:Qe?t.name:void 0,children:i},t.id)})})]}),(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(`div`,{ref:ye,className:`absolute inset-0`}),Ee&&e&&(0,q.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,q.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,q.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,q.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),De&&e&&(0,q.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,q.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,q.jsxs)(`button`,{type:`button`,onClick:Oe,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,q.jsx)(ce,{width:14,height:14}),`Copy`]}),(0,q.jsx)(`button`,{type:`button`,onClick:ke,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,q.jsx)(Be,{width:14,height:14})})]}),!e&&(0,q.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&&de&&(0,q.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,q.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,q.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,q.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,q.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:he}),(0,q.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`}),ge&&(0,q.jsx)(`span`,{className:`text-muted`,children:ge}),(0,q.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,_e]})]}),n.lastResumeError&&(0,q.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,q.jsx)(ne,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,q.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,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,q.jsx)(zT,{session:n})]})}),j&&e&&!N&&(0,q.jsxs)(`button`,{onClick:je,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,q.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,q.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,q.jsx)(jO,{onSendKey:Je,disabled:a!==`connected`||de,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:Ye,isKeyboardVisible:Ze,onEnterTextMode:Xe}),(A||k)&&(0,q.jsx)(MO,{isOpen:B,onClose:()=>V(!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,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,q.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,q.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,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,q.jsx)(`button`,{ref:ae,onClick:Fe,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function zO({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=G(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,q.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,q.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,q.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,q.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,q.jsx)(`p`,{className:`text-danger`,children:s}),(0,q.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,q.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,q.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,q.jsx)(ve,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,q.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,q.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,q.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,q.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,q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function BO({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=>H(e)===t);e?(v(e.id),b(H(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(H(e))):i.length>0?(v(i[0].id),b(H(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(H(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,q.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,q.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,q.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,q.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,q.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,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,q.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,q.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,q.jsx)(Zm,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,q.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.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,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,q.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,q.jsx)(zO,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function VO({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 HO={};function UO(e,t){let n=x.useRef(HO);return n.current===HO&&(n.current=e(t)),n}var WO=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],GO=WO&&WO!==x.useLayoutEffect?WO:e=>e();function KO(e){let t=UO(qO).current;return t.next=e,GO(t.effect),t.trampoline}function qO(){let e={next:void 0,callback:JO,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function JO(){}function YO(e,t,n,r){let i=UO(ZO).current;return QO(i,e,t,n,r)&&ek(i,[e,t,n,r]),i.callback}function XO(e){let t=UO(ZO).current;return $O(t,e)&&ek(t,e),t.callback}function ZO(){return{callback:null,cleanup:null,refs:[]}}function QO(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function $O(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function ek(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 tk=typeof document<`u`?x.useLayoutEffect:()=>{},nk={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},rk={...nk,position:`fixed`,top:0,left:0},ik={...nk,position:`absolute`};function ak(){}Object.freeze([]);var ok=Object.freeze({});function sk(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 ck=18;function lk(e){return ck>=e}function uk(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(lk(19)?n?.ref:t.ref)??null}function dk(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function fk(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 pk(e,t){return typeof e==`function`?e(t):e}function mk(e,t){return typeof e==`function`?e(t):e}var hk={};function gk(e,t,n,r,i){let a={...Sk(e,hk)};return t&&(a=vk(a,t)),n&&(a=vk(a,n)),r&&(a=vk(a,r)),i&&(a=vk(a,i)),a}function _k(e){if(e.length===0)return hk;if(e.length===1)return Sk(e[0],hk);let t={...Sk(e[0],hk)};for(let n=1;n<e.length;n+=1)t=vk(t,e[n]);return t}function vk(e,t){return xk(t)?t(e):yk(e,t)}function yk(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=dk(e.style,r);break;case`className`:e[n]=Tk(e.className,r);break;default:bk(n,r)?e[n]=Ck(e[n],r):e[n]=r}}return e}function bk(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 xk(e){return typeof e==`function`}function Sk(e,t){return xk(e)?e(t):e??hk}function Ck(e,t){return t?e?n=>{if(Ek(n)){let r=n;wk(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function wk(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Tk(e,t){return t?e?t+` `+e:t:e}function Ek(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Dk(e,t,n={}){let r=t.render,i=Ok(t,n);return n.enabled===!1?null:Ak(e,r,i,n.state??ok)}function Ok(e,t={}){let{className:n,style:r,render:i}=e,{state:a=ok,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?pk(n,a):void 0,d=l?mk(r,a):void 0,f=l?fk(a,c):ok,p=l?dk(f,Array.isArray(s)?_k(s):s)??ok:ok;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=XO([p.ref,uk(i),...o]):p.ref=YO(p.ref,uk(i),o):YO(null,null)),l?(u!==void 0&&(p.className=Tk(p.className,u)),d!==void 0&&(p.style=dk(p.style,d)),p):ok}var kk=Symbol.for(`react.lazy`);function Ak(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=gk(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===kk&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return jk(e,n);throw Error(sk(8))}function jk(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 Mk={...x},Nk=0;function Pk(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(Nk+=1,r(`${t}-${Nk}`))},[n,t]),i}var Fk=Mk.useId;function Ik(e,t){if(Fk!==void 0){let n=Fk();return e??(t?`${t}-${n}`:n)}return Pk(e,t)}function Lk(e){return Ik(e,`base-ui`)}function Rk(){return typeof window<`u`}function zk(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bk(e){return Rk()?e instanceof Element||e instanceof zk(e).Element:!1}function Vk(e){return Rk()?e instanceof HTMLElement||e instanceof zk(e).HTMLElement:!1}function Hk(e){return!Rk()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof zk(e).ShadowRoot}var Uk=x.createContext(void 0);function Wk(e=!1){let t=x.useContext(Uk);if(t===void 0&&!e)throw Error(sk(16));return t}function Gk(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 Kk(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=Wk(!0)!==void 0,s=KO(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=Gk({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;qk(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return tk(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return gk({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(wk(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||(wk(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:KO(e=>{a.current=e,l()})}}function qk(e){return Vk(e)&&e.tagName===`BUTTON`}var Jk=x.createContext(void 0);function Yk(){let e=x.useContext(Jk);if(e===void 0)throw Error(sk(63));return e}var Xk=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}({}),Zk={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Qk={valid(e){return e===null?null:e?{[Xk.valid]:``}:{[Xk.invalid]:``}}},$k=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}({}),eA={...Qk,checked(e){return e?{[$k.checked]:``}:{[$k.unchecked]:``}}};function tA(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var nA=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ak,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function rA(){return x.useContext(nA)}var iA=x.createContext({invalid:void 0,name:void 0,validityData:{state:Zk,errors:[],error:``,value:``,initialValue:null},setValidityData:ak,disabled:void 0,touched:!1,setTouched:ak,dirty:!1,setDirty:ak,filled:!1,setFilled:ak,focused:!1,setFocused:ak,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=ok)=>e,getInputValidationProps:(e=ok)=>e,inputRef:{current:null},commit:async()=>{}}});function aA(e=!0){let t=x.useContext(iA);if(t.setValidityData===ak&&!e)throw Error(sk(28));return t}function oA(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=rA(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=aA(),f=KO(e.getValue);tk(()=>{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]),tk(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:tA(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?K.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),tk(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var sA=x.createContext({controlId:void 0,registerControlId:ak,labelId:void 0,setLabelId:ak,messageIds:[],setMessageIds:ak,getDescriptionProps:e=>e});function cA(){return x.useContext(sA)}function lA(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=cA(),o=Lk(t),s=n?i:void 0,c=UO(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=KO(()=>{!l.current||a===ak||(l.current=!1,a(c.current,void 0))});return tk(()=>{if(a===ak)return;let e;if(n){let n=r?.current;e=Bk(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 uA=`none`;function dA(e,t,n,r){let i=!1,a=!1,o=r??ok;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 fA(e,t){let n=x.useRef(e),r=KO(t);tk(()=>{n.current!==e&&r(n.current)},[e,r]),tk(()=>{n.current=e},[e])}var pA=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:_}=rA(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=aA(),{labelId:A}=cA(),j=D||f,M=O??s,N=KO(l),P=x.useRef(null),F=YO(P,o,k.inputRef),I=x.useRef(null),L=Lk(),R=lA({id:a,implicit:!1,controlRef:I}),z=c?void 0:R,[B,V]=VO({controlled:n,default:!!i,name:`Switch`,state:`checked`});oA({id:L,commit:k.commit,value:B,controlRef:I,name:M,getValue:()=>B}),tk(()=>{P.current&&C(P.current.checked)},[P,C]),fA(B,()=>{_(M),b(B!==S.initialValue),C(B),T()?k.commit(B):k.commit(B,!0)});let{getButtonProps:H,buttonRef:U}=Kk({disabled:j,native:c}),W={id:c?R:L,role:`switch`,"aria-checked":B,"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})))}},G=x.useMemo(()=>gk({checked:B,disabled:j,id:z,name:M,required:d,style:M?ik:rk,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=dA(uA,e.nativeEvent);N?.(t,n),!n.isCanceled&&V(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?ok:{value:h}),[B,j,F,z,M,N,d,V,k,h]),ee=x.useMemo(()=>({...v,checked:B,disabled:j,readOnly:u,required:d}),[v,B,j,u,d]),K=Dk(`span`,e,{state:ee,ref:[t,I,U],props:[W,k.getValidationProps,g,H],stateAttributesMapping:eA});return(0,q.jsxs)(Jk.Provider,{value:ee,children:[K,!B&&M&&m!==void 0&&(0,q.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,q.jsx)(`input`,{...G})]})}),mA=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=aA(),o=Yk();return Dk(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:eA,props:i})});function hA(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=hA(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function gA(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=hA(e))&&(r&&(r+=` `),r+=t);return r}var _A=(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},vA=(e,t)=>({classGroupId:e,validator:t}),yA=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),bA=`-`,xA=[],SA=`arbitrary..`,CA=e=>{let t=EA(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return TA(e);let n=e.split(bA);return wA(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?_A(i,t):t:i||xA}return n[e]||xA}}},wA=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=wA(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(bA):e.slice(t).join(bA),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},TA=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?SA+r:void 0})(),EA=e=>{let{theme:t,classGroups:n}=e;return DA(n,t)},DA=(e,t)=>{let n=yA();for(let r in e){let i=e[r];OA(i,n,r,t)}return n},OA=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];kA(i,t,n,r)}},kA=(e,t,n,r)=>{if(typeof e==`string`){AA(e,t,n);return}if(typeof e==`function`){jA(e,t,n,r);return}MA(e,t,n,r)},AA=(e,t,n)=>{let r=e===``?t:NA(t,e);r.classGroupId=n},jA=(e,t,n,r)=>{if(PA(e)){OA(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(vA(n,e))},MA=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];OA(o,NA(t,a),n,r)}},NA=(e,t)=>{let n=e,r=t.split(bA),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=yA(),n.nextPart.set(t,i)),n=i}return n},PA=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,FA=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)}}},IA=`!`,LA=`:`,RA=[],zA=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),BA=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===LA){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(IA)?(c=s.slice(0,-1),l=!0):s.startsWith(IA)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return zA(t,l,c,u)};if(t){let e=t+LA,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):zA(RA,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},VA=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}},HA=e=>({cache:FA(e.cacheSize),parseClassName:BA(e),sortModifiers:VA(e),...CA(e)}),UA=/\s+/,WA=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(UA),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+IA: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},GA=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=KA(n))&&(i&&(i+=` `),i+=r);return i},KA=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=KA(e[r]))&&(n&&(n+=` `),n+=t);return n},qA=(e,...t)=>{let n,r,i,a,o=o=>(n=HA(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=WA(e,n);return i(e,a),a};return a=o,(...e)=>a(GA(...e))},JA=[],YA=e=>{let t=t=>t[e]||JA;return t.isThemeGetter=!0,t},XA=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ZA=/^\((?:(\w[\w-]*):)?(.+)\)$/i,QA=/^\d+\/\d+$/,$A=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ej=/\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$/,tj=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nj=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rj=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ij=e=>QA.test(e),aj=e=>!!e&&!Number.isNaN(Number(e)),oj=e=>!!e&&Number.isInteger(Number(e)),sj=e=>e.endsWith(`%`)&&aj(e.slice(0,-1)),cj=e=>$A.test(e),lj=()=>!0,uj=e=>ej.test(e)&&!tj.test(e),dj=()=>!1,fj=e=>nj.test(e),pj=e=>rj.test(e),mj=e=>!Q(e)&&!$(e),hj=e=>Dj(e,jj,dj),Q=e=>XA.test(e),gj=e=>Dj(e,Mj,uj),_j=e=>Dj(e,Nj,aj),vj=e=>Dj(e,kj,dj),yj=e=>Dj(e,Aj,pj),bj=e=>Dj(e,Fj,fj),$=e=>ZA.test(e),xj=e=>Oj(e,Mj),Sj=e=>Oj(e,Pj),Cj=e=>Oj(e,kj),wj=e=>Oj(e,jj),Tj=e=>Oj(e,Aj),Ej=e=>Oj(e,Fj,!0),Dj=(e,t,n)=>{let r=XA.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Oj=(e,t,n=!1)=>{let r=ZA.exec(e);return r?r[1]?t(r[1]):n:!1},kj=e=>e===`position`||e===`percentage`,Aj=e=>e===`image`||e===`url`,jj=e=>e===`length`||e===`size`||e===`bg-size`,Mj=e=>e===`length`,Nj=e=>e===`number`,Pj=e=>e===`family-name`,Fj=e=>e===`shadow`,Ij=qA(()=>{let e=YA(`color`),t=YA(`font`),n=YA(`text`),r=YA(`font-weight`),i=YA(`tracking`),a=YA(`leading`),o=YA(`breakpoint`),s=YA(`container`),c=YA(`spacing`),l=YA(`radius`),u=YA(`shadow`),d=YA(`inset-shadow`),f=YA(`text-shadow`),p=YA(`drop-shadow`),m=YA(`blur`),h=YA(`perspective`),g=YA(`aspect`),_=YA(`ease`),v=YA(`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=()=>[ij,`full`,`auto`,...w()],E=()=>[oj,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,oj,$,Q]},oj,$,Q],O=()=>[oj,`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=()=>[ij,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),Cj,vj,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,wj,hj,{size:[$,Q]}],R=()=>[sj,xj,gj],z=()=>[``,`none`,`full`,l,$,Q],B=()=>[``,aj,xj,gj],V=()=>[`solid`,`dashed`,`dotted`,`double`],H=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],U=()=>[aj,sj,Cj,vj],W=()=>[``,`none`,m,$,Q],G=()=>[`none`,aj,$,Q],ee=()=>[`none`,aj,$,Q],K=()=>[aj,$,Q],te=()=>[ij,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[cj],breakpoint:[cj],color:[lj],container:[cj],"drop-shadow":[cj],ease:[`in`,`out`,`in-out`],font:[mj],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[cj],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[cj],shadow:[cj],spacing:[`px`,aj],text:[cj],"text-shadow":[cj],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ij,Q,$,g]}],container:[`container`],columns:[{columns:[aj,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:[oj,`auto`,$,Q]}],basis:[{basis:[ij,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[aj,ij,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,aj,$,Q]}],shrink:[{shrink:[``,aj,$,Q]}],order:[{order:[oj,`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,xj,gj]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,_j]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,sj,Q]}],"font-family":[{font:[Sj,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":[aj,`none`,$,_j]}],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:[...V(),`wavy`]}],"text-decoration-thickness":[{decoration:[aj,`from-font`,`auto`,$,gj]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[aj,`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`]},oj,$,Q],radial:[``,$,Q],conic:[oj,$,Q]},Tj,yj]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":B()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...V(),`hidden`,`none`]}],"divide-style":[{divide:[...V(),`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:[...V(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[aj,$,Q]}],"outline-w":[{outline:[``,aj,xj,gj]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,Ej,bj]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,Ej,bj]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:B()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[aj,gj]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,Ej,bj]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[aj,$,Q]}],"mix-blend":[{"mix-blend":[...H(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":H()}],"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":[aj]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"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":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"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":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"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":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"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":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"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":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"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":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"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":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"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":[aj]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"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:W()}],brightness:[{brightness:[aj,$,Q]}],contrast:[{contrast:[aj,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Ej,bj]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,aj,$,Q]}],"hue-rotate":[{"hue-rotate":[aj,$,Q]}],invert:[{invert:[``,aj,$,Q]}],saturate:[{saturate:[aj,$,Q]}],sepia:[{sepia:[``,aj,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":W()}],"backdrop-brightness":[{"backdrop-brightness":[aj,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[aj,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,aj,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[aj,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,aj,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[aj,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[aj,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,aj,$,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:[aj,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[aj,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":[`scale-3d`],skew:[{skew:K()}],"skew-x":[{"skew-x":K()}],"skew-y":[{"skew-y":K()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"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:[aj,xj,gj,_j]}],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 Lj(...e){return Ij(gA(e))}function Rj({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,q.jsx)(pA,{checked:e,onCheckedChange:t,disabled:n,className:Lj(`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,q.jsx)(mA,{className:Lj(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var zj=null,Bj=!1,Vj={},Hj=500;function Uj(){if(typeof window>`u`)return null;if(zj?.state===`closed`&&(zj=null),!zj){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;zj=new e}return zj}function Wj(){zj&&=(zj.close().catch(()=>{}),null),Uj()}function Gj(){return Bj}function Kj(){zj&&(Wj(),Bj=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&Kj()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Kj()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&Kj(),e=t},5e3)}async function qj(){let e=Uj();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),Bj=!1}async function Jj(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function Yj(e){let t=Uj();if(!t||(await Jj(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 Xj(){let e=Date.now();if(!(e-(Vj.permission||0)<Hj)){Vj.permission=e;try{await Yj({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function Zj(){let e=Date.now();if(!(e-(Vj.idle||0)<Hj)){Vj.idle=e;try{await Yj({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function Qj({isOpen:e,onClose:t}){let n=G(e=>e.defaultProjectDir),r=G(e=>e.setDefaultProjectDir),i=G(e=>e.commandPresets),a=G(e=>e.setCommandPresets),o=G(e=>e.defaultPresetId),s=G(e=>e.setDefaultPresetId),c=G(e=>e.sessionSortMode),l=G(e=>e.setSessionSortMode),u=G(e=>e.sessionSortDirection),d=G(e=>e.setSessionSortDirection),f=G(e=>e.useWebGL),p=G(e=>e.setUseWebGL),m=G(e=>e.fontSize),h=G(e=>e.setFontSize),g=G(e=>e.lineHeight),_=G(e=>e.setLineHeight),v=G(e=>e.letterSpacing),y=G(e=>e.setLetterSpacing),b=G(e=>e.fontOption),S=G(e=>e.setFontOption),C=G(e=>e.customFontFamily),w=G(e=>e.setCustomFontFamily),T=G(e=>e.shortcutModifier),E=G(e=>e.setShortcutModifier),D=G(e=>e.showProjectName),O=G(e=>e.setShowProjectName),k=G(e=>e.showLastUserMessage),A=G(e=>e.setShowLastUserMessage),j=G(e=>e.showSessionIdPrefix),M=G(e=>e.setShowSessionIdPrefix),N=ZD(e=>e.theme),F=ZD(e=>e.setTheme),I=G(e=>e.soundOnPermission),R=G(e=>e.setSoundOnPermission),z=G(e=>e.soundOnIdle),B=G(e=>e.setSoundOnIdle),[V,H]=(0,x.useState)(n),[U,W]=(0,x.useState)(i),[ee,K]=(0,x.useState)(o),[te,ne]=(0,x.useState)(c),[re,ie]=(0,x.useState)(u),[ae,oe]=(0,x.useState)(f),[se,ce]=(0,x.useState)(m),[le,ue]=(0,x.useState)(g),[de,fe]=(0,x.useState)(v),[pe,me]=(0,x.useState)(b),[he,ge]=(0,x.useState)(C),[_e,ve]=(0,x.useState)(T),[ye,be]=(0,x.useState)(D),[xe,Se]=(0,x.useState)(k),[Ce,we]=(0,x.useState)(j),[Te,Ee]=(0,x.useState)(N),[De,Oe]=(0,x.useState)(I),[ke,Ae]=(0,x.useState)(z),[je,Me]=(0,x.useState)(!0),[Ne,Pe]=(0,x.useState)(!1),[Fe,Ie]=(0,x.useState)(24),[Le,Re]=(0,x.useState)(!1),[ze,Be]=(0,x.useState)(!1),[Ve,He]=(0,x.useState)(``),[Ue,Ge]=(0,x.useState)(``),[qe,Je]=(0,x.useState)(``),Ye=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(Ye.current&&=(clearTimeout(Ye.current),null),e){if(H(n),W(i),K(o),ne(c),ie(u),oe(f),ce(m),ue(g),fe(v),me(b),ge(C),ve(T),be(D),Se(k),we(j),Ee(N),Oe(I),Ae(z),Be(!1),He(``),Ge(``),Je(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Me(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Ie(e.hours)).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`&&(Ye.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{Ye.current&&=(clearTimeout(Ye.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,z,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 Xe=e=>{e.preventDefault();let n=V.trim(),i=ae!==f;r(n||`~/Documents/GitHub`),a(U),s(ee),l(te),d(re),p(ae),h(se),_(le),y(de),S(pe),w(he),E(_e),O(ye),A(xe),M(Ce),F(Te),R(De),B(ke),t({webglChanged:i})},Ze=(e,t)=>{W(n=>n.map(n=>n.id===e?{...n,...t}:n))},Qe=e=>{let t=U.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=U.filter(t=>t.id!==e);W(n),e===ee&&K(n[0]?.id||`claude`)},$e=()=>{if(!Ve.trim()||!Ue.trim()||U.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Ve.trim(),command:Ue.trim(),isBuiltIn:!1,agentType:qe||void 0};W([...U,e]),Be(!1),He(``),Ge(``),Je(``)},et=U.length<50,tt=e=>{Pe(!0),Me(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).catch(()=>Me(!e)).finally(()=>Pe(!1))},nt=e=>{let t=Fe;Re(!0),Ie(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).catch(()=>Ie(t)).finally(()=>Re(!1))};return(0,q.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,q.jsxs)(`form`,{onSubmit:Xe,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,q.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,q.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,q.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,q.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,q.jsx)(`select`,{value:ee,onChange:e=>K(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:U.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:U.map(e=>(0,q.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(`input`,{value:e.label,onChange:t=>Ze(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>Qe(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,q.jsx)(`input`,{value:e.command,onChange:t=>Ze(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,q.jsxs)(`select`,{value:e.agentType||``,onChange:t=>Ze(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,q.jsx)(`option`,{value:``,children:`Terminal`}),(0,q.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,q.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),ze?(0,q.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,q.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,q.jsx)(`input`,{value:Ve,onChange:e=>He(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,q.jsx)(`input`,{value:Ue,onChange:e=>Ge(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`select`,{value:qe,onChange:e=>Je(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,q.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,q.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,q.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>Be(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`button`,onClick:$e,disabled:!Ve.trim()||!Ue.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>Be(!0),disabled:!et,className:`btn text-xs mt-3 w-full`,children:et?`+ Add Preset`:`Max 50 presets`})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`created`?`btn-primary`:``}`,onClick:()=>ne(`created`),children:`Created`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`status`?`btn-primary`:``}`,onClick:()=>ne(`status`),children:`Status`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`manual`?`btn-primary`:``}`,onClick:()=>ne(`manual`),children:`Manual`})]}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:te===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:te===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),te===`created`&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`desc`?`btn-primary`:``}`,onClick:()=>ie(`desc`),children:`Newest First`}),(0,q.jsx)(`button`,{type:`button`,className:`btn flex-1 ${re===`asc`?`btn-primary`:``}`,onClick:()=>ie(`asc`),children:`Oldest First`})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,q.jsx)(Rj,{checked:ye,onCheckedChange:be})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,q.jsx)(Rj,{checked:xe,onCheckedChange:Se})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,q.jsx)(Rj,{checked:Ce,onCheckedChange:we})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,q.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`number`,min:1,max:168,value:Fe,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&nt(t)},disabled:Le,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,q.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>void Xj(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,q.jsx)(Rj,{checked:De,onCheckedChange:e=>{Oe(e),e&&qj()}})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>void Zj(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,q.jsx)(Rj,{checked:ke,onCheckedChange:e=>{Ae(e),e&&qj()}})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,q.jsx)(Rj,{checked:ae,onCheckedChange:oe})]}),ae!==f&&(0,q.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,q.jsx)(Rj,{checked:je,onCheckedChange:tt,disabled:Ne})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(Math.max(6,se-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,q.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,q.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:se}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(Math.min(24,se+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,q.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:le,onChange:e=>ue(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,q.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:le.toFixed(1)})]})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:de,onChange:e=>fe(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,q.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[de,`px`]})]})]}),(0,q.jsxs)(`div`,{className:`mt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,q.jsx)(`select`,{value:pe,onChange:e=>me(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),pe===`custom`&&(0,q.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,q.jsx)(Rj,{checked:Te===`dark`,onCheckedChange:e=>Ee(e?`dark`:`light`)})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,q.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,q.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${_e===e?`btn-primary`:``}`,onClick:()=>ve(e),children:e===`auto`?`Auto`:Ke(e)},e))}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:_e===`auto`?`Platform default: ${Ke(We(`auto`))}`:`Shortcuts: ${Ke(_e)}+[N/X/[/]]`})]})]})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var $j=[];function eM(e){x.useEffect(e,$j)}var tM=x.createContext(void 0);function nM(){let e=x.useContext(tM);if(!e)throw Error(sk(73));return e}var rM=Symbol(`NOT_FOUND`);function iM(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function aM(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function oM(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 sM=e=>Array.isArray(e)?e:[e];function cM(e){let t=Array.isArray(e[0])?e[0]:e;return oM(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function lM(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function uM(e){let t;return{get(n){return t&&e(t.key,n)?t.value:rM},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function dM(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 rM}function i(t,i){r(t)===rM&&(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 fM=(e,t)=>e===t;function pM(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 mM(e,t){let{equalityCheck:n=fM,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=pM(n),o=0,s=r<=1?uM(a):dM(r,a);function c(){let t=s.get(arguments);if(t===rM){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 hM=class{constructor(e){this.value=e}deref(){return this.value}},gM=typeof WeakRef<`u`?WeakRef:hM,_M=0,vM=1;function yM(){return{s:_M,v:void 0,o:null,p:null}}function bM(e,t={}){let n=yM(),{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=yM(),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=yM(),e.set(n,t)):t=r}}let s=t,c;if(t.s===vM)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 gM(c):c}return s.s=vM,s.v=c,c}return o.clearCache=()=>{n=yM(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function xM(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()),iM(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=bM,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=sM(c),p=sM(u),m=cM(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=lM(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 SM=xM(bM),CM=Object.assign((e,t=SM)=>{aM(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:()=>CM}),wM=xM({memoize:mM,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),TM=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(sk(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},EM=(...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(sk(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(sk(2))}u=wM(...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`)}}},DM=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})),OM=s(((e,t)=>{t.exports=DM()})),kM=s((e=>{var t=p(),n=OM();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}})),AM=s(((e,t)=>{t.exports=kM()})),jM=[],MM=void 0;function NM(){return MM}function PM(e){jM.push(e)}var FM=OM(),IM=AM(),LM=lk(19)?BM:VM;function RM(e,t,n,r,i){return LM(e,t,n,r,i)}function zM(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,FM.useSyncExternalStore)(e.subscribe,a,a)}PM({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,FM.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function BM(e,t,n,r,i){let a=NM();if(!a)return zM(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 VM(e,t,n,r,i){return(0,IM.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var HM=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 RM(this,e,t,n,r)}},UM=class extends HM{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),tk(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;tk(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;tk(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;tk(()=>{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),RM(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=KO(t??ak);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)}})}},WM=null;globalThis.requestAnimationFrame;var GM=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)}},KM=class e{static create(){return new e}static request(e){return GM.request(e)}static cancel(e){return GM.cancel(e)}currentId=WM;request(e){this.cancel(),this.currentId=GM.request(()=>{this.currentId=WM,e()})}cancel=()=>{this.currentId!==WM&&(GM.cancel(this.currentId),this.currentId=WM)};disposeEffect=()=>this.cancel};function qM(){let e=UO(KM.create).current;return eM(e.disposeEffect),e}var JM=0,YM=class e{static create(){return new e}currentId=JM;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=JM,t()},e)}isStarted(){return this.currentId!==JM}clear=()=>{this.currentId!==JM&&(clearTimeout(this.currentId),this.currentId=JM)};disposeEffect=()=>this.clear};function XM(){let e=UO(YM.create).current;return eM(e.disposeEffect),e}var ZM=0;function QM(e){return ZM+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${ZM}`}function $M(e){return e?.ownerDocument||document}function eN(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 tN=typeof navigator<`u`,nN=sN(),rN=lN(),iN=cN();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),nN.platform===`MacIntel`&&nN.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(nN.platform),tN&&/firefox/i.test(iN);var aN=tN&&/apple/i.test(navigator.vendor);tN&&/Edg/i.test(iN),tN&&/android/i.test(rN)||/android/i.test(iN),tN&&rN.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var oN=iN.includes(`jsdom/`);function sN(){if(!tN)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 cN(){if(!tN)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function lN(){if(!tN)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function uN(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function dN(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Hk(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function fN(e){return`composedPath`in e?e.composedPath()[0]:e.target}function pN(e){if(!e||oN)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var mN=EM(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}),hN={toasts:TM(e=>e.toasts),isEmpty:TM(e=>e.toasts.length===0),toast:TM(mN,(e,t)=>e.get(t)?.value),toastIndex:TM(mN,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:TM(mN,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:TM(mN,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:TM(e=>e.hovering),focused:TM(e=>e.focused),expanded:TM(e=>e.hovering||e.focused),expandedOrOutOfFocus:TM(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:TM(e=>e.prevFocusElement)},gN=class extends UM{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},hN)}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=hN.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||QM(`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)),hN.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=hN.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)),hN.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{hN.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=eN(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=eN(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=eN(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??=YM.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=fN(e);dN(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!hN.expandedOrOutOfFocus(this.state),a=i?YM.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=uN($M(this.state.viewport));if(!this.state.viewport||!dN(this.state.viewport,t)||!pN(t))return;let n=hN.toasts(this.state),r=hN.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()}},_N=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=UO(()=>new gN({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return eM(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,q.jsx)(tM.Provider,{value:a,children:t})},vN=x.forwardRef(function(e,t){let[n,r]=x.useState();tk(()=>{aN&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,q.jsx)(`span`,{...e,ref:t,style:rk,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),yN=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),bN=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=nM(),s=XM(),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(uN($M(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=zk(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=zk(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=fN(n),i=uN($M(e));(!dN(e,r)||!pN(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=$M(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||pN($M(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||dN(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=Dk(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[yN.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,q.jsxs)(x.Fragment,{children:[!u&&m&&(0,q.jsx)(vN,{onFocus:_}),i,!u&&m&&(0,q.jsx)(vN,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,q.jsxs)(x.Fragment,{children:[!u&&m&&(0,q.jsx)(vN,{onFocus:_}),E,!f&&D.length>0&&(0,q.jsx)(`div`,{style:rk,children:D.map(e=>(0,q.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,q.jsx)(`div`,{children:e.title}),(0,q.jsx)(`div`,{children:e.description})]},e.id))})]})});function xN(e){return lk(19)?e:e?`true`:void 0}var SN=x.createContext(void 0);function CN(){let e=x.useContext(SN);if(!e)throw Error(sk(66));return e}var wN=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),TN={[wN.startingStyle]:``},EN={[wN.endingStyle]:``},DN={transitionStatus(e){return e===`starting`?TN:e===`ending`?EN:null}};function ON(e){return e==null?e:`current`in e?e.current:e}function kN(e,t=!1,n=!0){let r=qM();return KO((i,a=null)=>{r.cancel();function o(){K.flushSync(i)}let s=ON(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=wN.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 AN(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=KO(i),o=kN(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var jN=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}({}),MN={...DN,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},NN=40,PN=10,FN=.5,IN=1;function LN(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 RN(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 zN=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=nM(),[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),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),V=u.useState(`focused`),H=u.useState(`expanded`);AN({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let U=KO((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?K.flushSync(a):a()});tk(U,[U]);function W(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**FN:-(Math.abs(e)**FN):(!c.includes(`right`)&&e>0&&(n=e**FN),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**FN))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**FN:-(Math.abs(t)**FN):(!c.includes(`down`)&&t>0&&(r=t**FN),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**FN))),{x:n,y:r}}function G(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=fN(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=RN(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 ee(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)>=IN&&(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=LN(u,a,o),f(u));else{let e=N.current,t=LN(e,l,s);t>NN?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=PN&&(F.current=!0)}let d=W(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 te(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>NN&&(t=!0,a=`right`);break;case`left`:r<-NN&&(t=!0,a=`left`);break;case`down`:i>NN&&(t=!0,a=`down`);break;case`up`:i<-NN&&(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 ne(e){if(e.key===`Escape`){if(!A.current||!dN(A.current,uN($M(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){dN(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function re(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[jN.swipeMovementX]:`0px`,[jN.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,[jN.swipeMovementX]:`${e}px`,[jN.swipeMovementY]:`${t}px`}}let ie=n.priority===`high`,ae={role:ie?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":ie&&!V?!0:void 0,onPointerDown:l?G:void 0,onPointerMove:l?ee:void 0,onPointerUp:l?te:void 0,onKeyDown:ne,inert:xN(n.limited),style:{...re(),[jN.index]:n.transitionStatus===`ending`?R:z,[jN.offsetY]:`${B}px`,[jN.height]:n.height?`${n.height}px`:void 0}},oe=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:U,index:R,visibleIndex:z,expanded:H}),[n,w,E,p,d,U,R,z,H]),se={transitionStatus:n.transitionStatus,expanded:H,limited:n.limited||!1,type:n.type,swiping:oe.swiping,swipeDirection:oe.swipeDirection},ce=Dk(`div`,e,{ref:[t,oe.rootRef],state:se,stateAttributesMapping:MN,props:[ae,o]});return(0,q.jsx)(SN.Provider,{value:oe,children:ce})}),BN=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=CN(),l=a??s.description,u=!!l,d=Ik(i);tk(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=Dk(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),VN=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=CN(),l=a??s.title,u=!!l,d=Ik(i);tk(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=Dk(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),HN=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=nM(),{toast:c}=CN(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=Kk({disabled:i,native:a}),m={type:c.type};return Dk(`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 UN(){let e=x.useContext(tM);if(!e)throw Error(sk(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 WN(){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||QM(`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 GN=5e3,KN=WN();function qN({toast:e}){return(0,q.jsxs)(zN,{toast:e,className:Lj(`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,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(VN,{className:Lj(`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,q.jsx)(BN,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,q.jsx)(HN,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,q.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,q.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,q.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function JN(){let{toasts:e}=UN();return(0,q.jsx)(q.Fragment,{children:e.map(e=>(0,q.jsx)(qN,{toast:e},e.id))})}function YN(){return(0,q.jsxs)(_N,{timeout:GN,toastManager:KN,children:[(0,q.jsx)(JN,{}),(0,q.jsx)(bN,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var XN=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ZN=3e3,QN=8e3,$N=15e3,eP=5e3,tP=2e4,nP=1e4,rP=1500,iP=5e3,aP=750,oP=4,sP=5e3,cP=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(Z(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,Z(`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=>{Z(`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?XN[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`){Z(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){Z(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}Z(`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`;Z(`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?QN:ZN;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(Z(`ws_connect_timeout`,{wsState:XN[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){Z(`ws_onopen_stale`,this.wsSnap(),`info`);return}Z(`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(),Z(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(iP)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(Z(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){Z(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}Z(`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>$N&&(Z(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},eP))}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 Z(`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(Z(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){Z(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(Z(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},rP)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){Z(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){Z(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){Z(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,Z(`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()},aP)):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,Z(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},nP)))};e!==void 0&&e<tP?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,tP)},e):this.heartbeatTimer=window.setInterval(t,tP)}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()){Z(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=oP){Z(`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()},sP);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Z(`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){Z(`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 lP(){let e=Wm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{cP.connect(),cP.startLifecycleListeners();let t=cP.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),cP.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{cP.send(e)},[]),subscribe:(0,x.useMemo)(()=>cP.subscribe.bind(cP),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>cP.getConnectionEpoch(),[])}}var uP=100;function dP({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>uP?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function fP(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 pP(){(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=()=>{dP({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(),fP(document)}},[])}function mP(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 hP(){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=Wm(e=>e.sessions),_=Wm(e=>e.agentSessions),v=Wm(e=>e.agentSessionsEpoch),y=Wm(e=>e.selectedSessionId),b=Wm(e=>e.selectedHibernatingSessionId),S=Wm(e=>e.setSessions),C=Wm(e=>e.setAgentSessions),w=Wm(e=>e.setActiveAgentSessions),T=Wm(e=>e.setHostStatuses),E=Wm(e=>e.updateSession),D=Wm(e=>e.setSelectedSessionId),O=Wm(e=>e.setSelectedHibernatingSessionId),k=Wm(e=>e.hasLoaded),A=Wm(e=>e.connectionStatus),j=Wm(e=>e.connectionError),M=Wm(e=>e.clearExitingSession),N=Wm(e=>e.markSessionExiting),P=Wm(e=>e.setRemoteAllowControl),F=Wm(e=>e.setRemoteAllowAttach),I=Wm(e=>e.setHostLabel),L=Wm(e=>e.setPreferWindowName),R=Wm(e=>e.hostStatuses),z=Wm(e=>e.remoteAllowControl),B=Wm(e=>e.hostLabel),V=ZD(e=>e.theme),H=ee(),U=G(e=>e.defaultProjectDir),W=G(e=>e.commandPresets),te=G(e=>e.defaultPresetId),ne=G(e=>e.lastProjectPath),re=G(e=>e.setLastProjectPath),ie=G(e=>e.addRecentPath),ae=G(e=>e.shortcutModifier),oe=G(e=>e.sidebarWidth),se=G(e=>e.setSidebarWidth),ce=G(e=>e.projectFilters),le=G(e=>e.hostFilters),ue=G(e=>e.soundOnPermission),de=G(e=>e.soundOnIdle),fe=Wm(e=>e.connectionEpoch),{sendMessage:pe,subscribe:me,getConnectionEpoch:he}=lP();pP(),(0,x.useEffect)(()=>{if(typeof document>`u`||!ue&&!de)return;let e=!1,t=()=>{e&&!Gj()||(e=!0,qj())};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)}},[ue,de]);let ge=(0,x.useRef)(!1),_e=(0,x.useCallback)(e=>{e.preventDefault(),ge.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(!ge.current)return;let t=e.clientX;se(Math.max(180,Math.min(400,t)))},t=()=>{ge.current&&(ge.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)}},[se]),(0,x.useEffect)(()=>{let e=me(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=Wm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=G.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&&Xj(),e.status===`working`&&i.status===`waiting`&&r&&Zj())}if(Ne.current.size>0){let e=he();for(let[t,n]of Ne.current)n.epoch!==e&&Ne.current.delete(t)}let i=Ne.current.size>0?e.sessions.filter(e=>!Ne.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Wm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(ke.current=s),S(i);let c=Ae.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Wm.getState(),{projectFilters:d,hostFilters:f}=G.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&&(Ae.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&&YT(e.clientLogLevel)),e.type===`session-update`){let t=Wm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=G.getState();t!==`permission`&&n===`permission`&&e&&Xj(),t===`working`&&n===`waiting`&&r&&Zj()}}if(e.type===`session-created`){let t=Wm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),ie(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=G.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){SD(e.sessionId);let t=Wm.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}=Wm.getState(),a=ke.current;i&&!n.some(e=>e.sessionId===i)&&(Ae.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)?(ke.current=null,O(a)):a&&(ke.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Wm.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=Wm.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=Wm.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=Ne.current.get(e.sessionId);if(t){let n=Wm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ne.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,ie,M,pe,D,O,h,S,C,w,T,P,F,I,L,me,E]);let ve=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),ye=_.hibernating??[],be=_.history??[],xe=(0,x.useMemo)(()=>mP(ye,ce,le),[ye,ce,le]),Se=(0,x.useMemo)(()=>xe.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[xe,m,b]);(0,x.useEffect)(()=>{ve?.projectPath&&!ve.remote&&re(ve.projectPath)},[ve?.projectPath,ve?.remote,re]);let Ce=G(e=>e.sessionSortMode),we=G(e=>e.sessionSortDirection),Te=G(e=>e.manualSessionOrder),Ee=(0,x.useMemo)(()=>km(g,{mode:Ce,direction:we,manualOrder:Te}),[g,Ce,we,Te]),De=(0,x.useMemo)(()=>{let e=Ee;return ce.length>0&&(e=e.filter(e=>ce.includes(e.projectPath))),le.length>0&&(e=e.filter(e=>le.includes(e.host??``))),e},[Ee,ce,le]),Oe=(0,x.useRef)(b),ke=(0,x.useRef)(null),Ae=(0,x.useRef)(null),je=(0,x.useRef)(fe),Me=(0,x.useCallback)(()=>De.length>0?(D(De[0].id),!0):xe.length>0?(O(xe[0].sessionId),!0):!1,[De,xe,D,O]);(0,x.useEffect)(()=>{let e=Oe.current;e&&b===null&&!ye.some(t=>t.sessionId===e)?Ae.current=e:b!==null&&(Ae.current=null),Oe.current=b},[ye,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{je.current!==fe&&(je.current=fe,ke.current=null,Ae.current=null,h(null))},[fe]),(0,x.useEffect)(()=>{k&&(b||y&&(De.some(e=>e.id===y)||Me()||D(null)))},[k,y,b,Me,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==fe||xe.some(e=>e.sessionId===b))return;let e=De.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Me()||O(null)},[xe,De,v,m,b,Me,D,O,fe]),(0,x.useEffect)(()=>{let e=Ae.current;if(!e)return;if(b!==null){Ae.current=null;return}let t=De.find(t=>t.agentSessionId?.trim()===e);if(t){Ae.current=null,D(t.id);return}if(y!==null){Ae.current=null;return}Me()&&(Ae.current=null)},[De,y,b,Me,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(De.length>0||xe.length>0)&&Me()},[xe.length,De.length,k,Me,y,b]);let Ne=(0,x.useRef)(new Map),Pe=(0,x.useCallback)((e,t=`unknown`)=>{SD(e);let{sessions:n,selectedSessionId:r}=Wm.getState(),i=n.find(t=>t.id===e);i&&Ne.current.set(e,{session:i,wasSelected:r===e,epoch:he()}),(0,K.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),pe({type:`session-kill`,sessionId:e,source:t})},[N,S,pe]);(0,x.useEffect)(()=>{let n=We(ae),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=qe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=De;if(t.length===0){let t=xe;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&&H&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Pe(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,De,xe,Pe,ae,H]);let Fe=()=>H?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Ie=()=>l(!0),Le=(e,t,n,r)=>{pe({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||re(e)},Re=e=>{pe({type:`session-wake`,sessionId:e})},ze=(0,x.useCallback)(e=>{pe({type:`session-hibernate`,sessionId:e})},[pe]),Be=(e,t)=>{pe({type:`session-rename`,sessionId:e,newName:t})},Ve=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&pe({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,pe]),He=(0,x.useCallback)(e=>{pe({type:`session-move-to-history`,sessionId:e})},[pe]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,V)},[V]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ue=(0,x.useMemo)(()=>B?R.filter(e=>e.host!==B):R,[R,B]);return(0,q.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:oe},children:[(0,q.jsx)(Xe,{connectionStatus:A,onNewSession:Fe,onOpenSettings:Ie,tailscaleIp:f?.tailscaleIp??null}),(0,q.jsx)(WT,{sessions:g,hibernatingSessions:ye,historySessions:be,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Be,onResume:Re,onHibernate:ze,onKill:Pe,onDuplicate:Ve,onMoveToHistory:He,onNewSession:Fe,loading:!k,error:j||u})]}),(0,q.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:_e}),(0,q.jsx)(RO,{session:ve,sessions:De,hibernatingSession:Se,hibernatingSessions:ye,connectionStatus:A,connectionEpoch:fe,sendMessage:pe,subscribe:me,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Fe,onKillSession:Pe,onRenameSession:Be,onOpenSettings:Ie,onResumeSession:Re,onHibernateSession:ze,onMoveToHistory:He,historySessions:be,loading:!k,error:j||u}),(0,q.jsx)(BO,{isOpen:e,onClose:()=>t(!1),onCreate:Le,defaultProjectDir:U,commandPresets:W,defaultPresetId:te,lastProjectPath:ne,activeProjectPath:ve&&!ve.remote?ve.projectPath:void 0,remoteHosts:Ue,remoteAllowControl:z,initialHost:n,initialPath:i,initialCommand:o}),(0,q.jsx)(Qj,{isOpen:c,onClose:()=>l(!1)}),(0,q.jsx)(YN,{})]})}var gP=`modulepreload`,_P=function(e){return`/`+e},vP={},yP=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=_P(t,n),t in vP)return;vP[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`:gP,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)})},bP=`true`,xP=`false`,SP=bP===`true`,CP=xP===`true`;function wP(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,SP||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await yP(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()},!CP)if(SP)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}Ve()&&document.documentElement.classList.add(`ios`),He()&&document.documentElement.classList.add(`ios-pwa`),wP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var TP=document.getElementById(`root`);if(!TP)throw Error(`Root element not found`);(0,E.createRoot)(TP).render((0,q.jsx)(x.StrictMode,{children:(0,q.jsx)(hP,{})}));