@sma1lboy/rove 0.9.277-next.2 → 0.9.277-next.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.
Files changed (52) hide show
  1. package/dist/cli/{chunk-671ak750.js → chunk-0t6j1skp.js} +1 -1
  2. package/dist/cli/{chunk-n94vzkbe.js → chunk-1cyeyw6g.js} +1 -1
  3. package/dist/cli/{chunk-vwpf55cr.js → chunk-2569f2kc.js} +2 -2
  4. package/dist/cli/{chunk-j1qy79fd.js → chunk-2drde6sc.js} +1 -1
  5. package/dist/cli/{chunk-vpsarakj.js → chunk-4xr4pv54.js} +1 -1
  6. package/dist/cli/{chunk-z3qz6enf.js → chunk-6cfs0nqe.js} +1 -1
  7. package/dist/cli/{chunk-d552cvb2.js → chunk-73zg0mrb.js} +1 -1
  8. package/dist/cli/{chunk-rmsdybs3.js → chunk-7ks7rrnr.js} +2 -2
  9. package/dist/cli/{chunk-ys6v36ph.js → chunk-8j3b5m5h.js} +1 -1
  10. package/dist/cli/{chunk-fgtc1xq9.js → chunk-8jn2axtz.js} +1 -1
  11. package/dist/cli/{chunk-mxx0y791.js → chunk-9s7q3432.js} +1 -1
  12. package/dist/cli/{chunk-gbd5j3dv.js → chunk-aefvcbng.js} +1 -1
  13. package/dist/cli/{chunk-3y0z478f.js → chunk-am5cpb9n.js} +1 -1
  14. package/dist/cli/{chunk-37fas9aj.js → chunk-byh66pd6.js} +1 -1
  15. package/dist/cli/{chunk-pqr6td4z.js → chunk-cgmqnhjn.js} +1 -1
  16. package/dist/cli/{chunk-9x2xd1rz.js → chunk-ck9jdarp.js} +1 -1
  17. package/dist/cli/{chunk-tw9tfs1d.js → chunk-d6j2d6fk.js} +1 -1
  18. package/dist/cli/{chunk-0rvydb9q.js → chunk-e04pp8f5.js} +1 -1
  19. package/dist/cli/{chunk-3dhv5n19.js → chunk-exp78r1c.js} +1 -1
  20. package/dist/cli/{chunk-cf3vpsm5.js → chunk-f7egph8g.js} +1 -1
  21. package/dist/cli/{chunk-jejmt4k0.js → chunk-hdzsswee.js} +3 -3
  22. package/dist/cli/{chunk-kag7cfbr.js → chunk-hzvb6xsd.js} +1 -1
  23. package/dist/cli/{chunk-j9tsdn1d.js → chunk-j30488hn.js} +1 -1
  24. package/dist/cli/{chunk-rztqccs3.js → chunk-jgkdxj5f.js} +1 -1
  25. package/dist/cli/{chunk-748656h7.js → chunk-k2j2tjvd.js} +2 -2
  26. package/dist/cli/{chunk-ta1p2nwa.js → chunk-k9jhy3yx.js} +1 -1
  27. package/dist/cli/{chunk-zpwvjt14.js → chunk-kgpj4k4z.js} +1 -1
  28. package/dist/cli/chunk-m98jd1fz.js +3 -0
  29. package/dist/cli/{chunk-shtm72c0.js → chunk-mcxvazp4.js} +1 -1
  30. package/dist/cli/{chunk-vkv1v3xn.js → chunk-nhd4y1dw.js} +2 -2
  31. package/dist/cli/{chunk-yzdrhytj.js → chunk-np398f2a.js} +1 -1
  32. package/dist/cli/{chunk-mjyhy152.js → chunk-nqwza8b0.js} +1 -1
  33. package/dist/cli/{chunk-ca4x8s96.js → chunk-nv6dz5wy.js} +2 -2
  34. package/dist/cli/{chunk-2vph030z.js → chunk-nvcq93bp.js} +1 -1
  35. package/dist/cli/{chunk-36eyrv4r.js → chunk-p7v3w8ys.js} +1 -1
  36. package/dist/cli/{chunk-6wfhq8xd.js → chunk-qwwt4ch2.js} +1 -1
  37. package/dist/cli/{chunk-g9xknhjq.js → chunk-sh37tm44.js} +1 -1
  38. package/dist/cli/{chunk-nw092jak.js → chunk-t2p22ww7.js} +1 -1
  39. package/dist/cli/{chunk-9fdy8vne.js → chunk-t99295wq.js} +1 -1
  40. package/dist/cli/{chunk-5yh5trgy.js → chunk-v4bax7cf.js} +1 -1
  41. package/dist/cli/{chunk-wzss4pzh.js → chunk-ve76p2mx.js} +1 -1
  42. package/dist/cli/{chunk-bykqhbvy.js → chunk-vwmwmycs.js} +1 -1
  43. package/dist/cli/{chunk-zrf93zrx.js → chunk-w2tcb3rn.js} +1 -1
  44. package/dist/cli/{chunk-rjy900p4.js → chunk-wac6eaxn.js} +1 -1
  45. package/dist/cli/{chunk-5apxck3d.js → chunk-was6vqxt.js} +7 -7
  46. package/dist/cli/{chunk-z3wrbtcq.js → chunk-ym0zghjh.js} +2 -2
  47. package/dist/cli/{chunk-tnatqcy7.js → chunk-z1y9gys2.js} +1 -1
  48. package/dist/cli/index.js +2 -2
  49. package/dist/web/assets/{index-BakEtMcK.js → index-c14wNHdR.js} +29 -29
  50. package/dist/web/index.html +1 -1
  51. package/package.json +1 -1
  52. package/dist/cli/chunk-m4z6kepz.js +0 -3
@@ -35,7 +35,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
35
35
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),gm&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=zm(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=em(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Bm),Bm),t/=Bm,t/Math.abs(t)+Math.round(t*(Vm-1)))}shouldForceSelection(e){return fm?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Hm)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(fm&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Um&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=Tm(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=zm(n,this._bufferService.cols)}};Gm=ll([Y(3,Il),Y(4,Rl),Y(5,Xl),Y(6,Hl),Y(7,Zl),Y(8,Yl)],Gm);var Km=class{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={}}},qm=class{constructor(){this._color=new Km,this._css=new Km}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Jm=Object.freeze((()=>{let e=[Sp.toColor(`#2e3436`),Sp.toColor(`#cc0000`),Sp.toColor(`#4e9a06`),Sp.toColor(`#c4a000`),Sp.toColor(`#3465a4`),Sp.toColor(`#75507b`),Sp.toColor(`#06989a`),Sp.toColor(`#d3d7cf`),Sp.toColor(`#555753`),Sp.toColor(`#ef2929`),Sp.toColor(`#8ae234`),Sp.toColor(`#fce94f`),Sp.toColor(`#729fcf`),Sp.toColor(`#ad7fa8`),Sp.toColor(`#34e2e2`),Sp.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:bp.toCss(r,i,a),rgba:bp.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:bp.toCss(n,n,n),rgba:bp.toRgba(n,n,n)})}return e})()),Ym=Sp.toColor(`#ffffff`),Xm=Sp.toColor(`#000000`),Zm=Sp.toColor(`#ffffff`),Qm=Xm,$m={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},eh=Ym,th=class extends Tu{constructor(e){super(),this._optionsService=e,this._contrastCache=new qm,this._halfContrastCache=new qm,this._onChangeColors=this._register(new X),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ym,background:Xm,cursor:Zm,cursorAccent:Qm,selectionForeground:void 0,selectionBackgroundTransparent:$m,selectionBackgroundOpaque:xp.blend(Xm,$m),selectionInactiveBackgroundTransparent:$m,selectionInactiveBackgroundOpaque:xp.blend(Xm,$m),scrollbarSliderBackground:xp.opacity(Ym,.2),scrollbarSliderHoverBackground:xp.opacity(Ym,.4),scrollbarSliderActiveBackground:xp.opacity(Ym,.5),overviewRulerBorder:Ym,ansi:Jm.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=nh(e.foreground,Ym),t.background=nh(e.background,Xm),t.cursor=xp.blend(t.background,nh(e.cursor,Zm)),t.cursorAccent=xp.blend(t.background,nh(e.cursorAccent,Qm)),t.selectionBackgroundTransparent=nh(e.selectionBackground,$m),t.selectionBackgroundOpaque=xp.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=nh(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xp.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?nh(e.selectionForeground,yp):void 0,t.selectionForeground===yp&&(t.selectionForeground=void 0),xp.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=xp.opacity(t.selectionBackgroundTransparent,.3)),xp.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=xp.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=nh(e.scrollbarSliderBackground,xp.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=nh(e.scrollbarSliderHoverBackground,xp.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=nh(e.scrollbarSliderActiveBackground,xp.opacity(t.foreground,.5)),t.overviewRulerBorder=nh(e.overviewRulerBorder,eh),t.ansi=Jm.slice(),t.ansi[0]=nh(e.black,Jm[0]),t.ansi[1]=nh(e.red,Jm[1]),t.ansi[2]=nh(e.green,Jm[2]),t.ansi[3]=nh(e.yellow,Jm[3]),t.ansi[4]=nh(e.blue,Jm[4]),t.ansi[5]=nh(e.magenta,Jm[5]),t.ansi[6]=nh(e.cyan,Jm[6]),t.ansi[7]=nh(e.white,Jm[7]),t.ansi[8]=nh(e.brightBlack,Jm[8]),t.ansi[9]=nh(e.brightRed,Jm[9]),t.ansi[10]=nh(e.brightGreen,Jm[10]),t.ansi[11]=nh(e.brightYellow,Jm[11]),t.ansi[12]=nh(e.brightBlue,Jm[12]),t.ansi[13]=nh(e.brightMagenta,Jm[13]),t.ansi[14]=nh(e.brightCyan,Jm[14]),t.ansi[15]=nh(e.brightWhite,Jm[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=nh(e.extendedAnsi[r],Jm[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};th=ll([Y(0,Hl)],th);function nh(e,t){if(e!==void 0)try{return Sp.toColor(e)}catch{}return t}var rh=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ih=class{constructor(){this._services=new rh,this._services.set(Bl,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Nl(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},ah={trace:0,debug:1,info:2,warn:3,error:4,off:5},oh=`xterm.js: `,sh=class extends Tu{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),ch=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ah[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?``:oh)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};sh=ll([Y(0,Hl)],sh);var ch,lh=class extends Tu{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new X),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new X),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new X),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},uh=3,dh=Object.freeze(new Dl),fh=0,ph=2,mh=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*uh);let r=t||kl.fromCharData([0,Tl,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*uh+0],n=t&2097151;return[this._data[e*uh+1],t&2097152?this._combined[e]:n?xl(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*uh+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*uh+0]=e|2097152|t[2]<<22):this._data[e*uh+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*uh+0]>>22}hasWidth(e){return this._data[e*uh+0]&12582912}getFg(e){return this._data[e*uh+1]}getBg(e){return this._data[e*uh+2]}hasContent(e){return this._data[e*uh+0]&4194303}getCodePoint(e){let t=this._data[e*uh+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*uh+0]&2097152}getString(e){let t=this._data[e*uh+0];return t&2097152?this._combined[e]:t&2097151?xl(t&2097151):``}isProtected(e){return this._data[e*uh+2]&536870912}loadCell(e,t){return fh=e*uh,t.content=this._data[fh+0],t.fg=this._data[fh+1],t.bg=this._data[fh+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*uh+0]=t.content,this._data[e*uh+1]=t.fg,this._data[e*uh+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*uh+0]=t|n<<22,this._data[e*uh+1]=r.fg,this._data[e*uh+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*uh+0];r&2097152?this._combined[e]+=xl(t):r&2097151?(this._combined[e]=xl(r&2097151)+xl(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*uh+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new kl;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new kl;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*ph<this._data.buffer.byteLength;let n=e*uh;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*ph<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ph<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*uh+0]&4194303)return e+(this._data[e*uh+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*uh+0]&4194303||this._data[e*uh+2]&50331648)return e+(this._data[e*uh+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<uh;e++)this._data[(n+i)*uh+e]=a[(t+i)*uh+e];a[(t+i)*uh+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<uh;e++)this._data[(n+i)*uh+e]=a[(t+i)*uh+e];a[(t+i)*uh+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*uh+0],n=e&2097151,a=e&2097152?this._combined[t]:n?xl(n):El;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function hh(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=yh(u,d,t),p=1,m=0;for(;p<u.length;){let e=yh(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function gh(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function _h(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function vh(e,t,n){let r=[],i=e.map((n,r)=>yh(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=yh(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function yh(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var bh=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new X),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),bu(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};bh._nextId=1;var xh=bh,Sh={},Ch=Sh.B;Sh[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},Sh.A={"#":`£`},Sh.B=void 0,Sh[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},Sh.C=Sh[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Sh.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},Sh.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},Sh.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},Sh.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},Sh.E=Sh[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},Sh.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},Sh.H=Sh[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Sh[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var wh=4294967295,Th=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=dh.clone(),this.savedCharset=Ch,this.markers=[],this._nullCell=kl.fromCharData([0,Tl,1,0]),this._whitespaceCell=kl.fromCharData([0,El,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new xm,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new lh(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ol),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ol),this._whitespaceCell}getBlankLine(e,t){return new mh(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>wh?wh:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=dh);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new lh(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(dh),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new mh(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new mh(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=hh(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(dh),n);if(r.length>0){let n=gh(this.lines,r);_h(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(dh),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new mh(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(dh),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=vh(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(dh,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=yh(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new xh(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Eh=class extends Tu{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new X),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new Th(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Th(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Dh=2,Oh=1,kh=class extends Tu{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Dh),this.rows=Math.max(e.rawOptions.rows||0,Oh),this.buffers=this._register(new Eh(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};kh=ll([Y(0,Hl)],kh);var Ah={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:fm,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},jh=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Mh=class extends Tu{constructor(e){super(),this._onOptionChange=this._register(new X),this.onOptionChange=this._onOptionChange.event;let t={...Ah};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Su(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in Ah))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Ah))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=Ah[e],!Nh(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Ah[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=jh.includes(t)?t:Ah[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function Nh(e){return e===`block`||e===`underline`||e===`bar`}function Ph(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Ph(e[r],t-1);return n}var Fh=Object.freeze({insertMode:!1}),Ih=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Lh=class extends Tu{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new X),this.onData=this._onData.event,this._onUserInput=this._register(new X),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new X),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ph(Fh),this.decPrivateModes=Ph(Ih)}reset(){this.modes=Ph(Fh),this.decPrivateModes=Ph(Ih)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Lh=ll([Y(0,Il),Y(1,Vl),Y(2,Hl)],Lh);var Rh={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function zh(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Bh=String.fromCharCode,Vh={DEFAULT:e=>{let t=[zh(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Bh(t[0])}${Bh(t[1])}${Bh(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${zh(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${zh(e,!0)};${e.x};${e.y}${t}`}},Hh=class extends Tu{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new X),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Rh))this.addProtocol(e,Rh[e]);for(let e of Object.keys(Vh))this.addEncoding(e,Vh[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};Hh=ll([Y(0,Il),Y(1,Rl),Y(2,Hl)],Hh);var Uh=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Wh=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Gh;function Kh(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var qh=class{constructor(){if(this.version=`6`,!Gh){Gh=new Uint8Array(65536),Gh.fill(1),Gh[0]=0,Gh.fill(0,1,32),Gh.fill(0,127,160),Gh.fill(2,4352,4448),Gh[9001]=2,Gh[9002]=2,Gh.fill(2,11904,42192),Gh[12351]=1,Gh.fill(2,44032,55204),Gh.fill(2,63744,64256),Gh.fill(2,65040,65050),Gh.fill(2,65072,65136),Gh.fill(2,65280,65377),Gh.fill(2,65504,65511);for(let e=0;e<Uh.length;++e)Gh.fill(0,Uh[e][0],Uh[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Gh[e]:Kh(e,Wh)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Jh.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Jh.createPropertyValue(0,n,r)}},Jh=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new X,this.onChange=this._onChange.event;let e=new qh;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Yh=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Xh(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Zh=2147483647,Qh=256,$h=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>Qh)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Zh?Zh:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>Zh?Zh:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,Zh):e}},eg=[],tg=class{constructor(){this._state=0,this._active=eg,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eg}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=eg,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||eg,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Sl(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=eg,this._id=-1,this._state=0}}},ng=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Sl(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},rg=[],ig=class{constructor(){this._handlers=Object.create(null),this._active=rg,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=rg}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=rg,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||rg,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Sl(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=rg,this._ident=0}},ag=new $h;ag.addParam(0);var og=class{constructor(e){this._handler=e,this._data=``,this._params=ag,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ag,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Sl(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=ag,this._data=``,this._hitLimit=!1,e));return this._params=ag,this._data=``,this._hitLimit=!1,t}},sg=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},cg=160,lg=function(){let e=new sg(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(cg,0,2,0),e.add(cg,8,5,8),e.add(cg,6,0,6),e.add(cg,11,0,11),e.add(cg,13,13,13),e}(),ug=class extends Tu{constructor(e=lg){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new $h,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Su(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new tg),this._dcsParser=this._register(new ig),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:cg)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<cg){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<cg){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<cg){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<cg){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<cg){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<cg){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},dg=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,fg=/^[\da-f]+$/;function pg(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=dg.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),fg.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function mg(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function hg(e,t=16){let[n,r,i]=e;return`rgb:${mg(n,t)}/${mg(r,t)}/${mg(i,t)}`}var gg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},_g=131072,vg=10;function yg(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var bg=5e3,xg=0,Sg=class extends Tu{constructor(e,t,n,r,i,a,o,s,c=new ug){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Cl,this._utf8Decoder=new wl,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=dh.clone(),this._eraseAttrDataInternal=dh.clone(),this._onRequestBell=this._register(new X),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new X),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new X),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new X),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new X),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new X),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new X),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new X),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new X),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Cg(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fp.IND,()=>this.index()),this._parser.setExecuteHandler(fp.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fp.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ng(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new ng(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new ng(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new ng(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new ng(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new ng(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new ng(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new ng(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new ng(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new ng(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new ng(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new ng(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in Sh)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new og((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),bg))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${bg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>_g&&(a=this._parseStack.position+_g)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<_g&&(this._parseBuffer=new Uint32Array(Math.min(e.length,_g))),o||this._dirtyRowTracker.clearRange(),e.length>_g)for(let t=a;t<e.length;t+=_g){let a=t+_g<e.length?t+_g:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=Jh.extractWidth(t);let n=Jh.extractShouldJoin(t),m=n?Jh.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(xl(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof mh&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!yg(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new og(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ng(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(dh));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=Jh.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Q.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ch),this._charsetService.setgCharset(1,Ch),this._charsetService.setgCharset(2,Ch),this._charsetService.setgCharset(3,Ch);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Q.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Dl.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=dh.fg,e.bg=dh.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=dh.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=dh.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=dh.fg&16777215,r.bg&=-67108864,r.bg|=dh.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=dh.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!yg(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>vg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>vg&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(wg(n)){if(r===`?`)t.push({type:0,index:n});else{let e=pg(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=pg(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);wg(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Ch),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(gg[e[0]],Sh[e[1]]||Ch),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=dh.clone(),this._eraseAttrDataInternal=dh.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new kl;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Q.ESC}${e}${Q.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Cg=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(xg=e,e=t,t=xg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Cg=ll([Y(0,Il)],Cg);function wg(e){return 0<=e&&e<256}var Tg=5e7,Eg=12,Dg=50,Og=class extends Tu{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Tg)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=Eg?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=Eg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Dg&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},kg=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};kg=ll([Y(0,Il)],kg);var Ag=!1,jg=class extends Tu{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Eu),this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onData=this._register(new X),this.onData=this._onData.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new X),this._instantiationService=new ih,this.optionsService=this._register(new Mh(e)),this._instantiationService.setService(Hl,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(kh)),this._instantiationService.setService(Il,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(sh)),this._instantiationService.setService(Vl,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Lh)),this._instantiationService.setService(Rl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Hh)),this._instantiationService.setService(Ll,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Jh)),this._instantiationService.setService(Wl,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Yh),this._instantiationService.setService(zl,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(kg),this._instantiationService.setService(Ul,this._oscLinkService),this._inputHandler=this._register(new Sg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Nu.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Nu.forward(this._bufferService.onResize,this._onResize)),this._register(Nu.forward(this.coreService.onData,this._onData)),this._register(Nu.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Og((e,t)=>this._inputHandler.parse(e,t))),this._register(Nu.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new X),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ag&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Ag=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Dh),t=Math.max(t,Oh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Xh.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Xh(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Su(()=>{for(let t of e)t.dispose()})}}},Mg={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function Ng(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?Q.ESC+`OA`:Q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?Q.ESC+`OD`:Q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?Q.ESC+`OC`:Q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?Q.ESC+`OB`:Q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+`[Z`;break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`D`:t?Q.ESC+`OD`:Q.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`C`:t?Q.ESC+`OC`:Q.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`A`:t?Q.ESC+`OA`:Q.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`B`:t?Q.ESC+`OB`:Q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+`[2~`);break;case 46:i.key=a?Q.ESC+`[3;`+(a+1)+`~`:Q.ESC+`[3~`;break;case 36:i.key=a?Q.ESC+`[1;`+(a+1)+`H`:t?Q.ESC+`OH`:Q.ESC+`[H`;break;case 35:i.key=a?Q.ESC+`[1;`+(a+1)+`F`:t?Q.ESC+`OF`:Q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?Q.ESC+`[5;`+(a+1)+`~`:Q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?Q.ESC+`[6;`+(a+1)+`~`:Q.ESC+`[6~`;break;case 112:i.key=a?Q.ESC+`[1;`+(a+1)+`P`:Q.ESC+`OP`;break;case 113:i.key=a?Q.ESC+`[1;`+(a+1)+`Q`:Q.ESC+`OQ`;break;case 114:i.key=a?Q.ESC+`[1;`+(a+1)+`R`:Q.ESC+`OR`;break;case 115:i.key=a?Q.ESC+`[1;`+(a+1)+`S`:Q.ESC+`OS`;break;case 116:i.key=a?Q.ESC+`[15;`+(a+1)+`~`:Q.ESC+`[15~`;break;case 117:i.key=a?Q.ESC+`[17;`+(a+1)+`~`:Q.ESC+`[17~`;break;case 118:i.key=a?Q.ESC+`[18;`+(a+1)+`~`:Q.ESC+`[18~`;break;case 119:i.key=a?Q.ESC+`[19;`+(a+1)+`~`:Q.ESC+`[19~`;break;case 120:i.key=a?Q.ESC+`[20;`+(a+1)+`~`:Q.ESC+`[20~`;break;case 121:i.key=a?Q.ESC+`[21;`+(a+1)+`~`:Q.ESC+`[21~`;break;case 122:i.key=a?Q.ESC+`[23;`+(a+1)+`~`:Q.ESC+`[23~`;break;case 123:i.key=a?Q.ESC+`[24;`+(a+1)+`~`:Q.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Mg[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Q.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Q.ESC+n}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Q.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Q.US),e.key===`@`&&(i.key=Q.NUL))}return i}var Pg=0,Fg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new xm,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new xm,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Pg=this._search(t),Pg===-1)||this._getKey(this._array[Pg])!==t)return!1;do if(this._array[Pg]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pg),!0;while(++Pg<this._array.length&&this._getKey(this._array[Pg])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pg=this._search(e),!(Pg<0||Pg>=this._array.length)&&this._getKey(this._array[Pg])===e))do yield this._array[Pg];while(++Pg<this._array.length&&this._getKey(this._array[Pg])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pg=this._search(e),!(Pg<0||Pg>=this._array.length)&&this._getKey(this._array[Pg])===e))do t(this._array[Pg]);while(++Pg<this._array.length&&this._getKey(this._array[Pg])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Ig=0,Lg=0,Rg=class extends Tu{constructor(){super(),this._decorations=new Fg(e=>e?.marker.line),this._onDecorationRegistered=this._register(new X),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new X),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Su(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new zg(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{Ig=t.options.x??0,Lg=Ig+(t.options.width??1),e>=Ig&&e<Lg&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},zg=class extends wu{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new X),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new X),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?Sp.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Sp.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Bg=1e3,Vg=class{constructor(e,t=Bg){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Hg=20,Ug=class extends Tu{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Vg(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
36
36
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Z(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Su(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<Hg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
37
37
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Hg+1&&(this._liveRegion.textContent+=pl.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Ug=ll([Y(1,Bl),Y(2,Yl),Y(3,Zl)],Ug);var Wg=class extends Tu{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new X),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new X),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Su(()=>{bu(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Z(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Z(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Z(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Z(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Gg(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,bu(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Wg=ll([Y(1,Xl),Y(2,Zl),Y(3,Il),Y(4,tu)],Wg);function Gg(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Kg=class extends jg{constructor(e={}){super(e),this._linkifier=this._register(new Eu),this.browser=im,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Eu),this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new X),this.onKey=this._onKey.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new X),this.onBell=this._onBell.event,this._onFocus=this._register(new X),this._onBlur=this._register(new X),this._onA11yCharEmitter=this._register(new X),this._onA11yTabEmitter=this._register(new X),this._onWillOpen=this._register(new X),this._setup(),this._decorationService=this._instantiationService.createInstance(Rg),this._instantiationService.setService(Gl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance($p),this._instantiationService.setService(tu,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Kl)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Nu.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Nu.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Nu.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Nu.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Su(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=xp.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${hg(r)}${pp.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=bp.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=bp.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ug,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Z(this.element,`copy`,e=>{this.hasSelection()&&gl(e,this._selectionService)}));let e=e=>_l(e,this.textarea,this.coreService,this.optionsService);this._register(Z(this.textarea,`paste`,e)),this._register(Z(this.element,`paste`,e)),cm?this._register(Z(this.element,`mousedown`,e=>{e.button===2&&bl(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Z(this.element,`contextmenu`,e=>{bl(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),gm&&this._register(Z(this.element,`auxclick`,e=>{e.button===1&&yl(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Z(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Z(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Z(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Z(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Z(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Z(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Z(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Z(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,dl.get()),_m||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Zp,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Yl,this._coreBrowserService),this._register(Z(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Z(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(qp,this._document,this._helperContainer),this._instantiationService.setService(Jl,this._charSizeService),this._themeService=this._instantiationService.createInstance(th),this._instantiationService.setService(eu,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Op),this._instantiationService.setService($l,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Cm,this.rows,this.screenElement)),this._instantiationService.setService(Zl,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(mp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(nm),this._instantiationService.setService(Xl,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Wg,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ap,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Gm,this.element,this.screenElement,r)),this._instantiationService.setService(Ql,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Nu.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(op,this.screenElement)),this._register(Z(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ug,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(dp,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(dp,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Kp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Z(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Z(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){vl(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=Ng(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(qg(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(dh));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`)}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function qg(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Jg=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Yg=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new kl)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Xg=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Yg(t)}getNullCell(){return new kl}},Zg=class extends Tu{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new X),this.onBufferChange=this._onBufferChange.event,this._normal=new Xg(this._core.buffers.normal,`normal`),this._alternate=new Xg(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Qg=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},$g=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},e_=[`cols`,`rows`],t_=0,n_=class extends Tu{constructor(e){super(),this._core=this._register(new Kg(e)),this._addonManager=this._register(new Jg),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(e_.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new Qg(this._core),this._parser}get unicode(){return this._checkProposedApi(),new $g(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new Zg(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
38
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return dl.get()},set promptLabel(e){dl.set(e)},get tooMuchOutput(){return pl.get()},set tooMuchOutput(e){pl.set(e)}}}_verifyIntegers(...e){for(t_ of e)if(t_===1/0||isNaN(t_)||t_%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(t_ of e)if(t_&&(t_===1/0||isNaN(t_)||t_%1!=0||t_<0))throw Error(`This API only accepts positive integers`)}},r_=class extends Error{code;detail;constructor(e,t,n){super(t),this.code=e,this.detail=n}},i_=[500,1e3,2e3,4e3,8e3,15e3],a_=4e3,o_=1e4,s_=class{url;token;conn=_({state:`connecting`,hello:null,failures:0});ws=null;nextId=1;pending=new Map;listeners=new Map;openHooks=new Set;retryTimer=null;deadline=null;constructor(e,t){this.url=e,this.token=t}start(){this.connect();let e=()=>{document.visibilityState===`visible`&&this.checkNow()};document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),window.addEventListener(`pageshow`,e)}checkNow(){if(this.retryTimer!==null){this.retryNow();return}let e=this.ws;!e||this.conn.get().state!==`open`||this.deadline!==null||(this.armDeadline(e,a_),this.request(`hello`).then(()=>this.clearDeadline(),e=>{e instanceof r_&&e.code!==`NOT_CONNECTED`&&this.clearDeadline()}))}armDeadline(e,t){this.clearDeadline(),this.deadline=window.setTimeout(()=>this.lost(e),t)}clearDeadline(){this.deadline!==null&&window.clearTimeout(this.deadline),this.deadline=null}onOpen(e){return this.openHooks.add(e),this.conn.get().state===`open`&&e(),()=>this.openHooks.delete(e)}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}request(e,t={},n){let r=this.ws;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new r_(`NOT_CONNECTED`,`not connected to rove`));let i=this.nextId++;return new Promise((a,o)=>{this.pending.set(i,{resolve:e=>a(e),reject:o,progress:n}),r.send(JSON.stringify({id:i,op:e,args:t}))})}connect(){this.retryTimer=null;let e=Ta(this.url,[`rove.v1`,`rove.bearer.${this.token}`]);this.ws=e,this.armDeadline(e,o_),e.onmessage=e=>this.receive(String(e.data)),e.onopen=()=>{this.request(`hello`).then(e=>{this.clearDeadline(),this.conn.set({state:`open`,hello:e,failures:0});for(let e of this.openHooks)e()},()=>this.lost(e))},e.onclose=()=>this.lost(e)}lost(e){if(this.ws!==e)return;this.ws=null,this.clearDeadline(),e.onopen=null,e.onclose=null,e.onmessage=null,e.close();for(let e of this.pending.values())e.reject(new r_(`NOT_CONNECTED`,`connection lost`));this.pending.clear();let t=this.conn.get().failures+1;this.conn.set({state:`retrying`,hello:this.conn.get().hello,failures:t});let n=i_[Math.min(t-1,i_.length-1)];this.retryTimer=window.setTimeout(()=>this.connect(),n)}receive(e){let t;try{t=JSON.parse(e)}catch{return}if(!t||typeof t!=`object`)return;if(`event`in t&&typeof t.event==`string`){let e=`data`in t?t.data:void 0;if(t.event===`op.progress`){let t=e;typeof t?.id==`number`&&typeof t.line==`string`&&this.pending.get(t.id)?.progress?.(t.line);return}for(let n of this.listeners.get(t.event)??[])n(e);return}if(!(`id`in t)||typeof t.id!=`number`)return;let n=this.pending.get(t.id);if(!n)return;if(this.pending.delete(t.id),`ok`in t&&t.ok===!0){n.resolve(`result`in t?t.result:void 0);return}let r=`error`in t&&t.error&&typeof t.error==`object`?t.error:{},i=`code`in r&&typeof r.code==`string`?r.code:`INTERNAL`,a=`message`in r&&typeof r.message==`string`?r.message:i;n.reject(new r_(i,a,r))}retryNow(){this.retryTimer!==null&&(window.clearTimeout(this.retryTimer),this.connect())}};function c_(){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}function l_(e,t){return e===`auto`?t?`dark`:`light`:e}function u_(e,t,n){let r=e.find(e=>e.name===t)??e.find(e=>e.name===`claude`);return r?r[n]:null}var d_=e=>[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16));function f_(e){let[t=0,n=0,r=0]=d_(e).map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r}function p_(e,t){let[n=0,r=0]=[f_(e),f_(t)].sort((e,t)=>t-e);return(n+.05)/(r+.05)}var m_=4.5,h_=1.1;function g_(e,t,n){let r=e=>t.every(t=>p_(e,t)>=n(t));if(r(e))return e;let i=d_(e),a=f_(t[0])<.18?255:0;for(let e=.02;e<1;e+=.02){let t=i.map(t=>Math.round(t+(a-t)*e).toString(16).padStart(2,`0`)).join(``);if(r(`#${t}`))return`#${t}`}return a?`#ffffff`:`#000000`}function __(e){let t=[e.background,e.backgroundPanel,e.backgroundElement,e.backgroundMenu],n=g_(e.diffLineNumber,t,()=>m_);return{muted:g_(e.textMuted,t,e=>Math.max(m_,p_(n,e)*h_)),subtle:n}}function v_(e,t){let n=t.colorblind===`on`,r=__(e);return{"--paper":e.background,"--surface":e.backgroundPanel,"--inset":e.backgroundElement,"--menu":e.backgroundMenu,"--line":e.border,"--line-active":e.borderActive,"--line-subtle":e.borderSubtle,"--ink":e.text,"--muted":r.muted,"--subtle":r.subtle,"--accent":e.primary,"--error":e.error,"--success":e.success,"--warning":e.warning,"--info":e.info,"--merged":e.syntaxType,"--focus":e[t.focusAccent]??e.primary,"--diff-added":(n?e.diffAddedColorblind:e.diffAdded)??e.diffAdded,"--diff-removed":e.diffRemoved,"--diff-added-bg":(n?e.diffAddedBgColorblind:e.diffAddedBg)??e.diffAddedBg,"--diff-removed-bg":e.diffRemovedBg}}function y_(e){return{background:e.background,foreground:e.text,cursor:e.primary,cursorAccent:e.background,selectionBackground:e.backgroundMenu,black:e.background,red:e.error,green:e.success,yellow:e.warning,blue:e.info,magenta:e.syntaxType,cyan:e.secondary,white:e.textMuted,brightBlack:e.diffLineNumber,brightRed:e.error,brightGreen:e.success,brightYellow:e.warning,brightBlue:e.info,brightMagenta:e.syntaxType,brightCyan:e.secondary,brightWhite:e.text}}var b_=_(null),x_=_(null),S_=`rove.prefs`,C_={locale:`en`,theme:`claude`,themeMode:`dark`,transparent:!0,focusAccent:`primary`,splitStyle:`line`,railFold:`glyphs`,workingBorder:`flow`,taskColors:`on`,glyphSet:`braille`,colorblind:`off`,runningTitle:`shimmer`,toast:!0,sound:!0,soundVolume:.4,crossTask:!0,finishedAlerts:!0,keyHints:!0,zen:!0,editorKind:`auto`,worktreeBase:`default`,scrollbackRows:1e3,tabStrip:`never`,prefixTap:`local`,remoteProjects:!1,autoStatus:!1,dispatcher:!1};function w_(){try{let e=JSON.parse(localStorage.getItem(S_)??`null`);if(e&&typeof e==`object`&&`prefs`in e&&`themes`in e)return{...e,loaded:!0}}catch{}return{loaded:!1,prefs:C_,options:{},info:{editorCustomSet:!1,worktreeCustomPath:``},themes:[],glyphSets:{}}}var T_=_(w_());function E_(e){(e.locale===`en`||e.locale===`zh`)&&Ce.set(e.locale)}E_(T_.get().prefs);function D_(e){let t={loaded:!0,prefs:e.prefs,options:e.options,info:e.info,themes:e.themes,glyphSets:e.glyphSets};T_.set(t),E_(t.prefs),localStorage.setItem(S_,JSON.stringify(t))}async function O_(e){D_(await e.request(`prefs.get`))}async function k_(e,t,n){let r=T_.get();T_.set({...r,prefs:{...r.prefs,[t]:n}}),E_(T_.get().prefs);try{let r=await e.request(`prefs.set`,{key:t,value:n});D_({...T_.get(),prefs:r.prefs})}catch(e){T_.set(r),E_(r.prefs),G(e instanceof Error?e.message:String(e),`error`)}}function A_(){return v(T_)}function j_(e,t){let n=e.options[t];return Array.isArray(n)?n:[]}var M_=900,N_=new WeakMap;function P_(e){e.setAttribute(`data-scrolling`,``),window.clearTimeout(N_.get(e)),N_.set(e,window.setTimeout(()=>e.removeAttribute(`data-scrolling`),M_))}function F_(){document.addEventListener(`scroll`,e=>{let t=e.target instanceof Element?e.target:document.scrollingElement;t&&P_(t)},{capture:!0,passive:!0})}var I_={background:`#141413`,foreground:`#eae7df`,cursor:`#cc785c`,cursorAccent:`#141413`,selectionBackground:`#33312e`,black:`#141413`,red:`#ec6f74`,green:`#9aca86`,yellow:`#e8c96b`,blue:`#61aaf2`,magenta:`#9b87f5`,cyan:`#d4967e`,white:`#a9a39a`,brightBlack:`#6b665f`,brightRed:`#ec6f74`,brightGreen:`#9aca86`,brightYellow:`#e8c96b`,brightBlue:`#61aaf2`,brightMagenta:`#9b87f5`,brightCyan:`#e0ab96`,brightWhite:`#eae7df`},L_=`Rove Nerd Symbols`,R_=[`"JetBrains Mono"`,`"${L_}"`,`"SF Mono"`,`ui-monospace`,`Menlo`,`monospace`].join(`, `),z_=1500;function B_(e,t,n){let r=null,i=null,a=null,o=()=>{let t=e.element?.querySelector(`.xterm-screen`);if(!r||!t||e.rows<=0||e.cols<=0)return;let n=document.createElement(`canvas`).getContext(`2d`);n&&(n.font=`${e.options.fontSize??13}px ${R_}`);let i=n?.measureText(`W`).width??0;r.style.setProperty(`--row-h`,`${t.clientHeight/e.rows}px`),i>0&&(r.style.letterSpacing=`${t.clientWidth/e.cols-i}px`)},s=()=>{r?.remove(),r=null,i?.dispose(),i=null,a!==null&&window.clearTimeout(a),a=null};return{snapshot:()=>n.serializeAsHTML({scrollback:0,includeGlobalBackground:!0}),raise(n){s(),r=document.createElement(`div`),r.className=jt,r.innerHTML=n,r.style.backgroundColor=(b_.get()??I_).background??``,t.append(r),o(),requestAnimationFrame(o),i=e.onResize(o),a=window.setTimeout(s,z_)},lower:s,get raised(){return r!==null}}}var V_=``,H_=new Intl.Segmenter(void 0,{granularity:`grapheme`}),U_=/^(?:insertText|insertReplacementText|insertTranscription|delete\w+|history(?:Undo|Redo))$/;function W_(e,t){let n=Array.from(H_.segment(e),e=>e.segment),r=Array.from(H_.segment(t),e=>e.segment),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.map(e=>/[\r\n]/.test(e)).lastIndexOf(!0)+1;return V_.repeat(n.length-Math.max(i,a))+r.slice(i).join(``)}function G_(e,t,n,r){return!U_.test(e)||e===`insertText`&&t&&r===n+t?null:W_(n,r)}function K_(e,t,n){return W_(e+n.substring(t),n)}function q_(e,t){let n=e.textarea,r=e.element;if(!n||!r)return()=>{};let i=``,a=``,o=!1,s=``,c=0,l=!1,u=e=>{(e.keyCode===229||e.key===`Process`||e.key===`Unidentified`)&&(l=!0)},d=()=>{l=!1},f=()=>{a=n.value===i?i:``},p=e=>{let r=e;if(r.target===n){if(r.inputType===`insertFromPaste`)n.value=``;else if(!r.isComposing&&!l){let e=G_(r.inputType,r.data,a,n.value);e!==null&&(r.stopImmediatePropagation(),e&&t(e))}i=a=n.value}},m=()=>{o=!0,s=n.value===i?i:``,c=n.value.length},h=()=>{o=!1;let[e,r]=[s,c];setTimeout(()=>{let s=o?``:K_(e,r,n.value);s&&t(s),i=a=n.value},0)},g=()=>{let{selectionStart:e,selectionEnd:r,value:a}=n;if(e===r||o||a!==i)return;let s=W_(a,a.slice(0,e)+a.slice(r));s&&t(s)},_=()=>{!o&&n.value&&(n.value=``),i=a=n.value,l=!1};r.addEventListener(`keydown`,u,!0),r.addEventListener(`keyup`,d,!0),r.addEventListener(`beforeinput`,f,!0),r.addEventListener(`input`,p,!0),r.addEventListener(`compositionstart`,m,!0),r.addEventListener(`compositionend`,h),r.addEventListener(`paste`,g,!0),n.addEventListener(`blur`,_);let v=e.onKey(_);return()=>{r.removeEventListener(`keydown`,u,!0),r.removeEventListener(`keyup`,d,!0),r.removeEventListener(`beforeinput`,f,!0),r.removeEventListener(`input`,p,!0),r.removeEventListener(`compositionstart`,m,!0),r.removeEventListener(`compositionend`,h),r.removeEventListener(`paste`,g,!0),n.removeEventListener(`blur`,_),v.dispose()}}var J_=2,Y_=1,X_=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(J_,Math.floor(u/e.css.cell.width)),rows:Math.max(Y_,Math.floor(l/e.css.cell.height))}}},Z_=class extends X_{term;constructor(e){super(),this.term=e}proposeDimensions(){let e=super.proposeDimensions(),t=this.term.element,n=t?.parentElement,r=this.term._core?._renderService?.dimensions?.css.cell.width;if(!e||!t||!n||!r)return e;let i=getComputedStyle(t),a=Number.parseInt(getComputedStyle(n).width)-Number.parseInt(i.paddingLeft)-Number.parseInt(i.paddingRight);return{cols:Math.max(e.cols,Math.floor(a/r)),rows:e.rows}}},Q_=64,$_=33554432,ev=27,tv=new TextDecoder(`latin1`);function nv(e){let t=new Map;for(let n of e.split(`,`)){let e=n.indexOf(`=`);e>0&&t.set(n.slice(0,e),n.slice(e+1))}return t}function rv(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function iv(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}async function av(e,t){let n=rv(t);e.get(`o`)===`z`&&(n=await iv(n));let r=e.get(`f`)??`32`;if(r===`100`)return createImageBitmap(new Blob([n],{type:`image/png`}));let i=Number(e.get(`s`)),a=Number(e.get(`v`)),o=r===`24`?3:r===`32`?4:0;if(!o||!(i>0&&a>0)||n.length<i*a*o)return null;let s=new Uint8ClampedArray(i*a*4);for(let e=0;e<i*a;e++)s[e*4]=n[e*o],s[e*4+1]=n[e*o+1],s[e*4+2]=n[e*o+2],s[e*4+3]=o===4?n[e*4+3]:255;return createImageBitmap(new ImageData(s,i,a))}var ov=class{changed;images=new Map;apc=null;apcBytes=0;escPending=!1;upload=null;constructor(e){this.changed=e}push(e){let t=0;for(this.escPending&&e.length>0&&(this.escPending=!1,this.apc&&e[0]===92?(this.finish(),t=1):(this.apc=null,e[0]===95&&(this.apc=[],this.apcBytes=0,t=1)));t<e.length;){let n=e.indexOf(ev,t);if(this.apc){if(n===-1){this.append(e.subarray(t));return}if(this.append(e.subarray(t,n)),n+1>=e.length){this.escPending=!0;return}e[n+1]===92?this.finish():this.apc=null,t=n+2;continue}if(n===-1)return;if(n+1>=e.length){this.escPending=!0;return}e[n+1]===95?(this.apc=[],this.apcBytes=0,t=n+2):t=n+1}}append(e){!this.apc||e.length===0||(this.apcBytes+=e.length,this.apcBytes>$_?this.apc=null:this.apc.push(e.slice()))}finish(){let e=this.apc;if(this.apc=null,!e)return;let t=e.map(e=>tv.decode(e)).join(``);if(t[0]!==`G`)return;let n=t.indexOf(`;`),r=nv(n===-1?t.slice(1):t.slice(1,n));this.command(r,n===-1?``:t.slice(n+1))}command(e,t){if(this.upload&&[...e.keys()].every(e=>e===`m`||e===`q`)){if(this.upload.parts.push(t),e.get(`m`)!==`1`){let{keys:e,parts:t}=this.upload;this.upload=null,this.transmitted(e,t.join(``))}return}this.upload=null;let n=e.get(`a`)??`t`;if(n===`t`||n===`T`){if((e.get(`t`)??`d`)!==`d`)return;e.get(`m`)===`1`?this.upload={keys:e,parts:[t]}:this.transmitted(e,t)}else n===`p`?this.placed(e):n===`d`&&this.deleted(e)}entry(e){let t=this.images.get(e)??{cols:null,rows:null,bitmap:null};this.images.delete(e),this.images.set(e,t);for(let e of this.images.keys()){if(this.images.size<=Q_)break;this.images.get(e)?.bitmap?.close(),this.images.delete(e)}return t}transmitted(e,t){let n=Number(e.get(`i`));if(!(n>0))return;let r=this.entry(n);e.get(`a`)===`T`&&this.placed(e),av(e,t).then(e=>{if(e){if(this.images.get(n)!==r)return e.close();r.bitmap?.close(),r.bitmap=e,this.changed()}}).catch(()=>{})}placed(e){let t=Number(e.get(`i`));if(!(t>0)||e.get(`U`)!==`1`)return;let n=this.entry(t),r=Number(e.get(`c`)),i=Number(e.get(`r`));n.cols=r>0?r:null,n.rows=i>0?i:null,this.changed()}deleted(e){let t=e.get(`d`)??`a`;if(t!==`i`&&t!==`I`)return;let n=Number(e.get(`i`));this.images.get(n)?.bitmap?.close(),this.images.delete(n)&&this.changed()}dispose(){for(let e of this.images.values())e.bitmap?.close();this.images.clear()}},sv=`305-305 30d-30e 310-310 312-312 33d-33f 346-346 34a-34c 350-352 357-357 35b-35b 363-36f 483-487
38
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return dl.get()},set promptLabel(e){dl.set(e)},get tooMuchOutput(){return pl.get()},set tooMuchOutput(e){pl.set(e)}}}_verifyIntegers(...e){for(t_ of e)if(t_===1/0||isNaN(t_)||t_%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(t_ of e)if(t_&&(t_===1/0||isNaN(t_)||t_%1!=0||t_<0))throw Error(`This API only accepts positive integers`)}},r_=class extends Error{code;detail;constructor(e,t,n){super(t),this.code=e,this.detail=n}},i_=[500,1e3,2e3,4e3,8e3,15e3],a_=4e3,o_=1e4,s_=class{url;token;conn=_({state:`connecting`,hello:null,failures:0});ws=null;nextId=1;pending=new Map;listeners=new Map;openHooks=new Set;retryTimer=null;deadline=null;constructor(e,t){this.url=e,this.token=t}start(){this.connect();let e=()=>{document.visibilityState===`visible`&&this.checkNow()};document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),window.addEventListener(`pageshow`,e)}checkNow(){if(this.retryTimer!==null){this.retryNow();return}let e=this.ws;!e||this.conn.get().state!==`open`||this.deadline!==null||(this.armDeadline(e,a_),this.request(`hello`).then(()=>this.clearDeadline(),e=>{e instanceof r_&&e.code!==`NOT_CONNECTED`&&this.clearDeadline()}))}armDeadline(e,t){this.clearDeadline(),this.deadline=window.setTimeout(()=>this.lost(e),t)}clearDeadline(){this.deadline!==null&&window.clearTimeout(this.deadline),this.deadline=null}onOpen(e){return this.openHooks.add(e),this.conn.get().state===`open`&&e(),()=>this.openHooks.delete(e)}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}request(e,t={},n){let r=this.ws;if(!r||r.readyState!==WebSocket.OPEN)return Promise.reject(new r_(`NOT_CONNECTED`,`not connected to rove`));let i=this.nextId++;return new Promise((a,o)=>{this.pending.set(i,{resolve:e=>a(e),reject:o,progress:n}),r.send(JSON.stringify({id:i,op:e,args:t}))})}connect(){this.retryTimer=null;let e=Ta(this.url,[`rove.v1`,`rove.bearer.${this.token}`]);this.ws=e,this.armDeadline(e,o_),e.onmessage=e=>this.receive(String(e.data)),e.onopen=()=>{this.request(`hello`).then(e=>{this.clearDeadline(),this.conn.set({state:`open`,hello:e,failures:0});for(let e of this.openHooks)e()},()=>this.lost(e))},e.onclose=()=>this.lost(e)}lost(e){if(this.ws!==e)return;this.ws=null,this.clearDeadline(),e.onopen=null,e.onclose=null,e.onmessage=null,e.close();for(let e of this.pending.values())e.reject(new r_(`NOT_CONNECTED`,`connection lost`));this.pending.clear();let t=this.conn.get().failures+1;this.conn.set({state:`retrying`,hello:this.conn.get().hello,failures:t});let n=i_[Math.min(t-1,i_.length-1)];this.retryTimer=window.setTimeout(()=>this.connect(),n)}receive(e){let t;try{t=JSON.parse(e)}catch{return}if(!t||typeof t!=`object`)return;if(`event`in t&&typeof t.event==`string`){let e=`data`in t?t.data:void 0;if(t.event===`op.progress`){let t=e;typeof t?.id==`number`&&typeof t.line==`string`&&this.pending.get(t.id)?.progress?.(t.line);return}for(let n of this.listeners.get(t.event)??[])n(e);return}if(!(`id`in t)||typeof t.id!=`number`)return;let n=this.pending.get(t.id);if(!n)return;if(this.pending.delete(t.id),`ok`in t&&t.ok===!0){n.resolve(`result`in t?t.result:void 0);return}let r=`error`in t&&t.error&&typeof t.error==`object`?t.error:{},i=`code`in r&&typeof r.code==`string`?r.code:`INTERNAL`,a=`message`in r&&typeof r.message==`string`?r.message:i;n.reject(new r_(i,a,r))}retryNow(){this.retryTimer!==null&&(window.clearTimeout(this.retryTimer),this.connect())}};function c_(){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}function l_(e,t){return e===`auto`?t?`dark`:`light`:e}function u_(e,t,n){let r=e.find(e=>e.name===t)??e.find(e=>e.name===`claude`);return r?r[n]:null}var d_=e=>[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16));function f_(e){let[t=0,n=0,r=0]=d_(e).map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r}function p_(e,t){let[n=0,r=0]=[f_(e),f_(t)].sort((e,t)=>t-e);return(n+.05)/(r+.05)}var m_=4.5,h_=1.1;function g_(e,t,n){let r=e=>t.every(t=>p_(e,t)>=n(t));if(r(e))return e;let i=d_(e),a=f_(t[0])<.18?255:0;for(let e=.02;e<1;e+=.02){let t=i.map(t=>Math.round(t+(a-t)*e).toString(16).padStart(2,`0`)).join(``);if(r(`#${t}`))return`#${t}`}return a?`#ffffff`:`#000000`}function __(e){let t=[e.background,e.backgroundPanel,e.backgroundElement,e.backgroundMenu],n=g_(e.diffLineNumber,t,()=>m_);return{muted:g_(e.textMuted,t,e=>Math.max(m_,p_(n,e)*h_)),subtle:n}}function v_(e,t){let n=t.colorblind===`on`,r=__(e);return{"--paper":e.background,"--surface":e.backgroundPanel,"--inset":e.backgroundElement,"--menu":e.backgroundMenu,"--line":e.border,"--line-active":e.borderActive,"--line-subtle":e.borderSubtle,"--ink":e.text,"--muted":r.muted,"--subtle":r.subtle,"--accent":e.primary,"--error":e.error,"--success":e.success,"--warning":e.warning,"--info":e.info,"--merged":e.syntaxType,"--focus":e[t.focusAccent]??e.primary,"--diff-added":(n?e.diffAddedColorblind:e.diffAdded)??e.diffAdded,"--diff-removed":e.diffRemoved,"--diff-added-bg":(n?e.diffAddedBgColorblind:e.diffAddedBg)??e.diffAddedBg,"--diff-removed-bg":e.diffRemovedBg}}function y_(e){return{background:e.background,foreground:e.text,cursor:e.primary,cursorAccent:e.background,selectionBackground:e.backgroundMenu,black:e.background,red:e.error,green:e.success,yellow:e.warning,blue:e.info,magenta:e.syntaxType,cyan:e.secondary,white:e.textMuted,brightBlack:e.diffLineNumber,brightRed:e.error,brightGreen:e.success,brightYellow:e.warning,brightBlue:e.info,brightMagenta:e.syntaxType,brightCyan:e.secondary,brightWhite:e.text}}var b_=_(null),x_=_(null),S_=`rove.prefs`,C_={locale:`en`,theme:`claude`,themeMode:`dark`,transparent:!0,focusAccent:`primary`,splitStyle:`line`,railFold:`glyphs`,workingBorder:`flow`,taskColors:`on`,glyphSet:`braille`,colorblind:`off`,runningTitle:`shimmer`,toast:!0,sound:!0,soundVolume:.4,crossTask:!0,finishedAlerts:!0,keyHints:!0,zen:!0,editorKind:`auto`,worktreeBase:`default`,scrollbackRows:1e3,tabStrip:`never`,prefixTap:`local`,remoteProjects:!1,autoStatus:!1,dispatcher:!1,updateChannel:`latest`,updateNotify:!0};function w_(){try{let e=JSON.parse(localStorage.getItem(S_)??`null`);if(e&&typeof e==`object`&&`prefs`in e&&`themes`in e){let t=e;return{...t,prefs:{...C_,...t.prefs},loaded:!0}}}catch{}return{loaded:!1,prefs:C_,options:{},info:{editorCustomSet:!1,worktreeCustomPath:``},themes:[],glyphSets:{}}}var T_=_(w_());function E_(e){(e.locale===`en`||e.locale===`zh`)&&Ce.set(e.locale)}E_(T_.get().prefs);function D_(e){let t={loaded:!0,prefs:e.prefs,options:e.options,info:e.info,themes:e.themes,glyphSets:e.glyphSets};T_.set(t),E_(t.prefs),localStorage.setItem(S_,JSON.stringify(t))}async function O_(e){D_(await e.request(`prefs.get`))}async function k_(e,t,n){let r=T_.get();T_.set({...r,prefs:{...r.prefs,[t]:n}}),E_(T_.get().prefs);try{let r=await e.request(`prefs.set`,{key:t,value:n});D_({...T_.get(),prefs:r.prefs})}catch(e){T_.set(r),E_(r.prefs),G(e instanceof Error?e.message:String(e),`error`)}}function A_(){return v(T_)}function j_(e,t){let n=e.options[t];return Array.isArray(n)?n:[]}var M_=900,N_=new WeakMap;function P_(e){e.setAttribute(`data-scrolling`,``),window.clearTimeout(N_.get(e)),N_.set(e,window.setTimeout(()=>e.removeAttribute(`data-scrolling`),M_))}function F_(){document.addEventListener(`scroll`,e=>{let t=e.target instanceof Element?e.target:document.scrollingElement;t&&P_(t)},{capture:!0,passive:!0})}var I_={background:`#141413`,foreground:`#eae7df`,cursor:`#cc785c`,cursorAccent:`#141413`,selectionBackground:`#33312e`,black:`#141413`,red:`#ec6f74`,green:`#9aca86`,yellow:`#e8c96b`,blue:`#61aaf2`,magenta:`#9b87f5`,cyan:`#d4967e`,white:`#a9a39a`,brightBlack:`#6b665f`,brightRed:`#ec6f74`,brightGreen:`#9aca86`,brightYellow:`#e8c96b`,brightBlue:`#61aaf2`,brightMagenta:`#9b87f5`,brightCyan:`#e0ab96`,brightWhite:`#eae7df`},L_=`Rove Nerd Symbols`,R_=[`"JetBrains Mono"`,`"${L_}"`,`"SF Mono"`,`ui-monospace`,`Menlo`,`monospace`].join(`, `),z_=1500;function B_(e,t,n){let r=null,i=null,a=null,o=()=>{let t=e.element?.querySelector(`.xterm-screen`);if(!r||!t||e.rows<=0||e.cols<=0)return;let n=document.createElement(`canvas`).getContext(`2d`);n&&(n.font=`${e.options.fontSize??13}px ${R_}`);let i=n?.measureText(`W`).width??0;r.style.setProperty(`--row-h`,`${t.clientHeight/e.rows}px`),i>0&&(r.style.letterSpacing=`${t.clientWidth/e.cols-i}px`)},s=()=>{r?.remove(),r=null,i?.dispose(),i=null,a!==null&&window.clearTimeout(a),a=null};return{snapshot:()=>n.serializeAsHTML({scrollback:0,includeGlobalBackground:!0}),raise(n){s(),r=document.createElement(`div`),r.className=jt,r.innerHTML=n,r.style.backgroundColor=(b_.get()??I_).background??``,t.append(r),o(),requestAnimationFrame(o),i=e.onResize(o),a=window.setTimeout(s,z_)},lower:s,get raised(){return r!==null}}}var V_=``,H_=new Intl.Segmenter(void 0,{granularity:`grapheme`}),U_=/^(?:insertText|insertReplacementText|insertTranscription|delete\w+|history(?:Undo|Redo))$/;function W_(e,t){let n=Array.from(H_.segment(e),e=>e.segment),r=Array.from(H_.segment(t),e=>e.segment),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.map(e=>/[\r\n]/.test(e)).lastIndexOf(!0)+1;return V_.repeat(n.length-Math.max(i,a))+r.slice(i).join(``)}function G_(e,t,n,r){return!U_.test(e)||e===`insertText`&&t&&r===n+t?null:W_(n,r)}function K_(e,t,n){return W_(e+n.substring(t),n)}function q_(e,t){let n=e.textarea,r=e.element;if(!n||!r)return()=>{};let i=``,a=``,o=!1,s=``,c=0,l=!1,u=e=>{(e.keyCode===229||e.key===`Process`||e.key===`Unidentified`)&&(l=!0)},d=()=>{l=!1},f=()=>{a=n.value===i?i:``},p=e=>{let r=e;if(r.target===n){if(r.inputType===`insertFromPaste`)n.value=``;else if(!r.isComposing&&!l){let e=G_(r.inputType,r.data,a,n.value);e!==null&&(r.stopImmediatePropagation(),e&&t(e))}i=a=n.value}},m=()=>{o=!0,s=n.value===i?i:``,c=n.value.length},h=()=>{o=!1;let[e,r]=[s,c];setTimeout(()=>{let s=o?``:K_(e,r,n.value);s&&t(s),i=a=n.value},0)},g=()=>{let{selectionStart:e,selectionEnd:r,value:a}=n;if(e===r||o||a!==i)return;let s=W_(a,a.slice(0,e)+a.slice(r));s&&t(s)},_=()=>{!o&&n.value&&(n.value=``),i=a=n.value,l=!1};r.addEventListener(`keydown`,u,!0),r.addEventListener(`keyup`,d,!0),r.addEventListener(`beforeinput`,f,!0),r.addEventListener(`input`,p,!0),r.addEventListener(`compositionstart`,m,!0),r.addEventListener(`compositionend`,h),r.addEventListener(`paste`,g,!0),n.addEventListener(`blur`,_);let v=e.onKey(_);return()=>{r.removeEventListener(`keydown`,u,!0),r.removeEventListener(`keyup`,d,!0),r.removeEventListener(`beforeinput`,f,!0),r.removeEventListener(`input`,p,!0),r.removeEventListener(`compositionstart`,m,!0),r.removeEventListener(`compositionend`,h),r.removeEventListener(`paste`,g,!0),n.removeEventListener(`blur`,_),v.dispose()}}var J_=2,Y_=1,X_=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(J_,Math.floor(u/e.css.cell.width)),rows:Math.max(Y_,Math.floor(l/e.css.cell.height))}}},Z_=class extends X_{term;constructor(e){super(),this.term=e}proposeDimensions(){let e=super.proposeDimensions(),t=this.term.element,n=t?.parentElement,r=this.term._core?._renderService?.dimensions?.css.cell.width;if(!e||!t||!n||!r)return e;let i=getComputedStyle(t),a=Number.parseInt(getComputedStyle(n).width)-Number.parseInt(i.paddingLeft)-Number.parseInt(i.paddingRight);return{cols:Math.max(e.cols,Math.floor(a/r)),rows:e.rows}}},Q_=64,$_=33554432,ev=27,tv=new TextDecoder(`latin1`);function nv(e){let t=new Map;for(let n of e.split(`,`)){let e=n.indexOf(`=`);e>0&&t.set(n.slice(0,e),n.slice(e+1))}return t}function rv(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function iv(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}async function av(e,t){let n=rv(t);e.get(`o`)===`z`&&(n=await iv(n));let r=e.get(`f`)??`32`;if(r===`100`)return createImageBitmap(new Blob([n],{type:`image/png`}));let i=Number(e.get(`s`)),a=Number(e.get(`v`)),o=r===`24`?3:r===`32`?4:0;if(!o||!(i>0&&a>0)||n.length<i*a*o)return null;let s=new Uint8ClampedArray(i*a*4);for(let e=0;e<i*a;e++)s[e*4]=n[e*o],s[e*4+1]=n[e*o+1],s[e*4+2]=n[e*o+2],s[e*4+3]=o===4?n[e*4+3]:255;return createImageBitmap(new ImageData(s,i,a))}var ov=class{changed;images=new Map;apc=null;apcBytes=0;escPending=!1;upload=null;constructor(e){this.changed=e}push(e){let t=0;for(this.escPending&&e.length>0&&(this.escPending=!1,this.apc&&e[0]===92?(this.finish(),t=1):(this.apc=null,e[0]===95&&(this.apc=[],this.apcBytes=0,t=1)));t<e.length;){let n=e.indexOf(ev,t);if(this.apc){if(n===-1){this.append(e.subarray(t));return}if(this.append(e.subarray(t,n)),n+1>=e.length){this.escPending=!0;return}e[n+1]===92?this.finish():this.apc=null,t=n+2;continue}if(n===-1)return;if(n+1>=e.length){this.escPending=!0;return}e[n+1]===95?(this.apc=[],this.apcBytes=0,t=n+2):t=n+1}}append(e){!this.apc||e.length===0||(this.apcBytes+=e.length,this.apcBytes>$_?this.apc=null:this.apc.push(e.slice()))}finish(){let e=this.apc;if(this.apc=null,!e)return;let t=e.map(e=>tv.decode(e)).join(``);if(t[0]!==`G`)return;let n=t.indexOf(`;`),r=nv(n===-1?t.slice(1):t.slice(1,n));this.command(r,n===-1?``:t.slice(n+1))}command(e,t){if(this.upload&&[...e.keys()].every(e=>e===`m`||e===`q`)){if(this.upload.parts.push(t),e.get(`m`)!==`1`){let{keys:e,parts:t}=this.upload;this.upload=null,this.transmitted(e,t.join(``))}return}this.upload=null;let n=e.get(`a`)??`t`;if(n===`t`||n===`T`){if((e.get(`t`)??`d`)!==`d`)return;e.get(`m`)===`1`?this.upload={keys:e,parts:[t]}:this.transmitted(e,t)}else n===`p`?this.placed(e):n===`d`&&this.deleted(e)}entry(e){let t=this.images.get(e)??{cols:null,rows:null,bitmap:null};this.images.delete(e),this.images.set(e,t);for(let e of this.images.keys()){if(this.images.size<=Q_)break;this.images.get(e)?.bitmap?.close(),this.images.delete(e)}return t}transmitted(e,t){let n=Number(e.get(`i`));if(!(n>0))return;let r=this.entry(n);e.get(`a`)===`T`&&this.placed(e),av(e,t).then(e=>{if(e){if(this.images.get(n)!==r)return e.close();r.bitmap?.close(),r.bitmap=e,this.changed()}}).catch(()=>{})}placed(e){let t=Number(e.get(`i`));if(!(t>0)||e.get(`U`)!==`1`)return;let n=this.entry(t),r=Number(e.get(`c`)),i=Number(e.get(`r`));n.cols=r>0?r:null,n.rows=i>0?i:null,this.changed()}deleted(e){let t=e.get(`d`)??`a`;if(t!==`i`&&t!==`I`)return;let n=Number(e.get(`i`));this.images.get(n)?.bitmap?.close(),this.images.delete(n)&&this.changed()}dispose(){for(let e of this.images.values())e.bitmap?.close();this.images.clear()}},sv=`305-305 30d-30e 310-310 312-312 33d-33f 346-346 34a-34c 350-352 357-357 35b-35b 363-36f 483-487
39
39
  592-595 597-599 59c-5a1 5a8-5a9 5ab-5ac 5af-5af 5c4-5c4 610-617 657-65b 65d-65e 6d6-6dc 6df-6e2
40
40
  6e4-6e4 6e7-6e8 6eb-6ec 730-730 732-733 735-736 73a-73a 73d-73d 73f-741 743-743 745-745 747-747
41
41
  749-74a 7eb-7f1 7f3-7f3 816-819 81b-823 825-827 829-82d 951-951 953-954 f82-f83 f86-f87 135d-135f
@@ -111,42 +111,42 @@ void main() {
111
111
  `)}),i===`gate`&&a&&(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:a.options.map(e=>(0,V.jsxs)(H,{disabled:d,title:e.detail,onClick:()=>void p(()=>_T(t,a.id,{option:e.key})),children:[`[ `,e.key===a.recommended?`★ `:``,e.label,` ]`]},e.key))}),i===`menu`&&r&&(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[yv.map(e=>(0,V.jsxs)(H,{disabled:d,onClick:()=>void p(()=>gT(t,n,r,e.bytes(!1))),children:[`[ `,e.cap,` ]`]},e.id)),(0,V.jsx)(H,{onClick:e.onOpenTab,children:z(`inbox.openTab`)})]}),(i===`reply`||i===`gate`)&&(0,V.jsxs)(`form`,{className:`flex min-w-0 items-center gap-2`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,V.jsx)(`input`,{className:`min-w-0 flex-1 rounded-sm border-hairline border-line bg-paper px-2 py-1.5 font-mono text-ink focus-visible:border-line-active focus-visible:outline-none touch:min-h-10 touch:text-display`,value:l,disabled:d,placeholder:z(`inbox.replyPlaceholder`),"aria-label":z(`inbox.replyPlaceholder`),autoComplete:`off`,enterKeyHint:`send`,onChange:e=>u(e.target.value)}),(0,V.jsx)(H,{type:`submit`,disabled:d||l.trim()===``,children:z(`inbox.send`)})]})]})}function ST({text:e}){return(0,V.jsx)(`span`,{className:`inline-flex flex-wrap gap-x-3 gap-y-0`,children:e.split(`·`).map(e=>e.trim()).filter(Boolean).map(e=>(0,V.jsx)(`span`,{children:e},e))})}var CT={accent:`text-accent`,muted:`text-subtle`,attention:`text-error`,warning:`text-warning`,info:`text-info`,success:`text-success`,added:`text-diff-added`,removed:`text-diff-removed`},wT={accent:`text-accent`,muted:`text-subtle`,attention:`text-error`,warning:`text-warning`,success:`text-success`,info:`text-accent`,ink:`text-ink`},TT=6;function ET(e,t){return e?`${e.repo.split(`/`).filter(Boolean).pop()??e.repo} › ${e.label}`:t}function DT({model:e}){B();let t=v(e.tasks),n=v(e.visits),r=v(e.tabs),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(Date.now());(0,g.useEffect)(()=>{let e=window.setInterval(()=>l(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let u=new Map((t?.tasks??[]).map(e=>[e.id,e])),d=(e,t)=>e&&t&&r[e]?.find(e=>e.id===t)?.title||``,f=Fo(t?.attention??[],t?.tasks.map(e=>e.id)??[]).map((e,t)=>{let n=e.taskId?u.get(e.taskId):void 0;return{key:`a${t}:${e.taskId}:${e.tabId}`,section:`attention`,taskId:e.taskId,tabId:e.tabId,identity:ET(n,e.label??e.taskId??``),subtitle:d(e.taskId,e.tabId)||n?.branch||``,at:e.at,attention:e}}),p=new Set(f.map(e=>`${e.taskId}:${e.tabId}`)),m=n.filter(e=>u.has(e.taskId)&&!p.has(`${e.taskId}:${e.tabId}`)).slice(0,TT).map(e=>({key:`r:${e.taskId}:${e.tabId}`,section:`recent`,taskId:e.taskId,tabId:e.tabId,identity:ET(u.get(e.taskId),e.taskId),subtitle:d(e.taskId,e.tabId)||u.get(e.taskId)?.branch||``,at:e.at})),h=[...f,...m],_=h[Math.min(i,h.length-1)],y=async t=>{if(t.attention&&No(t.attention.state))return ko(e,t.attention);!t.attention?.taskId||t.attention.gateId||await e.client.request(`attention.dismiss`,{taskId:t.attention.taskId,...t.tabId?{tabId:t.tabId}:{}}).catch(e=>G(String(e),`error`))},b=t=>{if(t.attention&&No(t.attention.state))return Ao(e,t.attention);t.attention&&y(t),t.taskId&&u.has(t.taskId)&&(e.select(t.taskId,t.tabId),yn())};(0,g.useEffect)(()=>{let e=e=>{if(!(e.target instanceof HTMLElement&&e.target.closest(`input, textarea`))){if(e.key===`ArrowDown`||e.key===`j`)a(e=>Math.min(h.length-1,e+1));else if(e.key===`ArrowUp`||e.key===`k`)a(e=>Math.max(0,e-1));else if(e.key===`Enter`&&_)b(_);else if(e.key===`d`&&_?.attention)y(_);else return;e.preventDefault()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let x=n=>{let r=n.attention?jo(n.attention.state):null,i=n===_,l=n.attention,d=n.taskId?u.get(n.taskId):void 0,f=l?.gateId?t?.gates?.find(e=>e.id===l.gateId&&e.status===`open`):void 0,p=n.tabId??f?.tabId??null,m=!!l&&!!d&&!d.machine&&!No(l.state)&&(!l.gateId||!!f)&&(!!p||!!f),g=l?.state===`permission_needed`||!!p&&d?.tabStatus?.[p]?.kind===`needs-input`,v=f?`gate`:l?.state===`dead`?`readonly`:g?`menu`:`reply`,y=`${n.taskId}:${n.tabId}:${l?.gateId??``}`,x=m&&o===y;return(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`div`,{className:Jn,children:[(0,V.jsxs)(`button`,{type:`button`,className:`${Qn({selected:i,stack:!0})} ${Yn}`,onMouseEnter:()=>a(h.indexOf(n)),onClick:()=>b(n),children:[(0,V.jsxs)(`span`,{className:Kn,children:[(0,V.jsx)(`span`,{className:$n,children:n.identity}),r&&(0,V.jsxs)(`span`,{className:`flex-none font-mono text-meta font-normal normal-nums ${wT[r.tone]}`,children:[r.glyph,` `,z(r.stateKey)]}),(0,V.jsx)(`span`,{className:qn,children:Mo(c-n.at)})]}),n.subtitle&&(0,V.jsx)(`span`,{className:`truncate font-mono text-meta font-normal normal-nums text-muted`,children:n.subtitle})]}),m&&(0,V.jsx)(H,{className:`flex-none whitespace-nowrap pr-2 font-mono text-meta`,"aria-expanded":x,onClick:()=>{a(h.indexOf(n)),s(x?null:y)},children:z(x?`inbox.hide`:`inbox.reply`)})]}),x&&n.taskId&&(0,V.jsx)(xT,{model:e,taskId:n.taskId,tabId:p,mode:v,gate:f,onOpenTab:()=>b(n)})]},n.key)};return(0,V.jsx)(ir,{title:z(`inbox.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsx)(`p`,{className:`${U} text-muted ${Un} touch:hidden!`,children:(0,V.jsx)(ST,{text:z(`inbox.hints`)})}),(0,V.jsx)(`h2`,{className:`${U} text-muted ${Wn}`,children:z(`inbox.attention`)}),f.length===0?(0,V.jsx)(`p`,{className:`mono text-muted`,children:z(`inbox.empty`)}):(0,V.jsx)(`ul`,{className:Gn,children:f.map(x)}),m.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted mt-1`,children:z(`inbox.recent`)}),(0,V.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:m.map(x)})]})]})})}var OT=[`project`,`state`],kT=`rove.railGroup`,AT=_(OT.find(e=>e===localStorage.getItem(kT))??`project`);function jT(e){AT.set(e),localStorage.setItem(kT,e)}var MT=`rove.activeSortMode`;function NT(){let e=localStorage.getItem(MT);return YC.find(t=>t===e)??`recent`}var PT=_(NT());function FT(e){PT.set(e),localStorage.setItem(MT,e)}function IT(){FT(YC[(YC.indexOf(PT.get())+1)%YC.length]??`default`)}var LT=_(!1),RT=_(null);function zT(e){e&&(PT.get()!=="default"||AT.get()===`state`)&&(FT(`default`),jT(`project`),G(q(`tasks`,`sort.reorderSwitched`))),e||RT.set(null),LT.set(e)}async function BT(e,t,n){let r=n<0?`up`:`down`;try{await e.client.request(`task.move`,{taskId:t.task.id,direction:r})}catch(e){G(q(`tasks`,`toast.moveFailed`,{error:e instanceof Error?e.message:String(e)}),`error`)}}async function VT(e,t,n){let r=n<0?`up`:`down`;try{for(let i=0;i<Math.abs(n);i++)await e.client.request(`task.move`,{taskId:t,direction:r})}catch(e){G(q(`tasks`,`toast.moveFailed`,{error:e instanceof Error?e.message:String(e)}),`error`)}}async function HT(e,t,n){if(n.pin!==void 0)try{await e.client.request(`task.pin`,{taskId:t,pinned:n.pin})}catch(e){G(q(`tasks`,`toast.moveFailed`,{error:e instanceof Error?e.message:String(e)}),`error`);return}await VT(e,t,n.steps)}var UT=`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,WT=`before:absolute before:top-0 before:left-1 before:content-[''] before:[border-left:var(--hairline)_solid_var(--line-active)]`,GT={blank:``,pipe:`${WT} before:bottom-0`,tee:`${WT} before:bottom-0`,elbow:`${WT} before:right-0 before:bottom-1/2 before:rounded-bl-[6px] before:[border-bottom:var(--hairline)_solid_var(--line-active)]`},KT=e=>`relative w-3 ${GT[e]}`,qT=`-mx-1 inline-flex min-w-6 cursor-pointer items-center justify-center gap-1 self-stretch rounded-xs px-2 font-mono hover:bg-hover`,JT=`inline-flex items-center gap-1`,YT=e=>`fixed z-35 flex max-h-[min(380px,60vh)] w-85 max-w-[calc(100vw-24px)] animate-pr-list-in flex-col overflow-y-auto overscroll-contain rounded-md border-hairline border-line bg-surface p-1.5 shadow-popover transition-[opacity,translate] duration-120 ease-in motion-reduce:animate-none motion-reduce:transition-none ${e?`-translate-x-1 opacity-0`:``}`,XT=`pointer-events-none fixed z-35 max-w-80 -translate-y-1/2 animate-row-tip-in rounded-sm border-hairline border-line bg-inset px-2.5 py-1.5 text-meta leading-[1.4] whitespace-normal wrap-anywhere text-ink shadow-popover motion-reduce:animate-none`,ZT=`inline-flex flex-none items-center text-subtle`,QT=`group/rail rail @container row-1 flex min-h-0 flex-col focus:outline-none ${ze}`,$T=`flex min-w-0 items-center gap-2.5 overflow-hidden px-3.5 pt-3.5 pb-2.5 whitespace-nowrap`,eE=`flex gap-1 px-3.5 pb-2 text-meta`,tE=`flex flex-wrap items-center gap-x-2.5 gap-y-0.5 px-3.5 pb-2 font-mono text-meta`,nE=`min-w-0 flex-1 border-none bg-transparent p-0 text-ink [font:inherit] outline-none placeholder:text-subtle`,rE=e=>`flex-1 overflow-y-auto px-1.5 pt-1 pb-3 scrollbar-none ${e?`[&>[data-row]]:[transition:transform_150ms_ease-out] motion-reduce:[&>[data-row]]:transition-none`:``}`,iE=`group-focus-within/rail:[box-shadow:inset_0_0_0_1px_var(--focus)]`,aE=e=>`group/head mx-2 mt-1.5 mb-1 flex items-center gap-1 font-mono text-meta font-semibold normal-nums text-subtle not-first:mt-4.5 ${e.moving||e.dragging?`bg-accent-soft`:``} ${e.moving?`after:font-mono after:text-meta after:font-medium after:normal-nums after:text-accent after:content-['move']`:``}`,oE=`touch:relative touch:after:absolute touch:after:-inset-x-1.5 touch:after:-inset-y-3 touch:after:content-['']`,sE=`group/toggle -ml-1 inline-flex min-w-0 cursor-pointer items-center gap-1 rounded-xs border-none bg-transparent px-1 py-0.5 text-inherit [font:inherit] hover:text-ink ${oE}`,cE=e=>e?``:`opacity-0 group-hover/head:opacity-100 group-focus-visible/toggle:opacity-100 touch:opacity-100`,lE=`-mr-[4.5px] ml-auto size-5 cursor-pointer rounded-xs border-none bg-transparent text-muted opacity-0 [font:400_var(--fs-display)/1_var(--sans)] group-hover/head:opacity-100 hover:bg-hover hover:text-ink focus-visible:opacity-100 touch:opacity-100 ${oE}`,uE=1e4;function dE(e,t){let n=e.hostLabel||e.alias;if(e.state===`online`)return e.version?`${n} · v${e.version}`:n;let r=t[e.state];return e.state===`mismatch`?e.version?`${n} · ⚠ v${e.version} (${r})`:`${n} · ⚠ ${r}`:`${n} · ${r}`}function fE(e,t,n,r=e){let i=t?.hostLabel&&t.hostLabel!==e?` (${t.hostLabel})`:``,a=n.runsOn.replace(`{host}`,t?`${e}${i}`:r);return!t||t.state===`online`?a:`${a}${dE(t,n).slice((t.hostLabel||t.alias).length)}`}function pE(e,t,n){if(e.kind!==`task`||e.machine===void 0)return null;let r=e.machine;return fE(r,t.find(e=>e.alias===r),n,e.task.machine?.label)}function mE({label:e}){return(0,V.jsx)(`span`,{className:ZT,title:e,role:`img`,"aria-label":e,children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4.5 13a3 3 0 0 1-.4-5.97A4.5 4.5 0 0 1 12.8 6.6 3.2 3.2 0 0 1 12.3 13Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinejoin:`round`})})})}function hE({host:e,onMachines:t}){return B(),(0,V.jsxs)(`div`,{className:Ut,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`machine.filesElsewhere`,{host:e})}),(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`machine.filesHint`,{host:e})}),(0,V.jsx)(`div`,{children:(0,V.jsx)(H,{hit:`tight`,onClick:t,children:z(`machines.open`)})})]})}function gE(e){let t=v(e.client.conn),n=v(e.remote),[r,i]=(0,g.useState)(()=>Ns(e,`machines.list`)?.machines??[]),a=[...new Set(n.map(e=>`${e.machine?.id}:${e.machine?.stale??!1}`))].join();return(0,g.useEffect)(()=>{if(t.state!==`open`)return;let n=!0,r=()=>Fs(e,`machines.list`).then(e=>n&&i(e.machines),()=>{});r();let a=window.setInterval(r,uE);return()=>{n=!1,window.clearInterval(a)}},[e.client,t.state,a]),r}var _E=`flex min-h-0 min-w-0 flex-1 flex-col p-4 font-mono text-meta leading-[1.5] font-normal not-italic normal-nums`,vE=`flex flex-1 flex-col items-center justify-center gap-1.5 text-center`,yE=`mx-auto flex w-full max-w-[104ch] flex-col gap-2`,bE=`flex flex-col gap-2 rounded-md border-hairline border-line bg-surface px-3 py-2.5 focus-within:border-line-active`,xE=`flex flex-wrap items-center justify-end gap-1.5`,SE=`max-h-[40vh] min-h-[4.5em] w-full bg-transparent text-ink [border:0] [outline:0]`,CE=`flex flex-wrap items-center gap-1.5 px-1`,wE=`flex-1`,TE=`size-3.25 flex-none fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.3]`,EE=(e=!1)=>`inline-flex max-w-[28ch] items-center gap-1.5 overflow-hidden rounded-full border-hairline px-2.5 py-0.75 text-ellipsis whitespace-nowrap touch:py-1.75 [&:hover]:bg-hover [&:hover]:text-ink aria-expanded:bg-hover aria-expanded:text-ink ${e?`border-[color-mix(in_srgb,var(--accent)_45%,transparent)] bg-accent-soft text-accent`:`border-line text-muted`}`,DE=`disabled:cursor-default disabled:opacity-60`,OE=`group/chip relative inline-flex`,kE=`flex min-h-0 flex-col gap-1 overflow-y-auto p-1.5 [outline:0]`,AE=`flex min-h-0 flex-col overflow-y-auto`,jE=`sticky top-0 z-1 m-0 bg-surface px-1.5 pt-1.5 pb-0.5 text-left`,ME=e=>`flex w-full items-baseline gap-2 rounded-[calc(var(--radius)-6px)] px-2 py-1 text-left touch:py-2.5 disabled:cursor-default disabled:opacity-50 ${e.dim?`text-subtle`:`text-ink`} ${e.cursor?`bg-hover`:``}`,NE=`flex-[0_0_1.5ch] text-accent`,PE=`ml-auto pl-3 inline-flex items-center gap-1`,FE=`flex-none whitespace-nowrap`,IE=`flex flex-col gap-0.5 px-1.5 py-0.5`,LE=`min-w-[36ch]`;function RE(){return(0,V.jsx)(`svg`,{className:TE,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z`})})}function zE(){return(0,V.jsxs)(`svg`,{className:TE,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,V.jsx)(`circle`,{cx:`4.5`,cy:`3.5`,r:`1.5`}),(0,V.jsx)(`circle`,{cx:`4.5`,cy:`12.5`,r:`1.5`}),(0,V.jsx)(`circle`,{cx:`11.5`,cy:`5`,r:`1.5`}),(0,V.jsx)(`path`,{d:`M4.5 5v6M11.5 6.5c0 3-7 2-7 4.5`})]})}function BE(){return(0,V.jsx)(`svg`,{className:TE,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M10.5 4.5 5.8 9.2a1.4 1.4 0 0 0 2 2l5-5a2.8 2.8 0 0 0-4-4l-5.2 5.2a4.2 4.2 0 0 0 6 6L13 9`})})}function VE(e){let[t,n]=(0,g.useState)(!1),r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{let e=a.current;if(!t||!e)return;let n=e.getBoundingClientRect(),r=n.right>window.innerWidth-8?window.innerWidth-8-n.right:n.left<8?8-n.left:0;r&&(e.style.transform=`translateX(${Math.round(r)}px)`)},[t]);let o=()=>{n(!1),i.current?.focus()};return(0,g.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[t]),(0,V.jsxs)(`span`,{ref:r,className:OE,onKeyDown:e=>{e.key!==`Escape`||!t||(e.preventDefault(),e.stopPropagation(),o())},children:[(0,V.jsx)(`button`,{ref:i,type:`button`,className:EE(),"data-field":e.field,title:e.title,"aria-haspopup":`menu`,"aria-expanded":t,disabled:e.disabled,onClick:()=>n(e=>!e),children:e.label}),t&&(0,V.jsx)(`div`,{ref:a,className:`absolute bottom-[calc(100%+6px)] left-0 z-20 flex max-h-[min(50vh,420px)] max-w-[min(52ch,calc(100vw-16px))] min-w-[min(34ch,calc(100vw-16px))] flex-col overflow-hidden rounded-md border-hairline border-line-active bg-surface shadow-popover group-last-of-type/chip:right-0 group-last-of-type/chip:left-auto`,children:e.children(o)})]})}function HE(e){let[t,n]=(0,g.useState)(0),r=[...e.extra?[e.extra]:[],...e.rows,...e.more??[]],i=Math.min(t,Math.max(0,r.length-1)),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{a.current?.scrollIntoView({block:`nearest`})},[i,e.rows]),(0,V.jsxs)(`div`,{className:kE,children:[(0,V.jsx)(`input`,{className:Qt,autoFocus:!0,spellCheck:!1,placeholder:e.placeholder,value:e.query,onChange:t=>{n(0),e.onQuery(t.target.value)},onKeyDown:t=>{if(!t.nativeEvent.isComposing){if(t.key===`ArrowDown`||t.key===`ArrowUp`)t.preventDefault(),n(Math.max(0,Math.min(r.length-1,i+(t.key===`ArrowDown`?1:-1))));else if(t.key===`Enter`){t.preventDefault();let n=r[i];n&&e.onPick(n.key)}}}}),(0,V.jsxs)(`div`,{className:AE,children:[r.length===0&&(0,V.jsx)(`p`,{className:`mx-2 my-1 text-muted`,children:e.empty}),r.map((t,r)=>(0,V.jsxs)(g.Fragment,{children:[e.moreLabel&&t===e.more?.[0]&&(0,V.jsx)(`p`,{className:`mx-2 mt-2 mb-0.5 text-muted`,children:e.moreLabel}),(0,V.jsxs)(`button`,{type:`button`,"aria-current":t.checked===!0,ref:r===i?a:void 0,tabIndex:-1,title:t.title,className:ME({cursor:r===i}),onMouseMove:()=>n(r),onClick:()=>e.onPick(t.key),children:[(0,V.jsx)(`span`,{className:NE,children:t.checked?`✓`:``}),(0,V.jsx)(`span`,{className:FE,children:t.text}),t.dim&&(0,V.jsx)(`span`,{className:`ml-auto pl-3 text-muted ${t.title?`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`:``}`,children:t.dim})]})]},t.key))]})]})}function UE(e){return(0,V.jsxs)(`button`,{type:`button`,role:e.multi?`menuitemcheckbox`:`menuitemradio`,"aria-checked":e.checked,tabIndex:-1,disabled:e.option.disabled,className:ME({cursor:e.cursor,dim:e.option.dim}),onMouseMove:e.onHover,onClick:e.onPick,children:[(0,V.jsx)(`span`,{className:NE,children:e.checked?`✓`:``}),(0,V.jsx)(`span`,{children:e.option.label}),!e.checked&&e.digit!==void 0&&!e.option.disabled&&(0,V.jsx)(`span`,{className:`ml-auto pl-3 text-muted`,children:e.digit})]})}function WE(e){let[t,n]=(0,g.useState)(()=>Math.max(0,e.options.findIndex(t=>t.id===e.value))),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>r.current?.focus(),[]),(0,V.jsxs)(`div`,{ref:r,role:`menu`,tabIndex:-1,className:kE,onKeyDown:r=>{if(!(r.ctrlKey||r.metaKey||r.altKey||r.nativeEvent.isComposing)){if(r.key===`ArrowDown`||r.key===`ArrowUp`)r.preventDefault(),n(Math.max(0,Math.min(e.options.length-1,t+(r.key===`ArrowDown`?1:-1))));else if(r.key===`Enter`){r.preventDefault();let n=e.options[t];n&&!n.disabled&&e.onPick(n.id)}else if(e.onBack&&(r.key===`Escape`||r.key===`ArrowLeft`))r.preventDefault(),r.stopPropagation(),e.onBack();else{let t=e.digits?ws(r.key,e.options.length):null,n=t===null?void 0:e.options[t];if(!n||n.disabled)return;r.preventDefault(),e.onPick(n.id)}}},children:[e.onBack?(0,V.jsxs)(`button`,{type:`button`,className:`${jE} ${U} text-muted`,tabIndex:-1,onClick:e.onBack,children:[`‹ `,e.heading]}):(0,V.jsx)(`p`,{className:`${jE} ${U} text-muted`,children:e.heading}),e.options.map((r,i)=>(0,V.jsx)(UE,{option:r,checked:e.values?e.values.includes(r.id):r.id===e.value,multi:e.values!==void 0,cursor:i===t,digit:e.digits&&i<9?i+1:void 0,onHover:()=>n(i),onPick:()=>e.onPick(r.id)},r.id)),e.footer]})}function GE(e){let[t,n]=(0,g.useState)(`root`),r=e.models.length+ +(e.efforts.length>0),[i,a]=(0,g.useState)(()=>Math.max(0,e.models.findIndex(t=>t.id===e.model))),o=(0,g.useRef)(null);if((0,g.useEffect)(()=>{t===`root`&&o.current?.focus()},[t]),t===`effort`)return(0,V.jsx)(WE,{heading:z(`newSession.effort`),options:e.efforts,value:e.effort,onBack:()=>n(`root`),onPick:t=>{e.onEffort(t),e.close()}});let s=t=>{e.onModel(t),e.close()},c=e.efforts.find(t=>t.id===e.effort)?.label??``;return(0,V.jsxs)(`div`,{ref:o,role:`menu`,tabIndex:-1,className:kE,onKeyDown:t=>{if(!(t.ctrlKey||t.metaKey||t.altKey||t.nativeEvent.isComposing)){if(t.key===`ArrowDown`||t.key===`ArrowUp`)t.preventDefault(),a(Math.max(0,Math.min(r-1,i+(t.key===`ArrowDown`?1:-1))));else if(t.key===`Enter`||t.key===`ArrowRight`&&i>=e.models.length){t.preventDefault();let r=e.models[i];r?s(r.id):e.efforts.length>0&&n(`effort`)}else{let n=ws(t.key,e.models.length),r=n===null?void 0:e.models[n];if(!r)return;t.preventDefault(),s(r.id)}}},children:[(0,V.jsx)(`p`,{className:`${jE} ${U} text-muted`,children:z(`newSession.modelHeading`)}),e.models.map((t,n)=>(0,V.jsx)(UE,{option:t,checked:t.id===e.model,multi:!1,cursor:n===i,digit:n<9?n+1:void 0,onHover:()=>a(n),onPick:()=>s(t.id)},t.id)),e.efforts.length>0&&(0,V.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`${ME({cursor:i===e.models.length})} mt-1 border-t-hairline border-t-line`,onMouseMove:()=>a(e.models.length),onClick:()=>n(`effort`),children:[(0,V.jsx)(`span`,{className:`flex-[0_0_1.5ch] text-accent`}),(0,V.jsx)(`span`,{children:z(`newSession.effort`)}),(0,V.jsxs)(`span`,{className:`${PE} text-muted`,children:[c,(0,V.jsx)(Ma,{right:!0})]})]})]})}function KE(e){return(0,V.jsxs)(`div`,{className:`${kE} ${LE}`,children:[(0,V.jsx)(`p`,{className:`${jE} ${U} text-muted`,children:z(`newSession.branches`)}),(0,V.jsxs)(`label`,{className:IE,children:[(0,V.jsx)(`span`,{className:`text-muted`,children:z(`newSession.branchName`)}),(0,V.jsx)(`input`,{className:Qt,autoFocus:!0,spellCheck:!1,placeholder:z(`newSession.branchNamePlaceholder`),value:e.branch,onChange:t=>e.onBranch(t.target.value)})]}),e.repos.map(t=>(0,V.jsxs)(`label`,{className:IE,children:[(0,V.jsxs)(`span`,{children:[t.name,t.primary&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,z(`newSession.primary`)]})]}),(0,V.jsx)(`select`,{className:Qt,"aria-label":t.name,value:t.base||t.current,onChange:n=>e.onBase(t.path,n.target.value),children:(t.branches.includes(t.base||t.current)?t.branches:[t.base||t.current,...t.branches]).filter(e=>e!==``).map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))})]},t.path))]})}function qE(e){return e.id.startsWith(`root:`)?e.primary??e.checkouts[0]??e.id:e.id}function JE(e,t){if(!e)return null;let n=t.find(t=>t.id===e||t.checkouts.includes(e));return n?{ref:qE(n),clone:!1}:e.startsWith(`/`)?{ref:e,clone:!1}:null}function YE(e,t,n){let r=t.toLowerCase();return n?e.some(e=>e.toLowerCase()===`github.com/${r}`):e.some(e=>Zo(e).base.toLowerCase()===(r.split(`/`)[1]??``))}function XE(e){let t=e.begin?``:Xo(e.prompt);return{repo:e.pick.ref,machine:e.machine,...e.pick.clone?{clone:!0}:{},...e.baseRef?{baseBranch:e.baseRef}:{},...e.begin&&e.prompt?{prompt:e.prompt}:{},...t?{title:t}:{},...e.engine?{engine:e.engine}:{}}}var ZE={offline:`newSession.remoteOffline`,outdated:`newSession.remoteOutdated`},QE=(e,t)=>Fs(e,`machines.repos`,{machine:t});function $E(e,t){let n=t.filter(e=>e.state===`online`).map(e=>e.alias).join(`
112
112
  `);(0,g.useEffect)(()=>{for(let t of n?n.split(`
113
113
  `):[])QE(e,t).catch(()=>{})},[e,n])}function eD(e,t){B();let[n,r]=(0,g.useState)(null);if((0,g.useEffect)(()=>{if(!t)return;let n=!1;return QE(e,t).then(e=>!n&&r({machine:t,reply:e,failed:``})).catch(e=>!n&&r({machine:t,reply:null,failed:String(e)})),()=>{n=!0}},[e,t]),!t)return{repos:[],loaded:!0,problem:``};let i=n?.machine===t?n:void 0,a=Ns(e,`machines.repos`,{machine:t});if(!i&&!a)return{repos:[],loaded:!1,problem:``};let o=i?i.reply:a;if(!o)return{repos:[],loaded:!0,problem:z(`newSession.remoteFailed`,{machine:t,message:i?.failed??``})};let s=o.reason?ZE[o.reason]:void 0,c=o.reason?s?z(s,{machine:t}):z(`newSession.remoteFailed`,{machine:t,message:o.message??o.reason}):``;return{repos:o.repos,loaded:!0,problem:c}}function tD(e,t){return t.problem?t.problem:t.loaded?z(`newSession.remoteNone`,{machine:e}):z(`newSession.remoteLoading`,{machine:e})}function nD(){return(0,V.jsxs)(`svg`,{className:TE,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,V.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`8`,rx:`1`}),(0,V.jsx)(`path`,{d:`M5.5 13.5h5M8 11v2.5`})]})}function rD(e){let t=(B()===`zh`?Dr:Er).machine,n=e.machines.find(t=>t.alias===e.value),r=e.value?n?.hostLabel||e.value:z(`newSession.thisMachine`);return(0,V.jsx)(VE,{field:`machine`,title:z(`newSession.machine`),label:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(nD,{}),r]}),children:n=>(0,V.jsx)(WE,{heading:z(`newSession.machine`),options:[{id:``,label:z(`newSession.thisMachine`)},...e.machines.map(e=>({id:e.alias,label:dE(e,t),disabled:e.state!==`online`}))],value:e.value,digits:!0,onPick:t=>{e.onPick(t),n()}})})}function iD(e){let[t,n]=(0,g.useState)(``),r=t.trim();return(0,V.jsx)(VE,{field:`branch`,title:z(`newSession.branch`),label:e.value||z(`newSession.branch`),children:i=>(0,V.jsx)(HE,{placeholder:z(`newSession.branchTypeRef`),empty:``,rows:[{key:``,text:z(`newSession.branchRemoteDefault`),checked:e.value===``}],query:t,onQuery:n,extra:r?{key:r,text:r,checked:e.value===r}:null,onPick:t=>{e.onPick(t),n(``),i()}})})}async function aD(e,t){return(await e.client.request(`task.spawn`,XE(t))).taskIds[0]}function oD(e){return e instanceof r_&&e.code===`CLONE_FAILED`?q(`newTask`,`error.cloneFailed`,{error:e.message}):e instanceof Error?e.message:String(e)}function sD(e){let[t,n]=(0,g.useState)(``);if(e.ungrouped)return null;if(e.remote)return e.remotePick&&(0,V.jsx)(iD,{value:e.remoteBase,onPick:e.onRemoteBase});let{repos:r,bases:i,inPlace:a}=e,o=r[0]??``,s=e.probes[o]??null,c=i[o]||s?.current||``,l=Qo(s?.branches??[],t).map(e=>({key:e,text:e,checked:e===(i[o]||s?.current)})),u=r.map(t=>({path:t,name:Zo(t).base,primary:t===o,branches:e.probes[t]?.branches??[],current:e.probes[t]?.current??``,base:i[t]??``}));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`${EE(!a)} ${DE}`,"aria-pressed":!a,disabled:r.length>1,title:r.length>1?z(`newSession.worktreeMulti`):z(a?`newSession.worktreeOff`:`newSession.worktreeOn`),onClick:e.onToggleWorktree,children:[(0,V.jsx)(zE,{}),z(`newSession.worktree`)]}),r.length>1?(0,V.jsx)(VE,{field:`branch`,title:z(`newSession.branches`),label:z(`newSession.branches`),children:()=>(0,V.jsx)(KE,{repos:u,branch:e.branchName,onBranch:e.onBranchName,onBase:e.onBase})}):!a&&s?.ok&&c&&(0,V.jsx)(VE,{field:`branch`,title:z(`newSession.branch`),label:c,children:r=>(0,V.jsx)(HE,{placeholder:z(`newSession.branchSearch`),empty:z(`newSession.branchEmpty`),rows:l,query:t,onQuery:n,onPick:t=>{e.onBase(o,t),n(``),r()}})})]})}function cD(e,t){let[n,r]=(0,g.useState)(null),i=t&&n!==null,a=i?n:e.engine?[e.engine]:[];return{ids:a,comparing:i,setComparing:e=>r(e?a:null),toggle(t){let n=ys(a,t);r(n),n[0]&&n[0]!==e.engine&&e.setEngine(n[0])}}}function lD(e){let{picks:t,choice:n}=e,r=n.engines;if(r.length<2)return null;let i=t.ids.map(e=>r.find(t=>t.id===e)?.name??e);return(0,V.jsx)(VE,{field:`engine`,title:z(`newSession.engine`),label:bs(i)||z(`newSession.engine`),children:i=>(0,V.jsx)(WE,{heading:z(`newSession.engine`),options:r.map(e=>({id:e.id,label:e.name,dim:e.ready===!1})),value:n.engine,...t.comparing?{values:t.ids}:{},onPick:e=>{if(t.comparing)return t.toggle(e);n.setEngine(e),i()},footer:e.available&&r.length>1?(0,V.jsx)(H,{className:`mx-2 mt-1 mb-0.5 self-start font-mono`,"data-field":`compare-engines`,hit:`tight`,onClick:()=>t.setComparing(!t.comparing),children:z(t.comparing?`compare.oneEngine`:`compare.severalEngines`)}):null})})}function uD(e){return(0,V.jsx)(VE,{field:`model`,title:z(`newSession.model`),label:vs(e.models,e.model,e.effort,z(`newSession.modelDefault`)),children:t=>(0,V.jsx)(GE,{...e,close:t})})}var dD=6e4,fD=/^(?:(today|tomorrow|今天|明天)\s*)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/i,pD=/^\+\s*(?:(\d+)\s*h)?\s*(?:(\d+)\s*m)?$/i;function mD(e,t){let n=e.trim(),r=pD.exec(n);if(r&&(r[1]||r[2])){let e=Number(r[1]??0)*60+Number(r[2]??0);return e>0?new Date(t.getTime()+e*dD):null}let i=fD.exec(n);if(!i)return null;let a=i[1]?.toLowerCase(),o=Number(i[2]),s=Number(i[3]??0),c=i[4]?.toLowerCase();if(c){if(o<1||o>12)return null;o=o%12+(c===`pm`?12:0)}if(o>23||s>59)return null;let l=new Date(t.getFullYear(),t.getMonth(),t.getDate(),o,s);if(a===`tomorrow`||a===`明天`)l.setDate(l.getDate()+1);else if(l.getTime()<=t.getTime()){if(a)return null;l.setDate(l.getDate()+1)}return l.getTime()>t.getTime()?l:null}function hD(e,t=new Date){let n=e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return e.toDateString()===t.toDateString()?n:`${e.toLocaleDateString([],{weekday:`short`})} ${n}`}async function gD(e,t,n,r){await e.request(`task.scheduleStart`,{taskId:t,at:n.toISOString(),prompt:r})}function _D(e){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(``),a=()=>{let t=mD(r,new Date);t?e.onSchedule(t):e.onInvalid(z(`newSession.laterBad`))};return(0,V.jsxs)(V.Fragment,{children:[t&&(0,V.jsx)(`input`,{className:`${Qt} min-w-0 flex-1 basis-40`,value:r,placeholder:z(`newSession.laterPlaceholder`),"aria-label":z(`newSession.later`),spellCheck:!1,autoComplete:`off`,autoFocus:!0,disabled:e.disabled,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),e.stopPropagation(),a()):e.key===`Escape`&&(e.stopPropagation(),n(!1))}}),(0,V.jsx)(H,{variant:`row`,className:EE(t),"aria-pressed":t,disabled:e.disabled,onClick:()=>t&&r.trim()?a():n(!t),children:z(t&&r.trim()?`newSession.laterConfirm`:`newSession.later`)})]})}var vD=`clone:`;function yD(e){let{model:t,saved:n,picked:r,primary:i,home:a,query:o,remote:s}=e,[c,l]=(0,g.useState)(()=>Ns(t,`github.repos`)??null);(0,g.useEffect)(()=>{let e=!1;return Fs(t,`github.repos`).then(t=>!e&&l(t)).catch(()=>!e&&l({repos:[],reason:`failed`})),()=>{e=!0}},[t]);let u=o.trim(),d=Qo(n,o),f=z(`rail.noProject`),p=e.ungrouped&&(!u||f.toLowerCase().includes(u.toLowerCase()))?[{key:iw,text:f,dim:a,checked:e.ungrouped.on}]:[],m=d.map(e=>{let{base:t,dir:n}=Zo(e);return{key:e,text:t,dim:e===i&&r.length>1?`${z(`newSession.primary`)}, ${n}`:n,checked:r.includes(e)}}),h=ds(u),_=h&&(h.includes(`:`)||d.length===0)?h:null,v=!_&&$o(u)&&!n.includes(u)&&(!s||u.startsWith(`/`))?ts(es(u,a)):``,y=_?{key:vD+_,text:s?z(`newSession.cloneRowOn`,{source:_,machine:s.name}):z(`newSession.cloneRow`,{source:_})}:v?{key:v,text:v,checked:r.includes(v)}:null,b=u.toLowerCase(),x=(c?.repos??[]).filter(e=>e.nameWithOwner.toLowerCase().includes(b)).filter(e=>!YE(n,e.nameWithOwner,s!==void 0)).map(e=>({key:vD+e.nameWithOwner,text:e.nameWithOwner,dim:e.description,title:e.description}));return(0,V.jsx)(HE,{placeholder:z(s?`newSession.repoSearchRemote`:`newSession.repoSearch`),empty:s?.empty??z(`newSession.repoEmpty`),rows:s?.blocked?[]:[...p,...m],query:o,onQuery:e.onQuery,extra:s?.blocked?null:y,more:s?.blocked?[]:x,moreLabel:z(`newSession.githubGroup`),onPick:t=>{if(t===`~scratch`)return e.ungrouped?.pick(),e.close();if(!t.startsWith(`clone:`))return e.onToggle(t);e.onClone(t.slice(6)),e.close()}})}function bD(e){document.querySelector(`.dialog [data-field="${e}"]:not([hidden] *)`)?.focus()}function xD(e){let[t,n]=(0,g.useState)(0),r=e.open&&e.items.length>0,i=Math.min(t,Math.max(0,e.items.length-1)),a=(0,g.useRef)(null),{onCursor:o}=e;return(0,g.useEffect)(()=>o?.(i),[i,o]),(0,g.useEffect)(()=>{a.current?.scrollIntoView({block:`nearest`})},[i,e.items]),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`input`,{className:Qt,"data-field":e.field,spellCheck:!1,autoComplete:`off`,autoFocus:e.autoFocus,placeholder:e.placeholder,value:e.value,onChange:t=>{n(0),e.onChange(t.target.value.replace(/[\r\n]+/g,``))},onKeyDown:t=>{if(!t.nativeEvent.isComposing){if(t.key===`ArrowDown`||t.key===`ArrowUp`){if(!r)return;t.preventDefault(),n(Math.max(0,Math.min(e.items.length-1,i+(t.key===`ArrowDown`?1:-1))))}else t.key===`Tab`&&!t.shiftKey&&r&&e.onComplete?.(i)?(t.preventDefault(),n(0)):t.key===`Enter`&&!t.ctrlKey&&!t.metaKey&&(t.preventDefault(),r?((e.onEnterRow??e.onPick)(i),n(0)):e.onEnter?.())}}}),r&&(0,V.jsx)(`ul`,{className:`mx-0 mt-1 mb-0 max-h-47 list-none overflow-y-auto rounded-sm border-hairline border-line bg-inset p-0.5 font-mono text-meta`,children:e.items.map((t,n)=>(0,V.jsx)(`li`,{ref:n===i?a:void 0,children:(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":n===i,className:Yt({cursor:n===i,accent:!!t.accent}),onMouseDown:t=>{t.preventDefault(),e.onPick(n)},children:[(0,V.jsx)(`span`,{children:t.text}),t.dim&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,t.dim]})]})},t.key))})]})}function SD({model:e,engine:t,busy:n,error:r,run:i}){let[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(()=>localStorage.getItem(`rove.web.cloneParent`)||`~/`),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(`main`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)({base:``,home:``,names:[]});(0,g.useEffect)(()=>{let t=!1,n=setTimeout(()=>{e.client.request(`fs.subdirs`,{path:s}).then(e=>!t&&y(e)).catch(()=>{})},60);return()=>{t=!0,clearTimeout(n)}},[e,s]);let b=l??ss(a),x=es(s.trim(),v.home),S=()=>i(async()=>{if(!a.trim())throw bD(`url`),Error(q(`newTask`,`error.gitUrlRequired`));let n;try{m(``),n=await e.client.request(`repo.clone`,{url:a.trim(),parentDir:x,...l?.trim()?{folder:l.trim()}:{}},m)}catch(e){throw e instanceof r_&&e.code===`CLONE_FAILED`?Error(q(`newTask`,`error.cloneFailed`,{error:e.message})):e}localStorage.setItem(cs,s.trim());let r=(await e.client.request(`task.spawn`,{repo:n.path,...t?{engine:t}:{},...d.trim()?{baseBranch:d.trim()}:{}})).taskIds[0];r&&e.selectWhenListed(r)});return(0,V.jsxs)(`form`,{className:Pn,onSubmit:e=>{e.preventDefault(),S()},children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.gitUrl`)}),(0,V.jsx)(`input`,{className:Qt,"data-field":`url`,spellCheck:!1,placeholder:`https://github.com/user/repo.git`,value:a,onChange:e=>o(e.target.value.replace(/[\r\n]+/g,``)),onKeyDown:e=>{e.key!==`Enter`||e.ctrlKey||e.metaKey||(e.preventDefault(),a.trim()&&bD(`parent`))}})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.parentDir`)}),(0,V.jsx)(xD,{field:`parent`,value:s,placeholder:`~/`,onChange:e=>{_(!0),c(e)},items:v.names.map(e=>({key:e,text:`${e}/`})),open:h,onPick:e=>{let t=v.names[e];t!==void 0&&c(rs(s,v.base,t,v.home)),_(!1),bD(`folder`)},onComplete:e=>{let t=v.names[e];if(t===void 0)return!1;let n=`${rs(s,v.base,t,v.home)}/`;return n!==s&&(c(n),!0)},onEnter:()=>bD(`folder`)}),(0,V.jsx)(`span`,{className:`text-muted`,children:q(`newTask`,`hint.remembered`)})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.folderName`)}),(0,V.jsx)(`input`,{className:Qt,"data-field":`folder`,spellCheck:!1,placeholder:q(`newTask`,`placeholder.folderName`),value:b,onChange:e=>u(e.target.value.replace(/[\r\n]+/g,``)),onKeyDown:e=>{e.key!==`Enter`||e.ctrlKey||e.metaKey||(e.preventDefault(),bD(`clone-base`))}})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.baseBranch`)}),(0,V.jsx)(`input`,{className:Qt,"data-field":`clone-base`,spellCheck:!1,placeholder:`main`,value:d,onChange:e=>f(e.target.value.replace(/[\r\n]+/g,``))})]}),n&&(0,V.jsx)(`p`,{className:`text-muted`,"data-field":`clone-progress`,children:p||q(`newTask`,`clone.progressInto`,{target:`${x}/${b}`})}),r&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,r]}),(0,V.jsx)(lr,{busy:n,submitLabel:q(`newTask`,n?`button.cloning`:`button.create`)})]})}function CD({model:e,engine:t,busy:n,error:r,run:i,repo:a,active:o}){let[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(new Set),[p,m]=(0,g.useState)(0),h=a.expanded;(0,g.useEffect)(()=>{if(!o||!h)return;let t=!1;return u(null),f(new Set),e.client.request(`repo.probe`,{path:h,adoptable:!0}).then(e=>!t&&u(e.worktrees??[])).catch(()=>!t&&u([])),()=>{t=!0}},[e,o,h]);let _=ps(l??[],s),v=e=>f(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=()=>i(async()=>{let n=d.size>0?_.filter(e=>d.has(e.path)):_.slice(p,p+1);if(n.length===0)throw Error(q(`newTask`,`error.noAdoptable`));let r=0,i,a;for(let o of n){let n={repo:h,worktreePath:o.path,branch:o.branch,...t?{engine:t}:{}};try{let t;try{t=await e.client.request(`worktree.adopt`,n)}catch(r){if(!(r instanceof r_&&r.code===`UNKNOWN_REPO`))throw r;await e.client.request(`task.openMain`,{repo:h}),t=await e.client.request(`worktree.adopt`,n)}a=t.taskId,r++}catch(e){i??=e instanceof Error?e.message:String(e)}}if(r===0)throw Error(q(`newTask`,`adopt.summaryNone`,{error:i??``}));G(r<n.length?q(`newTask`,`adopt.summaryPartial`,{done:r,total:n.length}):q(`newTask`,`adopt.summaryAll`,{count:r})),a&&e.selectWhenListed(a)}),b=d.size>0?q(`newTask`,`adopt.hintSelected`,{count:d.size}):q(`newTask`,`adopt.hintDefault`);return(0,V.jsxs)(`form`,{className:Pn,onSubmit:e=>{e.preventDefault(),y()},onKeyDown:e=>{e.ctrlKey&&!e.shiftKey&&!e.metaKey&&e.key.toLowerCase()===`a`&&(e.preventDefault(),e.stopPropagation(),f(e=>_.every(t=>e.has(t.path))?new Set:new Set(_.map(e=>e.path))))},children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.adoptFilter`)}),(0,V.jsx)(xD,{field:`filter`,value:s,placeholder:q(`newTask`,`placeholder.adoptFilter`),onChange:c,items:_.map(e=>{let t=[e.dirty===!0?`dirty`:e.dirty===null?`dirty?`:``,e.roveManaged?``:`external`].filter(Boolean).join(`,`);return{key:e.path,text:`${d.has(e.path)?`[x]`:`[ ]`} ${e.branch}${t?` (${t})`:``}`,dim:e.path,accent:d.has(e.path)}}),open:!0,onPick:e=>{let t=_[e];t&&v(t.path)},onCursor:m,onEnter:()=>{}}),(0,V.jsx)(`span`,{className:`text-muted`,children:q(`newTask`,`adopt.repoLine`,{path:h||q(`newTask`,`adopt.repoNone`)})}),l===null&&h&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`newTask`,`hint.scanningWorktrees`)}),l!==null&&_.length===0&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`newTask`,l.length===0?`adopt.noUnlinked`:`adopt.noMatch`)}),_.length>0&&(0,V.jsx)(`span`,{className:`text-muted`,children:(0,V.jsx)(ST,{text:Yo(b)})})]}),r&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,r]}),(0,V.jsx)(lr,{busy:n,submitLabel:q(`newTask`,`button.create`)})]})}var wD=[`existing`,`clone`,`adopt`];function TD(e,t){let n=Ns(e,`repos.list`)?.repos,[r,i]=(0,g.useState)(n??[]),[a,o]=(0,g.useState)(()=>Ns(e,`fs.subdirs`,{path:`~/`})?.home??``),[s,c]=(0,g.useState)(()=>{let e=t??n?.[0];return e?os(e,n??[]):``}),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null);(0,g.useEffect)(()=>{Promise.all([Fs(e,`repos.list`),Fs(e,`fs.subdirs`,{path:`~/`})]).then(([e,n])=>{i(e.repos),o(n.home);let r=t??e.repos[0]??``;c(t=>t||os(r,e.repos))}).catch(()=>{})},[e,t]);let h=$o(s.trim())&&!r.includes(s.trim());(0,g.useEffect)(()=>{if(!h)return;let t=!1,n=setTimeout(()=>{e.client.request(`fs.subdirs`,{path:s}).then(e=>!t&&f({base:e.base,names:e.names})).catch(()=>!t&&f({base:``,names:[]}))},60);return()=>{t=!0,clearTimeout(n)}},[e,h,s]);let _=as(s,r),v=_.kind===`path`?_.path:``,y=v.startsWith(`~`)&&!a?``:v.replace(/^~(?=\/|$)/,a).replace(/(.)\/+$/,`$1`);(0,g.useEffect)(()=>{if(m(null),!y)return;let t=!1,n=setTimeout(()=>{e.client.request(`repo.probe`,{path:y}).then(e=>!t&&m(e)).catch(()=>{})},150);return()=>{t=!0,clearTimeout(n)}},[e,y]);let b=new Set((e.tasks.get()?.tasks??[]).filter(e=>e.kind===`main`).map(e=>e.repo.replace(/\/+$/,``))),x=h?d?.names??[]:[],S=Qo(r,s),C=h?x.map(e=>({key:e,text:`${e}/`})):S.map(e=>{let{base:t,dir:n}=Zo(e);return{key:e,text:t,dim:n,accent:e===y}});return{text:s,saved:r,home:a,expanded:y,ambiguous:_.kind===`ambiguous`?_.name:null,mainRepos:b,open:!l,items:C,probe:p,setText:e=>{u(!1),c(e)},pick:e=>{if(h){let t=x[e];t!==void 0&&c(rs(s,d?.base??``,t,a))}else{let t=S[e];t!==void 0&&c(os(t,r))}u(!0),bD(`branch`)},complete:e=>{if(l)return!1;if(h){let t=x[e];if(t===void 0)return!1;let n=is(s,d?.base??``,t,a);return n!==s&&(c(n),!0)}let t=S[e];if(t===void 0)return!1;let n=os(t,r);return n!==s.trim()&&(c(n),u(!0),!0)},reopen:()=>u(!1)}}function ED(e){let{model:t,repo:n}=e,[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!0),[l,u]=(0,g.useState)(`task`),d=n.mainRepos.has(n.expanded),f=n.probe?.ok?n.probe:null,p=f?.branches??[];(0,g.useEffect)(()=>{!a&&f?.current&&i(f.current)},[a,f]),(0,g.useEffect)(()=>u(`task`),[n.expanded]);let m=Qo(p,r),h=i=>e.run(async()=>{if(n.ambiguous)throw n.reopen(),bD(`repo`),Error(q(`newTask`,`error.repoAmbiguous`,{name:n.ambiguous}));if(!n.expanded)throw bD(`repo`),Error(z(`newTask.needRepo`));let e=await t.client.request(`repo.probe`,{path:n.expanded});if(!e.ok)throw bD(`repo`),Error(e.reason??n.expanded);if(l===`project`&&d){let n=await t.client.request(`task.openMain`,{repo:e.repo});t.selectWhenListed(n.taskId);return}fn(e.repo,(i??r).trim())});return(0,V.jsxs)(`form`,{className:Pn,onSubmit:e=>{e.preventDefault(),h()},children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.repo`)}),(0,V.jsx)(xD,{field:`repo`,value:n.text,onChange:n.setText,items:n.items,open:n.open,onPick:n.pick,onComplete:n.complete,onEnter:()=>bD(`branch`)})]}),d&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`newTask`,`field.opens`)}),(0,V.jsx)(Go,{label:q(`newTask`,`field.opens`),field:`intent`,value:l,onChange:e=>u(e===`project`?`project`:`task`),choices:[{id:`task`,label:q(`newTask`,`intent.task`)},{id:`project`,label:q(`newTask`,`intent.project`)}]})]}),!(l===`project`&&d)&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`newTask`,`field.fromBranch`)}),(0,V.jsx)(xD,{field:`branch`,value:r,placeholder:`main`,onChange:e=>{o(!0),c(!0),i(e)},items:m.map(e=>({key:e,text:e,accent:e===r.trim()})),open:s,onPick:e=>{let t=m[e];t!==void 0&&(i(t),o(!0),c(!1),bD(`create`))},onEnterRow:e=>{let t=r.trim(),n=t?m.find(e=>e.toLowerCase()===t.toLowerCase()):void 0;h(n??m[e]??t)},onEnter:()=>void h()}),m.length===0&&e.error==null&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`newTask`,p.length===0?`hint.noBranchesFound`:`hint.noMatchBranch`)})]}),e.error&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,e.error]}),(0,V.jsx)(lr,{busy:e.busy,submitLabel:q(`newTask`,`button.create`)})]})}function DD({model:e,repo:t}){B();let[n,r]=(0,g.useState)(`existing`),{busy:i,error:a,setError:o,submit:s}=ar(),c=e.selection.get().taskId,l=e.tasks.get()?.tasks.find(e=>e.id===c)?.repo,u=TC(e,t??l),d=TD(e,t??l),f=(0,g.useRef)(null),p=(0,g.useRef)(!0);(0,g.useEffect)(()=>{if(o(null),p.current){p.current=!1,f.current?.querySelector(`[data-field=mode] [aria-pressed=true]`)?.focus();return}bD(n===`existing`?`repo`:n===`clone`?`url`:`filter`)},[n]);let m=u.engines.filter(e=>e.ready!==!1),h=()=>{let e=m.length>0?m:u.engines,t=e[(e.findIndex(e=>e.id===u.engine)+1)%e.length];t&&u.setEngine(t.id)},_=e=>r(t=>wD[(wD.indexOf(t)+e+wD.length)%wD.length]),v={model:e,engine:u.engine,busy:i,error:a,setError:o,run:s};return(0,V.jsx)(ir,{title:q(`newTask`,`title`),wide:!0,children:(0,V.jsxs)(`div`,{ref:f,onKeyDown:e=>{if(!(!e.ctrlKey||e.metaKey||e.altKey)){if(e.key===`]`||e.key===`[`)_(e.key===`]`?1:-1);else if(e.key.toLowerCase()===`e`&&!e.shiftKey)h();else return;e.preventDefault(),e.stopPropagation()}},children:[(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.mode`)}),(0,V.jsx)(Go,{label:q(`newTask`,`field.mode`),field:`mode`,value:n,onChange:e=>r(e),choices:wD.map(e=>({id:e,label:q(`newTask`,`tabs.${e}`)}))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:q(`newTask`,`field.engine`)}),(0,V.jsx)(jC,{engines:u.engines,value:u.engine,onChange:u.setEngine})]})]}),(0,V.jsx)(`div`,{hidden:n!==`existing`,children:(0,V.jsx)(ED,{...v,repo:d})}),(0,V.jsx)(`div`,{hidden:n!==`clone`,children:(0,V.jsx)(SD,{...v})}),(0,V.jsx)(`div`,{hidden:n!==`adopt`,children:(0,V.jsx)(CD,{...v,repo:d,active:n===`adopt`})}),(0,V.jsx)(`p`,{className:`keys-only mx-0 mt-2 mb-0 ${Gt}`,children:q(`newTask`,`legend`,{enter:q(`newTask`,`enterNext`)})})]})})}function OD(e,t){let n=e.scratch||e.noProject,r=n?[]:t.extraRepos??[];return{...n?{ungrouped:!0}:{repo:t.repo},...t.baseRef?{baseBranch:t.baseRef}:{},...r.length>0?{extras:r}:{},...e.machine?{machine:e.machine.id}:{},prompt:t.prompt,...t.engine?{engine:t.engine}:{},worktree:e.kind===`task`,retryOf:{id:e.id,label:e.label}}}function kD(e,t){return e?[e,...(t.extras??[]).map(e=>e.repo)]:[]}function AD(e,t){return e?{...t.baseBranch?{[e]:t.baseBranch}:{},...Object.fromEntries((t.extras??[]).flatMap(e=>e.baseRef?[[e.repo,e.baseRef]]:[]))}:{}}function jD(e,t){return e.retryOf&&e.engine&&e.engine===t?e.retryOf.id:void 0}async function MD(e,t){try{let{task:n}=await e.client.request(`task.get`,{taskId:t.id});if(!n.prompt)return void G(z(`menu.retryNoPrompt`),`error`);pn(OD(t,{...n,prompt:n.prompt}))}catch(e){G(K(e),`error`)}}function ND(e,t){let n=async n=>{await e.client.request(`task.archive`,{taskId:t.id,archived:!0,...n?{force:n}:{}}),G(q(`tasks`,`archive.done`,{title:t.label}))};W.set((0,V.jsx)(sr,{title:z(`newSession.retryArchiveTitle`,{title:t.label}),body:z(`newSession.retryArchiveBody`),confirmLabel:q(`tasks`,`menu.archive`),onConfirm:()=>n(!1),escalate:{when:e=>e instanceof r_&&e.code===`TASK_BUSY`,label:q(`tasks`,`archive.busyConfirm`),title:q(`tasks`,`archive.busyTitle`),body:()=>q(`tasks`,`archive.busyBody`,{title:t.label}),run:()=>n(!0)}}))}var PD=_([]),FD=()=>v(PD);async function ID(e){PD.set((await e.request(`snippets.get`)).snippets)}async function LD(e,t){PD.set((await e.request(`snippets.save`,{name:t.name,text:t.text})).snippets)}async function RD(e,t){PD.set((await e.request(`snippets.remove`,{name:t})).snippets)}var zD=/^[A-Za-z0-9][\w-]{0,31}$/;function BD(e,t){let n=t;for(;n>0&&/[\w-]/.test(e[n-1]??``);)n--;if(n===0||e[n-1]!==`@`)return null;let r=e[n-2];if(r!==void 0&&!/\s/.test(r))return null;let i=t;for(;i<e.length&&/[\w-]/.test(e[i]??``);)i++;return{start:n-1,end:i,query:e.slice(n,t)}}function VD(e,t){let n=t.toLowerCase(),r=e.filter(e=>e.name.toLowerCase().startsWith(n));return[...r.filter(e=>e.name.toLowerCase()===n),...r.filter(e=>e.name.toLowerCase()!==n)]}function HD(e,t,n){return{text:e.slice(0,t.start)+n.text+e.slice(t.end),caret:t.start+n.text.length}}var UD=e=>e.split(`
114
- `,1)[0]??``;function WD(e){return(0,V.jsx)(`ul`,{className:`${Jt} ${e.className}`,children:e.items.map((t,n)=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(H,{variant:`row`,tabIndex:-1,"aria-pressed":n===e.at,className:Yt({cursor:n===e.at,accent:!1}),onMouseDown:t=>{t.preventDefault(),e.onPick(n)},children:[(0,V.jsxs)(`span`,{className:`text-accent`,children:[`@`,t.name]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,UD(t.text)]})]})},t.name))})}function GD(e){let t=FD(),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),c=(0,g.useRef)(null),l=BD(e.value,Math.min(n,e.value.length)),u=l?VD(t,l.query):[],d=l!==null&&u.length>0&&o!==l.start,f=Math.min(i,Math.max(0,u.length-1));(0,g.useLayoutEffect)(()=>{let t=c.current,n=e.area.current;t===null||!n||(c.current=null,n.setSelectionRange(t,t),r(t))});let p=t=>{let n=u[t];if(!l||!n)return;let r=HD(e.value,l,n);c.current=r.caret,a(0),e.onChange(r.text)},m=e=>{if(!d||e.nativeEvent.isComposing)return!1;if(e.key===`ArrowDown`||e.key===`ArrowUp`)a(Math.max(0,Math.min(u.length-1,f+(e.key===`ArrowDown`?1:-1))));else if(e.key===`Tab`&&!e.shiftKey||e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)p(f);else if(e.key===`Escape`)s(l?.start??null),e.stopPropagation();else return!1;return e.preventDefault(),!0};return{list:d?(0,V.jsx)(WD,{items:u,at:f,className:e.listClassName??``,onPick:p}):null,field:{onChange:t=>{r(t.target.selectionStart),a(0),e.onChange(t.target.value)},onSelect:e=>r(e.currentTarget.selectionStart),onKeyDown:t=>{m(t)||!e.onEnter||t.key!==`Enter`||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),e.onEnter())}}}}function KD(e,t){fn(e,void 0,t)}function qD(){fn(void 0,void 0,void 0,void 0,!0)}var JD=`rove.web.newSession.worktree`,YD=``;function XD({model:e,seed:t}){let n=t.repo;B();let r=v(e.selection).taskId,i=e.tasks.get()?.tasks.find(e=>e.id===r)?.repo,a=TC(e,n??i,t.engine),o=Ns(e,`repos.list`)?.repos,s=e=>t.ungrouped?void 0:(t.machine?void 0:n)??i??e?.[0],[c,l]=(0,g.useState)(o??[]),[u,d]=(0,g.useState)(()=>Ns(e,`fs.subdirs`,{path:`~/`})?.home??``),[f,p]=(0,g.useState)(()=>kD(s(o),t)),[m,h]=(0,g.useState)(()=>Object.fromEntries(f.flatMap(t=>{let n=Ns(e,`repo.probe`,{path:t});return n?[[t,n]]:[]}))),_=(0,g.useRef)(new Set),[y,b]=(0,g.useState)(t.ungrouped===!0),x=()=>{b(!0),p([])},[S,C]=(0,g.useState)(()=>AD(s(o),t)),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(()=>(t.prompt!==void 0&&(YD=t.prompt),YD)),A=e=>{YD=e,k(e)},[j,ee]=(0,g.useState)(``),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,te]=(0,g.useState)(``),[L,ne]=(0,g.useState)(()=>t.worktree??localStorage.getItem(JD)!==`0`),re=e=>{localStorage.setItem(JD,e?`1`:`0`),ne(e)},[ie,R]=(0,g.useState)(null),{attachments:ae,attach:oe,remove:se,clear:ce}=Uo(e,R),le=(0,g.useRef)(null),ue=gE(e),[de,fe]=(0,g.useState)(t.machine??``),pe=de!==``,me=pe?null:zo(e=>void oe(e)),he=ue.find(e=>e.alias===de)?.hostLabel||de,ge=eD(e,de);$E(e,ue);let[_e,ve]=(0,g.useState)(null),[ye,be]=(0,g.useState)(``);(0,g.useEffect)(()=>{Promise.all([Fs(e,`repos.list`),Fs(e,`fs.subdirs`,{path:`~/`})]).then(([e,n])=>{l(e.repos),d(n.home);let r=s(e.repos);p(e=>e.length>0||!r?e:kD(r,t)),C(e=>({...e,...AD(r,t)}))}).catch(()=>{})},[e,n]);let xe=!pe&&!L&&f.length===1,Se=f[0]??``;(0,g.useEffect)(()=>{for(let t of f)_.current.has(t)||(_.current.add(t),Fs(e,`repo.probe`,{path:t}).then(e=>h(n=>({...n,[t]:e}))).catch(()=>{}))},[e,f]),(0,g.useEffect)(()=>{!pe||!ge.loaded||de!==t.machine||ve(e=>e??JE(n,ge.repos))},[ge.loaded]),(0,g.useEffect)(()=>le.current?.focus(),[]);let Ce=!pe&&!y&&!xe,we=cD(a,Ce),Te=a.engines.find(e=>e.id===a.engine),Ee=gs(Te,z(`newSession.modelDefault`)),De=_s(Te,z(`newSession.effortDefault`)),Oe=Ee.some(e=>e.id===j)?j:``,ke=De.some(e=>e.id===M)?M:``,Ae=async t=>{R(null),F(!0),te(z(`newSession.cloning`,{source:t}));try{let n=ts(es((localStorage.getItem(`rove.web.cloneParent`)||`~/`).trim(),u)),r=await e.client.request(`repo.clone`,{url:t,parentDir:n},te);l(e=>e.includes(r.path)?e:[...e,r.path]),p(e=>e.includes(r.path)?e:Cs(e,r.path)),b(!1),D(``)}catch(e){R(oD(e))}finally{F(!1),te(``)}},Me=async n=>{if(!_e)return R(z(`newSession.needRepo`));if(n&&!O.trim())return R(z(`newSession.needPrompt`));F(!0),te(_e.clone?z(`newSession.cloningOn`,{source:_e.ref,machine:he}):z(`newSession.startingOn`,{machine:he}));try{let r=await aD(e,{pick:_e,machine:de,engine:a.engine,prompt:O.trim(),begin:n,baseRef:ye});YD=``,dn.set(null),r&&e.selectWhenListed(r),t.retryOf&&r&&ND(e,t.retryOf)}catch(e){R(oD(e))}finally{F(!1),te(``)}},Ne=async(n=!0,r)=>{if(R(null),pe)return Me(n);if(!Se&&!y)return R(z(`newSession.needRepo`));if((n||r)&&!O.trim())return R(z(`newSession.needPrompt`));F(!0);let i=Vo(O.trim(),ae);try{let o=await Promise.all(f.map(t=>e.client.request(`repo.probe`,{path:t}))),s=o.find(e=>!e.ok);if(s)throw Error(s.reason??s.repo);let c,l;if(y)c=await Es(e.client.request.bind(e.client),a.engine,O,n);else if(xe)c=await Ds(e.client.request.bind(e.client),o[0]?.repo??Se,a.engine,O,n,i);else{let r=await e.client.request(`task.spawn`,Ts({repos:f.map((e,t)=>({repo:o[t]?.repo??e,baseRef:S[e]??``})),branch:w.trim(),engine:a.engine,commandFrom:jD(t,a.engine),engines:n?we.ids:[],prompt:i,begin:n,model:Oe,effort:ke}));c=r.taskIds[0],l=r.groupId}r&&c&&await gD(e.client,c,r,i).then(()=>G(z(`newSession.laterSet`,{time:hD(r)}))).catch(e=>G(oD(e),`error`)),YD=``,ce(),dn.set(null),l?ga(l):c&&e.selectWhenListed(c),t.retryOf&&c&&ND(e,t.retryOf)}catch(e){let t=xs(e);t?(YD=``,ce(),dn.set(null),G(e instanceof Error?e.message:String(e),`error`),ga(t)):R(e instanceof Error?e.message:String(e))}finally{F(!1)}},H=GD({value:O,onChange:A,area:le,onEnter:()=>void Ne()});return(0,V.jsxs)(`div`,{className:_E,children:[(0,V.jsxs)(`div`,{className:vE,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-accent`,children:z(`newSession.title`)}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:z(`newSession.tagline`)})]}),(0,V.jsxs)(`form`,{className:yE,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,V.jsxs)(`div`,{className:bE,...me?.drop,children:[(0,V.jsx)(`textarea`,{ref:le,className:SE,rows:4,spellCheck:!1,placeholder:z(`newSession.placeholder`),value:O,disabled:P,onPaste:me?.onPaste,...H.field}),H.list,(0,V.jsxs)(`div`,{className:xE,children:[!pe&&!y&&!we.comparing&&(0,V.jsx)(_D,{disabled:P,onSchedule:e=>void Ne(!1,e),onInvalid:R}),(0,V.jsx)(`button`,{type:`button`,className:EE(),disabled:P||we.comparing,title:we.comparing?z(`compare.needsPrompt`):void 0,onClick:()=>void Ne(!1),children:z(`newSession.createOnly`)}),(0,V.jsx)(`button`,{type:`submit`,className:je(),disabled:P,children:z(`newSession.start`)})]})]}),(0,V.jsxs)(`div`,{className:CE,children:[(0,V.jsx)(rD,{machines:ue,value:de,onPick:e=>{fe(e),ve(null),be(``),D(``),R(null),b(!1)}}),(0,V.jsx)(VE,{field:`repo`,title:!pe&&f.length>1?z(`newSession.repoCount`,{count:f.length}):z(`newSession.repo`),label:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(RE,{}),Ss(pe?_e?[_e.ref]:[]:f)||z(y?`rail.noProject`:`newSession.repo`),_e?.clone&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,z(`newSession.cloneTag`)]})]}),children:t=>(0,V.jsx)(yD,{model:e,saved:pe?ge.repos.map(qE):c,picked:pe?_e?[_e.ref]:[]:f,primary:pe?``:Se,home:pe?``:u,query:E,onQuery:D,onToggle:e=>{if(R(null),!pe)return b(!1),p(t=>Cs(t,e));ve({ref:e,clone:!1}),t()},onClone:e=>pe?ve({ref:e,clone:!0}):void Ae(e),close:t,remote:pe?{name:he,empty:tD(de,ge),blocked:ge.problem!==``}:void 0,ungrouped:pe?void 0:{on:y,pick:x}})}),(0,V.jsx)(sD,{remote:pe,remotePick:_e,remoteBase:ye,onRemoteBase:be,ungrouped:y,inPlace:xe,onToggleWorktree:()=>re(!L),repos:f,probes:m,bases:S,onBase:(e,t)=>C(n=>({...n,[e]:t})),branchName:w,onBranchName:T}),me&&(0,V.jsxs)(Bo,{className:`${EE(ae.length>0)} cursor-pointer`,title:z(`newSession.attachHint`),disabled:P,onFiles:e=>void oe(e),children:[(0,V.jsx)(BE,{}),z(`newSession.attach`)]}),(0,V.jsx)(`span`,{className:wE}),(0,V.jsx)(lD,{choice:a,picks:we,available:Ce}),!xe&&!pe&&!y&&!we.comparing&&(Ee.length>0||De.length>0)&&(0,V.jsx)(uD,{models:Ee,model:Oe,onModel:ee,efforts:De,effort:ke,onEffort:N})]}),!pe&&(0,V.jsx)(Wo,{attachments:ae,onRemove:se}),P&&I&&(0,V.jsx)(`p`,{className:`text-muted`,"data-field":`clone-progress`,children:I}),ie&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,ie]})]}),!pe&&(0,V.jsx)(`button`,{type:`button`,className:`mt-2 self-center px-1.5 py-0.5 text-subtle focus-visible:text-ink touch:mt-0.5 touch:py-2 [&:hover]:text-ink`,onClick:()=>W.set((0,V.jsx)(DD,{model:e,repo:Se||void 0})),children:z(`newSession.moreWays`)})]})}var ZD=[`needs`,`working`,`ready`,`idle`],QD=`~state:`;function $D(e){switch(e.rowStatus?.kind){case`attention`:case`needs-input`:case`unseen`:return`needs`;case`busy`:case`running`:return`working`}switch(e.group){case`waiting-on-you`:return`needs`;case`working`:return`working`;case`landing`:case`ready-for-review`:return`ready`}return e.pr?.lifecycle===`open`||e.status===`done`?`ready`:`idle`}var eO=e=>e&&e.kind!==`main`&&!aw(e)?zC(e.repo):void 0;function tO(e,t){let n=ow(e,t.sort),{children:r,nested:i}=dw([{repo:``,label:``,tasks:n}]),a=n.filter(e=>!i.has(e.id)),o=KC(a),s=e=>{let t=[],n=new Set,i=e=>{if(!n.has(e.id)){n.add(e.id),t.push(e);for(let t of r.get(e.id)??[])i(t)}};return i(e),t},c=new Map;for(let e of a){let t=GC(e),n=((t===null?void 0:o.get(t))??[e]).map(s),r=n.flat().map($D).reduce((e,t)=>ZD.indexOf(t)<ZD.indexOf(e)?t:e);for(let e of n)for(let t of e)c.set(t.id,r)}return ZD.flatMap(e=>{let t=n.filter(t=>c.get(t.id)===e);return t.length===0?[]:[{repo:``,label:z(`rail.state.${e}`),key:`${QD}${e}`,tasks:t}]})}function nO(e){let t=new Set(e.machines.map(e=>e.alias));return{rows:rO(mw(tO([...e.tasks.filter(e=>!e.routine),...e.remote.filter(e=>!e.routine&&e.machine!==void 0&&t.has(e.machine.id))],e),e.query,e.fold).map(e=>{if(e.kind!==`project`)return e;let t=e.id.slice(`project:${QD}`.length);return{id:`state:${t}`,kind:`state`,state:t,label:e.label,count:0}})),groups:[]}}function rO(e){let t=new Map,n=``;for(let r of e)r.kind===`state`?n=r.id:r.kind===`task`&&t.set(n,(t.get(n)??0)+1);return e.map(e=>e.kind===`state`?{...e,count:t.get(e.id)??0}:e)}var iO=new Set([`refused`,`timeout`,`host-key-changed`,`host-key-unverified`,`auth-denied`,`unresolved`,`ssh-failed`,`no-rove`,`no-daemon`,`bad-status`,`handshake`,`no-forwarding`,`lost`]);function aO(e){return e&&iO.has(e)?`machines.reason.${e}`:null}function oO(e,t){return e.filter(e=>e.machine?.id===t&&!e.routine&&!e.deleting)}function sO(e){let t=ZD.map(e=>({state:e,tasks:[]}));for(let n of e)t[ZD.indexOf($D(n))]?.tasks.push(n);return t.filter(e=>e.tasks.length>0)}var cO=`flex flex-col font-mono text-meta`,lO=`flex flex-col gap-1 border-t-hairline border-line py-2.5 first:border-t-0 first:pt-0`,uO=`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,dO=`min-w-0 text-ink wrap-anywhere`,fO=`m-0 text-muted wrap-anywhere`,pO=`flex flex-wrap gap-x-3.5 gap-y-1 pt-0.5 whitespace-nowrap`,mO=`mt-1.5 mb-0.5 text-subtle`,hO=`flex min-w-0 items-baseline gap-2 pl-2`,gO=`min-w-0 flex-1 truncate text-left`,_O=`min-w-0 max-w-[55%] flex-none truncate text-muted`;function vO(e){W.set((0,V.jsx)(SO,{model:e}))}function yO({model:e,tasks:t}){let n=t=>{yn(),e.select(t.id),pa()};return sO(t).map(e=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`${mO} m-0`,children:z(`rail.state.${e.state}`)}),e.tasks.map(e=>(0,V.jsxs)(H,{variant:`row`,className:`${hO} w-full rounded-sm py-0.5 hover:bg-hover`,onClick:()=>n(e),children:[(0,V.jsx)(`span`,{className:gO,children:e.label}),(0,V.jsx)(`span`,{className:_O,children:e.branch})]},e.id))]},e.state))}function bO({model:e,alias:t}){let[n,r]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return Fs(e,`machines.repos`,{machine:t}).then(e=>n&&r(e),e=>n&&r({failed:e instanceof Error?e.message:String(e)})),()=>{n=!1}},[e,t]),n?`failed`in n?(0,V.jsx)(`p`,{className:fO,children:z(`machines.reposFailed`,{message:n.failed})}):n.reason?(0,V.jsx)(`p`,{className:fO,children:z(`machines.reposFailed`,{message:n.message??n.reason})}):n.repos.length===0?(0,V.jsx)(`p`,{className:fO,children:z(`machines.noRepos`)}):n.repos.map(e=>(0,V.jsxs)(`div`,{className:hO,children:[(0,V.jsx)(`span`,{className:gO,children:e.id}),(0,V.jsx)(`span`,{className:_O,title:e.primary??e.checkouts[0],children:e.primary??e.checkouts[0]??``})]},e.id)):(0,V.jsx)(`p`,{className:fO,children:z(`machines.loading`)})}function xO(e){let{model:t,row:n,tasks:r,words:i}=e,[a,o]=(0,g.useState)(null),s=n.state===`online`,c=aO(n.reason),l=sO(r).map(e=>`${e.tasks.length} ${z(`rail.state.${e.state}`)}`),u=e=>o(a===e?null:e);return(0,V.jsxs)(`section`,{className:lO,children:[(0,V.jsxs)(`div`,{className:uO,children:[(0,V.jsx)(`span`,{className:`${dO} ${s?``:CT.warning}`,children:dE(n,i)}),(0,V.jsx)(`span`,{className:`text-muted`,children:l.length>0?l.join(` · `):z(`machines.noTasks`)})]}),c&&(0,V.jsx)(`p`,{className:`m-0 text-muted wrap-anywhere`,children:z(c)}),(0,V.jsxs)(`div`,{className:pO,children:[s&&(0,V.jsx)(H,{hit:`tight`,onClick:()=>{yn(),KD(void 0,n.alias)},children:z(`machines.newHere`)}),r.length>0&&(0,V.jsx)(H,{hit:`tight`,"aria-expanded":a===`tasks`,onClick:()=>u(`tasks`),children:z(a===`tasks`?`machines.hide`:`machines.tasks`)}),s&&(0,V.jsx)(H,{hit:`tight`,"aria-expanded":a===`repos`,onClick:()=>u(`repos`),children:z(a===`repos`?`machines.hide`:`machines.repos`)})]}),a===`tasks`&&(0,V.jsx)(yO,{model:t,tasks:r}),a===`repos`&&(0,V.jsx)(bO,{model:t,alias:n.alias})]})}function SO({model:e}){let t=B(),n=gE(e),r=v(e.remote),i=(t===`zh`?Dr:Er).machine;return(0,V.jsx)(ir,{title:z(`machines.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:`${Pn} ${cO}`,children:[n.length===0&&(0,V.jsx)(`p`,{className:`m-0 text-muted wrap-anywhere`,children:z(`machines.none`)}),n.map(t=>(0,V.jsx)(xO,{model:e,row:t,tasks:oO(r,t.alias),words:i},t.alias))]})})}function CO(e,t,n=300){let r=0,i,a=()=>{r++,i?.(),i=void 0};return{stop:a,run:o=>{a();let s=o.trim();if(s.length<2){t({kind:`idle`});return}let c=r,l=setTimeout(()=>{t({kind:`searching`}),e(s).then(e=>c===r&&t({kind:`done`,query:s,reply:e}),e=>c===r&&t({kind:`failed`,message:e instanceof Error?e.message:String(e)}))},n);i=()=>clearTimeout(l)}}}var wO=`mx-1.5 mt-2 mb-0.5 font-mono text-meta font-semibold normal-nums text-subtle first:mt-0`,TO=`mx-1.5 my-1 text-meta text-muted [overflow-wrap:anywhere]`,EO=e=>`flex w-full min-w-0 cursor-pointer flex-col gap-0.5 rounded-sm px-1.5 py-1.5 text-left text-ink [font:inherit] touch:py-2.5 ${e?`is-selected bg-hover`:``}`,DO=`flex min-w-0 items-baseline gap-2`,OO=`min-w-0 flex-1 truncate text-body`,kO=`whitespace-nowrap text-meta text-muted`,AO=`text-meta text-muted [overflow-wrap:anywhere]`,jO=`rounded-xs bg-accent/25 text-ink`;function MO(e,t){let[n,r]=(0,g.useState)({kind:`idle`});return(0,g.useEffect)(()=>{let n=CO(t=>e.client.request(`sessions.search`,{query:t}),r);return n.run(t),n.stop},[e,t]),n}function NO(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=0;for(let t=r.indexOf(i);i&&t>=0;t=r.indexOf(i,t+i.length))t>a&&n.push(e.slice(a,t)),n.push({hit:e.slice(t,t+i.length),at:t}),a=t+i.length;return n.push(e.slice(a)),n.map(e=>typeof e==`string`?e:(0,V.jsx)(`mark`,{className:jO,children:e.hit},e.at))}function PO({children:e}){return(0,V.jsx)(`h3`,{className:wO,children:e})}function FO({children:e,error:t}){return(0,V.jsx)(`p`,{className:`${TO} ${t?`text-error`:``}`,children:e})}function IO(e){return(0,V.jsx)(H,{variant:`row`,className:EO(e.selected),onMouseEnter:e.onHover,onClick:e.onOpen,children:(0,V.jsxs)(`span`,{className:DO,children:[(0,V.jsx)(`span`,{className:OO,children:e.title}),(0,V.jsx)(`span`,{className:kO,children:e.repo})]})})}function LO(e){let{hit:t}=e;return(0,V.jsxs)(H,{variant:`row`,className:EO(e.selected),onMouseEnter:e.onHover,onClick:e.onOpen,children:[(0,V.jsxs)(`span`,{className:DO,children:[(0,V.jsx)(`span`,{className:OO,children:t.title}),(0,V.jsxs)(`span`,{className:kO,children:[z(t.role===`user`?`search.you`:`search.agent`),` · `,Mo(Date.now()-Date.parse(t.at))]})]}),(0,V.jsx)(`span`,{className:AO,children:NO(t.snippet,e.query)})]})}var RO=_(`issues`);function zO(e,t,n){return{repo:e.repo,baseBranch:t,prompt:n,worktree:!0}}var BO=.2,VO=[`files`,`chat`,`diff`,`browser`];function HO(){return{top:{tabs:[{id:`t1`,kind:`files`}],active:`t1`},bottom:null,ratio:.5,focus:`top`,recent:[`t1`],next:2}}function UO(e){return e.bottom?[[`top`,e.top],[`bottom`,e.bottom]]:[[`top`,e.top]]}function WO(e){let t=e=>Number(e.id.slice(1));return UO(e).flatMap(([,e])=>e.tabs).sort((e,n)=>t(e)-t(n))}function GO(e,t){for(let[n,r]of UO(e)){let e=r.tabs.find(e=>e.id===t);if(e)return{tab:e,name:n,group:r}}return null}function KO(e,t){let n=WO(e).filter(e=>e.kind===t);for(let t of[...e.recent].reverse()){let e=n.find(e=>e.id===t);if(e)return e}return n[0]??null}function qO(e){return e.urls[e.at]??``}function JO(e){return e.slice(e.lastIndexOf(`/`)+1)}function YO(e){try{return new URL(e).host.replace(/^www\./,``)}catch{return e}}function XO(e,t){for(let[n,r]of UO(e))if(r.tabs.some(e=>e.kind===t))return n;return e.bottom?e.focus:`top`}function ZO(e,t,n){let r=e.tabs.filter(e=>e.id!==n).map(e=>e.id);for(let e of[...t].reverse())if(r.includes(e))return e;return r[0]??null}function QO(e){let{top:t,bottom:n}=e;n&&n.tabs.length===0&&(n=null),t.tabs.length===0&&n&&([t,n]=[n,null]);let r=new Set([...t.tabs,...n?.tabs??[]].map(e=>e.id)),i=e.recent.filter(e=>r.has(e)),a=e=>e.active&&e.tabs.some(t=>t.id===e.active)?e:{...e,active:ZO(e,i)};return{...e,top:a(t),bottom:n&&a(n),recent:i,focus:n?e.focus:`top`}}function $O(e,t,n){return t===`top`?{...e,top:n}:{...e,bottom:n}}function ek(e,t){let n=GO(e,t);if(!n)return e;let{group:r,name:i}=n,a=[...e.recent.filter(e=>e!==t),t];return r.active===t&&e.focus===i&&e.recent.at(-1)===t?e:{...$O(e,i,{...r,active:t}),focus:i,recent:a}}function tk(e){let t=WO(e);if(t.length<=12)return e;let n=new Set(UO(e).map(([,e])=>e.active)),r=t.filter(e=>!n.has(e.id)).sort((t,n)=>e.recent.indexOf(t.id)-e.recent.indexOf(n.id))[0];return r?mk(e,r.id):e}function nk(e,t,n){let r=`t${e.next}`,i=t===`bottom`&&e.bottom?`bottom`:`top`,a=i===`bottom`&&e.bottom?e.bottom:e.top;return tk(ek($O({...e,next:e.next+1},i,{...a,tabs:[...a.tabs,n(r)]}),r))}var rk=e=>({id:e,kind:`browser`,urls:[],at:-1});function ik(e,t){return nk(e,t,e=>({id:e,kind:`files`}))}function ak(e,t){return nk(e,t,rk)}function ok(e,t,n){let r=WO(e).find(e=>e.kind===`diff`&&e.path===t);return r?r.kind===`diff`&&r.scope!==n?ek(dk(e,{...r,scope:n}),r.id):ek(e,r.id):nk(e,XO(e,`diff`),e=>({id:e,kind:`diff`,path:t,scope:n}))}function sk(e,t){let n=WO(e).filter(e=>e.kind===`browser`),r=n.find(e=>qO(e)===t);if(r)return ek(e,r.id);let i=n.find(e=>qO(e)===``);return i?fk(e,i.id,t):fk(nk(e,XO(e,`browser`),rk),`t${e.next}`,t)}function ck(e,t){let n=KO(e,t);return n?ek(e,n.id):t===`diff`?ok(e,`.`,`working`):nk(e,XO(e,t),e=>t===`files`||t===`chat`?{id:e,kind:t}:rk(e))}function lk(e){let t=e.recent.at(-1),n=t?GO(e,t):null,r=n&&n.group.active===t?t:e.top.active;return(r?GO(e,r)?.tab.kind:null)??null}function uk(e,t,n){return t&&lk(e)===n?{panel:e,open:!1}:{panel:ck(e,n),open:!0}}function dk(e,t){let n=e=>({...e,tabs:e.tabs.map(e=>e.id===t.id?t:e)});return{...e,top:n(e.top),bottom:e.bottom&&n(e.bottom)}}function fk(e,t,n){let r=GO(e,t)?.tab;if(r?.kind!==`browser`||qO(r)===n)return e;let i=[...r.urls.slice(0,r.at+1),n].slice(-30);return dk(e,{...r,urls:i,at:i.length-1})}function pk(e,t,n){let r=GO(e,t)?.tab;return r?.kind!==`browser`||n===r.at||n<0||n>=r.urls.length?e:dk(e,{...r,at:n})}function mk(e,t){let n=GO(e,t);if(!n)return e;let{group:r}=n,i=r.tabs.filter(e=>e.id!==t),a=e.recent.filter(e=>e!==t),o=r.active===t?ZO(r,a,t):r.active;return QO({...$O(e,n.name,{tabs:i,active:o}),recent:a})}function hk(e,t){return WO(e).reduce((e,n)=>n.id===t?e:mk(e,n.id),e)}function gk(e,t,n,r){let i=GO(e,t);if(!i)return e;let a=i.group,o=a.tabs.filter(e=>e.id!==t),s=a.tabs.findIndex(e=>e.id===t);if(i.name===n){let c=Math.max(0,Math.min(o.length,(r??o.length)-+(r!==void 0&&r>s)));return ek(c===s?e:$O(e,n,{...a,tabs:[...o.slice(0,c),i.tab,...o.slice(c)]}),t)}let c=e.recent.filter(e=>e!==t),l=$O(e,i.name,{tabs:o,active:a.active===t?ZO(a,c,t):a.active}),u=(n===`top`?l.top:l.bottom)?.tabs??[],d=Math.max(0,Math.min(u.length,r??u.length));return ek(QO($O({...l,recent:c},n,{tabs:[...u.slice(0,d),i.tab,...u.slice(d)],active:t})),t)}function _k(e,t){let n=Math.max(BO,Math.min(.8,t));return Math.abs(n-e.ratio)<.001?e:{...e,ratio:n}}function vk(e,t,n){let r=new Map(n.map(e=>[e.id,e.kind])),i=[...e.filter(e=>r.has(e)&&!t.includes(e)),...t.filter(e=>r.has(e))],a=i.filter(e=>r.get(e)===`browser`),o=new Set(a.slice(0,Math.max(0,a.length-3)).filter(e=>!t.includes(e)));return i=i.filter(e=>!o.has(e)),i}function yk(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||!/^t\d+$/.test(t.id))return null;if(t.kind===`files`||t.kind===`chat`)return{id:t.id,kind:t.kind};if(t.kind===`diff`&&typeof t.path==`string`&&t.path!==``){let e=t.scope===`branch`||t.scope===`task`?t.scope:`working`;return{id:t.id,kind:`diff`,path:t.path,scope:e}}if(t.kind===`browser`&&Array.isArray(t.urls)){let e=t.urls.filter(e=>typeof e==`string`&&e!==``).slice(-30),n=typeof t.at==`number`&&Number.isInteger(t.at)?Math.min(e.length-1,Math.max(-1,t.at)):e.length-1;return{id:t.id,kind:`browser`,urls:e,at:e.length===0?-1:Math.max(0,n)}}return null}function bk(e,t){if(!e||typeof e!=`object`||!(`tabs`in e)||!Array.isArray(e.tabs))return null;let n=[];for(let r of e.tabs){let e=yk(r);!e||t.has(e.id)||(t.add(e.id),n.push(e))}return{tabs:n,active:`active`in e&&typeof e.active==`string`?e.active:null}}function xk(e){if(!e||typeof e!=`object`)return null;let t=e,n=new Set,r=bk(t.top,n);if(!r)return null;let i=bk(t.bottom,n),a=Math.max(0,...[...n].map(e=>Number(e.slice(1)))),o=typeof t.ratio==`number`&&Number.isFinite(t.ratio)?t.ratio:.5;return QO({top:r,bottom:i,ratio:Math.max(BO,Math.min(.8,o)),focus:t.focus===`bottom`?`bottom`:`top`,recent:Array.isArray(t.recent)?t.recent.filter(e=>typeof e==`string`):[],next:Math.max(a+1,typeof t.next==`number`&&Number.isInteger(t.next)?t.next:0)})}function Sk(e,t){let n=HO(),r=typeof t==`string`&&t!==``?t:``;if(e!==`browser`&&!r)return n;let i=ak(n,`top`),a=r?fk(i,`t2`,r):i;return e===`browser`?a:ek(a,`t1`)}function Ck(e){try{let t=JSON.parse(e??`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?Object.entries(t):[]}catch{return[]}}function wk(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));r[t]=n;for(let e of Object.keys(r).slice(0,-50))delete r[e];return r}function Tk(e,t){let n={};for(let[t,r]of Ck(e)){let e=xk(r);e&&(n[t]=e)}let r=new Map(Ck(t.tab).filter(([,e])=>VO.includes(e))),i=new Map(Ck(t.url)),a=[...new Set([...r.keys(),...i.keys()])].filter(e=>!(e in n));n={...Object.fromEntries(a.map(e=>[e,Sk(r.get(e),i.get(e))])),...n};for(let e of Object.keys(n).slice(0,-50))delete n[e];return n}var Ek=[`files`,`diff`,`browser`];function Dk(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.taskId==`string`&&t.taskId!==``&&Ek.includes(t.view)&&typeof t.at==`number`&&(t.url===void 0||typeof t.url==`string`)&&(t.path===void 0||typeof t.path==`string`)}function Ok(e){return e.narrow?{panel:!1,panelOpen:!1,narrow:!0}:{panel:!0,panelOpen:e.panelOpen&&!e.zen,narrow:!1}}function kk(e,t){return{tab:e.path?`diff`:e.view,...e.view===`browser`&&e.url?{url:e.url}:{},...e.view!==`browser`&&e.path?{diff:e.path}:{},show:t.taskId===e.taskId&&!t.narrow}}function Ak(e,t){return t.url?sk(e,t.url):t.diff?ok(e,t.diff,`working`):ck(e,t.tab)}var jk=`rove.web.panels`,Mk=`rove.web.panelTab`,Nk=`rove.web.panelUrl`;function Pk(){let e={tab:localStorage.getItem(Mk),url:localStorage.getItem(Nk)},t=Tk(localStorage.getItem(jk),e);return(e.tab!==null||e.url!==null)&&(localStorage.setItem(jk,JSON.stringify(t)),localStorage.removeItem(Mk),localStorage.removeItem(Nk)),t}var Fk=_(Pk()),Ik=HO();function Lk(e){return v(Fk)[e]??Ik}function Rk(e,t){let n=Fk.get()[e]??Ik,r=t(n);if(r===n)return;let i=wk(Fk.get(),e,r);Fk.set(i),localStorage.setItem(jk,JSON.stringify(i))}function zk(e,t){Rk(e,e=>ck(e,t)),Ua.set(!0),ya()&&za.set(t)}function Bk(e,t){let n=uk(Fk.get()[e]??Ik,Ua.get()&&!un.get(),t);Rk(e,()=>n.panel),Ua.set(n.open),n.open&&un.get()&&un.set(!1)}function Vk(e){Rk(e.taskId,t=>ok(t,e.path,e.scope)),Ua.set(!0),un.get()&&un.set(!1),ya()&&za.set(`diff`)}function Hk(e,t){Rk(e,e=>sk(e,t)),Ua.set(!0),un.get()&&un.set(!1),ya()&&za.set(`browser`)}function Uk(e,t){Rk(e,e=>mk(e,t));let n=za.get();ya()&&n!==`terminal`&&!KO(Fk.get()[e]??Ik,n)&&zk(e,`files`)}function Wk(e,t){let n=kk(e,{taskId:t,narrow:ya()});Rk(e.taskId,e=>Ak(e,n)),n.show&&(Ua.set(!0),un.get()&&un.set(!1))}var Gk=_(null),Kk=0;function qk(e,t){Gk.set({taskId:e,hit:t,nonce:++Kk}),zk(e,`chat`),un.get()&&un.set(!1)}var Jk=10;function Yk(e,t){let n=e=>e.surface===t?0:e.surface?1:2,r=Yi().filter(n=>Xi(n,t)&&n.live?.(e)!==!1).map((e,t)=>({command:e,index:t})).sort((e,t)=>n(e.command)-n(t.command)||Number(e.command.prefix)-Number(t.command.prefix)||e.index-t.index),i=new Set,a=[];for(let{command:e}of r){let t=e.chords[0];!t||e.id===`palette.open`||i.has(e.id)||(i.add(e.id),a.push({command:e,name:bo(e.id),raw:e.prefix?`${Zr()} + ${t}`:t}))}return a}function Xk(e){let t=document.activeElement instanceof HTMLElement?document.activeElement:null;W.set((0,V.jsx)(Qk,{model:e,surface:Qi(),origin:t}))}var Zk=8;function Qk({model:e,surface:t,origin:n}){B();let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(0),s=(0,g.useRef)(null),c=v(Kr),l=v(e.tasks),u=v(e.remote),d=(0,g.useMemo)(()=>Yk(e,t),[e,t,c]).filter(e=>oo(r,e.name,e.raw)),f=(gE(e).length>0?[{name:z(`machines.title`)}]:[]).filter(e=>oo(r,e.name,``)),p=r.trim(),m=p===``?[]:[...l?.tasks??[],...u].filter(e=>!e.routine&&!e.deleting&&[e.label,e.title,e.branch,zC(e.repo)].some(e=>e!==``&&Qa(p,e))).slice(0,Zk),h=v(e.installedMods).has(`issues`),_=[{id:`usage`,name:z(`usage.title`)},...h?[{id:`issues`,name:z(`reviewQueue.palette`),source:`reviews`}]:[]].filter(e=>p===``||Qa(p,e.name)),y=MO(e,r),b=y.kind===`done`?y.reply.matches:[],x=[...d.map(e=>({kind:`command`,row:e})),..._.map(e=>({kind:`page`,...e})),...f.map(e=>({kind:`machines`,...e})),...m.map(e=>({kind:`task`,task:e})),...b.map(e=>({kind:`hit`,hit:e}))],S=Math.min(a,Math.max(0,x.length-1));(0,g.useEffect)(()=>()=>n?.focus(),[n]),(0,g.useEffect)(()=>{s.current?.querySelector(`.is-selected`)?.scrollIntoView({block:`nearest`})},[S]);let C=t=>{if(t.kind===`machines`){vO(e);return}if(yn(),n?.focus(),t.kind===`command`){t.row.command.live?.(e)===!1?G(_o(`unavailable`),`error`):t.row.command.run(e);return}if(t.kind===`page`){t.source&&RO.set(t.source),ha(t.id);return}t.kind===`task`?e.select(t.task.id):e.select(t.hit.taskId,t.hit.tabId??null),pa(),t.kind===`hit`&&qk(t.hit.taskId,t.hit)},w=e=>{if(e.key===`ArrowDown`)o(Math.min(x.length-1,S+1));else if(e.key===`ArrowUp`)o(Math.max(0,S-1));else if(e.key===`Enter`){let e=x[S];e&&C(e)}else return;e.preventDefault()},T=p!==``&&(m.length>0||p.length>=2),E=0,D=()=>E++;return(0,V.jsx)(ir,{title:_o(`palette`),wide:!0,children:(0,V.jsxs)(`div`,{className:`${Pn} palette`,onKeyDown:w,children:[(0,V.jsx)(`input`,{className:ut,autoFocus:!0,spellCheck:!1,value:r,placeholder:_o(`search`),onChange:e=>{i(e.target.value),o(0)}}),(0,V.jsxs)(`div`,{className:st,ref:s,style:{maxHeight:`${(T?18:Jk)*1.9}em`},children:[x.length===0&&y.kind!==`searching`&&(0,V.jsx)(`p`,{className:`text-muted`,children:_o(`noResults`)}),T&&d.length>0&&(0,V.jsx)(PO,{children:z(`search.commands`)}),d.map(e=>{let t=D();return(0,V.jsx)(`button`,{type:`button`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`command`,row:e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},e.command.id)}),_.map(e=>{let t=D();return(0,V.jsx)(H,{variant:`row`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`page`,...e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},e.id)}),f.map(e=>{let t=D();return(0,V.jsx)(H,{variant:`row`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`machines`,...e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},`machines`)}),m.length>0&&(0,V.jsx)(PO,{children:z(`search.tasks`)}),m.map(e=>{let t=D();return(0,V.jsx)(IO,{title:e.label,repo:zC(e.repo),selected:t===S,onHover:()=>o(t),onOpen:()=>C({kind:`task`,task:e})},e.id)}),y.kind!==`idle`&&(0,V.jsx)(PO,{children:z(`search.inConversations`)}),y.kind===`searching`&&(0,V.jsx)(FO,{children:z(`search.searching`)}),y.kind===`failed`&&(0,V.jsx)(FO,{error:!0,children:y.message}),y.kind===`done`&&b.length===0&&(0,V.jsx)(FO,{children:z(`search.none`,{query:y.query})}),b.map(e=>{let t=D();return(0,V.jsx)(LO,{hit:e,query:y.kind===`done`?y.query:``,selected:t===S,onHover:()=>o(t),onOpen:()=>C({kind:`hit`,hit:e})},`${e.taskId}:${e.tabId??``}:${e.at}:${t}`)}),y.kind===`done`&&y.reply.truncated&&(0,V.jsx)(FO,{children:z(`search.truncated`)}),y.kind===`done`&&y.reply.skipped.length>0&&(0,V.jsx)(FO,{children:z(`search.skipped`,{count:y.reply.skipped.length})})]}),(0,V.jsx)(`p`,{className:`keys-only text-muted`,children:_o(`run`)})]})})}var $k=_(null);function eA(e){let t=(document.activeElement?.closest(`.rail`)==null?null:$k.get())??e.selection.get().taskId;return e.tasks.get()?.tasks.find(e=>e.id===t)??null}var tA={autoRouting:{title:`Auto routing`,hint:"Routing by depth: a task says how deep the work is — swift, standard, deep — and this table says which engine, model and reasoning effort that depth runs on. Pick a depth in the new-task dialog (or `rove api add --tier`) and Rove fills those three fields from the row; you still see them and can change them before the task starts. enter (or click) a row to point it somewhere else, with the same picker a task uses. A row whose target cannot start says why here, not at launch.",unconfigured:`Auto routing is off: a depth has nowhere to route — its engine is blank. Point it somewhere below, or remove the empty autoRouting.<tier>.engine from state.json.`,engineDefault:`engine default`,ready:`● ready`,unavailable:`! unavailable — {reason}`,classifierTitle:`Classifier`,classifierHint:"The rows above say what each depth RUNS. This says who CHOOSES one: switch it on and `rove api add --tier auto` reads the task's first message and picks the depth for you. It is off by default, it is never required, and it can never fail a create — no key, no network, a timeout, or an answer it is not confident enough about all leave you on the depth you would have had.",classifierDataFlow:"! Turning the classifier on sends the task's first message to a third party that is NOT the engine vendor you picked — TypeSafe System One for `jev`, or whatever address you point `custom` at. It reads the text before your engine does. Nothing leaves this machine while it is off.",classifierLabel:`Choose with`,classifierOff:`off`,classifierCustomLabel:`custom`,classifierOffHint:`— nothing is sent anywhere`,classifierJevHint:`— TypeSafe System One, billed to your own key`,classifierCustomHint:`— your endpoint: POST the text, answer with a depth and a confidence`,endpointLabel:`Endpoint`,endpointUnset:`(none — enter one, then set Choose with to custom)`,endpointTitle:`Custom classifier endpoint`,endpointField:`URL`,endpointInvalidTitle:`Not a URL`,endpointInvalidBody:`The endpoint has to start with https://, or http:// for a loopback address (127.0.0.1, localhost, ::1) — over a network, plain http would carry the task's first 1,200 characters in cleartext. Leave it empty to clear it.`,thresholdLabel:`Confidence floor`,thresholdHint:`— below this, the depth is left alone`,thresholdTitle:`Confidence floor`,thresholdField:`0 to 1`,thresholdInvalidTitle:`Not a confidence`,thresholdInvalidBody:`The floor is a number between 0 and 1. 0.5 is the shipped default.`,keyLabel:`API key`,keyStored:`stored {hint} — enter to replace, empty to clear`,keyFromEnv:"from ${env} — the environment wins over a stored key",keyNone:`not set — enter to paste one`,keyTitle:`{env}`,keyPlaceholder:`paste the key; leave empty to clear the stored one`,keySaved:`● key stored in ~/.rove/secrets.json (owner-only, never in state.json)`,keyCustomUnused:`● no Authorization header is sent to a custom endpoint — set autoRouting.classifierCustomKeyEnv to the variable holding its key if it needs one`,keyNoVariableTitle:`No key variable for this endpoint`,keyNoVariableBody:`A custom classifier endpoint is sent no Authorization header until autoRouting.classifierCustomKeyEnv names the variable its key lives in. Set that first — a key stored under a name nothing reads is a key at rest for no purpose.`,keyWriteFailedTitle:`Key not saved`,keyWriteFailedBody:`~/.rove/secrets.json could not be written: {reason}. Check directory permissions and disk space, then save again.`,keyMissing:`! no key — nothing is chosen and tasks keep their usual depth`,keyPresentEnv:"● key read from ${env} in this process's environment"}},nA={autoRouting:{title:`自动路由`,hint:"按深度路由:任务说明这活有多深——轻快、标准、深入——这张表说明那一档跑在哪个引擎、哪个模型、哪个推理强度上。在新建任务对话框里选一档(或 `rove api add --tier`),Rove 就照那一行填进这三个字段;任务启动前你仍然看得见、改得了。enter(或点击)某一行,用和任务一样的选择器把它指到别处。目标起不来的行会在这里说明原因,而不是等到启动时才炸。",unconfigured:`自动路由已关闭:有一档无处可去——它的引擎是空的。在下面把它指到某个引擎,或从 state.json 里删掉空的 autoRouting.<tier>.engine。`,engineDefault:`引擎默认`,ready:`● 可用`,unavailable:`! 不可用——{reason}`,classifierTitle:`分类器`,classifierHint:"上面几行说的是每一档**跑什么**,这里决定**由谁来选**:打开之后,`rove api add --tier auto` 会读任务的第一句话替你选档。默认关着,从来不是必需的,也永远不会让建 task 失败——没 key、断网、超时、或者它自己没把握,都只是让你停在本来就会用的那一档上。",classifierDataFlow:"! 打开分类器,任务的第一句话会发给一个**不是你选的那个引擎厂商**的第三方——`jev` 是 TypeSafe System One,`custom` 是你自己填的地址。它比你的引擎更早读到这段文字。关着的时候什么都不发。",classifierLabel:`选档方式`,classifierOff:`关`,classifierCustomLabel:`自定义`,classifierOffHint:`——不向任何地方发送`,classifierJevHint:`——TypeSafe System One,走你自己的 key 计费`,classifierCustomHint:`——你自己的接口:POST 那段文本,返回一个档位加一个置信度`,endpointLabel:`接口地址`,endpointUnset:`(未填——先填一个,再把「选档方式」切到自定义)`,endpointTitle:`自定义分类器接口`,endpointField:`URL`,endpointInvalidTitle:`不是一个 URL`,endpointInvalidBody:`接口地址要以 https:// 开头;http:// 只在回环地址(127.0.0.1、localhost、::1)上接受——发到网络上的话,明文 http 会把任务的前 1200 个字符原样带走。留空则清除。`,thresholdLabel:`置信度下限`,thresholdHint:`——低于这个值就不动档位`,thresholdTitle:`置信度下限`,thresholdField:`0 到 1`,thresholdInvalidTitle:`不是一个置信度`,thresholdInvalidBody:`下限是 0 到 1 之间的数。出厂默认 0.5。`,keyLabel:`API key`,keyStored:`已存 {hint}——enter 可替换,留空清除`,keyFromEnv:"来自环境变量 ${env}——环境变量优先于存起来的那个",keyNone:`未设置——enter 粘贴一个`,keyTitle:`{env}`,keyPlaceholder:`粘贴 key;留空则清除已存的那个`,keySaved:`● key 存在 ~/.rove/secrets.json(仅本人可读,不会进 state.json)`,keyCustomUnused:`● 自定义接口不会收到 Authorization 头——它若需要凭据,把 autoRouting.classifierCustomKeyEnv 指向存它的变量`,keyNoVariableTitle:`这个接口还没有 key 变量`,keyNoVariableBody:`在 autoRouting.classifierCustomKeyEnv 指定存 key 的变量之前,自定义分类器接口不会收到任何 Authorization 头。先设那个——存在一个没人读的名字下面的 key,只是白白落在盘上。`,keyWriteFailedTitle:`key 没存下`,keyWriteFailedBody:`写不了 ~/.rove/secrets.json:{reason}。请检查目录权限和磁盘空间,再次保存。`,keyMissing:`! 没有 key——不会替你选档,任务保持原来的档位`,keyPresentEnv:"● key 来自本进程环境变量 ${env}"}},rA={dev:{reset:`Reset UI state`,resetHint:`Clears ~/.config/rove/state.json and ~/.rove/tasks.json, then quits Rove — relaunch to start fresh. Working session list, pane sizes, theme, model picks all reset. Worktrees on disk and engine session history are not touched.`,resetButton:`[enter] Reset`,restart:`Restart backend`,restartHint:`Stops the Rove daemon and relaunches this window on the installed build — picks up daemon / orchestrator / engine edits without quitting by hand. Running engine sessions live in the PTY host and survive it; other attached Rove windows reconnect on their own.`,restartButton:`[enter] Restart`,reload:`Reload settings`,reloadHint:"Applies hand edits to ~/.config/rove/state.json (from `rove config`) to this window without a restart.",reloadButton:`[enter] Reload`,reloadDone:`Reloaded: {count} changed.`,reloadUnchanged:`Already matches state.json; nothing changed.`,reloadFailed:`state.json could not be read, nothing changed: {error}`,doctorHint:"Daemon wedged or unresponsive? Restart backend above does it from here; from a shell it is `rove daemon restart`. Hosted engine sessions stay alive across a daemon restart.",experimental:`Experimental`,remoteHint:"Remote projects (SSH): register a project whose git worktrees live on another host, driven from this local Rove. Unfinished — Hosted PTY engine launch over SSH is not implemented, and file/diff panes still degrade. Enables `rove add --remote`.",remote:`Remote projects`,autoStatusHint:`Auto status flow: a backlog task moves to in_progress when its engine starts a turn, and new sessions get a system-prompt note telling the agent to set in_review itself when the work is done. Never touches done/canceled.`,autoStatus:`Auto status flow`,dispatcherHint:"Field-notes dispatcher: task sessions file one-line gotchas (`rove api note`), the daemon forwards each to the repo's main session, and that session relays them to the in-flight tasks that benefit (`rove api dispatch`). Web-hosted sessions receive the relays today.",dispatcher:`Field-notes dispatcher`}},iA={dev:{reset:`重置 UI 状态`,resetHint:`清空 ~/.config/rove/state.json 和 ~/.rove/tasks.json,然后退出 Rove——重新启动即可从头开始。工作会话列表、面板尺寸、主题、模型选择都会重置。磁盘上的 worktree 和引擎会话历史不受影响。`,resetButton:`[enter] 重置`,restart:`重启后端`,restartHint:`停止 Rove daemon,并以已安装的版本重新启动当前窗口——无需手动退出即可应用 daemon / orchestrator / engine 的改动。正在运行的引擎会话由 PTY host 托管,不受影响;其他已连接的 Rove 窗口会自行重连。`,restartButton:`[enter] 重启`,reload:`重新加载设置`,reloadHint:"把对 ~/.config/rove/state.json 的手动修改(来自 `rove config`)应用到当前窗口,无需重启。",reloadButton:`[enter] 重新加载`,reloadDone:`已重新加载:{count} 项有变化。`,reloadUnchanged:`已与 state.json 一致,没有变化。`,reloadFailed:`无法读取 state.json,未做任何改动:{error}`,doctorHint:"daemon 卡住或无响应?上面的「重启后端」就能在这里完成;在 shell 里则是 `rove daemon restart`。Hosted PTY 引擎会话不会因 daemon 重启而退出。",experimental:`实验性`,remoteHint:"远程项目(SSH):注册一个 git worktree + 引擎都通过 SSH 跑在另一台主机上、由本地 Rove 驱动的项目。尚未完成——文件/diff 面板对远程仍会降级。启用 `rove add --remote`。",remote:`远程项目`,autoStatusHint:`自动状态流转:backlog 任务在其引擎开始一轮时移到 in_progress,新会话会拿到一条系统提示,告诉 agent 完成后自行设为 in_review。绝不触碰 done/canceled。`,autoStatus:`自动状态流转`,dispatcherHint:"现场笔记调度器:任务会话提交一行经验(`rove api note`),daemon 将每条转发给仓库的主会话,主会话再把它们转达给能受益的进行中任务(`rove api dispatch`)。目前由 Web 托管的会话会收到转达。",dispatcher:`现场笔记调度器`}},aA={engines:{title:`Engines`,hint:`Engines Rove can start on this machine. New tasks start with the default engine; switch an engine off to stop offering it.`,keys:`space available · d default · enter launch command · r rename · x reset/remove`,customTag:`custom`,available:`available`,off:`off`,defaultMark:`default`,makeDefault:`Make default`,status:{checking:`Checking…`,unknown:`Status unknown`,ready:`Ready`,notInstalled:`Not installed`,notOnPath:`Not on PATH`,signIn:`Sign in needed`,integrationMissing:`Integration not installed`,integrationOutdated:`Integration outdated`,integrationBlocked:`Integration blocked`},detail:{program:`Program`,command:`Command`,signIn:`Sign-in`,reporting:`Live status`,adapter:`Adapter`,programFound:`{binary} found at {path}.`,programMissing:`{binary} is not on PATH. Install the engine's CLI, or point its launch command at it.`,programUnknown:`Rove could not check for {binary}.`,commandDefault:`{command} (the default)`,commandCustom:`{command} (yours)`,signedIn:`Signed in.`,signedInAs:`Signed in as {who}.`,apiKey:`An API key is configured.`,token:`A token is configured ({source}).`,signedOut:`Not signed in. Sign in with the engine's own CLI.`,signInUnknown:`Rove can't see whether this engine is signed in.`,signInFailed:`Sign-in check failed: {error}`,hooksInstalled:`Rove's hooks are installed, so tabs report their state as it changes.`,hooksOutdated:`Rove's hooks are from an older version; reinstall them under Engine integrations.`,hooksMissing:`Rove's hooks are not installed; install them under Engine integrations.`,hooksAwaitEngine:`Rove's hooks can be installed once the engine is.`,hooksUnsupported:`This engine has no hooks for Rove to install.`,hooksBlocked:`Rove can't write its hooks into {file}: {reason}`,hooksBlockedHere:`Rove can't write its hooks into the engine's config: {reason}`,markersYes:`It leaves turn-complete markers that Rove reads back.`,markersNo:`It leaves no turn-complete markers.`,screenYes:`Screen rules cover what the hooks don't.`,screenNo:`No screen rules.`,screenNotNeeded:`No screen rules; the hooks report everything.`,adapterDeclared:`Borrows the {protocol} adapter.`,adapterGeneric:`Generic adapter: no transcript reader, sign-in check or resume.`,skill:`Rove skill`,skillInstalled:`Installed in {dir}.`,skillInstalledHere:`Installed and current.`,skillOutdated:`From an older Rove; reinstall it under Rove agent skill.`,skillMissing:`Not installed; install it under Rove agent skill.`},skill:{title:`Rove agent skill`,hint:`Teaches the agent in each engine to drive Rove itself (rove api): start tasks, read other sessions, message them.`,install:`Install ({count})`,noEngines:`No engine here takes the skill`,failed:`Install failed: {reason}`,bannerTitle:`ROVE SKILL NOT INSTALLED`,bannerHint:`{engines} can't drive Rove yet (start tasks, read other sessions). Click here to install.`,bannerHintWeb:`{engines} can't drive Rove yet (start tasks, read other sessions).`},integrations:{title:`Engine integrations`,hint:`Hooks Rove writes into each engine's own config, so a tab shows working, waiting or done the moment it happens.`,summary:`{installed} of {total} installed`,install:`Install missing ({count})`,upToDate:`All up to date`,remove:`Remove all ({count})`,noneInstalled:`Nothing to remove`},addEngine:`+ Add engine`,launchCommandTitle:`{name} launch command`,displayNameTitle:`{name} display name (blank = default)`,addTitle:`Add engine`,addStepTitle:`Add engine · {id}`,protocolTitle:`Add engine · {id} — protocol`,protocolNone:`None — generic adapter`,protocolFooter:`↑↓ choose · enter pick · esc cancel`,protocolRow:`protocol {protocol}`,protocolGeneric:`generic`,idPlaceholder:`lowercase slug, e.g. aider`,commandPlaceholder:`e.g. aider --model sonnet`,hookTrustHint:`Open {command} in the engine and approve hooks yourself. Written hooks are not proof of trust.`,readiness:`CLI: {cli} · login: {login} · hooks: {hooks}`,cliReady:`available`,cliMissing:`missing; install the engine CLI`,loginReady:`detected`,loginMissing:`sign in with the engine CLI`,readinessUnknown:`not observable`,hooksWritten:`written`,hooksMissing:`not written; Settings → Engines`,hooksOutdated:`outdated; Settings → Engines`,hookWaiting:`No hook event received yet. After approval, send a short prompt to verify activity.`,hookReceived:`Hook event recorded for this tab. Send a short prompt to check current reporting; current trust is not inferred.`,readinessFailed:`Readiness check unavailable; run rove doctor. No authorization is inferred.`},accounts:{checking:`Checking…`,notLoggedIn:`○ Not logged in`,loggedIn:`● Logged in: {email}`,apiKeyConfigured:`● API key configured`,chatgptLogin:`● ChatGPT login: {email}`,tokenConfigured:`● Token configured ({source})`,detected:`● Login detected`}},oA={engines:{title:`引擎`,hint:`Rove 能在这台机器上启动的引擎。新任务默认用「默认」引擎;关掉某个引擎,选引擎时就不再列出它。`,keys:`space 可用 · d 设为默认 · enter 启动命令 · r 重命名 · x 重置/移除`,customTag:`自定义`,available:`可用`,off:`已关`,defaultMark:`默认`,makeDefault:`设为默认`,status:{checking:`检查中…`,unknown:`状态未知`,ready:`就绪`,notInstalled:`未安装`,notOnPath:`不在 PATH 上`,signIn:`需要登录`,integrationMissing:`未安装接入`,integrationOutdated:`接入已过期`,integrationBlocked:`接入被拒绝`},detail:{program:`程序`,command:`命令`,signIn:`登录`,reporting:`实时状态`,adapter:`适配器`,programFound:`{binary} 位于 {path}。`,programMissing:`{binary} 不在 PATH 上。请安装引擎 CLI,或把启动命令指向它。`,programUnknown:`Rove 无法检查 {binary}。`,commandDefault:`{command}(默认)`,commandCustom:`{command}(自定义)`,signedIn:`已登录。`,signedInAs:`已登录:{who}。`,apiKey:`已配置 API key。`,token:`已配置 Token({source})。`,signedOut:`未登录。请用引擎自己的命令行登录。`,signInUnknown:`Rove 无法得知该引擎是否已登录。`,signInFailed:`登录检查失败:{error}`,hooksInstalled:`Rove 的钩子已安装,标签页的状态会实时上报。`,hooksOutdated:`Rove 的钩子来自旧版本;请在「引擎接入」里重新安装。`,hooksMissing:`Rove 的钩子未安装;请在「引擎接入」里安装。`,hooksAwaitEngine:`引擎安装后才能装 Rove 的钩子。`,hooksUnsupported:`该引擎没有可供 Rove 安装的钩子。`,hooksBlocked:`Rove 无法把钩子写入 {file}:{reason}`,hooksBlockedHere:`Rove 无法把钩子写入引擎配置:{reason}`,markersYes:`它会留下回合完成标记,Rove 可以读回。`,markersNo:`它不留下回合完成标记。`,screenYes:`读屏规则兜底钩子覆盖不到的状态。`,screenNo:`没有读屏规则。`,screenNotNeeded:`没有读屏规则;钩子已报全所有状态。`,adapterDeclared:`借用 {protocol} 适配器。`,adapterGeneric:`通用适配器:没有会话记录读取、登录检查和恢复。`,skill:`Rove 技能`,skillInstalled:`已安装在 {dir}。`,skillInstalledHere:`已安装,是最新版。`,skillOutdated:`来自旧版 Rove;请在「Rove 智能体技能」里重新安装。`,skillMissing:`未安装;请在「Rove 智能体技能」里安装。`},skill:{title:`Rove 智能体技能`,hint:`教会各引擎里的智能体自己操作 Rove(rove api):开任务、读其他会话、给它们发消息。`,install:`安装({count})`,noEngines:`这台机器上没有能装技能的引擎`,failed:`安装失败:{reason}`,bannerTitle:`ROVE 技能未安装`,bannerHint:`{engines} 还不能操作 Rove(开任务、读其他会话)。点这里安装。`,bannerHintWeb:`{engines} 还不能操作 Rove(开任务、读其他会话)。`},integrations:{title:`引擎接入`,hint:`Rove 写进各引擎自身配置的钩子,让标签页在工作、等待、完成的那一刻就显示出来。`,summary:`已安装 {installed}/{total}`,install:`安装缺失的({count})`,upToDate:`全部已是最新`,remove:`全部移除({count})`,noneInstalled:`没有可移除的`},addEngine:`+ 添加引擎`,launchCommandTitle:`{name} 的启动命令`,displayNameTitle:`{name} 的显示名称(留空 = 默认)`,addTitle:`添加引擎`,addStepTitle:`添加引擎 · {id}`,protocolTitle:`添加引擎 · {id} —— 协议`,protocolNone:`无 —— 通用适配器`,protocolFooter:`↑↓ 选择 · enter 确认 · esc 取消`,protocolRow:`协议 {protocol}`,protocolGeneric:`通用`,idPlaceholder:`小写短名,如 aider`,commandPlaceholder:`如 aider --model sonnet`,hookTrustHint:`在引擎中打开 {command},由你自行批准 hooks。写入不代表已授权。`,readiness:`CLI:{cli} · 登录:{login} · hooks:{hooks}`,cliReady:`可用`,cliMissing:`缺失;请安装引擎 CLI`,loginReady:`已检测到`,loginMissing:`请通过引擎 CLI 登录`,readinessUnknown:`无法观测`,hooksWritten:`已写入`,hooksMissing:`未写入;设置 → 引擎`,hooksOutdated:`已过时;设置 → 引擎`,hookWaiting:`尚未收到 hook 事件。授权后发送一条简短提示,验证活动状态。`,hookReceived:`已记录此标签页的 hook 事件。发送简短提示以检查当前上报;不据此推断当前授权。`,readinessFailed:`无法检查就绪状态;请运行 rove doctor。不会据此推断已授权。`},accounts:{checking:`检查中…`,notLoggedIn:`○ 未登录`,loggedIn:`● 已登录: {email}`,apiKeyConfigured:`● 已配置 API key`,chatgptLogin:`● ChatGPT 登录: {email}`,tokenConfigured:`● 已配置 Token ({source})`,detected:`● 检测到登录`}},sA={plugins:{title:`Plugins`,hint:"Rove's first-party mods first: enter (or click) installs or uninstalls one, and uninstalling keeps its data on disk. Then the plugins registered in ~/.rove/plugins.json: enter toggles one on or off — the daemon watches the file, so the change applies live. Rows indented under a plugin are the settings it declares; enter edits one, and the value reaches the plugin on its next run. Install and remove them from the shell: `rove plugin install <owner/repo>`, `rove plugin link <dir>`.",empty:"Kanban and Issues are first-party mods: enter (or click) installs one. No other plugins registered; add one with `rove plugin install <owner/repo>` — browse the `rove-plugin` topic on GitHub.",sourceLink:`linked {path}`,sourceGithub:`{spec}`,sourceBuiltIn:`first-party mod · not installed`,sourceBuiltInInstalled:`first-party mod · installed`,updateAvailable:`update available — rove plugin update`,declares:`{actions} actions · {events} events · {panes} panes`,declaresWithEngines:`{actions} actions · {events} events · {panes} panes · {engines} engines`,declaresPages:`· {pages} pages`,pageFailed:`page {detail}`,manifestUnreadable:`manifest unreadable; check the rove-plugin.toml path and TOML syntax`,unsupportedPlatform:`· not supported on this platform`,noHooks:`· no hooks declared`,lastRun:`· last run {label} {status} {ago} ago`,neverRun:`· never run`,runOk:`ok`,runRunning:`still running`,runFailed:"failed to start; inspect `rove plugin log <id>`",runExit:`exit {code}`,settingUnset:`(unset — enter to edit)`,settingInvalidTitle:`Not a number`,settingInvalidBody:`{label} only accepts a number. Keeping the previous value.`},marketplace:{title:`Marketplace`,hint:"Plugins published under the `rove-plugin` topic on GitHub, most-starred first. enter (or click) shows what the install would run and asks before running any of it. The listing is re-queried each time you open this section.",loading:`Searching GitHub…`,empty:`No plugins listed.`,offline:`GitHub is unreachable — showing first-party plugins only. Re-open this section to retry.`,installedTag:`installed`,firstParty:`first-party`,preparing:`cloning {ref}…`,installing:`building and registering {name}…`,installed:`installed {id} v{version} — it is enabled, and appears under Plugins.`,cancelled:`install cancelled; nothing was run.`,failed:`install failed: {error}. Check the build output and retry from Marketplace.`,alreadyInstalled:`already installed as {id} — manage it under Plugins.`,confirmTitle:`Install {name}?`,confirmInstall:`install`,previewSource:`source: {source}`,previewCommands:`Commands this plugin declares:`,previewNoCommands:`This plugin declares no commands.`,previewWarning:`warning: {warning}`,previewTrust:`Installing runs the build commands above, and the rest run later on the events they declare. They run as you, with your environment, and nothing is sandboxed.`}},cA={plugins:{title:`插件`,hint:"先列 Rove 官方 mod:enter(或点击)安装或卸载,卸载后数据仍留在磁盘上。再列在 ~/.rove/plugins.json 里注册的插件:enter 切换启用/禁用——daemon 监听该文件,改动实时生效。插件下方缩进的行是它声明的设置项,enter 编辑,新值在插件下次运行时生效。安装与移除在 shell 里做:`rove plugin install <owner/repo>`、`rove plugin link <dir>`。",empty:"Kanban 和 Issues 是官方 mod:enter(或点击)安装。尚未注册其他插件;用 `rove plugin install <owner/repo>` 安装一个——可在 GitHub 的 `rove-plugin` 话题下浏览。",sourceLink:`本地链接 {path}`,sourceGithub:`{spec}`,sourceBuiltIn:`官方 mod · 未安装`,sourceBuiltInInstalled:`官方 mod · 已安装`,updateAvailable:`有新版本 — rove plugin update`,declares:`{actions} 个动作 · {events} 个事件 · {panes} 个面板`,declaresWithEngines:`{actions} 个动作 · {events} 个事件 · {panes} 个面板 · {engines} 个引擎`,declaresPages:`· {pages} 个页面`,pageFailed:`页面 {detail}`,manifestUnreadable:`manifest 无法解析;请检查rove-plugin.toml 的路径和 TOML 语法`,unsupportedPlatform:`· 不支持当前平台`,noHooks:`· 未声明钩子`,lastRun:`· 上次运行 {label} {status} {ago}前`,neverRun:`· 尚未运行过`,runOk:`成功`,runRunning:`仍在运行`,runFailed:"启动失败;请查看 `rove plugin log <id>`",runExit:`退出码 {code}`,settingUnset:`(未设置 — enter 编辑)`,settingInvalidTitle:`不是数字`,settingInvalidBody:`{label} 只接受数字,保留原值。`},marketplace:{title:`插件市场`,hint:"GitHub 上 `rove-plugin` 话题下发布的插件,按 star 数排序。enter(或点击)会先列出安装会执行的命令,确认后才真正执行。每次进入本区块都会重新查询列表。",loading:`正在搜索 GitHub…`,empty:`列表为空。`,offline:`GitHub 不可达——只显示首方插件。重新进入本区块可再试一次。`,installedTag:`已安装`,firstParty:`首方`,preparing:`正在克隆 {ref}…`,installing:`正在构建并注册 {name}…`,installed:`已安装 {id} v{version}——已启用,可在「插件」区块管理。`,cancelled:`已取消安装,没有执行任何命令。`,failed:`安装失败:{error}。请检查构建输出,再从插件市场重试。`,alreadyInstalled:`已安装为 {id}——在「插件」区块管理。`,confirmTitle:`安装 {name}?`,confirmInstall:`安装`,previewSource:`来源:{source}`,previewCommands:`该插件声明的命令:`,previewNoCommands:`该插件未声明任何命令。`,previewWarning:`警告:{warning}`,previewTrust:`安装会执行上面的 build 命令,其余命令会在它们声明的事件发生时执行。它们以你的身份、带你的环境变量运行,没有任何沙箱。`}},lA={en:{appearance:{enabled:`On`,disabled:`Off`,borderFlow:`Flowing gradient`,borderStill:`Still`,glyphsBraille:`Braille`,glyphsStarburst:`Starburst (needs a font with the Dingbats block)`,glyphsAscii:`ASCII`,titleShimmer:`Shimmer`,titleStill:`Still`,preview:`Workspace preview`,tasks:`Tasks`,terminal:`Terminal`,files:`Files`,testsPassed:`Tests passed`,transparent:`Transparent background`,opaque:`Opaque background`,modeDark:`Dark`,modeLight:`Light`,modeAuto:`Auto (follow the terminal)`,openHint:`Enter to choose an option and preview it.`,chooseHint:`↑/↓ or j/k preview · enter apply · esc cancel`},title:`Settings`,esc:`esc`,nav:{default:`j/k pick · h/l switch level · enter activate · esc close`,feedback:`tab next field · enter sends on Send · esc close`},sections:{general:`General`,engines:`Engines`,autoRouting:`Auto routing`,plugins:`Plugins`,marketplace:`Marketplace`,keys:`Keybindings`,feedback:`Feedback`,dev:`Dev`},general:{usage:`USAGE`,theme:`Theme`,themeMode:`Mode`,themeHint:`l to enter list · j/k to highlight · enter to apply`,language:`Language`,languageHint:`Display language for Rove's UI. l to enter list · j/k to highlight · enter to apply.`,transparent:`Transparent background`,transparentHint:`Drops the renderer's bg fill so the host terminal shows through. enter toggles.`,on:`[x] on`,off:`[ ] off`,focusAccent:`Focus accent`,focusAccentHint:`Color of focused pane title, ▌ marker, and split borders.`,accentPrimary:`Primary (brand accent)`,accentSuccess:`Success (legacy green)`,accentInfo:`Info (cool blue)`,appearance:`Appearance`,appearanceHint:`How split panes draw.`,splitStyle:`Split panes`,workingBorder:`Working border`,taskColors:`Task colors`,glyphSet:`State glyphs`,colorblind:`Colorblind diff colours`,runningTitle:`Running title`,splitBox:`Box frames`,splitLine:`Divider line`,splitRail:`Accent rail`,splitRule:`Top rule`,notifications:`Notifications`,notificationsHint:`When a background tab finishes or pauses on an approval.`,toast:`Toast`,toastHint:`bottom-right popup`,sound:`Sound`,soundHint:`bell + chime + an OSC 9 desktop notification (rides SSH)`,soundVolume:`Chime volume — {percent}%`,soundVolumeHint:`enter cycles; applies to the next chime`,crossTask:`Cross-task`,crossTaskHint:`also for a task you switched away from`,finishedAlerts:`Finished turns`,finishedAlertsHint:`off: only approvals and errors alert; the unread dot stays`,keyHints:`Keyboard hints`,keyHintsHint:`The status-bar reminder and the first-use hints in the sidebar and files panes.`,keyHintsShow:`Show keyboard hints`,keyHintsShowHint:`re-enabling relights hints dismissed by use`,zen:`Zen mode`,zenHint:"The `zen` chip and `prefix`+z hide Files, keeping the Tasks rail and workspace.",zenDefaultOn:`Start in zen mode`,updates:`Updates`,updatesHint:`Stable releases are cut by hand; the nightly preview is built from main every day.`,updateChannel:`Channel: {channel}`,updateChannelHint:"enter switches; `rove update` follows it",updateChannelName:{latest:`stable`,nightly:`nightly preview`},updateTry:{latest:`[ Back to stable ]`,nightly:`[ Try the nightly preview ]`},updateTryHint:`installs it now and follows that channel`,updateCheck:`[ Check for updates ]`,updateCheckHint:`asks npm for the newest release`,updateCheckButton:`Check for updates`,updateChecking:`Checking…`,updateOpenPage:`Open Update page`,updateTryTitle:{latest:`Go back to stable?`,nightly:`Install the nightly preview?`},updateTryBody:{latest:`Rove installs the latest stable release, which can be older than this nightly, then quits.`,nightly:"Rove installs today's nightly build of main, then quits. It is newer and less tested; `rove update --stable` goes back."},railFold:`Folded task rail`,railFoldHint:`What the rail shows once folded away from its corner control.`,railFoldRow:`Folded rail shows: {style}`,railFoldRowHint:`enter cycles`,railFoldGlyphs:`status glyphs`,railFoldInitials:`glyph + initials`,railFoldHairline:`colour band only`,editor:`Editor`,editorHint:`What enter opens a file with in the file tree — diff mode when the editor supports it, the read-only preview when it isn't installed.`,editorRow:`editor: < {kind} >`,editorRowHint:`auto follows $VISUAL / $EDITOR, else nvim / vim / emacs / nano`,editorCustom:`custom: {cmd}`,editorCustomUnset:`(unset — enter to edit)`,worktree:`Worktree location`,worktreeHint:`Where new task worktrees are created. New tasks only.`,worktreeBase:`location: < {kind} >`,worktreeBaseHint:"custom takes `~`, a relative path, or a leading `$project_dir`",worktreeKindDefault:`default ~/.rove/worktrees`,worktreeKindNext:`next to project`,worktreeKindCustom:`custom`,worktreeCustom:`custom: {path}`,worktreeCustomUnset:`(unset — enter to edit)`,worktreeBaseTitle:`Custom worktree location (blank = default; $project_dir = project root)`,worktreeBaseField:`PATH`,editorCustomTitle:`Custom editor command (use {file} for the path)`,worktreeBaseInvalidTitle:`Can't use that worktree location`,worktreeBaseTokenBody:`{token} only expands as the leading path segment (e.g. {token}/../rove-worktrees). Keeping the previous setting.`,worktreeBaseUnusableBody:`{path} isn't usable ({error}). Keeping the previous setting — pick a writable directory.`,terminal:`Terminal`,terminalHint:`Applies to terminals opened after the change.`,scrollbackRow:`scrollback: {rows} rows`,scrollbackRowHint:`100–100000 · larger costs proportionally more CPU per redraw`,scrollbackTitle:`Terminal scrollback rows (100–100000)`,scrollbackField:`ROWS`,scrollbackInvalidTitle:`Not a number`,scrollbackInvalidBody:`Scrollback must be a number of rows (e.g. 1000). Keeping the previous setting.`,tabStripRow:`tab strip: {mode}`,tabStripMode:{never:`off — the sidebar tree lists tabs`,multipleOnly:`only with 2+ tabs`,always:`always`}},field:{command:`COMMAND`,name:`NAME`,id:`ID`},action:{save:`save`,next:`next`,add:`add`},reset:{title:`Reset UI state?`,body:`Wipes ~/.config/rove/state.json and ~/.rove/tasks.json, then quits Rove — relaunch for a fresh start with an empty working session list. Worktrees on disk and engine session history are NOT touched.`,done:`Rove: UI state reset. Relaunch Rove to start fresh.`,failedTitle:`UI state was not reset`,failedBody:`Could not write the settings file. Your settings and tasks have been kept. Try resetting again.`},restart:{title:`Restart backend?`,body:`Stops the daemon and relaunches this Rove on the installed build, so daemon / orchestrator / engine edits take effect. Running engine sessions live in the PTY host and keep going; open tabs come back. Any other attached windows reconnect on their own.`,done:`Rove: restarting the backend...`},stateWrite:{failedTitle:`Settings were not saved`,failedBody:`{file} could not be written ({keys}). Check its directory permissions and free disk space, then save again.`},...tA,...aA,...sA,keybindings:{title:`Keybindings`,hint:`Rebind direct and prefix chords in your own YAML file; changes reload live. Press F1 anywhere for the live keymap with every binding id.`,configFile:`Config file`,notCreated:` (not created yet)`,prefixTitle:`Command layer ({prefix})`,prefixHint:`Bare keys act in the focused pane; a small one-press set covers frequent Rove actions; {prefix} opens the command layer ({timeout}ms second-stroke window). Prefix bindings keep their pane scope and modal rules.`,tapPresentation:`Prefix tap`,tapPresentationHint:`Choose whether the complete guide also marks controls already on screen.`,tapPresentationLocal:`On-screen entries + complete guide (default)`,tapPresentationGuide:`Complete guide only`,prefixDisabled:`disabled`,fixed:`Fixed (not rebindable): {ids}.`,createHint:`No overrides file yet. Rove can write one for you, fully commented — nothing is rebound until you uncomment a line.`,createFile:`[enter] Create keybindings.yaml`,overridesApplied:`Overrides applied`,none:`none`,unbound:`(unbound)`,defaultKeys:`default: {keys}`,warnings:`Warnings`},feedback:{title:`Feedback`,hint:"Sends a GitHub Discussion to the Rove repo through `gh`. Requires `gh auth login`; category defaults to Feedback.",titleLabel:`title`,titlePlaceholder:`Short summary`,descriptionLabel:`description`,descriptionPlaceholder:`What happened? (enter for a new line · tab to Send)`,send:`[enter] Send to GitHub Discussions`},...rA},zh:{appearance:{enabled:`开启`,disabled:`关闭`,borderFlow:`流动渐变`,borderStill:`静止`,glyphsBraille:`盲文点`,glyphsStarburst:`星芒(需要含 Dingbats 符号区的字体)`,glyphsAscii:`ASCII`,titleShimmer:`流光`,titleStill:`静止`,preview:`工作区预览`,tasks:`任务`,terminal:`终端`,files:`文件`,testsPassed:`测试通过`,transparent:`透明背景`,opaque:`不透明背景`,modeDark:`深色`,modeLight:`浅色`,modeAuto:`自动(跟随终端)`,openHint:`按 Enter 打开选项和预览。`,chooseHint:`↑/↓ 或 j/k 预览 · enter 应用 · esc 取消`},title:`设置`,esc:`esc`,nav:{default:`j/k 选择 · h/l 切换层级 · enter 确认 · esc 关闭`,feedback:`tab 下一项 · enter 在发送项发送 · esc 关闭`},sections:{general:`通用`,autoRouting:`自动路由`,engines:`引擎`,plugins:`插件`,marketplace:`插件市场`,keys:`快捷键`,feedback:`反馈`,dev:`开发`},general:{usage:`用量`,theme:`主题`,themeMode:`明暗`,themeHint:`l 进入列表 · j/k 高亮 · enter 应用`,language:`语言`,languageHint:`Rove 界面的显示语言。l 进入列表 · j/k 高亮 · enter 应用。`,transparent:`透明背景`,transparentHint:`去掉渲染器的背景填充,让宿主终端透出来。按 enter 切换。`,on:`[x] 开`,off:`[ ] 关`,focusAccent:`聚焦强调色`,focusAccentHint:`聚焦面板标题、▌ 标记和分隔边框的颜色。`,accentPrimary:`主色(品牌强调色)`,accentSuccess:`成功色(传统绿)`,accentInfo:`信息色(冷蓝)`,appearance:`外观`,appearanceHint:`分屏面板怎么画边。`,splitStyle:`分屏面板`,workingBorder:`运行中边框`,taskColors:`任务配色`,glyphSet:`状态符号`,colorblind:`色盲友好的增删配色`,runningTitle:`运行中标题`,splitBox:`方框边框`,splitLine:`单线分隔`,splitRail:`左侧强调条`,splitRule:`顶部横线`,notifications:`通知`,notificationsHint:`后台标签完成或在审批处暂停时触发。`,toast:`Toast 弹窗`,toastHint:`右下角弹窗`,sound:`声音`,soundHint:`响铃 + 提示音 + OSC 9 桌面通知(经 SSH 直达本地)`,soundVolume:`提示音音量 — {percent}%`,soundVolumeHint:`回车循环切换;下一声提示音生效`,crossTask:`跨任务`,crossTaskHint:`你已切走的任务也通知`,finishedAlerts:`回合完成`,finishedAlertsHint:`关闭后只有审批和错误会提醒;未读标记照常`,keyHints:`键盘提示`,keyHintsHint:`状态栏提醒,以及侧栏和文件面板的首用提示。`,keyHintsShow:`显示键盘提示`,keyHintsShowHint:`重新开启会点亮已因使用而熄灭的提示`,zen:`禅模式`,zenHint:"`zen` 标记和 `prefix`+z 隐藏 Files,保留 Tasks 侧栏与 workspace。",zenDefaultOn:`启动即进入禅模式`,updates:`更新`,updatesHint:`稳定版手动发布;nightly 预览版每天从 main 自动构建。`,updateChannel:`渠道:{channel}`,updateChannelHint:"enter 切换;`rove update` 跟随它",updateChannelName:{latest:`稳定版`,nightly:`nightly 预览版`},updateTry:{latest:`[ 回到稳定版 ]`,nightly:`[ 试用 nightly 预览版 ]`},updateTryHint:`立即安装并改为跟随该渠道`,updateCheck:`[ 检查更新 ]`,updateCheckHint:`向 npm 查询最新版本`,updateCheckButton:`检查更新`,updateChecking:`检查中…`,updateOpenPage:`打开更新页`,updateTryTitle:{latest:`回到稳定版?`,nightly:`安装 nightly 预览版?`},updateTryBody:{latest:`Rove 会安装最新稳定版(可能比当前 nightly 旧),然后退出。`,nightly:"Rove 会安装今天从 main 构建的 nightly,然后退出。它更新、但测试更少;`rove update --stable` 可回到稳定版。"},railFold:`折叠后的任务栏`,railFoldHint:`任务栏从角标折叠之后显示什么。`,railFoldRow:`折叠后显示:{style}`,railFoldRowHint:`enter 切换`,railFoldGlyphs:`状态字形`,railFoldInitials:`字形 + 首字母`,railFoldHairline:`仅色带`,editor:`编辑器`,editorHint:`文件树里按 enter 用什么打开文件——支持时走编辑器 diff 模式,未安装时回退到只读预览。`,editorRow:`编辑器: < {kind} >`,editorRowHint:`auto 跟随 $VISUAL / $EDITOR,否则 nvim / vim / emacs / nano`,editorCustom:`自定义: {cmd}`,editorCustomUnset:`(未设置 — enter 编辑)`,worktree:`工作树位置`,worktreeHint:`新任务工作树的创建位置。仅对新任务生效。`,worktreeBase:`位置: < {kind} >`,worktreeBaseHint:"自定义可填 `~`、相对路径或以 `$project_dir` 开头",worktreeKindDefault:`默认 ~/.rove/worktrees`,worktreeKindNext:`项目旁边`,worktreeKindCustom:`自定义`,worktreeCustom:`自定义: {path}`,worktreeCustomUnset:`(未设置 — enter 编辑)`,worktreeBaseTitle:`自定义工作树位置(留空 = 默认;$project_dir = 项目根目录)`,worktreeBaseField:`路径`,editorCustomTitle:`自定义编辑器命令(用 {file} 代表文件路径)`,worktreeBaseInvalidTitle:`无法使用该工作树位置`,worktreeBaseTokenBody:`{token} 只能作为路径的第一段展开(如 {token}/../rove-worktrees)。保留原设置。`,worktreeBaseUnusableBody:`{path} 不可用({error})。保留原设置 —— 请选择一个可写目录。`,terminal:`终端`,terminalHint:`对修改后新打开的终端生效。`,scrollbackRow:`回滚行数: {rows} 行`,scrollbackRowHint:`100–100000 · 调大会按比例增加每次重绘的 CPU`,scrollbackTitle:`终端回滚行数(100–100000)`,scrollbackField:`行数`,scrollbackInvalidTitle:`不是数字`,scrollbackInvalidBody:`回滚行数必须是数字(如 1000)。保留原设置。`,tabStripRow:`标签栏: {mode}`,tabStripMode:{never:`关闭 — 标签在左侧树里`,multipleOnly:`仅 2 个以上标签时显示`,always:`始终显示`}},field:{command:`命令`,name:`名称`,id:`标识`},action:{save:`保存`,next:`下一步`,add:`添加`},reset:{title:`重置界面状态?`,body:`将清除 ~/.config/rove/state.json 和 ~/.rove/tasks.json 并退出 Rove —— 重新启动后会是一个干净的开始,工作会话列表为空。磁盘上的工作树和引擎会话历史不受影响。`,done:`Rove:界面状态已重置。重新启动 Rove 即可从头开始。`,failedTitle:`UI 状态未能重置`,failedBody:`无法写入设置文件。设置和任务均已保留,请稍后重新尝试重置。`},restart:{title:`重启后端?`,body:`会停掉 daemon,并以已安装的版本重新启动当前 Rove 窗口,从而让 daemon / orchestrator / 引擎的改动生效。正在运行的引擎会话由 PTY host 托管,不会中断;已打开的标签页会恢复。其他已连接的窗口会自行重连。`,done:`Rove:正在重启后端……`},stateWrite:{failedTitle:`设置未能保存`,failedBody:`{file} 写入失败({keys})。请检查目录权限和磁盘空间,再次保存。`},...nA,...oA,...cA,keybindings:{title:`快捷键`,hint:`在你自己的 YAML 文件里重绑定直接按键和 prefix 组合;修改会实时加载。任意位置按 F1 查看带每个绑定 id 的实时键位表。`,configFile:`配置文件`,notCreated:` (尚未创建)`,prefixTitle:`命令层({prefix})`,prefixHint:`裸键作用于当前聚焦面板;少量单次快捷键覆盖高频 Rove 操作;{prefix} 打开命令层(第二击窗口 {timeout}ms)。Prefix 绑定保持原有的面板作用域和 modal 规则。`,tapPresentation:`点按 Prefix`,tapPresentationHint:`选择完整指南是否同时标记当前屏幕上的入口。`,tapPresentationLocal:`屏幕入口 + 完整指南(默认)`,tapPresentationGuide:`仅完整指南`,prefixDisabled:`已禁用`,fixed:`固定(不可重绑定):{ids}。`,createHint:`还没有覆盖文件。Rove 可以帮你写一份带完整注释的——在你取消注释之前不会改动任何按键。`,createFile:`[enter] 创建 keybindings.yaml`,overridesApplied:`已应用的覆盖`,none:`无`,unbound:`(已解绑)`,defaultKeys:`默认: {keys}`,warnings:`警告`},feedback:{title:`反馈`,hint:"通过 `gh` 向 Rove 仓库发一条 GitHub Discussion。需要 `gh auth login`;分类默认为 Feedback。",titleLabel:`标题`,titlePlaceholder:`简短概括`,descriptionLabel:`描述`,descriptionPlaceholder:`发生了什么?(enter 换行 · tab 跳到发送)`,send:`[enter] 发送到 GitHub Discussions`},...iA}},uA={en:Er,zh:Dr};function $(e,t){return De(lA,e,t)}function dA(e,t){return De(uA,e,t)}function fA({label:e,value:t,picks:n,onPick:r}){return(0,V.jsx)(`fieldset`,{"aria-label":e,className:`m-0 inline-flex min-w-0 flex-wrap gap-0.5 rounded-sm border-hairline border-line bg-inset p-0.5`,children:n.map(e=>{let n=e.value===t;return(0,V.jsx)(`button`,{type:`button`,"aria-pressed":n,className:ke(`rounded-xs px-2.5 py-1 font-sans text-meta whitespace-nowrap touch:min-h-9`,`focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-focus`,n?`bg-menu text-ink`:`text-muted hover:bg-hover`),onClick:()=>!n&&r(e.value),children:e.label},e.value)})})}function pA({label:e,value:t,picks:n,onPick:r}){return(0,V.jsxs)(`span`,{className:`relative inline-flex max-w-full min-w-0 text-ink`,children:[(0,V.jsx)(`select`,{"aria-label":e,value:t,className:`max-w-full min-w-0 truncate rounded-sm border-hairline border-line bg-paper py-1.25 pr-7 pl-2.5 font-sans text-meta hover:border-line-active focus-visible:border-line-active focus-visible:outline-none touch:min-h-10`,onChange:e=>{let t=n.find(t=>String(t.value)===e.target.value);t&&r(t.value)},children:n.map(e=>(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,V.jsx)(Ma,{className:`pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 text-subtle`})]})}var mA=`${kn} w-narrow:pt-0`,hA=`dialog relative m-0 flex h-[min(640px,80vh)] w-[min(880px,calc(100vw-32px))] overflow-hidden rounded-md border-hairline border-line bg-surface text-inherit shadow-dialog focus:outline-none motion-safe:animate-rise-in [.is-leaving_&]:animate-sink-out w-narrow:h-dvh w-narrow:w-screen w-narrow:flex-col w-narrow:rounded-none w-narrow:border-0 short:h-[calc(100dvh-24px)]`,gA=`absolute top-3 right-3 z-1 grid size-7 place-items-center rounded-sm text-display leading-none text-muted hover:bg-inset hover:text-ink focus-visible:bg-inset focus-visible:text-ink touch:size-10`,_A=`flex w-56 flex-none flex-col gap-5 overflow-y-auto scrollbar-none [border-right:var(--hairline)_solid_var(--line)] px-2.5 py-4 w-narrow:w-full w-narrow:flex-1 w-narrow:[border-right:none] w-narrow:px-3 w-narrow:py-3`,vA=`m-0 px-2 pb-0.5 font-sans text-title font-semibold normal-nums text-ink`,yA=`flex flex-col gap-0.5`,bA=`m-0 px-2 pb-1 font-mono text-meta font-normal text-subtle`,xA=(e,t)=>`flex items-center rounded-sm px-2 py-1.25 text-left font-sans text-body touch:min-h-10 w-narrow:min-h-11 w-narrow:px-3 ${e?`bg-menu text-ink`:`${t?`text-muted`:`text-ink`} [&:hover]:bg-hover`}`,SA=`ml-auto hidden text-subtle w-narrow:block`,CA=`flex flex-col`,wA=`m-0 pb-2 text-meta text-subtle`,TA=`flex flex-col border-t-hairline border-t-line [&>*]:border-b-hairline [&>*]:border-b-line`,EA=`flex items-center justify-between gap-x-6 gap-y-2 py-3 w-narrow:flex-col w-narrow:items-stretch`,DA=`flex items-center justify-between gap-x-6 py-3`,OA=`flex flex-col gap-3 py-3`,kA=`flex min-w-0 flex-1 flex-col gap-0.5`,AA=`text-body text-ink`,jA=`text-meta text-muted [&_a]:text-accent`,MA=`max-w-90 min-w-0 truncate font-mono text-meta text-muted [overflow-wrap:anywhere]`,NA=`m-0 py-3 text-body text-muted`,PA=`rounded-sm border-hairline border-line bg-paper px-2.5 py-1.5 font-sans text-body text-ink focus-visible:border-line-active focus-visible:outline-none`,FA=`${PA} w-24 text-right`,IA=`flex flex-col gap-1.5`,LA=`text-meta font-medium text-muted`,RA=`min-h-30 max-h-[50vh] leading-[1.45]`,zA=`flex flex-wrap items-center justify-end gap-2.5`,BA=`flex items-center gap-2.5 rounded-sm bg-inset px-3 py-2 text-meta`,VA=`grid grid-cols-[minmax(0,1fr)_104px_72px] items-center gap-3`,HA=`flex flex-col`,UA=`${VA} pb-1.5 pl-7.5 font-sans text-meta font-medium normal-nums text-subtle [&>span:not(:first-child)]:text-center`,WA=`border-b-hairline border-b-line first:border-t-hairline first:border-t-line`,GA=`${VA} group/eng rounded-sm py-1.5 pr-1 pl-0`,KA=`flex min-w-0 items-center gap-2 rounded-sm py-1.5 pr-0 pl-1.5 text-left focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-focus`,qA=e=>`mx-0.5 ${e?`text-muted`:`text-subtle`}`,JA=`flex min-w-0 flex-col gap-0.5`,YA=e=>`truncate text-body leading-[inherit] font-medium ${e?`text-muted`:`text-ink`}`,XA=`ml-2 text-meta leading-[inherit] font-normal text-subtle`,ZA={ready:`bg-success`,attention:`bg-warning`,error:`bg-error`,absent:`bg-subtle`},QA=e=>`inline-flex items-center gap-1.5 text-meta leading-[inherit] ${e===`error`?`text-error`:`text-muted`}`,$A=e=>`size-1.75 flex-none rounded-full ${ZA[e]}`,ej=`flex justify-center`,tj=`rounded-full bg-accent-soft px-2.5 py-0.5 font-sans text-meta font-medium normal-nums capitalize text-accent`,nj=`rounded-full border-hairline border-line px-2.5 py-0.5 text-meta leading-[inherit] whitespace-nowrap text-muted opacity-0 transition-opacity duration-120 ease-[ease] group-hover/eng:opacity-100 group-focus-within/eng:opacity-100 hover:border-line-active hover:text-ink motion-reduce:transition-none touch:opacity-100`,rj=`mt-0 mr-1 mb-3 ml-7 flex flex-col gap-2.5 px-1.5 py-1`,ij=`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3.5 gap-y-1.5 text-meta leading-[1.5]`,aj=`text-subtle`,oj=e=>`m-0 wrap-anywhere ${e?`text-warning`:`text-ink`}`,sj=`flex items-center gap-2`,cj=`flex-1 px-2 py-1.25`,lj=`text-meta leading-[inherit] text-success`,uj=`flex items-center gap-3 py-2.5`,dj=`flex min-w-0 flex-1 flex-col gap-0.5`,fj=(e=!1)=>`overflow-hidden text-ellipsis text-meta text-muted ${e?`whitespace-normal`:`whitespace-nowrap`}`,pj=`flex flex-col gap-1 py-3`,mj=`flex items-baseline gap-3`,hj=`flex flex-col gap-2.5 pt-2`,gj=`grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-2`,_j=`m-0 pb-1.5 text-meta font-medium text-subtle`,vj=e=>e?`border-accent bg-accent-soft`:`border-line hover:bg-hover`,yj=`flex h-9 overflow-hidden rounded-xs border-hairline`,bj=`flex w-2/5 flex-col gap-0.75 p-1`,xj=`flex min-w-0 flex-1 flex-col gap-0.75 p-1`,Sj=`h-0.75 rounded-xs`,Cj=`mt-auto flex gap-0.75`,wj=`size-1 rounded-xs`,Tj=`flex min-w-0 items-baseline gap-1.5 font-sans text-meta`,Ej=`group relative h-4.5 w-7.5 flex-none justify-self-center rounded-full border-hairline border-line bg-inset transition-[background,border-color] duration-120 ease-[ease] aria-checked:border-accent aria-checked:bg-accent motion-reduce:transition-none`,Dj=`absolute top-0.5 left-0.5 size-3 rounded-full bg-muted transition-[transform,background] duration-120 ease-[ease] group-aria-checked:[transform:translateX(12px)] group-aria-checked:bg-paper motion-reduce:transition-none`;function Oj({on:e,...t}){return(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,className:Ej,...t,children:(0,V.jsx)(`span`,{className:Dj})})}function kj(e){return(0,V.jsxs)(`section`,{className:CA,children:[e.title&&(0,V.jsx)(`h2`,{className:`m-0 pb-1.5 font-sans text-meta font-medium normal-nums text-muted`,children:e.title}),e.hint&&(0,V.jsx)(`p`,{className:`m-0 pb-2 text-meta text-subtle`,children:e.hint}),(0,V.jsx)(`div`,{className:TA,children:e.children})]})}function Aj(e){let t=(0,V.jsxs)(`div`,{className:kA,children:[(0,V.jsx)(`span`,{id:e.labelId,className:AA,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:e.hint})]});return e.stack?(0,V.jsxs)(`div`,{className:OA,children:[t,e.children]}):(0,V.jsxs)(`div`,{className:e.inline?DA:EA,children:[t,e.children&&(0,V.jsx)(`div`,{className:`flex min-w-0 flex-none items-center justify-end gap-2 w-narrow:justify-start`,children:e.children})]})}function jj(e){let t=(0,g.useId)();return(0,V.jsx)(Aj,{label:e.label,hint:e.hint,labelId:t,inline:!0,children:(0,V.jsx)(Oj,{on:e.checked,"aria-labelledby":t,disabled:e.disabled,onClick:()=>e.onChange(!e.checked)})})}var Mj=36;function Nj(e){let t=e.picks.length<=4&&e.picks.reduce((e,t)=>e+t.label.length,0)<=Mj?fA:pA;return(0,V.jsx)(Aj,{label:e.label,hint:e.hint,children:(0,V.jsx)(t,{label:e.label,value:e.value,picks:e.picks,onPick:e.onPick})})}function Pj(e){return(0,V.jsx)(Aj,{label:e.label,hint:e.note,children:(0,V.jsx)(`span`,{className:MA,children:e.value})})}var Fj=`flex items-baseline justify-between`,Ij=`[&_b]:mr-2.5`,Lj=`my-2.5 flex flex-col`,Rj=e=>`flex gap-3 rounded-sm px-2 py-1 text-left text-[length:var(--fs-body)] ${e?`bg-menu`:``}`,zj=`min-w-[14ch]`,Bj=`whitespace-nowrap text-[length:var(--fs-meta)] text-warning`,Vj=`rail-tight:hidden`,Hj=`[&_h2]:mx-0 [&_h2]:mt-3.5 [&_h2]:mb-1 [&_h2]:text-[length:var(--fs-body)]`,Uj=`max-h-[55vh] overflow-x-hidden overflow-y-auto`,Wj=`mr-auto text-[length:var(--fs-meta)]`,Gj=`text-[length:var(--fs-body)] leading-[1.55] wrap-anywhere [&_h3]:mx-0 [&_h3]:mt-3 [&_h3]:mb-1.5 [&_h3]:font-sans [&_h3]:text-meta [&_h3]:font-medium [&_h3]:normal-nums [&_h3]:text-muted [&_h3:first-child]:mt-0 [&_ul]:m-0 [&_ul]:pl-4.5 [&_li+li]:mt-2 [&_p]:mx-0 [&_p]:mt-0 [&_p]:mb-2 [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2 [&_code]:rounded-sm [&_code]:bg-inset [&_code]:px-1 [&_code]:py-0 [&_code]:font-mono [&_code]:text-meta [&_code]:font-normal [&_code]:normal-nums`,Kj=`mt-3`,qj=e=>`rounded-sm px-2 py-1.25 ${e?`bg-menu`:``}`,Jj=`flex items-baseline gap-2 text-[length:var(--fs-body)]`,Yj=`flex items-baseline justify-between gap-2`,Xj=`font-mono`,Zj=`truncate`,Qj=`mt-4 text-[length:var(--fs-meta)]`;function $j(e){return e.replace(/\[`[0-9a-f]{7,40}`\]\([^)]*\)\s*/g,``).replace(/\s+[—-]\s+\[@[^\]]+\]\([^)]*\)\s*$/,``).trim()}function eM(e){let t=[],n=(e,n)=>t.push({kind:e,text:n,id:t.length});for(let r of e.split(/\r?\n/)){let e=r.trimEnd();if(e.trim()===``)continue;let i=/^#{1,6}\s+(.*)$/.exec(e);if(i){n(`heading`,i[1]??``);continue}let a=/^\s*[-*]\s+(.*)$/.exec(e);if(a){n(`item`,a[1]??``);continue}let o=t.at(-1);o&&o.kind!==`heading`?o.text=`${o.text} ${e.trim()}`:n(`para`,e.trim())}return t.map(e=>e.kind===`item`?{...e,text:$j(e.text)}:e)}var tM=/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)|`([^`]+)`|\*\*([^*]+)\*\*/g;function nM(e){let t=[],n=0;for(let r of e.matchAll(tM)){let i=r.index??0;i>n&&t.push(e.slice(n,i));let[a,o,s,c,l]=r;o!==void 0&&s!==void 0?t.push((0,V.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,children:nM(o)},i)):c===void 0?l!==void 0&&t.push((0,V.jsx)(`b`,{children:l},i)):t.push((0,V.jsx)(`code`,{children:c},i)),n=i+a.length}return n<e.length&&t.push(e.slice(n)),t}function rM({body:e}){let t=eM(e),n=[],r=[],i=()=>{r.length>0&&n.push((0,V.jsx)(`ul`,{children:r},`ul-${n.length}`)),r=[]};for(let e of t){if(e.kind===`item`){r.push((0,V.jsx)(`li`,{children:nM(e.text)},e.id));continue}i(),n.push(e.kind===`heading`?(0,V.jsx)(`h3`,{children:e.text},e.id):(0,V.jsx)(`p`,{children:nM(e.text)},e.id))}return i(),(0,V.jsx)(`div`,{className:Gj,children:n})}var iM=`page min-h-0 flex-1 rounded-md border-hairline border-line bg-paper px-4.5 py-3.5 focus:outline-none`,aM=`${iM} overflow-y-auto`,oM=`page-title mx-0 mt-0 mb-1.5 font-sans text-title font-bold normal-nums`,sM=`flex items-baseline justify-between gap-4 [&_.page-title]:m-0`,cM=e=>`min-w-0 truncate text-meta ${e?``:`leading-[inherit]`}`,lM=`flex flex-wrap items-center gap-2`,uM={row:`touch:after:-inset-x-0.75 touch:after:-inset-y-0.5`,kanban:`touch:after:-inset-x-0.75 touch:after:-top-1.5 touch:after:-bottom-1`,header:`touch:after:-inset-x-0.75 touch:after:-top-2.5 touch:after:-bottom-1.25`},dM=`mt-2.5 flex flex-col gap-1.5`,fM=e=>`flex cursor-pointer flex-col gap-0.5 rounded-sm px-2.5 py-1.5 ${e?`bg-menu`:``}`,pM=`flex min-w-0 items-baseline gap-2.5`,mM=`whitespace-nowrap text-muted`,hM=`flex gap-2.5 pl-[4ch] text-meta leading-[inherit] text-muted`,gM=`min-w-0 flex-1 truncate`,_M=`flex flex-col px-1.5 pb-2`,vM=`relative flex flex-col px-1.5 pt-1.5 pb-0.5`,yM=e=>`flex items-center rounded-sm px-2 py-0.75 text-left touch:min-h-10 ${e?`bg-menu text-ink`:`text-muted [&:hover]:bg-hover`}`,bM=`ml-auto -mr-[4.5px] w-5 text-center font-sans text-display leading-none font-normal text-accent normal-nums`,xM=`mr-[7px] size-3.5 flex-none fill-none stroke-current stroke-[1.75] [stroke-linecap:round] [stroke-linejoin:round]`,SM=_(null),CM=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),wM=e=>`https://github.com/Sma1lboy/rove/releases/tag/v${e}`;function TM(){return B()===`zh`?jr:Ar}function EM(e){return e.request(`update.check`,{force:!0,locale:Ce.get()}).then(e=>(SM.set(e),!0),()=>!1)}function DM(){let e=TM(),t=v(SM);return t?.info?.hasUpdate?(0,V.jsxs)(`button`,{type:`button`,className:`${U} text-muted ${Bj} ${He}`,title:CM(e.chip,{version:t.info.latest}),onClick:()=>ha(`update`),children:[`↑`,(0,V.jsxs)(`span`,{className:Vj,children:[` `,t.info.latest]})]}):null}function OM({client:e}){let t=TM(),n=v(SM),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(`release`),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(null);(0,g.useEffect)(()=>{l.current?.focus(),EM(e).finally(()=>i(!0))},[e]);let u=n?.info??null,d=n?.current??``,f=u?.latest??d,p=u?.hasUpdate===!0,m=r&&u===null,h=r&&u!==null&&!p,_=n?.notes??[],y=_[0]?.url??(f?wM(f):null),b=[{id:`release`,key:`R`,label:t.actions.openRelease,detail:y??t.releaseUrlUnavailable},{id:`close`,key:`Q`,label:t.actions.close,detail:t.actions.closeDetail}],x=e=>{if(e===`close`)return on.set(null);c(y&&window.open(y,`_blank`,`noopener`)!==null?t.statusReleaseOpened:t.statusReleaseError)};return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:l,onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`&&!window.getSelection()?.toString())return e.preventDefault(),x(`close`);if(e.metaKey||e.ctrlKey||e.altKey)return;let t=b.findIndex(e=>e.id===a);if(e.key===`j`||e.key===`ArrowDown`)o(b[(t+1)%b.length]?.id??`close`);else if(e.key===`k`||e.key===`ArrowUp`)o(b[(t-1+b.length)%b.length]?.id??`close`);else if(e.key===`Enter`)x(a);else if(e.key===`r`)x(`release`);else if(e.key===`q`||e.key===`Escape`)x(`close`);else return;e.preventDefault()},children:[(0,V.jsxs)(`div`,{className:Fj,children:[(0,V.jsx)(`h1`,{className:oM,children:t.pageTitle}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} mono`,onClick:()=>x(`close`),children:Ko()?z(`dialog.close`):t.closeHint})]}),(0,V.jsxs)(`p`,{className:`mono ${Ij}`,children:[(0,V.jsx)(`span`,{className:`text-muted`,children:t.current}),` `,(0,V.jsxs)(`b`,{children:[`v`,d]}),` `,(0,V.jsx)(`span`,{className:`text-muted`,children:t.latest}),` `,m?(0,V.jsx)(`b`,{className:`text-muted`,children:t.latestUnknown}):r?(0,V.jsxs)(`b`,{className:p?`text-warning`:`text-success`,children:[`v`,f]}):(0,V.jsx)(`span`,{className:`text-muted`,children:`…`})]}),m&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.registryRetry}),h&&(0,V.jsx)(`p`,{className:`text-success`,children:t.upToDate}),p&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:`rove update`}),(0,V.jsx)(`div`,{className:Lj,children:b.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:Rj(a===e.id),onClick:()=>x(e.id),children:[(0,V.jsxs)(`span`,{className:`mono keys-only text-accent`,children:[`[`,e.key,`]`]}),(0,V.jsx)(`span`,{className:zj,children:e.label}),(0,V.jsx)(`span`,{className:`text-muted`,children:e.detail})]},e.id))}),s&&(0,V.jsx)(`p`,{className:`mono text-accent`,children:s}),p&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:CM(t.changesSectionHeader,{from:d,to:f})}),!r&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.loadingNotes}),r&&p&&_.length===0&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.notesUnavailable}),_.map(e=>(0,V.jsxs)(`section`,{className:Hj,children:[(0,V.jsxs)(`h2`,{className:`mono`,children:[`v`,e.version]}),(0,V.jsx)(rM,{body:e.body})]},e.version))]})}var kM=`rove.whatsNewSeenVersion`,AM=e=>e.split(/[.-]/).slice(0,3).map(Number),jM=(e,t)=>{let[n,r]=[AM(e),AM(t)];for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)>(r[e]??0);return!1};function MM(e,t){let n=localStorage.getItem(kM);localStorage.setItem(kM,t),!(!n||!jM(t,n))&&e.request(`release.notes`,{version:t.replace(/-.*$/,``),locale:Ce.get()}).then(e=>W.set((0,V.jsx)(NM,{from:n,to:t,notes:e.notes})),()=>W.set((0,V.jsx)(NM,{from:n,to:t,notes:null})))}function NM(e){let t=TM(),n=(0,g.useRef)(null);return(0,g.useEffect)(()=>n.current?.focus(),[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`q`&&W.set(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,V.jsxs)(ir,{title:t.whatsNew.title,wide:!0,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:CM(t.whatsNew.upgraded,{from:e.from,to:e.to})}),(0,V.jsx)(`div`,{className:Uj,children:e.notes?(0,V.jsx)(rM,{body:e.notes.body}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.whatsNew.notesUnavailable})}),(0,V.jsxs)(`div`,{className:$t,children:[(0,V.jsx)(`span`,{className:`mono text-muted ${Wj} touch:hidden!`,children:z(`whatsNew.keys`)}),(0,V.jsx)(`a`,{className:Xt,href:e.notes?.url??wM(e.to),target:`_blank`,rel:`noopener noreferrer`,children:z(`whatsNew.openRelease`)}),(0,V.jsx)(`button`,{ref:n,type:`button`,className:je(),onClick:()=>W.set(null),children:z(`whatsNew.continue`)})]})]})}var PM=(e,t)=>e.replace(`{version}`,t);function FM({client:e}){let t=TM(),n=v(SM),[r,i]=(0,g.useState)(`idle`),a=()=>{i(`checking`),EM(e).then(e=>i(e?`done`:`failed`))},o=n?.info??null,s=r===`failed`||r===`done`&&o===null,c=r===`done`&&n&&o?o.hasUpdate?PM(t.available,o.latest):t.upToDate:s?t.latestUnknown:void 0,l=s?`text-muted`:o?.hasUpdate?`text-warning`:`text-success`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Aj,{label:$(`general.updates`),hint:$(`general.updatesHint`),children:[r===`done`&&o?.hasUpdate&&(0,V.jsx)(H,{variant:`action`,onClick:()=>ha(`update`),children:$(`general.updateOpenPage`)}),(0,V.jsx)(H,{variant:`action`,disabled:r===`checking`,onClick:a,children:$(r===`checking`?`general.updateChecking`:`general.updateCheckButton`)})]}),c&&(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:l,children:c}),hint:o?.hasUpdate?(0,V.jsx)(`code`,{className:`font-mono`,children:`rove update`}):void 0,children:r===`done`&&n&&o&&(0,V.jsx)(`span`,{className:`max-w-90 min-w-0 truncate font-mono text-meta text-muted [overflow-wrap:anywhere]`,children:`${t.current} v${n.current} · ${t.latest} v${o.latest}`})})]})}function IM({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`daemon.info`)??null);return(0,g.useEffect)(()=>{Fs(e,`daemon.info`).then(n,()=>n(null))},[e]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(kj,{title:z(`settings.about.groupRove`),children:[t?.daemonVersion&&(0,V.jsx)(Aj,{label:z(`settings.about.daemon`),hint:z(t.stale?`settings.about.daemonStale`:`settings.about.daemonCurrent`,{version:t.daemonVersion})}),(0,V.jsx)(FM,{client:e})]}),(0,V.jsx)(kj,{title:z(`settings.about.browser`),children:(0,V.jsx)(Aj,{label:z(`settings.about.signOut`),hint:z(`settings.about.browserHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>void ka().then(()=>window.location.reload()),children:z(`settings.about.signOut`)})})})]})}async function LM(e,t){let{taskId:n}=await e.client.request(`task.openScratch`);await NC(e,n,{kind:`engine`,prompt:t}),yn()}var RM=_(null);function zM({theme:e,mode:t}){let n=e[t],r=(e,t)=>({background:e,width:t});return(0,V.jsxs)(`span`,{className:yj,style:{background:n.background,borderColor:n.border},"aria-hidden":!0,children:[(0,V.jsxs)(`span`,{className:bj,style:{background:n.backgroundPanel},children:[(0,V.jsx)(`span`,{className:Sj,style:r(n.primary,`70%`)}),(0,V.jsx)(`span`,{className:Sj,style:r(n.textMuted,`85%`)}),(0,V.jsx)(`span`,{className:Sj,style:r(n.textMuted,`55%`)})]}),(0,V.jsxs)(`span`,{className:xj,children:[(0,V.jsx)(`span`,{className:Sj,style:r(n.text,`90%`)}),(0,V.jsx)(`span`,{className:Sj,style:r(n.textMuted,`65%`)}),(0,V.jsx)(`span`,{className:Sj,style:r(n.accent??n.primary,`40%`)}),(0,V.jsx)(`span`,{className:Cj,children:[n.success,n.warning,n.error,n.info].map((e,t)=>(0,V.jsx)(`span`,{className:wj,style:{background:e}},t))})]})]})}function BM(e){return(0,V.jsxs)(H,{variant:`card`,"aria-pressed":e.active,className:vj(e.active),onMouseEnter:()=>x_.set(e.theme),onFocus:()=>x_.set(e.theme),onClick:e.onClick,children:[(0,V.jsx)(zM,{theme:e.theme,mode:e.mode}),(0,V.jsxs)(`span`,{className:Tj,children:[(0,V.jsx)(`span`,{className:`truncate text-ink`,children:e.theme.name}),e.tag&&(0,V.jsx)(`span`,{className:`text-subtle`,children:e.tag})]})]})}function VM({children:e}){return(0,V.jsx)(`div`,{className:gj,onMouseLeave:()=>x_.set(null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||x_.set(null)},children:e})}function HM(e){let{model:t}=e,{client:n}=t,r=v(RM),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1);(0,g.useEffect)(()=>()=>x_.set(null),[]),(0,g.useEffect)(()=>void O_(n).catch(()=>void 0),[n]),(0,g.useEffect)(()=>{RM.get()===null&&n.request(`theme.hosted`).then(e=>RM.set(e),()=>RM.set({themes:[],dir:null}))},[n]);let f=e=>{l(!1),LM(t,z(`prefs.themeAgentPrompt`,{dir:e})).catch(()=>l(!0))},p=r?.dir??null,m=async e=>{a(e),s(null);try{await n.request(`theme.install`,{name:e}),await O_(n),await k_(n,`theme`,e)}catch{s(e)}finally{a(null)}},h=new Set(e.themes.map(e=>e.name)),_=(r?.themes??[]).filter(e=>!h.has(e.name));return(0,V.jsxs)(Aj,{label:e.label,hint:z(`prefs.themePreviewHint`),stack:!0,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:_j,children:z(`prefs.themeInstalled`)}),(0,V.jsx)(VM,{children:e.themes.map(t=>(0,V.jsx)(BM,{theme:t,mode:e.mode,active:t.name===e.value,tag:t.bundled?void 0:z(`prefs.themeUser`),onClick:()=>t.name!==e.value&&void k_(n,`theme`,t.name)},t.name))})]}),_.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(H,{className:`inline-flex items-center gap-1.5`,"aria-expanded":u,onClick:()=>d(!u),children:[(0,V.jsx)(Ma,{right:!u}),u?z(`prefs.themeHide`):z(`prefs.themeBrowse`,{count:_.length})]}),u&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`m-0 pb-1.5 text-meta font-medium text-subtle mt-2.5`,children:z(`prefs.themeMoreHint`)}),(0,V.jsx)(VM,{children:_.map(t=>(0,V.jsx)(BM,{theme:t,mode:e.mode,active:!1,tag:i===t.name?z(`prefs.themeInstalling`):o===t.name?z(`prefs.themeInstallFailed`):z(`prefs.themeGet`),onClick:()=>i===null&&void m(t.name)},t.name))})]})]}),p&&(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,V.jsx)(H,{variant:`action`,onClick:()=>f(p),children:z(`prefs.themeAgent`)}),(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:z(c?`prefs.themeAgentFailed`:`prefs.themeAgentHint`)})]})]})}var UM=_({}),WM=``,GM=`(prefers-color-scheme: dark)`;function KM(e){let t=window.matchMedia(GM);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function qM(){return(0,g.useSyncExternalStore)(KM,()=>window.matchMedia(GM).matches)}function JM(){let e=qM();return l_(A_().prefs.themeMode,e)}function YM(e){let t=JM(),n=A_();(0,g.useEffect)(()=>{if(!n.loaded||n.prefs.taskColors!==`on`)return;let r=`${n.prefs.theme}/${t}`;r!==WM&&(WM=r,UM.set({}));let i=()=>{let i=UM.get(),a=e.tasks.get(),o=[...a?.tasks??[],...a?.archived??[]].map(e=>e.id).filter(e=>!(e in i));o.length!==0&&e.client.request(`theme.taskColors`,{theme:n.prefs.theme,mode:t,taskIds:o}).then(e=>{WM===r&&UM.set({...UM.get(),...e.colors})}).catch(()=>void 0)};return i(),e.tasks.subscribe(i)},[e,t,n.loaded,n.prefs.taskColors,n.prefs.theme])}function XM(e){let t=A_(),n=v(UM);return e&&t.prefs.taskColors===`on`?n[e]:void 0}var ZM={themeMode:{dark:`appearance.modeDark`,light:`appearance.modeLight`,auto:`appearance.modeAuto`},focusAccent:{primary:`general.accentPrimary`,success:`general.accentSuccess`,info:`general.accentInfo`},splitStyle:{box:`general.splitBox`,line:`general.splitLine`,rail:`general.splitRail`,rule:`general.splitRule`},railFold:{glyphs:`general.railFoldGlyphs`,initials:`general.railFoldInitials`,hairline:`general.railFoldHairline`},workingBorder:{flow:`appearance.borderFlow`,still:`appearance.borderStill`},glyphSet:{braille:`appearance.glyphsBraille`,starburst:`appearance.glyphsStarburst`,ascii:`appearance.glyphsAscii`},runningTitle:{shimmer:`appearance.titleShimmer`,still:`appearance.titleStill`}};function QM({model:e}){let{client:t}=e,n=A_(),r=JM(),i=v(AT),a=(e,n)=>void k_(t,e,n),o=(e,t,r)=>(0,V.jsx)(Nj,{label:$(t),hint:r,value:n.prefs[e],picks:j_(n,e).map(t=>({value:t,label:e===`themeMode`&&t===`auto`?z(`prefs.modeAuto`):$(ZM[e]?.[String(t)]??String(t))})),onPick:t=>a(e,t)}),s=(e,t,r)=>(0,V.jsx)(jj,{label:$(t),hint:r,checked:e===`transparent`?n.prefs.transparent:n.prefs[e]===`on`,onChange:t=>a(e,e===`transparent`?t:t?`on`:`off`)});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(kj,{children:[(0,V.jsx)(HM,{model:e,label:$(`general.theme`),themes:n.themes,value:n.prefs.theme,mode:r}),o(`themeMode`,`general.themeMode`)]}),(0,V.jsxs)(kj,{title:z(`settings.appearance.groupColours`),children:[o(`focusAccent`,`general.focusAccent`,$(`general.focusAccentHint`)),s(`taskColors`,`general.taskColors`,z(`settings.appearance.taskColorsNote`)),s(`colorblind`,`general.colorblind`,z(`settings.appearance.colorblindNote`))]}),(0,V.jsxs)(kj,{title:z(`settings.appearance.groupTasks`),children:[o(`workingBorder`,`general.workingBorder`,z(`settings.appearance.workingBorderNote`)),o(`runningTitle`,`general.runningTitle`),o(`glyphSet`,`general.glyphSet`),o(`railFold`,`general.railFold`,$(`general.railFoldHint`)),(0,V.jsx)(Nj,{label:z(`settings.appearance.railGroup`),value:i,picks:OT.map(e=>({value:e,label:z(e===`state`?`settings.appearance.railGroupState`:`settings.appearance.railGroupProject`)})),onPick:jT})]}),(0,V.jsxs)(kj,{title:z(`settings.appearance.groupTerminal`),hint:z(`prefs.terminalOnly`),children:[s(`transparent`,`general.transparent`),o(`splitStyle`,`general.splitStyle`)]})]})}function $M(e,t,n){if(t===`offline`)return`offline`;if(t===`unsupported`||t===`mismatch`)return`outdated`;if(!e)return`loading`;let r=e.status;return r?r.gh?r.account?r.account===n?`same`:`different`:`signedOut`:`noGh`:e.reason===`failed`||!e.reason?`failed`:e.reason}var eN=2e3,tN=e=>e?.login?.state===`pending`||e?.login?.state===`syncing`;function nN(e){let{client:t}=e,n=gE(e),[r,i]=(0,g.useState)({}),a=n.flatMap(e=>e.state===`online`?[e.alias]:[]).join(`
114
+ `,1)[0]??``;function WD(e){return(0,V.jsx)(`ul`,{className:`${Jt} ${e.className}`,children:e.items.map((t,n)=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(H,{variant:`row`,tabIndex:-1,"aria-pressed":n===e.at,className:Yt({cursor:n===e.at,accent:!1}),onMouseDown:t=>{t.preventDefault(),e.onPick(n)},children:[(0,V.jsxs)(`span`,{className:`text-accent`,children:[`@`,t.name]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,UD(t.text)]})]})},t.name))})}function GD(e){let t=FD(),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),c=(0,g.useRef)(null),l=BD(e.value,Math.min(n,e.value.length)),u=l?VD(t,l.query):[],d=l!==null&&u.length>0&&o!==l.start,f=Math.min(i,Math.max(0,u.length-1));(0,g.useLayoutEffect)(()=>{let t=c.current,n=e.area.current;t===null||!n||(c.current=null,n.setSelectionRange(t,t),r(t))});let p=t=>{let n=u[t];if(!l||!n)return;let r=HD(e.value,l,n);c.current=r.caret,a(0),e.onChange(r.text)},m=e=>{if(!d||e.nativeEvent.isComposing)return!1;if(e.key===`ArrowDown`||e.key===`ArrowUp`)a(Math.max(0,Math.min(u.length-1,f+(e.key===`ArrowDown`?1:-1))));else if(e.key===`Tab`&&!e.shiftKey||e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)p(f);else if(e.key===`Escape`)s(l?.start??null),e.stopPropagation();else return!1;return e.preventDefault(),!0};return{list:d?(0,V.jsx)(WD,{items:u,at:f,className:e.listClassName??``,onPick:p}):null,field:{onChange:t=>{r(t.target.selectionStart),a(0),e.onChange(t.target.value)},onSelect:e=>r(e.currentTarget.selectionStart),onKeyDown:t=>{m(t)||!e.onEnter||t.key!==`Enter`||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),e.onEnter())}}}}function KD(e,t){fn(e,void 0,t)}function qD(){fn(void 0,void 0,void 0,void 0,!0)}var JD=`rove.web.newSession.worktree`,YD=``;function XD({model:e,seed:t}){let n=t.repo;B();let r=v(e.selection).taskId,i=e.tasks.get()?.tasks.find(e=>e.id===r)?.repo,a=TC(e,n??i,t.engine),o=Ns(e,`repos.list`)?.repos,s=e=>t.ungrouped?void 0:(t.machine?void 0:n)??i??e?.[0],[c,l]=(0,g.useState)(o??[]),[u,d]=(0,g.useState)(()=>Ns(e,`fs.subdirs`,{path:`~/`})?.home??``),[f,p]=(0,g.useState)(()=>kD(s(o),t)),[m,h]=(0,g.useState)(()=>Object.fromEntries(f.flatMap(t=>{let n=Ns(e,`repo.probe`,{path:t});return n?[[t,n]]:[]}))),_=(0,g.useRef)(new Set),[y,b]=(0,g.useState)(t.ungrouped===!0),x=()=>{b(!0),p([])},[S,C]=(0,g.useState)(()=>AD(s(o),t)),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(()=>(t.prompt!==void 0&&(YD=t.prompt),YD)),A=e=>{YD=e,k(e)},[j,ee]=(0,g.useState)(``),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,te]=(0,g.useState)(``),[L,ne]=(0,g.useState)(()=>t.worktree??localStorage.getItem(JD)!==`0`),re=e=>{localStorage.setItem(JD,e?`1`:`0`),ne(e)},[ie,R]=(0,g.useState)(null),{attachments:ae,attach:oe,remove:se,clear:ce}=Uo(e,R),le=(0,g.useRef)(null),ue=gE(e),[de,fe]=(0,g.useState)(t.machine??``),pe=de!==``,me=pe?null:zo(e=>void oe(e)),he=ue.find(e=>e.alias===de)?.hostLabel||de,ge=eD(e,de);$E(e,ue);let[_e,ve]=(0,g.useState)(null),[ye,be]=(0,g.useState)(``);(0,g.useEffect)(()=>{Promise.all([Fs(e,`repos.list`),Fs(e,`fs.subdirs`,{path:`~/`})]).then(([e,n])=>{l(e.repos),d(n.home);let r=s(e.repos);p(e=>e.length>0||!r?e:kD(r,t)),C(e=>({...e,...AD(r,t)}))}).catch(()=>{})},[e,n]);let xe=!pe&&!L&&f.length===1,Se=f[0]??``;(0,g.useEffect)(()=>{for(let t of f)_.current.has(t)||(_.current.add(t),Fs(e,`repo.probe`,{path:t}).then(e=>h(n=>({...n,[t]:e}))).catch(()=>{}))},[e,f]),(0,g.useEffect)(()=>{!pe||!ge.loaded||de!==t.machine||ve(e=>e??JE(n,ge.repos))},[ge.loaded]),(0,g.useEffect)(()=>le.current?.focus(),[]);let Ce=!pe&&!y&&!xe,we=cD(a,Ce),Te=a.engines.find(e=>e.id===a.engine),Ee=gs(Te,z(`newSession.modelDefault`)),De=_s(Te,z(`newSession.effortDefault`)),Oe=Ee.some(e=>e.id===j)?j:``,ke=De.some(e=>e.id===M)?M:``,Ae=async t=>{R(null),F(!0),te(z(`newSession.cloning`,{source:t}));try{let n=ts(es((localStorage.getItem(`rove.web.cloneParent`)||`~/`).trim(),u)),r=await e.client.request(`repo.clone`,{url:t,parentDir:n},te);l(e=>e.includes(r.path)?e:[...e,r.path]),p(e=>e.includes(r.path)?e:Cs(e,r.path)),b(!1),D(``)}catch(e){R(oD(e))}finally{F(!1),te(``)}},Me=async n=>{if(!_e)return R(z(`newSession.needRepo`));if(n&&!O.trim())return R(z(`newSession.needPrompt`));F(!0),te(_e.clone?z(`newSession.cloningOn`,{source:_e.ref,machine:he}):z(`newSession.startingOn`,{machine:he}));try{let r=await aD(e,{pick:_e,machine:de,engine:a.engine,prompt:O.trim(),begin:n,baseRef:ye});YD=``,dn.set(null),r&&e.selectWhenListed(r),t.retryOf&&r&&ND(e,t.retryOf)}catch(e){R(oD(e))}finally{F(!1),te(``)}},Ne=async(n=!0,r)=>{if(R(null),pe)return Me(n);if(!Se&&!y)return R(z(`newSession.needRepo`));if((n||r)&&!O.trim())return R(z(`newSession.needPrompt`));F(!0);let i=Vo(O.trim(),ae);try{let o=await Promise.all(f.map(t=>e.client.request(`repo.probe`,{path:t}))),s=o.find(e=>!e.ok);if(s)throw Error(s.reason??s.repo);let c,l;if(y)c=await Es(e.client.request.bind(e.client),a.engine,O,n);else if(xe)c=await Ds(e.client.request.bind(e.client),o[0]?.repo??Se,a.engine,O,n,i);else{let r=await e.client.request(`task.spawn`,Ts({repos:f.map((e,t)=>({repo:o[t]?.repo??e,baseRef:S[e]??``})),branch:w.trim(),engine:a.engine,commandFrom:jD(t,a.engine),engines:n?we.ids:[],prompt:i,begin:n,model:Oe,effort:ke}));c=r.taskIds[0],l=r.groupId}r&&c&&await gD(e.client,c,r,i).then(()=>G(z(`newSession.laterSet`,{time:hD(r)}))).catch(e=>G(oD(e),`error`)),YD=``,ce(),dn.set(null),l?ga(l):c&&e.selectWhenListed(c),t.retryOf&&c&&ND(e,t.retryOf)}catch(e){let t=xs(e);t?(YD=``,ce(),dn.set(null),G(e instanceof Error?e.message:String(e),`error`),ga(t)):R(e instanceof Error?e.message:String(e))}finally{F(!1)}},H=GD({value:O,onChange:A,area:le,onEnter:()=>void Ne()});return(0,V.jsxs)(`div`,{className:_E,children:[(0,V.jsxs)(`div`,{className:vE,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-accent`,children:z(`newSession.title`)}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:z(`newSession.tagline`)})]}),(0,V.jsxs)(`form`,{className:yE,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,V.jsxs)(`div`,{className:bE,...me?.drop,children:[(0,V.jsx)(`textarea`,{ref:le,className:SE,rows:4,spellCheck:!1,placeholder:z(`newSession.placeholder`),value:O,disabled:P,onPaste:me?.onPaste,...H.field}),H.list,(0,V.jsxs)(`div`,{className:xE,children:[!pe&&!y&&!we.comparing&&(0,V.jsx)(_D,{disabled:P,onSchedule:e=>void Ne(!1,e),onInvalid:R}),(0,V.jsx)(`button`,{type:`button`,className:EE(),disabled:P||we.comparing,title:we.comparing?z(`compare.needsPrompt`):void 0,onClick:()=>void Ne(!1),children:z(`newSession.createOnly`)}),(0,V.jsx)(`button`,{type:`submit`,className:je(),disabled:P,children:z(`newSession.start`)})]})]}),(0,V.jsxs)(`div`,{className:CE,children:[(0,V.jsx)(rD,{machines:ue,value:de,onPick:e=>{fe(e),ve(null),be(``),D(``),R(null),b(!1)}}),(0,V.jsx)(VE,{field:`repo`,title:!pe&&f.length>1?z(`newSession.repoCount`,{count:f.length}):z(`newSession.repo`),label:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(RE,{}),Ss(pe?_e?[_e.ref]:[]:f)||z(y?`rail.noProject`:`newSession.repo`),_e?.clone&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,z(`newSession.cloneTag`)]})]}),children:t=>(0,V.jsx)(yD,{model:e,saved:pe?ge.repos.map(qE):c,picked:pe?_e?[_e.ref]:[]:f,primary:pe?``:Se,home:pe?``:u,query:E,onQuery:D,onToggle:e=>{if(R(null),!pe)return b(!1),p(t=>Cs(t,e));ve({ref:e,clone:!1}),t()},onClone:e=>pe?ve({ref:e,clone:!0}):void Ae(e),close:t,remote:pe?{name:he,empty:tD(de,ge),blocked:ge.problem!==``}:void 0,ungrouped:pe?void 0:{on:y,pick:x}})}),(0,V.jsx)(sD,{remote:pe,remotePick:_e,remoteBase:ye,onRemoteBase:be,ungrouped:y,inPlace:xe,onToggleWorktree:()=>re(!L),repos:f,probes:m,bases:S,onBase:(e,t)=>C(n=>({...n,[e]:t})),branchName:w,onBranchName:T}),me&&(0,V.jsxs)(Bo,{className:`${EE(ae.length>0)} cursor-pointer`,title:z(`newSession.attachHint`),disabled:P,onFiles:e=>void oe(e),children:[(0,V.jsx)(BE,{}),z(`newSession.attach`)]}),(0,V.jsx)(`span`,{className:wE}),(0,V.jsx)(lD,{choice:a,picks:we,available:Ce}),!xe&&!pe&&!y&&!we.comparing&&(Ee.length>0||De.length>0)&&(0,V.jsx)(uD,{models:Ee,model:Oe,onModel:ee,efforts:De,effort:ke,onEffort:N})]}),!pe&&(0,V.jsx)(Wo,{attachments:ae,onRemove:se}),P&&I&&(0,V.jsx)(`p`,{className:`text-muted`,"data-field":`clone-progress`,children:I}),ie&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,ie]})]}),!pe&&(0,V.jsx)(`button`,{type:`button`,className:`mt-2 self-center px-1.5 py-0.5 text-subtle focus-visible:text-ink touch:mt-0.5 touch:py-2 [&:hover]:text-ink`,onClick:()=>W.set((0,V.jsx)(DD,{model:e,repo:Se||void 0})),children:z(`newSession.moreWays`)})]})}var ZD=[`needs`,`working`,`ready`,`idle`],QD=`~state:`;function $D(e){switch(e.rowStatus?.kind){case`attention`:case`needs-input`:case`unseen`:return`needs`;case`busy`:case`running`:return`working`}switch(e.group){case`waiting-on-you`:return`needs`;case`working`:return`working`;case`landing`:case`ready-for-review`:return`ready`}return e.pr?.lifecycle===`open`||e.status===`done`?`ready`:`idle`}var eO=e=>e&&e.kind!==`main`&&!aw(e)?zC(e.repo):void 0;function tO(e,t){let n=ow(e,t.sort),{children:r,nested:i}=dw([{repo:``,label:``,tasks:n}]),a=n.filter(e=>!i.has(e.id)),o=KC(a),s=e=>{let t=[],n=new Set,i=e=>{if(!n.has(e.id)){n.add(e.id),t.push(e);for(let t of r.get(e.id)??[])i(t)}};return i(e),t},c=new Map;for(let e of a){let t=GC(e),n=((t===null?void 0:o.get(t))??[e]).map(s),r=n.flat().map($D).reduce((e,t)=>ZD.indexOf(t)<ZD.indexOf(e)?t:e);for(let e of n)for(let t of e)c.set(t.id,r)}return ZD.flatMap(e=>{let t=n.filter(t=>c.get(t.id)===e);return t.length===0?[]:[{repo:``,label:z(`rail.state.${e}`),key:`${QD}${e}`,tasks:t}]})}function nO(e){let t=new Set(e.machines.map(e=>e.alias));return{rows:rO(mw(tO([...e.tasks.filter(e=>!e.routine),...e.remote.filter(e=>!e.routine&&e.machine!==void 0&&t.has(e.machine.id))],e),e.query,e.fold).map(e=>{if(e.kind!==`project`)return e;let t=e.id.slice(`project:${QD}`.length);return{id:`state:${t}`,kind:`state`,state:t,label:e.label,count:0}})),groups:[]}}function rO(e){let t=new Map,n=``;for(let r of e)r.kind===`state`?n=r.id:r.kind===`task`&&t.set(n,(t.get(n)??0)+1);return e.map(e=>e.kind===`state`?{...e,count:t.get(e.id)??0}:e)}var iO=new Set([`refused`,`timeout`,`host-key-changed`,`host-key-unverified`,`auth-denied`,`unresolved`,`ssh-failed`,`no-rove`,`no-daemon`,`bad-status`,`handshake`,`no-forwarding`,`lost`]);function aO(e){return e&&iO.has(e)?`machines.reason.${e}`:null}function oO(e,t){return e.filter(e=>e.machine?.id===t&&!e.routine&&!e.deleting)}function sO(e){let t=ZD.map(e=>({state:e,tasks:[]}));for(let n of e)t[ZD.indexOf($D(n))]?.tasks.push(n);return t.filter(e=>e.tasks.length>0)}var cO=`flex flex-col font-mono text-meta`,lO=`flex flex-col gap-1 border-t-hairline border-line py-2.5 first:border-t-0 first:pt-0`,uO=`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,dO=`min-w-0 text-ink wrap-anywhere`,fO=`m-0 text-muted wrap-anywhere`,pO=`flex flex-wrap gap-x-3.5 gap-y-1 pt-0.5 whitespace-nowrap`,mO=`mt-1.5 mb-0.5 text-subtle`,hO=`flex min-w-0 items-baseline gap-2 pl-2`,gO=`min-w-0 flex-1 truncate text-left`,_O=`min-w-0 max-w-[55%] flex-none truncate text-muted`;function vO(e){W.set((0,V.jsx)(SO,{model:e}))}function yO({model:e,tasks:t}){let n=t=>{yn(),e.select(t.id),pa()};return sO(t).map(e=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`${mO} m-0`,children:z(`rail.state.${e.state}`)}),e.tasks.map(e=>(0,V.jsxs)(H,{variant:`row`,className:`${hO} w-full rounded-sm py-0.5 hover:bg-hover`,onClick:()=>n(e),children:[(0,V.jsx)(`span`,{className:gO,children:e.label}),(0,V.jsx)(`span`,{className:_O,children:e.branch})]},e.id))]},e.state))}function bO({model:e,alias:t}){let[n,r]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return Fs(e,`machines.repos`,{machine:t}).then(e=>n&&r(e),e=>n&&r({failed:e instanceof Error?e.message:String(e)})),()=>{n=!1}},[e,t]),n?`failed`in n?(0,V.jsx)(`p`,{className:fO,children:z(`machines.reposFailed`,{message:n.failed})}):n.reason?(0,V.jsx)(`p`,{className:fO,children:z(`machines.reposFailed`,{message:n.message??n.reason})}):n.repos.length===0?(0,V.jsx)(`p`,{className:fO,children:z(`machines.noRepos`)}):n.repos.map(e=>(0,V.jsxs)(`div`,{className:hO,children:[(0,V.jsx)(`span`,{className:gO,children:e.id}),(0,V.jsx)(`span`,{className:_O,title:e.primary??e.checkouts[0],children:e.primary??e.checkouts[0]??``})]},e.id)):(0,V.jsx)(`p`,{className:fO,children:z(`machines.loading`)})}function xO(e){let{model:t,row:n,tasks:r,words:i}=e,[a,o]=(0,g.useState)(null),s=n.state===`online`,c=aO(n.reason),l=sO(r).map(e=>`${e.tasks.length} ${z(`rail.state.${e.state}`)}`),u=e=>o(a===e?null:e);return(0,V.jsxs)(`section`,{className:lO,children:[(0,V.jsxs)(`div`,{className:uO,children:[(0,V.jsx)(`span`,{className:`${dO} ${s?``:CT.warning}`,children:dE(n,i)}),(0,V.jsx)(`span`,{className:`text-muted`,children:l.length>0?l.join(` · `):z(`machines.noTasks`)})]}),c&&(0,V.jsx)(`p`,{className:`m-0 text-muted wrap-anywhere`,children:z(c)}),(0,V.jsxs)(`div`,{className:pO,children:[s&&(0,V.jsx)(H,{hit:`tight`,onClick:()=>{yn(),KD(void 0,n.alias)},children:z(`machines.newHere`)}),r.length>0&&(0,V.jsx)(H,{hit:`tight`,"aria-expanded":a===`tasks`,onClick:()=>u(`tasks`),children:z(a===`tasks`?`machines.hide`:`machines.tasks`)}),s&&(0,V.jsx)(H,{hit:`tight`,"aria-expanded":a===`repos`,onClick:()=>u(`repos`),children:z(a===`repos`?`machines.hide`:`machines.repos`)})]}),a===`tasks`&&(0,V.jsx)(yO,{model:t,tasks:r}),a===`repos`&&(0,V.jsx)(bO,{model:t,alias:n.alias})]})}function SO({model:e}){let t=B(),n=gE(e),r=v(e.remote),i=(t===`zh`?Dr:Er).machine;return(0,V.jsx)(ir,{title:z(`machines.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:`${Pn} ${cO}`,children:[n.length===0&&(0,V.jsx)(`p`,{className:`m-0 text-muted wrap-anywhere`,children:z(`machines.none`)}),n.map(t=>(0,V.jsx)(xO,{model:e,row:t,tasks:oO(r,t.alias),words:i},t.alias))]})})}function CO(e,t,n=300){let r=0,i,a=()=>{r++,i?.(),i=void 0};return{stop:a,run:o=>{a();let s=o.trim();if(s.length<2){t({kind:`idle`});return}let c=r,l=setTimeout(()=>{t({kind:`searching`}),e(s).then(e=>c===r&&t({kind:`done`,query:s,reply:e}),e=>c===r&&t({kind:`failed`,message:e instanceof Error?e.message:String(e)}))},n);i=()=>clearTimeout(l)}}}var wO=`mx-1.5 mt-2 mb-0.5 font-mono text-meta font-semibold normal-nums text-subtle first:mt-0`,TO=`mx-1.5 my-1 text-meta text-muted [overflow-wrap:anywhere]`,EO=e=>`flex w-full min-w-0 cursor-pointer flex-col gap-0.5 rounded-sm px-1.5 py-1.5 text-left text-ink [font:inherit] touch:py-2.5 ${e?`is-selected bg-hover`:``}`,DO=`flex min-w-0 items-baseline gap-2`,OO=`min-w-0 flex-1 truncate text-body`,kO=`whitespace-nowrap text-meta text-muted`,AO=`text-meta text-muted [overflow-wrap:anywhere]`,jO=`rounded-xs bg-accent/25 text-ink`;function MO(e,t){let[n,r]=(0,g.useState)({kind:`idle`});return(0,g.useEffect)(()=>{let n=CO(t=>e.client.request(`sessions.search`,{query:t}),r);return n.run(t),n.stop},[e,t]),n}function NO(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=0;for(let t=r.indexOf(i);i&&t>=0;t=r.indexOf(i,t+i.length))t>a&&n.push(e.slice(a,t)),n.push({hit:e.slice(t,t+i.length),at:t}),a=t+i.length;return n.push(e.slice(a)),n.map(e=>typeof e==`string`?e:(0,V.jsx)(`mark`,{className:jO,children:e.hit},e.at))}function PO({children:e}){return(0,V.jsx)(`h3`,{className:wO,children:e})}function FO({children:e,error:t}){return(0,V.jsx)(`p`,{className:`${TO} ${t?`text-error`:``}`,children:e})}function IO(e){return(0,V.jsx)(H,{variant:`row`,className:EO(e.selected),onMouseEnter:e.onHover,onClick:e.onOpen,children:(0,V.jsxs)(`span`,{className:DO,children:[(0,V.jsx)(`span`,{className:OO,children:e.title}),(0,V.jsx)(`span`,{className:kO,children:e.repo})]})})}function LO(e){let{hit:t}=e;return(0,V.jsxs)(H,{variant:`row`,className:EO(e.selected),onMouseEnter:e.onHover,onClick:e.onOpen,children:[(0,V.jsxs)(`span`,{className:DO,children:[(0,V.jsx)(`span`,{className:OO,children:t.title}),(0,V.jsxs)(`span`,{className:kO,children:[z(t.role===`user`?`search.you`:`search.agent`),` · `,Mo(Date.now()-Date.parse(t.at))]})]}),(0,V.jsx)(`span`,{className:AO,children:NO(t.snippet,e.query)})]})}var RO=_(`issues`);function zO(e,t,n){return{repo:e.repo,baseBranch:t,prompt:n,worktree:!0}}var BO=.2,VO=[`files`,`chat`,`diff`,`browser`];function HO(){return{top:{tabs:[{id:`t1`,kind:`files`}],active:`t1`},bottom:null,ratio:.5,focus:`top`,recent:[`t1`],next:2}}function UO(e){return e.bottom?[[`top`,e.top],[`bottom`,e.bottom]]:[[`top`,e.top]]}function WO(e){let t=e=>Number(e.id.slice(1));return UO(e).flatMap(([,e])=>e.tabs).sort((e,n)=>t(e)-t(n))}function GO(e,t){for(let[n,r]of UO(e)){let e=r.tabs.find(e=>e.id===t);if(e)return{tab:e,name:n,group:r}}return null}function KO(e,t){let n=WO(e).filter(e=>e.kind===t);for(let t of[...e.recent].reverse()){let e=n.find(e=>e.id===t);if(e)return e}return n[0]??null}function qO(e){return e.urls[e.at]??``}function JO(e){return e.slice(e.lastIndexOf(`/`)+1)}function YO(e){try{return new URL(e).host.replace(/^www\./,``)}catch{return e}}function XO(e,t){for(let[n,r]of UO(e))if(r.tabs.some(e=>e.kind===t))return n;return e.bottom?e.focus:`top`}function ZO(e,t,n){let r=e.tabs.filter(e=>e.id!==n).map(e=>e.id);for(let e of[...t].reverse())if(r.includes(e))return e;return r[0]??null}function QO(e){let{top:t,bottom:n}=e;n&&n.tabs.length===0&&(n=null),t.tabs.length===0&&n&&([t,n]=[n,null]);let r=new Set([...t.tabs,...n?.tabs??[]].map(e=>e.id)),i=e.recent.filter(e=>r.has(e)),a=e=>e.active&&e.tabs.some(t=>t.id===e.active)?e:{...e,active:ZO(e,i)};return{...e,top:a(t),bottom:n&&a(n),recent:i,focus:n?e.focus:`top`}}function $O(e,t,n){return t===`top`?{...e,top:n}:{...e,bottom:n}}function ek(e,t){let n=GO(e,t);if(!n)return e;let{group:r,name:i}=n,a=[...e.recent.filter(e=>e!==t),t];return r.active===t&&e.focus===i&&e.recent.at(-1)===t?e:{...$O(e,i,{...r,active:t}),focus:i,recent:a}}function tk(e){let t=WO(e);if(t.length<=12)return e;let n=new Set(UO(e).map(([,e])=>e.active)),r=t.filter(e=>!n.has(e.id)).sort((t,n)=>e.recent.indexOf(t.id)-e.recent.indexOf(n.id))[0];return r?mk(e,r.id):e}function nk(e,t,n){let r=`t${e.next}`,i=t===`bottom`&&e.bottom?`bottom`:`top`,a=i===`bottom`&&e.bottom?e.bottom:e.top;return tk(ek($O({...e,next:e.next+1},i,{...a,tabs:[...a.tabs,n(r)]}),r))}var rk=e=>({id:e,kind:`browser`,urls:[],at:-1});function ik(e,t){return nk(e,t,e=>({id:e,kind:`files`}))}function ak(e,t){return nk(e,t,rk)}function ok(e,t,n){let r=WO(e).find(e=>e.kind===`diff`&&e.path===t);return r?r.kind===`diff`&&r.scope!==n?ek(dk(e,{...r,scope:n}),r.id):ek(e,r.id):nk(e,XO(e,`diff`),e=>({id:e,kind:`diff`,path:t,scope:n}))}function sk(e,t){let n=WO(e).filter(e=>e.kind===`browser`),r=n.find(e=>qO(e)===t);if(r)return ek(e,r.id);let i=n.find(e=>qO(e)===``);return i?fk(e,i.id,t):fk(nk(e,XO(e,`browser`),rk),`t${e.next}`,t)}function ck(e,t){let n=KO(e,t);return n?ek(e,n.id):t===`diff`?ok(e,`.`,`working`):nk(e,XO(e,t),e=>t===`files`||t===`chat`?{id:e,kind:t}:rk(e))}function lk(e){let t=e.recent.at(-1),n=t?GO(e,t):null,r=n&&n.group.active===t?t:e.top.active;return(r?GO(e,r)?.tab.kind:null)??null}function uk(e,t,n){return t&&lk(e)===n?{panel:e,open:!1}:{panel:ck(e,n),open:!0}}function dk(e,t){let n=e=>({...e,tabs:e.tabs.map(e=>e.id===t.id?t:e)});return{...e,top:n(e.top),bottom:e.bottom&&n(e.bottom)}}function fk(e,t,n){let r=GO(e,t)?.tab;if(r?.kind!==`browser`||qO(r)===n)return e;let i=[...r.urls.slice(0,r.at+1),n].slice(-30);return dk(e,{...r,urls:i,at:i.length-1})}function pk(e,t,n){let r=GO(e,t)?.tab;return r?.kind!==`browser`||n===r.at||n<0||n>=r.urls.length?e:dk(e,{...r,at:n})}function mk(e,t){let n=GO(e,t);if(!n)return e;let{group:r}=n,i=r.tabs.filter(e=>e.id!==t),a=e.recent.filter(e=>e!==t),o=r.active===t?ZO(r,a,t):r.active;return QO({...$O(e,n.name,{tabs:i,active:o}),recent:a})}function hk(e,t){return WO(e).reduce((e,n)=>n.id===t?e:mk(e,n.id),e)}function gk(e,t,n,r){let i=GO(e,t);if(!i)return e;let a=i.group,o=a.tabs.filter(e=>e.id!==t),s=a.tabs.findIndex(e=>e.id===t);if(i.name===n){let c=Math.max(0,Math.min(o.length,(r??o.length)-+(r!==void 0&&r>s)));return ek(c===s?e:$O(e,n,{...a,tabs:[...o.slice(0,c),i.tab,...o.slice(c)]}),t)}let c=e.recent.filter(e=>e!==t),l=$O(e,i.name,{tabs:o,active:a.active===t?ZO(a,c,t):a.active}),u=(n===`top`?l.top:l.bottom)?.tabs??[],d=Math.max(0,Math.min(u.length,r??u.length));return ek(QO($O({...l,recent:c},n,{tabs:[...u.slice(0,d),i.tab,...u.slice(d)],active:t})),t)}function _k(e,t){let n=Math.max(BO,Math.min(.8,t));return Math.abs(n-e.ratio)<.001?e:{...e,ratio:n}}function vk(e,t,n){let r=new Map(n.map(e=>[e.id,e.kind])),i=[...e.filter(e=>r.has(e)&&!t.includes(e)),...t.filter(e=>r.has(e))],a=i.filter(e=>r.get(e)===`browser`),o=new Set(a.slice(0,Math.max(0,a.length-3)).filter(e=>!t.includes(e)));return i=i.filter(e=>!o.has(e)),i}function yk(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||!/^t\d+$/.test(t.id))return null;if(t.kind===`files`||t.kind===`chat`)return{id:t.id,kind:t.kind};if(t.kind===`diff`&&typeof t.path==`string`&&t.path!==``){let e=t.scope===`branch`||t.scope===`task`?t.scope:`working`;return{id:t.id,kind:`diff`,path:t.path,scope:e}}if(t.kind===`browser`&&Array.isArray(t.urls)){let e=t.urls.filter(e=>typeof e==`string`&&e!==``).slice(-30),n=typeof t.at==`number`&&Number.isInteger(t.at)?Math.min(e.length-1,Math.max(-1,t.at)):e.length-1;return{id:t.id,kind:`browser`,urls:e,at:e.length===0?-1:Math.max(0,n)}}return null}function bk(e,t){if(!e||typeof e!=`object`||!(`tabs`in e)||!Array.isArray(e.tabs))return null;let n=[];for(let r of e.tabs){let e=yk(r);!e||t.has(e.id)||(t.add(e.id),n.push(e))}return{tabs:n,active:`active`in e&&typeof e.active==`string`?e.active:null}}function xk(e){if(!e||typeof e!=`object`)return null;let t=e,n=new Set,r=bk(t.top,n);if(!r)return null;let i=bk(t.bottom,n),a=Math.max(0,...[...n].map(e=>Number(e.slice(1)))),o=typeof t.ratio==`number`&&Number.isFinite(t.ratio)?t.ratio:.5;return QO({top:r,bottom:i,ratio:Math.max(BO,Math.min(.8,o)),focus:t.focus===`bottom`?`bottom`:`top`,recent:Array.isArray(t.recent)?t.recent.filter(e=>typeof e==`string`):[],next:Math.max(a+1,typeof t.next==`number`&&Number.isInteger(t.next)?t.next:0)})}function Sk(e,t){let n=HO(),r=typeof t==`string`&&t!==``?t:``;if(e!==`browser`&&!r)return n;let i=ak(n,`top`),a=r?fk(i,`t2`,r):i;return e===`browser`?a:ek(a,`t1`)}function Ck(e){try{let t=JSON.parse(e??`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?Object.entries(t):[]}catch{return[]}}function wk(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));r[t]=n;for(let e of Object.keys(r).slice(0,-50))delete r[e];return r}function Tk(e,t){let n={};for(let[t,r]of Ck(e)){let e=xk(r);e&&(n[t]=e)}let r=new Map(Ck(t.tab).filter(([,e])=>VO.includes(e))),i=new Map(Ck(t.url)),a=[...new Set([...r.keys(),...i.keys()])].filter(e=>!(e in n));n={...Object.fromEntries(a.map(e=>[e,Sk(r.get(e),i.get(e))])),...n};for(let e of Object.keys(n).slice(0,-50))delete n[e];return n}var Ek=[`files`,`diff`,`browser`];function Dk(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.taskId==`string`&&t.taskId!==``&&Ek.includes(t.view)&&typeof t.at==`number`&&(t.url===void 0||typeof t.url==`string`)&&(t.path===void 0||typeof t.path==`string`)}function Ok(e){return e.narrow?{panel:!1,panelOpen:!1,narrow:!0}:{panel:!0,panelOpen:e.panelOpen&&!e.zen,narrow:!1}}function kk(e,t){return{tab:e.path?`diff`:e.view,...e.view===`browser`&&e.url?{url:e.url}:{},...e.view!==`browser`&&e.path?{diff:e.path}:{},show:t.taskId===e.taskId&&!t.narrow}}function Ak(e,t){return t.url?sk(e,t.url):t.diff?ok(e,t.diff,`working`):ck(e,t.tab)}var jk=`rove.web.panels`,Mk=`rove.web.panelTab`,Nk=`rove.web.panelUrl`;function Pk(){let e={tab:localStorage.getItem(Mk),url:localStorage.getItem(Nk)},t=Tk(localStorage.getItem(jk),e);return(e.tab!==null||e.url!==null)&&(localStorage.setItem(jk,JSON.stringify(t)),localStorage.removeItem(Mk),localStorage.removeItem(Nk)),t}var Fk=_(Pk()),Ik=HO();function Lk(e){return v(Fk)[e]??Ik}function Rk(e,t){let n=Fk.get()[e]??Ik,r=t(n);if(r===n)return;let i=wk(Fk.get(),e,r);Fk.set(i),localStorage.setItem(jk,JSON.stringify(i))}function zk(e,t){Rk(e,e=>ck(e,t)),Ua.set(!0),ya()&&za.set(t)}function Bk(e,t){let n=uk(Fk.get()[e]??Ik,Ua.get()&&!un.get(),t);Rk(e,()=>n.panel),Ua.set(n.open),n.open&&un.get()&&un.set(!1)}function Vk(e){Rk(e.taskId,t=>ok(t,e.path,e.scope)),Ua.set(!0),un.get()&&un.set(!1),ya()&&za.set(`diff`)}function Hk(e,t){Rk(e,e=>sk(e,t)),Ua.set(!0),un.get()&&un.set(!1),ya()&&za.set(`browser`)}function Uk(e,t){Rk(e,e=>mk(e,t));let n=za.get();ya()&&n!==`terminal`&&!KO(Fk.get()[e]??Ik,n)&&zk(e,`files`)}function Wk(e,t){let n=kk(e,{taskId:t,narrow:ya()});Rk(e.taskId,e=>Ak(e,n)),n.show&&(Ua.set(!0),un.get()&&un.set(!1))}var Gk=_(null),Kk=0;function qk(e,t){Gk.set({taskId:e,hit:t,nonce:++Kk}),zk(e,`chat`),un.get()&&un.set(!1)}var Jk=10;function Yk(e,t){let n=e=>e.surface===t?0:e.surface?1:2,r=Yi().filter(n=>Xi(n,t)&&n.live?.(e)!==!1).map((e,t)=>({command:e,index:t})).sort((e,t)=>n(e.command)-n(t.command)||Number(e.command.prefix)-Number(t.command.prefix)||e.index-t.index),i=new Set,a=[];for(let{command:e}of r){let t=e.chords[0];!t||e.id===`palette.open`||i.has(e.id)||(i.add(e.id),a.push({command:e,name:bo(e.id),raw:e.prefix?`${Zr()} + ${t}`:t}))}return a}function Xk(e){let t=document.activeElement instanceof HTMLElement?document.activeElement:null;W.set((0,V.jsx)(Qk,{model:e,surface:Qi(),origin:t}))}var Zk=8;function Qk({model:e,surface:t,origin:n}){B();let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(0),s=(0,g.useRef)(null),c=v(Kr),l=v(e.tasks),u=v(e.remote),d=(0,g.useMemo)(()=>Yk(e,t),[e,t,c]).filter(e=>oo(r,e.name,e.raw)),f=(gE(e).length>0?[{name:z(`machines.title`)}]:[]).filter(e=>oo(r,e.name,``)),p=r.trim(),m=p===``?[]:[...l?.tasks??[],...u].filter(e=>!e.routine&&!e.deleting&&[e.label,e.title,e.branch,zC(e.repo)].some(e=>e!==``&&Qa(p,e))).slice(0,Zk),h=v(e.installedMods).has(`issues`),_=[{id:`usage`,name:z(`usage.title`)},...h?[{id:`issues`,name:z(`reviewQueue.palette`),source:`reviews`}]:[]].filter(e=>p===``||Qa(p,e.name)),y=MO(e,r),b=y.kind===`done`?y.reply.matches:[],x=[...d.map(e=>({kind:`command`,row:e})),..._.map(e=>({kind:`page`,...e})),...f.map(e=>({kind:`machines`,...e})),...m.map(e=>({kind:`task`,task:e})),...b.map(e=>({kind:`hit`,hit:e}))],S=Math.min(a,Math.max(0,x.length-1));(0,g.useEffect)(()=>()=>n?.focus(),[n]),(0,g.useEffect)(()=>{s.current?.querySelector(`.is-selected`)?.scrollIntoView({block:`nearest`})},[S]);let C=t=>{if(t.kind===`machines`){vO(e);return}if(yn(),n?.focus(),t.kind===`command`){t.row.command.live?.(e)===!1?G(_o(`unavailable`),`error`):t.row.command.run(e);return}if(t.kind===`page`){t.source&&RO.set(t.source),ha(t.id);return}t.kind===`task`?e.select(t.task.id):e.select(t.hit.taskId,t.hit.tabId??null),pa(),t.kind===`hit`&&qk(t.hit.taskId,t.hit)},w=e=>{if(e.key===`ArrowDown`)o(Math.min(x.length-1,S+1));else if(e.key===`ArrowUp`)o(Math.max(0,S-1));else if(e.key===`Enter`){let e=x[S];e&&C(e)}else return;e.preventDefault()},T=p!==``&&(m.length>0||p.length>=2),E=0,D=()=>E++;return(0,V.jsx)(ir,{title:_o(`palette`),wide:!0,children:(0,V.jsxs)(`div`,{className:`${Pn} palette`,onKeyDown:w,children:[(0,V.jsx)(`input`,{className:ut,autoFocus:!0,spellCheck:!1,value:r,placeholder:_o(`search`),onChange:e=>{i(e.target.value),o(0)}}),(0,V.jsxs)(`div`,{className:st,ref:s,style:{maxHeight:`${(T?18:Jk)*1.9}em`},children:[x.length===0&&y.kind!==`searching`&&(0,V.jsx)(`p`,{className:`text-muted`,children:_o(`noResults`)}),T&&d.length>0&&(0,V.jsx)(PO,{children:z(`search.commands`)}),d.map(e=>{let t=D();return(0,V.jsx)(`button`,{type:`button`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`command`,row:e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},e.command.id)}),_.map(e=>{let t=D();return(0,V.jsx)(H,{variant:`row`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`page`,...e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},e.id)}),f.map(e=>{let t=D();return(0,V.jsx)(H,{variant:`row`,className:ct(t===S),title:e.name,onMouseEnter:()=>o(t),onClick:()=>C({kind:`machines`,...e}),children:(0,V.jsx)(`span`,{className:lt,children:`${t===S?`› `:` `}${e.name}`})},`machines`)}),m.length>0&&(0,V.jsx)(PO,{children:z(`search.tasks`)}),m.map(e=>{let t=D();return(0,V.jsx)(IO,{title:e.label,repo:zC(e.repo),selected:t===S,onHover:()=>o(t),onOpen:()=>C({kind:`task`,task:e})},e.id)}),y.kind!==`idle`&&(0,V.jsx)(PO,{children:z(`search.inConversations`)}),y.kind===`searching`&&(0,V.jsx)(FO,{children:z(`search.searching`)}),y.kind===`failed`&&(0,V.jsx)(FO,{error:!0,children:y.message}),y.kind===`done`&&b.length===0&&(0,V.jsx)(FO,{children:z(`search.none`,{query:y.query})}),b.map(e=>{let t=D();return(0,V.jsx)(LO,{hit:e,query:y.kind===`done`?y.query:``,selected:t===S,onHover:()=>o(t),onOpen:()=>C({kind:`hit`,hit:e})},`${e.taskId}:${e.tabId??``}:${e.at}:${t}`)}),y.kind===`done`&&y.reply.truncated&&(0,V.jsx)(FO,{children:z(`search.truncated`)}),y.kind===`done`&&y.reply.skipped.length>0&&(0,V.jsx)(FO,{children:z(`search.skipped`,{count:y.reply.skipped.length})})]}),(0,V.jsx)(`p`,{className:`keys-only text-muted`,children:_o(`run`)})]})})}var $k=_(null);function eA(e){let t=(document.activeElement?.closest(`.rail`)==null?null:$k.get())??e.selection.get().taskId;return e.tasks.get()?.tasks.find(e=>e.id===t)??null}t(((e,t)=>{t.exports={}}))();var tA={$schema:`https://json.schemastore.org/package.json`,name:`@sma1lboy/rove`,version:`0.9.276`,description:`Rove — the agent multiplexer for your terminal. Run coding agents on parallel tasks with isolated worktrees and persistent sessions.`,keywords:[`terminal`,`tui`,`cli`,`multiplexer`,`ai-agents`,`coding-agent`,`ai-coding-assistant`,`agentic-ai`,`parallel-agents`,`git-worktree`,`claude-code`,`codex`,`llm`,`developer-tools`],type:`module`,packageManager:`bun@1.3.13`,bin:{rove:`dist/cli/rove.js`},files:[`dist/cli`,`dist/completions`,`dist/web`,`dist/web-ui`,`dist/skills`,`dist/*.wav`,`README.md`,`LICENSE`],publishConfig:{access:`public`},repository:{type:`git`,url:`git+https://github.com/Sma1lboy/rove.git`},homepage:`https://rove.run`,bugs:{url:`https://github.com/Sma1lboy/rove/issues`},engines:{bun:`>=1.3.11`},scripts:{dev:`ROVE_DEV=1 bun --conditions=browser ./src/cli/rove.ts`,"dev:mock":`ROVE_DEV=1 bun ./src/tui-react/mock/host.tsx`,"dev:sandbox":`bun run scripts/dev-sandbox.ts run`,"dev:sandbox:reset":`bun run scripts/dev-sandbox.ts reset`,build:`bun run scripts/build.ts`,"build:rubric":`bun run scripts/build-tier-rubric.ts`,compile:`bun run scripts/compile.ts`,typecheck:`tsc --noEmit`,"check-i18n":`bun run scripts/check-i18n.ts`,test:`bun run test:fast && bun run test:socket`,"perf:golden":`bun scripts/perf-golden.ts`,"pty:soak":`bun scripts/pty-soak.ts`,"test:fast":`vitest run --passWithNoTests --minWorkers=1 --maxWorkers=8`,"test:socket":`ROVE_INCLUDE_SOCKET=1 vitest run test/daemon --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests`,"test:socket:coverage":`ROVE_INCLUDE_SOCKET=1 ROVE_COVERAGE_DAEMON=1 vitest run test/daemon --coverage --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests`,"test:behavior":`ROVE_INCLUDE_BEHAVIOR=1 vitest run test/behavior --pool forks --minWorkers=1 --maxWorkers=1 --retry=2 --passWithNoTests`,"test:render":`bun scripts/render-track.mjs`,coverage:`vitest run --coverage --passWithNoTests`,bench:`vitest bench --run`,lint:`biome check .`,knip:`knip-bun`,postinstall:`bun run scripts/check-preview-deps.ts || true`,prepublishOnly:`bun run typecheck && bun run build`,"plugin-sandbox":`bun run scripts/plugin-sandbox.ts`},"//":`biome.json + bunfig.toml live at the monorepo root since they apply repo-wide; bun.lock also lives at root (workspace-shared).`,dependencies:{"@ansi-tools/parser":`^1.0.15`,"@opentui/core":`0.4.3`,"@opentui/react":`0.4.3`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/addon-unicode11":`^0.9.0`,"@xterm/headless":`^6.0.0`,react:`^19.2.8`,"smol-toml":`^1.7.1`,ws:`^8.21.3`},optionalDependencies:{"node-pty":`^1.1.0`},devDependencies:{"@biomejs/biome":`1.9.4`,"@sma1lboy/rove-daemon":`0.7.23`,"@tsconfig/bun":`1.0.11`,"@types/bun":`1.3.14`,"@types/node":`25.6.2`,"@types/react":`^19.2.0`,"@vitest/coverage-v8":`2.1.9`,knip:`^6.14.2`,"react-devtools-core":`^7.0.1`,"rove-bridge":`0.0.37`,"rove-weixin":`0.0.37`,typescript:`5.8.2`,vitest:`2.1.9`},trustedDependencies:[]};tA.version,tA.name;var nA=[`latest`,`next`,`nightly`],rA={autoRouting:{title:`Auto routing`,hint:"Routing by depth: a task says how deep the work is — swift, standard, deep — and this table says which engine, model and reasoning effort that depth runs on. Pick a depth in the new-task dialog (or `rove api add --tier`) and Rove fills those three fields from the row; you still see them and can change them before the task starts. enter (or click) a row to point it somewhere else, with the same picker a task uses. A row whose target cannot start says why here, not at launch.",unconfigured:`Auto routing is off: a depth has nowhere to route — its engine is blank. Point it somewhere below, or remove the empty autoRouting.<tier>.engine from state.json.`,engineDefault:`engine default`,ready:`● ready`,unavailable:`! unavailable — {reason}`,classifierTitle:`Classifier`,classifierHint:"The rows above say what each depth RUNS. This says who CHOOSES one: switch it on and `rove api add --tier auto` reads the task's first message and picks the depth for you. It is off by default, it is never required, and it can never fail a create — no key, no network, a timeout, or an answer it is not confident enough about all leave you on the depth you would have had.",classifierDataFlow:"! Turning the classifier on sends the task's first message to a third party that is NOT the engine vendor you picked — TypeSafe System One for `jev`, or whatever address you point `custom` at. It reads the text before your engine does. Nothing leaves this machine while it is off.",classifierLabel:`Choose with`,classifierOff:`off`,classifierCustomLabel:`custom`,classifierOffHint:`— nothing is sent anywhere`,classifierJevHint:`— TypeSafe System One, billed to your own key`,classifierCustomHint:`— your endpoint: POST the text, answer with a depth and a confidence`,endpointLabel:`Endpoint`,endpointUnset:`(none — enter one, then set Choose with to custom)`,endpointTitle:`Custom classifier endpoint`,endpointField:`URL`,endpointInvalidTitle:`Not a URL`,endpointInvalidBody:`The endpoint has to start with https://, or http:// for a loopback address (127.0.0.1, localhost, ::1) — over a network, plain http would carry the task's first 1,200 characters in cleartext. Leave it empty to clear it.`,thresholdLabel:`Confidence floor`,thresholdHint:`— below this, the depth is left alone`,thresholdTitle:`Confidence floor`,thresholdField:`0 to 1`,thresholdInvalidTitle:`Not a confidence`,thresholdInvalidBody:`The floor is a number between 0 and 1. 0.5 is the shipped default.`,keyLabel:`API key`,keyStored:`stored {hint} — enter to replace, empty to clear`,keyFromEnv:"from ${env} — the environment wins over a stored key",keyNone:`not set — enter to paste one`,keyTitle:`{env}`,keyPlaceholder:`paste the key; leave empty to clear the stored one`,keySaved:`● key stored in ~/.rove/secrets.json (owner-only, never in state.json)`,keyCustomUnused:`● no Authorization header is sent to a custom endpoint — set autoRouting.classifierCustomKeyEnv to the variable holding its key if it needs one`,keyNoVariableTitle:`No key variable for this endpoint`,keyNoVariableBody:`A custom classifier endpoint is sent no Authorization header until autoRouting.classifierCustomKeyEnv names the variable its key lives in. Set that first — a key stored under a name nothing reads is a key at rest for no purpose.`,keyWriteFailedTitle:`Key not saved`,keyWriteFailedBody:`~/.rove/secrets.json could not be written: {reason}. Check directory permissions and disk space, then save again.`,keyMissing:`! no key — nothing is chosen and tasks keep their usual depth`,keyPresentEnv:"● key read from ${env} in this process's environment"}},iA={autoRouting:{title:`自动路由`,hint:"按深度路由:任务说明这活有多深——轻快、标准、深入——这张表说明那一档跑在哪个引擎、哪个模型、哪个推理强度上。在新建任务对话框里选一档(或 `rove api add --tier`),Rove 就照那一行填进这三个字段;任务启动前你仍然看得见、改得了。enter(或点击)某一行,用和任务一样的选择器把它指到别处。目标起不来的行会在这里说明原因,而不是等到启动时才炸。",unconfigured:`自动路由已关闭:有一档无处可去——它的引擎是空的。在下面把它指到某个引擎,或从 state.json 里删掉空的 autoRouting.<tier>.engine。`,engineDefault:`引擎默认`,ready:`● 可用`,unavailable:`! 不可用——{reason}`,classifierTitle:`分类器`,classifierHint:"上面几行说的是每一档**跑什么**,这里决定**由谁来选**:打开之后,`rove api add --tier auto` 会读任务的第一句话替你选档。默认关着,从来不是必需的,也永远不会让建 task 失败——没 key、断网、超时、或者它自己没把握,都只是让你停在本来就会用的那一档上。",classifierDataFlow:"! 打开分类器,任务的第一句话会发给一个**不是你选的那个引擎厂商**的第三方——`jev` 是 TypeSafe System One,`custom` 是你自己填的地址。它比你的引擎更早读到这段文字。关着的时候什么都不发。",classifierLabel:`选档方式`,classifierOff:`关`,classifierCustomLabel:`自定义`,classifierOffHint:`——不向任何地方发送`,classifierJevHint:`——TypeSafe System One,走你自己的 key 计费`,classifierCustomHint:`——你自己的接口:POST 那段文本,返回一个档位加一个置信度`,endpointLabel:`接口地址`,endpointUnset:`(未填——先填一个,再把「选档方式」切到自定义)`,endpointTitle:`自定义分类器接口`,endpointField:`URL`,endpointInvalidTitle:`不是一个 URL`,endpointInvalidBody:`接口地址要以 https:// 开头;http:// 只在回环地址(127.0.0.1、localhost、::1)上接受——发到网络上的话,明文 http 会把任务的前 1200 个字符原样带走。留空则清除。`,thresholdLabel:`置信度下限`,thresholdHint:`——低于这个值就不动档位`,thresholdTitle:`置信度下限`,thresholdField:`0 到 1`,thresholdInvalidTitle:`不是一个置信度`,thresholdInvalidBody:`下限是 0 到 1 之间的数。出厂默认 0.5。`,keyLabel:`API key`,keyStored:`已存 {hint}——enter 可替换,留空清除`,keyFromEnv:"来自环境变量 ${env}——环境变量优先于存起来的那个",keyNone:`未设置——enter 粘贴一个`,keyTitle:`{env}`,keyPlaceholder:`粘贴 key;留空则清除已存的那个`,keySaved:`● key 存在 ~/.rove/secrets.json(仅本人可读,不会进 state.json)`,keyCustomUnused:`● 自定义接口不会收到 Authorization 头——它若需要凭据,把 autoRouting.classifierCustomKeyEnv 指向存它的变量`,keyNoVariableTitle:`这个接口还没有 key 变量`,keyNoVariableBody:`在 autoRouting.classifierCustomKeyEnv 指定存 key 的变量之前,自定义分类器接口不会收到任何 Authorization 头。先设那个——存在一个没人读的名字下面的 key,只是白白落在盘上。`,keyWriteFailedTitle:`key 没存下`,keyWriteFailedBody:`写不了 ~/.rove/secrets.json:{reason}。请检查目录权限和磁盘空间,再次保存。`,keyMissing:`! 没有 key——不会替你选档,任务保持原来的档位`,keyPresentEnv:"● key 来自本进程环境变量 ${env}"}},aA={dev:{reset:`Reset UI state`,resetHint:`Clears ~/.config/rove/state.json and ~/.rove/tasks.json, then quits Rove — relaunch to start fresh. Working session list, pane sizes, theme, model picks all reset. Worktrees on disk and engine session history are not touched.`,resetButton:`[enter] Reset`,restart:`Restart backend`,restartHint:`Stops the Rove daemon and relaunches this window on the installed build — picks up daemon / orchestrator / engine edits without quitting by hand. Running engine sessions live in the PTY host and survive it; other attached Rove windows reconnect on their own.`,restartButton:`[enter] Restart`,reload:`Reload settings`,reloadHint:"Applies hand edits to ~/.config/rove/state.json (from `rove config`) to this window without a restart.",reloadButton:`[enter] Reload`,reloadDone:`Reloaded: {count} changed.`,reloadUnchanged:`Already matches state.json; nothing changed.`,reloadFailed:`state.json could not be read, nothing changed: {error}`,doctorHint:"Daemon wedged or unresponsive? Restart backend above does it from here; from a shell it is `rove daemon restart`. Hosted engine sessions stay alive across a daemon restart.",experimental:`Experimental`,remoteHint:"Remote projects (SSH): register a project whose git worktrees live on another host, driven from this local Rove. Unfinished — Hosted PTY engine launch over SSH is not implemented, and file/diff panes still degrade. Enables `rove add --remote`.",remote:`Remote projects`,autoStatusHint:`Auto status flow: a backlog task moves to in_progress when its engine starts a turn, and new sessions get a system-prompt note telling the agent to set in_review itself when the work is done. Never touches done/canceled.`,autoStatus:`Auto status flow`,dispatcherHint:"Field-notes dispatcher: task sessions file one-line gotchas (`rove api note`), the daemon forwards each to the repo's main session, and that session relays them to the in-flight tasks that benefit (`rove api dispatch`). Web-hosted sessions receive the relays today.",dispatcher:`Field-notes dispatcher`}},oA={dev:{reset:`重置 UI 状态`,resetHint:`清空 ~/.config/rove/state.json 和 ~/.rove/tasks.json,然后退出 Rove——重新启动即可从头开始。工作会话列表、面板尺寸、主题、模型选择都会重置。磁盘上的 worktree 和引擎会话历史不受影响。`,resetButton:`[enter] 重置`,restart:`重启后端`,restartHint:`停止 Rove daemon,并以已安装的版本重新启动当前窗口——无需手动退出即可应用 daemon / orchestrator / engine 的改动。正在运行的引擎会话由 PTY host 托管,不受影响;其他已连接的 Rove 窗口会自行重连。`,restartButton:`[enter] 重启`,reload:`重新加载设置`,reloadHint:"把对 ~/.config/rove/state.json 的手动修改(来自 `rove config`)应用到当前窗口,无需重启。",reloadButton:`[enter] 重新加载`,reloadDone:`已重新加载:{count} 项有变化。`,reloadUnchanged:`已与 state.json 一致,没有变化。`,reloadFailed:`无法读取 state.json,未做任何改动:{error}`,doctorHint:"daemon 卡住或无响应?上面的「重启后端」就能在这里完成;在 shell 里则是 `rove daemon restart`。Hosted PTY 引擎会话不会因 daemon 重启而退出。",experimental:`实验性`,remoteHint:"远程项目(SSH):注册一个 git worktree + 引擎都通过 SSH 跑在另一台主机上、由本地 Rove 驱动的项目。尚未完成——文件/diff 面板对远程仍会降级。启用 `rove add --remote`。",remote:`远程项目`,autoStatusHint:`自动状态流转:backlog 任务在其引擎开始一轮时移到 in_progress,新会话会拿到一条系统提示,告诉 agent 完成后自行设为 in_review。绝不触碰 done/canceled。`,autoStatus:`自动状态流转`,dispatcherHint:"现场笔记调度器:任务会话提交一行经验(`rove api note`),daemon 将每条转发给仓库的主会话,主会话再把它们转达给能受益的进行中任务(`rove api dispatch`)。目前由 Web 托管的会话会收到转达。",dispatcher:`现场笔记调度器`}},sA={engines:{title:`Engines`,hint:`Engines Rove can start on this machine. New tasks start with the default engine; switch an engine off to stop offering it.`,keys:`space available · d default · enter launch command · r rename · x reset/remove`,customTag:`custom`,available:`available`,off:`off`,defaultMark:`default`,makeDefault:`Make default`,status:{checking:`Checking…`,unknown:`Status unknown`,ready:`Ready`,notInstalled:`Not installed`,notOnPath:`Not on PATH`,signIn:`Sign in needed`,integrationMissing:`Integration not installed`,integrationOutdated:`Integration outdated`,integrationBlocked:`Integration blocked`},detail:{program:`Program`,command:`Command`,signIn:`Sign-in`,reporting:`Live status`,adapter:`Adapter`,programFound:`{binary} found at {path}.`,programMissing:`{binary} is not on PATH. Install the engine's CLI, or point its launch command at it.`,programUnknown:`Rove could not check for {binary}.`,commandDefault:`{command} (the default)`,commandCustom:`{command} (yours)`,signedIn:`Signed in.`,signedInAs:`Signed in as {who}.`,apiKey:`An API key is configured.`,token:`A token is configured ({source}).`,signedOut:`Not signed in. Sign in with the engine's own CLI.`,signInUnknown:`Rove can't see whether this engine is signed in.`,signInFailed:`Sign-in check failed: {error}`,hooksInstalled:`Rove's hooks are installed, so tabs report their state as it changes.`,hooksOutdated:`Rove's hooks are from an older version; reinstall them under Engine integrations.`,hooksMissing:`Rove's hooks are not installed; install them under Engine integrations.`,hooksAwaitEngine:`Rove's hooks can be installed once the engine is.`,hooksUnsupported:`This engine has no hooks for Rove to install.`,hooksBlocked:`Rove can't write its hooks into {file}: {reason}`,hooksBlockedHere:`Rove can't write its hooks into the engine's config: {reason}`,markersYes:`It leaves turn-complete markers that Rove reads back.`,markersNo:`It leaves no turn-complete markers.`,screenYes:`Screen rules cover what the hooks don't.`,screenNo:`No screen rules.`,screenNotNeeded:`No screen rules; the hooks report everything.`,adapterDeclared:`Borrows the {protocol} adapter.`,adapterGeneric:`Generic adapter: no transcript reader, sign-in check or resume.`,skill:`Rove skill`,skillInstalled:`Installed in {dir}.`,skillInstalledHere:`Installed and current.`,skillOutdated:`From an older Rove; reinstall it under Rove agent skill.`,skillMissing:`Not installed; install it under Rove agent skill.`},skill:{title:`Rove agent skill`,hint:`Teaches the agent in each engine to drive Rove itself (rove api): start tasks, read other sessions, message them.`,install:`Install ({count})`,noEngines:`No engine here takes the skill`,failed:`Install failed: {reason}`,bannerTitle:`ROVE SKILL NOT INSTALLED`,bannerHint:`{engines} can't drive Rove yet (start tasks, read other sessions). Click here to install.`,bannerHintWeb:`{engines} can't drive Rove yet (start tasks, read other sessions).`},integrations:{title:`Engine integrations`,hint:`Hooks Rove writes into each engine's own config, so a tab shows working, waiting or done the moment it happens.`,summary:`{installed} of {total} installed`,install:`Install missing ({count})`,upToDate:`All up to date`,remove:`Remove all ({count})`,noneInstalled:`Nothing to remove`},addEngine:`+ Add engine`,launchCommandTitle:`{name} launch command`,displayNameTitle:`{name} display name (blank = default)`,addTitle:`Add engine`,addStepTitle:`Add engine · {id}`,protocolTitle:`Add engine · {id} — protocol`,protocolNone:`None — generic adapter`,protocolFooter:`↑↓ choose · enter pick · esc cancel`,protocolRow:`protocol {protocol}`,protocolGeneric:`generic`,idPlaceholder:`lowercase slug, e.g. aider`,commandPlaceholder:`e.g. aider --model sonnet`,hookTrustHint:`Open {command} in the engine and approve hooks yourself. Written hooks are not proof of trust.`,readiness:`CLI: {cli} · login: {login} · hooks: {hooks}`,cliReady:`available`,cliMissing:`missing; install the engine CLI`,loginReady:`detected`,loginMissing:`sign in with the engine CLI`,readinessUnknown:`not observable`,hooksWritten:`written`,hooksMissing:`not written; Settings → Engines`,hooksOutdated:`outdated; Settings → Engines`,hookWaiting:`No hook event received yet. After approval, send a short prompt to verify activity.`,hookReceived:`Hook event recorded for this tab. Send a short prompt to check current reporting; current trust is not inferred.`,readinessFailed:`Readiness check unavailable; run rove doctor. No authorization is inferred.`},accounts:{checking:`Checking…`,notLoggedIn:`○ Not logged in`,loggedIn:`● Logged in: {email}`,apiKeyConfigured:`● API key configured`,chatgptLogin:`● ChatGPT login: {email}`,tokenConfigured:`● Token configured ({source})`,detected:`● Login detected`}},cA={engines:{title:`引擎`,hint:`Rove 能在这台机器上启动的引擎。新任务默认用「默认」引擎;关掉某个引擎,选引擎时就不再列出它。`,keys:`space 可用 · d 设为默认 · enter 启动命令 · r 重命名 · x 重置/移除`,customTag:`自定义`,available:`可用`,off:`已关`,defaultMark:`默认`,makeDefault:`设为默认`,status:{checking:`检查中…`,unknown:`状态未知`,ready:`就绪`,notInstalled:`未安装`,notOnPath:`不在 PATH 上`,signIn:`需要登录`,integrationMissing:`未安装接入`,integrationOutdated:`接入已过期`,integrationBlocked:`接入被拒绝`},detail:{program:`程序`,command:`命令`,signIn:`登录`,reporting:`实时状态`,adapter:`适配器`,programFound:`{binary} 位于 {path}。`,programMissing:`{binary} 不在 PATH 上。请安装引擎 CLI,或把启动命令指向它。`,programUnknown:`Rove 无法检查 {binary}。`,commandDefault:`{command}(默认)`,commandCustom:`{command}(自定义)`,signedIn:`已登录。`,signedInAs:`已登录:{who}。`,apiKey:`已配置 API key。`,token:`已配置 Token({source})。`,signedOut:`未登录。请用引擎自己的命令行登录。`,signInUnknown:`Rove 无法得知该引擎是否已登录。`,signInFailed:`登录检查失败:{error}`,hooksInstalled:`Rove 的钩子已安装,标签页的状态会实时上报。`,hooksOutdated:`Rove 的钩子来自旧版本;请在「引擎接入」里重新安装。`,hooksMissing:`Rove 的钩子未安装;请在「引擎接入」里安装。`,hooksAwaitEngine:`引擎安装后才能装 Rove 的钩子。`,hooksUnsupported:`该引擎没有可供 Rove 安装的钩子。`,hooksBlocked:`Rove 无法把钩子写入 {file}:{reason}`,hooksBlockedHere:`Rove 无法把钩子写入引擎配置:{reason}`,markersYes:`它会留下回合完成标记,Rove 可以读回。`,markersNo:`它不留下回合完成标记。`,screenYes:`读屏规则兜底钩子覆盖不到的状态。`,screenNo:`没有读屏规则。`,screenNotNeeded:`没有读屏规则;钩子已报全所有状态。`,adapterDeclared:`借用 {protocol} 适配器。`,adapterGeneric:`通用适配器:没有会话记录读取、登录检查和恢复。`,skill:`Rove 技能`,skillInstalled:`已安装在 {dir}。`,skillInstalledHere:`已安装,是最新版。`,skillOutdated:`来自旧版 Rove;请在「Rove 智能体技能」里重新安装。`,skillMissing:`未安装;请在「Rove 智能体技能」里安装。`},skill:{title:`Rove 智能体技能`,hint:`教会各引擎里的智能体自己操作 Rove(rove api):开任务、读其他会话、给它们发消息。`,install:`安装({count})`,noEngines:`这台机器上没有能装技能的引擎`,failed:`安装失败:{reason}`,bannerTitle:`ROVE 技能未安装`,bannerHint:`{engines} 还不能操作 Rove(开任务、读其他会话)。点这里安装。`,bannerHintWeb:`{engines} 还不能操作 Rove(开任务、读其他会话)。`},integrations:{title:`引擎接入`,hint:`Rove 写进各引擎自身配置的钩子,让标签页在工作、等待、完成的那一刻就显示出来。`,summary:`已安装 {installed}/{total}`,install:`安装缺失的({count})`,upToDate:`全部已是最新`,remove:`全部移除({count})`,noneInstalled:`没有可移除的`},addEngine:`+ 添加引擎`,launchCommandTitle:`{name} 的启动命令`,displayNameTitle:`{name} 的显示名称(留空 = 默认)`,addTitle:`添加引擎`,addStepTitle:`添加引擎 · {id}`,protocolTitle:`添加引擎 · {id} —— 协议`,protocolNone:`无 —— 通用适配器`,protocolFooter:`↑↓ 选择 · enter 确认 · esc 取消`,protocolRow:`协议 {protocol}`,protocolGeneric:`通用`,idPlaceholder:`小写短名,如 aider`,commandPlaceholder:`如 aider --model sonnet`,hookTrustHint:`在引擎中打开 {command},由你自行批准 hooks。写入不代表已授权。`,readiness:`CLI:{cli} · 登录:{login} · hooks:{hooks}`,cliReady:`可用`,cliMissing:`缺失;请安装引擎 CLI`,loginReady:`已检测到`,loginMissing:`请通过引擎 CLI 登录`,readinessUnknown:`无法观测`,hooksWritten:`已写入`,hooksMissing:`未写入;设置 → 引擎`,hooksOutdated:`已过时;设置 → 引擎`,hookWaiting:`尚未收到 hook 事件。授权后发送一条简短提示,验证活动状态。`,hookReceived:`已记录此标签页的 hook 事件。发送简短提示以检查当前上报;不据此推断当前授权。`,readinessFailed:`无法检查就绪状态;请运行 rove doctor。不会据此推断已授权。`},accounts:{checking:`检查中…`,notLoggedIn:`○ 未登录`,loggedIn:`● 已登录: {email}`,apiKeyConfigured:`● 已配置 API key`,chatgptLogin:`● ChatGPT 登录: {email}`,tokenConfigured:`● 已配置 Token ({source})`,detected:`● 检测到登录`}},lA={plugins:{title:`Plugins`,hint:"Rove's first-party mods first: enter (or click) installs or uninstalls one, and uninstalling keeps its data on disk. Then the plugins registered in ~/.rove/plugins.json: enter toggles one on or off — the daemon watches the file, so the change applies live. Rows indented under a plugin are the settings it declares; enter edits one, and the value reaches the plugin on its next run. Install and remove them from the shell: `rove plugin install <owner/repo>`, `rove plugin link <dir>`.",empty:"Kanban and Issues are first-party mods: enter (or click) installs one. No other plugins registered; add one with `rove plugin install <owner/repo>` — browse the `rove-plugin` topic on GitHub.",sourceLink:`linked {path}`,sourceGithub:`{spec}`,sourceBuiltIn:`first-party mod · not installed`,sourceBuiltInInstalled:`first-party mod · installed`,updateAvailable:`update available — rove plugin update`,declares:`{actions} actions · {events} events · {panes} panes`,declaresWithEngines:`{actions} actions · {events} events · {panes} panes · {engines} engines`,declaresPages:`· {pages} pages`,pageFailed:`page {detail}`,manifestUnreadable:`manifest unreadable; check the rove-plugin.toml path and TOML syntax`,unsupportedPlatform:`· not supported on this platform`,noHooks:`· no hooks declared`,lastRun:`· last run {label} {status} {ago} ago`,neverRun:`· never run`,runOk:`ok`,runRunning:`still running`,runFailed:"failed to start; inspect `rove plugin log <id>`",runExit:`exit {code}`,settingUnset:`(unset — enter to edit)`,settingInvalidTitle:`Not a number`,settingInvalidBody:`{label} only accepts a number. Keeping the previous value.`},marketplace:{title:`Marketplace`,hint:"Plugins published under the `rove-plugin` topic on GitHub, most-starred first. enter (or click) shows what the install would run and asks before running any of it. The listing is re-queried each time you open this section.",loading:`Searching GitHub…`,empty:`No plugins listed.`,offline:`GitHub is unreachable — showing first-party plugins only. Re-open this section to retry.`,installedTag:`installed`,firstParty:`first-party`,preparing:`cloning {ref}…`,installing:`building and registering {name}…`,installed:`installed {id} v{version} — it is enabled, and appears under Plugins.`,cancelled:`install cancelled; nothing was run.`,failed:`install failed: {error}. Check the build output and retry from Marketplace.`,alreadyInstalled:`already installed as {id} — manage it under Plugins.`,confirmTitle:`Install {name}?`,confirmInstall:`install`,previewSource:`source: {source}`,previewCommands:`Commands this plugin declares:`,previewNoCommands:`This plugin declares no commands.`,previewWarning:`warning: {warning}`,previewTrust:`Installing runs the build commands above, and the rest run later on the events they declare. They run as you, with your environment, and nothing is sandboxed.`}},uA={plugins:{title:`插件`,hint:"先列 Rove 官方 mod:enter(或点击)安装或卸载,卸载后数据仍留在磁盘上。再列在 ~/.rove/plugins.json 里注册的插件:enter 切换启用/禁用——daemon 监听该文件,改动实时生效。插件下方缩进的行是它声明的设置项,enter 编辑,新值在插件下次运行时生效。安装与移除在 shell 里做:`rove plugin install <owner/repo>`、`rove plugin link <dir>`。",empty:"Kanban 和 Issues 是官方 mod:enter(或点击)安装。尚未注册其他插件;用 `rove plugin install <owner/repo>` 安装一个——可在 GitHub 的 `rove-plugin` 话题下浏览。",sourceLink:`本地链接 {path}`,sourceGithub:`{spec}`,sourceBuiltIn:`官方 mod · 未安装`,sourceBuiltInInstalled:`官方 mod · 已安装`,updateAvailable:`有新版本 — rove plugin update`,declares:`{actions} 个动作 · {events} 个事件 · {panes} 个面板`,declaresWithEngines:`{actions} 个动作 · {events} 个事件 · {panes} 个面板 · {engines} 个引擎`,declaresPages:`· {pages} 个页面`,pageFailed:`页面 {detail}`,manifestUnreadable:`manifest 无法解析;请检查rove-plugin.toml 的路径和 TOML 语法`,unsupportedPlatform:`· 不支持当前平台`,noHooks:`· 未声明钩子`,lastRun:`· 上次运行 {label} {status} {ago}前`,neverRun:`· 尚未运行过`,runOk:`成功`,runRunning:`仍在运行`,runFailed:"启动失败;请查看 `rove plugin log <id>`",runExit:`退出码 {code}`,settingUnset:`(未设置 — enter 编辑)`,settingInvalidTitle:`不是数字`,settingInvalidBody:`{label} 只接受数字,保留原值。`},marketplace:{title:`插件市场`,hint:"GitHub 上 `rove-plugin` 话题下发布的插件,按 star 数排序。enter(或点击)会先列出安装会执行的命令,确认后才真正执行。每次进入本区块都会重新查询列表。",loading:`正在搜索 GitHub…`,empty:`列表为空。`,offline:`GitHub 不可达——只显示首方插件。重新进入本区块可再试一次。`,installedTag:`已安装`,firstParty:`首方`,preparing:`正在克隆 {ref}…`,installing:`正在构建并注册 {name}…`,installed:`已安装 {id} v{version}——已启用,可在「插件」区块管理。`,cancelled:`已取消安装,没有执行任何命令。`,failed:`安装失败:{error}。请检查构建输出,再从插件市场重试。`,alreadyInstalled:`已安装为 {id}——在「插件」区块管理。`,confirmTitle:`安装 {name}?`,confirmInstall:`安装`,previewSource:`来源:{source}`,previewCommands:`该插件声明的命令:`,previewNoCommands:`该插件未声明任何命令。`,previewWarning:`警告:{warning}`,previewTrust:`安装会执行上面的 build 命令,其余命令会在它们声明的事件发生时执行。它们以你的身份、带你的环境变量运行,没有任何沙箱。`}},dA={en:{appearance:{enabled:`On`,disabled:`Off`,borderFlow:`Flowing gradient`,borderStill:`Still`,glyphsBraille:`Braille`,glyphsStarburst:`Starburst (needs a font with the Dingbats block)`,glyphsAscii:`ASCII`,titleShimmer:`Shimmer`,titleStill:`Still`,preview:`Workspace preview`,tasks:`Tasks`,terminal:`Terminal`,files:`Files`,testsPassed:`Tests passed`,transparent:`Transparent background`,opaque:`Opaque background`,modeDark:`Dark`,modeLight:`Light`,modeAuto:`Auto (follow the terminal)`,openHint:`Enter to choose an option and preview it.`,chooseHint:`↑/↓ or j/k preview · enter apply · esc cancel`},title:`Settings`,esc:`esc`,nav:{default:`j/k pick · h/l switch level · enter activate · esc close`,feedback:`tab next field · enter sends on Send · esc close`},sections:{general:`General`,engines:`Engines`,autoRouting:`Auto routing`,plugins:`Plugins`,marketplace:`Marketplace`,keys:`Keybindings`,feedback:`Feedback`,dev:`Dev`},general:{usage:`USAGE`,theme:`Theme`,themeMode:`Mode`,themeHint:`l to enter list · j/k to highlight · enter to apply`,language:`Language`,languageHint:`Display language for Rove's UI. l to enter list · j/k to highlight · enter to apply.`,transparent:`Transparent background`,transparentHint:`Drops the renderer's bg fill so the host terminal shows through. enter toggles.`,on:`[x] on`,off:`[ ] off`,focusAccent:`Focus accent`,focusAccentHint:`Color of focused pane title, ▌ marker, and split borders.`,accentPrimary:`Primary (brand accent)`,accentSuccess:`Success (legacy green)`,accentInfo:`Info (cool blue)`,appearance:`Appearance`,appearanceHint:`How split panes draw.`,splitStyle:`Split panes`,workingBorder:`Working border`,taskColors:`Task colors`,glyphSet:`State glyphs`,colorblind:`Colorblind diff colours`,runningTitle:`Running title`,splitBox:`Box frames`,splitLine:`Divider line`,splitRail:`Accent rail`,splitRule:`Top rule`,notifications:`Notifications`,notificationsHint:`When a background tab finishes or pauses on an approval.`,toast:`Toast`,toastHint:`bottom-right popup`,sound:`Sound`,soundHint:`bell + chime + an OSC 9 desktop notification (rides SSH)`,soundVolume:`Chime volume — {percent}%`,soundVolumeHint:`enter cycles; applies to the next chime`,crossTask:`Cross-task`,crossTaskHint:`also for a task you switched away from`,finishedAlerts:`Finished turns`,finishedAlertsHint:`off: only approvals and errors alert; the unread dot stays`,keyHints:`Keyboard hints`,keyHintsHint:`The status-bar reminder and the first-use hints in the sidebar and files panes.`,keyHintsShow:`Show keyboard hints`,keyHintsShowHint:`re-enabling relights hints dismissed by use`,zen:`Zen mode`,zenHint:"The `zen` chip and `prefix`+z hide Files, keeping the Tasks rail and workspace.",zenDefaultOn:`Start in zen mode`,updates:`Updates`,updatesHint:`Stable is the default channel; next previews the coming release; nightly is built from main every day.`,updateChannelTitle:`Release channel`,updateChannel:`Channel: {channel}`,updateChannelHint:"enter cycles stable / next / nightly; `rove update` follows it",updateChannelName:{latest:`stable`,next:`next preview`,nightly:`nightly preview`},updateNotify:`Notify on updates`,updateNotifyHint:`new versions on this channel; off hides the update chip, and checking by hand still reports`,updateCheck:`[ Check for updates ]`,updateCheckHint:`asks npm for the newest release on this channel right now`,updateCheckButton:`Check for updates`,updateChecking:`Checking…`,updateOpenPage:`Open Update page`,updateOpenPageRow:`[ Open Update page ]`,railFold:`Folded task rail`,railFoldHint:`What the rail shows once folded away from its corner control.`,railFoldRow:`Folded rail shows: {style}`,railFoldRowHint:`enter cycles`,railFoldGlyphs:`status glyphs`,railFoldInitials:`glyph + initials`,railFoldHairline:`colour band only`,editor:`Editor`,editorHint:`What enter opens a file with in the file tree — diff mode when the editor supports it, the read-only preview when it isn't installed.`,editorRow:`editor: < {kind} >`,editorRowHint:`auto follows $VISUAL / $EDITOR, else nvim / vim / emacs / nano`,editorCustom:`custom: {cmd}`,editorCustomUnset:`(unset — enter to edit)`,worktree:`Worktree location`,worktreeHint:`Where new task worktrees are created. New tasks only.`,worktreeBase:`location: < {kind} >`,worktreeBaseHint:"custom takes `~`, a relative path, or a leading `$project_dir`",worktreeKindDefault:`default ~/.rove/worktrees`,worktreeKindNext:`next to project`,worktreeKindCustom:`custom`,worktreeCustom:`custom: {path}`,worktreeCustomUnset:`(unset — enter to edit)`,worktreeBaseTitle:`Custom worktree location (blank = default; $project_dir = project root)`,worktreeBaseField:`PATH`,editorCustomTitle:`Custom editor command (use {file} for the path)`,worktreeBaseInvalidTitle:`Can't use that worktree location`,worktreeBaseTokenBody:`{token} only expands as the leading path segment (e.g. {token}/../rove-worktrees). Keeping the previous setting.`,worktreeBaseUnusableBody:`{path} isn't usable ({error}). Keeping the previous setting — pick a writable directory.`,terminal:`Terminal`,terminalHint:`Applies to terminals opened after the change.`,scrollbackRow:`scrollback: {rows} rows`,scrollbackRowHint:`100–100000 · larger costs proportionally more CPU per redraw`,scrollbackTitle:`Terminal scrollback rows (100–100000)`,scrollbackField:`ROWS`,scrollbackInvalidTitle:`Not a number`,scrollbackInvalidBody:`Scrollback must be a number of rows (e.g. 1000). Keeping the previous setting.`,tabStripRow:`tab strip: {mode}`,tabStripMode:{never:`off — the sidebar tree lists tabs`,multipleOnly:`only with 2+ tabs`,always:`always`}},field:{command:`COMMAND`,name:`NAME`,id:`ID`},action:{save:`save`,next:`next`,add:`add`},reset:{title:`Reset UI state?`,body:`Wipes ~/.config/rove/state.json and ~/.rove/tasks.json, then quits Rove — relaunch for a fresh start with an empty working session list. Worktrees on disk and engine session history are NOT touched.`,done:`Rove: UI state reset. Relaunch Rove to start fresh.`,failedTitle:`UI state was not reset`,failedBody:`Could not write the settings file. Your settings and tasks have been kept. Try resetting again.`},restart:{title:`Restart backend?`,body:`Stops the daemon and relaunches this Rove on the installed build, so daemon / orchestrator / engine edits take effect. Running engine sessions live in the PTY host and keep going; open tabs come back. Any other attached windows reconnect on their own.`,done:`Rove: restarting the backend...`},stateWrite:{failedTitle:`Settings were not saved`,failedBody:`{file} could not be written ({keys}). Check its directory permissions and free disk space, then save again.`},...rA,...sA,...lA,keybindings:{title:`Keybindings`,hint:`Rebind direct and prefix chords in your own YAML file; changes reload live. Press F1 anywhere for the live keymap with every binding id.`,configFile:`Config file`,notCreated:` (not created yet)`,prefixTitle:`Command layer ({prefix})`,prefixHint:`Bare keys act in the focused pane; a small one-press set covers frequent Rove actions; {prefix} opens the command layer ({timeout}ms second-stroke window). Prefix bindings keep their pane scope and modal rules.`,tapPresentation:`Prefix tap`,tapPresentationHint:`Choose whether the complete guide also marks controls already on screen.`,tapPresentationLocal:`On-screen entries + complete guide (default)`,tapPresentationGuide:`Complete guide only`,prefixDisabled:`disabled`,fixed:`Fixed (not rebindable): {ids}.`,createHint:`No overrides file yet. Rove can write one for you, fully commented — nothing is rebound until you uncomment a line.`,createFile:`[enter] Create keybindings.yaml`,overridesApplied:`Overrides applied`,none:`none`,unbound:`(unbound)`,defaultKeys:`default: {keys}`,warnings:`Warnings`},feedback:{title:`Feedback`,hint:"Sends a GitHub Discussion to the Rove repo through `gh`. Requires `gh auth login`; category defaults to Feedback.",titleLabel:`title`,titlePlaceholder:`Short summary`,descriptionLabel:`description`,descriptionPlaceholder:`What happened? (enter for a new line · tab to Send)`,send:`[enter] Send to GitHub Discussions`},...aA},zh:{appearance:{enabled:`开启`,disabled:`关闭`,borderFlow:`流动渐变`,borderStill:`静止`,glyphsBraille:`盲文点`,glyphsStarburst:`星芒(需要含 Dingbats 符号区的字体)`,glyphsAscii:`ASCII`,titleShimmer:`流光`,titleStill:`静止`,preview:`工作区预览`,tasks:`任务`,terminal:`终端`,files:`文件`,testsPassed:`测试通过`,transparent:`透明背景`,opaque:`不透明背景`,modeDark:`深色`,modeLight:`浅色`,modeAuto:`自动(跟随终端)`,openHint:`按 Enter 打开选项和预览。`,chooseHint:`↑/↓ 或 j/k 预览 · enter 应用 · esc 取消`},title:`设置`,esc:`esc`,nav:{default:`j/k 选择 · h/l 切换层级 · enter 确认 · esc 关闭`,feedback:`tab 下一项 · enter 在发送项发送 · esc 关闭`},sections:{general:`通用`,autoRouting:`自动路由`,engines:`引擎`,plugins:`插件`,marketplace:`插件市场`,keys:`快捷键`,feedback:`反馈`,dev:`开发`},general:{usage:`用量`,theme:`主题`,themeMode:`明暗`,themeHint:`l 进入列表 · j/k 高亮 · enter 应用`,language:`语言`,languageHint:`Rove 界面的显示语言。l 进入列表 · j/k 高亮 · enter 应用。`,transparent:`透明背景`,transparentHint:`去掉渲染器的背景填充,让宿主终端透出来。按 enter 切换。`,on:`[x] 开`,off:`[ ] 关`,focusAccent:`聚焦强调色`,focusAccentHint:`聚焦面板标题、▌ 标记和分隔边框的颜色。`,accentPrimary:`主色(品牌强调色)`,accentSuccess:`成功色(传统绿)`,accentInfo:`信息色(冷蓝)`,appearance:`外观`,appearanceHint:`分屏面板怎么画边。`,splitStyle:`分屏面板`,workingBorder:`运行中边框`,taskColors:`任务配色`,glyphSet:`状态符号`,colorblind:`色盲友好的增删配色`,runningTitle:`运行中标题`,splitBox:`方框边框`,splitLine:`单线分隔`,splitRail:`左侧强调条`,splitRule:`顶部横线`,notifications:`通知`,notificationsHint:`后台标签完成或在审批处暂停时触发。`,toast:`Toast 弹窗`,toastHint:`右下角弹窗`,sound:`声音`,soundHint:`响铃 + 提示音 + OSC 9 桌面通知(经 SSH 直达本地)`,soundVolume:`提示音音量 — {percent}%`,soundVolumeHint:`回车循环切换;下一声提示音生效`,crossTask:`跨任务`,crossTaskHint:`你已切走的任务也通知`,finishedAlerts:`回合完成`,finishedAlertsHint:`关闭后只有审批和错误会提醒;未读标记照常`,keyHints:`键盘提示`,keyHintsHint:`状态栏提醒,以及侧栏和文件面板的首用提示。`,keyHintsShow:`显示键盘提示`,keyHintsShowHint:`重新开启会点亮已因使用而熄灭的提示`,zen:`禅模式`,zenHint:"`zen` 标记和 `prefix`+z 隐藏 Files,保留 Tasks 侧栏与 workspace。",zenDefaultOn:`启动即进入禅模式`,updates:`更新`,updatesHint:`稳定版是默认渠道;next 预览即将发布的版本;nightly 每天从 main 自动构建。`,updateChannelTitle:`发布渠道`,updateChannel:`渠道:{channel}`,updateChannelHint:"enter 在稳定版 / next / nightly 间切换;`rove update` 跟随它",updateChannelName:{latest:`稳定版`,next:`next 预览版`,nightly:`nightly 预览版`},updateNotify:`有新版本时通知我`,updateNotifyHint:`只针对所选渠道;关闭后不再显示更新标记,手动检查仍会给出结果`,updateCheck:`[ 检查更新 ]`,updateCheckHint:`立即向 npm 查询所选渠道的最新版本`,updateCheckButton:`检查更新`,updateChecking:`检查中…`,updateOpenPage:`打开更新页`,updateOpenPageRow:`[ 打开更新页 ]`,railFold:`折叠后的任务栏`,railFoldHint:`任务栏从角标折叠之后显示什么。`,railFoldRow:`折叠后显示:{style}`,railFoldRowHint:`enter 切换`,railFoldGlyphs:`状态字形`,railFoldInitials:`字形 + 首字母`,railFoldHairline:`仅色带`,editor:`编辑器`,editorHint:`文件树里按 enter 用什么打开文件——支持时走编辑器 diff 模式,未安装时回退到只读预览。`,editorRow:`编辑器: < {kind} >`,editorRowHint:`auto 跟随 $VISUAL / $EDITOR,否则 nvim / vim / emacs / nano`,editorCustom:`自定义: {cmd}`,editorCustomUnset:`(未设置 — enter 编辑)`,worktree:`工作树位置`,worktreeHint:`新任务工作树的创建位置。仅对新任务生效。`,worktreeBase:`位置: < {kind} >`,worktreeBaseHint:"自定义可填 `~`、相对路径或以 `$project_dir` 开头",worktreeKindDefault:`默认 ~/.rove/worktrees`,worktreeKindNext:`项目旁边`,worktreeKindCustom:`自定义`,worktreeCustom:`自定义: {path}`,worktreeCustomUnset:`(未设置 — enter 编辑)`,worktreeBaseTitle:`自定义工作树位置(留空 = 默认;$project_dir = 项目根目录)`,worktreeBaseField:`路径`,editorCustomTitle:`自定义编辑器命令(用 {file} 代表文件路径)`,worktreeBaseInvalidTitle:`无法使用该工作树位置`,worktreeBaseTokenBody:`{token} 只能作为路径的第一段展开(如 {token}/../rove-worktrees)。保留原设置。`,worktreeBaseUnusableBody:`{path} 不可用({error})。保留原设置 —— 请选择一个可写目录。`,terminal:`终端`,terminalHint:`对修改后新打开的终端生效。`,scrollbackRow:`回滚行数: {rows} 行`,scrollbackRowHint:`100–100000 · 调大会按比例增加每次重绘的 CPU`,scrollbackTitle:`终端回滚行数(100–100000)`,scrollbackField:`行数`,scrollbackInvalidTitle:`不是数字`,scrollbackInvalidBody:`回滚行数必须是数字(如 1000)。保留原设置。`,tabStripRow:`标签栏: {mode}`,tabStripMode:{never:`关闭 — 标签在左侧树里`,multipleOnly:`仅 2 个以上标签时显示`,always:`始终显示`}},field:{command:`命令`,name:`名称`,id:`标识`},action:{save:`保存`,next:`下一步`,add:`添加`},reset:{title:`重置界面状态?`,body:`将清除 ~/.config/rove/state.json 和 ~/.rove/tasks.json 并退出 Rove —— 重新启动后会是一个干净的开始,工作会话列表为空。磁盘上的工作树和引擎会话历史不受影响。`,done:`Rove:界面状态已重置。重新启动 Rove 即可从头开始。`,failedTitle:`UI 状态未能重置`,failedBody:`无法写入设置文件。设置和任务均已保留,请稍后重新尝试重置。`},restart:{title:`重启后端?`,body:`会停掉 daemon,并以已安装的版本重新启动当前 Rove 窗口,从而让 daemon / orchestrator / 引擎的改动生效。正在运行的引擎会话由 PTY host 托管,不会中断;已打开的标签页会恢复。其他已连接的窗口会自行重连。`,done:`Rove:正在重启后端……`},stateWrite:{failedTitle:`设置未能保存`,failedBody:`{file} 写入失败({keys})。请检查目录权限和磁盘空间,再次保存。`},...iA,...cA,...uA,keybindings:{title:`快捷键`,hint:`在你自己的 YAML 文件里重绑定直接按键和 prefix 组合;修改会实时加载。任意位置按 F1 查看带每个绑定 id 的实时键位表。`,configFile:`配置文件`,notCreated:` (尚未创建)`,prefixTitle:`命令层({prefix})`,prefixHint:`裸键作用于当前聚焦面板;少量单次快捷键覆盖高频 Rove 操作;{prefix} 打开命令层(第二击窗口 {timeout}ms)。Prefix 绑定保持原有的面板作用域和 modal 规则。`,tapPresentation:`点按 Prefix`,tapPresentationHint:`选择完整指南是否同时标记当前屏幕上的入口。`,tapPresentationLocal:`屏幕入口 + 完整指南(默认)`,tapPresentationGuide:`仅完整指南`,prefixDisabled:`已禁用`,fixed:`固定(不可重绑定):{ids}。`,createHint:`还没有覆盖文件。Rove 可以帮你写一份带完整注释的——在你取消注释之前不会改动任何按键。`,createFile:`[enter] 创建 keybindings.yaml`,overridesApplied:`已应用的覆盖`,none:`无`,unbound:`(已解绑)`,defaultKeys:`默认: {keys}`,warnings:`警告`},feedback:{title:`反馈`,hint:"通过 `gh` 向 Rove 仓库发一条 GitHub Discussion。需要 `gh auth login`;分类默认为 Feedback。",titleLabel:`标题`,titlePlaceholder:`简短概括`,descriptionLabel:`描述`,descriptionPlaceholder:`发生了什么?(enter 换行 · tab 跳到发送)`,send:`[enter] 发送到 GitHub Discussions`},...oA}},fA={en:Er,zh:Dr};function $(e,t){return De(dA,e,t)}function pA(e,t){return De(fA,e,t)}function mA({label:e,value:t,picks:n,onPick:r}){return(0,V.jsx)(`fieldset`,{"aria-label":e,className:`m-0 inline-flex min-w-0 flex-wrap gap-0.5 rounded-sm border-hairline border-line bg-inset p-0.5`,children:n.map(e=>{let n=e.value===t;return(0,V.jsx)(`button`,{type:`button`,"aria-pressed":n,className:ke(`rounded-xs px-2.5 py-1 font-sans text-meta whitespace-nowrap touch:min-h-9`,`focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-focus`,n?`bg-menu text-ink`:`text-muted hover:bg-hover`),onClick:()=>!n&&r(e.value),children:e.label},e.value)})})}function hA({label:e,value:t,picks:n,onPick:r}){return(0,V.jsxs)(`span`,{className:`relative inline-flex max-w-full min-w-0 text-ink`,children:[(0,V.jsx)(`select`,{"aria-label":e,value:t,className:`max-w-full min-w-0 truncate rounded-sm border-hairline border-line bg-paper py-1.25 pr-7 pl-2.5 font-sans text-meta hover:border-line-active focus-visible:border-line-active focus-visible:outline-none touch:min-h-10`,onChange:e=>{let t=n.find(t=>String(t.value)===e.target.value);t&&r(t.value)},children:n.map(e=>(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,V.jsx)(Ma,{className:`pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 text-subtle`})]})}var gA=`${kn} w-narrow:pt-0`,_A=`dialog relative m-0 flex h-[min(640px,80vh)] w-[min(880px,calc(100vw-32px))] overflow-hidden rounded-md border-hairline border-line bg-surface text-inherit shadow-dialog focus:outline-none motion-safe:animate-rise-in [.is-leaving_&]:animate-sink-out w-narrow:h-dvh w-narrow:w-screen w-narrow:flex-col w-narrow:rounded-none w-narrow:border-0 short:h-[calc(100dvh-24px)]`,vA=`absolute top-3 right-3 z-1 grid size-7 place-items-center rounded-sm text-display leading-none text-muted hover:bg-inset hover:text-ink focus-visible:bg-inset focus-visible:text-ink touch:size-10`,yA=`flex w-56 flex-none flex-col gap-5 overflow-y-auto scrollbar-none [border-right:var(--hairline)_solid_var(--line)] px-2.5 py-4 w-narrow:w-full w-narrow:flex-1 w-narrow:[border-right:none] w-narrow:px-3 w-narrow:py-3`,bA=`m-0 px-2 pb-0.5 font-sans text-title font-semibold normal-nums text-ink`,xA=`flex flex-col gap-0.5`,SA=`m-0 px-2 pb-1 font-mono text-meta font-normal text-subtle`,CA=(e,t)=>`flex items-center rounded-sm px-2 py-1.25 text-left font-sans text-body touch:min-h-10 w-narrow:min-h-11 w-narrow:px-3 ${e?`bg-menu text-ink`:`${t?`text-muted`:`text-ink`} [&:hover]:bg-hover`}`,wA=`ml-auto hidden text-subtle w-narrow:block`,TA=`flex flex-col`,EA=`m-0 pb-2 text-meta text-subtle`,DA=`flex flex-col border-t-hairline border-t-line [&>*]:border-b-hairline [&>*]:border-b-line`,OA=`flex items-center justify-between gap-x-6 gap-y-2 py-3 w-narrow:flex-col w-narrow:items-stretch`,kA=`flex items-center justify-between gap-x-6 py-3`,AA=`flex flex-col gap-3 py-3`,jA=`flex min-w-0 flex-1 flex-col gap-0.5`,MA=`text-body text-ink`,NA=`text-meta text-muted [&_a]:text-accent`,PA=`max-w-90 min-w-0 truncate font-mono text-meta text-muted [overflow-wrap:anywhere]`,FA=`m-0 py-3 text-body text-muted`,IA=`rounded-sm border-hairline border-line bg-paper px-2.5 py-1.5 font-sans text-body text-ink focus-visible:border-line-active focus-visible:outline-none`,LA=`${IA} w-24 text-right`,RA=`flex flex-col gap-1.5`,zA=`text-meta font-medium text-muted`,BA=`min-h-30 max-h-[50vh] leading-[1.45]`,VA=`flex flex-wrap items-center justify-end gap-2.5`,HA=`flex items-center gap-2.5 rounded-sm bg-inset px-3 py-2 text-meta`,UA=`grid grid-cols-[minmax(0,1fr)_104px_72px] items-center gap-3`,WA=`flex flex-col`,GA=`${UA} pb-1.5 pl-7.5 font-sans text-meta font-medium normal-nums text-subtle [&>span:not(:first-child)]:text-center`,KA=`border-b-hairline border-b-line first:border-t-hairline first:border-t-line`,qA=`${UA} group/eng rounded-sm py-1.5 pr-1 pl-0`,JA=`flex min-w-0 items-center gap-2 rounded-sm py-1.5 pr-0 pl-1.5 text-left focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-focus`,YA=e=>`mx-0.5 ${e?`text-muted`:`text-subtle`}`,XA=`flex min-w-0 flex-col gap-0.5`,ZA=e=>`truncate text-body leading-[inherit] font-medium ${e?`text-muted`:`text-ink`}`,QA=`ml-2 text-meta leading-[inherit] font-normal text-subtle`,$A={ready:`bg-success`,attention:`bg-warning`,error:`bg-error`,absent:`bg-subtle`},ej=e=>`inline-flex items-center gap-1.5 text-meta leading-[inherit] ${e===`error`?`text-error`:`text-muted`}`,tj=e=>`size-1.75 flex-none rounded-full ${$A[e]}`,nj=`flex justify-center`,rj=`rounded-full bg-accent-soft px-2.5 py-0.5 font-sans text-meta font-medium normal-nums capitalize text-accent`,ij=`rounded-full border-hairline border-line px-2.5 py-0.5 text-meta leading-[inherit] whitespace-nowrap text-muted opacity-0 transition-opacity duration-120 ease-[ease] group-hover/eng:opacity-100 group-focus-within/eng:opacity-100 hover:border-line-active hover:text-ink motion-reduce:transition-none touch:opacity-100`,aj=`mt-0 mr-1 mb-3 ml-7 flex flex-col gap-2.5 px-1.5 py-1`,oj=`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3.5 gap-y-1.5 text-meta leading-[1.5]`,sj=`text-subtle`,cj=e=>`m-0 wrap-anywhere ${e?`text-warning`:`text-ink`}`,lj=`flex items-center gap-2`,uj=`flex-1 px-2 py-1.25`,dj=`text-meta leading-[inherit] text-success`,fj=`flex items-center gap-3 py-2.5`,pj=`flex min-w-0 flex-1 flex-col gap-0.5`,mj=(e=!1)=>`overflow-hidden text-ellipsis text-meta text-muted ${e?`whitespace-normal`:`whitespace-nowrap`}`,hj=`flex flex-col gap-1 py-3`,gj=`flex items-baseline gap-3`,_j=`flex flex-col gap-2.5 pt-2`,vj=`grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-2`,yj=`m-0 pb-1.5 text-meta font-medium text-subtle`,bj=e=>e?`border-accent bg-accent-soft`:`border-line hover:bg-hover`,xj=`flex h-9 overflow-hidden rounded-xs border-hairline`,Sj=`flex w-2/5 flex-col gap-0.75 p-1`,Cj=`flex min-w-0 flex-1 flex-col gap-0.75 p-1`,wj=`h-0.75 rounded-xs`,Tj=`mt-auto flex gap-0.75`,Ej=`size-1 rounded-xs`,Dj=`flex min-w-0 items-baseline gap-1.5 font-sans text-meta`,Oj=`group relative h-4.5 w-7.5 flex-none justify-self-center rounded-full border-hairline border-line bg-inset transition-[background,border-color] duration-120 ease-[ease] aria-checked:border-accent aria-checked:bg-accent motion-reduce:transition-none`,kj=`absolute top-0.5 left-0.5 size-3 rounded-full bg-muted transition-[transform,background] duration-120 ease-[ease] group-aria-checked:[transform:translateX(12px)] group-aria-checked:bg-paper motion-reduce:transition-none`;function Aj({on:e,...t}){return(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,className:Oj,...t,children:(0,V.jsx)(`span`,{className:kj})})}function jj(e){return(0,V.jsxs)(`section`,{className:TA,children:[e.title&&(0,V.jsx)(`h2`,{className:`m-0 pb-1.5 font-sans text-meta font-medium normal-nums text-muted`,children:e.title}),e.hint&&(0,V.jsx)(`p`,{className:`m-0 pb-2 text-meta text-subtle`,children:e.hint}),(0,V.jsx)(`div`,{className:DA,children:e.children})]})}function Mj(e){let t=(0,V.jsxs)(`div`,{className:jA,children:[(0,V.jsx)(`span`,{id:e.labelId,className:MA,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:e.hint})]});return e.stack?(0,V.jsxs)(`div`,{className:AA,children:[t,e.children]}):(0,V.jsxs)(`div`,{className:e.inline?kA:OA,children:[t,e.children&&(0,V.jsx)(`div`,{className:`flex min-w-0 flex-none items-center justify-end gap-2 w-narrow:justify-start`,children:e.children})]})}function Nj(e){let t=(0,g.useId)();return(0,V.jsx)(Mj,{label:e.label,hint:e.hint,labelId:t,inline:!0,children:(0,V.jsx)(Aj,{on:e.checked,"aria-labelledby":t,disabled:e.disabled,onClick:()=>e.onChange(!e.checked)})})}var Pj=36;function Fj(e){let t=e.picks.length<=4&&e.picks.reduce((e,t)=>e+t.label.length,0)<=Pj?mA:hA;return(0,V.jsx)(Mj,{label:e.label,hint:e.hint,children:(0,V.jsx)(t,{label:e.label,value:e.value,picks:e.picks,onPick:e.onPick})})}function Ij(e){return(0,V.jsx)(Mj,{label:e.label,hint:e.note,children:(0,V.jsx)(`span`,{className:PA,children:e.value})})}var Lj=`flex items-baseline justify-between`,Rj=`[&_b]:mr-2.5`,zj=`my-2.5 flex flex-col`,Bj=e=>`flex gap-3 rounded-sm px-2 py-1 text-left text-[length:var(--fs-body)] ${e?`bg-menu`:``}`,Vj=`min-w-[14ch]`,Hj=`whitespace-nowrap text-[length:var(--fs-meta)] text-warning`,Uj=`rail-tight:hidden`,Wj=`[&_h2]:mx-0 [&_h2]:mt-3.5 [&_h2]:mb-1 [&_h2]:text-[length:var(--fs-body)]`,Gj=`max-h-[55vh] overflow-x-hidden overflow-y-auto`,Kj=`mr-auto text-[length:var(--fs-meta)]`,qj=`text-[length:var(--fs-body)] leading-[1.55] wrap-anywhere [&_h3]:mx-0 [&_h3]:mt-3 [&_h3]:mb-1.5 [&_h3]:font-sans [&_h3]:text-meta [&_h3]:font-medium [&_h3]:normal-nums [&_h3]:text-muted [&_h3:first-child]:mt-0 [&_ul]:m-0 [&_ul]:pl-4.5 [&_li+li]:mt-2 [&_p]:mx-0 [&_p]:mt-0 [&_p]:mb-2 [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2 [&_code]:rounded-sm [&_code]:bg-inset [&_code]:px-1 [&_code]:py-0 [&_code]:font-mono [&_code]:text-meta [&_code]:font-normal [&_code]:normal-nums`,Jj=`mt-3`,Yj=e=>`rounded-sm px-2 py-1.25 ${e?`bg-menu`:``}`,Xj=`flex items-baseline gap-2 text-[length:var(--fs-body)]`,Zj=`flex items-baseline justify-between gap-2`,Qj=`font-mono`,$j=`truncate`,eM=`mt-4 text-[length:var(--fs-meta)]`;function tM(e){return e.replace(/\[`[0-9a-f]{7,40}`\]\([^)]*\)\s*/g,``).replace(/\s+[—-]\s+\[@[^\]]+\]\([^)]*\)\s*$/,``).trim()}function nM(e){let t=[],n=(e,n)=>t.push({kind:e,text:n,id:t.length});for(let r of e.split(/\r?\n/)){let e=r.trimEnd();if(e.trim()===``)continue;let i=/^#{1,6}\s+(.*)$/.exec(e);if(i){n(`heading`,i[1]??``);continue}let a=/^\s*[-*]\s+(.*)$/.exec(e);if(a){n(`item`,a[1]??``);continue}let o=t.at(-1);o&&o.kind!==`heading`?o.text=`${o.text} ${e.trim()}`:n(`para`,e.trim())}return t.map(e=>e.kind===`item`?{...e,text:tM(e.text)}:e)}var rM=/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)|`([^`]+)`|\*\*([^*]+)\*\*/g;function iM(e){let t=[],n=0;for(let r of e.matchAll(rM)){let i=r.index??0;i>n&&t.push(e.slice(n,i));let[a,o,s,c,l]=r;o!==void 0&&s!==void 0?t.push((0,V.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,children:iM(o)},i)):c===void 0?l!==void 0&&t.push((0,V.jsx)(`b`,{children:l},i)):t.push((0,V.jsx)(`code`,{children:c},i)),n=i+a.length}return n<e.length&&t.push(e.slice(n)),t}function aM({body:e}){let t=nM(e),n=[],r=[],i=()=>{r.length>0&&n.push((0,V.jsx)(`ul`,{children:r},`ul-${n.length}`)),r=[]};for(let e of t){if(e.kind===`item`){r.push((0,V.jsx)(`li`,{children:iM(e.text)},e.id));continue}i(),n.push(e.kind===`heading`?(0,V.jsx)(`h3`,{children:e.text},e.id):(0,V.jsx)(`p`,{children:iM(e.text)},e.id))}return i(),(0,V.jsx)(`div`,{className:qj,children:n})}var oM=`page min-h-0 flex-1 rounded-md border-hairline border-line bg-paper px-4.5 py-3.5 focus:outline-none`,sM=`${oM} overflow-y-auto`,cM=`page-title mx-0 mt-0 mb-1.5 font-sans text-title font-bold normal-nums`,lM=`flex items-baseline justify-between gap-4 [&_.page-title]:m-0`,uM=e=>`min-w-0 truncate text-meta ${e?``:`leading-[inherit]`}`,dM=`flex flex-wrap items-center gap-2`,fM={row:`touch:after:-inset-x-0.75 touch:after:-inset-y-0.5`,kanban:`touch:after:-inset-x-0.75 touch:after:-top-1.5 touch:after:-bottom-1`,header:`touch:after:-inset-x-0.75 touch:after:-top-2.5 touch:after:-bottom-1.25`},pM=`mt-2.5 flex flex-col gap-1.5`,mM=e=>`flex cursor-pointer flex-col gap-0.5 rounded-sm px-2.5 py-1.5 ${e?`bg-menu`:``}`,hM=`flex min-w-0 items-baseline gap-2.5`,gM=`whitespace-nowrap text-muted`,_M=`flex gap-2.5 pl-[4ch] text-meta leading-[inherit] text-muted`,vM=`min-w-0 flex-1 truncate`,yM=`flex flex-col px-1.5 pb-2`,bM=`relative flex flex-col px-1.5 pt-1.5 pb-0.5`,xM=e=>`flex items-center rounded-sm px-2 py-0.75 text-left touch:min-h-10 ${e?`bg-menu text-ink`:`text-muted [&:hover]:bg-hover`}`,SM=`ml-auto -mr-[4.5px] w-5 text-center font-sans text-display leading-none font-normal text-accent normal-nums`,CM=`mr-[7px] size-3.5 flex-none fill-none stroke-current stroke-[1.75] [stroke-linecap:round] [stroke-linejoin:round]`,wM=_(null),TM=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),EM=e=>`https://github.com/Sma1lboy/rove/releases/tag/v${e}`;function DM(){return B()===`zh`?jr:Ar}function OM(e,t){return e.request(`update.check`,{force:!0,locale:Ce.get(),channel:t}).then(e=>(wM.set(e),!0),()=>!1)}function kM(){let e=DM(),t=v(wM),{prefs:n}=A_();return!n.updateNotify||!t?.info?.hasUpdate?null:(0,V.jsxs)(`button`,{type:`button`,className:`${U} text-muted ${Hj} ${He}`,title:TM(e.chip,{version:t.info.latest}),onClick:()=>ha(`update`),children:[`↑`,(0,V.jsxs)(`span`,{className:Uj,children:[` `,t.info.latest]})]})}function AM({client:e}){let t=DM(),n=v(wM),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(`release`),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(null);(0,g.useEffect)(()=>{l.current?.focus(),OM(e).finally(()=>i(!0))},[e]);let u=n?.info??null,d=n?.current??``,f=u?.latest??d,p=u?.hasUpdate===!0,m=r&&u===null,h=r&&u!==null&&!p,_=n?.notes??[],y=_[0]?.url??(f?EM(f):null),b=[{id:`release`,key:`R`,label:t.actions.openRelease,detail:y??t.releaseUrlUnavailable},{id:`close`,key:`Q`,label:t.actions.close,detail:t.actions.closeDetail}],x=e=>{if(e===`close`)return on.set(null);c(y&&window.open(y,`_blank`,`noopener`)!==null?t.statusReleaseOpened:t.statusReleaseError)};return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:l,onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`&&!window.getSelection()?.toString())return e.preventDefault(),x(`close`);if(e.metaKey||e.ctrlKey||e.altKey)return;let t=b.findIndex(e=>e.id===a);if(e.key===`j`||e.key===`ArrowDown`)o(b[(t+1)%b.length]?.id??`close`);else if(e.key===`k`||e.key===`ArrowUp`)o(b[(t-1+b.length)%b.length]?.id??`close`);else if(e.key===`Enter`)x(a);else if(e.key===`r`)x(`release`);else if(e.key===`q`||e.key===`Escape`)x(`close`);else return;e.preventDefault()},children:[(0,V.jsxs)(`div`,{className:Lj,children:[(0,V.jsx)(`h1`,{className:cM,children:t.pageTitle}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} mono`,onClick:()=>x(`close`),children:Ko()?z(`dialog.close`):t.closeHint})]}),(0,V.jsxs)(`p`,{className:`mono ${Rj}`,children:[(0,V.jsx)(`span`,{className:`text-muted`,children:t.current}),` `,(0,V.jsxs)(`b`,{children:[`v`,d]}),` `,(0,V.jsx)(`span`,{className:`text-muted`,children:t.latest}),` `,m?(0,V.jsx)(`b`,{className:`text-muted`,children:t.latestUnknown}):r?(0,V.jsxs)(`b`,{className:p?`text-warning`:`text-success`,children:[`v`,f]}):(0,V.jsx)(`span`,{className:`text-muted`,children:`…`})]}),m&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.registryRetry}),h&&(0,V.jsx)(`p`,{className:`text-success`,children:t.upToDate}),p&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:`rove update`}),(0,V.jsx)(`div`,{className:zj,children:b.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:Bj(a===e.id),onClick:()=>x(e.id),children:[(0,V.jsxs)(`span`,{className:`mono keys-only text-accent`,children:[`[`,e.key,`]`]}),(0,V.jsx)(`span`,{className:Vj,children:e.label}),(0,V.jsx)(`span`,{className:`text-muted`,children:e.detail})]},e.id))}),s&&(0,V.jsx)(`p`,{className:`mono text-accent`,children:s}),p&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:TM(t.changesSectionHeader,{from:d,to:f})}),!r&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.loadingNotes}),r&&p&&_.length===0&&(0,V.jsx)(`p`,{className:`text-muted`,children:t.notesUnavailable}),_.map(e=>(0,V.jsxs)(`section`,{className:Wj,children:[(0,V.jsxs)(`h2`,{className:`mono`,children:[`v`,e.version]}),(0,V.jsx)(aM,{body:e.body})]},e.version))]})}var jM=`rove.whatsNewSeenVersion`,MM=e=>e.split(/[.-]/).slice(0,3).map(Number),NM=(e,t)=>{let[n,r]=[MM(e),MM(t)];for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)>(r[e]??0);return!1};function PM(e,t){let n=localStorage.getItem(jM);localStorage.setItem(jM,t),!(!n||!NM(t,n))&&e.request(`release.notes`,{version:t.replace(/-.*$/,``),locale:Ce.get()}).then(e=>W.set((0,V.jsx)(FM,{from:n,to:t,notes:e.notes})),()=>W.set((0,V.jsx)(FM,{from:n,to:t,notes:null})))}function FM(e){let t=DM(),n=(0,g.useRef)(null);return(0,g.useEffect)(()=>n.current?.focus(),[]),(0,g.useEffect)(()=>{let e=e=>{e.key===`q`&&W.set(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,V.jsxs)(ir,{title:t.whatsNew.title,wide:!0,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:TM(t.whatsNew.upgraded,{from:e.from,to:e.to})}),(0,V.jsx)(`div`,{className:Gj,children:e.notes?(0,V.jsx)(aM,{body:e.notes.body}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.whatsNew.notesUnavailable})}),(0,V.jsxs)(`div`,{className:$t,children:[(0,V.jsx)(`span`,{className:`mono text-muted ${Kj} touch:hidden!`,children:z(`whatsNew.keys`)}),(0,V.jsx)(`a`,{className:Xt,href:e.notes?.url??EM(e.to),target:`_blank`,rel:`noopener noreferrer`,children:z(`whatsNew.openRelease`)}),(0,V.jsx)(`button`,{ref:n,type:`button`,className:je(),onClick:()=>W.set(null),children:z(`whatsNew.continue`)})]})]})}var IM=(e,t)=>e.replace(`{version}`,t);function LM({client:e}){let t=DM(),n=v(wM),{prefs:r}=A_(),[i,a]=(0,g.useState)(`idle`),o=()=>{a(`checking`),OM(e,r.updateChannel).then(e=>a(e?`done`:`failed`))},s=t=>{a(`idle`),k_(e,`updateChannel`,t)},c=n?.info??null,l=i===`failed`||i===`done`&&c===null,u=i===`done`&&n&&c?c.hasUpdate?IM(t.available,c.latest):t.upToDate:l?t.latestUnknown:void 0,d=l?`text-muted`:c?.hasUpdate?`text-warning`:`text-success`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Fj,{label:$(`general.updateChannelTitle`),hint:$(`general.updatesHint`),value:r.updateChannel,picks:nA.map(e=>({value:e,label:$(`general.updateChannelName.${e}`)})),onPick:s}),(0,V.jsx)(Nj,{label:$(`general.updateNotify`),hint:$(`general.updateNotifyHint`),checked:r.updateNotify,onChange:t=>void k_(e,`updateNotify`,t)}),(0,V.jsxs)(Mj,{label:$(`general.updates`),hint:$(`general.updateCheckHint`),children:[i===`done`&&c?.hasUpdate&&(0,V.jsx)(H,{variant:`action`,onClick:()=>ha(`update`),children:$(`general.updateOpenPage`)}),(0,V.jsx)(H,{variant:`action`,disabled:i===`checking`,onClick:o,children:$(i===`checking`?`general.updateChecking`:`general.updateCheckButton`)})]}),u&&(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:d,children:u}),hint:c?.hasUpdate?(0,V.jsx)(`code`,{className:`font-mono`,children:`rove update`}):void 0,children:i===`done`&&n&&c&&(0,V.jsx)(`span`,{className:`max-w-90 min-w-0 truncate font-mono text-meta text-muted [overflow-wrap:anywhere]`,title:`${t.latest} v${c.latest}`,children:`${t.current} v${n.current} · ${t.latest} v${c.latest}`})})]})}function RM({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`daemon.info`)??null);return(0,g.useEffect)(()=>{Fs(e,`daemon.info`).then(n,()=>n(null))},[e]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(jj,{title:z(`settings.about.groupRove`),children:[t?.daemonVersion&&(0,V.jsx)(Mj,{label:z(`settings.about.daemon`),hint:z(t.stale?`settings.about.daemonStale`:`settings.about.daemonCurrent`,{version:t.daemonVersion})}),(0,V.jsx)(LM,{client:e})]}),(0,V.jsx)(jj,{title:z(`settings.about.browser`),children:(0,V.jsx)(Mj,{label:z(`settings.about.signOut`),hint:z(`settings.about.browserHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>void ka().then(()=>window.location.reload()),children:z(`settings.about.signOut`)})})})]})}async function zM(e,t){let{taskId:n}=await e.client.request(`task.openScratch`);await NC(e,n,{kind:`engine`,prompt:t}),yn()}var BM=_(null);function VM({theme:e,mode:t}){let n=e[t],r=(e,t)=>({background:e,width:t});return(0,V.jsxs)(`span`,{className:xj,style:{background:n.background,borderColor:n.border},"aria-hidden":!0,children:[(0,V.jsxs)(`span`,{className:Sj,style:{background:n.backgroundPanel},children:[(0,V.jsx)(`span`,{className:wj,style:r(n.primary,`70%`)}),(0,V.jsx)(`span`,{className:wj,style:r(n.textMuted,`85%`)}),(0,V.jsx)(`span`,{className:wj,style:r(n.textMuted,`55%`)})]}),(0,V.jsxs)(`span`,{className:Cj,children:[(0,V.jsx)(`span`,{className:wj,style:r(n.text,`90%`)}),(0,V.jsx)(`span`,{className:wj,style:r(n.textMuted,`65%`)}),(0,V.jsx)(`span`,{className:wj,style:r(n.accent??n.primary,`40%`)}),(0,V.jsx)(`span`,{className:Tj,children:[n.success,n.warning,n.error,n.info].map((e,t)=>(0,V.jsx)(`span`,{className:Ej,style:{background:e}},t))})]})]})}function HM(e){return(0,V.jsxs)(H,{variant:`card`,"aria-pressed":e.active,className:bj(e.active),onMouseEnter:()=>x_.set(e.theme),onFocus:()=>x_.set(e.theme),onClick:e.onClick,children:[(0,V.jsx)(VM,{theme:e.theme,mode:e.mode}),(0,V.jsxs)(`span`,{className:Dj,children:[(0,V.jsx)(`span`,{className:`truncate text-ink`,children:e.theme.name}),e.tag&&(0,V.jsx)(`span`,{className:`text-subtle`,children:e.tag})]})]})}function UM({children:e}){return(0,V.jsx)(`div`,{className:vj,onMouseLeave:()=>x_.set(null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||x_.set(null)},children:e})}function WM(e){let{model:t}=e,{client:n}=t,r=v(BM),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1);(0,g.useEffect)(()=>()=>x_.set(null),[]),(0,g.useEffect)(()=>void O_(n).catch(()=>void 0),[n]),(0,g.useEffect)(()=>{BM.get()===null&&n.request(`theme.hosted`).then(e=>BM.set(e),()=>BM.set({themes:[],dir:null}))},[n]);let f=e=>{l(!1),zM(t,z(`prefs.themeAgentPrompt`,{dir:e})).catch(()=>l(!0))},p=r?.dir??null,m=async e=>{a(e),s(null);try{await n.request(`theme.install`,{name:e}),await O_(n),await k_(n,`theme`,e)}catch{s(e)}finally{a(null)}},h=new Set(e.themes.map(e=>e.name)),_=(r?.themes??[]).filter(e=>!h.has(e.name));return(0,V.jsxs)(Mj,{label:e.label,hint:z(`prefs.themePreviewHint`),stack:!0,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:yj,children:z(`prefs.themeInstalled`)}),(0,V.jsx)(UM,{children:e.themes.map(t=>(0,V.jsx)(HM,{theme:t,mode:e.mode,active:t.name===e.value,tag:t.bundled?void 0:z(`prefs.themeUser`),onClick:()=>t.name!==e.value&&void k_(n,`theme`,t.name)},t.name))})]}),_.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(H,{className:`inline-flex items-center gap-1.5`,"aria-expanded":u,onClick:()=>d(!u),children:[(0,V.jsx)(Ma,{right:!u}),u?z(`prefs.themeHide`):z(`prefs.themeBrowse`,{count:_.length})]}),u&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`m-0 pb-1.5 text-meta font-medium text-subtle mt-2.5`,children:z(`prefs.themeMoreHint`)}),(0,V.jsx)(UM,{children:_.map(t=>(0,V.jsx)(HM,{theme:t,mode:e.mode,active:!1,tag:i===t.name?z(`prefs.themeInstalling`):o===t.name?z(`prefs.themeInstallFailed`):z(`prefs.themeGet`),onClick:()=>i===null&&void m(t.name)},t.name))})]})]}),p&&(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,V.jsx)(H,{variant:`action`,onClick:()=>f(p),children:z(`prefs.themeAgent`)}),(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:z(c?`prefs.themeAgentFailed`:`prefs.themeAgentHint`)})]})]})}var GM=_({}),KM=``,qM=`(prefers-color-scheme: dark)`;function JM(e){let t=window.matchMedia(qM);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function YM(){return(0,g.useSyncExternalStore)(JM,()=>window.matchMedia(qM).matches)}function XM(){let e=YM();return l_(A_().prefs.themeMode,e)}function ZM(e){let t=XM(),n=A_();(0,g.useEffect)(()=>{if(!n.loaded||n.prefs.taskColors!==`on`)return;let r=`${n.prefs.theme}/${t}`;r!==KM&&(KM=r,GM.set({}));let i=()=>{let i=GM.get(),a=e.tasks.get(),o=[...a?.tasks??[],...a?.archived??[]].map(e=>e.id).filter(e=>!(e in i));o.length!==0&&e.client.request(`theme.taskColors`,{theme:n.prefs.theme,mode:t,taskIds:o}).then(e=>{KM===r&&GM.set({...GM.get(),...e.colors})}).catch(()=>void 0)};return i(),e.tasks.subscribe(i)},[e,t,n.loaded,n.prefs.taskColors,n.prefs.theme])}function QM(e){let t=A_(),n=v(GM);return e&&t.prefs.taskColors===`on`?n[e]:void 0}var $M={themeMode:{dark:`appearance.modeDark`,light:`appearance.modeLight`,auto:`appearance.modeAuto`},focusAccent:{primary:`general.accentPrimary`,success:`general.accentSuccess`,info:`general.accentInfo`},splitStyle:{box:`general.splitBox`,line:`general.splitLine`,rail:`general.splitRail`,rule:`general.splitRule`},railFold:{glyphs:`general.railFoldGlyphs`,initials:`general.railFoldInitials`,hairline:`general.railFoldHairline`},workingBorder:{flow:`appearance.borderFlow`,still:`appearance.borderStill`},glyphSet:{braille:`appearance.glyphsBraille`,starburst:`appearance.glyphsStarburst`,ascii:`appearance.glyphsAscii`},runningTitle:{shimmer:`appearance.titleShimmer`,still:`appearance.titleStill`}};function eN({model:e}){let{client:t}=e,n=A_(),r=XM(),i=v(AT),a=(e,n)=>void k_(t,e,n),o=(e,t,r)=>(0,V.jsx)(Fj,{label:$(t),hint:r,value:n.prefs[e],picks:j_(n,e).map(t=>({value:t,label:e===`themeMode`&&t===`auto`?z(`prefs.modeAuto`):$($M[e]?.[String(t)]??String(t))})),onPick:t=>a(e,t)}),s=(e,t,r)=>(0,V.jsx)(Nj,{label:$(t),hint:r,checked:e===`transparent`?n.prefs.transparent:n.prefs[e]===`on`,onChange:t=>a(e,e===`transparent`?t:t?`on`:`off`)});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(jj,{children:[(0,V.jsx)(WM,{model:e,label:$(`general.theme`),themes:n.themes,value:n.prefs.theme,mode:r}),o(`themeMode`,`general.themeMode`)]}),(0,V.jsxs)(jj,{title:z(`settings.appearance.groupColours`),children:[o(`focusAccent`,`general.focusAccent`,$(`general.focusAccentHint`)),s(`taskColors`,`general.taskColors`,z(`settings.appearance.taskColorsNote`)),s(`colorblind`,`general.colorblind`,z(`settings.appearance.colorblindNote`))]}),(0,V.jsxs)(jj,{title:z(`settings.appearance.groupTasks`),children:[o(`workingBorder`,`general.workingBorder`,z(`settings.appearance.workingBorderNote`)),o(`runningTitle`,`general.runningTitle`),o(`glyphSet`,`general.glyphSet`),o(`railFold`,`general.railFold`,$(`general.railFoldHint`)),(0,V.jsx)(Fj,{label:z(`settings.appearance.railGroup`),value:i,picks:OT.map(e=>({value:e,label:z(e===`state`?`settings.appearance.railGroupState`:`settings.appearance.railGroupProject`)})),onPick:jT})]}),(0,V.jsxs)(jj,{title:z(`settings.appearance.groupTerminal`),hint:z(`prefs.terminalOnly`),children:[s(`transparent`,`general.transparent`),o(`splitStyle`,`general.splitStyle`)]})]})}function tN(e,t,n){if(t===`offline`)return`offline`;if(t===`unsupported`||t===`mismatch`)return`outdated`;if(!e)return`loading`;let r=e.status;return r?r.gh?r.account?r.account===n?`same`:`different`:`signedOut`:`noGh`:e.reason===`failed`||!e.reason?`failed`:e.reason}var nN=2e3,rN=e=>e?.login?.state===`pending`||e?.login?.state===`syncing`;function iN(e){let{client:t}=e,n=gE(e),[r,i]=(0,g.useState)({}),a=n.flatMap(e=>e.state===`online`?[e.alias]:[]).join(`
115
115
  `),o=(0,g.useMemo)(()=>a?a.split(`
116
- `):[],[a]),s=(0,g.useRef)(new Set),c=(0,g.useCallback)(async e=>{let n=e===``?{}:{machine:e},r=await t.request(`github.status`,n).catch(e=>({status:null,reason:`failed`,message:K(e)}));i(t=>({...t,[e]:r}))},[t]),l=(0,g.useCallback)(()=>Promise.all([``,...o].map(c)).then(()=>{}),[c,o]);return(0,g.useEffect)(()=>{l()},[l]),(0,g.useEffect)(()=>{let e=new Set(Object.entries(r).flatMap(([e,t])=>tN(t.status)?[e]:[])),t=[...s.current].some(t=>!e.has(t));if(s.current=e,t&&l(),e.size===0)return;let n=window.setTimeout(()=>{for(let t of e)c(t)},eN);return()=>window.clearTimeout(n)},[r,c,l]),{machines:n,probes:r,refresh:l,probe:c,act:(0,g.useCallback)(async(e,n)=>{try{let r=await t.request(e,n);return r.ok||G(r.message,`error`),r}catch(e){return G(K(e),`error`),null}},[t])}}var rN={same:`markSame`,different:`markDifferent`,signedOut:`markSignedOut`,noGh:`markNoGh`,outdated:`markOutdated`,offline:`markOffline`,denied:`markDenied`,failed:`markFailed`},iN=(e,t)=>z(`settings.connectors.${e}`,t),aN={same:`text-diff-added`,signedOut:`text-diff-removed`,failed:`text-diff-removed`,denied:`text-diff-removed`,different:`text-warning`,outdated:`text-warning`,offline:`text-muted`,noGh:`text-muted`,loading:`text-muted`};function oN(e,t){return e===`loading`?iN(`loading`):iN(rN[e],{login:t?.account??``})}function sN(e){if(!e?.gh)return``;let t=e.ssh.ok?`✓ ${e.ssh.user??``}`.trim():`✗`;return iN(`detail`,{protocol:e.protocol??`—`,ssh:t})}function cN(){return(0,V.jsx)(`svg`,{className:`flex-none`,viewBox:`0 0 16 16`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{fill:`currentColor`,d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})})}function lN(e){navigator.clipboard.writeText(e).then(()=>G(iN(`codeCopied`)),()=>{})}function uN({login:e,onCancel:t}){return e.state===`failed`?(0,V.jsxs)(`div`,{className:BA,children:[(0,V.jsx)(`span`,{className:`text-muted`,children:iN(`loginFailed`,{error:e.error??``})}),(0,V.jsx)(H,{className:`ml-auto`,onClick:t,children:iN(`dismiss`)})]}):e.state===`syncing`?(0,V.jsx)(`div`,{className:BA,children:(0,V.jsx)(`span`,{className:`text-muted`,children:iN(`syncing`)})}):(0,V.jsxs)(`div`,{className:BA,children:[e.code?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`font-mono font-normal normal-nums rounded-sm border-hairline border-dashed border-line px-2 py-0.5 text-display tracking-code`,title:iN(`codeHint`),onClick:()=>lN(e.code??``),children:e.code}),(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:iN(`openGithub`)})]}):(0,V.jsx)(`span`,{className:`text-muted`,children:iN(`loading`)}),(0,V.jsx)(H,{className:`ml-auto`,onClick:t,children:z(`dialog.cancel`)})]})}function dN(e){let t=$M(e.probe,e.machine,e.rove),n=e.probe?.status??null,r=tN(n),i=t===`different`||t===`signedOut`,a=n?.login;return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:uj,children:[(0,V.jsxs)(`div`,{className:dj,children:[(0,V.jsx)(`span`,{className:AA,children:e.name}),(0,V.jsx)(`span`,{className:fj(),title:[n?.authDetail,n?.ssh.detail].filter(Boolean).join(`, `)||void 0,children:sN(n)})]}),(0,V.jsx)(`span`,{className:`whitespace-nowrap text-meta ${aN[t]}`,title:e.probe?.message,children:oN(t,n)}),e.onSync&&i&&e.rove&&!r&&(0,V.jsx)(H,{variant:`action`,disabled:e.busy,onClick:e.onSync,children:iN(`useRove`)}),e.onLogin&&i&&!r&&(0,V.jsx)(H,{variant:`action`,disabled:e.busy,onClick:e.onLogin,children:iN(`loginThere`)})]}),a&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsx)(uN,{login:a,onCancel:e.onCancel})})]})}function fN({model:e}){let{machines:t,probes:n,refresh:r,probe:i,act:a}=nN(e),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),u=n[``],d=u?.status?.account??null,f=tN(u?.status),p=async(e,t)=>{s(e);try{await t()}finally{s(null)}},m=e=>p(e,async()=>{await a(`github.login`,e===``?{}:{machine:e}),await i(e)}),h=e=>p(e,async()=>{await a(`github.login`,e===``?{cancel:!0}:{machine:e,cancel:!0}),await i(e)}),_=e=>p(e,async()=>{(await a(`github.sync`,{machine:e}))?.ok&&G(iN(`synced`,{machine:e,login:d??``})),await i(e)}),v=()=>p(``,async()=>{(await a(`github.logout`,{}))?.ok&&l(!1),await r()});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(kj,{children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Aj,{label:(0,V.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,V.jsx)(cN,{}),`GitHub`]}),hint:iN(`githubDescription`),children:d?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:MA,children:[`@`,d]}),(0,V.jsx)(H,{variant:`action`,disabled:o!==null,onClick:()=>l(!0),children:iN(`disconnect`)})]}):!f&&(0,V.jsx)(H,{variant:`filled`,disabled:o!==null||!u,onClick:()=>void m(``),children:iN(`connect`)})}),c&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-inset px-3 py-2.5 [&_p]:m-0 [&_p]:text-meta [&_p]:text-muted`,children:[(0,V.jsx)(`p`,{children:iN(`disconnectBody`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2.5`,children:[(0,V.jsx)(H,{onClick:()=>l(!1),children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:`danger`,disabled:o!==null,onClick:()=>void v(),children:iN(`disconnect`)})]})]})}),!d&&u?.status?.login&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsx)(uN,{login:u.status.login,onCancel:()=>void h(``)})})]})}),d&&(0,V.jsxs)(kj,{title:iN(`machines`),children:[(0,V.jsx)(dN,{name:iN(`thisMachine`),probe:u,machine:null,rove:d,busy:o!==null,onCancel:()=>void h(``)}),t.map(e=>(0,V.jsx)(dN,{name:e.alias,probe:n[e.alias],machine:e.state,rove:d,busy:o!==null,onSync:()=>void _(e.alias),onLogin:()=>void m(e.alias),onCancel:()=>void h(e.alias)},e.alias)),(0,V.jsx)(`div`,{className:`py-2.5`,children:(0,V.jsx)(H,{onClick:()=>void r(),children:iN(`refresh`)})})]})]})}function pN({model:e}){return(0,V.jsx)(fN,{model:e})}var mN=[{key:`remoteProjects`,label:`dev.remote`,hint:`dev.remoteHint`},{key:`autoStatus`,label:`dev.autoStatus`,hint:`dev.autoStatusHint`},{key:`dispatcher`,label:`dev.dispatcher`,hint:`dev.dispatcherHint`}];function hN({client:e}){let{prefs:t}=A_(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),o=async()=>{if(n){a(!0);try{if(n===`reset`){await e.request(`dev.reset`),localStorage.removeItem(`rove.prefs`),window.location.reload();return}await e.request(`daemon.restart`),G($(`restart.done`)),r(null)}catch(e){G(K(e),`error`)}finally{a(!1)}}},s=(e,t,a,s,c)=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Aj,{label:t,hint:a,children:(0,V.jsx)(H,{variant:`action`,onClick:()=>r(e),children:s})}),n===e&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-inset px-3 py-2.5 [&_p]:m-0 [&_p]:text-meta [&_p]:text-muted`,children:[(0,V.jsx)(`strong`,{children:$(`${e}.title`)}),(0,V.jsx)(`p`,{children:z(e===`reset`?`prefs.resetBody`:`prefs.restartBody`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2.5`,children:[(0,V.jsx)(H,{onClick:()=>r(null),children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:c?`danger`:`filled`,disabled:i,onClick:()=>void o(),children:s})]})]})})]});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(kj,{title:$(`dev.experimental`),children:mN.map(n=>(0,V.jsx)(jj,{label:$(n.label),hint:$(n.hint),checked:t[n.key],onChange:t=>void k_(e,n.key,t)},n.key))}),(0,V.jsxs)(kj,{hint:$(`dev.doctorHint`),children:[s(`restart`,$(`dev.restart`),z(`prefs.restartHint`),z(`prefs.restartButton`),!1),s(`reset`,$(`dev.reset`),z(`prefs.resetHint`),z(`prefs.resetButton`),!0)]})]})}function gN(e){return e.binaryFound===void 0?{key:`settings.engines.status.checking`,tone:`unknown`}:e.binaryFound===null?{key:`settings.engines.status.unknown`,tone:`unknown`}:e.binaryFound?e.configIssue?{key:`settings.engines.status.integrationBlocked`,tone:`error`}:e.login===`no`?{key:`settings.engines.status.signIn`,tone:`attention`}:e.hooks===`outdated`?{key:`settings.engines.status.integrationOutdated`,tone:`attention`}:e.hooks===`not-installed`?{key:`settings.engines.status.integrationMissing`,tone:`attention`}:{key:`settings.engines.status.ready`,tone:`ready`}:e.commandChosen?{key:`settings.engines.status.notOnPath`,tone:`attention`}:{key:`settings.engines.status.notInstalled`,tone:`absent`}}var _N=_([]),vN=3e4;function yN(e){return e.request(`skill.missing`).then(e=>_N.set(e.engines),()=>{})}function bN(e){(0,g.useEffect)(()=>{let t=e.onOpen(()=>void yN(e)),n=window.setInterval(()=>void yN(e),vN);return()=>{t(),window.clearInterval(n)}},[e])}function xN(e){return e.request(`skill.install`).then(e=>{e.error&&G($(`engines.skill.failed`,{reason:e.error}),`error`)}).catch(e=>G(K(e),`error`)).then(()=>yN(e))}function SN(e){return gN({binaryFound:e.binaryFound,login:e.login,hooks:e.hooks,configIssue:e.configIssue,commandChosen:e.custom||e.customized})}var CN={ready:`ready`,attention:`attention`,error:`error`,absent:`absent`,unknown:`absent`};function wN({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`engines.settings`)?.engines??null),[r,i]=(0,g.useState)(null),a=(0,g.useCallback)(()=>Fs(e,`engines.settings`).then(e=>n(e.engines),e=>G(K(e),`error`)),[e]);(0,g.useEffect)(()=>{a()},[a]);let o=(t,n={})=>void e.request(t,n).then(a).catch(e=>G(K(e),`error`));return t?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`p`,{className:wA,children:$(`engines.hint`)}),(0,V.jsxs)(`div`,{className:HA,children:[(0,V.jsxs)(`div`,{className:UA,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{children:$(`engines.defaultMark`)}),(0,V.jsx)(`span`,{children:$(`engines.available`)})]}),t.map(e=>(0,V.jsx)(TN,{engine:e,open:r===e.id,onToggleOpen:()=>i(r===e.id?null:e.id),run:o},e.id))]})]}),(0,V.jsx)(ON,{engines:t,run:o}),(0,V.jsx)(kN,{engines:t,client:e,reload:a})]}):(0,V.jsx)(`p`,{className:NA,children:z(`preview.loading`)})}function TN(e){let{engine:t,run:n}=e,r=(0,g.useId)(),i=SN(t);return(0,V.jsxs)(`div`,{className:WA,children:[(0,V.jsxs)(`div`,{className:GA,children:[(0,V.jsxs)(`button`,{type:`button`,className:KA,"aria-expanded":e.open,"aria-controls":r,onClick:e.onToggleOpen,children:[(0,V.jsx)(Ma,{right:!e.open,className:qA(e.open)}),(0,V.jsxs)(`span`,{className:JA,children:[(0,V.jsxs)(`span`,{className:YA(!t.enabled),children:[t.name,t.renamedFrom?(0,V.jsx)(`span`,{className:XA,children:t.renamedFrom}):null,t.custom&&!t.renamedFrom?(0,V.jsx)(`span`,{className:XA,children:$(`engines.customTag`)}):null]}),(0,V.jsxs)(`span`,{className:QA(CN[i.tone]),children:[(0,V.jsx)(`span`,{className:$A(CN[i.tone]),"aria-hidden":`true`}),$(i.key.slice(9))]})]})]}),(0,V.jsx)(`div`,{className:ej,children:t.isDefault?(0,V.jsx)(`span`,{className:tj,children:$(`engines.defaultMark`)}):t.canBeDefault?(0,V.jsx)(`button`,{type:`button`,className:nj,"aria-label":z(`settings.engines.default`,{name:t.name}),onClick:()=>n(`engine.setDefault`,{id:t.id}),children:$(`engines.makeDefault`)}):null}),(0,V.jsx)(Oj,{on:t.enabled,"aria-label":z(`settings.engines.enabled`,{name:t.name}),onClick:()=>n(`engine.setEnabled`,{id:t.id,enabled:!t.enabled})})]}),e.open?(0,V.jsx)(DN,{id:r,engine:t,run:n}):null]})}function EN(e){if(e.configIssue)return $(`engines.detail.hooksBlockedHere`,{reason:e.configIssue});switch(e.hooks){case`installed`:return $(`engines.detail.hooksInstalled`);case`outdated`:return $(`engines.detail.hooksOutdated`);case`not-installed`:return e.binaryFound===!1?$(`engines.detail.hooksAwaitEngine`):$(`engines.detail.hooksMissing`);default:return $(`engines.detail.hooksUnsupported`)}}function DN(e){let{engine:t,run:n}=e,[r,i]=(0,g.useState)(null),a=t.binaryFound===!0?$(`engines.detail.programFound`,{binary:t.binary,path:t.binaryPath??t.binary}):t.binaryFound===!1?$(`engines.detail.programMissing`,{binary:t.binary}):$(`engines.detail.programUnknown`,{binary:t.binary}),o=t.login===`yes`?$(`engines.detail.signedIn`):t.login===`no`?$(`engines.detail.signedOut`):$(`engines.detail.signInUnknown`),s=[EN(t),$(t.markers?`engines.detail.markersYes`:`engines.detail.markersNo`),$(t.screen?`engines.detail.screenYes`:t.hooks===`installed`?`engines.detail.screenNotNeeded`:`engines.detail.screenNo`)];return(0,V.jsxs)(`div`,{id:e.id,className:rj,children:[(0,V.jsxs)(`dl`,{className:ij,children:[(0,V.jsx)(`dt`,{className:aj,children:$(`engines.detail.program`)}),(0,V.jsx)(`dd`,{className:oj(t.binaryFound===!1),children:a}),(0,V.jsx)(`dt`,{className:aj,children:$(`engines.detail.signIn`)}),(0,V.jsx)(`dd`,{className:oj(t.login===`no`),children:o}),(0,V.jsx)(`dt`,{className:aj,children:$(`engines.detail.reporting`)}),(0,V.jsx)(`dd`,{className:oj(!1),children:s.map(e=>(0,V.jsx)(`span`,{className:`block`,children:e},e))}),t.skill===`unsupported`?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:aj,children:$(`engines.detail.skill`)}),(0,V.jsx)(`dd`,{className:oj(t.skill!==`installed`),children:$(t.skill===`installed`?`engines.detail.skillInstalledHere`:t.skill===`outdated`?`engines.detail.skillOutdated`:`engines.detail.skillMissing`)})]}),t.custom?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:aj,children:$(`engines.detail.adapter`)}),(0,V.jsx)(`dd`,{className:oj(!1),children:t.protocol?$(`engines.detail.adapterDeclared`,{protocol:t.protocol}):$(`engines.detail.adapterGeneric`)})]}):null]}),r===null?(0,V.jsxs)(`div`,{className:sj,children:[(0,V.jsx)(H,{variant:`action`,onClick:()=>i(t.name),children:z(`settings.engines.rename`)}),t.custom||t.customized?(0,V.jsx)(H,{variant:`action`,onClick:()=>n(`engine.reset`,{id:t.id}),children:t.custom?z(`settings.engines.remove`):z(`settings.engines.reset`)}):null]}):(0,V.jsxs)(`form`,{className:sj,onSubmit:e=>{e.preventDefault(),n(`engine.rename`,{id:t.id,name:r}),i(null)},children:[(0,V.jsx)(`input`,{className:`${Zt} w-full ${cj}`,autoFocus:!0,value:r,"aria-label":z(`settings.engines.rename`),placeholder:z(`settings.engines.namePlaceholder`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i(null))}}),(0,V.jsx)(H,{variant:`filled`,type:`submit`,children:z(`settings.engines.save`)}),(0,V.jsx)(H,{variant:`action`,onClick:()=>i(null),children:z(`settings.engines.cancel`)})]})]})}function ON({engines:e,run:t}){let n=e.filter(e=>e.hooks!==`unsupported`),r=n.filter(e=>e.binaryFound!==!1),i=r.filter(e=>e.hooks===`installed`).length,a=r.length-i,o=n.filter(e=>e.hooks!==`not-installed`).length;return n.length===0?null:(0,V.jsx)(kj,{title:$(`engines.integrations.title`),hint:$(`engines.integrations.hint`),children:(0,V.jsx)(Aj,{label:$(`engines.integrations.summary`,{installed:i,total:r.length}),children:(0,V.jsxs)(`div`,{className:zA,children:[a>0?(0,V.jsx)(H,{variant:`filled`,onClick:()=>t(`engines.hooks.install`),children:$(`engines.integrations.install`,{count:a})}):(0,V.jsx)(`span`,{className:lj,children:$(`engines.integrations.upToDate`)}),o>0?(0,V.jsx)(H,{variant:`action`,onClick:()=>t(`engines.hooks.uninstall`),children:$(`engines.integrations.remove`,{count:o})}):null]})})})}function kN(e){let t=e.engines.filter(e=>e.skill!==`unsupported`),n=t.filter(e=>e.skill===`installed`).length,r=t.length-n;return(0,V.jsx)(kj,{title:$(`engines.skill.title`),hint:$(`engines.skill.hint`),children:(0,V.jsx)(Aj,{label:t.length>0?$(`engines.integrations.summary`,{installed:n,total:t.length}):$(`engines.skill.noEngines`),children:r>0?(0,V.jsx)(H,{variant:`filled`,onClick:()=>void xN(e.client).then(e.reload),children:$(`engines.skill.install`,{count:r})}):t.length>0?(0,V.jsx)(`span`,{className:lj,children:$(`engines.integrations.upToDate`)}):null})})}function AN({client:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1);return(0,V.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:a=>{a.preventDefault(),!(!t.trim()||!r.trim())&&(o(!0),e.request(`feedback.send`,{title:t.trim(),body:r}).then(e=>{G(z(`settings.feedback.sent`,{url:e.discussion?.url??``})),n(``),i(``)}).catch(e=>G(K(e),`error`)).finally(()=>o(!1)))},children:[(0,V.jsx)(`p`,{className:`m-0 ${jA}`,children:z(`settings.feedback.hint`)}),(0,V.jsxs)(`label`,{className:IA,children:[(0,V.jsx)(`span`,{className:LA,children:z(`settings.feedback.titleLabel`)}),(0,V.jsx)(`input`,{className:`${PA} w-full`,value:t,onChange:e=>n(e.target.value)})]}),(0,V.jsxs)(`label`,{className:IA,children:[(0,V.jsx)(`span`,{className:LA,children:z(`settings.feedback.body`)}),(0,V.jsx)(`textarea`,{className:`${PA} ${RA} w-full`,rows:6,value:r,onChange:e=>i(e.target.value)})]}),(0,V.jsx)(`div`,{className:zA,children:(0,V.jsx)(H,{variant:`filled`,type:`submit`,disabled:a||!t.trim()||!r.trim(),children:z(`settings.feedback.send`)})})]})}var jN=[{value:`en`,label:`English`},{value:`zh`,label:`中文`}],MN={default:`general.worktreeKindDefault`,nextToProject:`general.worktreeKindNext`,custom:`general.worktreeKindCustom`};function NN({model:e}){let{client:t}=e,n=A_(),{prefs:r,info:i}=n,a=(e,n)=>void k_(t,e,n),o=[`default`,`nextToProject`];(i.worktreeCustomPath||r.worktreeBase===`custom`)&&o.push(`custom`);let s=o.map(e=>({value:e,label:$(MN[e])}));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(kj,{title:z(`settings.general.groupInterface`),children:[(0,V.jsx)(Nj,{label:$(`general.language`),hint:z(`prefs.languageHint`),value:r.locale,picks:jN,onPick:e=>a(`locale`,e)}),(0,V.jsx)(jj,{label:$(`general.keyHintsShow`),hint:$(`general.keyHintsHint`),checked:r.keyHints,onChange:e=>a(`keyHints`,e)}),(0,V.jsx)(jj,{label:$(`general.zenDefaultOn`),hint:z(`prefs.zenHint`),checked:r.zen,onChange:e=>a(`zen`,e)}),(0,V.jsx)(Nj,{label:z(`settings.general.tabStrip`),value:r.tabStrip,picks:j_(n,`tabStrip`).map(e=>({value:e,label:$(`general.tabStripMode.${e}`)})),onPick:e=>a(`tabStrip`,e)})]}),(0,V.jsxs)(kj,{title:z(`settings.general.groupFiles`),children:[(0,V.jsx)(Nj,{label:$(`general.editor`),hint:z(`settings.general.editorNote`),value:r.editorKind,picks:j_(n,`editorKind`).map(e=>({value:e,label:e})),onPick:e=>a(`editorKind`,e)}),(0,V.jsx)(Nj,{label:$(`general.worktree`),hint:$(`general.worktreeHint`),value:r.worktreeBase,picks:s,onPick:e=>a(`worktreeBase`,e)})]}),(0,V.jsx)(kj,{title:z(`settings.general.groupTerminal`),hint:$(`general.terminalHint`),children:(0,V.jsx)(PN,{client:t})})]})}function PN({client:e}){let t=A_(),n=t.options.scrollbackRows,r=n&&`min`in n?n:{min:100,max:1e5},[i,a]=(0,g.useState)(String(t.prefs.scrollbackRows));return(0,g.useEffect)(()=>a(String(t.prefs.scrollbackRows)),[t.prefs.scrollbackRows]),(0,V.jsx)(Aj,{label:z(`settings.general.scrollback`),hint:$(`general.scrollbackRowHint`),children:(0,V.jsx)(`input`,{className:FA,inputMode:`numeric`,value:i,"aria-label":$(`general.scrollbackTitle`),onChange:e=>a(e.target.value),onBlur:()=>{let n=Number(i);if(i.trim()===``||!Number.isInteger(n)){a(String(t.prefs.scrollbackRows));return}let o=Math.min(r.max,Math.max(r.min,n));o===t.prefs.scrollbackRows?a(String(o)):k_(e,`scrollbackRows`,o)},onKeyDown:e=>e.key===`Enter`&&e.currentTarget.blur()})})}[...Array.from({length:12},(e,t)=>`f${t+1}`)];var FN={"diff.review.cursor":`diff-review cursor is a fixed raw binding (j/k), not keymap-driven`,"diff.review.range":`diff-review range anchor is a fixed raw binding (v), not keymap-driven`,"diff.review.note":`diff-review note is a fixed raw binding (c), not keymap-driven`,"diff.review.send":`diff-review send is a fixed raw binding (s), not keymap-driven`,"diff.review.drop":`diff-review drop-note is a fixed raw binding (x), not keymap-driven`,"diff.review.reload":`preview reload is a fixed raw binding (r), not keymap-driven`};function IN(e,t){let n=`alternating [${e}, ${t}] pairs`;return{layout:n,validateCount:e=>e>=2&&e%2==0?null:`needs ${n} (an even number of chords — got ${e})`}}IN(`top (double-tap)`,`bottom`),IN(`down`,`up`),IN(`down`,`up`),IN(`down`,`up`),IN(`collapse`,`expand`),IN(`previous tab`,`next tab`);async function LN(e){try{(await e.request(`keybindings.createFile`)).created||G(z(`keys.exists`),`error`),await Yr(e)}catch(e){G(K(e),`error`)}}function RN({model:e}){let{client:t}=e,{prefs:n}=A_(),r=v(Kr),[i,a]=(0,g.useState)(!1);(0,g.useEffect)(()=>void Yr(t),[t]);let o=r.prefix.key??$(`keybindings.prefixDisabled`),s=Object.keys(FN).sort();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(kj,{children:[(0,V.jsx)(Nj,{label:$(`keybindings.tapPresentation`),hint:$(`keybindings.tapPresentationHint`),value:n.prefixTap,picks:[{value:`local`,label:$(`keybindings.tapPresentationLocal`)},{value:`guide`,label:$(`keybindings.tapPresentationGuide`)}],onPick:e=>void k_(t,`prefixTap`,e)}),(0,V.jsx)(Aj,{label:$(`keybindings.prefixTitle`,{prefix:o}),hint:$(`keybindings.prefixHint`,{prefix:o,timeout:r.prefix.timeoutMs})})]}),(0,V.jsxs)(kj,{title:$(`keybindings.configFile`),hint:`${$(`keybindings.hint`)} ${z(`prefs.keysYaml`)}`,children:[(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:`font-mono break-all`,children:r.path+(r.exists?``:$(`keybindings.notCreated`))})}),!r.exists&&(0,V.jsx)(Aj,{label:z(`keys.createFile`),hint:$(`keybindings.createHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>void LN(t),children:z(`keys.createFile`)})}),(0,V.jsx)(Aj,{label:z(`keys.agent`),hint:z(i?`keys.agentFailed`:`keys.agentHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>{a(!1),LM(e,z(`keys.agentPrompt`,{path:r.path})).catch(()=>a(!0))},children:z(`keys.agent`)})})]}),r.exists&&(0,V.jsxs)(kj,{title:$(`keybindings.overridesApplied`),children:[r.applied.length===0&&(0,V.jsx)(Aj,{label:$(`keybindings.none`)}),r.applied.map(e=>(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:`font-mono`,children:e.id}),hint:`${e.keys.length>0?e.keys.join(` / `):$(`keybindings.unbound`)} (${$(`keybindings.defaultKeys`,{keys:e.defaultKeys.join(` / `)})})`},e.id))]}),r.warnings.length>0&&(0,V.jsx)(kj,{title:$(`keybindings.warnings`),children:r.warnings.map(e=>(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:`text-warning`,children:e})},e))}),r.plugins.length>0&&(0,V.jsx)(kj,{title:z(`keys.pluginChords`),children:r.plugins.map(e=>(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:`font-mono`,children:e.chord}),hint:(0,V.jsx)(`span`,{className:`font-mono`,children:`${e.kind}:${e.target}`})},e.chord))}),(0,V.jsx)(`p`,{className:wA,children:$(`keybindings.fixed`,{ids:s.join(`, `)})})]})}var zN=`/assets/pulse-3XJkP4CJ.wav`;function BN(e,t){return e===`error`||t}function VN(e,t){return t||e.kind!==`done`||e.turnEnd!==!0}function HN(e,t){return t&&e.silent!==!0}function UN(e){return e===`permission_needed`?`needs_input`:e===`error`||e===`rate_limited`||e===`dead`?`error`:e===`turn_complete`?`done`:null}function WN(e,t,n,r){if(e===null)return[];let i=[];for(let[a,o]of t){if(a===n||e.get(a)===o)continue;let t=r(o);t&&i.push({key:a,kind:t})}return i}function GN(){return window.isSecureContext&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}var KN=()=>navigator.serviceWorker.register(`sw.js`);async function qN(e){if(!GN())return`unsupported`;if(Notification.permission===`denied`)return`blocked`;let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();if(!t)return`off`;let{subscribed:n}=await e.request(`push.status`,{endpoint:t.endpoint});return n?`on`:`off`}async function JN(e){if(!GN())return`unsupported`;if(await Notification.requestPermission()!==`granted`)return`blocked`;let t=await KN();await navigator.serviceWorker.ready;let{publicKey:n}=await e.request(`push.key`),r=await t.pushManager.getSubscription();return r?.options.applicationServerKey&&$N(r.options.applicationServerKey)!==n&&(await r.unsubscribe(),r=null),r??=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:QN(n)}),await e.request(`push.subscribe`,{subscription:r.toJSON()}),`on`}async function YN(e){let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();return t&&(await e.request(`push.unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),`off`}async function XN(e,t,n,r){let i={body:r,tag:`task:${e}:${t}`,icon:`icon-192.png`,data:{taskId:e}},a=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;a?await a.showNotification(`Rove — ${n}`,i):new Notification(`Rove — ${n}`,i)}function ZN(e){let t=new URLSearchParams(window.location.search),n=t.get(`task`);if(n){t.delete(`task`);let r=t.toString();history.replaceState(null,``,`${window.location.pathname}${r?`?${r}`:``}${window.location.hash}`),e.selectWhenListed(n)}if(!(`serviceWorker`in navigator))return()=>{};let r=t=>{let n=t.data;n?.type===`rove.openTask`&&typeof n.taskId==`string`&&n.taskId&&e.selectWhenListed(n.taskId)};return navigator.serviceWorker.addEventListener(`message`,r),()=>navigator.serviceWorker.removeEventListener(`message`,r)}function QN(e){let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.charCodeAt(0))}function $N(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var eP={done:`✓`,needs_input:`?`,error:`✕`};function tP(e){let t=new Audio(zN);t.volume=Math.min(1,Math.max(0,e)),t.play().catch(()=>void 0)}function nP(e,t,n){!document.hidden||typeof Notification>`u`||Notification.permission!==`granted`||XN(e,t,n,eP[t]).catch(()=>void 0)}function rP(){typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission()}function iP(e){let t=new Map;for(let n of e.tasks)n.activity&&t.set(n.id,n.activity.state);return t}function aP(e){let t=(0,g.useRef)(null);(0,g.useEffect)(()=>{let n=()=>{let n=e.tasks.get();if(!n)return;let r=iP(n),i=WN(t.current,r,null,UN);t.current=r;let{prefs:a}=T_.get();if(!a.crossTask)return;let o=e.selection.get().taskId,s=new Map(n.tasks.map(e=>[e.id,e.label]));for(let{key:e,kind:t}of i){if(e===o||!VN({kind:t,turnEnd:!0},a.finishedAlerts))continue;let n=s.get(e)??e;BN(t,a.toast)&&G(`${eP[t]} ${n}`,t===`error`?`error`:`info`),HN({},a.sound)&&(tP(a.soundVolume),nP(e,t,n))}};return n(),e.tasks.subscribe(n)},[e])}function oP({client:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(null);(0,g.useEffect)(()=>{qN(e).then(n,()=>n(`off`))},[e]);let a=t=>{i(null),(t?JN(e):YN(e)).then(n,e=>i(e instanceof Error?e.message:String(e)))},o=r?z(`prefs.pushFailed`,{error:r}):z(t===`unsupported`?`prefs.pushUnsupported`:t===`blocked`?`prefs.pushBlocked`:`prefs.pushHint`);return(0,V.jsx)(jj,{label:z(`prefs.push`),hint:o,checked:t===`on`,disabled:t===null||t===`unsupported`||t===`blocked`,onChange:a})}function sP({model:e}){let{client:t}=e,n=A_(),{prefs:r}=n,i=(e,n)=>void k_(t,e,n);return(0,V.jsxs)(kj,{children:[(0,V.jsx)(jj,{label:$(`general.toast`),hint:z(`settings.notifications.toastNote`),checked:r.toast,onChange:e=>i(`toast`,e)}),(0,V.jsx)(jj,{label:$(`general.sound`),hint:z(`prefs.soundHint`),checked:r.sound,onChange:e=>{e&&rP(),i(`sound`,e)}}),(0,V.jsx)(Nj,{label:z(`settings.notifications.volume`),hint:z(`prefs.soundVolumeHint`),value:r.soundVolume,picks:j_(n,`soundVolume`).map(e=>({value:e,label:`${Math.round(e*100)}%`})),onPick:e=>{T_.get().prefs.sound&&tP(e),i(`soundVolume`,e)}}),(0,V.jsx)(jj,{label:$(`general.crossTask`),hint:$(`general.crossTaskHint`),checked:r.crossTask,onChange:e=>i(`crossTask`,e)}),(0,V.jsx)(jj,{label:$(`general.finishedAlerts`),hint:$(`general.finishedAlertsHint`),checked:r.finishedAlerts,onChange:e=>i(`finishedAlerts`,e)}),(0,V.jsx)(oP,{client:t})]})}var cP={kanban:`kanban`,issues:`issues`};function lP({model:e}){let t=v(e.installedMods),[n,r]=(0,g.useState)(()=>Ns(e,`builtinMods.list`)?.mods??null);if((0,g.useEffect)(()=>{Fs(e,`builtinMods.list`).then(e=>r(e.mods),()=>r([])),e.refreshMods()},[e]),!n||n.length===0)return null;let i=n=>{let r=!t.has(n.id);e.client.request(`builtinMod.setInstalled`,{id:n.id,installed:r}).then(()=>(!r&&on.get()===cP[n.id]&&on.set(null),e.refreshMods())).catch(e=>G(K(e),`error`))};return(0,V.jsx)(kj,{title:z(`settings.plugins.builtIn`),hint:z(`settings.plugins.builtInHint`),children:n.map(e=>(0,V.jsx)(Aj,{label:e.name,hint:e.description,inline:!0,children:(0,V.jsx)(Oj,{on:t.has(e.id),"aria-label":z(`settings.plugins.turnOn`,{name:e.name}),onClick:()=>i(e)})},e.id))})}function uP({model:e}){let{client:t}=e,[n,r]=(0,g.useState)(()=>Ns(t,`plugins.list`)?.plugins??null),i=(0,g.useCallback)(()=>Fs(t,`plugins.list`).then(e=>r(e.plugins),e=>G(K(e),`error`)),[t]);return(0,g.useEffect)(()=>{i()},[i]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(lP,{model:e}),(0,V.jsx)(kj,{title:z(`settings.plugins.registered`),children:n?n.length===0?(0,V.jsx)(`p`,{className:NA,children:z(`settings.plugins.empty`)}):n.map(e=>(0,V.jsx)(Aj,{label:e.id,hint:[e.version,e.linked?z(`settings.plugins.linked`):null,e.platformOk===!1?z(`settings.plugins.unsupportedPlatform`):null].filter(Boolean).join(`, `),inline:!0,children:(0,V.jsx)(Oj,{on:e.enabled,"aria-label":e.id,onClick:()=>void t.request(`plugin.setEnabled`,{id:e.id,enabled:!e.enabled}).then(i).catch(e=>G(K(e),`error`))})},e.id)):(0,V.jsx)(`p`,{className:NA,children:z(`preview.loading`)})})]})}function dP(e){let[t,n]=(0,g.useState)(e.tier.engine),[r,i]=(0,g.useState)(e.tier.model??``),[a,o]=(0,g.useState)(e.tier.effort??``),s=e.engines.find(e=>e.id===t);return(0,V.jsxs)(`form`,{className:hj,onSubmit:n=>{n.preventDefault(),e.onSave(t,s?.takesModel?r.trim():``,a)},onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),e.onCancel())},children:[(0,V.jsx)(fA,{label:$(`sections.engines`),value:t,picks:e.engines.map(e=>({value:e.id,label:e.name})),onPick:t=>{let r=e.engines.find(e=>e.id===t);n(t),r&&!r.effortLevels.includes(a)&&o(``),r&&!r.takesModel&&i(``)}}),s&&s.effortLevels.length>0&&(0,V.jsx)(fA,{label:z(`prefs.tierEffort`),value:a,picks:[``,...s.effortLevels].map(e=>({value:e,label:e||$(`autoRouting.engineDefault`)})),onPick:o}),s?.takesModel&&(0,V.jsx)(`input`,{className:`rounded-sm border-hairline border-line bg-paper px-2.5 py-1.5 font-sans text-body text-ink focus-visible:border-line-active focus-visible:outline-none`,value:r,spellCheck:!1,placeholder:$(`autoRouting.engineDefault`),"aria-label":z(`prefs.tierModel`),onChange:e=>i(e.target.value)}),(0,V.jsxs)(`div`,{className:zA,children:[(0,V.jsx)(H,{onClick:e.onCancel,children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:`filled`,type:`submit`,children:$(`action.save`)})]})]})}function fP({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`autoRouting.get`)??null),[r,i]=(0,g.useState)(null),a=(0,g.useCallback)(()=>Fs(e,`autoRouting.get`).then(n,e=>G(K(e),`error`)),[e]);(0,g.useEffect)(()=>{a()},[a]);let o=(t,n)=>e.request(t,n).then(a).catch(e=>G(K(e),`error`));if(!t)return(0,V.jsx)(`p`,{className:NA,children:z(`preview.loading`)});let s=t.classifier,c=[{value:`off`,label:$(`autoRouting.classifierOff`)},{value:`jev`,label:`jev`},...s.canCustom||s.mode===`custom`?[{value:`custom`,label:$(`autoRouting.classifierCustomLabel`)}]:[]],l=s.mode===`off`?$(`autoRouting.classifierOffHint`):s.mode===`jev`?$(`autoRouting.classifierJevHint`):$(`autoRouting.classifierCustomHint`),u=s.keySource===`env`?$(`autoRouting.keyPresentEnv`,{env:s.keyEnv??``}):s.keySource===`file`?$(`autoRouting.keySaved`):s.keyConfigured?$(`autoRouting.keyMissing`):$(`autoRouting.keyCustomUnused`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(kj,{hint:$(`autoRouting.hint`),children:[!t.configured&&(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:`text-warning`,children:$(`autoRouting.unconfigured`)})}),t.tiers.map(e=>(0,V.jsxs)(`div`,{className:pj,children:[(0,V.jsxs)(`div`,{className:mj,children:[(0,V.jsx)(`span`,{className:AA,children:dA(`tier.${e.tier}`)}),(0,V.jsx)(`span`,{className:`${jA} min-w-0 truncate`,children:[e.engineName,e.model??$(`autoRouting.engineDefault`),e.effort??$(`autoRouting.engineDefault`)].join(` · `)}),(0,V.jsx)(H,{className:`ml-auto`,onClick:()=>i(r===e.tier?null:e.tier),children:z(`prefs.tierEdit`)})]}),(0,V.jsx)(`span`,{className:jA,children:dA(`tierDesc.${e.tier}`)}),(0,V.jsx)(`span`,{className:`text-meta ${e.block?`text-warning`:`text-success`}`,children:e.block?$(`autoRouting.unavailable`,{reason:e.block}):$(`autoRouting.ready`)}),r===e.tier&&(0,V.jsx)(dP,{tier:e,engines:t.engines,onCancel:()=>i(null),onSave:(t,n,r)=>{i(null),o(`autoRouting.setTier`,{tier:e.tier,engine:t,model:n,effort:r})}})]},e.tier))]}),(0,V.jsxs)(kj,{title:$(`autoRouting.classifierTitle`),hint:$(`autoRouting.classifierHint`),children:[(0,V.jsx)(Aj,{label:(0,V.jsx)(`span`,{className:s.mode===`off`?`text-muted`:`text-warning`,children:$(`autoRouting.classifierDataFlow`)})}),(0,V.jsx)(Nj,{label:$(`autoRouting.classifierLabel`),hint:l.replace(/^[—\s]+/,``),value:s.mode,picks:c,onPick:e=>void o(`autoRouting.setClassifier`,{mode:e})})]}),(0,V.jsxs)(kj,{title:z(`prefs.classifierConnection`),hint:z(`prefs.editInTui`),children:[(0,V.jsx)(Pj,{label:$(`autoRouting.endpointLabel`),value:s.endpointHost||z(`prefs.unset`)}),(0,V.jsx)(Pj,{label:$(`autoRouting.thresholdLabel`),value:s.threshold.toFixed(2)}),(0,V.jsx)(Aj,{label:$(`autoRouting.keyLabel`),hint:u})]})]})}var pP=[{id:`preferences`,sections:[`general`,`appearance`,`notifications`,`snippets`,`keys`]},{id:`agents`,sections:[`engines`,`autoRouting`,`connectors`,`plugins`]},{id:`more`,sections:[`about`,`feedback`,`dev`]}],mP=e=>({section:e??`general`,drilled:e!==void 0});function hP(e,t){return t&&e.drilled?`list`:`close`}var gP=e=>e.split(`
117
- `,1)[0]??``;function _P(e){let[t,n]=(0,g.useState)(e.editing?.name??``),[r,i]=(0,g.useState)(e.editing?.text??``),[a,o]=(0,g.useState)(!1),s=zD.test(t)&&r.trim()!==``;return(0,V.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:n=>{n.preventDefault(),s&&(o(!0),LD(e.client,{name:t,text:r}).then(e.onDone).catch(e=>{G(K(e),`error`),o(!1)}))},children:[(0,V.jsxs)(`label`,{className:IA,children:[(0,V.jsx)(`span`,{className:LA,children:z(`snippets.name`)}),(0,V.jsx)(`input`,{className:`${PA} w-full font-mono`,value:t,maxLength:32,spellCheck:!1,autoComplete:`off`,autoFocus:!e.editing,readOnly:e.editing!==void 0,placeholder:z(`snippets.namePlaceholder`),onChange:e=>n(e.target.value)}),t!==``&&!zD.test(t)&&(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:z(`snippets.badName`)})]}),(0,V.jsxs)(`label`,{className:IA,children:[(0,V.jsx)(`span`,{className:LA,children:z(`snippets.text`)}),(0,V.jsx)(`textarea`,{className:`${PA} ${RA} w-full`,rows:5,value:r,maxLength:8e3,placeholder:z(`snippets.textPlaceholder`),onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:zA,children:[(0,V.jsx)(H,{onClick:e.onDone,children:z(`snippets.cancel`)}),(0,V.jsx)(H,{type:`submit`,disabled:a||!s,children:z(`snippets.save`)})]})]})}function vP({model:e}){let{client:t}=e,n=FD(),[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>void ID(t).catch(()=>void 0),[t]),(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(kj,{children:[n.length===0&&r===null&&(0,V.jsx)(Aj,{label:z(`snippets.empty`)}),n.map(e=>(0,V.jsxs)(Aj,{label:(0,V.jsxs)(`span`,{className:`font-mono`,children:[`@`,e.name]}),hint:gP(e.text),children:[(0,V.jsx)(H,{onClick:()=>i(e),children:z(`snippets.edit`)}),(0,V.jsx)(H,{onClick:()=>void RD(t,e.name).then(()=>{i(null),G(z(`snippets.removed`,{name:e.name}))}).catch(e=>G(K(e),`error`)),children:z(`snippets.remove`)})]},e.name))]}),r===null?(0,V.jsx)(`div`,{className:zA,children:(0,V.jsx)(H,{onClick:()=>i(`new`),children:z(`snippets.add`)})}):(0,V.jsx)(_P,{client:t,editing:r===`new`?void 0:r,onDone:()=>i(null)},r===`new`?`new`:r.name)]})}var yP=e=>e>=95?`crit`:e>=75?`warn`:`ok`,bP=e=>String(e).padStart(2,`0`);function xP(e,t){if(e==null||e<=t)return``;let n=new Date(e),r=`${bP(n.getHours())}:${bP(n.getMinutes())}`;return e-t<864e5?`→ ${r}`:`→ ${n.getMonth()+1}/${n.getDate()} ${r}`}function SP(e,t){let n=e.windows.find(e=>e.kind===`session`)??e.windows[0];return n?{label:n.label,percentText:`${n.percent}%`,resetText:xP(n.resetsAt,t),tone:yP(n.percent)}:null}function CP(e){if(!e)return null;let t=e.contextWindowTokens;if(t===void 0||t<=0)return null;let n=Math.min(100,Math.max(0,Math.round(e.contextTokens/t*100)));return{label:`ctx`,percentText:`${n}%${e.approximate?`~`:``}`,resetText:``,tone:yP(n)}}function wP(e){return!e||e.inputTokens===void 0&&e.outputTokens===void 0?null:{label:`Σ`,text:TP((e.inputTokens??0)+(e.outputTokens??0))}}function TP(e){return e<1e3?String(e):e<1e6?`${Math.floor(e/1e3)}k`:`${(Math.floor(e/1e5)/10).toFixed(1)}M`}var EP=1e4;function DP({percentText:e,tone:t}){let n=Math.min(100,Math.max(0,Number.parseInt(e,10)||0));return(0,V.jsx)(`span`,{className:Rt(t),style:{"--fill":`${n}%`}})}function OP({client:e,taskId:t,tabId:n,inset:r=!0}){let i=v(e.conn),[a,o]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(i.state!==`open`)return;let r=!0,a=()=>e.request(`usage.get`,t&&n?{taskId:t,tabId:n}:{}).then(e=>{r&&o(e)}).catch(()=>{});a();let s=window.setInterval(a,EP);return()=>{r=!1,window.clearInterval(s)}},[e,i.state,t,n]);let s=CP(a?.context),c=wP(a?.context),l=Date.now(),u=(a?.usage??[]).flatMap(e=>{let t=SP({capturedAt:e.capturedAt,windows:e.windows},l);return t?[{vendor:e.vendor,name:e.name,chip:t}]:[]});return!s&&!c&&u.length===0?null:(0,V.jsxs)(`div`,{className:`${Ft} ${r?`px-3.5`:``}`,children:[s&&(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{children:s.label}),(0,V.jsx)(DP,{percentText:s.percentText,tone:s.tone}),(0,V.jsx)(`span`,{className:Lt[s.tone],children:s.percentText})]}),c&&(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{children:c.label}),(0,V.jsx)(`span`,{className:`text-muted`,children:c.text})]}),u.map(({vendor:e,name:t,chip:n})=>(0,V.jsxs)(H,{variant:`row`,className:`${It} cursor-pointer hover:text-ink`,title:`${t} · ${n.label} ${n.percentText} ${n.resetText}`.trim(),"aria-label":`${z(`usage.open`)}: ${t}`,onClick:()=>{yn(),ha(`usage`)},children:[(0,V.jsx)(`span`,{children:t}),(0,V.jsx)(`span`,{className:Lt[n.tone],children:n.percentText})]},e))]})}var kP={general:e=>(0,V.jsx)(NN,{model:e}),appearance:e=>(0,V.jsx)(QM,{model:e}),notifications:e=>(0,V.jsx)(sP,{model:e}),snippets:e=>(0,V.jsx)(vP,{model:e}),keys:e=>(0,V.jsx)(RN,{model:e}),engines:e=>(0,V.jsx)(wN,{client:e.client}),autoRouting:e=>(0,V.jsx)(fP,{client:e.client}),connectors:e=>(0,V.jsx)(pN,{model:e}),plugins:e=>(0,V.jsx)(uP,{model:e}),about:e=>(0,V.jsx)(IM,{client:e.client}),feedback:e=>(0,V.jsx)(AN,{client:e.client}),dev:e=>(0,V.jsx)(hN,{client:e.client})},AP={general:`sections.general`,engines:`sections.engines`,autoRouting:`sections.autoRouting`,plugins:`sections.plugins`,keys:`sections.keys`,feedback:`sections.feedback`,dev:`sections.dev`},jP=e=>{let t=AP[e];return t?$(t):z(`settings.sections.${e}`)};function MP(e){return(0,V.jsxs)(`nav`,{className:_A,"aria-label":z(`settings.title`),children:[(0,V.jsx)(`h1`,{className:vA,children:z(`settings.title`)}),pP.map(t=>(0,V.jsxs)(`div`,{className:yA,children:[(0,V.jsx)(`p`,{className:bA,children:z(`settings.groups.${t.id}`)}),t.sections.map(n=>(0,V.jsxs)(H,{variant:`row`,className:xA(!e.narrow&&e.current===n,t.id===`more`),"aria-current":!e.narrow&&e.current===n?`page`:void 0,onClick:()=>e.onPick(n),children:[jP(n),(0,V.jsx)(Ma,{right:!0,className:SA})]},n))]},t.id))]})}function NP({model:e,section:t}){B();let[n,r]=(0,g.useState)(()=>mP(t)),i=xa(),a=()=>hP(n,i)===`list`?r({...n,drilled:!1}):yn();(0,g.useEffect)(()=>{let e=document.querySelector(`.dialog`);e&&!e.contains(document.activeElement)&&e.focus()},[]),(0,g.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),a())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let o=!i||!n.drilled,s=!i||n.drilled;return(0,V.jsx)(`div`,{className:mA,onMouseDown:e=>e.target===e.currentTarget&&yn(),children:(0,V.jsxs)(`dialog`,{tabIndex:-1,open:!0,className:hA,"aria-label":z(`settings.title`),onKeyDown:e=>{let t=e.target;e.key===`Escape`&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.blur(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation())},children:[(0,V.jsx)(H,{variant:`row`,className:gA,"aria-label":z(`dialog.close`),title:z(`dialog.close`),onClick:yn,children:`×`}),i&&n.drilled&&(0,V.jsx)(H,{variant:`row`,className:`hidden flex-none items-center px-4 py-3 pr-12 text-left font-mono text-meta font-bold text-accent w-narrow:flex touch:min-h-11`,onClick:a,children:`‹ ${z(`settings.title`)}`}),o&&(0,V.jsx)(MP,{current:n.section,narrow:i,onPick:e=>r({section:e,drilled:!0})}),i&&o&&(0,V.jsx)(OP,{client:e.client,taskId:null,tabId:null,inset:!1}),s&&(0,V.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto scrollbar-none`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col gap-7 px-8 pt-7 pb-10 w-narrow:gap-6 w-narrow:px-4 w-narrow:pt-1 w-narrow:pb-10`,children:[(0,V.jsxs)(`header`,{className:`flex flex-col gap-1 pr-8`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-display font-semibold normal-nums text-ink`,children:jP(n.section)}),(0,V.jsx)(`p`,{className:`m-0 text-body text-muted`,children:z(`settings.pages.${n.section}`)})]}),(0,V.jsx)(`div`,{className:`flex flex-col gap-7 w-narrow:gap-6`,children:kP[n.section](e)})]})},n.section)]})})}function PP(e){let t=e.todos;return!t||t.length===0?null:{done:t.filter(e=>e.done).length,total:t.length}}function FP(e){return(e.todos??[]).filter(e=>!e.done)}function IP(e){let t=FP(e);return t.length===0?null:`Please work through these remaining todos for this task, and tell me what you did for each:\n${t.map(e=>`- ${e.text}`).join(`
118
- `)}`}var LP=/LAND_CONFLICT/,RP=/MAIN_CHECKOUT_DIRTY/,zP=/SYNC_CONFLICT(?:: )?(.*)/,BP=/SYNC_WORKTREE_DIRTY(?:: )?(.*)/;function VP(e){let t=K(e);return LP.test(t)?q(`worktrees`,`land.conflict`,{files:t}):RP.test(t)?q(`worktrees`,`land.dirtyBase`):q(`worktrees`,`land.failed`,{error:t})}async function HP(e,t,n){if(t.machine){UP(e,t,t.machine.label,n);return}let r;try{r=await e.client.request(`task.landPreflight`,{taskId:t.id})}catch(e){G(q(`worktrees`,`land.failed`,{error:K(e)}),`error`);return}if(r.refusal){G(r.refusal===`MAIN_CHECKOUT_DIRTY`?q(`worktrees`,`land.dirtyBase`):q(`worktrees`,`land.failed`,{error:r.message??r.refusal}),`error`);return}let i=t.branch||t.title,a=FP(e.tasks.get()?.tasks.find(e=>e.id===t.id)??{}).length;W.set((0,V.jsx)(sr,{title:q(`worktrees`,`land.confirmTitle`),body:[q(`worktrees`,r.ahead===1?`land.confirmBodyOne`:`land.confirmBody`,{branch:i,landedOn:r.landedOn,commits:r.ahead??`?`}),...a>0?[z(`files.landTodos`,{count:a})]:[]].join(`
116
+ `):[],[a]),s=(0,g.useRef)(new Set),c=(0,g.useCallback)(async e=>{let n=e===``?{}:{machine:e},r=await t.request(`github.status`,n).catch(e=>({status:null,reason:`failed`,message:K(e)}));i(t=>({...t,[e]:r}))},[t]),l=(0,g.useCallback)(()=>Promise.all([``,...o].map(c)).then(()=>{}),[c,o]);return(0,g.useEffect)(()=>{l()},[l]),(0,g.useEffect)(()=>{let e=new Set(Object.entries(r).flatMap(([e,t])=>rN(t.status)?[e]:[])),t=[...s.current].some(t=>!e.has(t));if(s.current=e,t&&l(),e.size===0)return;let n=window.setTimeout(()=>{for(let t of e)c(t)},nN);return()=>window.clearTimeout(n)},[r,c,l]),{machines:n,probes:r,refresh:l,probe:c,act:(0,g.useCallback)(async(e,n)=>{try{let r=await t.request(e,n);return r.ok||G(r.message,`error`),r}catch(e){return G(K(e),`error`),null}},[t])}}var aN={same:`markSame`,different:`markDifferent`,signedOut:`markSignedOut`,noGh:`markNoGh`,outdated:`markOutdated`,offline:`markOffline`,denied:`markDenied`,failed:`markFailed`},oN=(e,t)=>z(`settings.connectors.${e}`,t),sN={same:`text-diff-added`,signedOut:`text-diff-removed`,failed:`text-diff-removed`,denied:`text-diff-removed`,different:`text-warning`,outdated:`text-warning`,offline:`text-muted`,noGh:`text-muted`,loading:`text-muted`};function cN(e,t){return e===`loading`?oN(`loading`):oN(aN[e],{login:t?.account??``})}function lN(e){if(!e?.gh)return``;let t=e.ssh.ok?`✓ ${e.ssh.user??``}`.trim():`✗`;return oN(`detail`,{protocol:e.protocol??`—`,ssh:t})}function uN(){return(0,V.jsx)(`svg`,{className:`flex-none`,viewBox:`0 0 16 16`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{fill:`currentColor`,d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})})}function dN(e){navigator.clipboard.writeText(e).then(()=>G(oN(`codeCopied`)),()=>{})}function fN({login:e,onCancel:t}){return e.state===`failed`?(0,V.jsxs)(`div`,{className:HA,children:[(0,V.jsx)(`span`,{className:`text-muted`,children:oN(`loginFailed`,{error:e.error??``})}),(0,V.jsx)(H,{className:`ml-auto`,onClick:t,children:oN(`dismiss`)})]}):e.state===`syncing`?(0,V.jsx)(`div`,{className:HA,children:(0,V.jsx)(`span`,{className:`text-muted`,children:oN(`syncing`)})}):(0,V.jsxs)(`div`,{className:HA,children:[e.code?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`font-mono font-normal normal-nums rounded-sm border-hairline border-dashed border-line px-2 py-0.5 text-display tracking-code`,title:oN(`codeHint`),onClick:()=>dN(e.code??``),children:e.code}),(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:oN(`openGithub`)})]}):(0,V.jsx)(`span`,{className:`text-muted`,children:oN(`loading`)}),(0,V.jsx)(H,{className:`ml-auto`,onClick:t,children:z(`dialog.cancel`)})]})}function pN(e){let t=tN(e.probe,e.machine,e.rove),n=e.probe?.status??null,r=rN(n),i=t===`different`||t===`signedOut`,a=n?.login;return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:fj,children:[(0,V.jsxs)(`div`,{className:pj,children:[(0,V.jsx)(`span`,{className:MA,children:e.name}),(0,V.jsx)(`span`,{className:mj(),title:[n?.authDetail,n?.ssh.detail].filter(Boolean).join(`, `)||void 0,children:lN(n)})]}),(0,V.jsx)(`span`,{className:`whitespace-nowrap text-meta ${sN[t]}`,title:e.probe?.message,children:cN(t,n)}),e.onSync&&i&&e.rove&&!r&&(0,V.jsx)(H,{variant:`action`,disabled:e.busy,onClick:e.onSync,children:oN(`useRove`)}),e.onLogin&&i&&!r&&(0,V.jsx)(H,{variant:`action`,disabled:e.busy,onClick:e.onLogin,children:oN(`loginThere`)})]}),a&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsx)(fN,{login:a,onCancel:e.onCancel})})]})}function mN({model:e}){let{machines:t,probes:n,refresh:r,probe:i,act:a}=iN(e),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),u=n[``],d=u?.status?.account??null,f=rN(u?.status),p=async(e,t)=>{s(e);try{await t()}finally{s(null)}},m=e=>p(e,async()=>{await a(`github.login`,e===``?{}:{machine:e}),await i(e)}),h=e=>p(e,async()=>{await a(`github.login`,e===``?{cancel:!0}:{machine:e,cancel:!0}),await i(e)}),_=e=>p(e,async()=>{(await a(`github.sync`,{machine:e}))?.ok&&G(oN(`synced`,{machine:e,login:d??``})),await i(e)}),v=()=>p(``,async()=>{(await a(`github.logout`,{}))?.ok&&l(!1),await r()});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(jj,{children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Mj,{label:(0,V.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,V.jsx)(uN,{}),`GitHub`]}),hint:oN(`githubDescription`),children:d?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:PA,children:[`@`,d]}),(0,V.jsx)(H,{variant:`action`,disabled:o!==null,onClick:()=>l(!0),children:oN(`disconnect`)})]}):!f&&(0,V.jsx)(H,{variant:`filled`,disabled:o!==null||!u,onClick:()=>void m(``),children:oN(`connect`)})}),c&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-inset px-3 py-2.5 [&_p]:m-0 [&_p]:text-meta [&_p]:text-muted`,children:[(0,V.jsx)(`p`,{children:oN(`disconnectBody`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2.5`,children:[(0,V.jsx)(H,{onClick:()=>l(!1),children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:`danger`,disabled:o!==null,onClick:()=>void v(),children:oN(`disconnect`)})]})]})}),!d&&u?.status?.login&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsx)(fN,{login:u.status.login,onCancel:()=>void h(``)})})]})}),d&&(0,V.jsxs)(jj,{title:oN(`machines`),children:[(0,V.jsx)(pN,{name:oN(`thisMachine`),probe:u,machine:null,rove:d,busy:o!==null,onCancel:()=>void h(``)}),t.map(e=>(0,V.jsx)(pN,{name:e.alias,probe:n[e.alias],machine:e.state,rove:d,busy:o!==null,onSync:()=>void _(e.alias),onLogin:()=>void m(e.alias),onCancel:()=>void h(e.alias)},e.alias)),(0,V.jsx)(`div`,{className:`py-2.5`,children:(0,V.jsx)(H,{onClick:()=>void r(),children:oN(`refresh`)})})]})]})}function hN({model:e}){return(0,V.jsx)(mN,{model:e})}var gN=[{key:`remoteProjects`,label:`dev.remote`,hint:`dev.remoteHint`},{key:`autoStatus`,label:`dev.autoStatus`,hint:`dev.autoStatusHint`},{key:`dispatcher`,label:`dev.dispatcher`,hint:`dev.dispatcherHint`}];function _N({client:e}){let{prefs:t}=A_(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),o=async()=>{if(n){a(!0);try{if(n===`reset`){await e.request(`dev.reset`),localStorage.removeItem(`rove.prefs`),window.location.reload();return}await e.request(`daemon.restart`),G($(`restart.done`)),r(null)}catch(e){G(K(e),`error`)}finally{a(!1)}}},s=(e,t,a,s,c)=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(Mj,{label:t,hint:a,children:(0,V.jsx)(H,{variant:`action`,onClick:()=>r(e),children:s})}),n===e&&(0,V.jsx)(`div`,{className:`pb-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-inset px-3 py-2.5 [&_p]:m-0 [&_p]:text-meta [&_p]:text-muted`,children:[(0,V.jsx)(`strong`,{children:$(`${e}.title`)}),(0,V.jsx)(`p`,{children:z(e===`reset`?`prefs.resetBody`:`prefs.restartBody`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2.5`,children:[(0,V.jsx)(H,{onClick:()=>r(null),children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:c?`danger`:`filled`,disabled:i,onClick:()=>void o(),children:s})]})]})})]});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(jj,{title:$(`dev.experimental`),children:gN.map(n=>(0,V.jsx)(Nj,{label:$(n.label),hint:$(n.hint),checked:t[n.key],onChange:t=>void k_(e,n.key,t)},n.key))}),(0,V.jsxs)(jj,{hint:$(`dev.doctorHint`),children:[s(`restart`,$(`dev.restart`),z(`prefs.restartHint`),z(`prefs.restartButton`),!1),s(`reset`,$(`dev.reset`),z(`prefs.resetHint`),z(`prefs.resetButton`),!0)]})]})}function vN(e){return e.binaryFound===void 0?{key:`settings.engines.status.checking`,tone:`unknown`}:e.binaryFound===null?{key:`settings.engines.status.unknown`,tone:`unknown`}:e.binaryFound?e.configIssue?{key:`settings.engines.status.integrationBlocked`,tone:`error`}:e.login===`no`?{key:`settings.engines.status.signIn`,tone:`attention`}:e.hooks===`outdated`?{key:`settings.engines.status.integrationOutdated`,tone:`attention`}:e.hooks===`not-installed`?{key:`settings.engines.status.integrationMissing`,tone:`attention`}:{key:`settings.engines.status.ready`,tone:`ready`}:e.commandChosen?{key:`settings.engines.status.notOnPath`,tone:`attention`}:{key:`settings.engines.status.notInstalled`,tone:`absent`}}var yN=_([]),bN=3e4;function xN(e){return e.request(`skill.missing`).then(e=>yN.set(e.engines),()=>{})}function SN(e){(0,g.useEffect)(()=>{let t=e.onOpen(()=>void xN(e)),n=window.setInterval(()=>void xN(e),bN);return()=>{t(),window.clearInterval(n)}},[e])}function CN(e){return e.request(`skill.install`).then(e=>{e.error&&G($(`engines.skill.failed`,{reason:e.error}),`error`)}).catch(e=>G(K(e),`error`)).then(()=>xN(e))}function wN(e){return vN({binaryFound:e.binaryFound,login:e.login,hooks:e.hooks,configIssue:e.configIssue,commandChosen:e.custom||e.customized})}var TN={ready:`ready`,attention:`attention`,error:`error`,absent:`absent`,unknown:`absent`};function EN({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`engines.settings`)?.engines??null),[r,i]=(0,g.useState)(null),a=(0,g.useCallback)(()=>Fs(e,`engines.settings`).then(e=>n(e.engines),e=>G(K(e),`error`)),[e]);(0,g.useEffect)(()=>{a()},[a]);let o=(t,n={})=>void e.request(t,n).then(a).catch(e=>G(K(e),`error`));return t?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`p`,{className:EA,children:$(`engines.hint`)}),(0,V.jsxs)(`div`,{className:WA,children:[(0,V.jsxs)(`div`,{className:GA,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{children:$(`engines.defaultMark`)}),(0,V.jsx)(`span`,{children:$(`engines.available`)})]}),t.map(e=>(0,V.jsx)(DN,{engine:e,open:r===e.id,onToggleOpen:()=>i(r===e.id?null:e.id),run:o},e.id))]})]}),(0,V.jsx)(AN,{engines:t,run:o}),(0,V.jsx)(jN,{engines:t,client:e,reload:a})]}):(0,V.jsx)(`p`,{className:FA,children:z(`preview.loading`)})}function DN(e){let{engine:t,run:n}=e,r=(0,g.useId)(),i=wN(t);return(0,V.jsxs)(`div`,{className:KA,children:[(0,V.jsxs)(`div`,{className:qA,children:[(0,V.jsxs)(`button`,{type:`button`,className:JA,"aria-expanded":e.open,"aria-controls":r,onClick:e.onToggleOpen,children:[(0,V.jsx)(Ma,{right:!e.open,className:YA(e.open)}),(0,V.jsxs)(`span`,{className:XA,children:[(0,V.jsxs)(`span`,{className:ZA(!t.enabled),children:[t.name,t.renamedFrom?(0,V.jsx)(`span`,{className:QA,children:t.renamedFrom}):null,t.custom&&!t.renamedFrom?(0,V.jsx)(`span`,{className:QA,children:$(`engines.customTag`)}):null]}),(0,V.jsxs)(`span`,{className:ej(TN[i.tone]),children:[(0,V.jsx)(`span`,{className:tj(TN[i.tone]),"aria-hidden":`true`}),$(i.key.slice(9))]})]})]}),(0,V.jsx)(`div`,{className:nj,children:t.isDefault?(0,V.jsx)(`span`,{className:rj,children:$(`engines.defaultMark`)}):t.canBeDefault?(0,V.jsx)(`button`,{type:`button`,className:ij,"aria-label":z(`settings.engines.default`,{name:t.name}),onClick:()=>n(`engine.setDefault`,{id:t.id}),children:$(`engines.makeDefault`)}):null}),(0,V.jsx)(Aj,{on:t.enabled,"aria-label":z(`settings.engines.enabled`,{name:t.name}),onClick:()=>n(`engine.setEnabled`,{id:t.id,enabled:!t.enabled})})]}),e.open?(0,V.jsx)(kN,{id:r,engine:t,run:n}):null]})}function ON(e){if(e.configIssue)return $(`engines.detail.hooksBlockedHere`,{reason:e.configIssue});switch(e.hooks){case`installed`:return $(`engines.detail.hooksInstalled`);case`outdated`:return $(`engines.detail.hooksOutdated`);case`not-installed`:return e.binaryFound===!1?$(`engines.detail.hooksAwaitEngine`):$(`engines.detail.hooksMissing`);default:return $(`engines.detail.hooksUnsupported`)}}function kN(e){let{engine:t,run:n}=e,[r,i]=(0,g.useState)(null),a=t.binaryFound===!0?$(`engines.detail.programFound`,{binary:t.binary,path:t.binaryPath??t.binary}):t.binaryFound===!1?$(`engines.detail.programMissing`,{binary:t.binary}):$(`engines.detail.programUnknown`,{binary:t.binary}),o=t.login===`yes`?$(`engines.detail.signedIn`):t.login===`no`?$(`engines.detail.signedOut`):$(`engines.detail.signInUnknown`),s=[ON(t),$(t.markers?`engines.detail.markersYes`:`engines.detail.markersNo`),$(t.screen?`engines.detail.screenYes`:t.hooks===`installed`?`engines.detail.screenNotNeeded`:`engines.detail.screenNo`)];return(0,V.jsxs)(`div`,{id:e.id,className:aj,children:[(0,V.jsxs)(`dl`,{className:oj,children:[(0,V.jsx)(`dt`,{className:sj,children:$(`engines.detail.program`)}),(0,V.jsx)(`dd`,{className:cj(t.binaryFound===!1),children:a}),(0,V.jsx)(`dt`,{className:sj,children:$(`engines.detail.signIn`)}),(0,V.jsx)(`dd`,{className:cj(t.login===`no`),children:o}),(0,V.jsx)(`dt`,{className:sj,children:$(`engines.detail.reporting`)}),(0,V.jsx)(`dd`,{className:cj(!1),children:s.map(e=>(0,V.jsx)(`span`,{className:`block`,children:e},e))}),t.skill===`unsupported`?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:sj,children:$(`engines.detail.skill`)}),(0,V.jsx)(`dd`,{className:cj(t.skill!==`installed`),children:$(t.skill===`installed`?`engines.detail.skillInstalledHere`:t.skill===`outdated`?`engines.detail.skillOutdated`:`engines.detail.skillMissing`)})]}),t.custom?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:sj,children:$(`engines.detail.adapter`)}),(0,V.jsx)(`dd`,{className:cj(!1),children:t.protocol?$(`engines.detail.adapterDeclared`,{protocol:t.protocol}):$(`engines.detail.adapterGeneric`)})]}):null]}),r===null?(0,V.jsxs)(`div`,{className:lj,children:[(0,V.jsx)(H,{variant:`action`,onClick:()=>i(t.name),children:z(`settings.engines.rename`)}),t.custom||t.customized?(0,V.jsx)(H,{variant:`action`,onClick:()=>n(`engine.reset`,{id:t.id}),children:t.custom?z(`settings.engines.remove`):z(`settings.engines.reset`)}):null]}):(0,V.jsxs)(`form`,{className:lj,onSubmit:e=>{e.preventDefault(),n(`engine.rename`,{id:t.id,name:r}),i(null)},children:[(0,V.jsx)(`input`,{className:`${Zt} w-full ${uj}`,autoFocus:!0,value:r,"aria-label":z(`settings.engines.rename`),placeholder:z(`settings.engines.namePlaceholder`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i(null))}}),(0,V.jsx)(H,{variant:`filled`,type:`submit`,children:z(`settings.engines.save`)}),(0,V.jsx)(H,{variant:`action`,onClick:()=>i(null),children:z(`settings.engines.cancel`)})]})]})}function AN({engines:e,run:t}){let n=e.filter(e=>e.hooks!==`unsupported`),r=n.filter(e=>e.binaryFound!==!1),i=r.filter(e=>e.hooks===`installed`).length,a=r.length-i,o=n.filter(e=>e.hooks!==`not-installed`).length;return n.length===0?null:(0,V.jsx)(jj,{title:$(`engines.integrations.title`),hint:$(`engines.integrations.hint`),children:(0,V.jsx)(Mj,{label:$(`engines.integrations.summary`,{installed:i,total:r.length}),children:(0,V.jsxs)(`div`,{className:VA,children:[a>0?(0,V.jsx)(H,{variant:`filled`,onClick:()=>t(`engines.hooks.install`),children:$(`engines.integrations.install`,{count:a})}):(0,V.jsx)(`span`,{className:dj,children:$(`engines.integrations.upToDate`)}),o>0?(0,V.jsx)(H,{variant:`action`,onClick:()=>t(`engines.hooks.uninstall`),children:$(`engines.integrations.remove`,{count:o})}):null]})})})}function jN(e){let t=e.engines.filter(e=>e.skill!==`unsupported`),n=t.filter(e=>e.skill===`installed`).length,r=t.length-n;return(0,V.jsx)(jj,{title:$(`engines.skill.title`),hint:$(`engines.skill.hint`),children:(0,V.jsx)(Mj,{label:t.length>0?$(`engines.integrations.summary`,{installed:n,total:t.length}):$(`engines.skill.noEngines`),children:r>0?(0,V.jsx)(H,{variant:`filled`,onClick:()=>void CN(e.client).then(e.reload),children:$(`engines.skill.install`,{count:r})}):t.length>0?(0,V.jsx)(`span`,{className:dj,children:$(`engines.integrations.upToDate`)}):null})})}function MN({client:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1);return(0,V.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:a=>{a.preventDefault(),!(!t.trim()||!r.trim())&&(o(!0),e.request(`feedback.send`,{title:t.trim(),body:r}).then(e=>{G(z(`settings.feedback.sent`,{url:e.discussion?.url??``})),n(``),i(``)}).catch(e=>G(K(e),`error`)).finally(()=>o(!1)))},children:[(0,V.jsx)(`p`,{className:`m-0 ${NA}`,children:z(`settings.feedback.hint`)}),(0,V.jsxs)(`label`,{className:RA,children:[(0,V.jsx)(`span`,{className:zA,children:z(`settings.feedback.titleLabel`)}),(0,V.jsx)(`input`,{className:`${IA} w-full`,value:t,onChange:e=>n(e.target.value)})]}),(0,V.jsxs)(`label`,{className:RA,children:[(0,V.jsx)(`span`,{className:zA,children:z(`settings.feedback.body`)}),(0,V.jsx)(`textarea`,{className:`${IA} ${BA} w-full`,rows:6,value:r,onChange:e=>i(e.target.value)})]}),(0,V.jsx)(`div`,{className:VA,children:(0,V.jsx)(H,{variant:`filled`,type:`submit`,disabled:a||!t.trim()||!r.trim(),children:z(`settings.feedback.send`)})})]})}var NN=[{value:`en`,label:`English`},{value:`zh`,label:`中文`}],PN={default:`general.worktreeKindDefault`,nextToProject:`general.worktreeKindNext`,custom:`general.worktreeKindCustom`};function FN({model:e}){let{client:t}=e,n=A_(),{prefs:r,info:i}=n,a=(e,n)=>void k_(t,e,n),o=[`default`,`nextToProject`];(i.worktreeCustomPath||r.worktreeBase===`custom`)&&o.push(`custom`);let s=o.map(e=>({value:e,label:$(PN[e])}));return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(jj,{title:z(`settings.general.groupInterface`),children:[(0,V.jsx)(Fj,{label:$(`general.language`),hint:z(`prefs.languageHint`),value:r.locale,picks:NN,onPick:e=>a(`locale`,e)}),(0,V.jsx)(Nj,{label:$(`general.keyHintsShow`),hint:$(`general.keyHintsHint`),checked:r.keyHints,onChange:e=>a(`keyHints`,e)}),(0,V.jsx)(Nj,{label:$(`general.zenDefaultOn`),hint:z(`prefs.zenHint`),checked:r.zen,onChange:e=>a(`zen`,e)}),(0,V.jsx)(Fj,{label:z(`settings.general.tabStrip`),value:r.tabStrip,picks:j_(n,`tabStrip`).map(e=>({value:e,label:$(`general.tabStripMode.${e}`)})),onPick:e=>a(`tabStrip`,e)})]}),(0,V.jsxs)(jj,{title:z(`settings.general.groupFiles`),children:[(0,V.jsx)(Fj,{label:$(`general.editor`),hint:z(`settings.general.editorNote`),value:r.editorKind,picks:j_(n,`editorKind`).map(e=>({value:e,label:e})),onPick:e=>a(`editorKind`,e)}),(0,V.jsx)(Fj,{label:$(`general.worktree`),hint:$(`general.worktreeHint`),value:r.worktreeBase,picks:s,onPick:e=>a(`worktreeBase`,e)})]}),(0,V.jsx)(jj,{title:z(`settings.general.groupTerminal`),hint:$(`general.terminalHint`),children:(0,V.jsx)(IN,{client:t})})]})}function IN({client:e}){let t=A_(),n=t.options.scrollbackRows,r=n&&`min`in n?n:{min:100,max:1e5},[i,a]=(0,g.useState)(String(t.prefs.scrollbackRows));return(0,g.useEffect)(()=>a(String(t.prefs.scrollbackRows)),[t.prefs.scrollbackRows]),(0,V.jsx)(Mj,{label:z(`settings.general.scrollback`),hint:$(`general.scrollbackRowHint`),children:(0,V.jsx)(`input`,{className:LA,inputMode:`numeric`,value:i,"aria-label":$(`general.scrollbackTitle`),onChange:e=>a(e.target.value),onBlur:()=>{let n=Number(i);if(i.trim()===``||!Number.isInteger(n)){a(String(t.prefs.scrollbackRows));return}let o=Math.min(r.max,Math.max(r.min,n));o===t.prefs.scrollbackRows?a(String(o)):k_(e,`scrollbackRows`,o)},onKeyDown:e=>e.key===`Enter`&&e.currentTarget.blur()})})}[...Array.from({length:12},(e,t)=>`f${t+1}`)];var LN={"diff.review.cursor":`diff-review cursor is a fixed raw binding (j/k), not keymap-driven`,"diff.review.range":`diff-review range anchor is a fixed raw binding (v), not keymap-driven`,"diff.review.note":`diff-review note is a fixed raw binding (c), not keymap-driven`,"diff.review.send":`diff-review send is a fixed raw binding (s), not keymap-driven`,"diff.review.drop":`diff-review drop-note is a fixed raw binding (x), not keymap-driven`,"diff.review.reload":`preview reload is a fixed raw binding (r), not keymap-driven`};function RN(e,t){let n=`alternating [${e}, ${t}] pairs`;return{layout:n,validateCount:e=>e>=2&&e%2==0?null:`needs ${n} (an even number of chords — got ${e})`}}RN(`top (double-tap)`,`bottom`),RN(`down`,`up`),RN(`down`,`up`),RN(`down`,`up`),RN(`collapse`,`expand`),RN(`previous tab`,`next tab`);async function zN(e){try{(await e.request(`keybindings.createFile`)).created||G(z(`keys.exists`),`error`),await Yr(e)}catch(e){G(K(e),`error`)}}function BN({model:e}){let{client:t}=e,{prefs:n}=A_(),r=v(Kr),[i,a]=(0,g.useState)(!1);(0,g.useEffect)(()=>void Yr(t),[t]);let o=r.prefix.key??$(`keybindings.prefixDisabled`),s=Object.keys(LN).sort();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(jj,{children:[(0,V.jsx)(Fj,{label:$(`keybindings.tapPresentation`),hint:$(`keybindings.tapPresentationHint`),value:n.prefixTap,picks:[{value:`local`,label:$(`keybindings.tapPresentationLocal`)},{value:`guide`,label:$(`keybindings.tapPresentationGuide`)}],onPick:e=>void k_(t,`prefixTap`,e)}),(0,V.jsx)(Mj,{label:$(`keybindings.prefixTitle`,{prefix:o}),hint:$(`keybindings.prefixHint`,{prefix:o,timeout:r.prefix.timeoutMs})})]}),(0,V.jsxs)(jj,{title:$(`keybindings.configFile`),hint:`${$(`keybindings.hint`)} ${z(`prefs.keysYaml`)}`,children:[(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:`font-mono break-all`,children:r.path+(r.exists?``:$(`keybindings.notCreated`))})}),!r.exists&&(0,V.jsx)(Mj,{label:z(`keys.createFile`),hint:$(`keybindings.createHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>void zN(t),children:z(`keys.createFile`)})}),(0,V.jsx)(Mj,{label:z(`keys.agent`),hint:z(i?`keys.agentFailed`:`keys.agentHint`),children:(0,V.jsx)(H,{variant:`action`,onClick:()=>{a(!1),zM(e,z(`keys.agentPrompt`,{path:r.path})).catch(()=>a(!0))},children:z(`keys.agent`)})})]}),r.exists&&(0,V.jsxs)(jj,{title:$(`keybindings.overridesApplied`),children:[r.applied.length===0&&(0,V.jsx)(Mj,{label:$(`keybindings.none`)}),r.applied.map(e=>(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:`font-mono`,children:e.id}),hint:`${e.keys.length>0?e.keys.join(` / `):$(`keybindings.unbound`)} (${$(`keybindings.defaultKeys`,{keys:e.defaultKeys.join(` / `)})})`},e.id))]}),r.warnings.length>0&&(0,V.jsx)(jj,{title:$(`keybindings.warnings`),children:r.warnings.map(e=>(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:`text-warning`,children:e})},e))}),r.plugins.length>0&&(0,V.jsx)(jj,{title:z(`keys.pluginChords`),children:r.plugins.map(e=>(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:`font-mono`,children:e.chord}),hint:(0,V.jsx)(`span`,{className:`font-mono`,children:`${e.kind}:${e.target}`})},e.chord))}),(0,V.jsx)(`p`,{className:EA,children:$(`keybindings.fixed`,{ids:s.join(`, `)})})]})}var VN=`/assets/pulse-3XJkP4CJ.wav`;function HN(e,t){return e===`error`||t}function UN(e,t){return t||e.kind!==`done`||e.turnEnd!==!0}function WN(e,t){return t&&e.silent!==!0}function GN(e){return e===`permission_needed`?`needs_input`:e===`error`||e===`rate_limited`||e===`dead`?`error`:e===`turn_complete`?`done`:null}function KN(e,t,n,r){if(e===null)return[];let i=[];for(let[a,o]of t){if(a===n||e.get(a)===o)continue;let t=r(o);t&&i.push({key:a,kind:t})}return i}function qN(){return window.isSecureContext&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}var JN=()=>navigator.serviceWorker.register(`sw.js`);async function YN(e){if(!qN())return`unsupported`;if(Notification.permission===`denied`)return`blocked`;let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();if(!t)return`off`;let{subscribed:n}=await e.request(`push.status`,{endpoint:t.endpoint});return n?`on`:`off`}async function XN(e){if(!qN())return`unsupported`;if(await Notification.requestPermission()!==`granted`)return`blocked`;let t=await JN();await navigator.serviceWorker.ready;let{publicKey:n}=await e.request(`push.key`),r=await t.pushManager.getSubscription();return r?.options.applicationServerKey&&tP(r.options.applicationServerKey)!==n&&(await r.unsubscribe(),r=null),r??=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:eP(n)}),await e.request(`push.subscribe`,{subscription:r.toJSON()}),`on`}async function ZN(e){let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();return t&&(await e.request(`push.unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),`off`}async function QN(e,t,n,r){let i={body:r,tag:`task:${e}:${t}`,icon:`icon-192.png`,data:{taskId:e}},a=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;a?await a.showNotification(`Rove — ${n}`,i):new Notification(`Rove — ${n}`,i)}function $N(e){let t=new URLSearchParams(window.location.search),n=t.get(`task`);if(n){t.delete(`task`);let r=t.toString();history.replaceState(null,``,`${window.location.pathname}${r?`?${r}`:``}${window.location.hash}`),e.selectWhenListed(n)}if(!(`serviceWorker`in navigator))return()=>{};let r=t=>{let n=t.data;n?.type===`rove.openTask`&&typeof n.taskId==`string`&&n.taskId&&e.selectWhenListed(n.taskId)};return navigator.serviceWorker.addEventListener(`message`,r),()=>navigator.serviceWorker.removeEventListener(`message`,r)}function eP(e){let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.charCodeAt(0))}function tP(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var nP={done:`✓`,needs_input:`?`,error:`✕`};function rP(e){let t=new Audio(VN);t.volume=Math.min(1,Math.max(0,e)),t.play().catch(()=>void 0)}function iP(e,t,n){!document.hidden||typeof Notification>`u`||Notification.permission!==`granted`||QN(e,t,n,nP[t]).catch(()=>void 0)}function aP(){typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission()}function oP(e){let t=new Map;for(let n of e.tasks)n.activity&&t.set(n.id,n.activity.state);return t}function sP(e){let t=(0,g.useRef)(null);(0,g.useEffect)(()=>{let n=()=>{let n=e.tasks.get();if(!n)return;let r=oP(n),i=KN(t.current,r,null,GN);t.current=r;let{prefs:a}=T_.get();if(!a.crossTask)return;let o=e.selection.get().taskId,s=new Map(n.tasks.map(e=>[e.id,e.label]));for(let{key:e,kind:t}of i){if(e===o||!UN({kind:t,turnEnd:!0},a.finishedAlerts))continue;let n=s.get(e)??e;HN(t,a.toast)&&G(`${nP[t]} ${n}`,t===`error`?`error`:`info`),WN({},a.sound)&&(rP(a.soundVolume),iP(e,t,n))}};return n(),e.tasks.subscribe(n)},[e])}function cP({client:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(null);(0,g.useEffect)(()=>{YN(e).then(n,()=>n(`off`))},[e]);let a=t=>{i(null),(t?XN(e):ZN(e)).then(n,e=>i(e instanceof Error?e.message:String(e)))},o=r?z(`prefs.pushFailed`,{error:r}):z(t===`unsupported`?`prefs.pushUnsupported`:t===`blocked`?`prefs.pushBlocked`:`prefs.pushHint`);return(0,V.jsx)(Nj,{label:z(`prefs.push`),hint:o,checked:t===`on`,disabled:t===null||t===`unsupported`||t===`blocked`,onChange:a})}function lP({model:e}){let{client:t}=e,n=A_(),{prefs:r}=n,i=(e,n)=>void k_(t,e,n);return(0,V.jsxs)(jj,{children:[(0,V.jsx)(Nj,{label:$(`general.toast`),hint:z(`settings.notifications.toastNote`),checked:r.toast,onChange:e=>i(`toast`,e)}),(0,V.jsx)(Nj,{label:$(`general.sound`),hint:z(`prefs.soundHint`),checked:r.sound,onChange:e=>{e&&aP(),i(`sound`,e)}}),(0,V.jsx)(Fj,{label:z(`settings.notifications.volume`),hint:z(`prefs.soundVolumeHint`),value:r.soundVolume,picks:j_(n,`soundVolume`).map(e=>({value:e,label:`${Math.round(e*100)}%`})),onPick:e=>{T_.get().prefs.sound&&rP(e),i(`soundVolume`,e)}}),(0,V.jsx)(Nj,{label:$(`general.crossTask`),hint:$(`general.crossTaskHint`),checked:r.crossTask,onChange:e=>i(`crossTask`,e)}),(0,V.jsx)(Nj,{label:$(`general.finishedAlerts`),hint:$(`general.finishedAlertsHint`),checked:r.finishedAlerts,onChange:e=>i(`finishedAlerts`,e)}),(0,V.jsx)(cP,{client:t})]})}var uP={kanban:`kanban`,issues:`issues`};function dP({model:e}){let t=v(e.installedMods),[n,r]=(0,g.useState)(()=>Ns(e,`builtinMods.list`)?.mods??null);if((0,g.useEffect)(()=>{Fs(e,`builtinMods.list`).then(e=>r(e.mods),()=>r([])),e.refreshMods()},[e]),!n||n.length===0)return null;let i=n=>{let r=!t.has(n.id);e.client.request(`builtinMod.setInstalled`,{id:n.id,installed:r}).then(()=>(!r&&on.get()===uP[n.id]&&on.set(null),e.refreshMods())).catch(e=>G(K(e),`error`))};return(0,V.jsx)(jj,{title:z(`settings.plugins.builtIn`),hint:z(`settings.plugins.builtInHint`),children:n.map(e=>(0,V.jsx)(Mj,{label:e.name,hint:e.description,inline:!0,children:(0,V.jsx)(Aj,{on:t.has(e.id),"aria-label":z(`settings.plugins.turnOn`,{name:e.name}),onClick:()=>i(e)})},e.id))})}function fP({model:e}){let{client:t}=e,[n,r]=(0,g.useState)(()=>Ns(t,`plugins.list`)?.plugins??null),i=(0,g.useCallback)(()=>Fs(t,`plugins.list`).then(e=>r(e.plugins),e=>G(K(e),`error`)),[t]);return(0,g.useEffect)(()=>{i()},[i]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(dP,{model:e}),(0,V.jsx)(jj,{title:z(`settings.plugins.registered`),children:n?n.length===0?(0,V.jsx)(`p`,{className:FA,children:z(`settings.plugins.empty`)}):n.map(e=>(0,V.jsx)(Mj,{label:e.id,hint:[e.version,e.linked?z(`settings.plugins.linked`):null,e.platformOk===!1?z(`settings.plugins.unsupportedPlatform`):null].filter(Boolean).join(`, `),inline:!0,children:(0,V.jsx)(Aj,{on:e.enabled,"aria-label":e.id,onClick:()=>void t.request(`plugin.setEnabled`,{id:e.id,enabled:!e.enabled}).then(i).catch(e=>G(K(e),`error`))})},e.id)):(0,V.jsx)(`p`,{className:FA,children:z(`preview.loading`)})})]})}function pP(e){let[t,n]=(0,g.useState)(e.tier.engine),[r,i]=(0,g.useState)(e.tier.model??``),[a,o]=(0,g.useState)(e.tier.effort??``),s=e.engines.find(e=>e.id===t);return(0,V.jsxs)(`form`,{className:_j,onSubmit:n=>{n.preventDefault(),e.onSave(t,s?.takesModel?r.trim():``,a)},onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),e.onCancel())},children:[(0,V.jsx)(mA,{label:$(`sections.engines`),value:t,picks:e.engines.map(e=>({value:e.id,label:e.name})),onPick:t=>{let r=e.engines.find(e=>e.id===t);n(t),r&&!r.effortLevels.includes(a)&&o(``),r&&!r.takesModel&&i(``)}}),s&&s.effortLevels.length>0&&(0,V.jsx)(mA,{label:z(`prefs.tierEffort`),value:a,picks:[``,...s.effortLevels].map(e=>({value:e,label:e||$(`autoRouting.engineDefault`)})),onPick:o}),s?.takesModel&&(0,V.jsx)(`input`,{className:`rounded-sm border-hairline border-line bg-paper px-2.5 py-1.5 font-sans text-body text-ink focus-visible:border-line-active focus-visible:outline-none`,value:r,spellCheck:!1,placeholder:$(`autoRouting.engineDefault`),"aria-label":z(`prefs.tierModel`),onChange:e=>i(e.target.value)}),(0,V.jsxs)(`div`,{className:VA,children:[(0,V.jsx)(H,{onClick:e.onCancel,children:z(`dialog.cancel`)}),(0,V.jsx)(H,{variant:`filled`,type:`submit`,children:$(`action.save`)})]})]})}function mP({client:e}){let[t,n]=(0,g.useState)(()=>Ns(e,`autoRouting.get`)??null),[r,i]=(0,g.useState)(null),a=(0,g.useCallback)(()=>Fs(e,`autoRouting.get`).then(n,e=>G(K(e),`error`)),[e]);(0,g.useEffect)(()=>{a()},[a]);let o=(t,n)=>e.request(t,n).then(a).catch(e=>G(K(e),`error`));if(!t)return(0,V.jsx)(`p`,{className:FA,children:z(`preview.loading`)});let s=t.classifier,c=[{value:`off`,label:$(`autoRouting.classifierOff`)},{value:`jev`,label:`jev`},...s.canCustom||s.mode===`custom`?[{value:`custom`,label:$(`autoRouting.classifierCustomLabel`)}]:[]],l=s.mode===`off`?$(`autoRouting.classifierOffHint`):s.mode===`jev`?$(`autoRouting.classifierJevHint`):$(`autoRouting.classifierCustomHint`),u=s.keySource===`env`?$(`autoRouting.keyPresentEnv`,{env:s.keyEnv??``}):s.keySource===`file`?$(`autoRouting.keySaved`):s.keyConfigured?$(`autoRouting.keyMissing`):$(`autoRouting.keyCustomUnused`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(jj,{hint:$(`autoRouting.hint`),children:[!t.configured&&(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:`text-warning`,children:$(`autoRouting.unconfigured`)})}),t.tiers.map(e=>(0,V.jsxs)(`div`,{className:hj,children:[(0,V.jsxs)(`div`,{className:gj,children:[(0,V.jsx)(`span`,{className:MA,children:pA(`tier.${e.tier}`)}),(0,V.jsx)(`span`,{className:`${NA} min-w-0 truncate`,children:[e.engineName,e.model??$(`autoRouting.engineDefault`),e.effort??$(`autoRouting.engineDefault`)].join(` · `)}),(0,V.jsx)(H,{className:`ml-auto`,onClick:()=>i(r===e.tier?null:e.tier),children:z(`prefs.tierEdit`)})]}),(0,V.jsx)(`span`,{className:NA,children:pA(`tierDesc.${e.tier}`)}),(0,V.jsx)(`span`,{className:`text-meta ${e.block?`text-warning`:`text-success`}`,children:e.block?$(`autoRouting.unavailable`,{reason:e.block}):$(`autoRouting.ready`)}),r===e.tier&&(0,V.jsx)(pP,{tier:e,engines:t.engines,onCancel:()=>i(null),onSave:(t,n,r)=>{i(null),o(`autoRouting.setTier`,{tier:e.tier,engine:t,model:n,effort:r})}})]},e.tier))]}),(0,V.jsxs)(jj,{title:$(`autoRouting.classifierTitle`),hint:$(`autoRouting.classifierHint`),children:[(0,V.jsx)(Mj,{label:(0,V.jsx)(`span`,{className:s.mode===`off`?`text-muted`:`text-warning`,children:$(`autoRouting.classifierDataFlow`)})}),(0,V.jsx)(Fj,{label:$(`autoRouting.classifierLabel`),hint:l.replace(/^[—\s]+/,``),value:s.mode,picks:c,onPick:e=>void o(`autoRouting.setClassifier`,{mode:e})})]}),(0,V.jsxs)(jj,{title:z(`prefs.classifierConnection`),hint:z(`prefs.editInTui`),children:[(0,V.jsx)(Ij,{label:$(`autoRouting.endpointLabel`),value:s.endpointHost||z(`prefs.unset`)}),(0,V.jsx)(Ij,{label:$(`autoRouting.thresholdLabel`),value:s.threshold.toFixed(2)}),(0,V.jsx)(Mj,{label:$(`autoRouting.keyLabel`),hint:u})]})]})}var hP=[{id:`preferences`,sections:[`general`,`appearance`,`notifications`,`snippets`,`keys`]},{id:`agents`,sections:[`engines`,`autoRouting`,`connectors`,`plugins`]},{id:`more`,sections:[`about`,`feedback`,`dev`]}],gP=e=>({section:e??`general`,drilled:e!==void 0});function _P(e,t){return t&&e.drilled?`list`:`close`}var vP=e=>e.split(`
117
+ `,1)[0]??``;function yP(e){let[t,n]=(0,g.useState)(e.editing?.name??``),[r,i]=(0,g.useState)(e.editing?.text??``),[a,o]=(0,g.useState)(!1),s=zD.test(t)&&r.trim()!==``;return(0,V.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:n=>{n.preventDefault(),s&&(o(!0),LD(e.client,{name:t,text:r}).then(e.onDone).catch(e=>{G(K(e),`error`),o(!1)}))},children:[(0,V.jsxs)(`label`,{className:RA,children:[(0,V.jsx)(`span`,{className:zA,children:z(`snippets.name`)}),(0,V.jsx)(`input`,{className:`${IA} w-full font-mono`,value:t,maxLength:32,spellCheck:!1,autoComplete:`off`,autoFocus:!e.editing,readOnly:e.editing!==void 0,placeholder:z(`snippets.namePlaceholder`),onChange:e=>n(e.target.value)}),t!==``&&!zD.test(t)&&(0,V.jsx)(`span`,{className:`text-meta text-muted [&_a]:text-accent`,children:z(`snippets.badName`)})]}),(0,V.jsxs)(`label`,{className:RA,children:[(0,V.jsx)(`span`,{className:zA,children:z(`snippets.text`)}),(0,V.jsx)(`textarea`,{className:`${IA} ${BA} w-full`,rows:5,value:r,maxLength:8e3,placeholder:z(`snippets.textPlaceholder`),onChange:e=>i(e.target.value)})]}),(0,V.jsxs)(`div`,{className:VA,children:[(0,V.jsx)(H,{onClick:e.onDone,children:z(`snippets.cancel`)}),(0,V.jsx)(H,{type:`submit`,disabled:a||!s,children:z(`snippets.save`)})]})]})}function bP({model:e}){let{client:t}=e,n=FD(),[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>void ID(t).catch(()=>void 0),[t]),(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(jj,{children:[n.length===0&&r===null&&(0,V.jsx)(Mj,{label:z(`snippets.empty`)}),n.map(e=>(0,V.jsxs)(Mj,{label:(0,V.jsxs)(`span`,{className:`font-mono`,children:[`@`,e.name]}),hint:vP(e.text),children:[(0,V.jsx)(H,{onClick:()=>i(e),children:z(`snippets.edit`)}),(0,V.jsx)(H,{onClick:()=>void RD(t,e.name).then(()=>{i(null),G(z(`snippets.removed`,{name:e.name}))}).catch(e=>G(K(e),`error`)),children:z(`snippets.remove`)})]},e.name))]}),r===null?(0,V.jsx)(`div`,{className:VA,children:(0,V.jsx)(H,{onClick:()=>i(`new`),children:z(`snippets.add`)})}):(0,V.jsx)(yP,{client:t,editing:r===`new`?void 0:r,onDone:()=>i(null)},r===`new`?`new`:r.name)]})}var xP=e=>e>=95?`crit`:e>=75?`warn`:`ok`,SP=e=>String(e).padStart(2,`0`);function CP(e,t){if(e==null||e<=t)return``;let n=new Date(e),r=`${SP(n.getHours())}:${SP(n.getMinutes())}`;return e-t<864e5?`→ ${r}`:`→ ${n.getMonth()+1}/${n.getDate()} ${r}`}function wP(e,t){let n=e.windows.find(e=>e.kind===`session`)??e.windows[0];return n?{label:n.label,percentText:`${n.percent}%`,resetText:CP(n.resetsAt,t),tone:xP(n.percent)}:null}function TP(e){if(!e)return null;let t=e.contextWindowTokens;if(t===void 0||t<=0)return null;let n=Math.min(100,Math.max(0,Math.round(e.contextTokens/t*100)));return{label:`ctx`,percentText:`${n}%${e.approximate?`~`:``}`,resetText:``,tone:xP(n)}}function EP(e){return!e||e.inputTokens===void 0&&e.outputTokens===void 0?null:{label:`Σ`,text:DP((e.inputTokens??0)+(e.outputTokens??0))}}function DP(e){return e<1e3?String(e):e<1e6?`${Math.floor(e/1e3)}k`:`${(Math.floor(e/1e5)/10).toFixed(1)}M`}var OP=1e4;function kP({percentText:e,tone:t}){let n=Math.min(100,Math.max(0,Number.parseInt(e,10)||0));return(0,V.jsx)(`span`,{className:Rt(t),style:{"--fill":`${n}%`}})}function AP({client:e,taskId:t,tabId:n,inset:r=!0}){let i=v(e.conn),[a,o]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(i.state!==`open`)return;let r=!0,a=()=>e.request(`usage.get`,t&&n?{taskId:t,tabId:n}:{}).then(e=>{r&&o(e)}).catch(()=>{});a();let s=window.setInterval(a,OP);return()=>{r=!1,window.clearInterval(s)}},[e,i.state,t,n]);let s=TP(a?.context),c=EP(a?.context),l=Date.now(),u=(a?.usage??[]).flatMap(e=>{let t=wP({capturedAt:e.capturedAt,windows:e.windows},l);return t?[{vendor:e.vendor,name:e.name,chip:t}]:[]});return!s&&!c&&u.length===0?null:(0,V.jsxs)(`div`,{className:`${Ft} ${r?`px-3.5`:``}`,children:[s&&(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{children:s.label}),(0,V.jsx)(kP,{percentText:s.percentText,tone:s.tone}),(0,V.jsx)(`span`,{className:Lt[s.tone],children:s.percentText})]}),c&&(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{children:c.label}),(0,V.jsx)(`span`,{className:`text-muted`,children:c.text})]}),u.map(({vendor:e,name:t,chip:n})=>(0,V.jsxs)(H,{variant:`row`,className:`${It} cursor-pointer hover:text-ink`,title:`${t} · ${n.label} ${n.percentText} ${n.resetText}`.trim(),"aria-label":`${z(`usage.open`)}: ${t}`,onClick:()=>{yn(),ha(`usage`)},children:[(0,V.jsx)(`span`,{children:t}),(0,V.jsx)(`span`,{className:Lt[n.tone],children:n.percentText})]},e))]})}var jP={general:e=>(0,V.jsx)(FN,{model:e}),appearance:e=>(0,V.jsx)(eN,{model:e}),notifications:e=>(0,V.jsx)(lP,{model:e}),snippets:e=>(0,V.jsx)(bP,{model:e}),keys:e=>(0,V.jsx)(BN,{model:e}),engines:e=>(0,V.jsx)(EN,{client:e.client}),autoRouting:e=>(0,V.jsx)(mP,{client:e.client}),connectors:e=>(0,V.jsx)(hN,{model:e}),plugins:e=>(0,V.jsx)(fP,{model:e}),about:e=>(0,V.jsx)(RM,{client:e.client}),feedback:e=>(0,V.jsx)(MN,{client:e.client}),dev:e=>(0,V.jsx)(_N,{client:e.client})},MP={general:`sections.general`,engines:`sections.engines`,autoRouting:`sections.autoRouting`,plugins:`sections.plugins`,keys:`sections.keys`,feedback:`sections.feedback`,dev:`sections.dev`},NP=e=>{let t=MP[e];return t?$(t):z(`settings.sections.${e}`)};function PP(e){return(0,V.jsxs)(`nav`,{className:yA,"aria-label":z(`settings.title`),children:[(0,V.jsx)(`h1`,{className:bA,children:z(`settings.title`)}),hP.map(t=>(0,V.jsxs)(`div`,{className:xA,children:[(0,V.jsx)(`p`,{className:SA,children:z(`settings.groups.${t.id}`)}),t.sections.map(n=>(0,V.jsxs)(H,{variant:`row`,className:CA(!e.narrow&&e.current===n,t.id===`more`),"aria-current":!e.narrow&&e.current===n?`page`:void 0,onClick:()=>e.onPick(n),children:[NP(n),(0,V.jsx)(Ma,{right:!0,className:wA})]},n))]},t.id))]})}function FP({model:e,section:t}){B();let[n,r]=(0,g.useState)(()=>gP(t)),i=xa(),a=()=>_P(n,i)===`list`?r({...n,drilled:!1}):yn();(0,g.useEffect)(()=>{let e=document.querySelector(`.dialog`);e&&!e.contains(document.activeElement)&&e.focus()},[]),(0,g.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),a())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let o=!i||!n.drilled,s=!i||n.drilled;return(0,V.jsx)(`div`,{className:gA,onMouseDown:e=>e.target===e.currentTarget&&yn(),children:(0,V.jsxs)(`dialog`,{tabIndex:-1,open:!0,className:_A,"aria-label":z(`settings.title`),onKeyDown:e=>{let t=e.target;e.key===`Escape`&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.blur(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation())},children:[(0,V.jsx)(H,{variant:`row`,className:vA,"aria-label":z(`dialog.close`),title:z(`dialog.close`),onClick:yn,children:`×`}),i&&n.drilled&&(0,V.jsx)(H,{variant:`row`,className:`hidden flex-none items-center px-4 py-3 pr-12 text-left font-mono text-meta font-bold text-accent w-narrow:flex touch:min-h-11`,onClick:a,children:`‹ ${z(`settings.title`)}`}),o&&(0,V.jsx)(PP,{current:n.section,narrow:i,onPick:e=>r({section:e,drilled:!0})}),i&&o&&(0,V.jsx)(AP,{client:e.client,taskId:null,tabId:null,inset:!1}),s&&(0,V.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto scrollbar-none`,children:(0,V.jsxs)(`div`,{className:`flex w-full flex-col gap-7 px-8 pt-7 pb-10 w-narrow:gap-6 w-narrow:px-4 w-narrow:pt-1 w-narrow:pb-10`,children:[(0,V.jsxs)(`header`,{className:`flex flex-col gap-1 pr-8`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-display font-semibold normal-nums text-ink`,children:NP(n.section)}),(0,V.jsx)(`p`,{className:`m-0 text-body text-muted`,children:z(`settings.pages.${n.section}`)})]}),(0,V.jsx)(`div`,{className:`flex flex-col gap-7 w-narrow:gap-6`,children:jP[n.section](e)})]})},n.section)]})})}function IP(e){let t=e.todos;return!t||t.length===0?null:{done:t.filter(e=>e.done).length,total:t.length}}function LP(e){return(e.todos??[]).filter(e=>!e.done)}function RP(e){let t=LP(e);return t.length===0?null:`Please work through these remaining todos for this task, and tell me what you did for each:\n${t.map(e=>`- ${e.text}`).join(`
118
+ `)}`}var zP=/LAND_CONFLICT/,BP=/MAIN_CHECKOUT_DIRTY/,VP=/SYNC_CONFLICT(?:: )?(.*)/,HP=/SYNC_WORKTREE_DIRTY(?:: )?(.*)/;function UP(e){let t=K(e);return zP.test(t)?q(`worktrees`,`land.conflict`,{files:t}):BP.test(t)?q(`worktrees`,`land.dirtyBase`):q(`worktrees`,`land.failed`,{error:t})}async function WP(e,t,n){if(t.machine){GP(e,t,t.machine.label,n);return}let r;try{r=await e.client.request(`task.landPreflight`,{taskId:t.id})}catch(e){G(q(`worktrees`,`land.failed`,{error:K(e)}),`error`);return}if(r.refusal){G(r.refusal===`MAIN_CHECKOUT_DIRTY`?q(`worktrees`,`land.dirtyBase`):q(`worktrees`,`land.failed`,{error:r.message??r.refusal}),`error`);return}let i=t.branch||t.title,a=LP(e.tasks.get()?.tasks.find(e=>e.id===t.id)??{}).length;W.set((0,V.jsx)(sr,{title:q(`worktrees`,`land.confirmTitle`),body:[q(`worktrees`,r.ahead===1?`land.confirmBodyOne`:`land.confirmBody`,{branch:i,landedOn:r.landedOn,commits:r.ahead??`?`}),...a>0?[z(`files.landTodos`,{count:a})]:[]].join(`
119
119
 
120
- `),confirmLabel:q(`worktrees`,`land.button`),onConfirm:async()=>{try{let r=await e.client.request(`task.land`,{taskId:t.id});G(q(`worktrees`,`land.done`,{branch:i,landedOn:r.landedOn,commit:r.commit.slice(0,8)})),n?.()}catch(e){throw Error(VP(e))}}}))}function UP(e,t,n,r){let i=t.branch||t.title;W.set((0,V.jsx)(sr,{title:z(`taskops.publishTitle`),body:z(`taskops.publishBody`,{branch:i,host:n}),confirmLabel:z(`taskops.publishButton`),onConfirm:async()=>{let n=await e.client.request(`task.land`,{taskId:t.id}),a=n.published?.prUrl;a?G(z(`taskops.publishedPr`,{branch:i,url:a})):G(z(`taskops.publishedNoPr`,{branch:i,reason:GP(n.published?.prError??``)}),`error`),r?.()}}))}async function WP(e,t){try{let n=await e.client.request(`task.syncBase`,{taskId:t});G(q(`tasks`,n.alreadyCurrent?`sync.alreadyCurrent`:`sync.done`,{base:n.baseRef}))}catch(e){let t=K(e),n=zP.exec(t),r=BP.exec(t);G(n?q(`tasks`,`sync.conflict`,{files:n[1]?.trim()||`?`}):r?q(`tasks`,`sync.dirty`,{files:r[1]?.trim()||`?`}):q(`tasks`,`sync.failed`,{error:t}),`error`)}}function GP(e){return e.split(`
121
- `).find(e=>e.trim().length>0)?.trim()??e.trim()}async function KP(e,t,n){try{let r=await e.client.request(`task.fixChecks`,e.engineTarget(t));r.outcome===`unavailable`?G(q(`files`,`toast.ciChecksUnavailable`,{detail:GP(r.detail??``)}),`error`):r.outcome===`none`?G(q(`files`,`toast.ciNoFailingChecks`),`error`):G(n)}catch(e){G(K(e),`error`)}}async function qP(e,t){try{let n=await e.client.request(`task.openEditor`,{taskId:t});n.outcome===`noEditor`?G(q(`tasks`,`toast.noEditor`),`error`):n.outcome===`failed`&&G(q(`tasks`,`toast.openWorktreeFailed`,{label:n.label??``}),`error`)}catch(e){G(q(`tasks`,`toast.worktreeErrorGeneric`,{message:K(e)}),`error`)}}function JP(e,t){let n=e.tasks.get();return[...n?.tasks??[],...n?.archived??[]].filter(e=>e.parentTaskId===t)}function YP(e,t){let n=JP(e,t.id),r=n.length>0,i=n=>e.client.request(`task.delete`,{taskId:t.id,...n}).then(()=>{});return(0,V.jsx)(sr,{title:r?q(`tasks`,`confirm.childrenTitle`,{title:t.label,count:String(n.length)}):q(`tasks`,t.kind===`dir`?`confirm.deleteTitleDir`:`confirm.deleteTitle`,{title:t.label}),body:r?q(`tasks`,`confirm.childrenBody`):q(`tasks`,t.kind===`dir`?`confirm.deleteBodyDir`:`confirm.deleteBodyTask`),confirmLabel:q(`tasks`,r?`confirm.childrenPromote`:`confirm.deleteConfirm`),onConfirm:()=>i({}),...r?{secondary:{label:q(`tasks`,`confirm.childrenCascade`),onConfirm:()=>i({cascade:!0})}}:{},escalate:{when:e=>e instanceof r_&&e.code===`DIRTY_WORKTREE`,label:q(`tasks`,`confirm.forceDeleteConfirm`),title:q(`tasks`,`confirm.forceDeleteTitle`,{title:t.label}),body:e=>`${q(`worktrees`,`delete.forceBody`,{branch:t.branch||t.title})}\n\n${q(`worktrees`,`delete.forceReason`,{reason:K(e).replace(`task ${t.id} `,``)})}`,run:e=>i({force:!0,...e?{cascade:!0}:{}})}})}function XP(e,t){let n=JP(e,t.id),r=n.length>0,i=t.label,a=async()=>{let{tabs:n}=await e.client.request(`task.tabs`,{taskId:t.id});for(let r of n)await e.client.request(`tab.close`,{taskId:t.id,tabId:r.id});await e.refreshTabsNow()},o,s=async t=>{for(let r of n)try{await e.client.request(`task.delete`,{taskId:r.id,cascade:!0,...t?{force:!0}:{}})}catch(e){throw o=r.title,e}await a()};return(0,V.jsx)(sr,{title:r?q(`tasks`,`confirm.childrenTitle`,{title:i,count:String(n.length)}):q(`tasks`,`confirm.deleteTitleDir`,{title:i}),body:q(`tasks`,r?`confirm.childrenBodyMain`:`confirm.deleteBodyMain`),confirmLabel:q(`tasks`,r?`confirm.childrenKeepMain`:`confirm.deleteConfirm`),onConfirm:a,...r?{secondary:{label:q(`tasks`,`confirm.childrenCascadeMain`),onConfirm:()=>s(!1)}}:{},escalate:{when:e=>e instanceof r_&&e.code===`DIRTY_WORKTREE`,label:q(`tasks`,`confirm.forceDeleteConfirm`),title:q(`tasks`,`confirm.forceDeleteTitle`,{title:i}),body:e=>`${q(`worktrees`,`delete.forceBody`,{branch:o??i})}\n\n${K(e)}`,run:()=>s(!0)}})}async function ZP(e,t){let n=t.archived!==!0,r=t.label,i=async i=>{await e.client.request(`task.archive`,{taskId:t.id,archived:n,...i?{force:!0}:{}}),G(q(`tasks`,n?`archive.done`:`archive.restored`,{title:r}))};try{await i(!1)}catch(e){if(n&&e instanceof r_&&e.code===`TASK_BUSY`){W.set((0,V.jsx)(sr,{title:q(`tasks`,`archive.busyTitle`),body:q(`tasks`,`archive.busyBody`,{title:r}),confirmLabel:q(`tasks`,`archive.busyConfirm`),onConfirm:()=>i(!0)}));return}G(q(`tasks`,n?`archive.failed`:`archive.restoreFailed`,{error:K(e)}),`error`)}}function QP(e,t,n){return(0,V.jsx)(sr,{title:q(`tasks`,`confirm.forgetProjectTitle`,{title:n}),body:q(`tasks`,`confirm.forgetProjectBody`),confirmLabel:q(`tasks`,`confirm.forgetProjectConfirm`),onConfirm:async()=>{try{await e.client.request(`project.forget`,{repo:t})}catch(e){throw Error(q(`tasks`,`toast.forgetProjectFailed`,{error:K(e)}))}}})}var $P=e=>{let{taskId:t}=e.selection.get();return e.tasks.get()?.tasks.find(e=>e.id===t)??null},eF=e=>{let{taskId:t,tabId:n}=e.selection.get(),r=t?e.tabs.get()[t]?.find(e=>e.id===n):void 0;return!!r&&!bw(r.split)},tF=[{id:`app.refresh`,live:()=>oi.get().stale,run:e=>ui(e.client)},{id:`palette.open`,live:()=>!0,run:Xk},{id:`task.new.global`,live:()=>!0,run:e=>KD($P(e)?.repo)},{id:`chat.tab.fork`,live:e=>!!$P(e),run:e=>{let t=$P(e);t&&W.set((0,V.jsx)(RC,{model:e,taskId:t.id,context:`continue`}))}},{id:`chat.fork.new`,live:e=>!!$P(e),run:e=>{let t=$P(e);t&&W.set((0,V.jsx)(RC,{model:e,taskId:t.id,destination:`fork`}))}},{id:`settings.open`,live:()=>!0,run:e=>W.set((0,V.jsx)(NP,{model:e}))},{id:`inbox.show`,live:()=>!0,run:e=>W.set((0,V.jsx)(DT,{model:e}))},{id:`focus.previous`,live:()=>!0,run:()=>Gi(-1)},{id:`focus.next`,live:()=>!0,run:()=>Gi(1)},{id:`workspace.zenToggle`,live:e=>!!$P(e),run:()=>un.set(!un.get())},{id:`files.createPR`,live:e=>!!$P(e),run:e=>{let t=$P(e);t&&e.client.request(`tab.requestPR`,e.engineTarget(t.id)).then(()=>G(z(`files.prRequested`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},{id:`chat.tab.close`,live:e=>!!e.selection.get().tabId&&eF(e),run:e=>{let{taskId:t,tabId:n}=e.selection.get();!t||!n||e.client.request(`tab.close`,{taskId:t,tabId:n}).then(()=>e.refreshTabsNow()).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},{id:`kanban.open`,live:e=>e.installedMods.get().has(`kanban`),run:()=>ha(`kanban`)},{id:`automations.open`,live:()=>!0,run:()=>ha(`routines`)},{id:`workItems.open`,live:e=>e.installedMods.get().has(`issues`),run:()=>ha(`issues`)},{id:`task.moveMode`,live:e=>!!eA(e),run:()=>{zT(!LT.get()),document.querySelector(`.rail`)?.focus()}},{id:`files.syncBase`,live:e=>eA(e)?.kind===`task`,run:e=>{let t=eA(e);t&&WP(e,t.id)}},{id:`files.fixChecks`,live:e=>!!eA(e),run:e=>{let t=eA(e);t&&KP(e,t.id,z(`taskops.fixSent`))}},{id:`task.openEditor`,live:e=>!!eA(e),run:e=>{let t=eA(e);t&&qP(e,t.id)}}];qi(()=>tF.map(e=>({id:e.id,chords:ni(e.id),prefix:!0,live:e.live,run:e.run})));function nF(e){return Ya(e[0]??``)}function rF(e,t){let n=Qi(),r=Yi().filter(t=>t.prefix&&Xi(t,n)&&t.live?.(e)!==!1);for(let e of t){let t=r.filter(t=>t.chords.includes(e)).sort((e,t)=>Zi(e,n)-Zi(t,n))[0];if(t)return t}}var iF=null,aF=null;function oF(){iF=null,aF!==null&&window.clearTimeout(aF),aF=null;let e=Jw.get();e.guide?.kind===`prefix`&&Jw.set({...e,guide:null})}function sF(){if(iF!==null){oF();return}W.get()||Zr()===null||(iF=Date.now(),Jw.set({...Jw.get(),guide:{kind:`prefix`,armedAt:iF}}),aF!==null&&window.clearTimeout(aF),aF=window.setTimeout(oF,Kr.get().prefix.timeoutMs))}function cF(e,t){oF();let n=typeof t==`string`?[t]:t,r=rF(e,n);Xw(nF(n),r?.id??null),r?.run(e)}var lF=null;function uF(){lF!==null&&window.clearTimeout(lF),lF=null;let e=Jw.get();e.guide?.kind===`direct`&&Jw.set({...e,guide:null})}function dF(){lF!==null||W.get()||(lF=window.setTimeout(()=>{oF(),Jw.set({...Jw.get(),guide:{kind:`direct`}})},400))}function fF(e){(0,g.useEffect)(()=>{let t=t=>{if(t.key===`Control`){t.repeat||dF();return}if(uF(),[`Shift`,`Alt`,`Meta`].includes(t.key))return;let n=Ja(t),{firstStrokes:r,timeoutMs:i}=Kr.get().prefix;if(iF!==null&&Date.now()-iF<=i){if(t.preventDefault(),t.stopImmediatePropagation(),t.key===`Escape`)return oF();cF(e,n);return}oF(),!W.get()&&n.some(e=>r.includes(e))&&(t.preventDefault(),t.stopImmediatePropagation(),sF())},n=e=>e.key===`Control`&&uF(),r=e=>{iF!==null&&(e.target instanceof Element&&e.target.closest(`.prefix-guide, .shortcut-badge, [data-prefix-arm]`)||oF())};return window.addEventListener(`keydown`,t,{capture:!0}),window.addEventListener(`keyup`,n,{capture:!0}),window.addEventListener(`pointerdown`,r,{capture:!0}),window.addEventListener(`blur`,uF),()=>{window.removeEventListener(`keydown`,t,{capture:!0}),window.removeEventListener(`keyup`,n,{capture:!0}),window.removeEventListener(`pointerdown`,r,{capture:!0}),window.removeEventListener(`blur`,uF),uF(),oF()}},[e])}function pF(e){let t=Qi(),n=new Map;for(let r of Yi()){if(!r.prefix||!Xi(r,t)||r.live?.(e)===!1)continue;let i=Zi(r,t);for(let e of r.chords){let t=n.get(e);(!t||i<t.rank)&&n.set(e,{action:r.id,rank:i})}}return[...n].map(([e,{action:t}])=>({stroke:e,action:t}))}function mF(e){let t=new Map(Vr.map((e,t)=>[e.id,t])),n=new Map;for(let{stroke:t,action:r}of e)n.set(r,[...n.get(r)??[],t]);let r=new Map,i=[...n].sort(([e],[n])=>(t.get(e)??2**53-1)-(t.get(n)??2**53-1));for(let[e,t]of i){let n=ao(e);r.set(n,[...r.get(n)??[],{action:e,strokes:t}])}return[...r].map(([e,t])=>({category:e,actions:t}))}var hF=e=>e===`prefix.moreCommands`?_o(`moreCommandsPrefix`):xo(e);function gF(e){let[,t]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(e===null)return;let n=window.setTimeout(()=>t(e=>e+1),Math.max(30,e-Date.now()));return()=>window.clearTimeout(n)},[e])}function _F({model:e}){B();let t=v(Jw);v(Kr),v(e.selection);let n=Date.now(),r=t.entries.filter(e=>n-e.at<qw),i=t.guide?.kind===`prefix`?t.guide.armedAt:null,a=i!==null&&n-i<Kw?i+Kw:null;gF(a??(r[0]?r[0].at+qw:null));let o=t.guide?.kind===`direct`||i!==null&&a===null;if(!o&&!t.guide&&r.length===0)return null;if(o&&t.guide){let n=t.guide.kind===`direct`,r=n?Ww($i(e,Qi()),Zr()):pF(e);return(0,V.jsxs)(`output`,{className:`mono ${tt}`,onMouseDown:e=>e.preventDefault(),children:[(0,V.jsxs)(`div`,{className:rt,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:n?_o(`directLayer`):_o(`commandLayer`,{prefix:Zr()??``})}),(0,V.jsx)(`span`,{className:`keys-only text-muted`,children:_o(n?`releaseCtrl`:`escCancel`)})]}),(0,V.jsx)(`div`,{className:it,children:mF(r).map(t=>(0,V.jsxs)(`div`,{className:at,children:[(0,V.jsx)(`div`,{className:`text-accent`,children:So(t.category)}),t.actions.map(({action:t,strokes:r})=>(0,V.jsxs)(`button`,{type:`button`,className:ot,disabled:n,onClick:()=>r[0]&&cF(e,r[0]),children:[(0,V.jsx)(`span`,{className:nt,children:r.map(Ya).join(`/`)}),(0,V.jsx)(`span`,{children:hF(t)})]},t))]},t.category))})]})}return(0,V.jsxs)(`output`,{className:yt,children:[r.map(e=>(0,V.jsxs)(vF,{at:e.at,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:Zr()}),` + `,e.stroke,` →`,` `,e.action?hF(e.action):(0,V.jsx)(`span`,{className:`text-muted`,children:`∅`})]},e.id)),i!==null&&(0,V.jsxs)(`div`,{className:bt(!1),children:[(0,V.jsx)(`span`,{className:`text-accent`,children:Zr()}),` ⋯`]})]})}function vF({at:e,children:t}){let[n]=(0,g.useState)(Date.now),r=n-e>140,i={"--hud-out":`${e+qw-140-n}ms`};return(0,V.jsx)(`div`,{className:bt(r),style:i,children:t})}function yF({model:e,bindingId:t,head:n=!1}){let r=v(Jw);v(Kr);let i=A_().prefs.prefixTap;if(r.guide?.kind!==`prefix`||i!==`local`)return null;let a=Uw({bindingId:t,reachability:$i(e,Qi()),prefixKey:Zr()});if(!a)return null;let o=Yi().find(e=>e.id===t&&e.prefix)?.chords[0];return(0,V.jsx)(`button`,{type:`button`,className:`mono ${qe(n)}`,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),o&&cF(e,o)},children:a})}var bF=[`workingBorder`,`runningTitle`,`taskColors`,`glyphSet`,`colorblind`];function xF(e){let{client:t}=e,n=A_(),r=JM(),i=v(x_);YM(e),aP(e),(0,g.useEffect)(()=>{let e=()=>{O_(t).catch(()=>void 0),ID(t).catch(()=>void 0)},n=()=>document.visibilityState===`visible`&&e(),r=t.onOpen(e);return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,n),()=>{r(),window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,n)}},[t]),(0,g.useEffect)(()=>{let e=document.documentElement,t=i?i[r]:u_(n.themes,n.prefs.theme,r),a=t?v_(t,n.prefs):{};for(let[t,n]of Object.entries(a))e.style.setProperty(t,n);e.style.colorScheme=r;for(let t of bF)e.dataset[t]=String(n.prefs[t]);b_.set(t?y_(t):null);let o=document.querySelector(`meta[name="theme-color"]`);o||(o=document.createElement(`meta`),o.name=`theme-color`,document.head.append(o)),o.content=getComputedStyle(document.body).backgroundColor},[n,r,i]),(0,g.useEffect)(()=>{n.loaded&&un.get()!==n.prefs.zen&&un.set(n.prefs.zen)},[n.loaded,n.prefs.zen]),(0,g.useEffect)(()=>un.subscribe(()=>{un.get()!==T_.get().prefs.zen&&k_(t,`zen`,un.get())}),[t])}var SF={sidebar:[{id:`sidebar.nav`,msg:`move`},{id:`sidebar.select`,msg:`open`}],files:[{id:`files.nav`,msg:`move`},{id:`files.hierarchy`,msg:`collapse`},{id:`files.open`,msg:`open`,always:!0},{id:`files.diff`,msg:`diff`,always:!0}]};function CF(e,t){return SF[e].flatMap(e=>{if(t===`always`&&e.always!==!0)return[];let n=eo(e.id);return n?[{cap:n,msg:e.msg}]:[]})}var wF=e=>`rove.web.hintUsed.${e}`,TF=_({sidebar:localStorage.getItem(wF(`sidebar`))===`1`});function EF(e){TF.get()[e]||(localStorage.setItem(wF(e),`1`),TF.set({...TF.get(),[e]:!0}))}function DF(e,t){return e.kind===`task`&&t.kind===`task`?e.taskId===t.taskId:e.kind===`page`&&t.kind===`page`?e.id===t.id:e.kind===`new`&&t.kind===`new`}var OF={entries:[],at:-1};function kF(e,t){let n=e.entries[e.at];if(n&&DF(n,t)){let n=[...e.entries];return n[e.at]=t,{entries:n,at:e.at}}let r=[...e.entries.slice(0,e.at+1),t].slice(-50);return{entries:r,at:r.length-1}}function AF(e,t,n){for(let r=e.at+t;r>=0&&r<e.entries.length;r+=t){let t=e.entries[r];if(t&&n(t))return r}return-1}var jF=_(OF);function MF(e){let t=on.get();if(t)return{kind:`page`,id:t};let n=dn.get();if(n)return{kind:`new`,start:n};let{taskId:r,tabId:i}=e.selection.get();return r?{kind:`task`,taskId:r,tabId:i}:null}function NF(e,t){if(t.kind!==`task`)return!0;let n=e.tasks.get()?.tasks.find(e=>e.id===t.taskId);return n!==void 0&&!n.deleting}var PF=!1;function FF(e){let t=!1,n=()=>{t||(t=!0,queueMicrotask(()=>{if(t=!1,PF)return;let n=MF(e);n&&jF.set(kF(jF.get(),n))}))};n();let r=[e.selection.subscribe(n),on.subscribe(n),dn.subscribe(n)];return()=>{for(let e of r)e()}}function IF(e,t){let n=jF.get(),r=AF(n,t,t=>NF(e,t)),i=n.entries[r];i&&(PF=!0,i.kind===`task`?(on.set(null),dn.set(null),e.select(i.taskId,i.tabId)):i.kind===`page`?(dn.set(null),ha(i.id)):(on.set(null),dn.set(i.start)),jF.set({entries:n.entries,at:r}),queueMicrotask(()=>{PF=!1}))}var LF={working:`info`,waiting:`warning`,error:`attention`,done:`success`,idle:`muted`},RF={prOpen:``,prMerged:``,prClosed:``};function zF(e){let t=BF(e);return{look:t,tone:LF[t]}}function BF(e){switch(e?.kind){case`busy`:case`running`:return`working`;case`needs-input`:return`waiting`;case`attention`:return e.reason===`rate_limited`?`waiting`:`error`;case`unseen`:return`done`;default:return`idle`}}function VF(e){return e.rowStatus?.kind===`needs-input`||e.rowStatus?.kind===`attention`}var HF={busy:0,attention:1,"needs-input":2,running:3,unseen:4,idle:5};function UF(e){let t;for(let{rowStatus:n}of e)n&&(!t||HF[n.kind]<HF[t.kind]||n.kind===t.kind&&n.since>t.since)&&(t=n);return t}function WF(e,t,n){if(!e)return null;if(e.lifecycle===`merged`)return{glyph:RF.prMerged,tone:n?`text-muted`:`text-merged`,state:`merged`};if(e.lifecycle===`closed`)return{glyph:RF.prClosed,tone:`text-muted`,state:`closed`};if(e.lifecycle!==`open`&&e.lifecycle!==`ready_to_merge`&&e.lifecycle!==`unknown`)return null;let r=t===`conflict`?`conflict`:t===`failing`?`failing`:t===`passing`?`passing`:e.checkState===`pending`?`pending`:void 0,i=n?`text-muted`:r===`conflict`||r===`failing`?`text-error`:r===`passing`?`text-success`:`text-muted`;return{glyph:RF.prOpen,tone:i,state:`open`,...r?{checks:r}:{}}}function GF(e){return WF(e.pr,e.prChip,e.prChipStale===!0)}function KF(e){return WF(e,(e.mergeable??``).toUpperCase()===`CONFLICTING`?`conflict`:e.checkState===`failing`?`failing`:e.checkState===`passing`?`passing`:null,!1)}function qF(e){let t=e=>e.state===`open`?e.tone===`text-error`?0:1:e.state===`merged`?2:3;return[...e].sort((e,n)=>t(e)-t(n))[0]}var JF=192,YF=`rove.web.railWidth`,XF=`rove.web.railFolded`;function ZF(){let e=Number(localStorage.getItem(YF));return Number.isFinite(e)&&e>0?e:null}var QF=_(ZF());QF.subscribe(()=>{let e=QF.get();e===null?localStorage.removeItem(YF):localStorage.setItem(YF,String(Math.round(e)))}),QF.subscribe(Sn);var $F=_(localStorage.getItem(XF)===`1`);$F.subscribe(()=>localStorage.setItem(XF,$F.get()?`1`:`0`));var eI=_(!1),tI=null;function nI(e){tI!==null&&window.clearTimeout(tI),tI=null,e?eI.set(!0):tI=window.setTimeout(()=>eI.set(!1),250)}$F.subscribe(()=>eI.set(!1)),$F.subscribe(Sn);function rI(e,t=window.innerWidth){let n=Math.max(JF,t-320);return Math.max(JF,Math.min(n,Math.round(e)))}var iI=`flex-none fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.25]`,aI=(e={})=>`relative grid cursor-pointer place-items-center rounded-sm border-none p-0 disabled:cursor-default disabled:opacity-35 [&_svg]:fill-none [&_svg]:stroke-current [&_svg]:[stroke-linecap:round] [&_svg]:[stroke-linejoin:round] [&_svg]:[stroke-width:1.25] touch:after:absolute touch:after:-inset-x-px touch:after:-top-2 touch:after:-bottom-1.25 touch:after:content-[''] touch:first:after:-left-2 ${e.tool?`size-5.5 flex-none`:`size-6.5`} ${e.tool||e.small?`[&_svg]:size-3.5`:`[&_svg]:size-4`} ${e.on?`bg-accent-soft text-accent`:`bg-transparent text-subtle enabled:hover:bg-hover enabled:hover:text-ink`}`,oI=`absolute top-2 left-2 z-7 flex items-center gap-0.5`,sI=`[&.is-resizing_iframe]:pointer-events-none`,cI=e=>`side-panel ${Ve} relative row-1 flex min-h-0 min-w-0 flex-col ${sI} ${e?`flex-1 p-0`:`pt-2 pr-1 pb-1 pl-0`}`,lI=`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] [--divider:5px] *:col-1 ${sI}`,uI=e=>`side-head flex min-h-6.5 min-w-0 items-center gap-0.5 pb-1.5 font-mono text-meta normal-nums ${e?`px-2 pt-0`:`narrow:px-2 narrow:pt-0`}`,dI=`scrollbar-none flex min-w-0 flex-1 gap-0.5 overflow-x-auto`,fI=e=>`group/ptab relative flex max-w-40 items-center hover:text-ink data-[drop=after]:shadow-[inset_-2px_0_0_var(--accent)] data-[drop=before]:shadow-[inset_2px_0_0_var(--accent)] ${e.active?`is-active text-ink`:`text-muted`} ${e.compact&&!e.active?`min-w-0 flex-none`:`min-w-18 flex-initial`}`,pI=e=>`flex min-w-0 cursor-pointer items-center gap-1.5 border-none bg-transparent text-inherit [font:inherit] ${e?`px-1.75 py-1`:`py-1 pr-0.5 pl-2`}`,mI=`truncate`,hI=`touch:relative size-4 flex-none cursor-pointer rounded-xs border-none bg-transparent p-0 mr-1 font-mono text-title leading-none text-subtle opacity-0 group-hover/ptab:opacity-100 hover:bg-hover hover:text-ink focus-visible:opacity-100 [@media(hover:none)]:opacity-100 touch:after:absolute touch:after:-inset-1.5 touch:after:-left-1 touch:after:content-['']`,gI=`ml-auto flex gap-0.5`,_I=`relative row-3 cursor-row-resize touch-none before:absolute before:inset-x-0 before:top-[calc(var(--divider)/2)] before:h-px before:bg-line before:content-[''] hover:before:bg-line-active after:absolute after:inset-x-0 after:-inset-y-0.75 after:content-['']`,vI=`side-view flex min-h-0 min-w-0 flex-col [&[hidden]]:hidden`,yI=`row-2 m-auto flex max-w-[44ch] flex-col items-center gap-2.5 p-4 text-center font-mono text-meta leading-[1.5] text-subtle normal-nums`,bI=`flex min-h-0 flex-1 flex-col gap-1.5`,xI=`flex items-center gap-0.5 [&_svg]:flex-none`,SI=`mx-0.5 min-w-0 flex-1 rounded-sm border-none bg-inset px-2 py-1 text-ink [font-size:var(--fs-meta)] focus:bg-hover focus:outline-none aria-invalid:text-muted`,CI=`min-w-0 flex-1 rounded-sm border-none bg-[#fff]`;function wI({edge:e,className:t,...n}){return(0,V.jsx)(`div`,{"data-grip":``,className:ke(`absolute inset-y-0 z-5 w-1.5 cursor-col-resize touch-none`,`after:absolute after:inset-y-0 after:w-0.5 after:bg-line-active after:opacity-0 after:transition-opacity after:duration-120`,`hover:after:opacity-100 hover:after:delay-250 active:after:bg-accent active:after:opacity-100 active:after:delay-0`,e===`right`?`right-0 after:right-0`:`left-0 after:left-0`,t),...n})}var TI=400;function EI({rail:e}){B();let t=(0,g.useRef)(null),n=(0,g.useRef)(0);return(0,V.jsx)(wI,{edge:`right`,title:z(`layout.railResize`),onPointerDown:n=>{t.current={x:n.clientX,width:e.current?.getBoundingClientRect().width??0,moved:!1},n.currentTarget.setPointerCapture(n.pointerId),Cn(!0)},onPointerMove:e=>{let n=t.current;!n||e.clientX===n.x||(n.moved=!0,QF.set(rI(n.width+e.clientX-n.x)))},onPointerUp:()=>{let e=t.current;if(t.current=null,!e)return;if(e.moved){n.current=0;return}let r=Date.now();r-n.current<TI?(n.current=0,QF.set(null)):n.current=r},onLostPointerCapture:()=>Cn(!1)})}function DI({side:e}){return(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,V.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`13`,height:`11`,rx:`2.5`}),(0,V.jsx)(`path`,{d:e===`left`?`M6 2.5v11`:`M10 2.5v11`})]})}function OI({model:e}){B();let t=v(jF),n=v($F),r=v(e.tasks),i=t=>NF(e,t),a=z(n?`layout.railUnfold`:`layout.railFold`),o=n&&(r?.tasks??[]).some(VF);return(0,V.jsxs)(`div`,{className:oI,onMouseEnter:()=>n&&eI.get()&&nI(!0),onMouseLeave:()=>n&&eI.get()&&nI(!1),children:[(0,V.jsxs)(`button`,{type:`button`,className:aI(),title:a,"aria-label":a,onClick:()=>$F.set(!n),children:[(0,V.jsx)(DI,{side:`left`}),o&&(0,V.jsx)(`span`,{className:`absolute top-0.75 right-0.75 size-1.5 rounded-full bg-accent`})]}),(0,V.jsx)(`button`,{type:`button`,className:aI(),title:z(`layout.navBack`),"aria-label":z(`layout.navBack`),disabled:AF(t,-1,i)<0,onClick:()=>IF(e,-1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M10 3.5 5.5 8l4.5 4.5`})})}),(0,V.jsx)(`button`,{type:`button`,className:aI(),title:z(`layout.navForward`),"aria-label":z(`layout.navForward`),disabled:AF(t,1,i)<0,onClick:()=>IF(e,1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M6 3.5 10.5 8 6 12.5`})})})]})}var kI={terminal:`layout.narrowTerminal`,chat:`layout.narrowChat`,files:`layout.narrowFiles`,diff:`layout.narrowDiff`,browser:`layout.narrowBrowser`};function AI({taskId:e}){B();let t=v(za);return(0,V.jsxs)(`div`,{className:Ue,children:[(0,V.jsx)(`button`,{type:`button`,className:`mono ${We}`,onClick:ma,children:(0,V.jsx)(`span`,{className:`text-accent`,children:`‹ ${Co(`narrowBack`)}`})}),e&&(0,V.jsx)(`span`,{className:`mono ml-auto flex gap-0.5`,role:`tablist`,children:[`terminal`,...Ra].map(n=>(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:Ge,onClick:()=>n===`terminal`?za.set(n):zk(e,n),children:z(kI[n])},n))})]})}function jI({title:e}){return B(),(0,V.jsxs)(`button`,{type:`button`,className:Qn({}),onClick:pa,children:[(0,V.jsx)(`span`,{className:`${nr} font-bold text-accent`,children:`↩`}),(0,V.jsx)(`span`,{className:$n,children:wo(`recentJump`,{title:e})})]})}function MI({pane:e}){B();let{prefs:t}=A_(),n=v(TF)[e];if(!t.keyHints)return null;let r=CF(e,n?`always`:`firstUse`);return r.length===0?null:(0,V.jsx)(`p`,{className:`mono text-muted ${Ke}`,children:(0,V.jsx)(ST,{text:r.map(e=>`${Gr(e.cap)} ${vo(`pane.${e.msg}`)}`).join(` · `)})})}var NI=`rove.awaySeen`,PI=6e4,FI=e=>e.filter(e=>!e.deleting),II=e=>e.pr?.lifecycle===`merged`,LI={error:!0,dead:!0};function RI(e,t,n){if(!t||n-t.at<=6e5)return null;let r=FI(e),i=e=>(e.activity?.since??0)>t.at,a=r.filter(e=>LI[e.activity?.state??``]===!0&&i(e)),o=r.filter(e=>e.group===`waiting-on-you`&&!a.includes(e)),s=r.filter(e=>e.activity?.state===`turn_complete`&&i(e)),c=r.filter(e=>II(e)&&!t.merged.includes(e.id));return s.length+o.length+a.length+c.length===0?null:{since:t.at,finished:s,needs:o,failed:a,merged:c}}var zI=_(null);function BI(){try{let e=JSON.parse(localStorage.getItem(NI)??`null`);return e&&typeof e.at==`number`&&Array.isArray(e.merged)?e:null}catch{return null}}function VI(e,t){let n={at:t,merged:FI(e).filter(II).map(e=>e.id)};try{localStorage.setItem(NI,JSON.stringify(n))}catch{}}var HI=8e3;function UI(e,t){let n=null,r=0,i,a=()=>{let t=e();t&&!document.hidden&&VI(t.tasks,Date.now())},o=()=>{n=null,a()},s=()=>{let t=e();if(!t||document.hidden)return;let s=Date.now();if(!n){let e=BI();e&&s-e.at>6e5&&(n=e,r=s+HI,i=setTimeout(o,HI))}if(!n){a();return}let c=RI(t.tasks,n,r-HI);c&&zI.set(c)};s();let c=t(s);document.addEventListener(`visibilitychange`,s);let l=setInterval(()=>{n||a()},PI);return()=>{c(),document.removeEventListener(`visibilitychange`,s),clearInterval(l),clearTimeout(i)}}var WI=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function GI(e,t,n){let r=t.currentTarget.getBoundingClientRect();nn.set({x:r.left,y:r.bottom,target:t.currentTarget,items:n.map(t=>({label:t.label,run:()=>e.select(t.id)}))})}function KI({model:e}){B(),(0,g.useEffect)(()=>UI(()=>e.tasks.get(),t=>e.tasks.subscribe(t)),[e]);let t=v(zI);if(!t)return null;let n=[{key:`finished`,rows:t.finished,open:n=>GI(e,n,t.finished)},{key:`needs`,rows:t.needs,open:()=>W.set((0,V.jsx)(DT,{model:e}))},{key:`failed`,rows:t.failed,open:n=>GI(e,n,t.failed)},{key:`merged`,rows:t.merged,open:n=>GI(e,n,t.merged)}];return(0,V.jsxs)(`div`,{className:tE,children:[(0,V.jsxs)(`span`,{className:`text-muted`,children:[z(`rail.recap.since`,{time:WI(t.since)}),` ·`]}),n.filter(e=>e.rows.length>0).map((e,t,n)=>(0,V.jsxs)(`span`,{className:`inline-flex gap-2.5`,children:[(0,V.jsx)(H,{hit:`tight`,onClick:e.open,children:z(`rail.recap.${e.key}`,{count:e.rows.length})}),t<n.length-1&&(0,V.jsx)(`span`,{className:`text-muted`,children:`·`})]},e.key)),(0,V.jsx)(H,{hit:`tight`,className:`ml-auto`,"aria-label":z(`rail.recap.dismiss`),title:z(`rail.recap.dismiss`),onClick:()=>zI.set(null),children:`×`})]})}function qI(e,t){return e.filter(e=>e.groupId===t).sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``)||e.title.localeCompare(t.title))}var JI=400;function YI(e){let t=null;for(let n of e.history?.messages??[]){if(n.role!==`assistant`)continue;let e=(n.blocks??[]).flatMap(e=>e.type===`text`&&e.text?[e.text]:[]).join(`
120
+ `),confirmLabel:q(`worktrees`,`land.button`),onConfirm:async()=>{try{let r=await e.client.request(`task.land`,{taskId:t.id});G(q(`worktrees`,`land.done`,{branch:i,landedOn:r.landedOn,commit:r.commit.slice(0,8)})),n?.()}catch(e){throw Error(UP(e))}}}))}function GP(e,t,n,r){let i=t.branch||t.title;W.set((0,V.jsx)(sr,{title:z(`taskops.publishTitle`),body:z(`taskops.publishBody`,{branch:i,host:n}),confirmLabel:z(`taskops.publishButton`),onConfirm:async()=>{let n=await e.client.request(`task.land`,{taskId:t.id}),a=n.published?.prUrl;a?G(z(`taskops.publishedPr`,{branch:i,url:a})):G(z(`taskops.publishedNoPr`,{branch:i,reason:qP(n.published?.prError??``)}),`error`),r?.()}}))}async function KP(e,t){try{let n=await e.client.request(`task.syncBase`,{taskId:t});G(q(`tasks`,n.alreadyCurrent?`sync.alreadyCurrent`:`sync.done`,{base:n.baseRef}))}catch(e){let t=K(e),n=VP.exec(t),r=HP.exec(t);G(n?q(`tasks`,`sync.conflict`,{files:n[1]?.trim()||`?`}):r?q(`tasks`,`sync.dirty`,{files:r[1]?.trim()||`?`}):q(`tasks`,`sync.failed`,{error:t}),`error`)}}function qP(e){return e.split(`
121
+ `).find(e=>e.trim().length>0)?.trim()??e.trim()}async function JP(e,t,n){try{let r=await e.client.request(`task.fixChecks`,e.engineTarget(t));r.outcome===`unavailable`?G(q(`files`,`toast.ciChecksUnavailable`,{detail:qP(r.detail??``)}),`error`):r.outcome===`none`?G(q(`files`,`toast.ciNoFailingChecks`),`error`):G(n)}catch(e){G(K(e),`error`)}}async function YP(e,t){try{let n=await e.client.request(`task.openEditor`,{taskId:t});n.outcome===`noEditor`?G(q(`tasks`,`toast.noEditor`),`error`):n.outcome===`failed`&&G(q(`tasks`,`toast.openWorktreeFailed`,{label:n.label??``}),`error`)}catch(e){G(q(`tasks`,`toast.worktreeErrorGeneric`,{message:K(e)}),`error`)}}function XP(e,t){let n=e.tasks.get();return[...n?.tasks??[],...n?.archived??[]].filter(e=>e.parentTaskId===t)}function ZP(e,t){let n=XP(e,t.id),r=n.length>0,i=n=>e.client.request(`task.delete`,{taskId:t.id,...n}).then(()=>{});return(0,V.jsx)(sr,{title:r?q(`tasks`,`confirm.childrenTitle`,{title:t.label,count:String(n.length)}):q(`tasks`,t.kind===`dir`?`confirm.deleteTitleDir`:`confirm.deleteTitle`,{title:t.label}),body:r?q(`tasks`,`confirm.childrenBody`):q(`tasks`,t.kind===`dir`?`confirm.deleteBodyDir`:`confirm.deleteBodyTask`),confirmLabel:q(`tasks`,r?`confirm.childrenPromote`:`confirm.deleteConfirm`),onConfirm:()=>i({}),...r?{secondary:{label:q(`tasks`,`confirm.childrenCascade`),onConfirm:()=>i({cascade:!0})}}:{},escalate:{when:e=>e instanceof r_&&e.code===`DIRTY_WORKTREE`,label:q(`tasks`,`confirm.forceDeleteConfirm`),title:q(`tasks`,`confirm.forceDeleteTitle`,{title:t.label}),body:e=>`${q(`worktrees`,`delete.forceBody`,{branch:t.branch||t.title})}\n\n${q(`worktrees`,`delete.forceReason`,{reason:K(e).replace(`task ${t.id} `,``)})}`,run:e=>i({force:!0,...e?{cascade:!0}:{}})}})}function QP(e,t){let n=XP(e,t.id),r=n.length>0,i=t.label,a=async()=>{let{tabs:n}=await e.client.request(`task.tabs`,{taskId:t.id});for(let r of n)await e.client.request(`tab.close`,{taskId:t.id,tabId:r.id});await e.refreshTabsNow()},o,s=async t=>{for(let r of n)try{await e.client.request(`task.delete`,{taskId:r.id,cascade:!0,...t?{force:!0}:{}})}catch(e){throw o=r.title,e}await a()};return(0,V.jsx)(sr,{title:r?q(`tasks`,`confirm.childrenTitle`,{title:i,count:String(n.length)}):q(`tasks`,`confirm.deleteTitleDir`,{title:i}),body:q(`tasks`,r?`confirm.childrenBodyMain`:`confirm.deleteBodyMain`),confirmLabel:q(`tasks`,r?`confirm.childrenKeepMain`:`confirm.deleteConfirm`),onConfirm:a,...r?{secondary:{label:q(`tasks`,`confirm.childrenCascadeMain`),onConfirm:()=>s(!1)}}:{},escalate:{when:e=>e instanceof r_&&e.code===`DIRTY_WORKTREE`,label:q(`tasks`,`confirm.forceDeleteConfirm`),title:q(`tasks`,`confirm.forceDeleteTitle`,{title:i}),body:e=>`${q(`worktrees`,`delete.forceBody`,{branch:o??i})}\n\n${K(e)}`,run:()=>s(!0)}})}async function $P(e,t){let n=t.archived!==!0,r=t.label,i=async i=>{await e.client.request(`task.archive`,{taskId:t.id,archived:n,...i?{force:!0}:{}}),G(q(`tasks`,n?`archive.done`:`archive.restored`,{title:r}))};try{await i(!1)}catch(e){if(n&&e instanceof r_&&e.code===`TASK_BUSY`){W.set((0,V.jsx)(sr,{title:q(`tasks`,`archive.busyTitle`),body:q(`tasks`,`archive.busyBody`,{title:r}),confirmLabel:q(`tasks`,`archive.busyConfirm`),onConfirm:()=>i(!0)}));return}G(q(`tasks`,n?`archive.failed`:`archive.restoreFailed`,{error:K(e)}),`error`)}}function eF(e,t,n){return(0,V.jsx)(sr,{title:q(`tasks`,`confirm.forgetProjectTitle`,{title:n}),body:q(`tasks`,`confirm.forgetProjectBody`),confirmLabel:q(`tasks`,`confirm.forgetProjectConfirm`),onConfirm:async()=>{try{await e.client.request(`project.forget`,{repo:t})}catch(e){throw Error(q(`tasks`,`toast.forgetProjectFailed`,{error:K(e)}))}}})}var tF=e=>{let{taskId:t}=e.selection.get();return e.tasks.get()?.tasks.find(e=>e.id===t)??null},nF=e=>{let{taskId:t,tabId:n}=e.selection.get(),r=t?e.tabs.get()[t]?.find(e=>e.id===n):void 0;return!!r&&!bw(r.split)},rF=[{id:`app.refresh`,live:()=>oi.get().stale,run:e=>ui(e.client)},{id:`palette.open`,live:()=>!0,run:Xk},{id:`task.new.global`,live:()=>!0,run:e=>KD(tF(e)?.repo)},{id:`chat.tab.fork`,live:e=>!!tF(e),run:e=>{let t=tF(e);t&&W.set((0,V.jsx)(RC,{model:e,taskId:t.id,context:`continue`}))}},{id:`chat.fork.new`,live:e=>!!tF(e),run:e=>{let t=tF(e);t&&W.set((0,V.jsx)(RC,{model:e,taskId:t.id,destination:`fork`}))}},{id:`settings.open`,live:()=>!0,run:e=>W.set((0,V.jsx)(FP,{model:e}))},{id:`inbox.show`,live:()=>!0,run:e=>W.set((0,V.jsx)(DT,{model:e}))},{id:`focus.previous`,live:()=>!0,run:()=>Gi(-1)},{id:`focus.next`,live:()=>!0,run:()=>Gi(1)},{id:`workspace.zenToggle`,live:e=>!!tF(e),run:()=>un.set(!un.get())},{id:`files.createPR`,live:e=>!!tF(e),run:e=>{let t=tF(e);t&&e.client.request(`tab.requestPR`,e.engineTarget(t.id)).then(()=>G(z(`files.prRequested`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},{id:`chat.tab.close`,live:e=>!!e.selection.get().tabId&&nF(e),run:e=>{let{taskId:t,tabId:n}=e.selection.get();!t||!n||e.client.request(`tab.close`,{taskId:t,tabId:n}).then(()=>e.refreshTabsNow()).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},{id:`kanban.open`,live:e=>e.installedMods.get().has(`kanban`),run:()=>ha(`kanban`)},{id:`automations.open`,live:()=>!0,run:()=>ha(`routines`)},{id:`workItems.open`,live:e=>e.installedMods.get().has(`issues`),run:()=>ha(`issues`)},{id:`task.moveMode`,live:e=>!!eA(e),run:()=>{zT(!LT.get()),document.querySelector(`.rail`)?.focus()}},{id:`files.syncBase`,live:e=>eA(e)?.kind===`task`,run:e=>{let t=eA(e);t&&KP(e,t.id)}},{id:`files.fixChecks`,live:e=>!!eA(e),run:e=>{let t=eA(e);t&&JP(e,t.id,z(`taskops.fixSent`))}},{id:`task.openEditor`,live:e=>!!eA(e),run:e=>{let t=eA(e);t&&YP(e,t.id)}}];qi(()=>rF.map(e=>({id:e.id,chords:ni(e.id),prefix:!0,live:e.live,run:e.run})));function iF(e){return Ya(e[0]??``)}function aF(e,t){let n=Qi(),r=Yi().filter(t=>t.prefix&&Xi(t,n)&&t.live?.(e)!==!1);for(let e of t){let t=r.filter(t=>t.chords.includes(e)).sort((e,t)=>Zi(e,n)-Zi(t,n))[0];if(t)return t}}var oF=null,sF=null;function cF(){oF=null,sF!==null&&window.clearTimeout(sF),sF=null;let e=Jw.get();e.guide?.kind===`prefix`&&Jw.set({...e,guide:null})}function lF(){if(oF!==null){cF();return}W.get()||Zr()===null||(oF=Date.now(),Jw.set({...Jw.get(),guide:{kind:`prefix`,armedAt:oF}}),sF!==null&&window.clearTimeout(sF),sF=window.setTimeout(cF,Kr.get().prefix.timeoutMs))}function uF(e,t){cF();let n=typeof t==`string`?[t]:t,r=aF(e,n);Xw(iF(n),r?.id??null),r?.run(e)}var dF=null;function fF(){dF!==null&&window.clearTimeout(dF),dF=null;let e=Jw.get();e.guide?.kind===`direct`&&Jw.set({...e,guide:null})}function pF(){dF!==null||W.get()||(dF=window.setTimeout(()=>{cF(),Jw.set({...Jw.get(),guide:{kind:`direct`}})},400))}function mF(e){(0,g.useEffect)(()=>{let t=t=>{if(t.key===`Control`){t.repeat||pF();return}if(fF(),[`Shift`,`Alt`,`Meta`].includes(t.key))return;let n=Ja(t),{firstStrokes:r,timeoutMs:i}=Kr.get().prefix;if(oF!==null&&Date.now()-oF<=i){if(t.preventDefault(),t.stopImmediatePropagation(),t.key===`Escape`)return cF();uF(e,n);return}cF(),!W.get()&&n.some(e=>r.includes(e))&&(t.preventDefault(),t.stopImmediatePropagation(),lF())},n=e=>e.key===`Control`&&fF(),r=e=>{oF!==null&&(e.target instanceof Element&&e.target.closest(`.prefix-guide, .shortcut-badge, [data-prefix-arm]`)||cF())};return window.addEventListener(`keydown`,t,{capture:!0}),window.addEventListener(`keyup`,n,{capture:!0}),window.addEventListener(`pointerdown`,r,{capture:!0}),window.addEventListener(`blur`,fF),()=>{window.removeEventListener(`keydown`,t,{capture:!0}),window.removeEventListener(`keyup`,n,{capture:!0}),window.removeEventListener(`pointerdown`,r,{capture:!0}),window.removeEventListener(`blur`,fF),fF(),cF()}},[e])}function hF(e){let t=Qi(),n=new Map;for(let r of Yi()){if(!r.prefix||!Xi(r,t)||r.live?.(e)===!1)continue;let i=Zi(r,t);for(let e of r.chords){let t=n.get(e);(!t||i<t.rank)&&n.set(e,{action:r.id,rank:i})}}return[...n].map(([e,{action:t}])=>({stroke:e,action:t}))}function gF(e){let t=new Map(Vr.map((e,t)=>[e.id,t])),n=new Map;for(let{stroke:t,action:r}of e)n.set(r,[...n.get(r)??[],t]);let r=new Map,i=[...n].sort(([e],[n])=>(t.get(e)??2**53-1)-(t.get(n)??2**53-1));for(let[e,t]of i){let n=ao(e);r.set(n,[...r.get(n)??[],{action:e,strokes:t}])}return[...r].map(([e,t])=>({category:e,actions:t}))}var _F=e=>e===`prefix.moreCommands`?_o(`moreCommandsPrefix`):xo(e);function vF(e){let[,t]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(e===null)return;let n=window.setTimeout(()=>t(e=>e+1),Math.max(30,e-Date.now()));return()=>window.clearTimeout(n)},[e])}function yF({model:e}){B();let t=v(Jw);v(Kr),v(e.selection);let n=Date.now(),r=t.entries.filter(e=>n-e.at<qw),i=t.guide?.kind===`prefix`?t.guide.armedAt:null,a=i!==null&&n-i<Kw?i+Kw:null;vF(a??(r[0]?r[0].at+qw:null));let o=t.guide?.kind===`direct`||i!==null&&a===null;if(!o&&!t.guide&&r.length===0)return null;if(o&&t.guide){let n=t.guide.kind===`direct`,r=n?Ww($i(e,Qi()),Zr()):hF(e);return(0,V.jsxs)(`output`,{className:`mono ${tt}`,onMouseDown:e=>e.preventDefault(),children:[(0,V.jsxs)(`div`,{className:rt,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:n?_o(`directLayer`):_o(`commandLayer`,{prefix:Zr()??``})}),(0,V.jsx)(`span`,{className:`keys-only text-muted`,children:_o(n?`releaseCtrl`:`escCancel`)})]}),(0,V.jsx)(`div`,{className:it,children:gF(r).map(t=>(0,V.jsxs)(`div`,{className:at,children:[(0,V.jsx)(`div`,{className:`text-accent`,children:So(t.category)}),t.actions.map(({action:t,strokes:r})=>(0,V.jsxs)(`button`,{type:`button`,className:ot,disabled:n,onClick:()=>r[0]&&uF(e,r[0]),children:[(0,V.jsx)(`span`,{className:nt,children:r.map(Ya).join(`/`)}),(0,V.jsx)(`span`,{children:_F(t)})]},t))]},t.category))})]})}return(0,V.jsxs)(`output`,{className:yt,children:[r.map(e=>(0,V.jsxs)(bF,{at:e.at,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:Zr()}),` + `,e.stroke,` →`,` `,e.action?_F(e.action):(0,V.jsx)(`span`,{className:`text-muted`,children:`∅`})]},e.id)),i!==null&&(0,V.jsxs)(`div`,{className:bt(!1),children:[(0,V.jsx)(`span`,{className:`text-accent`,children:Zr()}),` ⋯`]})]})}function bF({at:e,children:t}){let[n]=(0,g.useState)(Date.now),r=n-e>140,i={"--hud-out":`${e+qw-140-n}ms`};return(0,V.jsx)(`div`,{className:bt(r),style:i,children:t})}function xF({model:e,bindingId:t,head:n=!1}){let r=v(Jw);v(Kr);let i=A_().prefs.prefixTap;if(r.guide?.kind!==`prefix`||i!==`local`)return null;let a=Uw({bindingId:t,reachability:$i(e,Qi()),prefixKey:Zr()});if(!a)return null;let o=Yi().find(e=>e.id===t&&e.prefix)?.chords[0];return(0,V.jsx)(`button`,{type:`button`,className:`mono ${qe(n)}`,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),o&&uF(e,o)},children:a})}var SF=[`workingBorder`,`runningTitle`,`taskColors`,`glyphSet`,`colorblind`];function CF(e){let{client:t}=e,n=A_(),r=XM(),i=v(x_);ZM(e),sP(e),(0,g.useEffect)(()=>{let e=()=>{O_(t).catch(()=>void 0),ID(t).catch(()=>void 0)},n=()=>document.visibilityState===`visible`&&e(),r=t.onOpen(e);return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,n),()=>{r(),window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,n)}},[t]),(0,g.useEffect)(()=>{let e=document.documentElement,t=i?i[r]:u_(n.themes,n.prefs.theme,r),a=t?v_(t,n.prefs):{};for(let[t,n]of Object.entries(a))e.style.setProperty(t,n);e.style.colorScheme=r;for(let t of SF)e.dataset[t]=String(n.prefs[t]);b_.set(t?y_(t):null);let o=document.querySelector(`meta[name="theme-color"]`);o||(o=document.createElement(`meta`),o.name=`theme-color`,document.head.append(o)),o.content=getComputedStyle(document.body).backgroundColor},[n,r,i]),(0,g.useEffect)(()=>{n.loaded&&un.get()!==n.prefs.zen&&un.set(n.prefs.zen)},[n.loaded,n.prefs.zen]),(0,g.useEffect)(()=>un.subscribe(()=>{un.get()!==T_.get().prefs.zen&&k_(t,`zen`,un.get())}),[t])}var wF={sidebar:[{id:`sidebar.nav`,msg:`move`},{id:`sidebar.select`,msg:`open`}],files:[{id:`files.nav`,msg:`move`},{id:`files.hierarchy`,msg:`collapse`},{id:`files.open`,msg:`open`,always:!0},{id:`files.diff`,msg:`diff`,always:!0}]};function TF(e,t){return wF[e].flatMap(e=>{if(t===`always`&&e.always!==!0)return[];let n=eo(e.id);return n?[{cap:n,msg:e.msg}]:[]})}var EF=e=>`rove.web.hintUsed.${e}`,DF=_({sidebar:localStorage.getItem(EF(`sidebar`))===`1`});function OF(e){DF.get()[e]||(localStorage.setItem(EF(e),`1`),DF.set({...DF.get(),[e]:!0}))}function kF(e,t){return e.kind===`task`&&t.kind===`task`?e.taskId===t.taskId:e.kind===`page`&&t.kind===`page`?e.id===t.id:e.kind===`new`&&t.kind===`new`}var AF={entries:[],at:-1};function jF(e,t){let n=e.entries[e.at];if(n&&kF(n,t)){let n=[...e.entries];return n[e.at]=t,{entries:n,at:e.at}}let r=[...e.entries.slice(0,e.at+1),t].slice(-50);return{entries:r,at:r.length-1}}function MF(e,t,n){for(let r=e.at+t;r>=0&&r<e.entries.length;r+=t){let t=e.entries[r];if(t&&n(t))return r}return-1}var NF=_(AF);function PF(e){let t=on.get();if(t)return{kind:`page`,id:t};let n=dn.get();if(n)return{kind:`new`,start:n};let{taskId:r,tabId:i}=e.selection.get();return r?{kind:`task`,taskId:r,tabId:i}:null}function FF(e,t){if(t.kind!==`task`)return!0;let n=e.tasks.get()?.tasks.find(e=>e.id===t.taskId);return n!==void 0&&!n.deleting}var IF=!1;function LF(e){let t=!1,n=()=>{t||(t=!0,queueMicrotask(()=>{if(t=!1,IF)return;let n=PF(e);n&&NF.set(jF(NF.get(),n))}))};n();let r=[e.selection.subscribe(n),on.subscribe(n),dn.subscribe(n)];return()=>{for(let e of r)e()}}function RF(e,t){let n=NF.get(),r=MF(n,t,t=>FF(e,t)),i=n.entries[r];i&&(IF=!0,i.kind===`task`?(on.set(null),dn.set(null),e.select(i.taskId,i.tabId)):i.kind===`page`?(dn.set(null),ha(i.id)):(on.set(null),dn.set(i.start)),NF.set({entries:n.entries,at:r}),queueMicrotask(()=>{IF=!1}))}var zF={working:`info`,waiting:`warning`,error:`attention`,done:`success`,idle:`muted`},BF={prOpen:``,prMerged:``,prClosed:``};function VF(e){let t=HF(e);return{look:t,tone:zF[t]}}function HF(e){switch(e?.kind){case`busy`:case`running`:return`working`;case`needs-input`:return`waiting`;case`attention`:return e.reason===`rate_limited`?`waiting`:`error`;case`unseen`:return`done`;default:return`idle`}}function UF(e){return e.rowStatus?.kind===`needs-input`||e.rowStatus?.kind===`attention`}var WF={busy:0,attention:1,"needs-input":2,running:3,unseen:4,idle:5};function GF(e){let t;for(let{rowStatus:n}of e)n&&(!t||WF[n.kind]<WF[t.kind]||n.kind===t.kind&&n.since>t.since)&&(t=n);return t}function KF(e,t,n){if(!e)return null;if(e.lifecycle===`merged`)return{glyph:BF.prMerged,tone:n?`text-muted`:`text-merged`,state:`merged`};if(e.lifecycle===`closed`)return{glyph:BF.prClosed,tone:`text-muted`,state:`closed`};if(e.lifecycle!==`open`&&e.lifecycle!==`ready_to_merge`&&e.lifecycle!==`unknown`)return null;let r=t===`conflict`?`conflict`:t===`failing`?`failing`:t===`passing`?`passing`:e.checkState===`pending`?`pending`:void 0,i=n?`text-muted`:r===`conflict`||r===`failing`?`text-error`:r===`passing`?`text-success`:`text-muted`;return{glyph:BF.prOpen,tone:i,state:`open`,...r?{checks:r}:{}}}function qF(e){return KF(e.pr,e.prChip,e.prChipStale===!0)}function JF(e){return KF(e,(e.mergeable??``).toUpperCase()===`CONFLICTING`?`conflict`:e.checkState===`failing`?`failing`:e.checkState===`passing`?`passing`:null,!1)}function YF(e){let t=e=>e.state===`open`?e.tone===`text-error`?0:1:e.state===`merged`?2:3;return[...e].sort((e,n)=>t(e)-t(n))[0]}var XF=192,ZF=`rove.web.railWidth`,QF=`rove.web.railFolded`;function $F(){let e=Number(localStorage.getItem(ZF));return Number.isFinite(e)&&e>0?e:null}var eI=_($F());eI.subscribe(()=>{let e=eI.get();e===null?localStorage.removeItem(ZF):localStorage.setItem(ZF,String(Math.round(e)))}),eI.subscribe(Sn);var tI=_(localStorage.getItem(QF)===`1`);tI.subscribe(()=>localStorage.setItem(QF,tI.get()?`1`:`0`));var nI=_(!1),rI=null;function iI(e){rI!==null&&window.clearTimeout(rI),rI=null,e?nI.set(!0):rI=window.setTimeout(()=>nI.set(!1),250)}tI.subscribe(()=>nI.set(!1)),tI.subscribe(Sn);function aI(e,t=window.innerWidth){let n=Math.max(XF,t-320);return Math.max(XF,Math.min(n,Math.round(e)))}var oI=`flex-none fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.25]`,sI=(e={})=>`relative grid cursor-pointer place-items-center rounded-sm border-none p-0 disabled:cursor-default disabled:opacity-35 [&_svg]:fill-none [&_svg]:stroke-current [&_svg]:[stroke-linecap:round] [&_svg]:[stroke-linejoin:round] [&_svg]:[stroke-width:1.25] touch:after:absolute touch:after:-inset-x-px touch:after:-top-2 touch:after:-bottom-1.25 touch:after:content-[''] touch:first:after:-left-2 ${e.tool?`size-5.5 flex-none`:`size-6.5`} ${e.tool||e.small?`[&_svg]:size-3.5`:`[&_svg]:size-4`} ${e.on?`bg-accent-soft text-accent`:`bg-transparent text-subtle enabled:hover:bg-hover enabled:hover:text-ink`}`,cI=`absolute top-2 left-2 z-7 flex items-center gap-0.5`,lI=`[&.is-resizing_iframe]:pointer-events-none`,uI=e=>`side-panel ${Ve} relative row-1 flex min-h-0 min-w-0 flex-col ${lI} ${e?`flex-1 p-0`:`pt-2 pr-1 pb-1 pl-0`}`,dI=`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)] [--divider:5px] *:col-1 ${lI}`,fI=e=>`side-head flex min-h-6.5 min-w-0 items-center gap-0.5 pb-1.5 font-mono text-meta normal-nums ${e?`px-2 pt-0`:`narrow:px-2 narrow:pt-0`}`,pI=`scrollbar-none flex min-w-0 flex-1 gap-0.5 overflow-x-auto`,mI=e=>`group/ptab relative flex max-w-40 items-center hover:text-ink data-[drop=after]:shadow-[inset_-2px_0_0_var(--accent)] data-[drop=before]:shadow-[inset_2px_0_0_var(--accent)] ${e.active?`is-active text-ink`:`text-muted`} ${e.compact&&!e.active?`min-w-0 flex-none`:`min-w-18 flex-initial`}`,hI=e=>`flex min-w-0 cursor-pointer items-center gap-1.5 border-none bg-transparent text-inherit [font:inherit] ${e?`px-1.75 py-1`:`py-1 pr-0.5 pl-2`}`,gI=`truncate`,_I=`touch:relative size-4 flex-none cursor-pointer rounded-xs border-none bg-transparent p-0 mr-1 font-mono text-title leading-none text-subtle opacity-0 group-hover/ptab:opacity-100 hover:bg-hover hover:text-ink focus-visible:opacity-100 [@media(hover:none)]:opacity-100 touch:after:absolute touch:after:-inset-1.5 touch:after:-left-1 touch:after:content-['']`,vI=`ml-auto flex gap-0.5`,yI=`relative row-3 cursor-row-resize touch-none before:absolute before:inset-x-0 before:top-[calc(var(--divider)/2)] before:h-px before:bg-line before:content-[''] hover:before:bg-line-active after:absolute after:inset-x-0 after:-inset-y-0.75 after:content-['']`,bI=`side-view flex min-h-0 min-w-0 flex-col [&[hidden]]:hidden`,xI=`row-2 m-auto flex max-w-[44ch] flex-col items-center gap-2.5 p-4 text-center font-mono text-meta leading-[1.5] text-subtle normal-nums`,SI=`flex min-h-0 flex-1 flex-col gap-1.5`,CI=`flex items-center gap-0.5 [&_svg]:flex-none`,wI=`mx-0.5 min-w-0 flex-1 rounded-sm border-none bg-inset px-2 py-1 text-ink [font-size:var(--fs-meta)] focus:bg-hover focus:outline-none aria-invalid:text-muted`,TI=`min-w-0 flex-1 rounded-sm border-none bg-[#fff]`;function EI({edge:e,className:t,...n}){return(0,V.jsx)(`div`,{"data-grip":``,className:ke(`absolute inset-y-0 z-5 w-1.5 cursor-col-resize touch-none`,`after:absolute after:inset-y-0 after:w-0.5 after:bg-line-active after:opacity-0 after:transition-opacity after:duration-120`,`hover:after:opacity-100 hover:after:delay-250 active:after:bg-accent active:after:opacity-100 active:after:delay-0`,e===`right`?`right-0 after:right-0`:`left-0 after:left-0`,t),...n})}var DI=400;function OI({rail:e}){B();let t=(0,g.useRef)(null),n=(0,g.useRef)(0);return(0,V.jsx)(EI,{edge:`right`,title:z(`layout.railResize`),onPointerDown:n=>{t.current={x:n.clientX,width:e.current?.getBoundingClientRect().width??0,moved:!1},n.currentTarget.setPointerCapture(n.pointerId),Cn(!0)},onPointerMove:e=>{let n=t.current;!n||e.clientX===n.x||(n.moved=!0,eI.set(aI(n.width+e.clientX-n.x)))},onPointerUp:()=>{let e=t.current;if(t.current=null,!e)return;if(e.moved){n.current=0;return}let r=Date.now();r-n.current<DI?(n.current=0,eI.set(null)):n.current=r},onLostPointerCapture:()=>Cn(!1)})}function kI({side:e}){return(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,V.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`13`,height:`11`,rx:`2.5`}),(0,V.jsx)(`path`,{d:e===`left`?`M6 2.5v11`:`M10 2.5v11`})]})}function AI({model:e}){B();let t=v(NF),n=v(tI),r=v(e.tasks),i=t=>FF(e,t),a=z(n?`layout.railUnfold`:`layout.railFold`),o=n&&(r?.tasks??[]).some(UF);return(0,V.jsxs)(`div`,{className:cI,onMouseEnter:()=>n&&nI.get()&&iI(!0),onMouseLeave:()=>n&&nI.get()&&iI(!1),children:[(0,V.jsxs)(`button`,{type:`button`,className:sI(),title:a,"aria-label":a,onClick:()=>tI.set(!n),children:[(0,V.jsx)(kI,{side:`left`}),o&&(0,V.jsx)(`span`,{className:`absolute top-0.75 right-0.75 size-1.5 rounded-full bg-accent`})]}),(0,V.jsx)(`button`,{type:`button`,className:sI(),title:z(`layout.navBack`),"aria-label":z(`layout.navBack`),disabled:MF(t,-1,i)<0,onClick:()=>RF(e,-1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M10 3.5 5.5 8l4.5 4.5`})})}),(0,V.jsx)(`button`,{type:`button`,className:sI(),title:z(`layout.navForward`),"aria-label":z(`layout.navForward`),disabled:MF(t,1,i)<0,onClick:()=>RF(e,1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M6 3.5 10.5 8 6 12.5`})})})]})}var jI={terminal:`layout.narrowTerminal`,chat:`layout.narrowChat`,files:`layout.narrowFiles`,diff:`layout.narrowDiff`,browser:`layout.narrowBrowser`};function MI({taskId:e}){B();let t=v(za);return(0,V.jsxs)(`div`,{className:Ue,children:[(0,V.jsx)(`button`,{type:`button`,className:`mono ${We}`,onClick:ma,children:(0,V.jsx)(`span`,{className:`text-accent`,children:`‹ ${Co(`narrowBack`)}`})}),e&&(0,V.jsx)(`span`,{className:`mono ml-auto flex gap-0.5`,role:`tablist`,children:[`terminal`,...Ra].map(n=>(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,className:Ge,onClick:()=>n===`terminal`?za.set(n):zk(e,n),children:z(jI[n])},n))})]})}function NI({title:e}){return B(),(0,V.jsxs)(`button`,{type:`button`,className:Qn({}),onClick:pa,children:[(0,V.jsx)(`span`,{className:`${nr} font-bold text-accent`,children:`↩`}),(0,V.jsx)(`span`,{className:$n,children:wo(`recentJump`,{title:e})})]})}function PI({pane:e}){B();let{prefs:t}=A_(),n=v(DF)[e];if(!t.keyHints)return null;let r=TF(e,n?`always`:`firstUse`);return r.length===0?null:(0,V.jsx)(`p`,{className:`mono text-muted ${Ke}`,children:(0,V.jsx)(ST,{text:r.map(e=>`${Gr(e.cap)} ${vo(`pane.${e.msg}`)}`).join(` · `)})})}var FI=`rove.awaySeen`,II=6e4,LI=e=>e.filter(e=>!e.deleting),RI=e=>e.pr?.lifecycle===`merged`,zI={error:!0,dead:!0};function BI(e,t,n){if(!t||n-t.at<=6e5)return null;let r=LI(e),i=e=>(e.activity?.since??0)>t.at,a=r.filter(e=>zI[e.activity?.state??``]===!0&&i(e)),o=r.filter(e=>e.group===`waiting-on-you`&&!a.includes(e)),s=r.filter(e=>e.activity?.state===`turn_complete`&&i(e)),c=r.filter(e=>RI(e)&&!t.merged.includes(e.id));return s.length+o.length+a.length+c.length===0?null:{since:t.at,finished:s,needs:o,failed:a,merged:c}}var VI=_(null);function HI(){try{let e=JSON.parse(localStorage.getItem(FI)??`null`);return e&&typeof e.at==`number`&&Array.isArray(e.merged)?e:null}catch{return null}}function UI(e,t){let n={at:t,merged:LI(e).filter(RI).map(e=>e.id)};try{localStorage.setItem(FI,JSON.stringify(n))}catch{}}var WI=8e3;function GI(e,t){let n=null,r=0,i,a=()=>{let t=e();t&&!document.hidden&&UI(t.tasks,Date.now())},o=()=>{n=null,a()},s=()=>{let t=e();if(!t||document.hidden)return;let s=Date.now();if(!n){let e=HI();e&&s-e.at>6e5&&(n=e,r=s+WI,i=setTimeout(o,WI))}if(!n){a();return}let c=BI(t.tasks,n,r-WI);c&&VI.set(c)};s();let c=t(s);document.addEventListener(`visibilitychange`,s);let l=setInterval(()=>{n||a()},II);return()=>{c(),document.removeEventListener(`visibilitychange`,s),clearInterval(l),clearTimeout(i)}}var KI=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function qI(e,t,n){let r=t.currentTarget.getBoundingClientRect();nn.set({x:r.left,y:r.bottom,target:t.currentTarget,items:n.map(t=>({label:t.label,run:()=>e.select(t.id)}))})}function JI({model:e}){B(),(0,g.useEffect)(()=>GI(()=>e.tasks.get(),t=>e.tasks.subscribe(t)),[e]);let t=v(VI);if(!t)return null;let n=[{key:`finished`,rows:t.finished,open:n=>qI(e,n,t.finished)},{key:`needs`,rows:t.needs,open:()=>W.set((0,V.jsx)(DT,{model:e}))},{key:`failed`,rows:t.failed,open:n=>qI(e,n,t.failed)},{key:`merged`,rows:t.merged,open:n=>qI(e,n,t.merged)}];return(0,V.jsxs)(`div`,{className:tE,children:[(0,V.jsxs)(`span`,{className:`text-muted`,children:[z(`rail.recap.since`,{time:KI(t.since)}),` ·`]}),n.filter(e=>e.rows.length>0).map((e,t,n)=>(0,V.jsxs)(`span`,{className:`inline-flex gap-2.5`,children:[(0,V.jsx)(H,{hit:`tight`,onClick:e.open,children:z(`rail.recap.${e.key}`,{count:e.rows.length})}),t<n.length-1&&(0,V.jsx)(`span`,{className:`text-muted`,children:`·`})]},e.key)),(0,V.jsx)(H,{hit:`tight`,className:`ml-auto`,"aria-label":z(`rail.recap.dismiss`),title:z(`rail.recap.dismiss`),onClick:()=>VI.set(null),children:`×`})]})}function YI(e,t){return e.filter(e=>e.groupId===t).sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``)||e.title.localeCompare(t.title))}var XI=400;function ZI(e){let t=null;for(let n of e.history?.messages??[]){if(n.role!==`assistant`)continue;let e=(n.blocks??[]).flatMap(e=>e.type===`text`&&e.text?[e.text]:[]).join(`
122
122
  `).trim(),r=n.timestamp??``;e&&(!t||r>t.at)&&(t={at:r,text:e})}let n=(e.terminal?.tail??[]).map(e=>e.trimEnd()).filter(e=>e.trim()!==``),r=t?.text??n.slice(-6).join(`
123
- `);return r?r.length>JI?`${r.slice(0,JI).trimEnd()}…`:r:null}function XI(e){let t=e.files.filter(e=>e.scope===`working`),n=t.length>0?`working`:`branch`,r=n===`working`?t:e.files.filter(e=>e.scope===`branch`);return{scope:n,files:r,added:r.reduce((e,t)=>e+(t.added??0),0),deleted:r.reduce((e,t)=>e+(t.deleted??0),0)}}async function ZI(e,t,n){let r=new Set(e.tasks.get()?.tasks.map(e=>e.id)),i=0;try{for(let a of t.filter(e=>r.has(e)))await e.client.request(`task.archive`,{taskId:a,archived:!0,...n?{force:!0}:{}}),i++}catch(e){if(i>0&&G(z(`compare.archived`,{count:i})),e instanceof r_&&e.code===`TASK_BUSY`)throw e;G(z(`compare.archiveFailed`,{error:K(e)}),`error`);return}G(z(`compare.archived`,{count:i}))}async function QI(e,t,n){try{for(let r of n)r.id!==t.id&&r.kept&&await e.client.request(`task.keep`,{taskId:r.id,kept:!1});await e.client.request(`task.keep`,{taskId:t.id,kept:!0})}catch(e){G(z(`compare.keepFailed`,{error:K(e)}),`error`);return}G(z(`compare.keptToast`,{title:t.label}));let r=n.filter(e=>e.id!==t.id).map(e=>e.id);r.length!==0&&W.set((0,V.jsx)(sr,{title:z(`compare.archiveTitle`),body:z(`compare.archiveBody`,{count:r.length}),confirmLabel:z(`compare.archiveConfirm`),onConfirm:()=>ZI(e,r,!1),escalate:{when:e=>e instanceof r_&&e.code===`TASK_BUSY`,label:z(`compare.archiveBusyConfirm`),title:z(`compare.archiveBusyTitle`),body:()=>z(`compare.archiveBusyBody`),run:()=>ZI(e,r,!0)}}))}async function $I(e,t){try{await e.client.request(`task.keep`,{taskId:t.id,kept:!1}),G(z(`compare.unkeptToast`,{title:t.label}))}catch(e){G(z(`compare.keepFailed`,{error:K(e)}),`error`)}}var eL={title:`ROUTINES`,holdingDaemon:`keeping the daemon awake`,notHolding:`none active`,needAttention:`{count} of {total} need you ·`,paused:`paused`,newTitle:`New routine`,composerLegend:`enter create · tab fields · ←→ ↑↓ edit the focused field · esc cancel`,fieldName:`NAME`,fieldRepo:`REPO`,fieldTarget:`DELIVER TO`,fieldTargetTab:`EXISTING ENGINE TAB`,targetFresh:`New task on each run`,targetStanding:`Routine-owned standing task`,targetExisting:`Existing conversation: {task} / {tab}. Never creates or revives a session.`,fieldPrompt:`PROMPT`,fieldSchedule:`SCHEDULE (FIVE-FIELD CRON)`,namePlaceholder:`weekday dependency audit`,promptPlaceholder:`Audit dependencies and summarize risky changes.`,noProject:`Ungrouped`,cronInvalid:`not a five-field cron`,cronField:{minute:`min`,hour:`hour`,dayOfMonth:`day`,month:`month`,dayOfWeek:`weekday`},schedule:{everyDay:`every day {at}`,weekdays:`weekdays {at}`,weekends:`weekends {at}`,onWeekday:`{weekday} {at}`,everyMinute:`every minute`,everyMinutes:`every {n}m`,everyHours:`every {n}h`,hourlyAt:`hourly at :{minute}`,atClock:`at {time}`,dow:{MON:`Mondays`,TUE:`Tuesdays`,WED:`Wednesdays`,THU:`Thursdays`,FRI:`Fridays`,SAT:`Saturdays`,SUN:`Sundays`}},when:{inMinutes:`in {n}m`,inHours:`in {n}h`,inDays:`in {n}d`,minutesAgo:`{n}m ago`,hoursAgo:`{n}h ago`,now:`now`,justNow:`just now`,dateTime:`{date}, {time}`},runStatus:{dispatched:`dispatched`,revived:`revived`,skipped_cancelled:`cancelled before delivery`,skipped_precheck:`skipped (precheck)`,skipped_blocked:`skipped (task can't use it)`,skipped_missed:`skipped (missed)`,skipped_unavailable:`skipped (unavailable)`,dispatch_failed:`dispatch failed`,ran:`ran`,script_failed:`script failed`},cronNever:`valid, but never fires`,missing:{target:`Choose an existing task.`,targetTab:`Enter an existing tab id, e.g. tab-2.`,name:`Give it a name.`,repo:`Pick a project.`,prompt:`Say what it should do.`,schedule:`That schedule will not run.`},empty:`No routines scheduled.`,emptyHint:`Press n to create one.`,precheck:`precheck: {command}`,lastFailed:`last failed {when}: {reason}`,recentRuns:`RECENT RUNS`,precheckDetail:`WHY IT SKIPPED — precheck {exit} in {duration}ms`,precheckExited:`exited {code}`,precheckTimedOut:`timed out`,precheckStdout:`stdout`,precheckStderr:`stderr`,precheckNoOutput:`(no output)`,noRuns:`Not run yet.`,responses:`RESPONSES`,noResponses:"No run has reported back yet. Agents answer with `routine-respond`.",responseAwaiting:`awaiting response`,responseMissing:`no response`,noSelection:`A routine runs its prompt in a project on a schedule.`,running:`Running {name}…`,ranWith:`{name}: {status}`,latestRunNoTask:`The latest run created no task.`,runNow:`[ run now ]`,deleteTitle:`Delete routine?`,deleteBody:`{name} and its run history will be removed. Tasks it already created are untouched.`,deleteButton:`Delete`,createFailed:`Couldn't create the routine: {error}`,deleteFailed:`Couldn't delete "{name}": {error}`,enableFailed:`"{name}" stays paused: {error}`,disableFailed:`"{name}" stays enabled: {error}`,runFailed:`Couldn't run "{name}" now — schedule unchanged: {error}`},tL={title:`例行任务`,holdingDaemon:`正在保持守护进程常驻`,notHolding:`无启用项`,needAttention:`{total} 个中有 {count} 个需要处理 ·`,paused:`已暂停`,newTitle:`新建例行任务`,composerLegend:`enter 创建 · tab 切字段 · ←→ ↑↓ 编辑当前字段 · esc 取消`,fieldName:`名称`,fieldTarget:`投递目标`,fieldTargetTab:`既有引擎标签页`,targetFresh:`每次新建任务`,targetStanding:`例行任务自有的常驻任务`,targetExisting:`既有会话:{task} / {tab}。不会创建或重启会话。`,fieldRepo:`仓库`,fieldPrompt:`提示词`,fieldSchedule:`调度(五段 cron)`,namePlaceholder:`工作日依赖审计`,promptPlaceholder:`审计依赖并总结有风险的变更。`,noProject:`未分组`,cronInvalid:`不是合法的五段 cron`,cronField:{minute:`分`,hour:`时`,dayOfMonth:`日`,month:`月`,dayOfWeek:`星期`},schedule:{everyDay:`每天{at}`,weekdays:`工作日{at}`,weekends:`周末{at}`,onWeekday:`{weekday}{at}`,everyMinute:`每分钟`,everyMinutes:`每 {n} 分钟`,everyHours:`每 {n} 小时`,hourlyAt:`每小时的 :{minute}`,atClock:`{time}`,dow:{MON:`每周一`,TUE:`每周二`,WED:`每周三`,THU:`每周四`,FRI:`每周五`,SAT:`每周六`,SUN:`每周日`}},when:{inMinutes:`{n} 分钟后`,inHours:`{n} 小时后`,inDays:`{n} 天后`,minutesAgo:`{n} 分钟前`,hoursAgo:`{n} 小时前`,now:`即将`,justNow:`刚刚`,dateTime:`{date} {time}`},runStatus:{dispatched:`已派发`,revived:`已重启会话`,skipped_cancelled:`交付前已取消`,skipped_precheck:`已跳过(预检)`,skipped_blocked:`已跳过(任务暂不能接收)`,skipped_missed:`已跳过(错过时间)`,skipped_unavailable:`已跳过(不可用)`,dispatch_failed:`派发失败`,ran:`已运行`,script_failed:`脚本失败`},cronNever:`语法合法,但永远不会触发`,missing:{target:`请选择既有任务。`,targetTab:`请输入既有标签页 ID,例如 tab-2。`,name:`起个名字。`,repo:`选一个项目。`,prompt:`说明它要做什么。`,schedule:`这个调度不会触发。`},empty:`还没有例行任务。`,emptyHint:`按 n 新建一条。`,precheck:`预检:{command}`,lastFailed:`上次失败({when}):{reason}`,recentRuns:`最近执行`,precheckDetail:`为什么跳过 —— 预检{exit},耗时 {duration}ms`,precheckExited:`退出码 {code}`,precheckTimedOut:`超时`,precheckStdout:`标准输出`,precheckStderr:`标准错误`,precheckNoOutput:`(无输出)`,noRuns:`尚未执行。`,responses:`回报`,noResponses:"还没有执行回报。agent 用 `routine-respond` 回报。",responseAwaiting:`等待回报`,responseMissing:`未回报`,noSelection:`例行任务会按调度在某个项目里跑它的提示词。`,running:`正在运行 {name}…`,ranWith:`{name}:{status}`,latestRunNoTask:`最近一次执行没有创建任务。`,runNow:`[ 立即运行 ]`,deleteTitle:`删除这条例行任务?`,deleteBody:`将删除 {name} 及其执行记录。它已经创建的任务不受影响。`,deleteButton:`删除`,createFailed:`创建例行任务失败:{error}`,deleteFailed:`删除“{name}”失败:{error}`,enableFailed:`“{name}”仍处于暂停状态:{error}`,disableFailed:`“{name}”仍处于启用状态:{error}`,runFailed:`无法立即运行“{name}”——排程未受影响:{error}`},nL={title:`Kanban`,hint:`tab project · ←↓↑→ card · enter detail · n new · d delete · r refresh · esc close`,loading:`Loading issues…`,noRepos:"No projects yet — add one with `rove add <path>`, or file a story with `rove api issue-create`.",empty:"No issues — agents file them via `rove api issue-create`.",readFailed:"Couldn't read this project's stories: {error}. Run `rove doctor`, then reopen Kanban.",readFailedToast:`Couldn't read stories for {repo}: {error}`,columnEmpty:`No cards`,column:{backlog:`Backlog`,inProgress:`In progress`,parked:`Parked`,done:`Done`},more:`+{count} more`,attention:`{count} need you`,turnComplete:`turn done`,menu:{setStatus:`status → {status}`},detail:{status:{open:`open`,doing:`doing`,hold:`hold`,done:`done`},statusLabel:`STATUS`,created:`created {date}`,linked:`linked to a session`,titleLabel:`TITLE`,description:`DESCRIPTION`,noDescription:`No description.`,attachHint:`paste a path / ctrl+v screenshot → inserts an image placeholder`,engine:`ENGINE`,workspace:`WORKSPACE`,placement:{worktree:`New worktree task — its own workspace`,projectWorktree:`New worktree — as a chattab in the project workspace`,project:`Project checkout — a new chattab, no worktree`},jumpLabel:`AFTER START`,jump:{stay:`Stay on the board`,follow:`Jump to the session`},startLegend:`enter/ctrl+enter start · tab fields · ←→ status/engine · ↑↓ workspace · esc save & close`,sessionLabel:`SESSION`,openAction:`Open the linked session ↵`,unlinkAction:`Unlink`,openLegend:`enter open the focused action · tab fields · ←→ status · unlink returns the card to Backlog · esc save & close`,eventsLabel:`EVENTS`,eventsLoading:`Loading events…`,eventsNone:`No engine events recorded yet.`,doneNote:`Done stories have nothing left to start — set the status back to reopen one · esc save & close`,startedBackground:`Started in background: {title}`,newStory:`NEW STORY`,createLegend:`ctrl+s save · enter/ctrl+enter save & start · tab fields · esc cancel`},confirmDelete:{title:`Delete story #{id}?`,body:`“{title}” will be removed from the tracker. A linked task, branch, or worktree is left untouched.`},deleteFailed:`Couldn't delete story #{id}: {error}`,createFailed:`Couldn't create the story: {error}`,updateFailed:`Couldn't save story #{id}: {error}`,statusFailed:`Story #{id} stays in its old column: {error}`,linkFailed:`Story #{id} isn't linked to its task: {error}`,unlinkFailed:`Story #{id} is still linked: {error}`},rL={title:`看板`,hint:`tab 切项目 · ←↓↑→ 选卡片 · enter 详情 · n 新建 · d 删除 · r 刷新 · esc 关闭`,loading:`正在加载 issues…`,noRepos:"还没有项目——用 `rove add <路径>` 添加一个,或用 `rove api issue-create` 创建一个 story。",empty:"暂无 issue——agent 可通过 `rove api issue-create` 创建。",readFailed:"读取该项目的 story 失败:{error}。请运行 `rove doctor`,再重新打开看板。",readFailedToast:`读取 {repo} 的 story 失败:{error}`,columnEmpty:`暂无卡片`,column:{backlog:`待办`,inProgress:`进行中`,parked:`搁置`,done:`已完成`},more:`还有 {count} 条`,attention:`{count} 张等你处理`,turnComplete:`回合完成`,menu:{setStatus:`状态 → {status}`},detail:{status:{open:`待办`,doing:`进行中`,hold:`搁置`,done:`已完成`},statusLabel:`状态`,created:`创建于 {date}`,linked:`已关联会话`,titleLabel:`标题`,description:`描述`,noDescription:`暂无描述。`,attachHint:`粘贴路径 / ctrl+v 贴截图 → 插入图片占位行`,engine:`引擎`,workspace:`工作区`,placement:{worktree:`新建 worktree 任务——独立工作区`,projectWorktree:`新建 worktree——作为项目工作区里的 chattab`,project:`项目主目录——新开 chattab,不建 worktree`},jumpLabel:`启动后`,jump:{stay:`留在看板`,follow:`跳转到会话`},startLegend:`enter/ctrl+enter 启动 · tab 切字段 · ←→ 状态/引擎 · ↑↓ 工作区 · esc 保存关闭`,sessionLabel:`会话`,openAction:`打开关联会话 ↵`,unlinkAction:`解除关联`,openLegend:`enter 执行选中操作 · tab 切字段 · ←→ 状态 · 解除关联把卡片退回 Backlog · esc 保存关闭`,eventsLabel:`事件`,eventsLoading:`正在加载事件…`,eventsNone:`暂无引擎事件记录。`,doneNote:`已完成的 story 无需启动——改回状态即可重新打开 · esc 保存关闭`,startedBackground:`已在后台启动:{title}`,newStory:`新建 STORY`,createLegend:`ctrl+s 仅保存 · enter/ctrl+enter 保存并启动 · tab 切字段 · esc 取消`},confirmDelete:{title:`删除 story #{id}?`,body:`「{title}」将从 tracker 中移除。已关联的任务、分支、worktree 不受影响。`},deleteFailed:`删除 story #{id} 失败:{error}`,createFailed:`创建 story 失败:{error}`,updateFailed:`保存 story #{id} 失败:{error}`,statusFailed:`Story #{id} 仍留在原来的列:{error}`,linkFailed:`Story #{id} 未能关联到它的任务:{error}`,unlinkFailed:`Story #{id} 仍处于关联状态:{error}`},iL={title:`ISSUES`,noRepo:`no project`,empty:`No open issues.`,assignedFilter:`assigned to me`,starting:`Starting work on #{number}…`,startedNoEngine:`Created {title}, but its engine did not start.`,linkedChip:`→ {title}`,openingLinked:`Opening {title}…`,startFailed:`Couldn't start work on #{number}: {error}`,errorHint:{noRemote:"Add a GitHub remote (`git remote add origin <url>`) and try again, or press q / esc to close.",ghMissing:"Install the `gh` CLI and authenticate, or press q / esc to close.",auth:"Run `gh auth login`, or press q / esc to close.",fallback:`{message} · press q / esc to close`}},aL={title:`议题`,noRepo:`无项目`,empty:`没有开放的议题。`,assignedFilter:`分配给我的`,starting:`正在开始处理 #{number}…`,startedNoEngine:`已创建 {title},但引擎没有启动。`,linkedChip:`→ {title}`,openingLinked:`正在打开 {title}…`,startFailed:`开始处理 #{number} 失败:{error}`,errorHint:{noRemote:"添加 GitHub remote(`git remote add origin <url>`)后重试,或按 q / esc 关闭。",ghMissing:"安装 `gh` CLI 并登录,或按 q / esc 关闭。",auth:"执行 `gh auth login`,或按 q / esc 关闭。",fallback:`{message} · 按 q / esc 关闭`}};function oL(){let e=B()===`zh`;return{kanban:e?rL:nL,auto:e?tL:eL,items:e?aL:iL,nav:(e?Dr:Er).nav,group:(e?Dr:Er).group,common:e?dr:ur}}function sL(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??e))}function cL(){let{auto:e}=oL();return(t,n)=>{let r=e;for(let e of t.replace(/^automations\./,``).split(`.`))r=r&&typeof r==`object`?Reflect.get(r,e):void 0;return typeof r==`string`?n?sL(r,n):r:t}}function lL(e){return e instanceof Error?e.message:String(e)}function uL(e){return e.replace(/^\/private\//,`/`).replace(/\/+$/,``)}function dL(e,t){let n=e.split(`/`).filter(Boolean),r=n[n.length-1]??e;return t.some(t=>t!==e&&t.split(`/`).filter(Boolean).pop()===r)&&n.length>1?`${n[n.length-2]}/${r}`:r}function fL(...e){let t=new Set,n=[];for(let r of e.flat()){if(!r||r.startsWith(`ssh://`))continue;let e=uL(r);t.has(e)||(t.add(e),n.push(r))}return n}function pL(e){return fL((v(e.tasks)?.tasks??[]).filter(e=>!aw(e)).map(e=>e.repo))}function mL(e){let t=v(e.tasks),{taskId:n}=v(e.selection);return t?.tasks.find(e=>e.id===n)?.repo}function hL(e){let[t,n]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let t=window.setInterval(()=>n(e=>e+1),e);return()=>window.clearInterval(t)},[e]),[t,(0,g.useCallback)(()=>n(e=>e+1),[])]}function gL(e){return e instanceof HTMLElement?e.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName):!1}function _L(e){let t=(0,g.useRef)(e);t.current=e,(0,g.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||W.get()||nn.get())return;let n=e.target instanceof HTMLElement?e.target:null;gL(n)||n?.closest(`.rail, .side-panel, .xterm`)||e.metaKey||e.altKey||e.ctrlKey&&e.key.toLowerCase()===`c`&&window.getSelection()?.toString()||t.current(e)&&(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function vL(){let e=(0,g.useRef)(null);return(0,g.useEffect)(()=>e.current?.focus(),[]),e}function yL({tone:e,children:t}){return(0,V.jsx)(`span`,{className:ke(`flex-none font-mono text-meta`,e&&CT[e]),children:t})}var bL=`mt-3 grid grid-cols-[repeat(auto-fit,minmax(min(100%,17rem),1fr))] items-start gap-x-5 gap-y-6`,xL=e=>e?`flex min-w-0 flex-col gap-2 pt-2 [border-top:var(--hairline)_solid_var(--accent)]`:`flex min-w-0 flex-col gap-2 pt-2 [border-top:var(--hairline)_solid_var(--line)]`,SL=`flex min-w-0 items-center gap-2`,CL=`min-w-0 truncate font-bold`,wL=`truncate font-mono text-meta text-muted`,TL=`m-0 line-clamp-6 whitespace-pre-wrap wrap-anywhere`,EL=`flex min-w-0 flex-col`,DL=`flex min-w-0 items-baseline gap-2 py-px font-mono text-meta`,OL=`flex flex-wrap gap-x-3.5 gap-y-1 font-mono text-meta`,kL=`flex min-w-0 flex-wrap items-center gap-x-3.5 gap-y-0.5 px-2.5 py-1 font-mono text-meta`,AL=1.2,jL=.3,ML=20,NL=.35,PL=.25,FL=.12,IL=2,LL=1,RL={error:{dots:[0,4,8,2,6],bright:1},done:{dots:[3,7,5,2],bright:1},idle:{dots:[1,2,5,8,7,6,3,0],bright:.6}},zL=Array.from({length:9},(e,t)=>Math.hypot(t%3-1,Math.floor(t/3)-1));function BL(e){return NL+.65*(.5+.5*Math.cos(2*Math.PI*e/AL))}function VL(e,t,n,r=1){switch(e){case`working`:{let e=t*80/1e3/r;return zL.map(t=>BL(e-t*jL))}case`waiting`:{let e=[0,1,4,5].includes(Math.floor(t/r)%ML);return Array(9).fill(e?PL:1)}default:{let t=RL[e],r=Array(9).fill(FL);return t?.dots.forEach((e,i)=>{let a=Math.min(Math.max(n-i*LL,0),IL)/IL;r[e]=t.bright*a+FL*(1-a)}),r}}}function HL(e,t){let n=RL[e];return!n||t<(n.dots.length-1)*LL+IL}var UL=3,WL=new Set,GL;function KL(e,t){let n=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,r=1/0,i=e.held+t-e.step,a=HL(e.look,n?r:i);return VL(e.look,t,n?r:i,n?UL:1).forEach((t,n)=>{let r=e.el.children[n].style;r.opacity=t.toFixed(3)}),a}function qL(){let e=Math.floor(performance.now()/80);for(let t of WL)KL(t,e)||WL.delete(t);JL()}function JL(){GL=WL.size?window.setTimeout(qL,80-performance.now()%80+2):void 0}function YL(e,t,n){let r=Math.floor(performance.now()/80),i=n>0?Math.max(Date.now()-n,0):1/0,a={el:e,look:t,step:r,held:Math.floor(i/80)};return KL(a,r)&&(WL.add(a),GL===void 0&&JL()),()=>{WL.delete(a)}}function XL({status:e}){let{look:t,tone:n}=zF(e);return(0,V.jsx)(QL,{look:t,tone:n,since:e?.since??0},t)}var ZL=e=>e===`muted`?`text-muted`:e===`ink`?`text-ink`:CT[e];function QL({look:e,tone:t,since:n}){let r=(0,g.useRef)(null),[i]=(0,g.useState)(n);return(0,g.useLayoutEffect)(()=>{let t=r.current;return t?YL(t,e,i):void 0},[e,i]),(0,V.jsx)(`span`,{ref:r,className:`inline-grid flex-none grid-cols-[repeat(3,3px)] auto-rows-[3px] gap-px self-center ${ZL(t)}`,"aria-hidden":`true`,children:Array.from({length:9},(e,t)=>(0,V.jsx)(`i`,{className:`rounded-full bg-current opacity-12`},t))})}var $L=6;function eR(e,t){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.id})??null),o=`${t.rowStatus?.kind??``}:${t.rowStatus?.since??0}`,s=JSON.stringify(t.changes??null);return(0,g.useEffect)(()=>{let n=!0;return Fs(e,`output.read`,{taskId:t.id,limit:8}).then(e=>n&&r(YI(e)),()=>n&&r(null)),()=>{n=!1}},[e,t.id,o]),(0,g.useEffect)(()=>{let n=!0;return Fs(e,`diff.files`,{taskId:t.id}).then(e=>n&&a(e),()=>{}),()=>{n=!1}},[e,t.id,s,o]),{reply:n,changes:i?XI(i):null}}function tR({changes:e,onOpen:t}){if(!e)return(0,V.jsx)(`p`,{className:Wt,children:`…`});if(e.files.length===0)return(0,V.jsx)(`p`,{className:`m-0 font-mono text-meta text-subtle`,children:z(`compare.noChanges`)});let n=e.files.length-$L;return(0,V.jsxs)(`div`,{className:EL,children:[(0,V.jsxs)(`p`,{className:`m-0 flex gap-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:z(`compare.files`,{count:e.files.length})}),e.added>0&&(0,V.jsxs)(yL,{tone:`added`,children:[`+`,e.added]}),e.deleted>0&&(0,V.jsxs)(yL,{tone:`removed`,children:[`−`,e.deleted]})]}),e.files.slice(0,$L).map(n=>(0,V.jsxs)(H,{variant:`row`,className:`${DL} text-left [&:hover]:underline`,title:n.path,onClick:()=>t(n.path,e.scope),children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.path}),n.added?(0,V.jsxs)(yL,{tone:`added`,children:[`+`,n.added]}):null,n.deleted?(0,V.jsxs)(yL,{tone:`removed`,children:[`−`,n.deleted]}):null]},n.path)),n>0&&(0,V.jsx)(`span`,{className:`font-mono text-meta text-subtle`,children:z(`compare.more`,{count:n})})]})}function nR({model:e,row:t,round:n}){let{reply:r,changes:i}=eR(e,t),{look:a}=zF(t.rowStatus),o=t.kept===!0,s=(n,r)=>{e.select(t.id),Vk({taskId:t.id,path:n,scope:r})};return(0,V.jsxs)(`section`,{className:xL(o),"data-attempt":t.id,children:[(0,V.jsxs)(`div`,{className:SL,children:[(0,V.jsx)(XL,{status:t.rowStatus}),(0,V.jsx)(`span`,{className:CL,children:t.engine?.name??t.label}),(0,V.jsx)(`span`,{className:`flex-none text-meta text-muted`,children:z(`compare.status.${a}`)}),o&&(0,V.jsx)(`span`,{className:`ml-auto flex-none font-mono text-meta text-accent`,children:z(`compare.kept`)})]}),(0,V.jsx)(`span`,{className:wL,title:t.branch,children:t.branch}),r?(0,V.jsx)(`p`,{className:TL,children:r}):(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:z(`compare.noReply`)}),(0,V.jsx)(tR,{changes:i,onOpen:s}),(0,V.jsxs)(`div`,{className:OL,children:[(0,V.jsx)(H,{hit:`tight`,onClick:()=>e.select(t.id),children:z(`compare.terminal`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(`.`,i?.scope??`working`),children:z(`compare.diff`)}),o?(0,V.jsx)(H,{hit:`tight`,onClick:()=>void $I(e,t),children:z(`compare.unkeep`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>void QI(e,t,n),children:z(`compare.keep`)})]})]})}function rR({model:e}){B();let t=v(cn),n=v(e.tasks),r=vL(),i=t&&n?qI(n.tasks,t):[];return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:r,onKeyDown:e=>{e.metaKey||e.ctrlKey||e.altKey||e.key!==`q`&&e.key!==`Escape`||(e.preventDefault(),on.set(null))},children:[(0,V.jsx)(`h1`,{className:oM,children:z(`compare.title`)}),i.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`compare.empty`)}):(0,V.jsx)(`div`,{className:bL,children:i.map(t=>(0,V.jsx)(nR,{model:e,row:t,round:i},t.id))})]})}function iR(e){let t=Math.floor(e/6e4),n=Math.floor(t/60);return{minutes:t,hours:n,days:Math.floor(n/24)}}function aR(e,t=Date.now()){let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`${r}s`;let{minutes:i,hours:a,days:o}=iR(n);return i<60?`${i}m`:a<24?`${a}h`:`${o}d`}var oR=[{id:`issues`,label:`reviewQueue.sourceIssues`},{id:`reviews`,label:`reviewQueue.sourceReviews`}];function sR(){B();let e=v(RO);return(0,V.jsx)(`span`,{className:`flex items-baseline gap-3 font-mono text-meta`,children:oR.map(t=>t.id===e?(0,V.jsx)(`span`,{className:`text-ink`,children:z(t.label)},t.id):(0,V.jsx)(H,{onClick:()=>RO.set(t.id),children:z(t.label)},t.id))})}var cR={passing:`reviewQueue.checksPassing`,failing:`reviewQueue.checksFailing`,pending:`reviewQueue.checksPending`},lR={missing:`reviewQueue.gh.missing`,unauthenticated:`reviewQueue.gh.unauthenticated`,failed:`reviewQueue.gh.failed`};function uR(e){let{pr:t}=e,n=Date.parse(t.createdAt),r=[t.isDraft?z(`reviewQueue.draft`):``,t.fork?z(`reviewQueue.fork`):``,t.checks?z(cR[t.checks]):``];return(0,V.jsxs)(`div`,{"data-row":e.index,className:fM(e.at),onClick:e.onPick,children:[(0,V.jsxs)(`div`,{className:pM,children:[(0,V.jsxs)(`span`,{className:`mono ${mM}`,children:[t.nameWithOwner.split(`/`)[1],`#`,t.number]}),(0,V.jsx)(`span`,{className:gM,children:t.title}),(0,V.jsx)(H,{disabled:e.busy,onClick:e.onReview,children:z(`reviewQueue.start`)})]}),(0,V.jsxs)(`div`,{className:hM,children:[(0,V.jsx)(`span`,{className:gM,children:[t.author,...r].filter(Boolean).join(`, `)}),(0,V.jsxs)(`span`,{className:`mono`,children:[`+`,t.additions,` −`,t.deletions]}),(0,V.jsx)(`span`,{className:`mono`,children:Number.isFinite(n)?aR(n,e.now):``})]})]})}function dR({model:e}){B();let t=e.client,[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(0),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),m=(0,g.useRef)(!1),h=vL(),_=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0,n=m.current;return m.current=!1,a(null),t.request(`review.queue`,n?{refresh:!0}:{}).then(t=>e&&r(t)).catch(t=>{e&&(a(lL(t)),r({prs:[],other:0}))}),()=>{e=!1}},[t,f]);let v=n?.prs??[],y=Math.min(o,Math.max(0,v.length-1));(0,g.useEffect)(()=>{_.current?.querySelector(`[data-row="${y}"]`)?.scrollIntoView({block:`nearest`})},[y]);let b=async e=>{if(c===null){l(e.number),d(z(`reviewQueue.preparing`,{number:e.number}));try{let{ref:n}=await t.request(`review.prepare`,{repo:e.repo,number:e.number});pn(zO(e,n,z(`reviewQueue.prompt`,{number:e.number,repo:e.nameWithOwner,title:e.title,url:e.url,head:e.headRef,base:e.baseRef})))}catch(t){G(z(`reviewQueue.failed`,{number:e.number,error:lL(t)}),`error`)}finally{l(null),d(null)}}};_L(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return s(Math.min(v.length-1,y+1)),!0;case`k`:case`ArrowUp`:return s(Math.max(0,y-1)),!0;case`r`:return m.current=!0,p(e=>e+1),!0;case`Enter`:{let e=v[y];return e&&b(e),!0}default:return!1}});let x=Date.now();return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:h,children:[(0,V.jsxs)(`div`,{className:sM,children:[(0,V.jsx)(`h1`,{className:oM,children:z(`reviewQueue.title`)}),(0,V.jsx)(sR,{})]}),i?(0,V.jsx)(`p`,{className:`text-error`,children:i}):n===null?(0,V.jsx)(`p`,{className:`text-muted`,children:`…`}):n.reason?(0,V.jsx)(`p`,{className:`text-muted`,children:z(lR[n.reason])}):v.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`reviewQueue.empty`)}):(0,V.jsx)(`div`,{className:dM,ref:_,children:v.map((e,t)=>(0,V.jsx)(uR,{pr:e,index:t,at:t===y,now:x,busy:c!==null,onPick:()=>s(t),onReview:()=>void b(e)},`${e.nameWithOwner}#${e.number}`))}),n&&n.other>0&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:z(`reviewQueue.other`,{count:n.other})}),u&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:u})]})}var fR=30;function pR(){let{items:e}=oL();return t=>{let n=t.indexOf(`: `);switch(n>=0?t.slice(0,n):`failed`){case`no-remote`:return e.errorHint.noRemote;case`gh-missing`:return e.errorHint.ghMissing;case`auth`:return e.errorHint.auth;default:return sL(e.errorHint.fallback,{message:t})}}}function mR({model:e}){let{items:t,common:n}=oL(),r=pR(),i=e.client,a=v(e.tasks),o=pL(e),s=mL(e),[c,l]=(0,g.useState)(()=>{let e=s?o.findIndex(e=>uL(e)===uL(s)):-1;return Math.max(0,e)}),u=o[c],d=(e,t)=>({repo:e,limit:fR,...t?{assignee:`@me`}:{}}),f=e=>Object.fromEntries(e.links.map(e=>[e.number,e.taskId])),[p,m]=(0,g.useState)(()=>u?Ns(i,`workitem.list`,d(u,!1))?.items??null:null),[h,_]=(0,g.useState)(()=>{let e=u?Ns(i,`workitem.links`,{repo:u}):void 0;return e?f(e):{}}),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(0),[T,E]=(0,g.useState)(0),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(null),j=vL(),ee=(0,g.useRef)(!1);(0,g.useEffect)(()=>{let e=!0;if(!u){m([]);return}b(null);let t=ee.current;ee.current=!1;let n=d(u,x),r=Ns(i,`workitem.list`,n);return r&&m(r.items),i.request(`workitem.list`,{...n,...t?{refresh:!0}:{}}).then(t=>e&&m(Ps(i,`workitem.list`,n,t).items)).catch(t=>{e&&(b(lL(t)),m([]))}),Fs(i,`workitem.links`,{repo:u}).then(t=>e&&_(f(t))).catch(()=>e&&_({})),()=>{e=!1}},[i,u,x,C,a?.tasks.length]);let M=p??[],N=Math.min(T,Math.max(0,M.length-1));(0,g.useEffect)(()=>A(null),[u,x]);let P=(0,g.useRef)(null);(0,g.useEffect)(()=>{P.current?.querySelector(`[data-row="${N}"]`)?.scrollIntoView({block:`nearest`})},[N]);let F=e=>a?.tasks.find(t=>t.id===e)?.label??e,I=t=>{on.set(null),e.select(t)},te=async()=>{let e=M[N];if(!e||!u||D)return;let n=h[e.number];if(n){A(sL(t.openingLinked,{title:F(n)})),I(n);return}O(!0),A(sL(t.starting,{number:e.number}));try{let n=await i.request(`workitem.start`,{repo:u,number:e.number});n.started?I(n.taskId):A(sL(t.startedNoEngine,{title:n.title}))}catch(n){G(sL(t.startFailed,{number:e.number,error:lL(n)}),`error`)}finally{O(!1)}};_L(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return E(Math.min(M.length-1,N+1)),!0;case`k`:case`ArrowUp`:return E(Math.max(0,N-1)),!0;case`Tab`:return l(t=>o.length?(t+(e.shiftKey?o.length-1:1))%o.length:0),!0;case`a`:return S(e=>!e),!0;case`r`:return ee.current=!0,w(e=>e+1),!0;case`Enter`:return te(),!0;default:return!1}});let L=Date.now();return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:j,children:[(0,V.jsxs)(`div`,{className:sM,children:[(0,V.jsx)(`h1`,{className:oM,children:t.title}),(0,V.jsx)(sR,{}),(0,V.jsxs)(`span`,{className:`mono touch:empty:hidden! text-muted ${cM(!0)}`,children:[u?dL(u,o):t.noRepo,x?` ${t.assignedFilter}`:``]})]}),y?(0,V.jsxs)(`div`,{className:dM,children:[(0,V.jsx)(`p`,{className:`text-error`,children:y}),(0,V.jsx)(`p`,{className:`text-muted`,children:r(y)})]}):p===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.loading}):M.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.empty}):(0,V.jsx)(`div`,{className:dM,ref:P,children:M.map((e,n)=>{let r=h[e.number],i=Date.parse(e.updatedAt);return(0,V.jsxs)(`div`,{"data-row":n,className:fM(n===N),onClick:()=>n===N?void te():E(n),children:[(0,V.jsxs)(`div`,{className:pM,children:[(0,V.jsxs)(`span`,{className:`mono ${mM}`,children:[`#`,e.number]}),(0,V.jsx)(`span`,{children:e.title})]}),(0,V.jsxs)(`div`,{className:hM,children:[(0,V.jsx)(`span`,{className:gM,children:[e.author,...e.labels.slice(0,2)].filter(Boolean).join(`, `)}),r&&(0,V.jsx)(`span`,{children:sL(t.linkedChip,{title:F(r)})}),(0,V.jsx)(`span`,{className:`mono`,children:Number.isFinite(i)?aR(i,L):``})]})]},e.number)})}),k&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:k})]})}function hR({model:e}){return v(RO)===`reviews`?(0,V.jsx)(dR,{model:e}):(0,V.jsx)(mR,{model:e})}var gR={backlog:`active`,in_progress:`active`,in_review:`parked`,error:`parked`,done:`terminal`,canceled:`terminal`,open:`active`,doing:`active`,hold:`parked`};function _R(e){return gR[e]??`parked`}var vR=[`backlog`,`in_progress`,`parked`,`done`];function yR(e,t,n){let r=e.find(e=>e.issues.length>0)?.issues[0]?.id??null;if(t==null)return r;let i=-1,a=-1;for(let[n,r]of e.entries()){let e=r.issues.findIndex(e=>e.id===t);if(e!==-1){i=n,a=e;break}}if(i===-1)return r;if(n===`up`||n===`down`){let r=e[i]?.issues??[],o=n===`up`?a-1:a+1;return r[Math.max(0,Math.min(o,r.length-1))]?.id??t}let o=n===`left`?-1:1;for(let n=i+o;n>=0&&n<e.length;n+=o){let r=e[n]?.issues??[];if(r.length!==0)return r[Math.min(a,r.length-1)]?.id??t}return t}function bR(e,t){let n=_R(e.status);return n===`terminal`?`done`:n===`parked`?`parked`:e.taskId!==void 0&&e.taskId!==``&&(t?.(e.taskId)??!0)||e.status===`doing`?`in_progress`:`backlog`}function xR(e,t){let n=0;return{columns:e.map(e=>{if(e.key!==`in_progress`)return e;let r=[],i=[];for(let n of e.issues)n.taskId!==void 0&&n.taskId!==``&&t(n.taskId)?r.push(n):i.push(n);return n=r.length,r.length===0?e:{...e,issues:[...r,...i]}}),attentionCount:n}}function SR(e,t){return e.created===t.created?t.id-e.id:e.created<t.created?1:-1}function CR(e,t){let n={backlog:[],in_progress:[],parked:[],done:[]};for(let r of e)n[bR(r,t)].push(r);return vR.map(e=>{let t=e===`done`||e===`parked`,r=n[e].sort(SR);return!t||r.length<=20?{key:e,issues:r,hiddenCount:0}:{key:e,issues:r.slice(0,20),hiddenCount:r.length-20}})}var wR=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`],TR=5242880;function ER(e,t){return/\.pdf$/i.test(e)?`pdf[${t}]`:`images[${t}]`}function DR(e){let t=-1;for(let n of e.matchAll(/^(?:images|pdf)\[(\d+)\]:/gm)){let e=Number.parseInt(n[1],10);e>t&&(t=e)}return t+1}function OR(e,t){let n=e.replace(/\s+$/,``),r=DR(e);for(let e of t){let t=`${ER(e,r)}: ${e}`;n=n.length>0?`${n}\n${t}`:t,r+=1}return n}function kR(e){return Array.from(e??[]).filter(e=>wR.includes(e.type))}function AR(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function jR(e,t){let n=AR(new Uint8Array(await t.arrayBuffer()));return(await e.request(`attachment.put`,{mime:t.type,data:n})).path}var MR=[`worktree`,`projectWorktree`,`project`];async function NR(e,t){let n=t.placement===`project`?`project`:`worktree`,{title:r,prompt:i}=await e.request(`issue.prompt`,{repo:t.repo,id:t.issue.id,where:n}),a=[];if(t.placement!==`project`){let{taskId:n}=await e.request(`task.create`,{repo:t.repo,engine:t.engine,title:r,prompt:i});if(await e.request(`issue.update`,{repo:t.repo,id:t.issue.id,task:n}).catch(e=>a.push({kind:`link`,error:lL(e)})),t.placement===`worktree`)return{taskId:n,warnings:a};let o=await e.request(`task.openMain`,{repo:t.repo}),s=await e.request(`tab.openViewport`,{taskId:o.taskId,viewTaskId:n});return{taskId:o.taskId,tabId:s.tabId,warnings:a}}let{taskId:o}=await e.request(`task.openMain`,{repo:t.repo}),{tabId:s,taskId:c=o}=await e.request(`tab.new`,{taskId:o,kind:`engine`,engine:t.engine,prompt:i});return await e.request(`issue.setStatus`,{repo:t.repo,id:t.issue.id,status:`doing`}).catch(e=>a.push({kind:`status`,error:lL(e)})),{taskId:c,tabId:s,warnings:a}}var PR=`text-meta leading-[inherit]`,FR=`text-meta`,IR=`flex flex-col gap-2 overflow-hidden`,LR=`flex min-w-0 items-baseline gap-3`,RR=`font-bold whitespace-nowrap text-accent touch:relative touch:after:absolute touch:after:-inset-x-2 touch:after:-inset-y-1 touch:after:content-['']`,zR=`min-w-0 truncate ${FR}`,BR=`ml-auto ${PR}`,VR=`grid min-h-0 flex-1 grid-cols-4 gap-2`,HR=`flex min-h-0 flex-1 flex-col gap-2`,UR=`flex gap-4 ${FR}`,WR=e=>`touch:relative touch:after:absolute touch:after:-inset-x-1.5 touch:after:-top-1 touch:after:-bottom-3 touch:after:content-[''] ${e?`font-bold text-accent`:`text-muted`}`,GR={in_progress:`text-accent`,parked:`text-warning`,done:`text-success`},KR=e=>`flex min-h-0 flex-col rounded-md border-hairline border-line p-2 ${e?`flex-1`:``}`,qR=e=>`m-0 mb-2 flex justify-between gap-2 font-mono text-meta font-bold normal-nums ${GR[e]??`text-muted`}`,JR=`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto`,YR=`m-0 ${FR}`,XR=e=>`flex flex-none cursor-pointer flex-col gap-1 rounded-sm border-hairline bg-surface px-2.5 py-2 ${e.selected?`border-accent`:e.attention?`border-warning`:`border-line hover:border-line-active`}`,ZR=`flex justify-between gap-2`,QR=e=>`min-w-0 font-bold wrap-anywhere ${e?`text-muted`:``}`,$R=`h-[2.8em] overflow-hidden whitespace-pre-wrap wrap-anywhere ${PR}`,ez=`flex justify-between gap-2 ${FR}`,tz=`w-[min(680px,calc(100vw-32px))]!`,nz=`flex items-baseline gap-3.5`,rz=`flex items-baseline gap-2.5`,iz=`tracking-[0] normal-case`,az=`min-h-40 font-mono`,oz=`flex flex-col items-start gap-0.5`,sz=e=>`text-left font-mono text-meta whitespace-pre-wrap normal-nums ${e?`font-bold text-accent`:`font-normal text-muted`}`,cz=PR,lz=`flex flex-col gap-1 [&_p]:m-0`,uz=`flex gap-2 ${FR}`,dz=`min-w-[4ch] text-right`,fz=`rounded-sm border-hairline border-transparent p-1 focus:border-accent focus:outline-none`,pz={choice:`radiogroup`,list:`listbox`,cells:`group`};function mz(e){return(0,V.jsx)(`div`,{ref:e.fieldRef,role:pz[e.kind??`choice`],tabIndex:0,"aria-label":e.label,className:`${fz} ${e.className??``}`,onKeyDown:e.onKeyDown,onClick:e.onClick,children:e.children})}var hz=[`open`,`doing`,`hold`,`done`];function gz({model:e,taskId:t}){let{kanban:n}=oL(),[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return e.client.request(`task.events`,{taskId:t}).then(e=>n&&i(e.events)).catch(()=>n&&i([])),()=>{n=!1}},[e,t]),(0,V.jsxs)(`div`,{className:lz,children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:n.detail.eventsLabel}),r===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.detail.eventsLoading}):r.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:n.detail.eventsNone}):r.map(e=>(0,V.jsxs)(`div`,{className:`mono ${uz}`,children:[(0,V.jsx)(`span`,{className:`text-muted ${dz}`,children:aR(e.at)}),(0,V.jsx)(`span`,{children:e.kind}),e.tail&&(0,V.jsx)(`span`,{className:`text-muted`,children:e.tail})]},`${e.at}:${e.kind}:${e.tail}`))]})}function _z(e){let{kanban:t}=oL(),{issue:n,mode:r}=e,i=r===`create`,a=!i&&n.taskId?n.taskId:null,o=i||!a&&n.status!==`done`,[s,c]=(0,g.useState)(n.title),[l,u]=(0,g.useState)(n.body),[d,f]=(0,g.useState)(n.status),[p,m]=(0,g.useState)(e.defaultEngine),[h,_]=(0,g.useState)(MR[0]),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1),S=(0,g.useRef)({}),C=e=>t=>{S.current[e]=t},w=i?`title`:o?`workspace`:a?`open`:`title`;(0,g.useEffect)(()=>S.current[w]?.focus(),[w]);let T=()=>({title:s.trim()||n.title,body:l,status:d}),E=()=>({engine:p,placement:h,jump:v}),D=t=>{yn(),t&&e.onOutcome(t)},O=()=>s.trim()?!0:(S.current.title?.focus(),!1),k=()=>{i?O()&&D({kind:`create`,title:s.trim(),body:l,start:E()}):o?D({kind:`start`,...E(),...T()}):a&&D({kind:`open`,taskId:a,...T()})},A=()=>{i&&O()&&D({kind:`create`,title:s.trim(),body:l,start:null})},j=()=>D(i?null:{kind:`close`,...T()}),ee=(0,g.useRef)({commit:k,saveOnly:A,close:j});ee.current={commit:k,saveOnly:A,close:j},(0,g.useEffect)(()=>{let e=e=>{let t=e.key===`Escape`?ee.current.close:e.key===`Enter`&&(e.ctrlKey||e.metaKey)?ee.current.commit:e.key.toLowerCase()===`s`&&e.ctrlKey&&!e.metaKey?ee.current.saveOnly:null;t&&(e.preventDefault(),e.stopImmediatePropagation(),t())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let M=async t=>{let n=t.find(e=>e.size>TR);if(n){G(z(`pages.attachTooLarge`,{name:n.name||n.type}),`error`);return}x(!0);try{let n=await Promise.all(t.map(t=>jR(e.model.client,t)));u(e=>OR(e,n))}catch(e){G(K(e),`error`)}finally{x(!1)}},N=e=>{let t=kR(e.clipboardData.files);t.length!==0&&(e.preventDefault(),M(t))},P=e=>{let t=kR(e.dataTransfer.files);e.preventDefault(),t.length>0&&M(t)},F=(e,t,n)=>e[(Math.max(0,e.indexOf(t))+n+e.length)%e.length],I=(e,t,n)=>r=>{if(r.ctrlKey||r.metaKey||r.altKey)return;let i=(e===`x`?{ArrowRight:1,l:1,ArrowLeft:-1,h:-1}:{ArrowDown:1,ArrowUp:-1})[r.key];if(i)t(i);else if(r.key===`Enter`&&n)n();else return;r.preventDefault()},te=d===`done`?`text-success`:d===`hold`?`text-warning`:d===`doing`?`text-accent`:`text-muted`,L=e=>t.detail.status[e];return(0,V.jsx)(`div`,{className:kn,onMouseDown:e=>e.target===e.currentTarget&&ee.current.close(),children:(0,V.jsxs)(`dialog`,{open:!0,className:`${An(!0)} ${tz}`,"aria-label":i?t.detail.newStory:`#${n.id}`,onPaste:N,onDrop:P,onDragOver:e=>e.preventDefault(),children:[(0,V.jsxs)(`div`,{className:jn,children:[i?(0,V.jsx)(`h1`,{className:`${U} text-muted`,children:t.detail.newStory}):(0,V.jsxs)(`h1`,{className:`${U} text-muted ${nz}`,children:[(0,V.jsxs)(`span`,{children:[`#`,n.id]}),(0,V.jsx)(`span`,{className:te,children:L(d)}),(0,V.jsx)(`span`,{className:`text-muted`,children:sL(t.detail.created,{date:n.created})}),a&&(0,V.jsx)(`span`,{className:`text-accent`,children:t.detail.linked})]}),(0,V.jsx)(`button`,{type:`button`,className:Nn,"aria-label":z(`dialog.close`),title:z(`dialog.close`),onClick:()=>ee.current.close(),children:`×`})]}),(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.detail.titleLabel}),(0,V.jsx)(`input`,{ref:C(`title`),className:Qt,spellCheck:!1,value:s,onChange:e=>c(e.target.value.replace(/[\r\n]+/g,` `)),onKeyDown:e=>{e.key===`Enter`&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),S.current.description?.focus())}})]}),(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.detail.description,(0,V.jsx)(`span`,{className:`text-muted ${iz}`,children:Ko()?z(`pages.attachHintTouch`):t.detail.attachHint}),b&&(0,V.jsx)(`span`,{className:`text-accent`,children:`…`})]}),(0,V.jsx)(`textarea`,{ref:C(`description`),className:`${Qt} ${Tn} ${az}`,rows:8,spellCheck:!1,placeholder:t.detail.noDescription,value:l,onChange:e=>u(e.target.value)})]}),!i&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted flex items-baseline gap-2.5`,children:[t.detail.statusLabel,(0,V.jsx)(`span`,{className:`keys-only text-muted tracking-[0] normal-case`,children:`←/→`})]}),(0,V.jsx)(mz,{fieldRef:C(`status`),label:t.detail.statusLabel,className:`flex flex-wrap gap-1.5`,onKeyDown:I(`x`,e=>f(F(hz,d,e))),children:hz.map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===d,className:Dn(e===d),onClick:()=>{f(e),S.current.status?.focus()},children:L(e)},e))})]}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.detail.engine,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`←/→`})]}),(0,V.jsx)(mz,{fieldRef:C(`engine`),label:t.detail.engine,className:En,onKeyDown:I(`x`,t=>m(F(e.engines.map(e=>e.id),p,t)),k),children:e.engines.map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e.id===p,className:Dn(e.id===p),onClick:()=>{m(e.id),S.current.engine?.focus()},children:e.name},e.id))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.detail.workspace,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`↑/↓`})]}),(0,V.jsx)(mz,{fieldRef:C(`workspace`),label:t.detail.workspace,className:oz,onKeyDown:I(`y`,e=>_(F(MR,h,e)),k),children:MR.map(e=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===h,className:`touch:py-1.5 ${sz(e===h)}`,onClick:()=>{_(e),S.current.workspace?.focus()},children:[e===h?`▸ `:` `,t.detail.placement[e]]},e))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.detail.jumpLabel,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`←/→`})]}),(0,V.jsx)(mz,{fieldRef:C(`jump`),label:t.detail.jumpLabel,className:En,onKeyDown:I(`x`,()=>y(!v),k),children:[!1,!0].map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===v,className:Dn(e===v),onClick:()=>{y(e),S.current.jump?.focus()},children:e?t.detail.jump.follow:t.detail.jump.stay},String(e)))})]}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${cz}`,children:(0,V.jsx)(ST,{text:Yo(i?t.detail.createLegend:t.detail.startLegend)})}),(0,V.jsxs)(`div`,{className:$t,children:[i&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:A,children:z(`pages.storySave`)}),(0,V.jsx)(`button`,{type:`button`,className:je(),onClick:k,children:z(i?`pages.storySaveStart`:`pages.storyStart`)})]})]}):a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.detail.sessionLabel}),(0,V.jsxs)(`div`,{className:`${En} ${fz}`,children:[(0,V.jsx)(`button`,{ref:C(`open`),type:`button`,className:Dn(!0),onClick:()=>D({kind:`open`,taskId:a,...T()}),children:t.detail.openAction}),(0,V.jsx)(`button`,{ref:C(`unlink`),type:`button`,className:Dn(),onClick:()=>D({kind:`unlink`,...T()}),children:t.detail.unlinkAction})]})]}),(0,V.jsx)(gz,{model:e.model,taskId:a}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${cz}`,children:(0,V.jsx)(ST,{text:Yo(t.detail.openLegend)})})]}):(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${cz}`,children:(0,V.jsx)(ST,{text:Yo(t.detail.doneNote)})})]})]})})}var vz={"waiting-on-you":`text-error`,landing:`text-success`,"ready-for-review":`text-ink`,working:`text-accent`};function yz(e){let[t,n]=(0,g.useState)(()=>{let t=Ns(e,`engines.list`);return t?ms(t.engines):[]});return(0,g.useEffect)(()=>{Fs(e,`engines.list`).then(e=>n(ms(e.engines))).catch(()=>n([]))},[e]),{engines:t,defaultEngine:hs(t)}}function bz(e,t){let n=pL(e),r=n.join(`
124
- `),[i,a]=(0,g.useState)(()=>Ns(e,`kanban.boards`)??null);return(0,g.useEffect)(()=>{let t=!0,r=e.client,i=e=>r.request(e).then(e=>e.repos).catch(()=>[]);return Promise.all([i(`repos.list`),i(`issue.repos`)]).then(([e,t])=>fL(e,n,t)).then(e=>Promise.all(e.map(e=>r.request(`issue.list`,{repo:e}).catch(t=>({repoRoot:e,nextId:1,issues:[],readError:lL(t)}))))).then(n=>{let r=Ps(e,`kanban.boards`,void 0,[...n].sort((e,t)=>e.repoRoot.localeCompare(t.repoRoot)));t&&a(r)}),()=>{t=!1}},[e,t,r]),i}function xz(e){let{issue:t}=e,n=t.body.trim();return(0,V.jsxs)(`div`,{"data-issue":t.id,className:XR({selected:e.selected,attention:e.badge?.tone===`text-error`}),onClick:()=>e.selected?e.onOpen():e.onSelect(),onContextMenu:t=>{t.preventDefault(),e.onMenu(t.clientX,t.clientY)},children:[(0,V.jsxs)(`div`,{className:ZR,children:[(0,V.jsx)(`span`,{className:QR(e.column===`done`),children:t.title}),(0,V.jsxs)(`span`,{className:`mono text-muted`,children:[`#`,t.id]})]}),(0,V.jsx)(`div`,{className:`text-muted ${$R}`,children:n}),(0,V.jsxs)(`div`,{className:`mono text-muted ${ez}`,children:[(0,V.jsx)(`span`,{children:t.created}),e.badge&&(0,V.jsx)(`span`,{className:e.badge.tone,children:e.badge.label})]})]})}var Sz=5e3,Cz=760;function wz({model:e}){let{kanban:t,group:n,common:r}=oL(),[i,a]=hL(Sz),o=bz(e,i),{engines:s,defaultEngine:c}=yz(e),l=v(e.tasks),u=mL(e),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),h=vL(),[_,y]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>y(e.clientWidth<Cz));return t.observe(e),()=>t.disconnect()},[h]);let b=o??[],x=u?b.find(e=>e.repoRoot.replace(/^\/private\//,`/`)===u.replace(/^\/private\//,`/`)):void 0,S=Math.max(0,b.findIndex(e=>e.repoRoot===(d??x?.repoRoot))),C=b[S],w=b.map(e=>e.repoRoot),T=b.filter(e=>e.readError).map(e=>`${e.repoRoot}\0${e.readError}`).join(`
125
- `);(0,g.useEffect)(()=>{for(let e of b)e.readError&&G(sL(t.readFailedToast,{repo:dL(e.repoRoot,w),error:e.readError}),`error`)},[T]);let E=l?.tasks??[],D=new Set(E.map(e=>e.id)),O=e=>E.find(t=>t.id===e)?.group,{columns:k,attentionCount:A}=xR(C?CR(C.issues,D.size===0?void 0:e=>D.has(e)):[],e=>O(e)===`waiting-on-you`),j={backlog:t.column.backlog,in_progress:t.column.inProgress,parked:t.column.parked,done:t.column.done},ee=(e,t)=>{let r=e.taskId&&(t===`in_progress`||t===`parked`)?O(e.taskId):void 0,i=r===`waiting-on-you`?n.waitingOnYou:r===`landing`?n.landing:r===`ready-for-review`?n.readyForReview:r===`working`?n.working:null;return r&&i?{label:i,tone:vz[r]??`text-muted`}:null},M=async(t,n,r,i)=>{try{return await e.client.request(t,{repo:C?.repoRoot,...n})}catch(e){return G(sL(r,{id:String(i),error:lL(e)}),`error`),null}finally{a()}},N=(e,n)=>M(`issue.setStatus`,{id:e.id,status:n},t.statusFailed,e.id),P=t=>{on.set(null),e.select(t)},F=async(n,r,i)=>{try{let a=await NR(e.client,{repo:n,issue:r,engine:i.engine,placement:i.placement});for(let e of a.warnings)G(sL(e.kind===`link`?t.linkFailed:t.statusFailed,{id:String(r.id),error:e.error}),`error`);i.jump?(on.set(null),e.selectWhenListed(a.taskId),a.tabId&&await e.refreshTabsNow().then(()=>e.select(a.taskId,a.tabId))):G(sL(t.detail.startedBackground,{title:`#${r.id} ${r.title}`}))}catch(e){G(K(e),`error`)}finally{a()}},I=async(e,n)=>{if(!C||n.kind===`create`)return;let r={};n.title!==e.title&&(r.title=n.title),n.body!==e.body&&(r.body=n.body),(r.title!==void 0||r.body!==void 0)&&await M(`issue.update`,{id:e.id,...r},t.updateFailed,e.id),n.status!==e.status&&await N(e,n.status),n.kind===`open`?P(n.taskId):n.kind===`unlink`?await M(`issue.update`,{id:e.id,task:`none`},t.unlinkFailed,e.id):n.kind===`start`&&await F(C.repoRoot,{...e,...r},n)},te=t=>{C&&(m(t.id),W.set((0,V.jsx)(_z,{model:e,issue:t,mode:`detail`,engines:s,defaultEngine:c,onOutcome:e=>void I(t,e)})))},L=()=>{if(!C)return;let n=C.repoRoot,r={id:C.nextId,title:``,status:`open`,created:new Date().toISOString().slice(0,10),body:``};W.set((0,V.jsx)(_z,{model:e,issue:r,mode:`create`,engines:s,defaultEngine:c,onOutcome:i=>{i.kind===`create`&&(async()=>{try{let t=await e.client.request(`issue.create`,{repo:n,title:i.title,body:i.body});if(a(),!i.start)return;let o=t.issues.find(e=>e.id===r.id)??t.issues.reduce((e,t)=>e&&e.id>t.id?e:t,null);o&&await F(n,o,i.start)}catch(e){G(sL(t.createFailed,{error:lL(e)}),`error`)}})()}}))},ne=()=>{let n=C?.issues.find(e=>e.id===p);if(!C||!n)return;let i=C.repoRoot;W.set((0,V.jsx)(sr,{title:sL(t.confirmDelete.title,{id:String(n.id)}),body:sL(t.confirmDelete.body,{title:n.title}),confirmLabel:r.confirm,onConfirm:async()=>{try{await e.client.request(`issue.delete`,{repo:i,id:n.id}),m(null)}catch(e){G(sL(t.deleteFailed,{id:String(n.id),error:lL(e)}),`error`)}finally{a()}}}))},re=e=>{b.length!==0&&(f(b[(S+e+b.length)%b.length]?.repoRoot??null),m(null))},ie=e=>{let t=yR(k,p,e);t!=null&&m(t)},R=e=>k.some(e=>e.issues.length>0)?ie(e):re(e===`left`?-1:1);_L(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`r`:return a(),!0;case`Tab`:return re(e.shiftKey?-1:1),!0;case`ArrowUp`:return ie(`up`),!0;case`ArrowDown`:return ie(`down`),!0;case`ArrowRight`:case`l`:return R(`right`),!0;case`ArrowLeft`:case`h`:return R(`left`),!0;case`Enter`:{let e=C?.issues.find(e=>e.id===p);return e&&te(e),!0}case`n`:return L(),!0;case`d`:return ne(),!0;default:return!1}});let ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{ae.current?.querySelector(`[data-issue="${p}"]`)?.scrollIntoView({block:`nearest`})},[p]);let oe=(e,n,r)=>{m(e.id),nn.set({x:n,y:r,items:hz.filter(t=>t!==e.status).map(n=>({label:sL(t.menu.setStatus,{status:t.detail.status[n]}),run:()=>void N(e,n)}))})},se=k.find(e=>e.issues.some(e=>e.id===p))??k.find(e=>e.issues.length>0)??k[0],ce=(e,n)=>(0,V.jsxs)(`section`,{className:KR(!n),children:[n&&(0,V.jsxs)(`h2`,{className:qR(e.key),children:[(0,V.jsxs)(`span`,{children:[j[e.key],` (`,e.issues.length+e.hiddenCount,`)`]}),e.key===`in_progress`&&A>0&&(0,V.jsx)(`span`,{className:`text-warning`,children:sL(t.attention,{count:String(A)})})]}),(0,V.jsxs)(`div`,{className:JR,children:[e.issues.map(t=>(0,V.jsx)(xz,{issue:t,column:e.key,selected:t.id===p,badge:ee(t,e.key),onSelect:()=>m(t.id),onOpen:()=>te(t),onMenu:(e,n)=>oe(t,e,n)},t.id)),e.issues.length===0&&e.hiddenCount===0&&(0,V.jsx)(`p`,{className:`mono text-muted ${YR}`,children:t.columnEmpty}),e.hiddenCount>0&&(0,V.jsx)(`p`,{className:`mono text-muted ${YR}`,children:sL(t.more,{count:String(e.hiddenCount)})})]})]},e.key);return(0,V.jsxs)(`div`,{className:`${iM} ${IR}`,tabIndex:0,ref:h,children:[(0,V.jsxs)(`div`,{className:`kb-top`,children:[(0,V.jsx)(`h1`,{className:oM,children:t.title}),(0,V.jsx)(`span`,{className:`mono keys-only text-muted`,children:t.hint}),(0,V.jsxs)(`span`,{className:`mono ${lM}`,children:[(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.kanban}`,disabled:!C,onClick:L,children:z(`pages.new`)}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.kanban}`,disabled:!C?.issues.some(e=>e.id===p),onClick:ne,children:z(`pages.delete`)})]})]}),o===null?(0,V.jsx)(`p`,{className:`text-muted`,children:t.loading}):C?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:LR,children:[(0,V.jsxs)(`button`,{type:`button`,className:RR,onClick:()=>re(1),children:[dL(C.repoRoot,w),b.length>1&&(0,V.jsx)(`span`,{className:`text-muted`,children:` ${S+1}/${b.length}`})]}),!_&&(0,V.jsx)(`span`,{className:`mono text-muted ${zR}`,children:C.repoRoot}),C.issues.length===0&&!C.readError&&(0,V.jsx)(`span`,{className:`text-muted ${BR}`,children:t.empty})]}),C.readError?(0,V.jsx)(`p`,{className:`text-error`,children:sL(t.readFailed,{error:C.readError})}):_&&se?(0,V.jsxs)(`div`,{className:HR,ref:ae,children:[(0,V.jsx)(`div`,{className:`mono ${UR}`,children:k.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:WR(e.key===se.key),onClick:()=>{let t=e.issues[0];t&&m(t.id)},children:[j[e.key],` (`,e.issues.length+e.hiddenCount,`)`]},e.key))}),ce(se,!1)]}):(0,V.jsx)(`div`,{className:VR,ref:ae,children:k.map(e=>ce(e,!0))})]}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.noRepos})]})}var Tz={title:`Mods`,empty:`No mod is drawing anything.`,emptyHint:`A plugin with a [mod] entry draws its panes here, in the TUI and the web alike.`,keys:`↑↓/tab move · enter press · esc back`,pressFailed:`{plugin}: the press did not reach the mod ({reason})`},Ez={title:`Mods`,empty:`当前没有 mod 在绘制内容。`,emptyHint:`声明了 [mod] 的插件会在这里绘制面板,TUI 和 web 显示的是同一份。`,keys:`↑↓/tab 移动 · enter 按下 · esc 返回`,pressFailed:`{plugin}:按键没有送达 mod({reason})`},Dz={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-error`,muted:`text-muted`},Oz=`flex flex-col gap-3`,kz=`[&_p]:mx-0 [&_p]:my-1`,Az=`rounded-md border-hairline border-line px-3 pt-2 pb-3 font-mono`,jz=`mb-2 text-meta leading-[inherit] text-ink`,Mz=(e,t)=>`flex min-w-0 items-start ${e?`[&>form]:flex-[1_1_12em] [&>form]:self-center`:``} ${t?`rounded-sm border-hairline border-line`:``}`,Nz=(e,t)=>`whitespace-pre-wrap wrap-anywhere ${e?Dz[e]:`text-ink`} ${t?`font-bold`:``}`,Pz=(e,t)=>`cursor-pointer rounded-sm border-hairline border-current px-2.5 py-0.5 [font:inherit] font-bold! ${Dz[e]} ${t?`bg-[color-mix(in_srgb,currentcolor_18%,transparent)]`:`bg-transparent [&:hover]:bg-[color-mix(in_srgb,currentcolor_18%,transparent)]`}`,Fz=`flex min-w-0 max-w-[40em] self-stretch`,Iz=`w-full font-mono`,Lz=[0,6,12,20];function Rz(e){return`mod-${e.kind}:${e.plugin}/${e.pane}/${e.key}`}function zz(e){let[t,n]=(0,g.useState)(e.value??``);return(0,V.jsx)(`form`,{className:Fz,onSubmit:r=>{r.preventDefault(),e.onSubmit(t),n(e.value??``)},children:(0,V.jsx)(`input`,{id:e.id,className:`${Qt} ${Iz}`,spellCheck:!1,value:t,placeholder:e.placeholder,onFocus:e.onFocus,onChange:e=>n(e.target.value)})})}function Bz(e){let{node:t}=e;if(t.type===`text`)return(0,V.jsx)(`span`,{className:Nz(t.tone,t.bold===!0),children:t.text});if(t.type===`input`){let n={kind:`input`,plugin:e.pane.plugin,pane:e.pane.id,key:t.key};return(0,V.jsx)(zz,{id:Rz(n),placeholder:t.placeholder,value:t.value,onFocus:()=>e.onFocus(n),onSubmit:t=>e.onSubmit(n,t)},t.value??``)}if(t.type===`button`){let n={kind:`button`,plugin:e.pane.plugin,pane:e.pane.id,key:t.key};return(0,V.jsx)(`button`,{type:`button`,id:Rz(n),className:Pz(t.tone??`info`,Ci(n,e.cursor)),onFocus:()=>e.onFocus(n),onClick:()=>e.onPress(n),children:t.label})}return(0,V.jsx)(`div`,{className:Mz(t.direction===`row`,t.border===!0),style:{flexDirection:t.direction??`column`,gap:Lz[t.gap??0],padding:Lz[t.padding??0]},children:t.children.map((t,n)=>(0,V.jsx)(Bz,{...e,node:t},n))})}function Vz({model:e}){let t=B()===`zh`?Ez:Tz,n=v(e.mods),r=Si(n),[i,a]=(0,g.useState)(null),o=wi(r,i),s=vL(),c=(0,g.useRef)(!1),l=(t,n,r={})=>{a(t),!c.current&&(c.current=!0,e.client.request(n,{plugin:t.plugin,pane:t.pane,key:t.key,...r}).catch(e=>G(e instanceof Error?e.message:String(e),`error`)).finally(()=>{c.current=!1}))},u=e=>l(e,`mod.press`),d=(e,t)=>l(e,`mod.submit`,{value:t}),f=e=>{let t=Ti(r,o,e);a(t),t&&document.getElementById(Rz(t))?.focus()};return _L(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`ArrowDown`:return f(1),!0;case`ArrowUp`:return f(-1),!0;case`Enter`:return e.target instanceof HTMLButtonElement?!1:(o?.kind===`button`&&u(o),!0);default:return!1}}),(0,V.jsxs)(`div`,{className:`${aM} ${Oz}`,tabIndex:0,ref:s,children:[(0,V.jsxs)(`div`,{className:sM,children:[(0,V.jsx)(`h1`,{className:oM,children:t.title}),(0,V.jsx)(`span`,{className:`keys-only touch:empty:hidden! text-muted ${cM(!1)}`,children:t.keys})]}),n.length===0?(0,V.jsxs)(`div`,{className:kz,children:[(0,V.jsx)(`p`,{children:t.empty}),(0,V.jsx)(`p`,{className:`text-muted`,children:t.emptyHint})]}):n.map(e=>(0,V.jsxs)(`section`,{className:Az,children:[(0,V.jsxs)(`header`,{className:jz,children:[e.title,` `,(0,V.jsx)(`span`,{className:`text-muted`,children:e.plugin})]}),(0,V.jsx)(Bz,{node:e.tree,pane:e,cursor:o,onPress:u,onSubmit:d,onFocus:a})]},`${e.plugin}/${e.id}`))]})}function Hz(e){return e===`dispatch_failed`||e===`skipped_unavailable`||e===`script_failed`}function Uz(e,t){return e.response?`responded`:e.status!==`dispatched`&&e.status!==`revived`?null:e.deliveryStatus===`missing`?`missing`:e.deliveryStatus===`awaiting`?`awaiting`:t-Date.parse(e.at)>72e5?`missing`:`awaiting`}var Wz=6e4,Gz=3294,Kz=new Map([[`JAN`,1],[`FEB`,2],[`MAR`,3],[`APR`,4],[`MAY`,5],[`JUN`,6],[`JUL`,7],[`AUG`,8],[`SEP`,9],[`OCT`,10],[`NOV`,11],[`DEC`,12]]),qz=new Map([[`SUN`,0],[`MON`,1],[`TUE`,2],[`WED`,3],[`THU`,4],[`FRI`,5],[`SAT`,6]]),Jz=256;function Yz(e,t,n){let r=e.toUpperCase(),i=t?.get(r);if(i!==void 0)return i;if(!/^\d+$/.test(r))throw Error(`invalid cron ${n}: ${e}`);return Number(r)}function Xz(e){let t=new Set;for(let n of e.value.split(`,`)){if(n.length===0)throw Error(`invalid cron ${e.field}: ${e.value}`);let[r,i,...a]=n.split(`/`);if(a.length>0||r===void 0)throw Error(`invalid cron ${e.field}: ${n}`);let o=1;if(i!==void 0&&(!/^\d+$/.test(i)||(o=Number(i),o<1)))throw Error(`invalid cron ${e.field} step: ${n}`);let s,c;if(r===`*`)s=e.min,c=e.max;else if(r.includes(`-`)){let[t,i,...a]=r.split(`-`);if(a.length>0||t===void 0||i===void 0)throw Error(`invalid cron ${e.field} range: ${n}`);s=Yz(t,e.names,e.field),c=Yz(i,e.names,e.field)}else s=Yz(r,e.names,e.field),c=i===void 0?s:e.max;if(s<e.min||c>e.max||s>c)throw Error(`cron ${e.field} out of range: ${n}`);for(let n=s;n<=c;n+=o)t.add(e.normalize?e.normalize(n):n)}return t}function Zz(e){if(e.length>Jz)throw Error(`cron expression is too long`);let t=e.trim().split(/\s+/).filter(Boolean);if(t.length!==5)throw Error(`cron expression needs 5 fields (minute hour day month weekday), got ${t.length}`);let[n,r,i,a,o]=t;return{minutes:Xz({value:n,min:0,max:59,field:`minute`}),hours:Xz({value:r,min:0,max:23,field:`hour`}),daysOfMonth:Xz({value:i,min:1,max:31,field:`day-of-month`}),months:Xz({value:a,min:1,max:12,field:`month`,names:Kz}),daysOfWeek:Xz({value:o,min:0,max:7,field:`weekday`,names:qz,normalize:e=>e%7}),dayOfMonthRestricted:!i.startsWith(`*`),dayOfWeekRestricted:!o.startsWith(`*`)}}function Qz(e){try{return Zz(e),!0}catch{return!1}}function $z(e,t,n){return new Date(e.year,e.month-1,e.day,t,n,0,0).getTime()}function eB(e){let t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}}function tB(e,t){return eB(new Date(e.year,e.month-1,e.day+t,12,0,0,0).getTime())}function nB(e,t){if(!e.months.has(t.month))return!1;let n=e.daysOfMonth.has(t.day),r=e.daysOfWeek.has(new Date(t.year,t.month-1,t.day).getDay());return e.dayOfMonthRestricted&&e.dayOfWeekRestricted?n||r:n&&r}function rB(e){return e-e%Wz}function iB(e,t){return[...e].sort((e,n)=>(e-n)*t)}function aB(e,t){let n=Zz(e),r=iB(n.hours,1),i=iB(n.minutes,1),a=new Date(rB(t)+Wz),o=eB(a.getTime()),s=a.getHours(),c=a.getMinutes();for(let e=0;e<Gz;e++){if(nB(n,o)){for(let e of r)if(!(e<s))for(let n of i){if(e===s&&n<c)continue;let r=$z(o,e,n);if(r>t)return r}}o=tB(o,1),s=0,c=0}throw Error(`cron expression never matches: ${e}`)}var oB=[`minute`,`hour`,`dayOfMonth`,`month`,`dayOfWeek`];function sB(e){let t=e.trim().split(/\s+/).filter(Boolean);return oB.map((e,n)=>t[n]??`*`)}function cB(e){return oB.map((t,n)=>e[n]??`*`).join(` `)}var lB=[`*`,`*/5`,`*/10`,`*/15`,`*/30`,...hB(0,59)],uB=[`*`,`*/2`,`*/3`,`*/4`,`*/6`,`*/12`,...hB(0,23)],dB=[`*`,...hB(1,31)],fB=[`*`,`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`],pB=[`*`,`MON-FRI`,`SAT,SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`,`SUN`],mB=[`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`,`SUN`];function hB(e,t){let n=[];for(let r=e;r<=t;r++)n.push(String(r));return n}var gB={minute:lB,hour:uB,dayOfMonth:dB,month:fB,dayOfWeek:pB};function _B(e,t,n){let r=gB[e],i=r.indexOf(t.trim().toUpperCase());return i<0?(n>0?r[0]:r[r.length-1])??t:r[(i+n+r.length)%r.length]??t}function vB(e,t){return Math.min(Math.max(e+t,0),oB.length-1)}function yB(e,t,n){let r=sB(e);return t<0||t>=oB.length||(r[t]=n),cB(r)}function bB(e,t){let[n,r,i,a,o]=sB(e);if(a!==`*`||i!==`*`||n===void 0||r===void 0||o===void 0)return null;let s=xB(n,r,t);if(!s)return null;let{at:c,bare:l}=s;if(o===`*`)return l?c:t(`automations.schedule.everyDay`,{at:c});if(o===`MON-FRI`)return t(`automations.schedule.weekdays`,{at:c});if(o===`SAT,SUN`)return t(`automations.schedule.weekends`,{at:c});let u=mB.find(e=>e===o.toUpperCase());return u?t(`automations.schedule.onWeekday`,{weekday:t(`automations.schedule.dow.${u}`),at:c}):null}function xB(e,t,n){return t===`*`?e===`*`?{at:n(`automations.schedule.everyMinute`),bare:!0}:e.startsWith(`*/`)?{at:n(`automations.schedule.everyMinutes`,{n:e.slice(2)}),bare:!0}:/^\d+$/.test(e)?{at:n(`automations.schedule.hourlyAt`,{minute:e.padStart(2,`0`)}),bare:!1}:null:t.startsWith(`*/`)&&e===`0`?{at:n(`automations.schedule.everyHours`,{n:t.slice(2)}),bare:!0}:/^\d+$/.test(t)&&/^\d+$/.test(e)?{at:n(`automations.schedule.atClock`,{time:`${t.padStart(2,`0`)}:${e.padStart(2,`0`)}`}),bare:!1}:null}function SB(e,t,n,r){let i=e.trim();if(!Qz(i))return{kind:`invalid`};let a;try{a=aB(i,t)}catch{return{kind:`never`}}return{kind:`ok`,nextRunMs:a,relative:CB(a-t,n),absolute:wB(a,t,n,r)}}function CB(e,t){let{minutes:n,hours:r,days:i}=iR(e);return n<60?t(`automations.when.inMinutes`,{n:Math.max(1,n)}):r<24?t(`automations.when.inHours`,{n:r}):t(`automations.when.inDays`,{n:i})}function wB(e,t,n,r){let i=new Date(e),a=`${String(i.getHours()).padStart(2,`0`)}:${String(i.getMinutes()).padStart(2,`0`)}`,o=new Date(t);if(i.getFullYear()===o.getFullYear()&&i.getMonth()===o.getMonth()&&i.getDate()===o.getDate())return a;let s=e-t<5184e5,c=i.toLocaleDateString(r,s?{weekday:`short`}:{weekday:`short`,month:`short`,day:`numeric`});return s?`${c} ${a}`:n(`automations.when.dateTime`,{date:c,time:a})}var TB={name:``,repo:``,prompt:``,schedule:`0 9 * * MON-FRI`};function EB(e){return e.name.trim().length>0&&(e.repo===null||e.repo.trim().length>0)&&e.prompt.trim().length>0&&(!e.target||e.target.taskId.trim().length>0&&/^tab-[\w-]+$/.test(e.target.tabId))&&Qz(e.schedule.trim())}function DB(e){return e.name.trim().length===0?`name`:e.repo!==null&&e.repo.trim().length===0?`repo`:e.target&&!e.target.taskId.trim()?`target`:e.target&&!/^tab-[\w-]+$/.test(e.target.tabId)?`targetTab`:e.prompt.trim().length===0?`prompt`:Qz(e.schedule.trim())?null:`schedule`}var OB=`flex flex-col overflow-hidden @container`,kB=`mt-2.5 grid min-h-0 flex-1 grid-cols-[minmax(260px,2fr)_minmax(0,3fr)] gap-4 rt-narrow:flex rt-narrow:flex-col rt-narrow:overflow-y-auto`,AB=`flex min-h-0 flex-col gap-3 overflow-y-auto scrollbar-none rt-narrow:shrink-0 rt-narrow:overflow-visible`,jB=`flex gap-1.5 px-2 pt-0 pb-1`,MB=e=>`flex min-w-0 cursor-pointer flex-col gap-0.5 rounded-sm px-2 py-1.5 ${e?`bg-menu`:`[&:hover]:bg-hover`}`,NB=`flex min-w-0 items-baseline gap-2.5`,PB=e=>`min-w-0 flex-1 truncate font-bold ${e?`text-muted`:``}`,FB=`whitespace-nowrap text-meta`,IB=`truncate text-meta`,LB=`flex min-h-0 flex-col gap-1.5 overflow-y-auto py-0 pr-0 pl-4 [border-left:var(--hairline)_solid_var(--line)] [&_h2]:m-0 [&_p]:m-0 [&>*]:shrink-0 [&>h2]:mt-2.5 rt-narrow:shrink-0 rt-narrow:overflow-visible rt-narrow:pt-3 rt-narrow:pl-0 rt-narrow:[border-left:none] rt-narrow:[border-top:var(--hairline)_solid_var(--line)]`,RB=`flex flex-wrap items-baseline justify-between gap-3`,zB=`font-sans text-display font-bold normal-nums wrap-anywhere`,BB=`mx-0 mt-1 mb-0 grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-3.5 gap-y-1 [&_dd]:m-0 [&_dd]:wrap-anywhere [&_dd_.mono]:whitespace-pre`,VB=`max-h-[12lh] overflow-y-auto rounded-sm bg-inset px-2.5 py-2 whitespace-pre-wrap wrap-anywhere`,HB=`min-w-0 text-meta leading-[inherit]`,UB=`flex w-full min-w-0 gap-2 text-inherit`,WB=UB,GB=`${UB} cursor-pointer border-none bg-transparent p-0 text-left font-[inherit] [&:hover]:underline`,KB=`min-w-0 flex-1 truncate`,qB=`[&+&]:mt-1.5`,JB=e=>`whitespace-pre-wrap wrap-anywhere text-meta ${e?``:`leading-[inherit]`}`,YB=`text-meta`,XB=`flex gap-4.5`,ZB=e=>`flex min-w-[5ch] flex-col gap-0.5 rounded-sm border-hairline px-1.5 py-1 text-left font-mono text-body normal-nums [&>span]:text-meta [&>span]:text-subtle ${e?`border-accent font-bold text-accent`:`border-transparent font-normal`}`,QB=`hidden gap-2 px-1 pt-0.5 pb-1.5 touch:flex`,$B=`h-8 w-11 touch-manipulation rounded-sm border-hairline border-line bg-inset font-mono text-display font-normal normal-nums text-ink`;function eV(e){let{auto:t,common:n}=oL(),r=cL(),i=B()===`zh`?`zh-CN`:`en-US`,[a,o]=(0,g.useState)(()=>({...TB,repo:e.repos.find(t=>e.defaultRepo&&uL(t)===uL(e.defaultRepo))??e.repos[0]??null})),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(null),d=(0,g.useRef)({}),f=e=>t=>{d.current[e]=t};(0,g.useEffect)(()=>d.current.name?.focus(),[]);let p=e=>{o(t=>({...t,...e})),u(null)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),yn())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let m=()=>{if(EB(a)){yn(),e.onSubmit({name:a.name.trim(),repo:a.repo===null?null:a.repo.trim(),prompt:a.prompt.trim(),schedule:a.schedule.trim(),...a.target?{target:a.target}:{}});return}let n=DB(a);n&&(d.current[n]?.focus(),u(Reflect.get(t.missing,n)))},h=a.repo===null?[]:e.tasks.filter(e=>uL(e.repo)===uL(a.repo??``)),_=a.target?h.findIndex(e=>e.id===a.target?.taskId)+1:0,v=e=>{let t=(_+e+h.length+1)%(h.length+1),n=h[t-1];p({target:n?{kind:`existing-tab`,taskId:n.id,tabId:`tab-1`}:void 0})},y=[null,...e.repos],b=e=>{let t=Math.min(Math.max(y.indexOf(a.repo)+e,0),y.length-1),n=y[t];n!==void 0&&p({repo:n,target:void 0})},x=e=>t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),e(t.key===`ArrowDown`?1:-1))},S=e=>t=>{t.key===`Enter`&&(t.preventDefault(),d.current[e]?.focus())},C=sB(a.schedule),w=e=>{let t=oB[s];t&&p({schedule:yB(a.schedule,s,_B(t,C[s]??`*`,e))})},T=e=>{if(!(e.ctrlKey||e.metaKey||e.altKey)){if(e.key===`ArrowLeft`||e.key===`h`)c(vB(s,-1));else if(e.key===`ArrowRight`||e.key===`l`)c(vB(s,1));else if(e.key===`ArrowUp`||e.key===`ArrowDown`)w(e.key===`ArrowUp`?1:-1);else return;e.preventDefault()}},E=SB(a.schedule,Date.now(),r,i),D=bB(a.schedule,r);return(0,V.jsx)(`div`,{className:kn,onMouseDown:e=>e.target===e.currentTarget&&yn(),children:(0,V.jsxs)(`dialog`,{open:!0,className:`${An(!0)} ${tz}`,"aria-label":t.newTitle,children:[(0,V.jsx)(`h1`,{className:`${U} text-muted`,children:t.newTitle}),(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.fieldName}),(0,V.jsx)(`input`,{ref:f(`name`),className:Qt,spellCheck:!1,placeholder:t.namePlaceholder,value:a.name,onChange:e=>p({name:e.target.value}),onKeyDown:S(`repo`)})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.fieldRepo,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`↑/↓`})]}),(0,V.jsx)(mz,{fieldRef:f(`repo`),kind:`list`,label:t.fieldRepo,className:oz,onKeyDown:x(b),children:y.map(t=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-selected":t===a.repo,className:`touch:py-1.5 ${sz(t===a.repo)}`,onClick:()=>{p({repo:t,target:void 0}),d.current.repo?.focus()},children:[t===a.repo?`▸ `:` `,t===null?z(`rail.noProject`):dL(t,e.repos)]},t??``))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.fieldTarget,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`↑/↓`})]}),(0,V.jsx)(mz,{fieldRef:f(`target`),kind:`list`,label:t.fieldTarget,onKeyDown:x(v),onClick:()=>v(1),children:a.target?h[_-1]?.title??a.target.taskId:t.targetFresh})]}),a.target&&(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:t.fieldTargetTab}),(0,V.jsx)(`input`,{ref:f(`targetTab`),className:Qt,spellCheck:!1,value:a.target.tabId,onChange:e=>a.target&&p({target:{...a.target,tabId:e.target.value}}),onKeyDown:S(`prompt`)})]}),(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.fieldPrompt}),(0,V.jsx)(`input`,{ref:f(`prompt`),className:Qt,spellCheck:!1,placeholder:t.promptPlaceholder,value:a.prompt,onChange:e=>p({prompt:e.target.value}),onKeyDown:S(`schedule`)})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${rz}`,children:[t.fieldSchedule,(0,V.jsx)(`span`,{className:`keys-only text-muted ${iz}`,children:`←/→ ↑/↓`})]}),(0,V.jsx)(mz,{fieldRef:f(`schedule`),kind:`cells`,label:t.fieldSchedule,className:XB,onKeyDown:T,children:oB.map((e,n)=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,className:ZB(n===s),onClick:()=>{c(n),d.current.schedule?.focus()},children:[C[n]??`*`,(0,V.jsx)(`span`,{children:t.cronField[e]})]},e))}),(0,V.jsx)(`div`,{className:QB,children:[-1,1].map(e=>{let n=t.cronField[oB[s]??`minute`]??``;return(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,className:$B,"aria-label":z(e<0?`pages.cronDown`:`pages.cronUp`,{field:n}),onClick:()=>{w(e),d.current.schedule?.focus()},children:e<0?`−`:`+`},e)})}),E.kind===`ok`?(0,V.jsxs)(`p`,{className:`mono text-success`,children:[D?`${D}, `:``,E.relative,`, `,E.absolute]}):(0,V.jsx)(`p`,{className:`mono text-error`,children:E.kind===`never`?t.cronNever:t.cronInvalid})]}),l&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,l]}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${cz}`,children:(0,V.jsx)(ST,{text:Yo(t.composerLegend)})}),(0,V.jsxs)(`div`,{className:$t,children:[(0,V.jsx)(`button`,{type:`button`,className:Xt,onClick:yn,children:n.cancel}),(0,V.jsx)(`button`,{ref:f(`confirm`),type:`button`,className:je(),onClick:m,children:n.create})]})]})]})})}var tV=[`ok`,`blocked`,`failed`,`skipped`];function nV(e){switch(e.status){case`dispatched`:case`revived`:case`ran`:return`ok`;case`skipped_blocked`:return`blocked`;case`dispatch_failed`:case`skipped_unavailable`:case`script_failed`:return`failed`;default:return`skipped`}}var rV={scheduled:`schedule`,manual:`manual`,webhook:`webhook`};function iV(e){if(e.status===`skipped_precheck`)return e.precheckResult?.durationMs??null;if(e.status===`ran`||e.status===`script_failed`)return null;let t=Date.parse(e.at),n=Date.parse(e.response?.at??``);return Number.isFinite(t)&&Number.isFinite(n)&&n>=t?n-t:null}function aV(e){if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return n%60==0?`${r}h`:`${r}h ${n%60}m`}function oV(e,t,n){return(t===null?Object.values(e).flat():e[t]??[]).filter(e=>n===null||nV(e)===n).sort((e,t)=>Date.parse(t.at)-Date.parse(e.at)||t.runNumber-e.runNumber)}function sV(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`);if(t<0||n<=t)return null;try{return{prefix:e.slice(0,t).trim(),value:JSON.parse(e.slice(t,n+1))}}catch{return null}}var cV=(e,t)=>e&&typeof e==`object`?Reflect.get(e,t):void 0;function lV(e){let t=sV(e);if(!t)return{summary:e,full:e};let n=cV(t.value,`error`)??t.value,r=cV(n,`message`),i=cV(n,`code`),a=typeof r==`string`?typeof i==`string`?`${i}: ${r}`:r:null,o=t.prefix.replace(/:$/,``);return{summary:a?`${o} — ${a}`:e,full:`${t.prefix}\n${JSON.stringify(t.value,null,2)}`}}function uV(e){let t=e.trim();if(!/^[[{]/.test(t))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}var dV={dispatched:`success`,revived:`success`,skipped_precheck:`muted`,skipped_blocked:`warning`,skipped_cancelled:`muted`,skipped_missed:`warning`,skipped_unavailable:`warning`,dispatch_failed:`error`,ran:`success`,script_failed:`error`},fV={success:`text-success`,muted:`text-muted`,warning:`text-warning`,error:`text-error`},pV={success:`✓`,error:`†`,warning:`!`,muted:`·`},mV=e=>dV[e]??`muted`;function hV(e){let{auto:t}=oL(),{runs:n,when:r}=e,i=e=>t.runStatus[e]??e,a=n.filter(e=>e.response);return(0,V.jsxs)(V.Fragment,{children:[n[0]?.precheckResult&&(0,V.jsx)(gV,{run:n[0]}),(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:t.responses}),a.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.noResponses}):a.map(e=>(0,V.jsxs)(`div`,{className:qB,children:[(0,V.jsx)(`p`,{className:`mono ${YB} ${fV[mV(e.status)]}`,children:`#${e.runNumber} ${i(e.status)}, ${r(e.response?.at)}`}),(0,V.jsx)(`p`,{className:JB(!1),children:uV(e.response?.text??``)})]},e.id))]})}function gV({run:e}){let{auto:t}=oL(),n=e.precheckResult;if(!n)return null;let r=n.timedOut?t.precheckTimedOut:sL(t.precheckExited,{code:String(n.exitCode??`?`)}),i=[{label:t.precheckStdout,text:n.stdout},{label:t.precheckStderr,text:n.stderr}].filter(e=>e.text.trim().length>0);return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:sL(t.precheckDetail,{exit:r,duration:String(n.durationMs)})}),i.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.precheckNoOutput}):i.map(e=>(0,V.jsx)(`p`,{className:`mono ${JB(!0)}`,children:`${e.label}: ${e.text.replace(/\s+$/,``).split(`
123
+ `);return r?r.length>XI?`${r.slice(0,XI).trimEnd()}…`:r:null}function QI(e){let t=e.files.filter(e=>e.scope===`working`),n=t.length>0?`working`:`branch`,r=n===`working`?t:e.files.filter(e=>e.scope===`branch`);return{scope:n,files:r,added:r.reduce((e,t)=>e+(t.added??0),0),deleted:r.reduce((e,t)=>e+(t.deleted??0),0)}}async function $I(e,t,n){let r=new Set(e.tasks.get()?.tasks.map(e=>e.id)),i=0;try{for(let a of t.filter(e=>r.has(e)))await e.client.request(`task.archive`,{taskId:a,archived:!0,...n?{force:!0}:{}}),i++}catch(e){if(i>0&&G(z(`compare.archived`,{count:i})),e instanceof r_&&e.code===`TASK_BUSY`)throw e;G(z(`compare.archiveFailed`,{error:K(e)}),`error`);return}G(z(`compare.archived`,{count:i}))}async function eL(e,t,n){try{for(let r of n)r.id!==t.id&&r.kept&&await e.client.request(`task.keep`,{taskId:r.id,kept:!1});await e.client.request(`task.keep`,{taskId:t.id,kept:!0})}catch(e){G(z(`compare.keepFailed`,{error:K(e)}),`error`);return}G(z(`compare.keptToast`,{title:t.label}));let r=n.filter(e=>e.id!==t.id).map(e=>e.id);r.length!==0&&W.set((0,V.jsx)(sr,{title:z(`compare.archiveTitle`),body:z(`compare.archiveBody`,{count:r.length}),confirmLabel:z(`compare.archiveConfirm`),onConfirm:()=>$I(e,r,!1),escalate:{when:e=>e instanceof r_&&e.code===`TASK_BUSY`,label:z(`compare.archiveBusyConfirm`),title:z(`compare.archiveBusyTitle`),body:()=>z(`compare.archiveBusyBody`),run:()=>$I(e,r,!0)}}))}async function tL(e,t){try{await e.client.request(`task.keep`,{taskId:t.id,kept:!1}),G(z(`compare.unkeptToast`,{title:t.label}))}catch(e){G(z(`compare.keepFailed`,{error:K(e)}),`error`)}}var nL={title:`ROUTINES`,holdingDaemon:`keeping the daemon awake`,notHolding:`none active`,needAttention:`{count} of {total} need you ·`,paused:`paused`,newTitle:`New routine`,composerLegend:`enter create · tab fields · ←→ ↑↓ edit the focused field · esc cancel`,fieldName:`NAME`,fieldRepo:`REPO`,fieldTarget:`DELIVER TO`,fieldTargetTab:`EXISTING ENGINE TAB`,targetFresh:`New task on each run`,targetStanding:`Routine-owned standing task`,targetExisting:`Existing conversation: {task} / {tab}. Never creates or revives a session.`,fieldPrompt:`PROMPT`,fieldSchedule:`SCHEDULE (FIVE-FIELD CRON)`,namePlaceholder:`weekday dependency audit`,promptPlaceholder:`Audit dependencies and summarize risky changes.`,noProject:`Ungrouped`,cronInvalid:`not a five-field cron`,cronField:{minute:`min`,hour:`hour`,dayOfMonth:`day`,month:`month`,dayOfWeek:`weekday`},schedule:{everyDay:`every day {at}`,weekdays:`weekdays {at}`,weekends:`weekends {at}`,onWeekday:`{weekday} {at}`,everyMinute:`every minute`,everyMinutes:`every {n}m`,everyHours:`every {n}h`,hourlyAt:`hourly at :{minute}`,atClock:`at {time}`,dow:{MON:`Mondays`,TUE:`Tuesdays`,WED:`Wednesdays`,THU:`Thursdays`,FRI:`Fridays`,SAT:`Saturdays`,SUN:`Sundays`}},when:{inMinutes:`in {n}m`,inHours:`in {n}h`,inDays:`in {n}d`,minutesAgo:`{n}m ago`,hoursAgo:`{n}h ago`,now:`now`,justNow:`just now`,dateTime:`{date}, {time}`},runStatus:{dispatched:`dispatched`,revived:`revived`,skipped_cancelled:`cancelled before delivery`,skipped_precheck:`skipped (precheck)`,skipped_blocked:`skipped (task can't use it)`,skipped_missed:`skipped (missed)`,skipped_unavailable:`skipped (unavailable)`,dispatch_failed:`dispatch failed`,ran:`ran`,script_failed:`script failed`},cronNever:`valid, but never fires`,missing:{target:`Choose an existing task.`,targetTab:`Enter an existing tab id, e.g. tab-2.`,name:`Give it a name.`,repo:`Pick a project.`,prompt:`Say what it should do.`,schedule:`That schedule will not run.`},empty:`No routines scheduled.`,emptyHint:`Press n to create one.`,precheck:`precheck: {command}`,lastFailed:`last failed {when}: {reason}`,recentRuns:`RECENT RUNS`,precheckDetail:`WHY IT SKIPPED — precheck {exit} in {duration}ms`,precheckExited:`exited {code}`,precheckTimedOut:`timed out`,precheckStdout:`stdout`,precheckStderr:`stderr`,precheckNoOutput:`(no output)`,noRuns:`Not run yet.`,responses:`RESPONSES`,noResponses:"No run has reported back yet. Agents answer with `routine-respond`.",responseAwaiting:`awaiting response`,responseMissing:`no response`,noSelection:`A routine runs its prompt in a project on a schedule.`,running:`Running {name}…`,ranWith:`{name}: {status}`,latestRunNoTask:`The latest run created no task.`,runNow:`[ run now ]`,deleteTitle:`Delete routine?`,deleteBody:`{name} and its run history will be removed. Tasks it already created are untouched.`,deleteButton:`Delete`,createFailed:`Couldn't create the routine: {error}`,deleteFailed:`Couldn't delete "{name}": {error}`,enableFailed:`"{name}" stays paused: {error}`,disableFailed:`"{name}" stays enabled: {error}`,runFailed:`Couldn't run "{name}" now — schedule unchanged: {error}`},rL={title:`例行任务`,holdingDaemon:`正在保持守护进程常驻`,notHolding:`无启用项`,needAttention:`{total} 个中有 {count} 个需要处理 ·`,paused:`已暂停`,newTitle:`新建例行任务`,composerLegend:`enter 创建 · tab 切字段 · ←→ ↑↓ 编辑当前字段 · esc 取消`,fieldName:`名称`,fieldTarget:`投递目标`,fieldTargetTab:`既有引擎标签页`,targetFresh:`每次新建任务`,targetStanding:`例行任务自有的常驻任务`,targetExisting:`既有会话:{task} / {tab}。不会创建或重启会话。`,fieldRepo:`仓库`,fieldPrompt:`提示词`,fieldSchedule:`调度(五段 cron)`,namePlaceholder:`工作日依赖审计`,promptPlaceholder:`审计依赖并总结有风险的变更。`,noProject:`未分组`,cronInvalid:`不是合法的五段 cron`,cronField:{minute:`分`,hour:`时`,dayOfMonth:`日`,month:`月`,dayOfWeek:`星期`},schedule:{everyDay:`每天{at}`,weekdays:`工作日{at}`,weekends:`周末{at}`,onWeekday:`{weekday}{at}`,everyMinute:`每分钟`,everyMinutes:`每 {n} 分钟`,everyHours:`每 {n} 小时`,hourlyAt:`每小时的 :{minute}`,atClock:`{time}`,dow:{MON:`每周一`,TUE:`每周二`,WED:`每周三`,THU:`每周四`,FRI:`每周五`,SAT:`每周六`,SUN:`每周日`}},when:{inMinutes:`{n} 分钟后`,inHours:`{n} 小时后`,inDays:`{n} 天后`,minutesAgo:`{n} 分钟前`,hoursAgo:`{n} 小时前`,now:`即将`,justNow:`刚刚`,dateTime:`{date} {time}`},runStatus:{dispatched:`已派发`,revived:`已重启会话`,skipped_cancelled:`交付前已取消`,skipped_precheck:`已跳过(预检)`,skipped_blocked:`已跳过(任务暂不能接收)`,skipped_missed:`已跳过(错过时间)`,skipped_unavailable:`已跳过(不可用)`,dispatch_failed:`派发失败`,ran:`已运行`,script_failed:`脚本失败`},cronNever:`语法合法,但永远不会触发`,missing:{target:`请选择既有任务。`,targetTab:`请输入既有标签页 ID,例如 tab-2。`,name:`起个名字。`,repo:`选一个项目。`,prompt:`说明它要做什么。`,schedule:`这个调度不会触发。`},empty:`还没有例行任务。`,emptyHint:`按 n 新建一条。`,precheck:`预检:{command}`,lastFailed:`上次失败({when}):{reason}`,recentRuns:`最近执行`,precheckDetail:`为什么跳过 —— 预检{exit},耗时 {duration}ms`,precheckExited:`退出码 {code}`,precheckTimedOut:`超时`,precheckStdout:`标准输出`,precheckStderr:`标准错误`,precheckNoOutput:`(无输出)`,noRuns:`尚未执行。`,responses:`回报`,noResponses:"还没有执行回报。agent 用 `routine-respond` 回报。",responseAwaiting:`等待回报`,responseMissing:`未回报`,noSelection:`例行任务会按调度在某个项目里跑它的提示词。`,running:`正在运行 {name}…`,ranWith:`{name}:{status}`,latestRunNoTask:`最近一次执行没有创建任务。`,runNow:`[ 立即运行 ]`,deleteTitle:`删除这条例行任务?`,deleteBody:`将删除 {name} 及其执行记录。它已经创建的任务不受影响。`,deleteButton:`删除`,createFailed:`创建例行任务失败:{error}`,deleteFailed:`删除“{name}”失败:{error}`,enableFailed:`“{name}”仍处于暂停状态:{error}`,disableFailed:`“{name}”仍处于启用状态:{error}`,runFailed:`无法立即运行“{name}”——排程未受影响:{error}`},iL={title:`Kanban`,hint:`tab project · ←↓↑→ card · enter detail · n new · d delete · r refresh · esc close`,loading:`Loading issues…`,noRepos:"No projects yet — add one with `rove add <path>`, or file a story with `rove api issue-create`.",empty:"No issues — agents file them via `rove api issue-create`.",readFailed:"Couldn't read this project's stories: {error}. Run `rove doctor`, then reopen Kanban.",readFailedToast:`Couldn't read stories for {repo}: {error}`,columnEmpty:`No cards`,column:{backlog:`Backlog`,inProgress:`In progress`,parked:`Parked`,done:`Done`},more:`+{count} more`,attention:`{count} need you`,turnComplete:`turn done`,menu:{setStatus:`status → {status}`},detail:{status:{open:`open`,doing:`doing`,hold:`hold`,done:`done`},statusLabel:`STATUS`,created:`created {date}`,linked:`linked to a session`,titleLabel:`TITLE`,description:`DESCRIPTION`,noDescription:`No description.`,attachHint:`paste a path / ctrl+v screenshot → inserts an image placeholder`,engine:`ENGINE`,workspace:`WORKSPACE`,placement:{worktree:`New worktree task — its own workspace`,projectWorktree:`New worktree — as a chattab in the project workspace`,project:`Project checkout — a new chattab, no worktree`},jumpLabel:`AFTER START`,jump:{stay:`Stay on the board`,follow:`Jump to the session`},startLegend:`enter/ctrl+enter start · tab fields · ←→ status/engine · ↑↓ workspace · esc save & close`,sessionLabel:`SESSION`,openAction:`Open the linked session ↵`,unlinkAction:`Unlink`,openLegend:`enter open the focused action · tab fields · ←→ status · unlink returns the card to Backlog · esc save & close`,eventsLabel:`EVENTS`,eventsLoading:`Loading events…`,eventsNone:`No engine events recorded yet.`,doneNote:`Done stories have nothing left to start — set the status back to reopen one · esc save & close`,startedBackground:`Started in background: {title}`,newStory:`NEW STORY`,createLegend:`ctrl+s save · enter/ctrl+enter save & start · tab fields · esc cancel`},confirmDelete:{title:`Delete story #{id}?`,body:`“{title}” will be removed from the tracker. A linked task, branch, or worktree is left untouched.`},deleteFailed:`Couldn't delete story #{id}: {error}`,createFailed:`Couldn't create the story: {error}`,updateFailed:`Couldn't save story #{id}: {error}`,statusFailed:`Story #{id} stays in its old column: {error}`,linkFailed:`Story #{id} isn't linked to its task: {error}`,unlinkFailed:`Story #{id} is still linked: {error}`},aL={title:`看板`,hint:`tab 切项目 · ←↓↑→ 选卡片 · enter 详情 · n 新建 · d 删除 · r 刷新 · esc 关闭`,loading:`正在加载 issues…`,noRepos:"还没有项目——用 `rove add <路径>` 添加一个,或用 `rove api issue-create` 创建一个 story。",empty:"暂无 issue——agent 可通过 `rove api issue-create` 创建。",readFailed:"读取该项目的 story 失败:{error}。请运行 `rove doctor`,再重新打开看板。",readFailedToast:`读取 {repo} 的 story 失败:{error}`,columnEmpty:`暂无卡片`,column:{backlog:`待办`,inProgress:`进行中`,parked:`搁置`,done:`已完成`},more:`还有 {count} 条`,attention:`{count} 张等你处理`,turnComplete:`回合完成`,menu:{setStatus:`状态 → {status}`},detail:{status:{open:`待办`,doing:`进行中`,hold:`搁置`,done:`已完成`},statusLabel:`状态`,created:`创建于 {date}`,linked:`已关联会话`,titleLabel:`标题`,description:`描述`,noDescription:`暂无描述。`,attachHint:`粘贴路径 / ctrl+v 贴截图 → 插入图片占位行`,engine:`引擎`,workspace:`工作区`,placement:{worktree:`新建 worktree 任务——独立工作区`,projectWorktree:`新建 worktree——作为项目工作区里的 chattab`,project:`项目主目录——新开 chattab,不建 worktree`},jumpLabel:`启动后`,jump:{stay:`留在看板`,follow:`跳转到会话`},startLegend:`enter/ctrl+enter 启动 · tab 切字段 · ←→ 状态/引擎 · ↑↓ 工作区 · esc 保存关闭`,sessionLabel:`会话`,openAction:`打开关联会话 ↵`,unlinkAction:`解除关联`,openLegend:`enter 执行选中操作 · tab 切字段 · ←→ 状态 · 解除关联把卡片退回 Backlog · esc 保存关闭`,eventsLabel:`事件`,eventsLoading:`正在加载事件…`,eventsNone:`暂无引擎事件记录。`,doneNote:`已完成的 story 无需启动——改回状态即可重新打开 · esc 保存关闭`,startedBackground:`已在后台启动:{title}`,newStory:`新建 STORY`,createLegend:`ctrl+s 仅保存 · enter/ctrl+enter 保存并启动 · tab 切字段 · esc 取消`},confirmDelete:{title:`删除 story #{id}?`,body:`「{title}」将从 tracker 中移除。已关联的任务、分支、worktree 不受影响。`},deleteFailed:`删除 story #{id} 失败:{error}`,createFailed:`创建 story 失败:{error}`,updateFailed:`保存 story #{id} 失败:{error}`,statusFailed:`Story #{id} 仍留在原来的列:{error}`,linkFailed:`Story #{id} 未能关联到它的任务:{error}`,unlinkFailed:`Story #{id} 仍处于关联状态:{error}`},oL={title:`ISSUES`,noRepo:`no project`,empty:`No open issues.`,assignedFilter:`assigned to me`,starting:`Starting work on #{number}…`,startedNoEngine:`Created {title}, but its engine did not start.`,linkedChip:`→ {title}`,openingLinked:`Opening {title}…`,startFailed:`Couldn't start work on #{number}: {error}`,errorHint:{noRemote:"Add a GitHub remote (`git remote add origin <url>`) and try again, or press q / esc to close.",ghMissing:"Install the `gh` CLI and authenticate, or press q / esc to close.",auth:"Run `gh auth login`, or press q / esc to close.",fallback:`{message} · press q / esc to close`}},sL={title:`议题`,noRepo:`无项目`,empty:`没有开放的议题。`,assignedFilter:`分配给我的`,starting:`正在开始处理 #{number}…`,startedNoEngine:`已创建 {title},但引擎没有启动。`,linkedChip:`→ {title}`,openingLinked:`正在打开 {title}…`,startFailed:`开始处理 #{number} 失败:{error}`,errorHint:{noRemote:"添加 GitHub remote(`git remote add origin <url>`)后重试,或按 q / esc 关闭。",ghMissing:"安装 `gh` CLI 并登录,或按 q / esc 关闭。",auth:"执行 `gh auth login`,或按 q / esc 关闭。",fallback:`{message} · 按 q / esc 关闭`}};function cL(){let e=B()===`zh`;return{kanban:e?aL:iL,auto:e?rL:nL,items:e?sL:oL,nav:(e?Dr:Er).nav,group:(e?Dr:Er).group,common:e?dr:ur}}function lL(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??e))}function uL(){let{auto:e}=cL();return(t,n)=>{let r=e;for(let e of t.replace(/^automations\./,``).split(`.`))r=r&&typeof r==`object`?Reflect.get(r,e):void 0;return typeof r==`string`?n?lL(r,n):r:t}}function dL(e){return e instanceof Error?e.message:String(e)}function fL(e){return e.replace(/^\/private\//,`/`).replace(/\/+$/,``)}function pL(e,t){let n=e.split(`/`).filter(Boolean),r=n[n.length-1]??e;return t.some(t=>t!==e&&t.split(`/`).filter(Boolean).pop()===r)&&n.length>1?`${n[n.length-2]}/${r}`:r}function mL(...e){let t=new Set,n=[];for(let r of e.flat()){if(!r||r.startsWith(`ssh://`))continue;let e=fL(r);t.has(e)||(t.add(e),n.push(r))}return n}function hL(e){return mL((v(e.tasks)?.tasks??[]).filter(e=>!aw(e)).map(e=>e.repo))}function gL(e){let t=v(e.tasks),{taskId:n}=v(e.selection);return t?.tasks.find(e=>e.id===n)?.repo}function _L(e){let[t,n]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let t=window.setInterval(()=>n(e=>e+1),e);return()=>window.clearInterval(t)},[e]),[t,(0,g.useCallback)(()=>n(e=>e+1),[])]}function vL(e){return e instanceof HTMLElement?e.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName):!1}function yL(e){let t=(0,g.useRef)(e);t.current=e,(0,g.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||W.get()||nn.get())return;let n=e.target instanceof HTMLElement?e.target:null;vL(n)||n?.closest(`.rail, .side-panel, .xterm`)||e.metaKey||e.altKey||e.ctrlKey&&e.key.toLowerCase()===`c`&&window.getSelection()?.toString()||t.current(e)&&(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function bL(){let e=(0,g.useRef)(null);return(0,g.useEffect)(()=>e.current?.focus(),[]),e}function xL({tone:e,children:t}){return(0,V.jsx)(`span`,{className:ke(`flex-none font-mono text-meta`,e&&CT[e]),children:t})}var SL=`mt-3 grid grid-cols-[repeat(auto-fit,minmax(min(100%,17rem),1fr))] items-start gap-x-5 gap-y-6`,CL=e=>e?`flex min-w-0 flex-col gap-2 pt-2 [border-top:var(--hairline)_solid_var(--accent)]`:`flex min-w-0 flex-col gap-2 pt-2 [border-top:var(--hairline)_solid_var(--line)]`,wL=`flex min-w-0 items-center gap-2`,TL=`min-w-0 truncate font-bold`,EL=`truncate font-mono text-meta text-muted`,DL=`m-0 line-clamp-6 whitespace-pre-wrap wrap-anywhere`,OL=`flex min-w-0 flex-col`,kL=`flex min-w-0 items-baseline gap-2 py-px font-mono text-meta`,AL=`flex flex-wrap gap-x-3.5 gap-y-1 font-mono text-meta`,jL=`flex min-w-0 flex-wrap items-center gap-x-3.5 gap-y-0.5 px-2.5 py-1 font-mono text-meta`,ML=1.2,NL=.3,PL=20,FL=.35,IL=.25,LL=.12,RL=2,zL=1,BL={error:{dots:[0,4,8,2,6],bright:1},done:{dots:[3,7,5,2],bright:1},idle:{dots:[1,2,5,8,7,6,3,0],bright:.6}},VL=Array.from({length:9},(e,t)=>Math.hypot(t%3-1,Math.floor(t/3)-1));function HL(e){return FL+.65*(.5+.5*Math.cos(2*Math.PI*e/ML))}function UL(e,t,n,r=1){switch(e){case`working`:{let e=t*80/1e3/r;return VL.map(t=>HL(e-t*NL))}case`waiting`:{let e=[0,1,4,5].includes(Math.floor(t/r)%PL);return Array(9).fill(e?IL:1)}default:{let t=BL[e],r=Array(9).fill(LL);return t?.dots.forEach((e,i)=>{let a=Math.min(Math.max(n-i*zL,0),RL)/RL;r[e]=t.bright*a+LL*(1-a)}),r}}}function WL(e,t){let n=BL[e];return!n||t<(n.dots.length-1)*zL+RL}var GL=3,KL=new Set,qL;function JL(e,t){let n=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,r=1/0,i=e.held+t-e.step,a=WL(e.look,n?r:i);return UL(e.look,t,n?r:i,n?GL:1).forEach((t,n)=>{let r=e.el.children[n].style;r.opacity=t.toFixed(3)}),a}function YL(){let e=Math.floor(performance.now()/80);for(let t of KL)JL(t,e)||KL.delete(t);XL()}function XL(){qL=KL.size?window.setTimeout(YL,80-performance.now()%80+2):void 0}function ZL(e,t,n){let r=Math.floor(performance.now()/80),i=n>0?Math.max(Date.now()-n,0):1/0,a={el:e,look:t,step:r,held:Math.floor(i/80)};return JL(a,r)&&(KL.add(a),qL===void 0&&XL()),()=>{KL.delete(a)}}function QL({status:e}){let{look:t,tone:n}=VF(e);return(0,V.jsx)(eR,{look:t,tone:n,since:e?.since??0},t)}var $L=e=>e===`muted`?`text-muted`:e===`ink`?`text-ink`:CT[e];function eR({look:e,tone:t,since:n}){let r=(0,g.useRef)(null),[i]=(0,g.useState)(n);return(0,g.useLayoutEffect)(()=>{let t=r.current;return t?ZL(t,e,i):void 0},[e,i]),(0,V.jsx)(`span`,{ref:r,className:`inline-grid flex-none grid-cols-[repeat(3,3px)] auto-rows-[3px] gap-px self-center ${$L(t)}`,"aria-hidden":`true`,children:Array.from({length:9},(e,t)=>(0,V.jsx)(`i`,{className:`rounded-full bg-current opacity-12`},t))})}var tR=6;function nR(e,t){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.id})??null),o=`${t.rowStatus?.kind??``}:${t.rowStatus?.since??0}`,s=JSON.stringify(t.changes??null);return(0,g.useEffect)(()=>{let n=!0;return Fs(e,`output.read`,{taskId:t.id,limit:8}).then(e=>n&&r(ZI(e)),()=>n&&r(null)),()=>{n=!1}},[e,t.id,o]),(0,g.useEffect)(()=>{let n=!0;return Fs(e,`diff.files`,{taskId:t.id}).then(e=>n&&a(e),()=>{}),()=>{n=!1}},[e,t.id,s,o]),{reply:n,changes:i?QI(i):null}}function rR({changes:e,onOpen:t}){if(!e)return(0,V.jsx)(`p`,{className:Wt,children:`…`});if(e.files.length===0)return(0,V.jsx)(`p`,{className:`m-0 font-mono text-meta text-subtle`,children:z(`compare.noChanges`)});let n=e.files.length-tR;return(0,V.jsxs)(`div`,{className:OL,children:[(0,V.jsxs)(`p`,{className:`m-0 flex gap-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:z(`compare.files`,{count:e.files.length})}),e.added>0&&(0,V.jsxs)(xL,{tone:`added`,children:[`+`,e.added]}),e.deleted>0&&(0,V.jsxs)(xL,{tone:`removed`,children:[`−`,e.deleted]})]}),e.files.slice(0,tR).map(n=>(0,V.jsxs)(H,{variant:`row`,className:`${kL} text-left [&:hover]:underline`,title:n.path,onClick:()=>t(n.path,e.scope),children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.path}),n.added?(0,V.jsxs)(xL,{tone:`added`,children:[`+`,n.added]}):null,n.deleted?(0,V.jsxs)(xL,{tone:`removed`,children:[`−`,n.deleted]}):null]},n.path)),n>0&&(0,V.jsx)(`span`,{className:`font-mono text-meta text-subtle`,children:z(`compare.more`,{count:n})})]})}function iR({model:e,row:t,round:n}){let{reply:r,changes:i}=nR(e,t),{look:a}=VF(t.rowStatus),o=t.kept===!0,s=(n,r)=>{e.select(t.id),Vk({taskId:t.id,path:n,scope:r})};return(0,V.jsxs)(`section`,{className:CL(o),"data-attempt":t.id,children:[(0,V.jsxs)(`div`,{className:wL,children:[(0,V.jsx)(QL,{status:t.rowStatus}),(0,V.jsx)(`span`,{className:TL,children:t.engine?.name??t.label}),(0,V.jsx)(`span`,{className:`flex-none text-meta text-muted`,children:z(`compare.status.${a}`)}),o&&(0,V.jsx)(`span`,{className:`ml-auto flex-none font-mono text-meta text-accent`,children:z(`compare.kept`)})]}),(0,V.jsx)(`span`,{className:EL,title:t.branch,children:t.branch}),r?(0,V.jsx)(`p`,{className:DL,children:r}):(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:z(`compare.noReply`)}),(0,V.jsx)(rR,{changes:i,onOpen:s}),(0,V.jsxs)(`div`,{className:AL,children:[(0,V.jsx)(H,{hit:`tight`,onClick:()=>e.select(t.id),children:z(`compare.terminal`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(`.`,i?.scope??`working`),children:z(`compare.diff`)}),o?(0,V.jsx)(H,{hit:`tight`,onClick:()=>void tL(e,t),children:z(`compare.unkeep`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>void eL(e,t,n),children:z(`compare.keep`)})]})]})}function aR({model:e}){B();let t=v(cn),n=v(e.tasks),r=bL(),i=t&&n?YI(n.tasks,t):[];return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:r,onKeyDown:e=>{e.metaKey||e.ctrlKey||e.altKey||e.key!==`q`&&e.key!==`Escape`||(e.preventDefault(),on.set(null))},children:[(0,V.jsx)(`h1`,{className:cM,children:z(`compare.title`)}),i.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`compare.empty`)}):(0,V.jsx)(`div`,{className:SL,children:i.map(t=>(0,V.jsx)(iR,{model:e,row:t,round:i},t.id))})]})}function oR(e){let t=Math.floor(e/6e4),n=Math.floor(t/60);return{minutes:t,hours:n,days:Math.floor(n/24)}}function sR(e,t=Date.now()){let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`${r}s`;let{minutes:i,hours:a,days:o}=oR(n);return i<60?`${i}m`:a<24?`${a}h`:`${o}d`}var cR=[{id:`issues`,label:`reviewQueue.sourceIssues`},{id:`reviews`,label:`reviewQueue.sourceReviews`}];function lR(){B();let e=v(RO);return(0,V.jsx)(`span`,{className:`flex items-baseline gap-3 font-mono text-meta`,children:cR.map(t=>t.id===e?(0,V.jsx)(`span`,{className:`text-ink`,children:z(t.label)},t.id):(0,V.jsx)(H,{onClick:()=>RO.set(t.id),children:z(t.label)},t.id))})}var uR={passing:`reviewQueue.checksPassing`,failing:`reviewQueue.checksFailing`,pending:`reviewQueue.checksPending`},dR={missing:`reviewQueue.gh.missing`,unauthenticated:`reviewQueue.gh.unauthenticated`,failed:`reviewQueue.gh.failed`};function fR(e){let{pr:t}=e,n=Date.parse(t.createdAt),r=[t.isDraft?z(`reviewQueue.draft`):``,t.fork?z(`reviewQueue.fork`):``,t.checks?z(uR[t.checks]):``];return(0,V.jsxs)(`div`,{"data-row":e.index,className:mM(e.at),onClick:e.onPick,children:[(0,V.jsxs)(`div`,{className:hM,children:[(0,V.jsxs)(`span`,{className:`mono ${gM}`,children:[t.nameWithOwner.split(`/`)[1],`#`,t.number]}),(0,V.jsx)(`span`,{className:vM,children:t.title}),(0,V.jsx)(H,{disabled:e.busy,onClick:e.onReview,children:z(`reviewQueue.start`)})]}),(0,V.jsxs)(`div`,{className:_M,children:[(0,V.jsx)(`span`,{className:vM,children:[t.author,...r].filter(Boolean).join(`, `)}),(0,V.jsxs)(`span`,{className:`mono`,children:[`+`,t.additions,` −`,t.deletions]}),(0,V.jsx)(`span`,{className:`mono`,children:Number.isFinite(n)?sR(n,e.now):``})]})]})}function pR({model:e}){B();let t=e.client,[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(0),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),m=(0,g.useRef)(!1),h=bL(),_=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0,n=m.current;return m.current=!1,a(null),t.request(`review.queue`,n?{refresh:!0}:{}).then(t=>e&&r(t)).catch(t=>{e&&(a(dL(t)),r({prs:[],other:0}))}),()=>{e=!1}},[t,f]);let v=n?.prs??[],y=Math.min(o,Math.max(0,v.length-1));(0,g.useEffect)(()=>{_.current?.querySelector(`[data-row="${y}"]`)?.scrollIntoView({block:`nearest`})},[y]);let b=async e=>{if(c===null){l(e.number),d(z(`reviewQueue.preparing`,{number:e.number}));try{let{ref:n}=await t.request(`review.prepare`,{repo:e.repo,number:e.number});pn(zO(e,n,z(`reviewQueue.prompt`,{number:e.number,repo:e.nameWithOwner,title:e.title,url:e.url,head:e.headRef,base:e.baseRef})))}catch(t){G(z(`reviewQueue.failed`,{number:e.number,error:dL(t)}),`error`)}finally{l(null),d(null)}}};yL(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return s(Math.min(v.length-1,y+1)),!0;case`k`:case`ArrowUp`:return s(Math.max(0,y-1)),!0;case`r`:return m.current=!0,p(e=>e+1),!0;case`Enter`:{let e=v[y];return e&&b(e),!0}default:return!1}});let x=Date.now();return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:h,children:[(0,V.jsxs)(`div`,{className:lM,children:[(0,V.jsx)(`h1`,{className:cM,children:z(`reviewQueue.title`)}),(0,V.jsx)(lR,{})]}),i?(0,V.jsx)(`p`,{className:`text-error`,children:i}):n===null?(0,V.jsx)(`p`,{className:`text-muted`,children:`…`}):n.reason?(0,V.jsx)(`p`,{className:`text-muted`,children:z(dR[n.reason])}):v.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`reviewQueue.empty`)}):(0,V.jsx)(`div`,{className:pM,ref:_,children:v.map((e,t)=>(0,V.jsx)(fR,{pr:e,index:t,at:t===y,now:x,busy:c!==null,onPick:()=>s(t),onReview:()=>void b(e)},`${e.nameWithOwner}#${e.number}`))}),n&&n.other>0&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:z(`reviewQueue.other`,{count:n.other})}),u&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:u})]})}var mR=30;function hR(){let{items:e}=cL();return t=>{let n=t.indexOf(`: `);switch(n>=0?t.slice(0,n):`failed`){case`no-remote`:return e.errorHint.noRemote;case`gh-missing`:return e.errorHint.ghMissing;case`auth`:return e.errorHint.auth;default:return lL(e.errorHint.fallback,{message:t})}}}function gR({model:e}){let{items:t,common:n}=cL(),r=hR(),i=e.client,a=v(e.tasks),o=hL(e),s=gL(e),[c,l]=(0,g.useState)(()=>{let e=s?o.findIndex(e=>fL(e)===fL(s)):-1;return Math.max(0,e)}),u=o[c],d=(e,t)=>({repo:e,limit:mR,...t?{assignee:`@me`}:{}}),f=e=>Object.fromEntries(e.links.map(e=>[e.number,e.taskId])),[p,m]=(0,g.useState)(()=>u?Ns(i,`workitem.list`,d(u,!1))?.items??null:null),[h,_]=(0,g.useState)(()=>{let e=u?Ns(i,`workitem.links`,{repo:u}):void 0;return e?f(e):{}}),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(0),[T,E]=(0,g.useState)(0),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(null),j=bL(),ee=(0,g.useRef)(!1);(0,g.useEffect)(()=>{let e=!0;if(!u){m([]);return}b(null);let t=ee.current;ee.current=!1;let n=d(u,x),r=Ns(i,`workitem.list`,n);return r&&m(r.items),i.request(`workitem.list`,{...n,...t?{refresh:!0}:{}}).then(t=>e&&m(Ps(i,`workitem.list`,n,t).items)).catch(t=>{e&&(b(dL(t)),m([]))}),Fs(i,`workitem.links`,{repo:u}).then(t=>e&&_(f(t))).catch(()=>e&&_({})),()=>{e=!1}},[i,u,x,C,a?.tasks.length]);let M=p??[],N=Math.min(T,Math.max(0,M.length-1));(0,g.useEffect)(()=>A(null),[u,x]);let P=(0,g.useRef)(null);(0,g.useEffect)(()=>{P.current?.querySelector(`[data-row="${N}"]`)?.scrollIntoView({block:`nearest`})},[N]);let F=e=>a?.tasks.find(t=>t.id===e)?.label??e,I=t=>{on.set(null),e.select(t)},te=async()=>{let e=M[N];if(!e||!u||D)return;let n=h[e.number];if(n){A(lL(t.openingLinked,{title:F(n)})),I(n);return}O(!0),A(lL(t.starting,{number:e.number}));try{let n=await i.request(`workitem.start`,{repo:u,number:e.number});n.started?I(n.taskId):A(lL(t.startedNoEngine,{title:n.title}))}catch(n){G(lL(t.startFailed,{number:e.number,error:dL(n)}),`error`)}finally{O(!1)}};yL(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return E(Math.min(M.length-1,N+1)),!0;case`k`:case`ArrowUp`:return E(Math.max(0,N-1)),!0;case`Tab`:return l(t=>o.length?(t+(e.shiftKey?o.length-1:1))%o.length:0),!0;case`a`:return S(e=>!e),!0;case`r`:return ee.current=!0,w(e=>e+1),!0;case`Enter`:return te(),!0;default:return!1}});let L=Date.now();return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:j,children:[(0,V.jsxs)(`div`,{className:lM,children:[(0,V.jsx)(`h1`,{className:cM,children:t.title}),(0,V.jsx)(lR,{}),(0,V.jsxs)(`span`,{className:`mono touch:empty:hidden! text-muted ${uM(!0)}`,children:[u?pL(u,o):t.noRepo,x?` ${t.assignedFilter}`:``]})]}),y?(0,V.jsxs)(`div`,{className:pM,children:[(0,V.jsx)(`p`,{className:`text-error`,children:y}),(0,V.jsx)(`p`,{className:`text-muted`,children:r(y)})]}):p===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.loading}):M.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.empty}):(0,V.jsx)(`div`,{className:pM,ref:P,children:M.map((e,n)=>{let r=h[e.number],i=Date.parse(e.updatedAt);return(0,V.jsxs)(`div`,{"data-row":n,className:mM(n===N),onClick:()=>n===N?void te():E(n),children:[(0,V.jsxs)(`div`,{className:hM,children:[(0,V.jsxs)(`span`,{className:`mono ${gM}`,children:[`#`,e.number]}),(0,V.jsx)(`span`,{children:e.title})]}),(0,V.jsxs)(`div`,{className:_M,children:[(0,V.jsx)(`span`,{className:vM,children:[e.author,...e.labels.slice(0,2)].filter(Boolean).join(`, `)}),r&&(0,V.jsx)(`span`,{children:lL(t.linkedChip,{title:F(r)})}),(0,V.jsx)(`span`,{className:`mono`,children:Number.isFinite(i)?sR(i,L):``})]})]},e.number)})}),k&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:k})]})}function _R({model:e}){return v(RO)===`reviews`?(0,V.jsx)(pR,{model:e}):(0,V.jsx)(gR,{model:e})}var vR={backlog:`active`,in_progress:`active`,in_review:`parked`,error:`parked`,done:`terminal`,canceled:`terminal`,open:`active`,doing:`active`,hold:`parked`};function yR(e){return vR[e]??`parked`}var bR=[`backlog`,`in_progress`,`parked`,`done`];function xR(e,t,n){let r=e.find(e=>e.issues.length>0)?.issues[0]?.id??null;if(t==null)return r;let i=-1,a=-1;for(let[n,r]of e.entries()){let e=r.issues.findIndex(e=>e.id===t);if(e!==-1){i=n,a=e;break}}if(i===-1)return r;if(n===`up`||n===`down`){let r=e[i]?.issues??[],o=n===`up`?a-1:a+1;return r[Math.max(0,Math.min(o,r.length-1))]?.id??t}let o=n===`left`?-1:1;for(let n=i+o;n>=0&&n<e.length;n+=o){let r=e[n]?.issues??[];if(r.length!==0)return r[Math.min(a,r.length-1)]?.id??t}return t}function SR(e,t){let n=yR(e.status);return n===`terminal`?`done`:n===`parked`?`parked`:e.taskId!==void 0&&e.taskId!==``&&(t?.(e.taskId)??!0)||e.status===`doing`?`in_progress`:`backlog`}function CR(e,t){let n=0;return{columns:e.map(e=>{if(e.key!==`in_progress`)return e;let r=[],i=[];for(let n of e.issues)n.taskId!==void 0&&n.taskId!==``&&t(n.taskId)?r.push(n):i.push(n);return n=r.length,r.length===0?e:{...e,issues:[...r,...i]}}),attentionCount:n}}function wR(e,t){return e.created===t.created?t.id-e.id:e.created<t.created?1:-1}function TR(e,t){let n={backlog:[],in_progress:[],parked:[],done:[]};for(let r of e)n[SR(r,t)].push(r);return bR.map(e=>{let t=e===`done`||e===`parked`,r=n[e].sort(wR);return!t||r.length<=20?{key:e,issues:r,hiddenCount:0}:{key:e,issues:r.slice(0,20),hiddenCount:r.length-20}})}var ER=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`],DR=5242880;function OR(e,t){return/\.pdf$/i.test(e)?`pdf[${t}]`:`images[${t}]`}function kR(e){let t=-1;for(let n of e.matchAll(/^(?:images|pdf)\[(\d+)\]:/gm)){let e=Number.parseInt(n[1],10);e>t&&(t=e)}return t+1}function AR(e,t){let n=e.replace(/\s+$/,``),r=kR(e);for(let e of t){let t=`${OR(e,r)}: ${e}`;n=n.length>0?`${n}\n${t}`:t,r+=1}return n}function jR(e){return Array.from(e??[]).filter(e=>ER.includes(e.type))}function MR(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function NR(e,t){let n=MR(new Uint8Array(await t.arrayBuffer()));return(await e.request(`attachment.put`,{mime:t.type,data:n})).path}var PR=[`worktree`,`projectWorktree`,`project`];async function FR(e,t){let n=t.placement===`project`?`project`:`worktree`,{title:r,prompt:i}=await e.request(`issue.prompt`,{repo:t.repo,id:t.issue.id,where:n}),a=[];if(t.placement!==`project`){let{taskId:n}=await e.request(`task.create`,{repo:t.repo,engine:t.engine,title:r,prompt:i});if(await e.request(`issue.update`,{repo:t.repo,id:t.issue.id,task:n}).catch(e=>a.push({kind:`link`,error:dL(e)})),t.placement===`worktree`)return{taskId:n,warnings:a};let o=await e.request(`task.openMain`,{repo:t.repo}),s=await e.request(`tab.openViewport`,{taskId:o.taskId,viewTaskId:n});return{taskId:o.taskId,tabId:s.tabId,warnings:a}}let{taskId:o}=await e.request(`task.openMain`,{repo:t.repo}),{tabId:s,taskId:c=o}=await e.request(`tab.new`,{taskId:o,kind:`engine`,engine:t.engine,prompt:i});return await e.request(`issue.setStatus`,{repo:t.repo,id:t.issue.id,status:`doing`}).catch(e=>a.push({kind:`status`,error:dL(e)})),{taskId:c,tabId:s,warnings:a}}var IR=`text-meta leading-[inherit]`,LR=`text-meta`,RR=`flex flex-col gap-2 overflow-hidden`,zR=`flex min-w-0 items-baseline gap-3`,BR=`font-bold whitespace-nowrap text-accent touch:relative touch:after:absolute touch:after:-inset-x-2 touch:after:-inset-y-1 touch:after:content-['']`,VR=`min-w-0 truncate ${LR}`,HR=`ml-auto ${IR}`,UR=`grid min-h-0 flex-1 grid-cols-4 gap-2`,WR=`flex min-h-0 flex-1 flex-col gap-2`,GR=`flex gap-4 ${LR}`,KR=e=>`touch:relative touch:after:absolute touch:after:-inset-x-1.5 touch:after:-top-1 touch:after:-bottom-3 touch:after:content-[''] ${e?`font-bold text-accent`:`text-muted`}`,qR={in_progress:`text-accent`,parked:`text-warning`,done:`text-success`},JR=e=>`flex min-h-0 flex-col rounded-md border-hairline border-line p-2 ${e?`flex-1`:``}`,YR=e=>`m-0 mb-2 flex justify-between gap-2 font-mono text-meta font-bold normal-nums ${qR[e]??`text-muted`}`,XR=`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto`,ZR=`m-0 ${LR}`,QR=e=>`flex flex-none cursor-pointer flex-col gap-1 rounded-sm border-hairline bg-surface px-2.5 py-2 ${e.selected?`border-accent`:e.attention?`border-warning`:`border-line hover:border-line-active`}`,$R=`flex justify-between gap-2`,ez=e=>`min-w-0 font-bold wrap-anywhere ${e?`text-muted`:``}`,tz=`h-[2.8em] overflow-hidden whitespace-pre-wrap wrap-anywhere ${IR}`,nz=`flex justify-between gap-2 ${LR}`,rz=`w-[min(680px,calc(100vw-32px))]!`,iz=`flex items-baseline gap-3.5`,az=`flex items-baseline gap-2.5`,oz=`tracking-[0] normal-case`,sz=`min-h-40 font-mono`,cz=`flex flex-col items-start gap-0.5`,lz=e=>`text-left font-mono text-meta whitespace-pre-wrap normal-nums ${e?`font-bold text-accent`:`font-normal text-muted`}`,uz=IR,dz=`flex flex-col gap-1 [&_p]:m-0`,fz=`flex gap-2 ${LR}`,pz=`min-w-[4ch] text-right`,mz=`rounded-sm border-hairline border-transparent p-1 focus:border-accent focus:outline-none`,hz={choice:`radiogroup`,list:`listbox`,cells:`group`};function gz(e){return(0,V.jsx)(`div`,{ref:e.fieldRef,role:hz[e.kind??`choice`],tabIndex:0,"aria-label":e.label,className:`${mz} ${e.className??``}`,onKeyDown:e.onKeyDown,onClick:e.onClick,children:e.children})}var _z=[`open`,`doing`,`hold`,`done`];function vz({model:e,taskId:t}){let{kanban:n}=cL(),[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return e.client.request(`task.events`,{taskId:t}).then(e=>n&&i(e.events)).catch(()=>n&&i([])),()=>{n=!1}},[e,t]),(0,V.jsxs)(`div`,{className:dz,children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:n.detail.eventsLabel}),r===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.detail.eventsLoading}):r.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:n.detail.eventsNone}):r.map(e=>(0,V.jsxs)(`div`,{className:`mono ${fz}`,children:[(0,V.jsx)(`span`,{className:`text-muted ${pz}`,children:sR(e.at)}),(0,V.jsx)(`span`,{children:e.kind}),e.tail&&(0,V.jsx)(`span`,{className:`text-muted`,children:e.tail})]},`${e.at}:${e.kind}:${e.tail}`))]})}function yz(e){let{kanban:t}=cL(),{issue:n,mode:r}=e,i=r===`create`,a=!i&&n.taskId?n.taskId:null,o=i||!a&&n.status!==`done`,[s,c]=(0,g.useState)(n.title),[l,u]=(0,g.useState)(n.body),[d,f]=(0,g.useState)(n.status),[p,m]=(0,g.useState)(e.defaultEngine),[h,_]=(0,g.useState)(PR[0]),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1),S=(0,g.useRef)({}),C=e=>t=>{S.current[e]=t},w=i?`title`:o?`workspace`:a?`open`:`title`;(0,g.useEffect)(()=>S.current[w]?.focus(),[w]);let T=()=>({title:s.trim()||n.title,body:l,status:d}),E=()=>({engine:p,placement:h,jump:v}),D=t=>{yn(),t&&e.onOutcome(t)},O=()=>s.trim()?!0:(S.current.title?.focus(),!1),k=()=>{i?O()&&D({kind:`create`,title:s.trim(),body:l,start:E()}):o?D({kind:`start`,...E(),...T()}):a&&D({kind:`open`,taskId:a,...T()})},A=()=>{i&&O()&&D({kind:`create`,title:s.trim(),body:l,start:null})},j=()=>D(i?null:{kind:`close`,...T()}),ee=(0,g.useRef)({commit:k,saveOnly:A,close:j});ee.current={commit:k,saveOnly:A,close:j},(0,g.useEffect)(()=>{let e=e=>{let t=e.key===`Escape`?ee.current.close:e.key===`Enter`&&(e.ctrlKey||e.metaKey)?ee.current.commit:e.key.toLowerCase()===`s`&&e.ctrlKey&&!e.metaKey?ee.current.saveOnly:null;t&&(e.preventDefault(),e.stopImmediatePropagation(),t())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let M=async t=>{let n=t.find(e=>e.size>DR);if(n){G(z(`pages.attachTooLarge`,{name:n.name||n.type}),`error`);return}x(!0);try{let n=await Promise.all(t.map(t=>NR(e.model.client,t)));u(e=>AR(e,n))}catch(e){G(K(e),`error`)}finally{x(!1)}},N=e=>{let t=jR(e.clipboardData.files);t.length!==0&&(e.preventDefault(),M(t))},P=e=>{let t=jR(e.dataTransfer.files);e.preventDefault(),t.length>0&&M(t)},F=(e,t,n)=>e[(Math.max(0,e.indexOf(t))+n+e.length)%e.length],I=(e,t,n)=>r=>{if(r.ctrlKey||r.metaKey||r.altKey)return;let i=(e===`x`?{ArrowRight:1,l:1,ArrowLeft:-1,h:-1}:{ArrowDown:1,ArrowUp:-1})[r.key];if(i)t(i);else if(r.key===`Enter`&&n)n();else return;r.preventDefault()},te=d===`done`?`text-success`:d===`hold`?`text-warning`:d===`doing`?`text-accent`:`text-muted`,L=e=>t.detail.status[e];return(0,V.jsx)(`div`,{className:kn,onMouseDown:e=>e.target===e.currentTarget&&ee.current.close(),children:(0,V.jsxs)(`dialog`,{open:!0,className:`${An(!0)} ${rz}`,"aria-label":i?t.detail.newStory:`#${n.id}`,onPaste:N,onDrop:P,onDragOver:e=>e.preventDefault(),children:[(0,V.jsxs)(`div`,{className:jn,children:[i?(0,V.jsx)(`h1`,{className:`${U} text-muted`,children:t.detail.newStory}):(0,V.jsxs)(`h1`,{className:`${U} text-muted ${iz}`,children:[(0,V.jsxs)(`span`,{children:[`#`,n.id]}),(0,V.jsx)(`span`,{className:te,children:L(d)}),(0,V.jsx)(`span`,{className:`text-muted`,children:lL(t.detail.created,{date:n.created})}),a&&(0,V.jsx)(`span`,{className:`text-accent`,children:t.detail.linked})]}),(0,V.jsx)(`button`,{type:`button`,className:Nn,"aria-label":z(`dialog.close`),title:z(`dialog.close`),onClick:()=>ee.current.close(),children:`×`})]}),(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.detail.titleLabel}),(0,V.jsx)(`input`,{ref:C(`title`),className:Qt,spellCheck:!1,value:s,onChange:e=>c(e.target.value.replace(/[\r\n]+/g,` `)),onKeyDown:e=>{e.key===`Enter`&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),S.current.description?.focus())}})]}),(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.detail.description,(0,V.jsx)(`span`,{className:`text-muted ${oz}`,children:Ko()?z(`pages.attachHintTouch`):t.detail.attachHint}),b&&(0,V.jsx)(`span`,{className:`text-accent`,children:`…`})]}),(0,V.jsx)(`textarea`,{ref:C(`description`),className:`${Qt} ${Tn} ${sz}`,rows:8,spellCheck:!1,placeholder:t.detail.noDescription,value:l,onChange:e=>u(e.target.value)})]}),!i&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted flex items-baseline gap-2.5`,children:[t.detail.statusLabel,(0,V.jsx)(`span`,{className:`keys-only text-muted tracking-[0] normal-case`,children:`←/→`})]}),(0,V.jsx)(gz,{fieldRef:C(`status`),label:t.detail.statusLabel,className:`flex flex-wrap gap-1.5`,onKeyDown:I(`x`,e=>f(F(_z,d,e))),children:_z.map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===d,className:Dn(e===d),onClick:()=>{f(e),S.current.status?.focus()},children:L(e)},e))})]}),o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.detail.engine,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`←/→`})]}),(0,V.jsx)(gz,{fieldRef:C(`engine`),label:t.detail.engine,className:En,onKeyDown:I(`x`,t=>m(F(e.engines.map(e=>e.id),p,t)),k),children:e.engines.map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e.id===p,className:Dn(e.id===p),onClick:()=>{m(e.id),S.current.engine?.focus()},children:e.name},e.id))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.detail.workspace,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`↑/↓`})]}),(0,V.jsx)(gz,{fieldRef:C(`workspace`),label:t.detail.workspace,className:cz,onKeyDown:I(`y`,e=>_(F(PR,h,e)),k),children:PR.map(e=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===h,className:`touch:py-1.5 ${lz(e===h)}`,onClick:()=>{_(e),S.current.workspace?.focus()},children:[e===h?`▸ `:` `,t.detail.placement[e]]},e))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.detail.jumpLabel,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`←/→`})]}),(0,V.jsx)(gz,{fieldRef:C(`jump`),label:t.detail.jumpLabel,className:En,onKeyDown:I(`x`,()=>y(!v),k),children:[!1,!0].map(e=>(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e===v,className:Dn(e===v),onClick:()=>{y(e),S.current.jump?.focus()},children:e?t.detail.jump.follow:t.detail.jump.stay},String(e)))})]}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${uz}`,children:(0,V.jsx)(ST,{text:Yo(i?t.detail.createLegend:t.detail.startLegend)})}),(0,V.jsxs)(`div`,{className:$t,children:[i&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:A,children:z(`pages.storySave`)}),(0,V.jsx)(`button`,{type:`button`,className:je(),onClick:k,children:z(i?`pages.storySaveStart`:`pages.storyStart`)})]})]}):a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.detail.sessionLabel}),(0,V.jsxs)(`div`,{className:`${En} ${mz}`,children:[(0,V.jsx)(`button`,{ref:C(`open`),type:`button`,className:Dn(!0),onClick:()=>D({kind:`open`,taskId:a,...T()}),children:t.detail.openAction}),(0,V.jsx)(`button`,{ref:C(`unlink`),type:`button`,className:Dn(),onClick:()=>D({kind:`unlink`,...T()}),children:t.detail.unlinkAction})]})]}),(0,V.jsx)(vz,{model:e.model,taskId:a}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${uz}`,children:(0,V.jsx)(ST,{text:Yo(t.detail.openLegend)})})]}):(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${uz}`,children:(0,V.jsx)(ST,{text:Yo(t.detail.doneNote)})})]})]})})}var bz={"waiting-on-you":`text-error`,landing:`text-success`,"ready-for-review":`text-ink`,working:`text-accent`};function xz(e){let[t,n]=(0,g.useState)(()=>{let t=Ns(e,`engines.list`);return t?ms(t.engines):[]});return(0,g.useEffect)(()=>{Fs(e,`engines.list`).then(e=>n(ms(e.engines))).catch(()=>n([]))},[e]),{engines:t,defaultEngine:hs(t)}}function Sz(e,t){let n=hL(e),r=n.join(`
124
+ `),[i,a]=(0,g.useState)(()=>Ns(e,`kanban.boards`)??null);return(0,g.useEffect)(()=>{let t=!0,r=e.client,i=e=>r.request(e).then(e=>e.repos).catch(()=>[]);return Promise.all([i(`repos.list`),i(`issue.repos`)]).then(([e,t])=>mL(e,n,t)).then(e=>Promise.all(e.map(e=>r.request(`issue.list`,{repo:e}).catch(t=>({repoRoot:e,nextId:1,issues:[],readError:dL(t)}))))).then(n=>{let r=Ps(e,`kanban.boards`,void 0,[...n].sort((e,t)=>e.repoRoot.localeCompare(t.repoRoot)));t&&a(r)}),()=>{t=!1}},[e,t,r]),i}function Cz(e){let{issue:t}=e,n=t.body.trim();return(0,V.jsxs)(`div`,{"data-issue":t.id,className:QR({selected:e.selected,attention:e.badge?.tone===`text-error`}),onClick:()=>e.selected?e.onOpen():e.onSelect(),onContextMenu:t=>{t.preventDefault(),e.onMenu(t.clientX,t.clientY)},children:[(0,V.jsxs)(`div`,{className:$R,children:[(0,V.jsx)(`span`,{className:ez(e.column===`done`),children:t.title}),(0,V.jsxs)(`span`,{className:`mono text-muted`,children:[`#`,t.id]})]}),(0,V.jsx)(`div`,{className:`text-muted ${tz}`,children:n}),(0,V.jsxs)(`div`,{className:`mono text-muted ${nz}`,children:[(0,V.jsx)(`span`,{children:t.created}),e.badge&&(0,V.jsx)(`span`,{className:e.badge.tone,children:e.badge.label})]})]})}var wz=5e3,Tz=760;function Ez({model:e}){let{kanban:t,group:n,common:r}=cL(),[i,a]=_L(wz),o=Sz(e,i),{engines:s,defaultEngine:c}=xz(e),l=v(e.tasks),u=gL(e),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),h=bL(),[_,y]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>y(e.clientWidth<Tz));return t.observe(e),()=>t.disconnect()},[h]);let b=o??[],x=u?b.find(e=>e.repoRoot.replace(/^\/private\//,`/`)===u.replace(/^\/private\//,`/`)):void 0,S=Math.max(0,b.findIndex(e=>e.repoRoot===(d??x?.repoRoot))),C=b[S],w=b.map(e=>e.repoRoot),T=b.filter(e=>e.readError).map(e=>`${e.repoRoot}\0${e.readError}`).join(`
125
+ `);(0,g.useEffect)(()=>{for(let e of b)e.readError&&G(lL(t.readFailedToast,{repo:pL(e.repoRoot,w),error:e.readError}),`error`)},[T]);let E=l?.tasks??[],D=new Set(E.map(e=>e.id)),O=e=>E.find(t=>t.id===e)?.group,{columns:k,attentionCount:A}=CR(C?TR(C.issues,D.size===0?void 0:e=>D.has(e)):[],e=>O(e)===`waiting-on-you`),j={backlog:t.column.backlog,in_progress:t.column.inProgress,parked:t.column.parked,done:t.column.done},ee=(e,t)=>{let r=e.taskId&&(t===`in_progress`||t===`parked`)?O(e.taskId):void 0,i=r===`waiting-on-you`?n.waitingOnYou:r===`landing`?n.landing:r===`ready-for-review`?n.readyForReview:r===`working`?n.working:null;return r&&i?{label:i,tone:bz[r]??`text-muted`}:null},M=async(t,n,r,i)=>{try{return await e.client.request(t,{repo:C?.repoRoot,...n})}catch(e){return G(lL(r,{id:String(i),error:dL(e)}),`error`),null}finally{a()}},N=(e,n)=>M(`issue.setStatus`,{id:e.id,status:n},t.statusFailed,e.id),P=t=>{on.set(null),e.select(t)},F=async(n,r,i)=>{try{let a=await FR(e.client,{repo:n,issue:r,engine:i.engine,placement:i.placement});for(let e of a.warnings)G(lL(e.kind===`link`?t.linkFailed:t.statusFailed,{id:String(r.id),error:e.error}),`error`);i.jump?(on.set(null),e.selectWhenListed(a.taskId),a.tabId&&await e.refreshTabsNow().then(()=>e.select(a.taskId,a.tabId))):G(lL(t.detail.startedBackground,{title:`#${r.id} ${r.title}`}))}catch(e){G(K(e),`error`)}finally{a()}},I=async(e,n)=>{if(!C||n.kind===`create`)return;let r={};n.title!==e.title&&(r.title=n.title),n.body!==e.body&&(r.body=n.body),(r.title!==void 0||r.body!==void 0)&&await M(`issue.update`,{id:e.id,...r},t.updateFailed,e.id),n.status!==e.status&&await N(e,n.status),n.kind===`open`?P(n.taskId):n.kind===`unlink`?await M(`issue.update`,{id:e.id,task:`none`},t.unlinkFailed,e.id):n.kind===`start`&&await F(C.repoRoot,{...e,...r},n)},te=t=>{C&&(m(t.id),W.set((0,V.jsx)(yz,{model:e,issue:t,mode:`detail`,engines:s,defaultEngine:c,onOutcome:e=>void I(t,e)})))},L=()=>{if(!C)return;let n=C.repoRoot,r={id:C.nextId,title:``,status:`open`,created:new Date().toISOString().slice(0,10),body:``};W.set((0,V.jsx)(yz,{model:e,issue:r,mode:`create`,engines:s,defaultEngine:c,onOutcome:i=>{i.kind===`create`&&(async()=>{try{let t=await e.client.request(`issue.create`,{repo:n,title:i.title,body:i.body});if(a(),!i.start)return;let o=t.issues.find(e=>e.id===r.id)??t.issues.reduce((e,t)=>e&&e.id>t.id?e:t,null);o&&await F(n,o,i.start)}catch(e){G(lL(t.createFailed,{error:dL(e)}),`error`)}})()}}))},ne=()=>{let n=C?.issues.find(e=>e.id===p);if(!C||!n)return;let i=C.repoRoot;W.set((0,V.jsx)(sr,{title:lL(t.confirmDelete.title,{id:String(n.id)}),body:lL(t.confirmDelete.body,{title:n.title}),confirmLabel:r.confirm,onConfirm:async()=>{try{await e.client.request(`issue.delete`,{repo:i,id:n.id}),m(null)}catch(e){G(lL(t.deleteFailed,{id:String(n.id),error:dL(e)}),`error`)}finally{a()}}}))},re=e=>{b.length!==0&&(f(b[(S+e+b.length)%b.length]?.repoRoot??null),m(null))},ie=e=>{let t=xR(k,p,e);t!=null&&m(t)},R=e=>k.some(e=>e.issues.length>0)?ie(e):re(e===`left`?-1:1);yL(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`r`:return a(),!0;case`Tab`:return re(e.shiftKey?-1:1),!0;case`ArrowUp`:return ie(`up`),!0;case`ArrowDown`:return ie(`down`),!0;case`ArrowRight`:case`l`:return R(`right`),!0;case`ArrowLeft`:case`h`:return R(`left`),!0;case`Enter`:{let e=C?.issues.find(e=>e.id===p);return e&&te(e),!0}case`n`:return L(),!0;case`d`:return ne(),!0;default:return!1}});let ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{ae.current?.querySelector(`[data-issue="${p}"]`)?.scrollIntoView({block:`nearest`})},[p]);let oe=(e,n,r)=>{m(e.id),nn.set({x:n,y:r,items:_z.filter(t=>t!==e.status).map(n=>({label:lL(t.menu.setStatus,{status:t.detail.status[n]}),run:()=>void N(e,n)}))})},se=k.find(e=>e.issues.some(e=>e.id===p))??k.find(e=>e.issues.length>0)??k[0],ce=(e,n)=>(0,V.jsxs)(`section`,{className:JR(!n),children:[n&&(0,V.jsxs)(`h2`,{className:YR(e.key),children:[(0,V.jsxs)(`span`,{children:[j[e.key],` (`,e.issues.length+e.hiddenCount,`)`]}),e.key===`in_progress`&&A>0&&(0,V.jsx)(`span`,{className:`text-warning`,children:lL(t.attention,{count:String(A)})})]}),(0,V.jsxs)(`div`,{className:XR,children:[e.issues.map(t=>(0,V.jsx)(Cz,{issue:t,column:e.key,selected:t.id===p,badge:ee(t,e.key),onSelect:()=>m(t.id),onOpen:()=>te(t),onMenu:(e,n)=>oe(t,e,n)},t.id)),e.issues.length===0&&e.hiddenCount===0&&(0,V.jsx)(`p`,{className:`mono text-muted ${ZR}`,children:t.columnEmpty}),e.hiddenCount>0&&(0,V.jsx)(`p`,{className:`mono text-muted ${ZR}`,children:lL(t.more,{count:String(e.hiddenCount)})})]})]},e.key);return(0,V.jsxs)(`div`,{className:`${oM} ${RR}`,tabIndex:0,ref:h,children:[(0,V.jsxs)(`div`,{className:`kb-top`,children:[(0,V.jsx)(`h1`,{className:cM,children:t.title}),(0,V.jsx)(`span`,{className:`mono keys-only text-muted`,children:t.hint}),(0,V.jsxs)(`span`,{className:`mono ${dM}`,children:[(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.kanban}`,disabled:!C,onClick:L,children:z(`pages.new`)}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.kanban}`,disabled:!C?.issues.some(e=>e.id===p),onClick:ne,children:z(`pages.delete`)})]})]}),o===null?(0,V.jsx)(`p`,{className:`text-muted`,children:t.loading}):C?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:zR,children:[(0,V.jsxs)(`button`,{type:`button`,className:BR,onClick:()=>re(1),children:[pL(C.repoRoot,w),b.length>1&&(0,V.jsx)(`span`,{className:`text-muted`,children:` ${S+1}/${b.length}`})]}),!_&&(0,V.jsx)(`span`,{className:`mono text-muted ${VR}`,children:C.repoRoot}),C.issues.length===0&&!C.readError&&(0,V.jsx)(`span`,{className:`text-muted ${HR}`,children:t.empty})]}),C.readError?(0,V.jsx)(`p`,{className:`text-error`,children:lL(t.readFailed,{error:C.readError})}):_&&se?(0,V.jsxs)(`div`,{className:WR,ref:ae,children:[(0,V.jsx)(`div`,{className:`mono ${GR}`,children:k.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:KR(e.key===se.key),onClick:()=>{let t=e.issues[0];t&&m(t.id)},children:[j[e.key],` (`,e.issues.length+e.hiddenCount,`)`]},e.key))}),ce(se,!1)]}):(0,V.jsx)(`div`,{className:UR,ref:ae,children:k.map(e=>ce(e,!0))})]}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.noRepos})]})}var Dz={title:`Mods`,empty:`No mod is drawing anything.`,emptyHint:`A plugin with a [mod] entry draws its panes here, in the TUI and the web alike.`,keys:`↑↓/tab move · enter press · esc back`,pressFailed:`{plugin}: the press did not reach the mod ({reason})`},Oz={title:`Mods`,empty:`当前没有 mod 在绘制内容。`,emptyHint:`声明了 [mod] 的插件会在这里绘制面板,TUI 和 web 显示的是同一份。`,keys:`↑↓/tab 移动 · enter 按下 · esc 返回`,pressFailed:`{plugin}:按键没有送达 mod({reason})`},kz={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-error`,muted:`text-muted`},Az=`flex flex-col gap-3`,jz=`[&_p]:mx-0 [&_p]:my-1`,Mz=`rounded-md border-hairline border-line px-3 pt-2 pb-3 font-mono`,Nz=`mb-2 text-meta leading-[inherit] text-ink`,Pz=(e,t)=>`flex min-w-0 items-start ${e?`[&>form]:flex-[1_1_12em] [&>form]:self-center`:``} ${t?`rounded-sm border-hairline border-line`:``}`,Fz=(e,t)=>`whitespace-pre-wrap wrap-anywhere ${e?kz[e]:`text-ink`} ${t?`font-bold`:``}`,Iz=(e,t)=>`cursor-pointer rounded-sm border-hairline border-current px-2.5 py-0.5 [font:inherit] font-bold! ${kz[e]} ${t?`bg-[color-mix(in_srgb,currentcolor_18%,transparent)]`:`bg-transparent [&:hover]:bg-[color-mix(in_srgb,currentcolor_18%,transparent)]`}`,Lz=`flex min-w-0 max-w-[40em] self-stretch`,Rz=`w-full font-mono`,zz=[0,6,12,20];function Bz(e){return`mod-${e.kind}:${e.plugin}/${e.pane}/${e.key}`}function Vz(e){let[t,n]=(0,g.useState)(e.value??``);return(0,V.jsx)(`form`,{className:Lz,onSubmit:r=>{r.preventDefault(),e.onSubmit(t),n(e.value??``)},children:(0,V.jsx)(`input`,{id:e.id,className:`${Qt} ${Rz}`,spellCheck:!1,value:t,placeholder:e.placeholder,onFocus:e.onFocus,onChange:e=>n(e.target.value)})})}function Hz(e){let{node:t}=e;if(t.type===`text`)return(0,V.jsx)(`span`,{className:Fz(t.tone,t.bold===!0),children:t.text});if(t.type===`input`){let n={kind:`input`,plugin:e.pane.plugin,pane:e.pane.id,key:t.key};return(0,V.jsx)(Vz,{id:Bz(n),placeholder:t.placeholder,value:t.value,onFocus:()=>e.onFocus(n),onSubmit:t=>e.onSubmit(n,t)},t.value??``)}if(t.type===`button`){let n={kind:`button`,plugin:e.pane.plugin,pane:e.pane.id,key:t.key};return(0,V.jsx)(`button`,{type:`button`,id:Bz(n),className:Iz(t.tone??`info`,Ci(n,e.cursor)),onFocus:()=>e.onFocus(n),onClick:()=>e.onPress(n),children:t.label})}return(0,V.jsx)(`div`,{className:Pz(t.direction===`row`,t.border===!0),style:{flexDirection:t.direction??`column`,gap:zz[t.gap??0],padding:zz[t.padding??0]},children:t.children.map((t,n)=>(0,V.jsx)(Hz,{...e,node:t},n))})}function Uz({model:e}){let t=B()===`zh`?Oz:Dz,n=v(e.mods),r=Si(n),[i,a]=(0,g.useState)(null),o=wi(r,i),s=bL(),c=(0,g.useRef)(!1),l=(t,n,r={})=>{a(t),!c.current&&(c.current=!0,e.client.request(n,{plugin:t.plugin,pane:t.pane,key:t.key,...r}).catch(e=>G(e instanceof Error?e.message:String(e),`error`)).finally(()=>{c.current=!1}))},u=e=>l(e,`mod.press`),d=(e,t)=>l(e,`mod.submit`,{value:t}),f=e=>{let t=Ti(r,o,e);a(t),t&&document.getElementById(Bz(t))?.focus()};return yL(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`ArrowDown`:return f(1),!0;case`ArrowUp`:return f(-1),!0;case`Enter`:return e.target instanceof HTMLButtonElement?!1:(o?.kind===`button`&&u(o),!0);default:return!1}}),(0,V.jsxs)(`div`,{className:`${sM} ${Az}`,tabIndex:0,ref:s,children:[(0,V.jsxs)(`div`,{className:lM,children:[(0,V.jsx)(`h1`,{className:cM,children:t.title}),(0,V.jsx)(`span`,{className:`keys-only touch:empty:hidden! text-muted ${uM(!1)}`,children:t.keys})]}),n.length===0?(0,V.jsxs)(`div`,{className:jz,children:[(0,V.jsx)(`p`,{children:t.empty}),(0,V.jsx)(`p`,{className:`text-muted`,children:t.emptyHint})]}):n.map(e=>(0,V.jsxs)(`section`,{className:Mz,children:[(0,V.jsxs)(`header`,{className:Nz,children:[e.title,` `,(0,V.jsx)(`span`,{className:`text-muted`,children:e.plugin})]}),(0,V.jsx)(Hz,{node:e.tree,pane:e,cursor:o,onPress:u,onSubmit:d,onFocus:a})]},`${e.plugin}/${e.id}`))]})}function Wz(e){return e===`dispatch_failed`||e===`skipped_unavailable`||e===`script_failed`}function Gz(e,t){return e.response?`responded`:e.status!==`dispatched`&&e.status!==`revived`?null:e.deliveryStatus===`missing`?`missing`:e.deliveryStatus===`awaiting`?`awaiting`:t-Date.parse(e.at)>72e5?`missing`:`awaiting`}var Kz=6e4,qz=3294,Jz=new Map([[`JAN`,1],[`FEB`,2],[`MAR`,3],[`APR`,4],[`MAY`,5],[`JUN`,6],[`JUL`,7],[`AUG`,8],[`SEP`,9],[`OCT`,10],[`NOV`,11],[`DEC`,12]]),Yz=new Map([[`SUN`,0],[`MON`,1],[`TUE`,2],[`WED`,3],[`THU`,4],[`FRI`,5],[`SAT`,6]]),Xz=256;function Zz(e,t,n){let r=e.toUpperCase(),i=t?.get(r);if(i!==void 0)return i;if(!/^\d+$/.test(r))throw Error(`invalid cron ${n}: ${e}`);return Number(r)}function Qz(e){let t=new Set;for(let n of e.value.split(`,`)){if(n.length===0)throw Error(`invalid cron ${e.field}: ${e.value}`);let[r,i,...a]=n.split(`/`);if(a.length>0||r===void 0)throw Error(`invalid cron ${e.field}: ${n}`);let o=1;if(i!==void 0&&(!/^\d+$/.test(i)||(o=Number(i),o<1)))throw Error(`invalid cron ${e.field} step: ${n}`);let s,c;if(r===`*`)s=e.min,c=e.max;else if(r.includes(`-`)){let[t,i,...a]=r.split(`-`);if(a.length>0||t===void 0||i===void 0)throw Error(`invalid cron ${e.field} range: ${n}`);s=Zz(t,e.names,e.field),c=Zz(i,e.names,e.field)}else s=Zz(r,e.names,e.field),c=i===void 0?s:e.max;if(s<e.min||c>e.max||s>c)throw Error(`cron ${e.field} out of range: ${n}`);for(let n=s;n<=c;n+=o)t.add(e.normalize?e.normalize(n):n)}return t}function $z(e){if(e.length>Xz)throw Error(`cron expression is too long`);let t=e.trim().split(/\s+/).filter(Boolean);if(t.length!==5)throw Error(`cron expression needs 5 fields (minute hour day month weekday), got ${t.length}`);let[n,r,i,a,o]=t;return{minutes:Qz({value:n,min:0,max:59,field:`minute`}),hours:Qz({value:r,min:0,max:23,field:`hour`}),daysOfMonth:Qz({value:i,min:1,max:31,field:`day-of-month`}),months:Qz({value:a,min:1,max:12,field:`month`,names:Jz}),daysOfWeek:Qz({value:o,min:0,max:7,field:`weekday`,names:Yz,normalize:e=>e%7}),dayOfMonthRestricted:!i.startsWith(`*`),dayOfWeekRestricted:!o.startsWith(`*`)}}function eB(e){try{return $z(e),!0}catch{return!1}}function tB(e,t,n){return new Date(e.year,e.month-1,e.day,t,n,0,0).getTime()}function nB(e){let t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}}function rB(e,t){return nB(new Date(e.year,e.month-1,e.day+t,12,0,0,0).getTime())}function iB(e,t){if(!e.months.has(t.month))return!1;let n=e.daysOfMonth.has(t.day),r=e.daysOfWeek.has(new Date(t.year,t.month-1,t.day).getDay());return e.dayOfMonthRestricted&&e.dayOfWeekRestricted?n||r:n&&r}function aB(e){return e-e%Kz}function oB(e,t){return[...e].sort((e,n)=>(e-n)*t)}function sB(e,t){let n=$z(e),r=oB(n.hours,1),i=oB(n.minutes,1),a=new Date(aB(t)+Kz),o=nB(a.getTime()),s=a.getHours(),c=a.getMinutes();for(let e=0;e<qz;e++){if(iB(n,o)){for(let e of r)if(!(e<s))for(let n of i){if(e===s&&n<c)continue;let r=tB(o,e,n);if(r>t)return r}}o=rB(o,1),s=0,c=0}throw Error(`cron expression never matches: ${e}`)}var cB=[`minute`,`hour`,`dayOfMonth`,`month`,`dayOfWeek`];function lB(e){let t=e.trim().split(/\s+/).filter(Boolean);return cB.map((e,n)=>t[n]??`*`)}function uB(e){return cB.map((t,n)=>e[n]??`*`).join(` `)}var dB=[`*`,`*/5`,`*/10`,`*/15`,`*/30`,..._B(0,59)],fB=[`*`,`*/2`,`*/3`,`*/4`,`*/6`,`*/12`,..._B(0,23)],pB=[`*`,..._B(1,31)],mB=[`*`,`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`],hB=[`*`,`MON-FRI`,`SAT,SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`,`SUN`],gB=[`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`,`SUN`];function _B(e,t){let n=[];for(let r=e;r<=t;r++)n.push(String(r));return n}var vB={minute:dB,hour:fB,dayOfMonth:pB,month:mB,dayOfWeek:hB};function yB(e,t,n){let r=vB[e],i=r.indexOf(t.trim().toUpperCase());return i<0?(n>0?r[0]:r[r.length-1])??t:r[(i+n+r.length)%r.length]??t}function bB(e,t){return Math.min(Math.max(e+t,0),cB.length-1)}function xB(e,t,n){let r=lB(e);return t<0||t>=cB.length||(r[t]=n),uB(r)}function SB(e,t){let[n,r,i,a,o]=lB(e);if(a!==`*`||i!==`*`||n===void 0||r===void 0||o===void 0)return null;let s=CB(n,r,t);if(!s)return null;let{at:c,bare:l}=s;if(o===`*`)return l?c:t(`automations.schedule.everyDay`,{at:c});if(o===`MON-FRI`)return t(`automations.schedule.weekdays`,{at:c});if(o===`SAT,SUN`)return t(`automations.schedule.weekends`,{at:c});let u=gB.find(e=>e===o.toUpperCase());return u?t(`automations.schedule.onWeekday`,{weekday:t(`automations.schedule.dow.${u}`),at:c}):null}function CB(e,t,n){return t===`*`?e===`*`?{at:n(`automations.schedule.everyMinute`),bare:!0}:e.startsWith(`*/`)?{at:n(`automations.schedule.everyMinutes`,{n:e.slice(2)}),bare:!0}:/^\d+$/.test(e)?{at:n(`automations.schedule.hourlyAt`,{minute:e.padStart(2,`0`)}),bare:!1}:null:t.startsWith(`*/`)&&e===`0`?{at:n(`automations.schedule.everyHours`,{n:t.slice(2)}),bare:!0}:/^\d+$/.test(t)&&/^\d+$/.test(e)?{at:n(`automations.schedule.atClock`,{time:`${t.padStart(2,`0`)}:${e.padStart(2,`0`)}`}),bare:!1}:null}function wB(e,t,n,r){let i=e.trim();if(!eB(i))return{kind:`invalid`};let a;try{a=sB(i,t)}catch{return{kind:`never`}}return{kind:`ok`,nextRunMs:a,relative:TB(a-t,n),absolute:EB(a,t,n,r)}}function TB(e,t){let{minutes:n,hours:r,days:i}=oR(e);return n<60?t(`automations.when.inMinutes`,{n:Math.max(1,n)}):r<24?t(`automations.when.inHours`,{n:r}):t(`automations.when.inDays`,{n:i})}function EB(e,t,n,r){let i=new Date(e),a=`${String(i.getHours()).padStart(2,`0`)}:${String(i.getMinutes()).padStart(2,`0`)}`,o=new Date(t);if(i.getFullYear()===o.getFullYear()&&i.getMonth()===o.getMonth()&&i.getDate()===o.getDate())return a;let s=e-t<5184e5,c=i.toLocaleDateString(r,s?{weekday:`short`}:{weekday:`short`,month:`short`,day:`numeric`});return s?`${c} ${a}`:n(`automations.when.dateTime`,{date:c,time:a})}var DB={name:``,repo:``,prompt:``,schedule:`0 9 * * MON-FRI`};function OB(e){return e.name.trim().length>0&&(e.repo===null||e.repo.trim().length>0)&&e.prompt.trim().length>0&&(!e.target||e.target.taskId.trim().length>0&&/^tab-[\w-]+$/.test(e.target.tabId))&&eB(e.schedule.trim())}function kB(e){return e.name.trim().length===0?`name`:e.repo!==null&&e.repo.trim().length===0?`repo`:e.target&&!e.target.taskId.trim()?`target`:e.target&&!/^tab-[\w-]+$/.test(e.target.tabId)?`targetTab`:e.prompt.trim().length===0?`prompt`:eB(e.schedule.trim())?null:`schedule`}var AB=`flex flex-col overflow-hidden @container`,jB=`mt-2.5 grid min-h-0 flex-1 grid-cols-[minmax(260px,2fr)_minmax(0,3fr)] gap-4 rt-narrow:flex rt-narrow:flex-col rt-narrow:overflow-y-auto`,MB=`flex min-h-0 flex-col gap-3 overflow-y-auto scrollbar-none rt-narrow:shrink-0 rt-narrow:overflow-visible`,NB=`flex gap-1.5 px-2 pt-0 pb-1`,PB=e=>`flex min-w-0 cursor-pointer flex-col gap-0.5 rounded-sm px-2 py-1.5 ${e?`bg-menu`:`[&:hover]:bg-hover`}`,FB=`flex min-w-0 items-baseline gap-2.5`,IB=e=>`min-w-0 flex-1 truncate font-bold ${e?`text-muted`:``}`,LB=`whitespace-nowrap text-meta`,RB=`truncate text-meta`,zB=`flex min-h-0 flex-col gap-1.5 overflow-y-auto py-0 pr-0 pl-4 [border-left:var(--hairline)_solid_var(--line)] [&_h2]:m-0 [&_p]:m-0 [&>*]:shrink-0 [&>h2]:mt-2.5 rt-narrow:shrink-0 rt-narrow:overflow-visible rt-narrow:pt-3 rt-narrow:pl-0 rt-narrow:[border-left:none] rt-narrow:[border-top:var(--hairline)_solid_var(--line)]`,BB=`flex flex-wrap items-baseline justify-between gap-3`,VB=`font-sans text-display font-bold normal-nums wrap-anywhere`,HB=`mx-0 mt-1 mb-0 grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-3.5 gap-y-1 [&_dd]:m-0 [&_dd]:wrap-anywhere [&_dd_.mono]:whitespace-pre`,UB=`max-h-[12lh] overflow-y-auto rounded-sm bg-inset px-2.5 py-2 whitespace-pre-wrap wrap-anywhere`,WB=`min-w-0 text-meta leading-[inherit]`,GB=`flex w-full min-w-0 gap-2 text-inherit`,KB=GB,qB=`${GB} cursor-pointer border-none bg-transparent p-0 text-left font-[inherit] [&:hover]:underline`,JB=`min-w-0 flex-1 truncate`,YB=`[&+&]:mt-1.5`,XB=e=>`whitespace-pre-wrap wrap-anywhere text-meta ${e?``:`leading-[inherit]`}`,ZB=`text-meta`,QB=`flex gap-4.5`,$B=e=>`flex min-w-[5ch] flex-col gap-0.5 rounded-sm border-hairline px-1.5 py-1 text-left font-mono text-body normal-nums [&>span]:text-meta [&>span]:text-subtle ${e?`border-accent font-bold text-accent`:`border-transparent font-normal`}`,eV=`hidden gap-2 px-1 pt-0.5 pb-1.5 touch:flex`,tV=`h-8 w-11 touch-manipulation rounded-sm border-hairline border-line bg-inset font-mono text-display font-normal normal-nums text-ink`;function nV(e){let{auto:t,common:n}=cL(),r=uL(),i=B()===`zh`?`zh-CN`:`en-US`,[a,o]=(0,g.useState)(()=>({...DB,repo:e.repos.find(t=>e.defaultRepo&&fL(t)===fL(e.defaultRepo))??e.repos[0]??null})),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(null),d=(0,g.useRef)({}),f=e=>t=>{d.current[e]=t};(0,g.useEffect)(()=>d.current.name?.focus(),[]);let p=e=>{o(t=>({...t,...e})),u(null)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),yn())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]);let m=()=>{if(OB(a)){yn(),e.onSubmit({name:a.name.trim(),repo:a.repo===null?null:a.repo.trim(),prompt:a.prompt.trim(),schedule:a.schedule.trim(),...a.target?{target:a.target}:{}});return}let n=kB(a);n&&(d.current[n]?.focus(),u(Reflect.get(t.missing,n)))},h=a.repo===null?[]:e.tasks.filter(e=>fL(e.repo)===fL(a.repo??``)),_=a.target?h.findIndex(e=>e.id===a.target?.taskId)+1:0,v=e=>{let t=(_+e+h.length+1)%(h.length+1),n=h[t-1];p({target:n?{kind:`existing-tab`,taskId:n.id,tabId:`tab-1`}:void 0})},y=[null,...e.repos],b=e=>{let t=Math.min(Math.max(y.indexOf(a.repo)+e,0),y.length-1),n=y[t];n!==void 0&&p({repo:n,target:void 0})},x=e=>t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),e(t.key===`ArrowDown`?1:-1))},S=e=>t=>{t.key===`Enter`&&(t.preventDefault(),d.current[e]?.focus())},C=lB(a.schedule),w=e=>{let t=cB[s];t&&p({schedule:xB(a.schedule,s,yB(t,C[s]??`*`,e))})},T=e=>{if(!(e.ctrlKey||e.metaKey||e.altKey)){if(e.key===`ArrowLeft`||e.key===`h`)c(bB(s,-1));else if(e.key===`ArrowRight`||e.key===`l`)c(bB(s,1));else if(e.key===`ArrowUp`||e.key===`ArrowDown`)w(e.key===`ArrowUp`?1:-1);else return;e.preventDefault()}},E=wB(a.schedule,Date.now(),r,i),D=SB(a.schedule,r);return(0,V.jsx)(`div`,{className:kn,onMouseDown:e=>e.target===e.currentTarget&&yn(),children:(0,V.jsxs)(`dialog`,{open:!0,className:`${An(!0)} ${rz}`,"aria-label":t.newTitle,children:[(0,V.jsx)(`h1`,{className:`${U} text-muted`,children:t.newTitle}),(0,V.jsxs)(`div`,{className:Pn,children:[(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.fieldName}),(0,V.jsx)(`input`,{ref:f(`name`),className:Qt,spellCheck:!1,placeholder:t.namePlaceholder,value:a.name,onChange:e=>p({name:e.target.value}),onKeyDown:S(`repo`)})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.fieldRepo,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`↑/↓`})]}),(0,V.jsx)(gz,{fieldRef:f(`repo`),kind:`list`,label:t.fieldRepo,className:cz,onKeyDown:x(b),children:y.map(t=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-selected":t===a.repo,className:`touch:py-1.5 ${lz(t===a.repo)}`,onClick:()=>{p({repo:t,target:void 0}),d.current.repo?.focus()},children:[t===a.repo?`▸ `:` `,t===null?z(`rail.noProject`):pL(t,e.repos)]},t??``))})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.fieldTarget,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`↑/↓`})]}),(0,V.jsx)(gz,{fieldRef:f(`target`),kind:`list`,label:t.fieldTarget,onKeyDown:x(v),onClick:()=>v(1),children:a.target?h[_-1]?.title??a.target.taskId:t.targetFresh})]}),a.target&&(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:t.fieldTargetTab}),(0,V.jsx)(`input`,{ref:f(`targetTab`),className:Qt,spellCheck:!1,value:a.target.tabId,onChange:e=>a.target&&p({target:{...a.target,tabId:e.target.value}}),onKeyDown:S(`prompt`)})]}),(0,V.jsxs)(`label`,{className:wn,children:[(0,V.jsx)(`span`,{className:`${U} text-muted`,children:t.fieldPrompt}),(0,V.jsx)(`input`,{ref:f(`prompt`),className:Qt,spellCheck:!1,placeholder:t.promptPlaceholder,value:a.prompt,onChange:e=>p({prompt:e.target.value}),onKeyDown:S(`schedule`)})]}),(0,V.jsxs)(`div`,{className:wn,children:[(0,V.jsxs)(`span`,{className:`${U} text-muted ${az}`,children:[t.fieldSchedule,(0,V.jsx)(`span`,{className:`keys-only text-muted ${oz}`,children:`←/→ ↑/↓`})]}),(0,V.jsx)(gz,{fieldRef:f(`schedule`),kind:`cells`,label:t.fieldSchedule,className:QB,onKeyDown:T,children:cB.map((e,n)=>(0,V.jsxs)(`button`,{type:`button`,tabIndex:-1,className:$B(n===s),onClick:()=>{c(n),d.current.schedule?.focus()},children:[C[n]??`*`,(0,V.jsx)(`span`,{children:t.cronField[e]})]},e))}),(0,V.jsx)(`div`,{className:eV,children:[-1,1].map(e=>{let n=t.cronField[cB[s]??`minute`]??``;return(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,className:tV,"aria-label":z(e<0?`pages.cronDown`:`pages.cronUp`,{field:n}),onClick:()=>{w(e),d.current.schedule?.focus()},children:e<0?`−`:`+`},e)})}),E.kind===`ok`?(0,V.jsxs)(`p`,{className:`mono text-success`,children:[D?`${D}, `:``,E.relative,`, `,E.absolute]}):(0,V.jsx)(`p`,{className:`mono text-error`,children:E.kind===`never`?t.cronNever:t.cronInvalid})]}),l&&(0,V.jsxs)(`p`,{className:`text-error`,children:[`※ `,l]}),(0,V.jsx)(`p`,{className:`touch:empty:hidden! text-muted ${uz}`,children:(0,V.jsx)(ST,{text:Yo(t.composerLegend)})}),(0,V.jsxs)(`div`,{className:$t,children:[(0,V.jsx)(`button`,{type:`button`,className:Xt,onClick:yn,children:n.cancel}),(0,V.jsx)(`button`,{ref:f(`confirm`),type:`button`,className:je(),onClick:m,children:n.create})]})]})]})})}var rV=[`ok`,`blocked`,`failed`,`skipped`];function iV(e){switch(e.status){case`dispatched`:case`revived`:case`ran`:return`ok`;case`skipped_blocked`:return`blocked`;case`dispatch_failed`:case`skipped_unavailable`:case`script_failed`:return`failed`;default:return`skipped`}}var aV={scheduled:`schedule`,manual:`manual`,webhook:`webhook`};function oV(e){if(e.status===`skipped_precheck`)return e.precheckResult?.durationMs??null;if(e.status===`ran`||e.status===`script_failed`)return null;let t=Date.parse(e.at),n=Date.parse(e.response?.at??``);return Number.isFinite(t)&&Number.isFinite(n)&&n>=t?n-t:null}function sV(e){if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return n%60==0?`${r}h`:`${r}h ${n%60}m`}function cV(e,t,n){return(t===null?Object.values(e).flat():e[t]??[]).filter(e=>n===null||iV(e)===n).sort((e,t)=>Date.parse(t.at)-Date.parse(e.at)||t.runNumber-e.runNumber)}function lV(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`);if(t<0||n<=t)return null;try{return{prefix:e.slice(0,t).trim(),value:JSON.parse(e.slice(t,n+1))}}catch{return null}}var uV=(e,t)=>e&&typeof e==`object`?Reflect.get(e,t):void 0;function dV(e){let t=lV(e);if(!t)return{summary:e,full:e};let n=uV(t.value,`error`)??t.value,r=uV(n,`message`),i=uV(n,`code`),a=typeof r==`string`?typeof i==`string`?`${i}: ${r}`:r:null,o=t.prefix.replace(/:$/,``);return{summary:a?`${o} — ${a}`:e,full:`${t.prefix}\n${JSON.stringify(t.value,null,2)}`}}function fV(e){let t=e.trim();if(!/^[[{]/.test(t))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}var pV={dispatched:`success`,revived:`success`,skipped_precheck:`muted`,skipped_blocked:`warning`,skipped_cancelled:`muted`,skipped_missed:`warning`,skipped_unavailable:`warning`,dispatch_failed:`error`,ran:`success`,script_failed:`error`},mV={success:`text-success`,muted:`text-muted`,warning:`text-warning`,error:`text-error`},hV={success:`✓`,error:`†`,warning:`!`,muted:`·`},gV=e=>pV[e]??`muted`;function _V(e){let{auto:t}=cL(),{runs:n,when:r}=e,i=e=>t.runStatus[e]??e,a=n.filter(e=>e.response);return(0,V.jsxs)(V.Fragment,{children:[n[0]?.precheckResult&&(0,V.jsx)(vV,{run:n[0]}),(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:t.responses}),a.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.noResponses}):a.map(e=>(0,V.jsxs)(`div`,{className:YB,children:[(0,V.jsx)(`p`,{className:`mono ${ZB} ${mV[gV(e.status)]}`,children:`#${e.runNumber} ${i(e.status)}, ${r(e.response?.at)}`}),(0,V.jsx)(`p`,{className:XB(!1),children:fV(e.response?.text??``)})]},e.id))]})}function vV({run:e}){let{auto:t}=cL(),n=e.precheckResult;if(!n)return null;let r=n.timedOut?t.precheckTimedOut:lL(t.precheckExited,{code:String(n.exitCode??`?`)}),i=[{label:t.precheckStdout,text:n.stdout},{label:t.precheckStderr,text:n.stderr}].filter(e=>e.text.trim().length>0);return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:lL(t.precheckDetail,{exit:r,duration:String(n.durationMs)})}),i.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.precheckNoOutput}):i.map(e=>(0,V.jsx)(`p`,{className:`mono ${XB(!0)}`,children:`${e.label}: ${e.text.replace(/\s+$/,``).split(`
126
126
  `).slice(-10).join(`
127
- `)}`},e.label))]})}var _V=30;function vV(e,t,n){let r=t.join(`\0`),[i,a]=(0,g.useState)(()=>Object.fromEntries(t.map(t=>[t,Ns(e,`routine.runs`,{id:t})?.runs??[]])));return(0,g.useEffect)(()=>{let n=!0;for(let r of t)Fs(e,`routine.runs`,{id:r}).then(e=>n&&a(t=>({...t,[r]:e.runs}))).catch(()=>void 0);return()=>{n=!1}},[e,r,n]),i}function yV(e){B();let{auto:t}=oL(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null);(0,g.useEffect)(()=>r(null),[e.followId]);let o=n===null?e.followId??``:n,s=o===``?e.routines.map(e=>e.id):[o],c=vV(e.c,s,e.tick),l=new Map(e.routines.map(e=>[e.id,e.name])),u=oV(c,o===``?null:o,i),d=e=>{if(e.status===`skipped_blocked`){let t=e.blocked?.reason;return t?sL(z(`runLog.blockedRun`),{reason:z(`runLog.blocked.${t}`)}):z(`runLog.outcome.blocked`)}return t.runStatus[e.status]??e.status},f=(e,t,n,r)=>(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":t,className:`max-w-40 truncate`,onClick:n,children:`[ ${e} ]`},r);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`runLog.title`)}),e.routines.length>1&&(0,V.jsx)(pA,{label:z(`runLog.routine`),value:o,picks:[{value:``,label:z(`runLog.allRoutines`)},...e.routines.map(e=>({value:e.id,label:e.name}))],onPick:r}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[f(z(`runLog.all`),i===null,()=>a(null),`all`),tV.map(e=>f(z(`runLog.outcome.${e}`),i===e,()=>a(e),e))]}),u.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:oV(c,o===``?null:o,null).length===0?t.noRuns:z(`runLog.empty`)}):u.slice(0,_V).map(n=>{let r=mV(n.status),i=Uz(n,e.now),a=i===`awaiting`?`, ${t.responseAwaiting}`:i===`missing`?`, ${t.responseMissing}`:``,s=iV(n),c=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:pV[r]}),(0,V.jsx)(`span`,{children:`#${n.runNumber}`}),o===``&&(0,V.jsx)(`span`,{className:`max-w-[20ch] truncate`,children:l.get(n.automationId)??``}),(0,V.jsx)(`span`,{className:KB,children:`${d(n)}${n.tabId?`, ${n.tabId}`:``}${a}`}),(0,V.jsx)(`span`,{className:`text-subtle`,children:z(`runLog.source.${rV[n.trigger]}`)}),s!==null&&(0,V.jsx)(`span`,{className:`text-muted`,children:aV(s)}),(0,V.jsx)(`span`,{className:`text-muted`,children:e.when(n.at)})]}),u=n.error?lV(n.error):null,f=n.taskId,p=i===`missing`?`text-warning`:fV[r];return(0,V.jsxs)(`div`,{className:`${HB} ${p}`,children:[f?(0,V.jsx)(`button`,{type:`button`,className:`mono ${GB}`,onClick:()=>e.openRun(f),children:c}):(0,V.jsx)(`span`,{className:`mono ${WB}`,children:c}),u&&(0,V.jsxs)(`details`,{className:`mono pl-[calc(2ch+16px)] [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:truncate [&_summary::-webkit-details-marker]:hidden [&[open]_summary]:whitespace-normal [&_pre]:mx-0 [&_pre]:mt-1 [&_pre]:mb-1.5 [&_pre]:max-h-[16lh] [&_pre]:overflow-auto [&_pre]:rounded-sm [&_pre]:bg-inset [&_pre]:px-2 [&_pre]:py-1.5 [&_pre]:whitespace-pre-wrap [&_pre]:wrap-anywhere [&_pre]:text-muted`,children:[(0,V.jsx)(`summary`,{children:u.summary}),(0,V.jsx)(`pre`,{children:u.full})]})]},n.id)}),u.length>_V&&(0,V.jsx)(`p`,{className:`text-muted`,children:z(`runLog.more`,{count:u.length-_V})})]})}var bV=5e3;function xV({model:e}){let{auto:t,common:n}=oL(),r=e.client,[i,a]=hL(bV),o=v(e.tasks),s=pL(e),c=mL(e),[l,u]=(0,g.useState)(()=>Ns(r,`routine.list`)??null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(null),y=vL(),b=cL(),x=B()===`zh`?`zh-CN`:`en-US`,S=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0;return Fs(r,`routine.list`).then(t=>e&&u(t)).catch(()=>e&&u(e=>e??{automations:[],keepsDaemonAlive:!1})),()=>{e=!1}},[r,i]);let C=l?.automations??[],w=l?.lastRunStatus??{},T=l?.lastFailure??{},E=e=>{let t=w[e.id];return t!==void 0&&Hz(t)},D=[{key:`pages.routinesNeedYou`,rows:C.filter(E)},{key:`pages.routinesActive`,rows:C.filter(e=>e.enabled&&!E(e))},{key:`pages.routinesPaused`,rows:C.filter(e=>!e.enabled&&!E(e))}],O=D.flatMap(e=>e.rows),k=Math.max(0,O.findIndex(e=>e.id===d)),A=O[k],j=e=>f(O[e]?.id??null),ee=D[0]?.rows.length??0,M=v(sn);(0,g.useEffect)(()=>{M===null||!l||(l.automations.some(e=>e.id===M)&&f(M),sn.set(null))},[M,l]);let N=vV(r,A?[A.id]:[],i),P=A?N[A.id]??[]:[];(0,g.useEffect)(()=>_(null),[A?.id]);let F=(0,g.useRef)(null),[I,te]=(0,g.useState)(0),L=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=S.current,t=I!==L.current;if(L.current=I,t&&e&&F.current&&e.offsetTop>F.current.offsetTop){e.scrollIntoView({block:`start`,behavior:`smooth`});return}F.current?.querySelector(`[data-row="${k}"]`)?.scrollIntoView({block:`nearest`})},[k,I]);let ne=Date.now(),re=e=>{let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return`—`;let r=n-ne,i=r>=0,a=Math.floor(Math.abs(r)/6e4),o=Math.floor(a/60);return a<1?i?t.when.now:t.when.justNow:a<60?sL(i?t.when.inMinutes:t.when.minutesAgo,{n:a}):o<24?sL(i?t.when.inHours:t.when.hoursAgo,{n:o}):new Date(n).toLocaleDateString()},ie=e=>o?.tasks.find(t=>t.id===e)?.label??e,R=t=>{on.set(null),e.select(t)},ae=(e,t,n)=>G(sL(e,{name:t,error:lL(n)}),`error`),oe=async()=>{if(!(!A||p)){m(A.id);try{await r.request(`routine.setEnabled`,{id:A.id,enabled:!A.enabled}),a()}catch(e){ae(A.enabled?t.disableFailed:t.enableFailed,A.name,e)}finally{m(null)}}},se=async()=>{if(!(!A||p)){m(A.id),_(sL(t.running,{name:A.name}));try{let e=await r.request(`routine.runNow`,{id:A.id});_(sL(t.ranWith,{name:A.name,status:e.status})),a()}catch(e){ae(t.runFailed,A.name,e)}finally{m(null)}}},ce=async()=>{if(p)return;let e=fL(await r.request(`repos.list`).then(e=>e.repos).catch(()=>[]),s);W.set((0,V.jsx)(eV,{repos:e,tasks:(o?.tasks??[]).filter(e=>!e.deleting).map(e=>({id:e.id,title:e.label,repo:e.repo})),defaultRepo:c,onSubmit:e=>{(async()=>{m(`new`);try{await r.request(`routine.create`,{...e.repo===null?{}:{repo:e.repo},name:e.name,prompt:e.prompt,schedule:e.schedule,...e.target?{targetTask:e.target.taskId,targetTab:e.target.tabId}:{}}),a()}catch(e){G(sL(t.createFailed,{error:lL(e)}),`error`)}finally{m(null)}})()}}))},le=()=>{if(!A||p)return;let e=A;W.set((0,V.jsx)(sr,{title:t.deleteTitle,body:sL(t.deleteBody,{name:e.name}),confirmLabel:t.deleteButton,onConfirm:async()=>{m(e.id);try{await r.request(`routine.delete`,{id:e.id}),a()}catch(n){ae(t.deleteFailed,e.name,n)}finally{m(null)}}}))};_L(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return j(Math.min(O.length-1,k+1)),!0;case`k`:case`ArrowUp`:return j(Math.max(0,k-1)),!0;case`n`:return ce(),!0;case`r`:return a(),!0;case`e`:return oe(),!0;case`s`:return se(),!0;case`d`:return le(),!0;case`Enter`:{let e=P[0]?.taskId;return e?R(e):P.length>0&&_(t.latestRunNoTask),!0}default:return!1}});let ue=A?.target,de=A?bB(A.schedule,b):null,fe=e=>e===void 0?z(`rail.noProject`):dL(e,C.flatMap(e=>e.repo??[])),pe=A?.nextRunAt?Date.parse(A.nextRunAt):NaN;return(0,V.jsxs)(`div`,{className:`${iM} ${OB}`,tabIndex:0,ref:y,children:[(0,V.jsxs)(`div`,{className:sM,children:[(0,V.jsx)(`h1`,{className:oM,children:t.title}),(0,V.jsxs)(`span`,{className:`mono ${lM}`,children:[ee>0&&(0,V.jsx)(`span`,{className:`text-error`,children:sL(t.needAttention,{count:String(ee),total:String(O.length)})}),(0,V.jsx)(`span`,{className:`text-muted`,children:l?.keepsDaemonAlive?t.holdingDaemon:t.notHolding}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.header}`,onClick:()=>void ce(),children:z(`pages.new`)})]})]}),l===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.loading}):O.length===0?(0,V.jsxs)(`div`,{className:dM,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:t.empty}),(0,V.jsx)(`p`,{className:`keys-only`,children:t.emptyHint})]}):(0,V.jsxs)(`div`,{className:kB,children:[(0,V.jsx)(`div`,{className:AB,ref:F,children:D.map(e=>e.rows.length===0?null:(0,V.jsxs)(`section`,{children:[(0,V.jsxs)(`h2`,{className:`${U} ${jB} ${e===D[0]?`text-error`:`text-muted`}`,children:[z(e.key),` `,(0,V.jsx)(`span`,{className:`mono`,children:e.rows.length})]}),e.rows.map(e=>{let n=O.indexOf(e),r=w[e.id],i=r?mV(r):null;return(0,V.jsxs)(`div`,{"data-row":n,className:MB(n===k),onClick:()=>{j(n),te(e=>e+1)},children:[(0,V.jsxs)(`span`,{className:NB,children:[(0,V.jsx)(`span`,{className:PB(!e.enabled),children:e.name}),(0,V.jsx)(`span`,{className:`mono text-muted ${FB}`,children:e.enabled?re(e.nextRunAt):t.paused}),(0,V.jsx)(`span`,{className:`mono ${i?fV[i]:`text-muted`}`,style:{width:`1ch`},children:i?pV[i]:` `})]}),(0,V.jsx)(`span`,{className:`mono text-muted ${IB}`,title:e.schedule,children:`${fe(e.repo)} · ${bB(e.schedule,b)??e.schedule}`}),T[e.id]?(0,V.jsx)(`span`,{className:`mono text-warning ${IB}`,title:T[e.id]?.reason,children:sL(t.lastFailed,{when:re(T[e.id]?.at),reason:T[e.id]?.reason??``})}):null]},e.id)})]},e.key))}),(0,V.jsx)(`div`,{className:LB,ref:S,children:A?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:RB,children:[(0,V.jsx)(`h2`,{className:zB,children:A.name}),(0,V.jsxs)(`span`,{className:`mono ${lM}`,children:[(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.row}`,disabled:p===A.id,onClick:()=>void se(),children:t.runNow}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.row}`,disabled:p===A.id,onClick:()=>void oe(),children:z(A.enabled?`pages.routinePause`:`pages.routineEnable`)}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${uM.row}`,disabled:p===A.id,onClick:le,children:z(`pages.delete`)})]})]}),(0,V.jsxs)(`dl`,{className:BB,children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineSchedule`)}),(0,V.jsxs)(`dd`,{children:[de??(0,V.jsx)(`span`,{className:`mono`,children:A.schedule}),de&&(0,V.jsx)(`span`,{className:`mono text-muted`,children:` ${A.schedule}`})]}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineNext`)}),(0,V.jsx)(`dd`,{className:A.enabled?``:`text-warning`,children:A.enabled?Number.isFinite(pe)?`${re(A.nextRunAt)} · ${new Date(pe).toLocaleString(x,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}`:`—`:t.paused}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineProject`)}),(0,V.jsx)(`dd`,{children:fe(A.repo)}),!A.script&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineDelivers`)}),(0,V.jsx)(`dd`,{children:ue?sL(t.targetExisting,{task:ie(ue.taskId),tab:ue.tabId}):A.persistentSession?t.targetStanding:t.targetFresh})]})]}),A.precheck&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:sL(t.precheck,{command:A.precheck.command})}),A.script?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routineScript`)}),(0,V.jsx)(`p`,{className:`mono ${VB}`,children:A.script.command})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routinePrompt`)}),(0,V.jsx)(`p`,{className:VB,children:A.prompt})]}),(0,V.jsx)(yV,{c:r,tick:i,routines:C,followId:A.id,now:ne,when:re,openRun:R}),(0,V.jsx)(hV,{runs:P,when:re})]}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.noSelection})})]}),h&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:h})]})}var SV=`flex min-w-0 items-baseline gap-2.5 font-mono text-meta whitespace-nowrap`,CV=`${SV} w-full cursor-pointer border-none bg-transparent p-0 text-left text-inherit [font:inherit] [&:hover]:underline`,wV=`w-[5ch] flex-none text-muted`,TV=`w-[16ch] flex-none overflow-hidden text-accent`,EV=`mt-3.5 mb-0.5`,DV=`min-w-0 flex-1 truncate`,OV=`flex-none text-right text-muted`,kV=`${OV} min-w-[5ch]`,AV=`${OV} min-w-[4ch]`,jV=`${OV} min-w-[5ch]`,MV=`w-[8ch] flex-none overflow-hidden text-accent`,NV=`flex flex-wrap gap-x-3 font-mono text-meta text-muted`,PV=`m-0 text-meta text-muted`,FV={turns:0,tokens:0,ms:0},IV=e=>(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0),LV=e=>Math.max(0,e.endedAt-e.startedAt),RV=(e,t)=>({turns:e.turns+1,tokens:e.tokens+IV(t),ms:e.ms+LV(t)});function zV(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function BV(e,t,n,r){let i=[];for(let e=n-1;e>=0;e--){let n=new Date(t);n.setDate(n.getDate()-e),i.push(zV(n.getTime()))}let a=new Map(i.map(e=>[e,{sum:FV,byEngine:{}}]));for(let t of e){let e=a.get(zV(t.startedAt));if(!e)continue;let n=t.vendor??`unknown`;e.sum=RV(e.sum,t),e.byEngine[n]=(e.byEngine[n]??0)+IV(t)}let o=e.reduce((e,t)=>Math.min(e,t.startedAt),1/0),s=e.length>=r&&Number.isFinite(o)?{count:e.length,day:zV(o)}:null;return{cutoff:s,days:i.map(e=>{let t=a.get(e);return{day:e,...t?.sum??FV,byEngine:t?.byEngine??{},partial:s!==null&&e<=s.day}})}}function VV(e){let t=new Map;for(let n of e){let e=n.vendor??`unknown`,r=n.model??`unknown`,i=`${e}\0${r}`;t.set(i,{engine:e,model:r,...RV(t.get(i)??FV,n)})}return[...t.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns)}function HV(e,t){let n=new Map;for(let t of e)n.set(t.taskId,{taskId:t.taskId,...RV(n.get(t.taskId)??FV,t)});return[...n.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns).slice(0,t)}function UV(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4)).replace(/\.0$/,``)}k`:`${(e/1e6).toFixed(+(e<1e7)).replace(/\.0$/,``)}M`}var WV=[``,`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`];function GV(e,t,n){if(e<=0||t<=0)return``;let r=Math.max(1,Math.round(e/t*n*8));return`${`█`.repeat(Math.floor(r/8))}${WV[r%8]}`}var KV=[`█`,`▓`,`▒`,`░`];function qV(e,t,n,r){return n<=0?``:t.map((t,i)=>{let a=e[t]??0,o=a<=0?0:Math.max(1,Math.round(a/n*r));return(KV[i%KV.length]??`█`).repeat(o)}).join(``)}var JV=.1,YV=/^(\d+)\s*(h|d)$/;function XV(e,t){let n=YV.exec(e.label.trim());if(!n||e.resetsAt===null||e.percent<=0)return null;let r=Number(n[1])*(n[2]===`d`?24:1)*36e5,i=r-(e.resetsAt-t);if(!(i>=r*JV)||i>r)return null;if(e.percent>=100)return{kind:`full`,at:t};let a=t+(100-e.percent)/e.percent*i;return a<e.resetsAt?{kind:`full`,at:a}:{kind:`lasts`}}var ZV=14,QV=500,$V=3e4,eH=16,tH=8,nH=8;function rH(e,t,n,r){let i=Ns(e,t,n),[a,o]=(0,g.useState)(i?{kind:`ready`,value:i}:{kind:`loading`}),s=JSON.stringify(n);return(0,g.useEffect)(()=>{let r=!0;return Fs(e,t,n).then(e=>r&&o({kind:`ready`,value:e})).catch(e=>r&&o(t=>t.kind===`ready`?t:{kind:`failed`,error:lL(e)})),()=>{r=!1}},[e,t,s,r]),a}var iH=e=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`${kV}`,children:UV(e.tokens)}),(0,V.jsx)(`span`,{className:`${AV}`,children:`${e.turns}t`}),(0,V.jsx)(`span`,{className:`${jV}`,children:aV(e.ms)})]});function aH({usage:e,nameOf:t}){let n=Date.now(),r=e.flatMap(e=>e.windows.map(r=>{let i={engine:e.name||t(e.vendor),label:r.label,percent:Math.round(r.percent)},a=XV(r,n);if(a?.kind===`full`){let t=a.at-n<72e6,o=new Date(a.at).toLocaleString([],{...t?{}:{weekday:`short`},hour:`2-digit`,minute:`2-digit`});return{key:`${e.vendor}:${r.kind}`,text:sL(z(`usage.full`),{...i,time:o})}}return{key:`${e.vendor}:${r.kind}`,text:sL(z(a?`usage.lasts`:`usage.window`),i)}}));return r.length===0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${EV}`,children:z(`usage.quota`)}),r.map(e=>(0,V.jsx)(`p`,{className:`mono ${PV}`,children:e.text},e.key))]})}function oH({row:e,title:t,open:n}){let r=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:DV,children:t}),iH(e)]});return n?(0,V.jsx)(H,{variant:`row`,className:CV,onClick:n,children:r}):(0,V.jsx)(`div`,{className:SV,children:r})}function sH({model:e}){B();let t=vL(),[n]=hL($V),r=rH(e,`turns.list`,{sinceDays:ZV,limit:QV},n),i=rH(e,`engines.list`,{},n),a=rH(e,`usage.get`,{},n),o=v(e.tasks),s=i.kind===`ready`?i.value.engines:[],c=e=>s.find(t=>t.id===e)?.name??e,l=e=>o?.tasks.find(t=>t.id===e)?.label??z(`usage.removedTask`);return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:t,onKeyDown:e=>{e.metaKey||e.ctrlKey||e.altKey||e.key!==`q`&&e.key!==`Escape`||(e.preventDefault(),on.set(null))},children:[(0,V.jsx)(`h1`,{className:oM,children:z(`usage.title`)}),(()=>{if(r.kind===`loading`)return(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.loading`)});if(r.kind===`failed`)return(0,V.jsx)(`p`,{className:`text-error`,children:sL(z(`usage.failed`),{error:r.error})});let t=r.value.turns,n=new Set(r.value.readers??[]),i=BV(t,Date.now(),ZV,QV),s=new Map;for(let e of i.days)for(let[t,n]of Object.entries(e.byEngine))s.set(t,(s.get(t)??0)+n);let u=[...s].sort((e,t)=>t[1]-e[1]).map(([e])=>e),d=Math.max(0,...i.days.map(e=>e.tokens)),f=VV(t),p=Math.max(0,...f.map(e=>e.tokens)),m=[...new Set((o?.tasks??[]).flatMap(e=>e.engine?.id&&!n.has(e.engine.id)?[e.engine.id]:[]))];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:PV,children:sL(z(`usage.range`),{days:ZV})}),t.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.empty`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${EV}`,children:z(`usage.perDay`)}),(0,V.jsx)(`div`,{className:NV,children:u.map((e,t)=>(0,V.jsx)(`span`,{children:`${KV[t%KV.length]} ${c(e)}`},e))}),i.days.map(e=>(0,V.jsxs)(`div`,{className:SV,children:[(0,V.jsx)(`span`,{className:wV,children:`${e.day.slice(5)}${e.partial?`~`:``}`}),(0,V.jsx)(`span`,{className:TV,children:qV(e.byEngine,u,d,eH)}),iH(e)]},e.day)),i.cutoff&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:sL(z(`usage.cutoff`),{count:i.cutoff.count,day:i.cutoff.day.slice(5)})}),(0,V.jsx)(`h2`,{className:`${U} text-muted ${EV}`,children:z(`usage.byModel`)}),f.map(e=>(0,V.jsxs)(`div`,{className:SV,children:[(0,V.jsx)(`span`,{className:DV,title:`${c(e.engine)} · ${e.model}`,children:`${c(e.engine)} · ${e.model}`}),(0,V.jsx)(`span`,{className:MV,children:GV(e.tokens,p,tH)}),iH(e)]},`${e.engine}\0${e.model}`)),(0,V.jsx)(`h2`,{className:`${U} text-muted ${EV}`,children:z(`usage.topTasks`)}),HV(t,nH).map(t=>(0,V.jsx)(oH,{row:t,title:l(t.taskId),open:o?.tasks.some(e=>e.id===t.taskId)?()=>{on.set(null),e.select(t.taskId)}:null},t.taskId))]}),m.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:sL(z(`usage.noReader`),{engines:m.map(c).join(`, `)})}),a.kind===`ready`&&a.value.usage&&(0,V.jsx)(aH,{usage:a.value.usage,nameOf:c})]})})()]})}var cH={id:`mods`,label:`mods`},lH=[{id:`kanban`,label:`kanban`,mod:`kanban`},{id:`routines`,label:`automations`},{id:`issues`,label:`issues`,mod:`issues`}];function uH({model:e}){let{nav:t}=oL(),n=v(on),r=v(e.mods).length>0,i=v(e.installedMods),a=[...lH.filter(e=>!e.mod||i.has(e.mod)),...r?[cH]:[]];return(0,V.jsxs)(`div`,{className:_M,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${yM(!1)}`,onClick:()=>KD(),children:[z(`rail.newTask`),(0,V.jsx)(`span`,{className:bM,"aria-hidden":`true`,children:`+`})]}),a.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`rail-nav-row ${yM(n===e.id)}`,"aria-current":n===e.id?`page`:void 0,onClick:()=>ha(e.id),children:t[e.label]},e.id))]})}function dH({model:e,page:t}){(0,g.useEffect)(()=>e.selection.subscribe(()=>on.set(null)),[e]);let n=v(e.installedMods);return t===`kanban`&&n.has(`kanban`)?(0,V.jsx)(wz,{model:e}):t===`routines`?(0,V.jsx)(xV,{model:e}):t===`issues`&&n.has(`issues`)?(0,V.jsx)(hR,{model:e}):t===`mods`?(0,V.jsx)(Vz,{model:e}):t===`compare`?(0,V.jsx)(rR,{model:e}):t===`usage`?(0,V.jsx)(sH,{model:e}):null}var fH=p();function pH(e){return e?.match(/^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/(?:pull|merge_requests|-\/merge_requests)\//)?.[1]}var mH=e=>e.charAt(0).toUpperCase()+e.slice(1);function hH(e){return[z(`rail.pr.state.${e.state}`),...e.checks?[z(`rail.pr.checks.${e.checks}`)]:[]].join(`, `)}function gH(e){let t=new Map;for(let n of e){let e=GF(n),r=[...e&&n.pr?[{pr:n.pr,mark:e}]:[],...(n.sessionPrs??[]).flatMap(e=>{let t=KF(e);return t?[{pr:e,mark:t}]:[]})];for(let{pr:e,mark:i}of r){let r=e.url??(e.number===void 0?n.id:`${n.repo}#${e.number}`),a=t.get(r),o=e.lifecycle===`unknown`,s=a?.pr.lifecycle===`unknown`;(!a||s&&!o||o===s&&qF([a.mark,i])!==a.mark)&&t.set(r,{task:n,pr:e,mark:i})}}return[...t.values()]}function _H({tasks:e,onOpen:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=(0,g.useRef)(null),l=Ko();(0,g.useLayoutEffect)(()=>{let e=c.current;if(!e||!n)return;let t=e.getBoundingClientRect();t.right>window.innerWidth-8&&(e.style.left=`${Math.max(8,window.innerWidth-t.width-8)}px`,e.style.top=`${n.bottom+6}px`);let r=e.getBoundingClientRect().bottom-(window.innerHeight-8);r>0&&(e.style.top=`${Math.max(8,e.getBoundingClientRect().top-r)}px`)},[n]);let u=()=>{t?.(),s.current!==null&&window.clearTimeout(s.current),s.current=null,a(!1),o.current&&!n&&r(o.current.getBoundingClientRect())},d=()=>{a(!0),s.current=window.setTimeout(()=>r(null),140)};(0,g.useEffect)(()=>{if(!l||!n)return;let e=e=>{let t=e.target;o.current?.contains(t)||c.current?.contains(t)||(a(!0),s.current=window.setTimeout(()=>r(null),140))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[l,n]),(0,g.useEffect)(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);let f=gH(e),p=qF(f.map(e=>e.mark));if(!p)return null;let m=f.length===1?`PR #${f[0]?.pr.number??``}, ${hH(p)}`:z(`rail.pr.many`,{count:f.length});return(0,V.jsxs)(`span`,{ref:o,className:`chip ${JT} ${p.tone}`,"aria-label":m,onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>{l&&(e.stopPropagation(),n&&!i?d():u())},children:[p.glyph,f.length>1&&(0,V.jsx)(`span`,{className:`font-sans`,children:f.length}),n&&(0,fH.createPortal)((0,V.jsx)(`div`,{ref:c,className:YT(i),style:{top:n.top-6,left:n.right+8},onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onContextMenu:e=>e.stopPropagation(),children:f.map(({task:e,pr:t,mark:n})=>{let r=pH(t?.url),i=t?.additions!==void 0&&t.deletions!==void 0;return(0,V.jsxs)(`button`,{type:`button`,className:`flex flex-col gap-1 rounded-[calc(var(--radius)-6px)] px-3 py-2 text-left font-sans enabled:hover:bg-hover`,disabled:!t?.url,onClick:()=>t?.url&&window.open(t.url,`_blank`,`noopener`),children:[(0,V.jsx)(`span`,{className:`truncate font-semibold text-ink`,children:t.title||e.label}),(0,V.jsxs)(`span`,{className:`flex items-baseline gap-0 text-meta leading-[inherit] whitespace-nowrap`,children:[(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.25 ${n.tone}`,children:[(0,V.jsx)(`span`,{className:`font-mono`,children:n.glyph}),mH(z(`rail.pr.state.${n.state}`))]}),(0,V.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-pre text-muted`,children:[...n.checks?[z(`rail.pr.checks.${n.checks}`)]:[],[r,t?.number===void 0?``:`#${t.number}`].filter(Boolean).join(` `)].filter(Boolean).map(e=>`, ${e}`).join(``)}),i&&(0,V.jsxs)(`span`,{className:`ml-auto flex gap-1.5 pl-3 tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions]}),(0,V.jsxs)(`span`,{className:`text-error`,children:[`−`,t.deletions]})]})]})]},t.url??`${e.id}#${t.number??``}`)})}),document.body)]})}var vH=`~archived`;function yH(e,t,n,r){let i=t.filter(e=>!e.routine);if(i.length===0)return e;let a={id:vH,kind:`archived`,count:i.length,expanded:n};if(!n)return[...e,a];let o=mw([{repo:``,label:``,key:vH,tasks:i}],``,r,1,!1);return[...e,a,...o.filter(e=>e.kind!==`project`)]}function bH(e,t,n){let r=t.kind===`main`,i=e=>r?e.kind===`main`:e.kind!==`main`&&e.repo===t.repo&&!e.pinned==!t.pinned;if(t.id===n.id||!i(n))return null;let a=e.filter(i).sort((e,t)=>(e.order??e.rank)-(t.order??t.rank)).map(e=>e.id);return a.indexOf(n.id)-a.indexOf(t.id)}function xH(e,t,n,r){let i=bH(e,t,n);return i===null?null:r===`above`&&i>0?i-1:r===`below`&&i<0?i+1:i}function SH(e,t){return e.id===t.id?!1:e.kind===`main`?t.kind===`main`:t.kind!==`main`&&t.repo===e.repo}function CH(e,t,n,r,i){if(!SH(t,n))return null;if(t.kind===`main`){let i=xH(e,t,n,r);return i?{steps:i}:null}let a=n.pinned===!0||i&&r===`above`,o={...t,pinned:a},s=a===(n.pinned===!0)?xH(e.map(e=>e.id===t.id?o:e),o,n,r)??0:0,c=a===(t.pinned===!0)?{}:{pin:a};return`pin`in c||s!==0?{...c,steps:s}:null}var wH=e=>e===void 0||e.kind===`project`||e.kind===`state`?0:e.kind===`task`||e.kind===`pane`||e.kind===`round`?e.depth:1;function TH(e,t){let n=wH(e[t]),r=t+1;for(;r<e.length&&wH(e[r])>n;)r++;return r}function EH(e,t,n){let r=e.findIndex(e=>e.id===t),i=r<0?e:[...e.slice(0,r),...e.slice(TH(e,r))];for(let e=i.findIndex(e=>e.id===n)-1;e>=0;e--){let t=i[e];if(!t||t.kind===`project`||t.kind===`state`)return!0;if(t.kind===`task`&&t.depth===1&&t.task.kind!==`main`||t.kind===`round`&&t.depth===1)return!1}return!1}function DH(e,t){let n=wH(e[t]),r=[];for(let i=2;i<=n;i++){let a=t+1;for(;a<e.length&&wH(e[a])>i;)a++;let o=a<e.length&&wH(e[a])===i;r.push(i===n?o?`tee`:`elbow`:o?`pipe`:`blank`)}return r}function OH(e,t,n,r){let i=e.findIndex(e=>e.id===t);if(i<0||t===n)return e;let a=TH(e,i),o=e.slice(i,a),s=[...e.slice(0,i),...e.slice(a)],c=s.findIndex(e=>e.id===n);if(c<0)return e;let l=r===`above`?c:TH(s,c);return[...s.slice(0,l),...o,...s.slice(l)]}function kH(e,t,n,r,i){let[a,o]=(0,g.useState)(null),s=(0,g.useRef)(t);s.current=t;let[c,l]=(0,g.useState)(null),u=(0,g.useRef)(()=>o(null));(0,g.useEffect)(()=>{if(!c)return;let e=()=>{l(null),u.current()};if(t!==c)return e();let n=window.setTimeout(e,3e3);return()=>window.clearTimeout(n)},[t,c]);let d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=()=>[...d.current?.querySelectorAll(`[data-row]`)??[]];(0,g.useLayoutEffect)(()=>{let e=f.current;if(!e||(f.current=null,window.matchMedia(`(prefers-reduced-motion: reduce)`).matches))return;let t=p().flatMap(t=>{let n=e.get(t.dataset.row??``),r=n===void 0?0:n-t.getBoundingClientRect().top;return r?[{el:t,dy:r}]:[]});for(let{el:e,dy:n}of t)e.style.transition=`none`,e.style.transform=`translateY(${n}px)`;d.current?.getBoundingClientRect();for(let{el:e}of t)e.style.transition=`transform 150ms ease-out`,e.style.transform=``,e.addEventListener(`transitionend`,()=>e.style.removeProperty(`transition`),{once:!0})});let m=(0,g.useRef)(null),h=(0,g.useRef)([]),_=(0,g.useRef)(new Map),v=(0,g.useRef)(0),y=(0,g.useRef)(0),b=e=>{m.current=e,o(e)},x=e=>!n||e.machine!==void 0?null:e.kind===`project`?t.find(t=>t.id===i(e.repo).mainTaskId)??null:e.kind===`task`&&e.depth===1&&e.task.kind!==`main`?e.task:null,S=e=>{let t=x(e);if(t)return{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t.id),d.current=n.currentTarget.closest(`[data-rail-body]`),T(d.current);let r=h.current,i=r.findIndex(t=>t.id===e.id);v.current=r.slice(i,TH(r,i)).reduce((e,t,n)=>e+(_.current.get(t.id)?.height??0)+(n>0?_.current.get(t.id)?.gap??0:0),0),y.current=n.clientY,b({fromRow:e.id,from:t,toRow:e.id,to:t,side:`above`})},onDragEnd:()=>m.current&&b(null)}},C=(e,t,n)=>{let r=t;if(n.from.kind===`main`)for(;r>0&&e[r]?.kind!==`project`;)r--;let i=e[r],a=i&&x(i);return!i||!a||!SH(n.from,a)?null:{row:i.id,task:a}},w={onDragOver:e=>{let t=m.current;if(!t)return;e.preventDefault();let n=e.clientY-y.current;y.current=e.clientY;let r=e.target.closest(`[data-row]`)?.dataset.row,i=h.current,a=C(i,i.findIndex(e=>e.id===r),t);if(!a||a.row===t.fromRow)return;let o=e.currentTarget.querySelector(`[data-row="${CSS.escape(t.fromRow)}"]`)?.getBoundingClientRect().top;if(o===void 0||e.clientY>=o&&e.clientY<o+v.current)return;let s=e.clientY<o?`above`:`below`;(s===`above`?n>=0:n<=0)||(t.toRow!==a.row||t.side!==s)&&b({...t,toRow:a.row,to:a.task,side:s})},onDrop:n=>{let i=m.current;if(!i)return;n.preventDefault();let a=CH(t,i.from,i.to,i.side,EH(h.current,i.fromRow,i.toRow));m.current=null,r?u.current=()=>o(null):u.current=()=>{f.current=new Map(p().map(e=>[e.dataset.row??``,e.getBoundingClientRect().top])),o(null),FT(`default`),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.default`)}))},a?HT(e,i.from.id,a).finally(()=>l(s.current)):u.current()}},T=e=>{let t=[...e?.querySelectorAll(`[data-row]`)??[]];_.current=new Map(t.map((e,n)=>{let r=t[n-1],i=r?e.offsetTop-r.offsetTop-r.offsetHeight:0;return[e.dataset.row??``,{top:e.offsetTop,gap:i,height:e.offsetHeight}]}))},E=e=>{h.current=a?OH(e,a.fromRow,a.toRow,a.side):e;let t=new Map;if(!a)return t;let n=Math.min(...[..._.current.values()].map(e=>e.top));for(let[e,r]of h.current.entries()){let i=_.current.get(r.id);if(!i)return new Map;e>0&&(n+=i.gap),n!==i.top&&t.set(r.id,n-i.top),n+=i.height}return t};return{props:S,body:w,dragging:a?.fromRow??null,places:e=>{let t=E(e);return e=>{let n=t.get(e.id);return n?{"data-row":e.id,style:{transform:`translateY(${n}px)`}}:{"data-row":e.id}}}}}function AH({model:e,narrow:t,onSettings:n}){B();let r=v(e.selection),i=v(_N),a=$(`engines.skill.bannerHintWeb`,{engines:i.join(`, `)});return(0,V.jsxs)(V.Fragment,{children:[!t&&(0,V.jsx)(OP,{client:e.client,taskId:r.taskId,tabId:r.tabId}),(0,V.jsxs)(`div`,{className:vM,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${yM(!1)}`,onClick:n,children:[(0,V.jsxs)(`svg`,{className:xM,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,V.jsx)(`span`,{children:z(`rail.settings`)}),i.length>0&&(0,V.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-meta text-subtle`,title:a,children:z(`rail.skillCue`)})]}),(0,V.jsx)(yF,{model:e,bindingId:`settings.open`})]})]})}function jH(e,t,n,r,i=null){let a=e=>e.kind===`task`&&e.task.kind===`main`&&e.fold===void 0&&e.task.id!==n&&e.task.id!==i&&(r?t[e.task.id]?.length===0:(t[e.task.id]?.length??0)===0),o=e.filter(e=>!a(e));return o.filter((e,t)=>{if(e.kind!==`project`&&e.kind!==`state`)return!0;let n=o[t+1];return n!==void 0&&n.kind!==`project`&&n.kind!==`state`})}var MH=_({});function NH(e,t,n){let r=MH.get()[`${e}::${t.id}`];return r&&r.sig===Ew(n)&&yw(n.root).some(e=>e.id===r.leaf)?r.leaf:n.activeLeafId}function PH(e,t,n,r){MH.set({...MH.get(),[`${e}::${t}`]:{sig:Ew(n),leaf:r}})}function FH(e,t,n,r){PH(e,t.id,n,r),ia(yC(e,t.id,r))?.focus()}function IH(e){let{taskId:t,tabId:n}=e.selection.get(),r=t?e.tabs.get()[t]?.find(e=>e.id===n):void 0;return t&&r?{taskId:t,tab:r}:null}async function LH(e,t,n){try{let r=await e.client.request(`tab.split`,t);await e.refreshTabsNow(),n?.(r)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}function RH(e,t,n,r,i){let a=i??(n.split?NH(t,n,n.split):`leaf-1`),o=e.selection.get();(o.taskId!==t||o.tabId!==n.id)&&e.select(t,n.id);let s=ia(yC(t,n.id,a))?.size();LH(e,{taskId:t,tabId:n.id,action:`open`,direction:r,leafId:a,...s},e=>{e.changed?e.split&&PH(t,n.id,e.split,e.leaf):G(z(`layout.splitTooSmall`),`error`)})}function zH(e,t,n,r){let i=n.split,a=i?NH(t,n,i):r,o=()=>LH(e,{taskId:t,tabId:n.id,action:`close`,leafId:r},e=>{let i=e.split;if(!i)return;let o=a!==r&&yw(i.root).some(e=>e.id===a);PH(t,n.id,i,o?a:i.activeLeafId)});if(!i||!ww(n,i,r)){o();return}W.set((0,V.jsx)(sr,{title:z(`confirm.closePaneTitle`,{pane:Cw(i,_w(n)).get(r)??r}),body:z(`confirm.closePaneBody`),confirmLabel:z(`menu.closePane`),onConfirm:o}))}function BH(e,t,n,r){let i=n.split;i&&W.set((0,V.jsx)(or,{title:yo(`split.renameTitle`),initial:Cw(i,_w(n)).get(r)??``,allowEmpty:!0,submitLabel:z(`dialog.save`),onSubmit:i=>LH(e,{taskId:t,tabId:n.id,action:`rename`,leafId:r,title:i})}))}function VH(e,t,n,r){return[{label:z(`menu.renamePane`),section:`split`,key:eo(`workspace.split.rename`)??void 0,run:()=>BH(e,t,n,r)},{label:z(`menu.closePane`),section:`split`,key:ti(`workspace.split.close`)||void 0,run:()=>zH(e,t,n,r)}]}function HH(e,t,n,r){return[{label:z(`menu.splitRight`),section:`split`,key:eo(`workspace.split.right`)??void 0,run:()=>RH(e,t,n,`right`,r)},{label:z(`menu.splitDown`),section:`split`,key:eo(`workspace.split.down`)??void 0,run:()=>RH(e,t,n,`down`,r)}]}function UH(e,t,n,r){let i=n.split,a=r??(i?NH(t,n,i):`leaf-1`);return[...HH(e,t,n,a),...bw(i)?VH(e,t,n,a):[]]}function WH(e,t){let n=e.tabs.get()[t]??[],r=e.selection.get(),i=(r.taskId===t?n.find(e=>e.id===r.tabId):void 0)??Li(n);return!i||!Tw(i)?[]:HH(e,t,i,i.split?NH(t,i,i.split):`leaf-1`)}function GH(e,{task:t,tab:n,leaf:r}){n.split&&FH(t.id,n,n.split,r),e.select(t.id,n.id)}function KH(e){let{row:t}=e,n=v(e.model.selection);v(MH);let r=n.taskId===t.task.id&&n.tabId===t.tab.id&&!!t.tab.split&&NH(t.task.id,t.tab,t.tab.split)===t.leaf;return(0,V.jsxs)(`button`,{type:`button`,className:`${Qn({size:`pane`})} ${e.cursor?iE:``}`,"aria-current":r||void 0,onClick:e.onClick,onContextMenu:e.onMenu,...e.place,children:[(0,V.jsx)(`span`,{className:UT,"aria-hidden":`true`,children:e.guides?.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${$n} text-(length:--fs-meta) ${r?`text-ink`:`text-muted`}`,children:t.label})]})}function qH(e,t){let n=t?.trim()??``;return n&&e?.effortLevels?.includes(n)?n:``}function JH({model:e,taskId:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)({}),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1),{busy:m,error:h,submit:_}=ar();(0,g.useEffect)(()=>{Promise.all([e.client.request(`engines.list`),e.client.request(`task.get`,{taskId:t})]).then(([e,t])=>{let n=ms(e.engines,t.task.engine).filter(e=>e.ready!==!1||e.id===t.task.engine),i=n.find(e=>e.id===t.task.engine)??n[0];r(n),a(t.task),s(i?.id??``),l(qH(i,t.task.effort)),d(i?.id===t.task.engine?t.task.model??``:``),p(!0)})},[e,t]);let v=n.find(e=>e.id===o),y=v?.effortLevels??[],b=y.length>0?[``,...y]:[],x=(v?.models??[]).map(e=>e.id).filter(e=>e.toLowerCase().includes(u.trim().toLowerCase())&&e!==u.trim()).slice(0,6),S=e=>{s(e);let t=n.find(t=>t.id===e);l(qH(t,e===i.engine?i.effort:void 0)),d(e===i.engine?i.model??``:``)},C=e=>{let t=n.findIndex(e=>e.id===o),r=n[Math.max(0,Math.min(n.length-1,t+e))];r&&S(r.id)},w=e=>{if(b.length===0)return;let t=Math.max(0,b.indexOf(c));l(b[Math.max(0,Math.min(b.length-1,t+e))]??``)},T=e=>{let t=e.target instanceof HTMLInputElement;if(e.key===`ArrowUp`&&!t)C(-1);else if(e.key===`ArrowDown`&&!t)C(1);else if((e.key===`ArrowLeft`||e.key===`h`)&&!t)w(-1);else if((e.key===`ArrowRight`||e.key===`l`)&&!t)w(1);else return;e.preventDefault()},E=()=>_(async()=>{if(!v)return;let n=y.length>0?c:void 0,r=v.acceptsModel?u.trim():void 0;(v.id!==i.engine||n!==void 0&&n!==(i.effort??``)||r!==void 0&&r!==(i.model??``))&&(await e.client.request(`task.setEngine`,{taskId:t,engine:v.id,...n===void 0?{}:{effort:n},...r===void 0?{}:{model:r}}),G(q(`tasks`,`toast.engineSwitched`,{engine:v.name})))});return(0,V.jsx)(ir,{title:q(`tasks`,`changeEngine.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Pn,onKeyDown:T,onSubmit:e=>{e.preventDefault(),E()},children:[(0,V.jsx)(`ul`,{className:On,"aria-label":q(`tasks`,`changeEngine.title`),children:n.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===o,className:Qn({selected:e.id===o}),onClick:()=>S(e.id),children:[(0,V.jsx)(`span`,{className:`${nr} text-accent`,children:e.id===o?`●`:` `}),(0,V.jsx)(`span`,{className:$n,children:e.name}),e.id===i.engine&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`tasks`,`changeEngine.current`)})]})},e.id))}),f&&v&&v.acceptsModel&&(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`engineModel.label`)}),(0,V.jsx)(`input`,{className:Qt,spellCheck:!1,placeholder:q(`tasks`,`engineModel.placeholder`),value:u,onChange:e=>d(e.target.value)}),x.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:x.map(e=>(0,V.jsx)(`button`,{type:`button`,className:Dn(),onClick:()=>d(e),children:e},e))})]}),b.length>0&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`changeEngine.effortLabel`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(e=>(0,V.jsx)(`button`,{type:`button`,"aria-pressed":e===c,className:Dn(e===c),onClick:()=>l(e),children:e===``?q(`tasks`,`changeEngine.noEffort`):e},e||`default`))})]}),(0,V.jsx)(`p`,{className:`keys-only ${Gt}`,children:(0,V.jsx)(ST,{text:[q(`tasks`,`changeEngine.footer.engine`),...v?.acceptsModel?[q(`tasks`,`changeEngine.footer.model`)]:[],...b.length>0?[q(`tasks`,`changeEngine.footer.effort`)]:[],q(`tasks`,`changeEngine.footer.set`),q(`tasks`,`changeEngine.footer.cancel`)].join(` · `)})}),h&&(0,V.jsx)(`p`,{className:`text-error`,children:h}),(0,V.jsx)(lr,{busy:m||!f,submitLabel:z(`taskops.set`)})]})})}function YH({model:e,task:t}){let[n,r]=(0,g.useState)(()=>Ns(e,`task.get`,{taskId:t.id})?.task??null),[i,a]=(0,g.useState)(null),{busy:o,error:s,submit:c}=ar();(0,g.useEffect)(()=>{Fs(e,`task.get`,{taskId:t.id}).then(e=>r(e.task)).catch(e=>a(K(e)))},[e,t.id]);let l=()=>c(async()=>{if(!n?.prompt)return;let t=(await e.client.request(`task.spawn`,{repo:n.repo,prompt:n.prompt,...n.engine?{engine:n.engine}:{},...n.baseRef?{baseBranch:n.baseRef}:{}})).taskIds[0];t&&e.selectWhenListed(t)});return(0,V.jsx)(ir,{title:q(`tasks`,`runAgain.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Pn,onSubmit:e=>{e.preventDefault(),l()},children:[(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`runAgain.source`,{title:t.label})}),(0,V.jsx)(`pre`,{className:Kt,children:n?.prompt??i??q(`tasks`,`fieldNotes.loading`)}),(0,V.jsx)(`p`,{className:Gt,children:q(`tasks`,`runAgain.hint`)}),s&&(0,V.jsx)(`p`,{className:`text-error`,children:s}),(0,V.jsx)(lr,{busy:o||!n?.prompt,submitLabel:q(`tasks`,`runAgain.confirm`)})]})})}function XH(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function ZH({model:e,repo:t}){let[n,r]=(0,g.useState)({kind:`loading`}),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=()=>e.client.request(`notes.list`,{repo:t}).then(e=>r({kind:`ready`,notes:e.notes})).catch(e=>r({kind:`error`,message:K(e)}));(0,g.useEffect)(()=>void d(),[]);let f=n.kind===`ready`?n.notes:[];(0,g.useEffect)(()=>a(e=>Math.max(0,Math.min(e,f.length-1))),[f.length]),(0,g.useEffect)(()=>{u.current?.querySelector(`.is-selected`)?.scrollIntoView({block:`nearest`})},[i]);let p=async n=>{if(n.id!==void 0){l(null);try{await e.client.request(`notes.delete`,{repo:t,id:n.id}),s(null),await d()}catch(e){l(K(e))}}};return(0,V.jsx)(ir,{title:q(`tasks`,`fieldNotes.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:Pn,onKeyDown:e=>{if(!o){if(e.key===`ArrowDown`||e.key===`j`)a(e=>Math.min(f.length-1,e+1));else if(e.key===`ArrowUp`||e.key===`k`)a(e=>Math.max(0,e-1));else if(e.key===`d`&&f[i]?.id!==void 0)s(f[i]??null);else return;e.preventDefault()}},children:[(0,V.jsx)(`p`,{className:`font-mono text-meta break-all text-muted`,children:t}),n.kind===`loading`&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.loading`)}),n.kind===`error`&&(0,V.jsx)(`p`,{className:`text-error`,children:n.message}),n.kind===`ready`&&f.length===0&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.empty`)}),f.length>0&&(0,V.jsx)(`ul`,{className:`m-0 list-none p-0 flex max-h-[44vh] flex-col gap-2 overflow-y-auto`,ref:u,children:f.map((e,t)=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:qt(t===i),onClick:()=>a(t),autoFocus:t===0,children:[(0,V.jsxs)(`span`,{className:`font-mono text-meta whitespace-pre text-accent`,children:[t===i?`▸ `:` `,XH(e.at),`, `,e.author]}),(0,V.jsx)(`span`,{className:`text-ink whitespace-pre-wrap wrap-anywhere`,children:e.text})]})},`${e.at}:${t}`))}),o&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-paper px-3 py-2.5`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:q(`tasks`,`fieldNotes.confirmDelete.title`)})}),(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.confirmDelete.body`,{text:o.text})}),c&&(0,V.jsx)(`p`,{className:`text-error`,children:c}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>s(null),children:z(`dialog.cancel`)}),(0,V.jsx)(`button`,{type:`button`,className:je({danger:!0}),onClick:()=>void p(o),children:z(`taskops.retire`)})]})]}),!o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`keys-only font-sans text-meta text-subtle`,children:q(`tasks`,`fieldNotes.footerDeletable`)}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,disabled:f[i]?.id===void 0,onClick:()=>s(f[i]??null),children:z(`taskops.retire`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:yn,children:z(`taskops.close`)})]})]})]})})}var QH=[`backlog`,`in_progress`,`in_review`,`done`,`canceled`,`error`],$H={backlog:`status.backlog`,in_progress:`status.inProgress`,in_review:`status.inReview`,done:`status.done`,canceled:`status.canceled`,error:`status.error`},eU=e=>({binding:e,key:eo(e)??void 0});async function tU(e,t){if(!e){G(z(`menu.nothingToCopy`,{what:t}),`error`);return}try{await navigator.clipboard.writeText(e),G(z(`menu.copied`,{text:e}))}catch{G(z(`menu.copyFailed`),`error`)}}function nU(e,t,n){let r=[{label:z(`menu.newTask`),section:`open`,run:()=>KD(t)}],i=n.mainTaskId;return i&&(n.first||r.push({label:q(`tasks`,`menu.moveToTop`),section:`edit`,run:()=>void e.client.request(`task.move`,{taskId:i,direction:`top`}).catch(e=>G(q(`tasks`,`toast.moveFailed`,{error:String(e)}),`error`))}),r.push({label:q(`tasks`,`menu.reorderProject`),section:`edit`,...eU(`sidebar.localMerge`),run:()=>iU(i)})),r.push({label:q(`tasks`,`menu.fieldNotes`),section:`notes`,run:()=>W.set((0,V.jsx)(ZH,{model:e,repo:t}))}),i&&r.push({label:q(`tasks`,`menu.forgetProject`),section:`danger`,danger:!0,run:()=>W.set(QP(e,t,n.label))}),r}function rU(e){return[{label:z(`menu.newChatNoFolder`),section:`open`,run:()=>qD()},{label:z(`menu.newShell`),section:`open`,run:()=>void PC(e).catch(e=>G(String(e),`error`))}]}function iU(e){let t=!LT.get();t&&e!==void 0&&RT.set(e),zT(t),document.querySelector(`.rail`)?.focus()}function aU(e,t){let n=(e.tasks.get()?.tasks??[]).filter(e=>e.kind===`main`&&!e.machine&&e.repo!==t.repo).map(e=>e.repo),r=n.map(e=>{let t=e.slice(e.lastIndexOf(`/`)+1);return{value:e,label:n.filter(e=>e.endsWith(`/${t}`)).length>1?e:t}});return r.length===0?(G(q(`tasks`,`moveToProject.empty`),`error`),null):(0,V.jsx)(cr,{title:q(`tasks`,`moveToProject.title`),choices:r,onPick:async n=>{await e.client.request(`task.moveToProject`,{taskId:t.id,repo:n}),G(q(`tasks`,`toast.movedToProject`,{project:r.find(e=>e.value===n)?.label??n}))}})}function oU(e,t,n){let r=e.client,i=[];n&&(i.push({label:z(`menu.closeTab`),section:`tab`,run:()=>W.set((0,V.jsx)(sr,{title:z(`confirm.closeTabTitle`,{tab:n.title??n.engineName??n.id}),body:z(`confirm.closeTabBody`),confirmLabel:z(`menu.closeTab`),onConfirm:async()=>{await r.request(`tab.close`,{taskId:t.id,tabId:n.id}),await e.refreshTabsNow()}}))}),i.push(...UH(e,t.id,n))),i.push({label:z(`menu.newChat`),section:`open`,run:()=>void MC(e,t.id)}),i.push({label:z(`menu.newChatPick`),section:`open`,run:()=>W.set((0,V.jsx)(RC,{model:e,taskId:t.id}))}),i.push({label:z(`menu.continueEngine`),section:`open`,...eU(`chat.tab.fork`),run:()=>W.set((0,V.jsx)(RC,{model:e,taskId:t.id,context:`continue`,sourceTabId:n?.id}))}),i.push({label:z(`menu.newShell`),section:`open`,run:()=>void NC(e,t.id,{kind:`shell`}).catch(e=>G(String(e),`error`))}),t.startsAt&&(i.push({label:z(`menu.startNow`),section:`open`,run:()=>void e.client.request(`task.startScheduledNow`,{taskId:t.id}).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.cancelStart`),section:`open`,run:()=>void e.client.request(`task.cancelScheduledStart`,{taskId:t.id}).catch(e=>G(String(e),`error`))})),t.hasPrompt&&(i.push({label:q(`tasks`,`menu.runAgain`),section:`open`,run:()=>W.set((0,V.jsx)(YH,{model:e,task:t}))}),i.push({label:z(`menu.retryEdit`),section:`open`,run:()=>void MD(e,t)}));let a=!t.machine;if(a&&i.push({label:q(`tasks`,`menu.openEditor`),section:`open`,...eU(`tasks.openWorktree`),run:()=>void qP(e,t.id)}),t.groupId){let e=t.groupId;i.push({label:z(`compare.menu`),section:`open`,run:()=>ga(e)})}i.push({label:z(`menu.rename`),section:`edit`,...eU(`sidebar.rename`),run:()=>W.set((0,V.jsx)(or,{title:z(`menu.rename`),initial:t.title,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.rename`,{taskId:t.id,title:e}).then(()=>{})}))}),t.kind!==`main`&&i.push({label:t.pinned?z(`menu.unpin`):z(`menu.pin`),section:`edit`,...eU(`sidebar.pin`),run:()=>void r.request(`task.pin`,{taskId:t.id,pinned:!t.pinned}).catch(e=>G(String(e),`error`))}),a&&i.push({label:q(`tasks`,`menu.reorder`),section:`edit`,...eU(`sidebar.localMerge`),run:()=>iU()}),i.push({label:z(`menu.setStatus`),section:`edit`,children:QH.map(e=>({label:z($H[e]),checked:e===t.status,run:()=>void r.request(`task.setStatus`,{taskId:t.id,status:e}).catch(e=>G(String(e),`error`))}))}),a&&t.kind!==`main`&&!t.routine&&!t.parentTaskId&&!t.extraRepoCount&&i.push({label:q(`tasks`,`menu.moveToProject`),section:`edit`,run:()=>{let n=aU(e,t);n&&W.set(n)}}),a&&i.push({label:z(`menu.changeEngine`),section:`edit`,...eU(`tasks.cycleEngine`),run:()=>W.set((0,V.jsx)(JH,{model:e,taskId:t.id}))}),t.pr?.checkState===`failing`&&i.push({label:q(`tasks`,`menu.fixChecks`),section:`git`,key:ti(`files.fixChecks`),run:()=>void KP(e,t.id,z(`taskops.fixSent`))}),t.kind===`task`&&t.branch&&a&&i.push({label:q(`tasks`,`menu.syncBase`),section:`git`,key:ti(`files.syncBase`),run:()=>void WP(e,t.id)}),t.branch&&i.push({label:z(`menu.renameBranch`),section:`git`,...eU(`tasks.renameBranch`),run:()=>W.set((0,V.jsx)(or,{title:z(`menu.renameBranch`),initial:t.branch,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.setBranch`,{taskId:t.id,branch:e}).then(()=>{})}))}),t.kind===`task`&&t.branch&&i.push({label:z(`menu.land`),section:`git`,run:()=>void HP(e,t)});let o=[{label:z(`menu.copyWhat.id`),run:()=>void tU(t.id,z(`menu.what.id`))}];return t.branch&&o.push({label:z(`menu.copyWhat.branch`),run:()=>void tU(t.branch,z(`menu.what.branch`))}),o.push({label:z(`menu.copyWhat.path`),run:()=>void r.request(`task.get`,{taskId:t.id}).then(e=>tU(e.task.worktreePath,z(`menu.what.path`))).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.copy`),section:`copy`,children:o}),t.kind!==`main`&&i.push({label:q(`tasks`,t.archived?`menu.unarchive`:`menu.archive`),section:`danger`,run:()=>void ZP(e,t)}),i.push({label:z(`menu.removeSession`),section:`danger`,...eU(`sidebar.delete`),danger:!0,run:()=>W.set(t.kind===`main`?XP(e,t):YP(e,t))}),i}var sU=`rove.collapsedProjects`,cU=`rove.foldedTasks`,lU=`rove.openedTasks`,uU=600;function dU(e){try{let t=JSON.parse(localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}function fU(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}var pU=(e,t)=>{let n=new Set(e);return n.delete(t)||n.add(t),n};function mU(){let e=v(PT),[t,n]=(0,g.useState)({active:!1,query:``}),[r,i]=(0,g.useState)(!1),a=()=>i(e=>!e),[o,s]=(0,g.useState)(()=>dU(sU)),c=e=>s(t=>{let n=pU(t,e);return fU(sU,n),n}),[l,u]=(0,g.useState)(()=>({folded:dU(cU),opened:dU(lU)}));return{sort:e,cycleSort:IT,search:t,setSearch:n,archivedOpen:r,toggleArchived:a,collapsed:o,toggleProject:c,hand:l,toggleTaskFold:(e,t)=>u(n=>{let r=new Set(n.folded),i=new Set(n.opened);return t?(r.delete(e),i.add(e)):(i.delete(e),r.add(e)),fU(cU,r),fU(lU,i),{folded:r,opened:i}})}}var hU=[`sidebar.nav`,`sidebar.goto`,`sidebar.select`,`sidebar.tree.open`,`sidebar.rename`,`sidebar.pin`,`sidebar.localMerge`,`sidebar.delete`,`sidebar.sort`,`sidebar.search.enter`,`tasks.renameBranch`,`tasks.cycleEngine`,`tasks.openWorktree`,`tasks.update`,`tasks.focusEngine`,`task.new`,`settings.open.sidebar`,`worktrees.open.sidebar`];function gU(e){for(let t of e)for(let e of hU){let n=ei(e).indexOf(t);if(n>=0)return{id:e,slot:n}}return null}function _U(e,t){let n=e.selection.get().taskId===t;e.select(t),pa(),n&&Wi()}function vU(e,t,n,r){let{search:i,setSearch:a}=n,[o,s]=(0,g.useState)(null),c=(0,g.useRef)(0),l=t.filter(e=>e.kind!==`project`&&e.kind!==`state`),u=l.findIndex(e=>e.id===o);(0,g.useEffect)(()=>{u<0&&s(r.selectedId&&l.some(e=>e.id===r.selectedId)?r.selectedId:l[0]?.id??null)},[u,l,r.selectedId]);let d=l[u],f=d?.kind===`task`||d?.kind===`pane`?d.task.id:null;(0,g.useEffect)(()=>$k.set(f),[f]);let p=l[0]?.id??null;(0,g.useEffect)(()=>{i.query,i.active&&s(p)},[i.active,i.query,p]);let m=e=>{let t=l[Math.max(0,Math.min(l.length-1,e))];t&&s(t.id)},h=t=>{t?.kind===`archived`&&n.toggleArchived(),t?.kind===`task`&&e.select(t.task.id),t?.kind===`round`&&ga(t.groupId),t?.kind===`pane`&&GH(e,t),t&&t.kind!==`archived`&&pa()},_=(t,n)=>{t?.kind===`task`&&tn(oU(e,t.task,null),n)?.run?.()},v=async t=>{if(t?.kind===`task`&&t.machine===void 0)try{let{engines:n}=await e.client.request(`engines.list`),r=ms(n).filter(e=>e.ready!==!1),i=r[(r.findIndex(e=>e.id===t.task.engine?.id)+1)%r.length];if(!i||i.id===t.task.engine?.id)return;await e.client.request(`task.setCommand`,{taskId:t.task.id,engine:i.id}),G(z(`rail.engineSwitched`,{engine:i.name}))}catch(e){G(z(`rail.engineSwitchFailed`,{error:e instanceof Error?e.message:String(e)}),`error`)}};return{cursor:o,setCursor:s,onKeyDown:t=>{let o=l[u],s=t.target instanceof HTMLInputElement;if(i.active){if(t.metaKey||t.ctrlKey||t.altKey)return;if(t.key===`Escape`)a({active:!1,query:``});else if(t.key===`Enter`)h(o),a({active:!1,query:``});else if(t.key===`ArrowDown`)m(u+1);else if(t.key===`ArrowUp`)m(u-1);else if(t.key===`Backspace`&&!s)a(e=>({...e,query:e.query.slice(0,-1)}));else if(t.key.length===1&&!s)a(e=>({...e,query:e.query+t.key}));else return;t.preventDefault();return}let d=gU(Ja(t));if(LT.get()){let n=o?.kind===`task`&&o.machine===void 0;if(d?.id===`sidebar.nav`)n&&BT(e,o,d.slot%2==0?1:-1);else if(d?.id===`sidebar.localMerge`||t.key===`Enter`||t.key===`Escape`)zT(!1);else return;t.preventDefault();return}switch(d?.id){case`sidebar.nav`:m(d.slot%2==0?u+1:u-1);break;case`sidebar.goto`:d.slot%2==1?m(l.length-1):Date.now()-c.current<uU?(m(0),c.current=0):c.current=Date.now();break;case`sidebar.select`:case`sidebar.tree.open`:h(o);break;case`tasks.focusEngine`:Wi();break;case`sidebar.rename`:case`sidebar.pin`:case`sidebar.delete`:case`tasks.renameBranch`:case`tasks.openWorktree`:_(o,d.id);break;case`tasks.cycleEngine`:v(o);break;case`sidebar.localMerge`:o?.machine===void 0&&zT(!0);break;case`sidebar.sort`:n.cycleSort(),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.${PT.get()}`)}));break;case`sidebar.search.enter`:a({active:!0,query:``});break;case`task.new`:r.onNewTask(o?.kind===`task`||o?.kind===`pane`?o.task.repo:void 0,o?.machine);break;case`settings.open.sidebar`:r.onSettings();break;case`worktrees.open.sidebar`:ha(`worktrees`);break;case`tasks.update`:ha(`update`);break;default:return}t.preventDefault()}}}var yU=(e,t,n)=>`~pane:${e}:${t}:${n}`;function bU(e,t){return e.flatMap(e=>e.kind===`task`?[e,...(t[e.task.id]??[]).flatMap(t=>{let n=t.split;if(!n||!bw(n))return[];let r=Cw(n,_w(t));return yw(n.root).map(n=>({id:yU(e.task.id,t.id,n.id),kind:`pane`,task:e.task,tab:t,leaf:n.id,label:r.get(n.id)??n.id,depth:e.depth+1,...e.machine===void 0?{}:{machine:e.machine}}))})]:[e])}function xU(e){let{row:t}=e;return(0,V.jsxs)(`button`,{type:`button`,className:`${Qn({size:`pane`})} ${e.cursor?iE:``}`,title:z(`compare.menu`),onClick:()=>{e.onClick(),ga(t.groupId)},...e.place,children:[e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${$n} text-(length:--fs-meta) text-muted`,children:t.title}),(0,V.jsxs)(`span`,{className:`${rr} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),(0,V.jsx)(`span`,{className:`text-subtle`,children:t.tasks.length}),(0,V.jsx)(XL,{status:UF(t.tasks)})]})]})}function SU(e){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let e=t.current;return()=>{e&&document.activeElement===e&&e.closest(`nav`)?.focus()}},[]),(0,V.jsxs)(`div`,{className:`${eE} mono items-center`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:`/`}),(0,V.jsx)(`input`,{ref:t,className:nE,type:`text`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,enterKeyHint:`go`,value:e.query,placeholder:z(`rail.searchPlaceholder`),"aria-label":z(`rail.searchPlaceholder`),onChange:t=>e.onChange(t.target.value)}),e.query&&(0,V.jsx)(`span`,{className:`ml-1.5 text-muted`,children:e.count})]})}var CU=450,wU=!1;typeof document<`u`&&(document.addEventListener(`keydown`,()=>{wU=!0},!0),document.addEventListener(`pointerdown`,()=>{wU=!1},!0));var TU=e=>{let t=e.querySelector(`.row-title`);return!!t&&t.scrollWidth>t.clientWidth};function EU(e,t){let[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null),o=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null},s=e=>{o(),i.current=window.setTimeout(()=>r(e.getBoundingClientRect()),CU)},c=()=>{o(),r(null)};return(0,g.useEffect)(()=>{let e=a.current,n=e?.closest(`.rail`);if(!t||!e||!n||!wU||!n.contains(document.activeElement)||!TU(e))return;let i=()=>{o(),r(null)},c=e=>{e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||i()};return s(e),n.addEventListener(`focusout`,c),()=>{n.removeEventListener(`focusout`,c),i()}},[t]),(0,g.useEffect)(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),{ref:e=>{a.current=e},onPointerEnter:e=>{e.pointerType===`touch`||!TU(e.currentTarget)||s(e.currentTarget)},onPointerLeave:c,hide:c,tip:n?(0,fH.createPortal)((0,V.jsx)(`div`,{className:XT,role:`tooltip`,style:{top:n.top+n.height/2,left:n.right+8},children:e}),document.body):null}}function DU({at:e}){let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=hD(t);return(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.startsAt`,{time:t.toLocaleString()}),children:[`◷ `,n]})}var OU=150,kU=128,AU=0,jU=2,MU=[{reach:.96,grow:1.5,pulse:.9,done:104},{reach:.72,grow:1.1,pulse:1.2,done:84},{reach:1,grow:1.7,pulse:.7,done:116},{reach:.84,grow:1.3,pulse:1,done:96},{reach:.62,grow:1.2,pulse:1.3,done:80}],NU=`/-\\|`,PU=6,FU=(e,t,n,r)=>{let i=e[n];i&&t>=0&&t<i.length&&(i[t]=r)};function IU(e,t){let n=Math.min(64,Math.max(24,Math.floor(t))),r=(Math.floor(e)%OU+OU)%OU,i=Array.from({length:11},()=>Array(n).fill(` `)),a=Array.from({length:11},()=>Array(n).fill(` `));FU(a,AU,0,`o`);let o=jU+2*(MU.length-1),s=Math.min(o,Math.floor(r/2));for(let e=1;e<=s;e++)FU(i,AU,e,`|`);if(MU.forEach((e,t)=>{let o=jU+2*t,s=2*o;if(r<s)return;FU(i,AU,o,`+`);let c=n-1-1,l=1+Math.max(1,Math.floor(c*e.reach)),u=Math.min(l,1+Math.floor((r-s)*e.grow)),d=r>=e.done&&u===l;for(let t=1;t<u;t++)!d&&((t-Math.floor(r*e.pulse))%PU+PU)%PU===0?FU(a,t,o,`=`):FU(i,t,o,`-`);d?FU(a,u,o,`o`):u<l?FU(a,u,o,`>`):FU(a,u,o,NU[(Math.floor(r/2)+t)%4]??`-`)}),r>=kU){let e=Math.ceil((r-kU+1)/22*(n+1));for(let t of[i,a])for(let r of t)r.fill(` `,0,Math.min(n,e))}return{base:i.map(e=>e.join(``)).join(`
127
+ `)}`},e.label))]})}var yV=30;function bV(e,t,n){let r=t.join(`\0`),[i,a]=(0,g.useState)(()=>Object.fromEntries(t.map(t=>[t,Ns(e,`routine.runs`,{id:t})?.runs??[]])));return(0,g.useEffect)(()=>{let n=!0;for(let r of t)Fs(e,`routine.runs`,{id:r}).then(e=>n&&a(t=>({...t,[r]:e.runs}))).catch(()=>void 0);return()=>{n=!1}},[e,r,n]),i}function xV(e){B();let{auto:t}=cL(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null);(0,g.useEffect)(()=>r(null),[e.followId]);let o=n===null?e.followId??``:n,s=o===``?e.routines.map(e=>e.id):[o],c=bV(e.c,s,e.tick),l=new Map(e.routines.map(e=>[e.id,e.name])),u=cV(c,o===``?null:o,i),d=e=>{if(e.status===`skipped_blocked`){let t=e.blocked?.reason;return t?lL(z(`runLog.blockedRun`),{reason:z(`runLog.blocked.${t}`)}):z(`runLog.outcome.blocked`)}return t.runStatus[e.status]??e.status},f=(e,t,n,r)=>(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":t,className:`max-w-40 truncate`,onClick:n,children:`[ ${e} ]`},r);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`runLog.title`)}),e.routines.length>1&&(0,V.jsx)(hA,{label:z(`runLog.routine`),value:o,picks:[{value:``,label:z(`runLog.allRoutines`)},...e.routines.map(e=>({value:e.id,label:e.name}))],onPick:r}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[f(z(`runLog.all`),i===null,()=>a(null),`all`),rV.map(e=>f(z(`runLog.outcome.${e}`),i===e,()=>a(e),e))]}),u.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:cV(c,o===``?null:o,null).length===0?t.noRuns:z(`runLog.empty`)}):u.slice(0,yV).map(n=>{let r=gV(n.status),i=Gz(n,e.now),a=i===`awaiting`?`, ${t.responseAwaiting}`:i===`missing`?`, ${t.responseMissing}`:``,s=oV(n),c=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:hV[r]}),(0,V.jsx)(`span`,{children:`#${n.runNumber}`}),o===``&&(0,V.jsx)(`span`,{className:`max-w-[20ch] truncate`,children:l.get(n.automationId)??``}),(0,V.jsx)(`span`,{className:JB,children:`${d(n)}${n.tabId?`, ${n.tabId}`:``}${a}`}),(0,V.jsx)(`span`,{className:`text-subtle`,children:z(`runLog.source.${aV[n.trigger]}`)}),s!==null&&(0,V.jsx)(`span`,{className:`text-muted`,children:sV(s)}),(0,V.jsx)(`span`,{className:`text-muted`,children:e.when(n.at)})]}),u=n.error?dV(n.error):null,f=n.taskId,p=i===`missing`?`text-warning`:mV[r];return(0,V.jsxs)(`div`,{className:`${WB} ${p}`,children:[f?(0,V.jsx)(`button`,{type:`button`,className:`mono ${qB}`,onClick:()=>e.openRun(f),children:c}):(0,V.jsx)(`span`,{className:`mono ${KB}`,children:c}),u&&(0,V.jsxs)(`details`,{className:`mono pl-[calc(2ch+16px)] [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:truncate [&_summary::-webkit-details-marker]:hidden [&[open]_summary]:whitespace-normal [&_pre]:mx-0 [&_pre]:mt-1 [&_pre]:mb-1.5 [&_pre]:max-h-[16lh] [&_pre]:overflow-auto [&_pre]:rounded-sm [&_pre]:bg-inset [&_pre]:px-2 [&_pre]:py-1.5 [&_pre]:whitespace-pre-wrap [&_pre]:wrap-anywhere [&_pre]:text-muted`,children:[(0,V.jsx)(`summary`,{children:u.summary}),(0,V.jsx)(`pre`,{children:u.full})]})]},n.id)}),u.length>yV&&(0,V.jsx)(`p`,{className:`text-muted`,children:z(`runLog.more`,{count:u.length-yV})})]})}var SV=5e3;function CV({model:e}){let{auto:t,common:n}=cL(),r=e.client,[i,a]=_L(SV),o=v(e.tasks),s=hL(e),c=gL(e),[l,u]=(0,g.useState)(()=>Ns(r,`routine.list`)??null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(null),y=bL(),b=uL(),x=B()===`zh`?`zh-CN`:`en-US`,S=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0;return Fs(r,`routine.list`).then(t=>e&&u(t)).catch(()=>e&&u(e=>e??{automations:[],keepsDaemonAlive:!1})),()=>{e=!1}},[r,i]);let C=l?.automations??[],w=l?.lastRunStatus??{},T=l?.lastFailure??{},E=e=>{let t=w[e.id];return t!==void 0&&Wz(t)},D=[{key:`pages.routinesNeedYou`,rows:C.filter(E)},{key:`pages.routinesActive`,rows:C.filter(e=>e.enabled&&!E(e))},{key:`pages.routinesPaused`,rows:C.filter(e=>!e.enabled&&!E(e))}],O=D.flatMap(e=>e.rows),k=Math.max(0,O.findIndex(e=>e.id===d)),A=O[k],j=e=>f(O[e]?.id??null),ee=D[0]?.rows.length??0,M=v(sn);(0,g.useEffect)(()=>{M===null||!l||(l.automations.some(e=>e.id===M)&&f(M),sn.set(null))},[M,l]);let N=bV(r,A?[A.id]:[],i),P=A?N[A.id]??[]:[];(0,g.useEffect)(()=>_(null),[A?.id]);let F=(0,g.useRef)(null),[I,te]=(0,g.useState)(0),L=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=S.current,t=I!==L.current;if(L.current=I,t&&e&&F.current&&e.offsetTop>F.current.offsetTop){e.scrollIntoView({block:`start`,behavior:`smooth`});return}F.current?.querySelector(`[data-row="${k}"]`)?.scrollIntoView({block:`nearest`})},[k,I]);let ne=Date.now(),re=e=>{let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return`—`;let r=n-ne,i=r>=0,a=Math.floor(Math.abs(r)/6e4),o=Math.floor(a/60);return a<1?i?t.when.now:t.when.justNow:a<60?lL(i?t.when.inMinutes:t.when.minutesAgo,{n:a}):o<24?lL(i?t.when.inHours:t.when.hoursAgo,{n:o}):new Date(n).toLocaleDateString()},ie=e=>o?.tasks.find(t=>t.id===e)?.label??e,R=t=>{on.set(null),e.select(t)},ae=(e,t,n)=>G(lL(e,{name:t,error:dL(n)}),`error`),oe=async()=>{if(!(!A||p)){m(A.id);try{await r.request(`routine.setEnabled`,{id:A.id,enabled:!A.enabled}),a()}catch(e){ae(A.enabled?t.disableFailed:t.enableFailed,A.name,e)}finally{m(null)}}},se=async()=>{if(!(!A||p)){m(A.id),_(lL(t.running,{name:A.name}));try{let e=await r.request(`routine.runNow`,{id:A.id});_(lL(t.ranWith,{name:A.name,status:e.status})),a()}catch(e){ae(t.runFailed,A.name,e)}finally{m(null)}}},ce=async()=>{if(p)return;let e=mL(await r.request(`repos.list`).then(e=>e.repos).catch(()=>[]),s);W.set((0,V.jsx)(nV,{repos:e,tasks:(o?.tasks??[]).filter(e=>!e.deleting).map(e=>({id:e.id,title:e.label,repo:e.repo})),defaultRepo:c,onSubmit:e=>{(async()=>{m(`new`);try{await r.request(`routine.create`,{...e.repo===null?{}:{repo:e.repo},name:e.name,prompt:e.prompt,schedule:e.schedule,...e.target?{targetTask:e.target.taskId,targetTab:e.target.tabId}:{}}),a()}catch(e){G(lL(t.createFailed,{error:dL(e)}),`error`)}finally{m(null)}})()}}))},le=()=>{if(!A||p)return;let e=A;W.set((0,V.jsx)(sr,{title:t.deleteTitle,body:lL(t.deleteBody,{name:e.name}),confirmLabel:t.deleteButton,onConfirm:async()=>{m(e.id);try{await r.request(`routine.delete`,{id:e.id}),a()}catch(n){ae(t.deleteFailed,e.name,n)}finally{m(null)}}}))};yL(e=>{if(e.ctrlKey)return e.key===`c`&&(on.set(null),!0);switch(e.key){case`Escape`:case`q`:return on.set(null),!0;case`j`:case`ArrowDown`:return j(Math.min(O.length-1,k+1)),!0;case`k`:case`ArrowUp`:return j(Math.max(0,k-1)),!0;case`n`:return ce(),!0;case`r`:return a(),!0;case`e`:return oe(),!0;case`s`:return se(),!0;case`d`:return le(),!0;case`Enter`:{let e=P[0]?.taskId;return e?R(e):P.length>0&&_(t.latestRunNoTask),!0}default:return!1}});let ue=A?.target,de=A?SB(A.schedule,b):null,fe=e=>e===void 0?z(`rail.noProject`):pL(e,C.flatMap(e=>e.repo??[])),pe=A?.nextRunAt?Date.parse(A.nextRunAt):NaN;return(0,V.jsxs)(`div`,{className:`${oM} ${AB}`,tabIndex:0,ref:y,children:[(0,V.jsxs)(`div`,{className:lM,children:[(0,V.jsx)(`h1`,{className:cM,children:t.title}),(0,V.jsxs)(`span`,{className:`mono ${dM}`,children:[ee>0&&(0,V.jsx)(`span`,{className:`text-error`,children:lL(t.needAttention,{count:String(ee),total:String(O.length)})}),(0,V.jsx)(`span`,{className:`text-muted`,children:l?.keepsDaemonAlive?t.holdingDaemon:t.notHolding}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.header}`,onClick:()=>void ce(),children:z(`pages.new`)})]})]}),l===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.loading}):O.length===0?(0,V.jsxs)(`div`,{className:pM,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:t.empty}),(0,V.jsx)(`p`,{className:`keys-only`,children:t.emptyHint})]}):(0,V.jsxs)(`div`,{className:jB,children:[(0,V.jsx)(`div`,{className:MB,ref:F,children:D.map(e=>e.rows.length===0?null:(0,V.jsxs)(`section`,{children:[(0,V.jsxs)(`h2`,{className:`${U} ${NB} ${e===D[0]?`text-error`:`text-muted`}`,children:[z(e.key),` `,(0,V.jsx)(`span`,{className:`mono`,children:e.rows.length})]}),e.rows.map(e=>{let n=O.indexOf(e),r=w[e.id],i=r?gV(r):null;return(0,V.jsxs)(`div`,{"data-row":n,className:PB(n===k),onClick:()=>{j(n),te(e=>e+1)},children:[(0,V.jsxs)(`span`,{className:FB,children:[(0,V.jsx)(`span`,{className:IB(!e.enabled),children:e.name}),(0,V.jsx)(`span`,{className:`mono text-muted ${LB}`,children:e.enabled?re(e.nextRunAt):t.paused}),(0,V.jsx)(`span`,{className:`mono ${i?mV[i]:`text-muted`}`,style:{width:`1ch`},children:i?hV[i]:` `})]}),(0,V.jsx)(`span`,{className:`mono text-muted ${RB}`,title:e.schedule,children:`${fe(e.repo)} · ${SB(e.schedule,b)??e.schedule}`}),T[e.id]?(0,V.jsx)(`span`,{className:`mono text-warning ${RB}`,title:T[e.id]?.reason,children:lL(t.lastFailed,{when:re(T[e.id]?.at),reason:T[e.id]?.reason??``})}):null]},e.id)})]},e.key))}),(0,V.jsx)(`div`,{className:zB,ref:S,children:A?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:BB,children:[(0,V.jsx)(`h2`,{className:VB,children:A.name}),(0,V.jsxs)(`span`,{className:`mono ${dM}`,children:[(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.row}`,disabled:p===A.id,onClick:()=>void se(),children:t.runNow}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.row}`,disabled:p===A.id,onClick:()=>void oe(),children:z(A.enabled?`pages.routinePause`:`pages.routineEnable`)}),(0,V.jsx)(`button`,{type:`button`,className:`${Xt} ${fM.row}`,disabled:p===A.id,onClick:le,children:z(`pages.delete`)})]})]}),(0,V.jsxs)(`dl`,{className:HB,children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineSchedule`)}),(0,V.jsxs)(`dd`,{children:[de??(0,V.jsx)(`span`,{className:`mono`,children:A.schedule}),de&&(0,V.jsx)(`span`,{className:`mono text-muted`,children:` ${A.schedule}`})]}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineNext`)}),(0,V.jsx)(`dd`,{className:A.enabled?``:`text-warning`,children:A.enabled?Number.isFinite(pe)?`${re(A.nextRunAt)} · ${new Date(pe).toLocaleString(x,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}`:`—`:t.paused}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineProject`)}),(0,V.jsx)(`dd`,{children:fe(A.repo)}),!A.script&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineDelivers`)}),(0,V.jsx)(`dd`,{children:ue?lL(t.targetExisting,{task:ie(ue.taskId),tab:ue.tabId}):A.persistentSession?t.targetStanding:t.targetFresh})]})]}),A.precheck&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:lL(t.precheck,{command:A.precheck.command})}),A.script?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routineScript`)}),(0,V.jsx)(`p`,{className:`mono ${UB}`,children:A.script.command})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routinePrompt`)}),(0,V.jsx)(`p`,{className:UB,children:A.prompt})]}),(0,V.jsx)(xV,{c:r,tick:i,routines:C,followId:A.id,now:ne,when:re,openRun:R}),(0,V.jsx)(_V,{runs:P,when:re})]}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.noSelection})})]}),h&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:h})]})}var wV=`flex min-w-0 items-baseline gap-2.5 font-mono text-meta whitespace-nowrap`,TV=`${wV} w-full cursor-pointer border-none bg-transparent p-0 text-left text-inherit [font:inherit] [&:hover]:underline`,EV=`w-[5ch] flex-none text-muted`,DV=`w-[16ch] flex-none overflow-hidden text-accent`,OV=`mt-3.5 mb-0.5`,kV=`min-w-0 flex-1 truncate`,AV=`flex-none text-right text-muted`,jV=`${AV} min-w-[5ch]`,MV=`${AV} min-w-[4ch]`,NV=`${AV} min-w-[5ch]`,PV=`w-[8ch] flex-none overflow-hidden text-accent`,FV=`flex flex-wrap gap-x-3 font-mono text-meta text-muted`,IV=`m-0 text-meta text-muted`,LV={turns:0,tokens:0,ms:0},RV=e=>(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0),zV=e=>Math.max(0,e.endedAt-e.startedAt),BV=(e,t)=>({turns:e.turns+1,tokens:e.tokens+RV(t),ms:e.ms+zV(t)});function VV(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function HV(e,t,n,r){let i=[];for(let e=n-1;e>=0;e--){let n=new Date(t);n.setDate(n.getDate()-e),i.push(VV(n.getTime()))}let a=new Map(i.map(e=>[e,{sum:LV,byEngine:{}}]));for(let t of e){let e=a.get(VV(t.startedAt));if(!e)continue;let n=t.vendor??`unknown`;e.sum=BV(e.sum,t),e.byEngine[n]=(e.byEngine[n]??0)+RV(t)}let o=e.reduce((e,t)=>Math.min(e,t.startedAt),1/0),s=e.length>=r&&Number.isFinite(o)?{count:e.length,day:VV(o)}:null;return{cutoff:s,days:i.map(e=>{let t=a.get(e);return{day:e,...t?.sum??LV,byEngine:t?.byEngine??{},partial:s!==null&&e<=s.day}})}}function UV(e){let t=new Map;for(let n of e){let e=n.vendor??`unknown`,r=n.model??`unknown`,i=`${e}\0${r}`;t.set(i,{engine:e,model:r,...BV(t.get(i)??LV,n)})}return[...t.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns)}function WV(e,t){let n=new Map;for(let t of e)n.set(t.taskId,{taskId:t.taskId,...BV(n.get(t.taskId)??LV,t)});return[...n.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns).slice(0,t)}function GV(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4)).replace(/\.0$/,``)}k`:`${(e/1e6).toFixed(+(e<1e7)).replace(/\.0$/,``)}M`}var KV=[``,`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`];function qV(e,t,n){if(e<=0||t<=0)return``;let r=Math.max(1,Math.round(e/t*n*8));return`${`█`.repeat(Math.floor(r/8))}${KV[r%8]}`}var JV=[`█`,`▓`,`▒`,`░`];function YV(e,t,n,r){return n<=0?``:t.map((t,i)=>{let a=e[t]??0,o=a<=0?0:Math.max(1,Math.round(a/n*r));return(JV[i%JV.length]??`█`).repeat(o)}).join(``)}var XV=.1,ZV=/^(\d+)\s*(h|d)$/;function QV(e,t){let n=ZV.exec(e.label.trim());if(!n||e.resetsAt===null||e.percent<=0)return null;let r=Number(n[1])*(n[2]===`d`?24:1)*36e5,i=r-(e.resetsAt-t);if(!(i>=r*XV)||i>r)return null;if(e.percent>=100)return{kind:`full`,at:t};let a=t+(100-e.percent)/e.percent*i;return a<e.resetsAt?{kind:`full`,at:a}:{kind:`lasts`}}var $V=14,eH=500,tH=3e4,nH=16,rH=8,iH=8;function aH(e,t,n,r){let i=Ns(e,t,n),[a,o]=(0,g.useState)(i?{kind:`ready`,value:i}:{kind:`loading`}),s=JSON.stringify(n);return(0,g.useEffect)(()=>{let r=!0;return Fs(e,t,n).then(e=>r&&o({kind:`ready`,value:e})).catch(e=>r&&o(t=>t.kind===`ready`?t:{kind:`failed`,error:dL(e)})),()=>{r=!1}},[e,t,s,r]),a}var oH=e=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`${jV}`,children:GV(e.tokens)}),(0,V.jsx)(`span`,{className:`${MV}`,children:`${e.turns}t`}),(0,V.jsx)(`span`,{className:`${NV}`,children:sV(e.ms)})]});function sH({usage:e,nameOf:t}){let n=Date.now(),r=e.flatMap(e=>e.windows.map(r=>{let i={engine:e.name||t(e.vendor),label:r.label,percent:Math.round(r.percent)},a=QV(r,n);if(a?.kind===`full`){let t=a.at-n<72e6,o=new Date(a.at).toLocaleString([],{...t?{}:{weekday:`short`},hour:`2-digit`,minute:`2-digit`});return{key:`${e.vendor}:${r.kind}`,text:lL(z(`usage.full`),{...i,time:o})}}return{key:`${e.vendor}:${r.kind}`,text:lL(z(a?`usage.lasts`:`usage.window`),i)}}));return r.length===0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${OV}`,children:z(`usage.quota`)}),r.map(e=>(0,V.jsx)(`p`,{className:`mono ${IV}`,children:e.text},e.key))]})}function cH({row:e,title:t,open:n}){let r=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:kV,children:t}),oH(e)]});return n?(0,V.jsx)(H,{variant:`row`,className:TV,onClick:n,children:r}):(0,V.jsx)(`div`,{className:wV,children:r})}function lH({model:e}){B();let t=bL(),[n]=_L(tH),r=aH(e,`turns.list`,{sinceDays:$V,limit:eH},n),i=aH(e,`engines.list`,{},n),a=aH(e,`usage.get`,{},n),o=v(e.tasks),s=i.kind===`ready`?i.value.engines:[],c=e=>s.find(t=>t.id===e)?.name??e,l=e=>o?.tasks.find(t=>t.id===e)?.label??z(`usage.removedTask`);return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:t,onKeyDown:e=>{e.metaKey||e.ctrlKey||e.altKey||e.key!==`q`&&e.key!==`Escape`||(e.preventDefault(),on.set(null))},children:[(0,V.jsx)(`h1`,{className:cM,children:z(`usage.title`)}),(()=>{if(r.kind===`loading`)return(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.loading`)});if(r.kind===`failed`)return(0,V.jsx)(`p`,{className:`text-error`,children:lL(z(`usage.failed`),{error:r.error})});let t=r.value.turns,n=new Set(r.value.readers??[]),i=HV(t,Date.now(),$V,eH),s=new Map;for(let e of i.days)for(let[t,n]of Object.entries(e.byEngine))s.set(t,(s.get(t)??0)+n);let u=[...s].sort((e,t)=>t[1]-e[1]).map(([e])=>e),d=Math.max(0,...i.days.map(e=>e.tokens)),f=UV(t),p=Math.max(0,...f.map(e=>e.tokens)),m=[...new Set((o?.tasks??[]).flatMap(e=>e.engine?.id&&!n.has(e.engine.id)?[e.engine.id]:[]))];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:IV,children:lL(z(`usage.range`),{days:$V})}),t.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.empty`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${OV}`,children:z(`usage.perDay`)}),(0,V.jsx)(`div`,{className:FV,children:u.map((e,t)=>(0,V.jsx)(`span`,{children:`${JV[t%JV.length]} ${c(e)}`},e))}),i.days.map(e=>(0,V.jsxs)(`div`,{className:wV,children:[(0,V.jsx)(`span`,{className:EV,children:`${e.day.slice(5)}${e.partial?`~`:``}`}),(0,V.jsx)(`span`,{className:DV,children:YV(e.byEngine,u,d,nH)}),oH(e)]},e.day)),i.cutoff&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:lL(z(`usage.cutoff`),{count:i.cutoff.count,day:i.cutoff.day.slice(5)})}),(0,V.jsx)(`h2`,{className:`${U} text-muted ${OV}`,children:z(`usage.byModel`)}),f.map(e=>(0,V.jsxs)(`div`,{className:wV,children:[(0,V.jsx)(`span`,{className:kV,title:`${c(e.engine)} · ${e.model}`,children:`${c(e.engine)} · ${e.model}`}),(0,V.jsx)(`span`,{className:PV,children:qV(e.tokens,p,rH)}),oH(e)]},`${e.engine}\0${e.model}`)),(0,V.jsx)(`h2`,{className:`${U} text-muted ${OV}`,children:z(`usage.topTasks`)}),WV(t,iH).map(t=>(0,V.jsx)(cH,{row:t,title:l(t.taskId),open:o?.tasks.some(e=>e.id===t.taskId)?()=>{on.set(null),e.select(t.taskId)}:null},t.taskId))]}),m.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:lL(z(`usage.noReader`),{engines:m.map(c).join(`, `)})}),a.kind===`ready`&&a.value.usage&&(0,V.jsx)(sH,{usage:a.value.usage,nameOf:c})]})})()]})}var uH={id:`mods`,label:`mods`},dH=[{id:`kanban`,label:`kanban`,mod:`kanban`},{id:`routines`,label:`automations`},{id:`issues`,label:`issues`,mod:`issues`}];function fH({model:e}){let{nav:t}=cL(),n=v(on),r=v(e.mods).length>0,i=v(e.installedMods),a=[...dH.filter(e=>!e.mod||i.has(e.mod)),...r?[uH]:[]];return(0,V.jsxs)(`div`,{className:yM,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${xM(!1)}`,onClick:()=>KD(),children:[z(`rail.newTask`),(0,V.jsx)(`span`,{className:SM,"aria-hidden":`true`,children:`+`})]}),a.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`rail-nav-row ${xM(n===e.id)}`,"aria-current":n===e.id?`page`:void 0,onClick:()=>ha(e.id),children:t[e.label]},e.id))]})}function pH({model:e,page:t}){(0,g.useEffect)(()=>e.selection.subscribe(()=>on.set(null)),[e]);let n=v(e.installedMods);return t===`kanban`&&n.has(`kanban`)?(0,V.jsx)(Ez,{model:e}):t===`routines`?(0,V.jsx)(CV,{model:e}):t===`issues`&&n.has(`issues`)?(0,V.jsx)(_R,{model:e}):t===`mods`?(0,V.jsx)(Uz,{model:e}):t===`compare`?(0,V.jsx)(aR,{model:e}):t===`usage`?(0,V.jsx)(lH,{model:e}):null}var mH=p();function hH(e){return e?.match(/^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/(?:pull|merge_requests|-\/merge_requests)\//)?.[1]}var gH=e=>e.charAt(0).toUpperCase()+e.slice(1);function _H(e){return[z(`rail.pr.state.${e.state}`),...e.checks?[z(`rail.pr.checks.${e.checks}`)]:[]].join(`, `)}function vH(e){let t=new Map;for(let n of e){let e=qF(n),r=[...e&&n.pr?[{pr:n.pr,mark:e}]:[],...(n.sessionPrs??[]).flatMap(e=>{let t=JF(e);return t?[{pr:e,mark:t}]:[]})];for(let{pr:e,mark:i}of r){let r=e.url??(e.number===void 0?n.id:`${n.repo}#${e.number}`),a=t.get(r),o=e.lifecycle===`unknown`,s=a?.pr.lifecycle===`unknown`;(!a||s&&!o||o===s&&YF([a.mark,i])!==a.mark)&&t.set(r,{task:n,pr:e,mark:i})}}return[...t.values()]}function yH({tasks:e,onOpen:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=(0,g.useRef)(null),l=Ko();(0,g.useLayoutEffect)(()=>{let e=c.current;if(!e||!n)return;let t=e.getBoundingClientRect();t.right>window.innerWidth-8&&(e.style.left=`${Math.max(8,window.innerWidth-t.width-8)}px`,e.style.top=`${n.bottom+6}px`);let r=e.getBoundingClientRect().bottom-(window.innerHeight-8);r>0&&(e.style.top=`${Math.max(8,e.getBoundingClientRect().top-r)}px`)},[n]);let u=()=>{t?.(),s.current!==null&&window.clearTimeout(s.current),s.current=null,a(!1),o.current&&!n&&r(o.current.getBoundingClientRect())},d=()=>{a(!0),s.current=window.setTimeout(()=>r(null),140)};(0,g.useEffect)(()=>{if(!l||!n)return;let e=e=>{let t=e.target;o.current?.contains(t)||c.current?.contains(t)||(a(!0),s.current=window.setTimeout(()=>r(null),140))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[l,n]),(0,g.useEffect)(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);let f=vH(e),p=YF(f.map(e=>e.mark));if(!p)return null;let m=f.length===1?`PR #${f[0]?.pr.number??``}, ${_H(p)}`:z(`rail.pr.many`,{count:f.length});return(0,V.jsxs)(`span`,{ref:o,className:`chip ${JT} ${p.tone}`,"aria-label":m,onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>{l&&(e.stopPropagation(),n&&!i?d():u())},children:[p.glyph,f.length>1&&(0,V.jsx)(`span`,{className:`font-sans`,children:f.length}),n&&(0,mH.createPortal)((0,V.jsx)(`div`,{ref:c,className:YT(i),style:{top:n.top-6,left:n.right+8},onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onContextMenu:e=>e.stopPropagation(),children:f.map(({task:e,pr:t,mark:n})=>{let r=hH(t?.url),i=t?.additions!==void 0&&t.deletions!==void 0;return(0,V.jsxs)(`button`,{type:`button`,className:`flex flex-col gap-1 rounded-[calc(var(--radius)-6px)] px-3 py-2 text-left font-sans enabled:hover:bg-hover`,disabled:!t?.url,onClick:()=>t?.url&&window.open(t.url,`_blank`,`noopener`),children:[(0,V.jsx)(`span`,{className:`truncate font-semibold text-ink`,children:t.title||e.label}),(0,V.jsxs)(`span`,{className:`flex items-baseline gap-0 text-meta leading-[inherit] whitespace-nowrap`,children:[(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.25 ${n.tone}`,children:[(0,V.jsx)(`span`,{className:`font-mono`,children:n.glyph}),gH(z(`rail.pr.state.${n.state}`))]}),(0,V.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-pre text-muted`,children:[...n.checks?[z(`rail.pr.checks.${n.checks}`)]:[],[r,t?.number===void 0?``:`#${t.number}`].filter(Boolean).join(` `)].filter(Boolean).map(e=>`, ${e}`).join(``)}),i&&(0,V.jsxs)(`span`,{className:`ml-auto flex gap-1.5 pl-3 tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions]}),(0,V.jsxs)(`span`,{className:`text-error`,children:[`−`,t.deletions]})]})]})]},t.url??`${e.id}#${t.number??``}`)})}),document.body)]})}var bH=`~archived`;function xH(e,t,n,r){let i=t.filter(e=>!e.routine);if(i.length===0)return e;let a={id:bH,kind:`archived`,count:i.length,expanded:n};if(!n)return[...e,a];let o=mw([{repo:``,label:``,key:bH,tasks:i}],``,r,1,!1);return[...e,a,...o.filter(e=>e.kind!==`project`)]}function SH(e,t,n){let r=t.kind===`main`,i=e=>r?e.kind===`main`:e.kind!==`main`&&e.repo===t.repo&&!e.pinned==!t.pinned;if(t.id===n.id||!i(n))return null;let a=e.filter(i).sort((e,t)=>(e.order??e.rank)-(t.order??t.rank)).map(e=>e.id);return a.indexOf(n.id)-a.indexOf(t.id)}function CH(e,t,n,r){let i=SH(e,t,n);return i===null?null:r===`above`&&i>0?i-1:r===`below`&&i<0?i+1:i}function wH(e,t){return e.id===t.id?!1:e.kind===`main`?t.kind===`main`:t.kind!==`main`&&t.repo===e.repo}function TH(e,t,n,r,i){if(!wH(t,n))return null;if(t.kind===`main`){let i=CH(e,t,n,r);return i?{steps:i}:null}let a=n.pinned===!0||i&&r===`above`,o={...t,pinned:a},s=a===(n.pinned===!0)?CH(e.map(e=>e.id===t.id?o:e),o,n,r)??0:0,c=a===(t.pinned===!0)?{}:{pin:a};return`pin`in c||s!==0?{...c,steps:s}:null}var EH=e=>e===void 0||e.kind===`project`||e.kind===`state`?0:e.kind===`task`||e.kind===`pane`||e.kind===`round`?e.depth:1;function DH(e,t){let n=EH(e[t]),r=t+1;for(;r<e.length&&EH(e[r])>n;)r++;return r}function OH(e,t,n){let r=e.findIndex(e=>e.id===t),i=r<0?e:[...e.slice(0,r),...e.slice(DH(e,r))];for(let e=i.findIndex(e=>e.id===n)-1;e>=0;e--){let t=i[e];if(!t||t.kind===`project`||t.kind===`state`)return!0;if(t.kind===`task`&&t.depth===1&&t.task.kind!==`main`||t.kind===`round`&&t.depth===1)return!1}return!1}function kH(e,t){let n=EH(e[t]),r=[];for(let i=2;i<=n;i++){let a=t+1;for(;a<e.length&&EH(e[a])>i;)a++;let o=a<e.length&&EH(e[a])===i;r.push(i===n?o?`tee`:`elbow`:o?`pipe`:`blank`)}return r}function AH(e,t,n,r){let i=e.findIndex(e=>e.id===t);if(i<0||t===n)return e;let a=DH(e,i),o=e.slice(i,a),s=[...e.slice(0,i),...e.slice(a)],c=s.findIndex(e=>e.id===n);if(c<0)return e;let l=r===`above`?c:DH(s,c);return[...s.slice(0,l),...o,...s.slice(l)]}function jH(e,t,n,r,i){let[a,o]=(0,g.useState)(null),s=(0,g.useRef)(t);s.current=t;let[c,l]=(0,g.useState)(null),u=(0,g.useRef)(()=>o(null));(0,g.useEffect)(()=>{if(!c)return;let e=()=>{l(null),u.current()};if(t!==c)return e();let n=window.setTimeout(e,3e3);return()=>window.clearTimeout(n)},[t,c]);let d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=()=>[...d.current?.querySelectorAll(`[data-row]`)??[]];(0,g.useLayoutEffect)(()=>{let e=f.current;if(!e||(f.current=null,window.matchMedia(`(prefers-reduced-motion: reduce)`).matches))return;let t=p().flatMap(t=>{let n=e.get(t.dataset.row??``),r=n===void 0?0:n-t.getBoundingClientRect().top;return r?[{el:t,dy:r}]:[]});for(let{el:e,dy:n}of t)e.style.transition=`none`,e.style.transform=`translateY(${n}px)`;d.current?.getBoundingClientRect();for(let{el:e}of t)e.style.transition=`transform 150ms ease-out`,e.style.transform=``,e.addEventListener(`transitionend`,()=>e.style.removeProperty(`transition`),{once:!0})});let m=(0,g.useRef)(null),h=(0,g.useRef)([]),_=(0,g.useRef)(new Map),v=(0,g.useRef)(0),y=(0,g.useRef)(0),b=e=>{m.current=e,o(e)},x=e=>!n||e.machine!==void 0?null:e.kind===`project`?t.find(t=>t.id===i(e.repo).mainTaskId)??null:e.kind===`task`&&e.depth===1&&e.task.kind!==`main`?e.task:null,S=e=>{let t=x(e);if(t)return{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t.id),d.current=n.currentTarget.closest(`[data-rail-body]`),T(d.current);let r=h.current,i=r.findIndex(t=>t.id===e.id);v.current=r.slice(i,DH(r,i)).reduce((e,t,n)=>e+(_.current.get(t.id)?.height??0)+(n>0?_.current.get(t.id)?.gap??0:0),0),y.current=n.clientY,b({fromRow:e.id,from:t,toRow:e.id,to:t,side:`above`})},onDragEnd:()=>m.current&&b(null)}},C=(e,t,n)=>{let r=t;if(n.from.kind===`main`)for(;r>0&&e[r]?.kind!==`project`;)r--;let i=e[r],a=i&&x(i);return!i||!a||!wH(n.from,a)?null:{row:i.id,task:a}},w={onDragOver:e=>{let t=m.current;if(!t)return;e.preventDefault();let n=e.clientY-y.current;y.current=e.clientY;let r=e.target.closest(`[data-row]`)?.dataset.row,i=h.current,a=C(i,i.findIndex(e=>e.id===r),t);if(!a||a.row===t.fromRow)return;let o=e.currentTarget.querySelector(`[data-row="${CSS.escape(t.fromRow)}"]`)?.getBoundingClientRect().top;if(o===void 0||e.clientY>=o&&e.clientY<o+v.current)return;let s=e.clientY<o?`above`:`below`;(s===`above`?n>=0:n<=0)||(t.toRow!==a.row||t.side!==s)&&b({...t,toRow:a.row,to:a.task,side:s})},onDrop:n=>{let i=m.current;if(!i)return;n.preventDefault();let a=TH(t,i.from,i.to,i.side,OH(h.current,i.fromRow,i.toRow));m.current=null,r?u.current=()=>o(null):u.current=()=>{f.current=new Map(p().map(e=>[e.dataset.row??``,e.getBoundingClientRect().top])),o(null),FT(`default`),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.default`)}))},a?HT(e,i.from.id,a).finally(()=>l(s.current)):u.current()}},T=e=>{let t=[...e?.querySelectorAll(`[data-row]`)??[]];_.current=new Map(t.map((e,n)=>{let r=t[n-1],i=r?e.offsetTop-r.offsetTop-r.offsetHeight:0;return[e.dataset.row??``,{top:e.offsetTop,gap:i,height:e.offsetHeight}]}))},E=e=>{h.current=a?AH(e,a.fromRow,a.toRow,a.side):e;let t=new Map;if(!a)return t;let n=Math.min(...[..._.current.values()].map(e=>e.top));for(let[e,r]of h.current.entries()){let i=_.current.get(r.id);if(!i)return new Map;e>0&&(n+=i.gap),n!==i.top&&t.set(r.id,n-i.top),n+=i.height}return t};return{props:S,body:w,dragging:a?.fromRow??null,places:e=>{let t=E(e);return e=>{let n=t.get(e.id);return n?{"data-row":e.id,style:{transform:`translateY(${n}px)`}}:{"data-row":e.id}}}}}function MH({model:e,narrow:t,onSettings:n}){B();let r=v(e.selection),i=v(yN),a=$(`engines.skill.bannerHintWeb`,{engines:i.join(`, `)});return(0,V.jsxs)(V.Fragment,{children:[!t&&(0,V.jsx)(AP,{client:e.client,taskId:r.taskId,tabId:r.tabId}),(0,V.jsxs)(`div`,{className:bM,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${xM(!1)}`,onClick:n,children:[(0,V.jsxs)(`svg`,{className:CM,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,V.jsx)(`span`,{children:z(`rail.settings`)}),i.length>0&&(0,V.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-meta text-subtle`,title:a,children:z(`rail.skillCue`)})]}),(0,V.jsx)(xF,{model:e,bindingId:`settings.open`})]})]})}function NH(e,t,n,r,i=null){let a=e=>e.kind===`task`&&e.task.kind===`main`&&e.fold===void 0&&e.task.id!==n&&e.task.id!==i&&(r?t[e.task.id]?.length===0:(t[e.task.id]?.length??0)===0),o=e.filter(e=>!a(e));return o.filter((e,t)=>{if(e.kind!==`project`&&e.kind!==`state`)return!0;let n=o[t+1];return n!==void 0&&n.kind!==`project`&&n.kind!==`state`})}var PH=_({});function FH(e,t,n){let r=PH.get()[`${e}::${t.id}`];return r&&r.sig===Ew(n)&&yw(n.root).some(e=>e.id===r.leaf)?r.leaf:n.activeLeafId}function IH(e,t,n,r){PH.set({...PH.get(),[`${e}::${t}`]:{sig:Ew(n),leaf:r}})}function LH(e,t,n,r){IH(e,t.id,n,r),ia(yC(e,t.id,r))?.focus()}function RH(e){let{taskId:t,tabId:n}=e.selection.get(),r=t?e.tabs.get()[t]?.find(e=>e.id===n):void 0;return t&&r?{taskId:t,tab:r}:null}async function zH(e,t,n){try{let r=await e.client.request(`tab.split`,t);await e.refreshTabsNow(),n?.(r)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}function BH(e,t,n,r,i){let a=i??(n.split?FH(t,n,n.split):`leaf-1`),o=e.selection.get();(o.taskId!==t||o.tabId!==n.id)&&e.select(t,n.id);let s=ia(yC(t,n.id,a))?.size();zH(e,{taskId:t,tabId:n.id,action:`open`,direction:r,leafId:a,...s},e=>{e.changed?e.split&&IH(t,n.id,e.split,e.leaf):G(z(`layout.splitTooSmall`),`error`)})}function VH(e,t,n,r){let i=n.split,a=i?FH(t,n,i):r,o=()=>zH(e,{taskId:t,tabId:n.id,action:`close`,leafId:r},e=>{let i=e.split;if(!i)return;let o=a!==r&&yw(i.root).some(e=>e.id===a);IH(t,n.id,i,o?a:i.activeLeafId)});if(!i||!ww(n,i,r)){o();return}W.set((0,V.jsx)(sr,{title:z(`confirm.closePaneTitle`,{pane:Cw(i,_w(n)).get(r)??r}),body:z(`confirm.closePaneBody`),confirmLabel:z(`menu.closePane`),onConfirm:o}))}function HH(e,t,n,r){let i=n.split;i&&W.set((0,V.jsx)(or,{title:yo(`split.renameTitle`),initial:Cw(i,_w(n)).get(r)??``,allowEmpty:!0,submitLabel:z(`dialog.save`),onSubmit:i=>zH(e,{taskId:t,tabId:n.id,action:`rename`,leafId:r,title:i})}))}function UH(e,t,n,r){return[{label:z(`menu.renamePane`),section:`split`,key:eo(`workspace.split.rename`)??void 0,run:()=>HH(e,t,n,r)},{label:z(`menu.closePane`),section:`split`,key:ti(`workspace.split.close`)||void 0,run:()=>VH(e,t,n,r)}]}function WH(e,t,n,r){return[{label:z(`menu.splitRight`),section:`split`,key:eo(`workspace.split.right`)??void 0,run:()=>BH(e,t,n,`right`,r)},{label:z(`menu.splitDown`),section:`split`,key:eo(`workspace.split.down`)??void 0,run:()=>BH(e,t,n,`down`,r)}]}function GH(e,t,n,r){let i=n.split,a=r??(i?FH(t,n,i):`leaf-1`);return[...WH(e,t,n,a),...bw(i)?UH(e,t,n,a):[]]}function KH(e,t){let n=e.tabs.get()[t]??[],r=e.selection.get(),i=(r.taskId===t?n.find(e=>e.id===r.tabId):void 0)??Li(n);return!i||!Tw(i)?[]:WH(e,t,i,i.split?FH(t,i,i.split):`leaf-1`)}function qH(e,{task:t,tab:n,leaf:r}){n.split&&LH(t.id,n,n.split,r),e.select(t.id,n.id)}function JH(e){let{row:t}=e,n=v(e.model.selection);v(PH);let r=n.taskId===t.task.id&&n.tabId===t.tab.id&&!!t.tab.split&&FH(t.task.id,t.tab,t.tab.split)===t.leaf;return(0,V.jsxs)(`button`,{type:`button`,className:`${Qn({size:`pane`})} ${e.cursor?iE:``}`,"aria-current":r||void 0,onClick:e.onClick,onContextMenu:e.onMenu,...e.place,children:[(0,V.jsx)(`span`,{className:UT,"aria-hidden":`true`,children:e.guides?.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${$n} text-(length:--fs-meta) ${r?`text-ink`:`text-muted`}`,children:t.label})]})}function YH(e,t){let n=t?.trim()??``;return n&&e?.effortLevels?.includes(n)?n:``}function XH({model:e,taskId:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)({}),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1),{busy:m,error:h,submit:_}=ar();(0,g.useEffect)(()=>{Promise.all([e.client.request(`engines.list`),e.client.request(`task.get`,{taskId:t})]).then(([e,t])=>{let n=ms(e.engines,t.task.engine).filter(e=>e.ready!==!1||e.id===t.task.engine),i=n.find(e=>e.id===t.task.engine)??n[0];r(n),a(t.task),s(i?.id??``),l(YH(i,t.task.effort)),d(i?.id===t.task.engine?t.task.model??``:``),p(!0)})},[e,t]);let v=n.find(e=>e.id===o),y=v?.effortLevels??[],b=y.length>0?[``,...y]:[],x=(v?.models??[]).map(e=>e.id).filter(e=>e.toLowerCase().includes(u.trim().toLowerCase())&&e!==u.trim()).slice(0,6),S=e=>{s(e);let t=n.find(t=>t.id===e);l(YH(t,e===i.engine?i.effort:void 0)),d(e===i.engine?i.model??``:``)},C=e=>{let t=n.findIndex(e=>e.id===o),r=n[Math.max(0,Math.min(n.length-1,t+e))];r&&S(r.id)},w=e=>{if(b.length===0)return;let t=Math.max(0,b.indexOf(c));l(b[Math.max(0,Math.min(b.length-1,t+e))]??``)},T=e=>{let t=e.target instanceof HTMLInputElement;if(e.key===`ArrowUp`&&!t)C(-1);else if(e.key===`ArrowDown`&&!t)C(1);else if((e.key===`ArrowLeft`||e.key===`h`)&&!t)w(-1);else if((e.key===`ArrowRight`||e.key===`l`)&&!t)w(1);else return;e.preventDefault()},E=()=>_(async()=>{if(!v)return;let n=y.length>0?c:void 0,r=v.acceptsModel?u.trim():void 0;(v.id!==i.engine||n!==void 0&&n!==(i.effort??``)||r!==void 0&&r!==(i.model??``))&&(await e.client.request(`task.setEngine`,{taskId:t,engine:v.id,...n===void 0?{}:{effort:n},...r===void 0?{}:{model:r}}),G(q(`tasks`,`toast.engineSwitched`,{engine:v.name})))});return(0,V.jsx)(ir,{title:q(`tasks`,`changeEngine.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Pn,onKeyDown:T,onSubmit:e=>{e.preventDefault(),E()},children:[(0,V.jsx)(`ul`,{className:On,"aria-label":q(`tasks`,`changeEngine.title`),children:n.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===o,className:Qn({selected:e.id===o}),onClick:()=>S(e.id),children:[(0,V.jsx)(`span`,{className:`${nr} text-accent`,children:e.id===o?`●`:` `}),(0,V.jsx)(`span`,{className:$n,children:e.name}),e.id===i.engine&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`tasks`,`changeEngine.current`)})]})},e.id))}),f&&v&&v.acceptsModel&&(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`engineModel.label`)}),(0,V.jsx)(`input`,{className:Qt,spellCheck:!1,placeholder:q(`tasks`,`engineModel.placeholder`),value:u,onChange:e=>d(e.target.value)}),x.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:x.map(e=>(0,V.jsx)(`button`,{type:`button`,className:Dn(),onClick:()=>d(e),children:e},e))})]}),b.length>0&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`changeEngine.effortLabel`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(e=>(0,V.jsx)(`button`,{type:`button`,"aria-pressed":e===c,className:Dn(e===c),onClick:()=>l(e),children:e===``?q(`tasks`,`changeEngine.noEffort`):e},e||`default`))})]}),(0,V.jsx)(`p`,{className:`keys-only ${Gt}`,children:(0,V.jsx)(ST,{text:[q(`tasks`,`changeEngine.footer.engine`),...v?.acceptsModel?[q(`tasks`,`changeEngine.footer.model`)]:[],...b.length>0?[q(`tasks`,`changeEngine.footer.effort`)]:[],q(`tasks`,`changeEngine.footer.set`),q(`tasks`,`changeEngine.footer.cancel`)].join(` · `)})}),h&&(0,V.jsx)(`p`,{className:`text-error`,children:h}),(0,V.jsx)(lr,{busy:m||!f,submitLabel:z(`taskops.set`)})]})})}function ZH({model:e,task:t}){let[n,r]=(0,g.useState)(()=>Ns(e,`task.get`,{taskId:t.id})?.task??null),[i,a]=(0,g.useState)(null),{busy:o,error:s,submit:c}=ar();(0,g.useEffect)(()=>{Fs(e,`task.get`,{taskId:t.id}).then(e=>r(e.task)).catch(e=>a(K(e)))},[e,t.id]);let l=()=>c(async()=>{if(!n?.prompt)return;let t=(await e.client.request(`task.spawn`,{repo:n.repo,prompt:n.prompt,...n.engine?{engine:n.engine}:{},...n.baseRef?{baseBranch:n.baseRef}:{}})).taskIds[0];t&&e.selectWhenListed(t)});return(0,V.jsx)(ir,{title:q(`tasks`,`runAgain.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Pn,onSubmit:e=>{e.preventDefault(),l()},children:[(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`runAgain.source`,{title:t.label})}),(0,V.jsx)(`pre`,{className:Kt,children:n?.prompt??i??q(`tasks`,`fieldNotes.loading`)}),(0,V.jsx)(`p`,{className:Gt,children:q(`tasks`,`runAgain.hint`)}),s&&(0,V.jsx)(`p`,{className:`text-error`,children:s}),(0,V.jsx)(lr,{busy:o||!n?.prompt,submitLabel:q(`tasks`,`runAgain.confirm`)})]})})}function QH(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function $H({model:e,repo:t}){let[n,r]=(0,g.useState)({kind:`loading`}),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=()=>e.client.request(`notes.list`,{repo:t}).then(e=>r({kind:`ready`,notes:e.notes})).catch(e=>r({kind:`error`,message:K(e)}));(0,g.useEffect)(()=>void d(),[]);let f=n.kind===`ready`?n.notes:[];(0,g.useEffect)(()=>a(e=>Math.max(0,Math.min(e,f.length-1))),[f.length]),(0,g.useEffect)(()=>{u.current?.querySelector(`.is-selected`)?.scrollIntoView({block:`nearest`})},[i]);let p=async n=>{if(n.id!==void 0){l(null);try{await e.client.request(`notes.delete`,{repo:t,id:n.id}),s(null),await d()}catch(e){l(K(e))}}};return(0,V.jsx)(ir,{title:q(`tasks`,`fieldNotes.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:Pn,onKeyDown:e=>{if(!o){if(e.key===`ArrowDown`||e.key===`j`)a(e=>Math.min(f.length-1,e+1));else if(e.key===`ArrowUp`||e.key===`k`)a(e=>Math.max(0,e-1));else if(e.key===`d`&&f[i]?.id!==void 0)s(f[i]??null);else return;e.preventDefault()}},children:[(0,V.jsx)(`p`,{className:`font-mono text-meta break-all text-muted`,children:t}),n.kind===`loading`&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.loading`)}),n.kind===`error`&&(0,V.jsx)(`p`,{className:`text-error`,children:n.message}),n.kind===`ready`&&f.length===0&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.empty`)}),f.length>0&&(0,V.jsx)(`ul`,{className:`m-0 list-none p-0 flex max-h-[44vh] flex-col gap-2 overflow-y-auto`,ref:u,children:f.map((e,t)=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:qt(t===i),onClick:()=>a(t),autoFocus:t===0,children:[(0,V.jsxs)(`span`,{className:`font-mono text-meta whitespace-pre text-accent`,children:[t===i?`▸ `:` `,QH(e.at),`, `,e.author]}),(0,V.jsx)(`span`,{className:`text-ink whitespace-pre-wrap wrap-anywhere`,children:e.text})]})},`${e.at}:${t}`))}),o&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-paper px-3 py-2.5`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:q(`tasks`,`fieldNotes.confirmDelete.title`)})}),(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.confirmDelete.body`,{text:o.text})}),c&&(0,V.jsx)(`p`,{className:`text-error`,children:c}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>s(null),children:z(`dialog.cancel`)}),(0,V.jsx)(`button`,{type:`button`,className:je({danger:!0}),onClick:()=>void p(o),children:z(`taskops.retire`)})]})]}),!o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`keys-only font-sans text-meta text-subtle`,children:q(`tasks`,`fieldNotes.footerDeletable`)}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,disabled:f[i]?.id===void 0,onClick:()=>s(f[i]??null),children:z(`taskops.retire`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:yn,children:z(`taskops.close`)})]})]})]})})}var eU=[`backlog`,`in_progress`,`in_review`,`done`,`canceled`,`error`],tU={backlog:`status.backlog`,in_progress:`status.inProgress`,in_review:`status.inReview`,done:`status.done`,canceled:`status.canceled`,error:`status.error`},nU=e=>({binding:e,key:eo(e)??void 0});async function rU(e,t){if(!e){G(z(`menu.nothingToCopy`,{what:t}),`error`);return}try{await navigator.clipboard.writeText(e),G(z(`menu.copied`,{text:e}))}catch{G(z(`menu.copyFailed`),`error`)}}function iU(e,t,n){let r=[{label:z(`menu.newTask`),section:`open`,run:()=>KD(t)}],i=n.mainTaskId;return i&&(n.first||r.push({label:q(`tasks`,`menu.moveToTop`),section:`edit`,run:()=>void e.client.request(`task.move`,{taskId:i,direction:`top`}).catch(e=>G(q(`tasks`,`toast.moveFailed`,{error:String(e)}),`error`))}),r.push({label:q(`tasks`,`menu.reorderProject`),section:`edit`,...nU(`sidebar.localMerge`),run:()=>oU(i)})),r.push({label:q(`tasks`,`menu.fieldNotes`),section:`notes`,run:()=>W.set((0,V.jsx)($H,{model:e,repo:t}))}),i&&r.push({label:q(`tasks`,`menu.forgetProject`),section:`danger`,danger:!0,run:()=>W.set(eF(e,t,n.label))}),r}function aU(e){return[{label:z(`menu.newChatNoFolder`),section:`open`,run:()=>qD()},{label:z(`menu.newShell`),section:`open`,run:()=>void PC(e).catch(e=>G(String(e),`error`))}]}function oU(e){let t=!LT.get();t&&e!==void 0&&RT.set(e),zT(t),document.querySelector(`.rail`)?.focus()}function sU(e,t){let n=(e.tasks.get()?.tasks??[]).filter(e=>e.kind===`main`&&!e.machine&&e.repo!==t.repo).map(e=>e.repo),r=n.map(e=>{let t=e.slice(e.lastIndexOf(`/`)+1);return{value:e,label:n.filter(e=>e.endsWith(`/${t}`)).length>1?e:t}});return r.length===0?(G(q(`tasks`,`moveToProject.empty`),`error`),null):(0,V.jsx)(cr,{title:q(`tasks`,`moveToProject.title`),choices:r,onPick:async n=>{await e.client.request(`task.moveToProject`,{taskId:t.id,repo:n}),G(q(`tasks`,`toast.movedToProject`,{project:r.find(e=>e.value===n)?.label??n}))}})}function cU(e,t,n){let r=e.client,i=[];n&&(i.push({label:z(`menu.closeTab`),section:`tab`,run:()=>W.set((0,V.jsx)(sr,{title:z(`confirm.closeTabTitle`,{tab:n.title??n.engineName??n.id}),body:z(`confirm.closeTabBody`),confirmLabel:z(`menu.closeTab`),onConfirm:async()=>{await r.request(`tab.close`,{taskId:t.id,tabId:n.id}),await e.refreshTabsNow()}}))}),i.push(...GH(e,t.id,n))),i.push({label:z(`menu.newChat`),section:`open`,run:()=>void MC(e,t.id)}),i.push({label:z(`menu.newChatPick`),section:`open`,run:()=>W.set((0,V.jsx)(RC,{model:e,taskId:t.id}))}),i.push({label:z(`menu.continueEngine`),section:`open`,...nU(`chat.tab.fork`),run:()=>W.set((0,V.jsx)(RC,{model:e,taskId:t.id,context:`continue`,sourceTabId:n?.id}))}),i.push({label:z(`menu.newShell`),section:`open`,run:()=>void NC(e,t.id,{kind:`shell`}).catch(e=>G(String(e),`error`))}),t.startsAt&&(i.push({label:z(`menu.startNow`),section:`open`,run:()=>void e.client.request(`task.startScheduledNow`,{taskId:t.id}).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.cancelStart`),section:`open`,run:()=>void e.client.request(`task.cancelScheduledStart`,{taskId:t.id}).catch(e=>G(String(e),`error`))})),t.hasPrompt&&(i.push({label:q(`tasks`,`menu.runAgain`),section:`open`,run:()=>W.set((0,V.jsx)(ZH,{model:e,task:t}))}),i.push({label:z(`menu.retryEdit`),section:`open`,run:()=>void MD(e,t)}));let a=!t.machine;if(a&&i.push({label:q(`tasks`,`menu.openEditor`),section:`open`,...nU(`tasks.openWorktree`),run:()=>void YP(e,t.id)}),t.groupId){let e=t.groupId;i.push({label:z(`compare.menu`),section:`open`,run:()=>ga(e)})}i.push({label:z(`menu.rename`),section:`edit`,...nU(`sidebar.rename`),run:()=>W.set((0,V.jsx)(or,{title:z(`menu.rename`),initial:t.title,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.rename`,{taskId:t.id,title:e}).then(()=>{})}))}),t.kind!==`main`&&i.push({label:t.pinned?z(`menu.unpin`):z(`menu.pin`),section:`edit`,...nU(`sidebar.pin`),run:()=>void r.request(`task.pin`,{taskId:t.id,pinned:!t.pinned}).catch(e=>G(String(e),`error`))}),a&&i.push({label:q(`tasks`,`menu.reorder`),section:`edit`,...nU(`sidebar.localMerge`),run:()=>oU()}),i.push({label:z(`menu.setStatus`),section:`edit`,children:eU.map(e=>({label:z(tU[e]),checked:e===t.status,run:()=>void r.request(`task.setStatus`,{taskId:t.id,status:e}).catch(e=>G(String(e),`error`))}))}),a&&t.kind!==`main`&&!t.routine&&!t.parentTaskId&&!t.extraRepoCount&&i.push({label:q(`tasks`,`menu.moveToProject`),section:`edit`,run:()=>{let n=sU(e,t);n&&W.set(n)}}),a&&i.push({label:z(`menu.changeEngine`),section:`edit`,...nU(`tasks.cycleEngine`),run:()=>W.set((0,V.jsx)(XH,{model:e,taskId:t.id}))}),t.pr?.checkState===`failing`&&i.push({label:q(`tasks`,`menu.fixChecks`),section:`git`,key:ti(`files.fixChecks`),run:()=>void JP(e,t.id,z(`taskops.fixSent`))}),t.kind===`task`&&t.branch&&a&&i.push({label:q(`tasks`,`menu.syncBase`),section:`git`,key:ti(`files.syncBase`),run:()=>void KP(e,t.id)}),t.branch&&i.push({label:z(`menu.renameBranch`),section:`git`,...nU(`tasks.renameBranch`),run:()=>W.set((0,V.jsx)(or,{title:z(`menu.renameBranch`),initial:t.branch,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.setBranch`,{taskId:t.id,branch:e}).then(()=>{})}))}),t.kind===`task`&&t.branch&&i.push({label:z(`menu.land`),section:`git`,run:()=>void WP(e,t)});let o=[{label:z(`menu.copyWhat.id`),run:()=>void rU(t.id,z(`menu.what.id`))}];return t.branch&&o.push({label:z(`menu.copyWhat.branch`),run:()=>void rU(t.branch,z(`menu.what.branch`))}),o.push({label:z(`menu.copyWhat.path`),run:()=>void r.request(`task.get`,{taskId:t.id}).then(e=>rU(e.task.worktreePath,z(`menu.what.path`))).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.copy`),section:`copy`,children:o}),t.kind!==`main`&&i.push({label:q(`tasks`,t.archived?`menu.unarchive`:`menu.archive`),section:`danger`,run:()=>void $P(e,t)}),i.push({label:z(`menu.removeSession`),section:`danger`,...nU(`sidebar.delete`),danger:!0,run:()=>W.set(t.kind===`main`?QP(e,t):ZP(e,t))}),i}var lU=`rove.collapsedProjects`,uU=`rove.foldedTasks`,dU=`rove.openedTasks`,fU=600;function pU(e){try{let t=JSON.parse(localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}function mU(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}var hU=(e,t)=>{let n=new Set(e);return n.delete(t)||n.add(t),n};function gU(){let e=v(PT),[t,n]=(0,g.useState)({active:!1,query:``}),[r,i]=(0,g.useState)(!1),a=()=>i(e=>!e),[o,s]=(0,g.useState)(()=>pU(lU)),c=e=>s(t=>{let n=hU(t,e);return mU(lU,n),n}),[l,u]=(0,g.useState)(()=>({folded:pU(uU),opened:pU(dU)}));return{sort:e,cycleSort:IT,search:t,setSearch:n,archivedOpen:r,toggleArchived:a,collapsed:o,toggleProject:c,hand:l,toggleTaskFold:(e,t)=>u(n=>{let r=new Set(n.folded),i=new Set(n.opened);return t?(r.delete(e),i.add(e)):(i.delete(e),r.add(e)),mU(uU,r),mU(dU,i),{folded:r,opened:i}})}}var _U=[`sidebar.nav`,`sidebar.goto`,`sidebar.select`,`sidebar.tree.open`,`sidebar.rename`,`sidebar.pin`,`sidebar.localMerge`,`sidebar.delete`,`sidebar.sort`,`sidebar.search.enter`,`tasks.renameBranch`,`tasks.cycleEngine`,`tasks.openWorktree`,`tasks.update`,`tasks.focusEngine`,`task.new`,`settings.open.sidebar`,`worktrees.open.sidebar`];function vU(e){for(let t of e)for(let e of _U){let n=ei(e).indexOf(t);if(n>=0)return{id:e,slot:n}}return null}function yU(e,t){let n=e.selection.get().taskId===t;e.select(t),pa(),n&&Wi()}function bU(e,t,n,r){let{search:i,setSearch:a}=n,[o,s]=(0,g.useState)(null),c=(0,g.useRef)(0),l=t.filter(e=>e.kind!==`project`&&e.kind!==`state`),u=l.findIndex(e=>e.id===o);(0,g.useEffect)(()=>{u<0&&s(r.selectedId&&l.some(e=>e.id===r.selectedId)?r.selectedId:l[0]?.id??null)},[u,l,r.selectedId]);let d=l[u],f=d?.kind===`task`||d?.kind===`pane`?d.task.id:null;(0,g.useEffect)(()=>$k.set(f),[f]);let p=l[0]?.id??null;(0,g.useEffect)(()=>{i.query,i.active&&s(p)},[i.active,i.query,p]);let m=e=>{let t=l[Math.max(0,Math.min(l.length-1,e))];t&&s(t.id)},h=t=>{t?.kind===`archived`&&n.toggleArchived(),t?.kind===`task`&&e.select(t.task.id),t?.kind===`round`&&ga(t.groupId),t?.kind===`pane`&&qH(e,t),t&&t.kind!==`archived`&&pa()},_=(t,n)=>{t?.kind===`task`&&tn(cU(e,t.task,null),n)?.run?.()},v=async t=>{if(t?.kind===`task`&&t.machine===void 0)try{let{engines:n}=await e.client.request(`engines.list`),r=ms(n).filter(e=>e.ready!==!1),i=r[(r.findIndex(e=>e.id===t.task.engine?.id)+1)%r.length];if(!i||i.id===t.task.engine?.id)return;await e.client.request(`task.setCommand`,{taskId:t.task.id,engine:i.id}),G(z(`rail.engineSwitched`,{engine:i.name}))}catch(e){G(z(`rail.engineSwitchFailed`,{error:e instanceof Error?e.message:String(e)}),`error`)}};return{cursor:o,setCursor:s,onKeyDown:t=>{let o=l[u],s=t.target instanceof HTMLInputElement;if(i.active){if(t.metaKey||t.ctrlKey||t.altKey)return;if(t.key===`Escape`)a({active:!1,query:``});else if(t.key===`Enter`)h(o),a({active:!1,query:``});else if(t.key===`ArrowDown`)m(u+1);else if(t.key===`ArrowUp`)m(u-1);else if(t.key===`Backspace`&&!s)a(e=>({...e,query:e.query.slice(0,-1)}));else if(t.key.length===1&&!s)a(e=>({...e,query:e.query+t.key}));else return;t.preventDefault();return}let d=vU(Ja(t));if(LT.get()){let n=o?.kind===`task`&&o.machine===void 0;if(d?.id===`sidebar.nav`)n&&BT(e,o,d.slot%2==0?1:-1);else if(d?.id===`sidebar.localMerge`||t.key===`Enter`||t.key===`Escape`)zT(!1);else return;t.preventDefault();return}switch(d?.id){case`sidebar.nav`:m(d.slot%2==0?u+1:u-1);break;case`sidebar.goto`:d.slot%2==1?m(l.length-1):Date.now()-c.current<fU?(m(0),c.current=0):c.current=Date.now();break;case`sidebar.select`:case`sidebar.tree.open`:h(o);break;case`tasks.focusEngine`:Wi();break;case`sidebar.rename`:case`sidebar.pin`:case`sidebar.delete`:case`tasks.renameBranch`:case`tasks.openWorktree`:_(o,d.id);break;case`tasks.cycleEngine`:v(o);break;case`sidebar.localMerge`:o?.machine===void 0&&zT(!0);break;case`sidebar.sort`:n.cycleSort(),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.${PT.get()}`)}));break;case`sidebar.search.enter`:a({active:!0,query:``});break;case`task.new`:r.onNewTask(o?.kind===`task`||o?.kind===`pane`?o.task.repo:void 0,o?.machine);break;case`settings.open.sidebar`:r.onSettings();break;case`worktrees.open.sidebar`:ha(`worktrees`);break;case`tasks.update`:ha(`update`);break;default:return}t.preventDefault()}}}var xU=(e,t,n)=>`~pane:${e}:${t}:${n}`;function SU(e,t){return e.flatMap(e=>e.kind===`task`?[e,...(t[e.task.id]??[]).flatMap(t=>{let n=t.split;if(!n||!bw(n))return[];let r=Cw(n,_w(t));return yw(n.root).map(n=>({id:xU(e.task.id,t.id,n.id),kind:`pane`,task:e.task,tab:t,leaf:n.id,label:r.get(n.id)??n.id,depth:e.depth+1,...e.machine===void 0?{}:{machine:e.machine}}))})]:[e])}function CU(e){let{row:t}=e;return(0,V.jsxs)(`button`,{type:`button`,className:`${Qn({size:`pane`})} ${e.cursor?iE:``}`,title:z(`compare.menu`),onClick:()=>{e.onClick(),ga(t.groupId)},...e.place,children:[e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${$n} text-(length:--fs-meta) text-muted`,children:t.title}),(0,V.jsxs)(`span`,{className:`${rr} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),(0,V.jsx)(`span`,{className:`text-subtle`,children:t.tasks.length}),(0,V.jsx)(QL,{status:GF(t.tasks)})]})]})}function wU(e){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let e=t.current;return()=>{e&&document.activeElement===e&&e.closest(`nav`)?.focus()}},[]),(0,V.jsxs)(`div`,{className:`${eE} mono items-center`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:`/`}),(0,V.jsx)(`input`,{ref:t,className:nE,type:`text`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,enterKeyHint:`go`,value:e.query,placeholder:z(`rail.searchPlaceholder`),"aria-label":z(`rail.searchPlaceholder`),onChange:t=>e.onChange(t.target.value)}),e.query&&(0,V.jsx)(`span`,{className:`ml-1.5 text-muted`,children:e.count})]})}var TU=450,EU=!1;typeof document<`u`&&(document.addEventListener(`keydown`,()=>{EU=!0},!0),document.addEventListener(`pointerdown`,()=>{EU=!1},!0));var DU=e=>{let t=e.querySelector(`.row-title`);return!!t&&t.scrollWidth>t.clientWidth};function OU(e,t){let[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null),o=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null},s=e=>{o(),i.current=window.setTimeout(()=>r(e.getBoundingClientRect()),TU)},c=()=>{o(),r(null)};return(0,g.useEffect)(()=>{let e=a.current,n=e?.closest(`.rail`);if(!t||!e||!n||!EU||!n.contains(document.activeElement)||!DU(e))return;let i=()=>{o(),r(null)},c=e=>{e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||i()};return s(e),n.addEventListener(`focusout`,c),()=>{n.removeEventListener(`focusout`,c),i()}},[t]),(0,g.useEffect)(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),{ref:e=>{a.current=e},onPointerEnter:e=>{e.pointerType===`touch`||!DU(e.currentTarget)||s(e.currentTarget)},onPointerLeave:c,hide:c,tip:n?(0,mH.createPortal)((0,V.jsx)(`div`,{className:XT,role:`tooltip`,style:{top:n.top+n.height/2,left:n.right+8},children:e}),document.body):null}}function kU({at:e}){let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=hD(t);return(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.startsAt`,{time:t.toLocaleString()}),children:[`◷ `,n]})}var AU=150,jU=128,MU=0,NU=2,PU=[{reach:.96,grow:1.5,pulse:.9,done:104},{reach:.72,grow:1.1,pulse:1.2,done:84},{reach:1,grow:1.7,pulse:.7,done:116},{reach:.84,grow:1.3,pulse:1,done:96},{reach:.62,grow:1.2,pulse:1.3,done:80}],FU=`/-\\|`,IU=6,LU=(e,t,n,r)=>{let i=e[n];i&&t>=0&&t<i.length&&(i[t]=r)};function RU(e,t){let n=Math.min(64,Math.max(24,Math.floor(t))),r=(Math.floor(e)%AU+AU)%AU,i=Array.from({length:11},()=>Array(n).fill(` `)),a=Array.from({length:11},()=>Array(n).fill(` `));LU(a,MU,0,`o`);let o=NU+2*(PU.length-1),s=Math.min(o,Math.floor(r/2));for(let e=1;e<=s;e++)LU(i,MU,e,`|`);if(PU.forEach((e,t)=>{let o=NU+2*t,s=2*o;if(r<s)return;LU(i,MU,o,`+`);let c=n-1-1,l=1+Math.max(1,Math.floor(c*e.reach)),u=Math.min(l,1+Math.floor((r-s)*e.grow)),d=r>=e.done&&u===l;for(let t=1;t<u;t++)!d&&((t-Math.floor(r*e.pulse))%IU+IU)%IU===0?LU(a,t,o,`=`):LU(i,t,o,`-`);d?LU(a,u,o,`o`):u<l?LU(a,u,o,`>`):LU(a,u,o,FU[(Math.floor(r/2)+t)%4]??`-`)}),r>=jU){let e=Math.ceil((r-jU+1)/22*(n+1));for(let t of[i,a])for(let r of t)r.fill(` `,0,Math.min(n,e))}return{base:i.map(e=>e.join(``)).join(`
128
128
  `),accent:a.map(e=>e.join(``)).join(`
129
- `)}}var LU=`min-h-0 w-full overflow-y-auto`,RU=`mx-auto mt-[min(16vh,8rem)] flex w-full max-w-130 flex-col gap-4 px-5 pb-7`,zU=`relative grid w-full select-none overflow-hidden font-mono text-(length:--fs-body) text-subtle [contain:layout_paint]`,BU=`col-start-1 row-start-1 m-0 whitespace-pre font-[inherit] leading-[inherit]`,VU=`invisible absolute top-0 left-0 whitespace-pre`,HU=1.3,UU=`0000000000`,WU=1e3/12;function GU(){let e=(0,g.useRef)(null),t=(0,g.useRef)(null),n=(0,g.useRef)(null),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let i=e.current,a=t.current,o=n.current,s=r.current;if(!i||!a||!o||!s)return;let c=window.matchMedia(`(prefers-reduced-motion: reduce)`),l=24,u=90,d=0,f=0,p=0,m=-1,h=!0,g=()=>{let e=IU(u,l);o.textContent=e.base,s.textContent=e.accent},_=()=>{let e=a.getBoundingClientRect().width/10;e>0&&(l=Math.min(64,Math.max(24,Math.floor(i.clientWidth/e)))),g()},v=e=>{d=requestAnimationFrame(v);let t=p+Math.floor((e-f)/WU);t!==m&&(m=t,u=t,g())},y=()=>{cancelAnimationFrame(d),d=0},b=()=>{y(),c.matches?(u=90,g()):h&&document.visibilityState===`visible`&&(f=performance.now(),p=u,m=-1,d=requestAnimationFrame(v))},x=new ResizeObserver(_);x.observe(i),_(),b();let S=new IntersectionObserver(e=>{h=e[e.length-1]?.isIntersecting??!0,b()});return S.observe(i),c.addEventListener(`change`,b),document.addEventListener(`visibilitychange`,b),()=>{y(),x.disconnect(),S.disconnect(),c.removeEventListener(`change`,b),document.removeEventListener(`visibilitychange`,b)}},[]),(0,V.jsxs)(`div`,{ref:e,"aria-hidden":`true`,"data-field":`first-run-art`,className:zU,style:{height:`${11*HU}em`,lineHeight:HU},children:[(0,V.jsx)(`span`,{ref:t,className:VU,children:UU}),(0,V.jsx)(`pre`,{ref:n,className:BU}),(0,V.jsx)(`pre`,{ref:r,className:`${BU} text-accent`})]})}function KU(e){let t=q(`doctor`,`fix.humanOnlyWhy`),n=[];if(e.git||n.push({id:`git`,label:q(`doctor`,`fix.git`),action:q(`doctor`,`fix.gitAction`),why:t}),e.engines.length===0){let r=e.signedOut.length>0;n.push({id:`engine`,label:q(`doctor`,r?`fix.noEngineLogin`:`fix.noEngine`),action:q(`doctor`,r?`fix.noEngineLoginAction`:`fix.noEngineAction`,{list:e.signedOut.map(e=>e.id).join(`, `)}),why:t})}return n}function qU({model:e}){B(),v(Kr);let[t,n]=(0,g.useState)(()=>Ns(e,`welcome.env`)??null);(0,g.useEffect)(()=>{let t=!0;return Fs(e,`welcome.env`).then(e=>t&&n(e)).catch(()=>{}),()=>{t=!1}},[e]);let r=t===null?null:t.engines.length>0?{key:`enginesFound`,warn:!1,list:t.engines.map(e=>e.name).join(`, `)}:t.signedOut.length>0?{key:`enginesSignedOut`,warn:!0,list:t.signedOut.map(e=>e.name).join(`, `)}:{key:`enginesMissing`,warn:!0,list:``},i=t!==null&&(t.engines.length===0||!t.git)?KU(t):[];return(0,V.jsx)(`div`,{className:LU,"data-field":`welcome`,children:(0,V.jsxs)(`div`,{className:RU,children:[(0,V.jsx)(GU,{}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-ink`,children:z(`firstRun.title`)}),(0,V.jsx)(`p`,{className:`m-0 font-sans text-body text-muted`,children:z(`firstRun.body`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,className:je(),"data-field":`start-first-task`,onClick:()=>KD(t?.start?.repo),children:z(`firstRun.start`)}),(0,V.jsx)(`span`,{className:`keys-only mono text-meta text-subtle`,children:ti(`task.new.global`)})]}),t!==null&&r!==null&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-sans text-meta`,children:[(0,V.jsx)(`p`,{className:`m-0 ${r.warn?`text-warning`:`text-subtle`}`,children:q(`workspace`,`welcome.${r.key}`,{list:r.list})}),!t.git&&(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:q(`workspace`,`welcome.gitMissing`)}),i.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:e.label}),(0,V.jsx)(`p`,{className:`mono m-0 text-accent`,children:e.action}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:e.why})]},e.id)),i.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:q(`common`,`failureHint`,{command:`rove doctor`})})]})]})})}function JU(e,t){e.preventDefault(),nn.set({x:e.clientX,y:e.clientY,items:t,target:e.currentTarget,fromKeyboard:e.button!==2})}function YU({model:e,narrow:t}){let n=B(),r=v(e.tasks),i=v(e.remote),a=gE(e),o=v(e.tabs),s=v(e.tabsSettled),c=v(e.selection),l=r?.tasks??[],u=r?.attention.filter(e=>e.unread).length??0,d=c.taskId,f=new Map([...l,...i].map(e=>[e.id,e])),p=mU(),m=v(LT),h=v(AT)===`state`,_=v(RT),y=e=>(h?nO:gw)({tasks:l,remote:i,machines:a,sort:p.sort,query:e,fold:{...p.hand,selectedId:d??void 0}}),b=y(p.search.active?p.search.query:``),{groups:x}=b,S=p.search.active?b.rows:yH(vw(bU(rO(jH(b.rows,o,c.taskId,s,_)),o),p.collapsed),r?.archived??[],p.archivedOpen,{...p.hand,selectedId:d??void 0}),C=e=>e.filter(e=>e.kind!==`project`&&e.kind!==`state`&&e.kind!==`round`),w=(n===`zh`?Dr:Er).machine,T=new Set(a.filter(e=>e.state!==`online`).map(e=>e.alias)),E=x.find(e=>e.tasks.some(e=>e.kind===`main`))?.repo,D=e=>({mainTaskId:x.find(t=>t.repo===e)?.tasks.find(e=>e.kind===`main`)?.id??null,label:zC(e),first:e===E}),O=kH(e,l,!p.search.active&&!h,p.sort==="default",D),k=O.places(S),A=()=>W.set((0,V.jsx)(NP,{model:e})),j=vU(e,S,p,{selectedId:d,onNewTask:KD,onSettings:A}),ee=_!==null&&S.some(e=>e.id===_),M=j.setCursor;(0,g.useEffect)(()=>{ee&&_!==null&&M(_)},[ee,_,M]);let N=C(y(``).rows).length,P=(0,g.useRef)(null),F=v($F)&&!t,I=v(eI)&&F,te=t?l.find(e=>e.id===c.taskId&&!e.deleting)??null:null;return(0,V.jsxs)(`nav`,{className:`${QT} ${F?`is-folded`:``}`,ref:P,inert:F&&!I,"aria-hidden":F&&!I,onMouseEnter:F?()=>nI(!0):void 0,onMouseLeave:F?()=>nI(!1):void 0,tabIndex:0,onKeyDown:e=>{EF(`sidebar`),j.onKeyDown(e)},children:[(0,V.jsxs)(`header`,{className:$T,children:[(0,V.jsxs)(`span`,{className:`${zt} mr-auto`,children:[(0,V.jsx)(`span`,{className:Bt,children:`[`}),` rove `,(0,V.jsx)(`span`,{className:Bt,children:`]`})]}),(0,V.jsxs)(`span`,{className:`relative`,children:[(0,V.jsx)(`button`,{type:`button`,className:`m-0 text-meta font-medium normal-nums inbox-chip relative ${Xn} ${He} ${u>0?`text-accent`:`text-muted`}`,onClick:()=>W.set((0,V.jsx)(DT,{model:e})),children:z(`rail.inbox`,{count:u})}),(0,V.jsx)(yF,{model:e,bindingId:`inbox.show`,head:!0})]}),(0,V.jsx)(DM,{})]}),m&&(0,V.jsxs)(`div`,{className:`flex gap-1 px-3.5 pb-2 text-meta mono`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:q(`tasks`,`moveChip`).trim()}),(0,V.jsx)(`span`,{className:`keys-only ml-1.5 text-muted`,children:(0,V.jsx)(ST,{text:z(`taskops.moveHint`)})})]}),p.search.active&&(0,V.jsx)(SU,{query:p.search.query,count:`${C(S).length}/${N}`,onChange:e=>p.setSearch(t=>({...t,query:e}))}),(0,V.jsx)(KI,{model:e}),(0,V.jsx)(uH,{model:e}),(0,V.jsxs)(`div`,{"data-rail-body":!0,className:rE(O.dragging!==null),...O.body,children:[r&&l.length===0&&i.length===0&&t&&(0,V.jsx)(qU,{model:e}),r&&l.length===0&&i.length===0&&!t&&(0,V.jsx)(`p`,{className:`m-0 px-2 py-3 font-mono text-meta text-subtle`,children:z(`rail.empty`)}),te&&(0,V.jsx)(jI,{title:te.title}),S.map((t,n)=>t.kind===`round`?(0,V.jsx)(xU,{row:t,guides:t.depth>1?DH(S,n):void 0,repo:h&&t.depth===1?eO(t.tasks[0]):void 0,cursor:t.id===j.cursor,place:k(t),onClick:()=>j.setCursor(t.id)},t.id):t.kind===`pane`?(0,V.jsx)(KH,{model:e,row:t,guides:DH(S,n),cursor:t.id===j.cursor,place:k(t),onClick:()=>{j.setCursor(t.id),GH(e,t),pa()},onMenu:n=>{j.setCursor(t.id),JU(n,VH(e,t.task.id,t.tab,t.leaf))}},t.id):(0,V.jsx)(XU,{row:t,guides:t.kind===`task`&&t.depth>1?DH(S,n):void 0,cloud:pE(t,a,w),repo:h&&t.kind===`task`&&t.depth===1?eO(t.task):void 0,tabs:t.kind===`task`?o[t.task.id]:void 0,selected:t.id===d,cursor:t.id===j.cursor,stale:t.machine!==void 0&&T.has(t.machine),collapsed:(t.kind===`project`||t.kind===`state`)&&p.collapsed.has(t.id),drag:O.props(t),dragging:O.dragging===t.id,place:k(t),onNewTask:t.kind===`project`?t.noProject?qD:()=>KD(t.repo,t.machine):void 0,moving:m&&t.machine===void 0&&(t.kind===`project`?!t.noProject&&D(t.repo).mainTaskId===j.cursor:t.id===j.cursor&&(t.kind!==`task`||t.task.kind!==`main`)),prTasks:t.kind===`task`?[t.task,...(t.fold?.descendantIds??[]).flatMap(e=>f.get(e)??[])]:void 0,rollup:t.kind===`task`&&t.fold?.collapsed?UF([t.task,...t.fold.descendantIds.flatMap(e=>f.get(e)??[])]):void 0,onToggleFold:()=>{t.kind===`task`&&p.toggleTaskFold(t.id,t.fold?.collapsed===!0),t.kind===`archived`&&p.toggleArchived()},onClick:()=>{j.setCursor(t.id),t.kind===`archived`&&p.toggleArchived(),(t.kind===`project`||t.kind===`state`)&&p.toggleProject(t.id),t.kind===`task`&&_U(e,t.task.id)},onMenu:n=>{if(t.kind!==`project`||t.machine===void 0){if(t.kind===`project`&&t.noProject){JU(n,rU(e));return}if(t.kind===`project`){let r=D(t.repo);r.mainTaskId&&S.some(e=>e.id===r.mainTaskId)&&j.setCursor(r.mainTaskId),JU(n,nU(e,t.repo,r));return}t.kind===`task`&&(j.setCursor(t.id),JU(n,$U(QU(oU(e,t.task,null),t.fold,()=>p.toggleTaskFold(t.id,t.fold?.collapsed===!0)),WH(e,t.task.id))))}}},t.id))]}),(0,V.jsx)(AH,{model:e,narrow:t,onSettings:A}),(0,V.jsx)(MI,{pane:`sidebar`}),!t&&!F&&(0,V.jsx)(EI,{rail:P})]})}function XU(e){let{row:t}=e,n=EU(t.kind===`task`?t.task.label:``,e.cursor&&t.kind===`task`),r=e.cursor?iE:``;if(t.kind===`project`||t.kind===`state`)return(0,V.jsxs)(`h2`,{className:aE({moving:e.moving,dragging:e.dragging}),onContextMenu:e.onMenu,...e.place,...e.drag,children:[(0,V.jsxs)(`button`,{type:`button`,className:sE,title:t.kind===`project`&&!t.noProject?t.repo:void 0,"aria-expanded":!e.collapsed,onClick:e.onClick,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.kind===`state`&&(0,V.jsx)(`span`,{className:`font-normal text-subtle`,children:t.count}),(0,V.jsx)(Ma,{right:e.collapsed,className:cE(!!e.collapsed)})]}),e.onNewTask&&t.kind===`project`&&(0,V.jsx)(`button`,{type:`button`,className:lE,title:z(`rail.newTask`),onClick:e.onNewTask,children:`+`})]});if(t.kind===`archived`)return(0,V.jsx)(`button`,{type:`button`,className:`${Qn({moving:e.moving||e.dragging})} ${r}`,"aria-expanded":t.expanded,onClick:e.onClick,...e.place,children:(0,V.jsx)(`span`,{className:`${er} ${e.stale?`text-subtle`:`text-muted`}`,children:q(`tasks`,`archivedRow`,{count:t.count})})});let i=t.task,a=i.rowStatus?.kind===`running`,o=PP(i);return(0,V.jsxs)(`button`,{type:`button`,ref:n.ref,className:`${Qn({selected:e.selected,moving:e.moving||e.dragging})} ${r}`,onClick:e.onClick,onContextMenu:e.onMenu,onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,...e.place,...e.drag,children:[n.tip,e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${er} ${e.stale?`text-subtle`:``} ${a?tr:``}`,children:t.attempt??i.label}),(0,V.jsxs)(`span`,{className:`${rr} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),t.level!==void 0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:t.level}),(i.extraRepoCount??0)>0&&(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.extraRepos`,{count:i.extraRepoCount??0}),children:[`+`,i.extraRepoCount]}),o&&(0,V.jsxs)(`span`,{className:`text-subtle tabular-nums`,title:z(`rail.todos`,o),children:[o.done,`/`,o.total]}),t.fold?.collapsed&&(0,V.jsx)(ZU,{count:t.fold.count,onUnfold:e.onToggleFold}),i.kept&&(0,V.jsx)(`span`,{className:`text-accent`,title:z(`compare.kept`),children:`✓`}),i.pinned&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`▴`}),i.startsAt&&(0,V.jsx)(DU,{at:i.startsAt}),(0,V.jsx)(_H,{tasks:e.prTasks??[i],onOpen:n.hide}),(0,V.jsx)(XL,{status:t.fold?.collapsed?e.rollup:i.rowStatus}),e.cloud&&(0,V.jsx)(mE,{label:e.cloud})]})]})}function ZU(e){let t=q(`tasks`,`menu.expandChildren`);return(0,V.jsxs)(`span`,{role:`button`,tabIndex:-1,"aria-label":t,"aria-expanded":!1,className:`chip text-muted ${qT}`,title:t,onClick:t=>{t.stopPropagation(),e.onUnfold()},children:[e.count,(0,V.jsx)(Ma,{right:!0})]})}function QU(e,t,n){if(!t)return e;let r={label:q(`tasks`,t.collapsed?`menu.expandChildren`:`menu.collapseChildren`),section:`open`,run:n},i=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,i+1),r,...e.slice(i+1)]}function $U(e,t){let n=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,n+1),...t,...e.slice(n+1)]}function eW(e){return e===`localhost`||e.endsWith(`.localhost`)||e===`[::1]`||/^127(\.\d{1,3}){3}$/.test(e)}var tW=/^(localhost|127(\.\d{1,3}){3}|\[::1\])(:\d+)?([/?#]|$)/i,nW=/^[a-z][a-z0-9+.-]*:(?!\d+([/?#]|$))/i;function rW(e){let t=e.trim();if(!t||/\s/.test(t)||nW.test(t)&&!/^https?:\/\//i.test(t))return null;let n=/^https?:\/\//i.test(t)?t:tW.test(t)?`http://${t}`:`https://${t.replace(/^\/\//,``)}`;try{let e=new URL(n);return e.hostname?e.href:null}catch{return null}}function iW(e,t,n=eW(t.hostname)){let r=new URL(e);return r.origin===t.origin?`self`:eW(r.hostname)?n?`yes`:`remote`:r.protocol===`https:`?`yes`:`unreachable`}function aW(e,t,n){let r=new URL(e).host;return t===`self`?{key:`self`,host:r}:t===`remote`?{key:`remote`,host:r}:t===`unreachable`?{key:`noFrame`,host:r}:n&&!n.reachable?{key:`unreachable`,host:r}:n&&!n.frameable?{key:`refuses`,host:r}:null}var oW=6e4,sW=new Map;function cW(e){let t=sW.get(e);return t&&Date.now()-t.at<oW?t:null}function lW(e,t,n){let[,r]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(!n||cW(t))return;let i=!0;return e.request(`browser.probe`,{url:t,origin:window.location.origin}).then(e=>sW.set(t,{probe:e,at:Date.now()}),()=>sW.set(t,{probe:null,at:Date.now()})).then(()=>i&&r(e=>e+1)),()=>{i=!1}},[e,t,n]);let i=n?cW(t):null;return{pending:n&&!i,probe:i?.probe??null}}function uW({d:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e})})}var dW=`M6.5 3.5h-3v9h9v-3M9.5 3.5h3v3M12.5 3.5l-5 5`;function fW({model:e,tab:t,onNavigate:n,onStep:r}){B();let i=qO(t),[a,o]=(0,g.useState)(i),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(0),d=v(e.client.conn).hello?.peer?.local,f=i?iW(i,window.location,d):null;(0,g.useEffect)(()=>{o(i),c(!1)},[i]);let p=e=>{let t=rW(e);c(t===null&&e.trim()!==``),t!==null&&(o(t),t===i?u(l+1):n(t))},m=i?new URL(i).hostname:``,h=f===`yes`&&i.startsWith(`https:`)&&!eW(m),{pending:_,probe:y}=lW(e.client,i,h),b=i&&f?aW(i,f,y):null,x=f===`yes`&&!b&&!_,S=b?z(`browser.${b.key}`,{host:b.host}):f===null?z(s?`browser.invalid`:`browser.empty`):null;return(0,V.jsxs)(`div`,{className:bI,children:[(0,V.jsxs)(`form`,{className:xI,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,V.jsx)(`button`,{type:`button`,className:aI({small:!0}),disabled:t.at<=0,title:z(`browser.back`),"aria-label":z(`browser.back`),onClick:()=>r(t.at-1),children:(0,V.jsx)(uW,{d:`M10 3.5 5.5 8l4.5 4.5`})}),(0,V.jsx)(`button`,{type:`button`,className:aI({small:!0}),disabled:t.at>=t.urls.length-1,title:z(`browser.forward`),"aria-label":z(`browser.forward`),onClick:()=>r(t.at+1),children:(0,V.jsx)(uW,{d:`M6 3.5 10.5 8 6 12.5`})}),(0,V.jsx)(`button`,{type:`button`,className:aI({small:!0}),disabled:!x,title:z(`browser.reload`),"aria-label":z(`browser.reload`),onClick:()=>u(l+1),children:(0,V.jsx)(uW,{d:`M12.5 8a4.5 4.5 0 1 1-1.4-3.3M12.5 2.5v2.7H9.8`})}),(0,V.jsx)(`input`,{className:`browser-url mono ${SI}`,value:a,placeholder:z(`browser.placeholder`),"aria-label":z(`browser.address`),"aria-invalid":s,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,inputMode:`url`,onChange:e=>o(e.target.value)}),i?(0,V.jsx)(`a`,{className:aI({small:!0}),href:i,target:`_blank`,rel:`noopener noreferrer`,title:z(`browser.openTab`),"aria-label":z(`browser.openTab`),children:(0,V.jsx)(uW,{d:dW})}):(0,V.jsx)(`button`,{type:`button`,className:aI({small:!0}),disabled:!0,"aria-label":z(`browser.openTab`),children:(0,V.jsx)(uW,{d:dW})})]}),x?(0,V.jsx)(`iframe`,{className:CI,src:i,title:i,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,referrerPolicy:`no-referrer`},`${i}#${l}`):S?(0,V.jsx)(`p`,{className:yI,children:S}):null]})}var pW=3;function mW({model:e,task:t}){B();let n=t.autoFixCi,r=n=>void e.client.request(`task.autoFixCi`,{taskId:t.id,enabled:n}).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsx)(`div`,{className:`flex items-center gap-3 px-2 pt-1 font-mono text-meta`,children:n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:n.stopped?CT.attention:`text-muted`,title:z(`files.autoFix.hint`),children:z(n.stopped?`files.autoFix.stopped`:`files.autoFix.count`,{n:n.attempts,max:pW})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>r(!1),children:z(`files.autoFix.off`)})]}):(0,V.jsx)(H,{hit:`tight`,title:z(`files.autoFix.hint`),onClick:()=>r(!0),children:z(`files.autoFix.on`)})})}function hW(e){let t=e.pr;return!!t&&t.number!==void 0&&!e.machine&&(t.lifecycle===`open`||t.lifecycle===`ready_to_merge`)}function gW(e){let t={fail:0,pending:0,pass:0,skipped:0};for(let n of e)t[n.state]++;return t}function _W(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h${String(n%60).padStart(2,`0`)}m`}function vW(e){let t=[],n=e.mergeState.toUpperCase();e.draft&&t.push({key:`files.merge.draft`,tone:`warning`}),e.mergeable.toUpperCase()===`CONFLICTING`||n===`DIRTY`?t.push({key:`files.merge.conflicts`,tone:`attention`}):n===`BEHIND`?t.push({key:`files.merge.behind`,tone:`warning`}):n===`UNSTABLE`?t.push({key:`files.merge.unstable`,tone:`warning`}):n===`BLOCKED`?t.push({key:`files.merge.blocked`,tone:`warning`}):n===`CLEAN`&&!e.draft&&t.push({key:`files.merge.clean`,tone:`success`});let r=e.review.toUpperCase();return r===`APPROVED`?t.push({key:`files.merge.approved`,tone:`success`}):r===`CHANGES_REQUESTED`?t.push({key:`files.merge.changes`,tone:`attention`}):r===`REVIEW_REQUIRED`&&t.push({key:`files.merge.reviewRequired`,tone:`warning`}),t}var yW=`flex flex-col gap-0.5 px-2 pb-2 font-mono text-meta`,bW=`flex items-start gap-2`,xW=`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 text-left text-ink`,SW={pass:{glyph:`✓`,tone:`success`},fail:{glyph:`✗`,tone:`attention`},pending:{glyph:`●`,tone:`warning`},skipped:{glyph:`–`,tone:`muted`}};function CW({model:e,task:t}){B();let n=t.pr,r=t.id,[i,a]=(0,g.useState)(()=>Ns(e,`pr.checks`,{taskId:r})??null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({}),[u,d]=(0,g.useState)(0),f=`${n?.number}:${n?.checkState}:${n?.mergeable}:${n?.reviewDecision}`;(0,g.useEffect)(()=>{let t=!0,n={taskId:r};return e.client.request(`pr.checks`,u>0?{...n,fresh:!0}:n).then(r=>{t&&(Ps(e,`pr.checks`,n,r),a(r))},e=>t&&a({outcome:`unavailable`,detail:e instanceof Error?e.message:String(e)})),()=>{t=!1}},[e,r,f,u]);let p=t=>{let n=`${t.runId}:${t.name}`;if(c[n]){l(({[n]:e,...t})=>t);return}l(e=>({...e,[n]:{state:`loading`}})),e.client.request(`pr.checkLog`,{taskId:r,runId:t.runId,job:t.name}).then(e=>e.outcome===`ok`?{state:`text`,text:e.tail}:e.outcome===`none`?{state:`note`,text:z(`files.checks.noLog`)}:{state:`note`,text:z(`files.checks.logUnavailable`,{detail:e.detail})}).catch(e=>({state:`note`,text:z(`files.checks.logUnavailable`,{detail:e instanceof Error?e.message:String(e)})})).then(e=>l(t=>n in t?{...t,[n]:e}:t))},m=(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>d(e=>e+1),children:z(`files.checks.refresh`)});if(!i)return(0,V.jsx)(`div`,{className:yW,children:(0,V.jsx)(`div`,{className:bW,children:(0,V.jsxs)(`span`,{className:`flex-1 text-muted`,children:[z(`files.checks.title`),` `,z(`files.checks.loading`)]})})});if(i.outcome!==`ok`)return(0,V.jsx)(`div`,{className:yW,children:(0,V.jsxs)(`div`,{className:bW,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted wrap-anywhere`,children:i.outcome===`none`?z(`files.checks.none`):z(`files.checks.unavailable`,{detail:i.detail})}),m]})});let h=gW(i.checks),_=o??(h.fail>0||h.pending>0),v=vW(i);return(0,V.jsxs)(`div`,{className:yW,children:[(0,V.jsxs)(`div`,{className:bW,children:[(0,V.jsxs)(H,{variant:`row`,className:xW,"aria-expanded":_,disabled:i.total===0,onClick:()=>s(!_),children:[i.total>0&&(0,V.jsx)(Ma,{right:!_}),(0,V.jsx)(`span`,{children:i.total===0?z(`files.checks.none`):z(`files.checks.summary`,{pass:h.pass+h.skipped,total:i.total})}),h.fail>0&&(0,V.jsx)(`span`,{className:CT.attention,children:z(`files.checks.failed`,{count:h.fail})}),h.pending>0&&(0,V.jsx)(`span`,{className:CT.warning,children:z(`files.checks.running`,{count:h.pending})}),v.map(e=>(0,V.jsx)(`span`,{className:CT[e.tone],children:z(e.key)},e.key))]}),m]}),_&&i.checks.map(e=>{let{glyph:t,tone:n}=SW[e.state],r=`${e.runId}:${e.name}`,i=c[r];return(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 pl-4`,children:[(0,V.jsx)(`span`,{className:`w-[1ch] flex-none text-center ${CT[n]}`,children:t}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),e.durationMs!==null&&(0,V.jsx)(`span`,{className:`flex-none text-subtle`,children:_W(e.durationMs)}),e.state===`fail`&&e.runId&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>p(e),children:z(i?`files.checks.hideLog`:`files.checks.log`)})]}),i&&(0,V.jsx)(`pre`,{className:`m-0 ml-4 mb-1 max-h-40 overflow-y-auto rounded-sm border-hairline border-line bg-inset px-2 py-1.5 whitespace-pre-wrap wrap-anywhere text-muted`,children:i.state===`loading`?z(`files.checks.loading`):i.text})]},`${e.name}:${e.url}`)}),_&&i.total>i.checks.length&&(0,V.jsx)(`span`,{className:`pl-4 text-subtle`,children:z(`files.checks.more`,{count:i.total-i.checks.length})})]})}function wW({model:e,task:t}){return hW(t)?(0,V.jsxs)(`div`,{onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsx)(CW,{model:e,task:t}),(0,V.jsx)(mW,{model:e,task:t})]}):null}function TW(e,t){let n={children:new Map,file:!1};for(let t of e){let e=n;for(let n of t.split(`/`)){let t=e.children.get(n);t||(t={children:new Map,file:!1},e.children.set(n,t)),e=t}e.file=!0}let r=[],i=(e,n,a)=>{let o=[...e.children].sort(([e,t],[n,r])=>{let i=t.children.size>0&&!t.file;return i===(r.children.size>0&&!r.file)?e.localeCompare(n):i?-1:1});for(let[e,s]of o){let o=s.children.size>0&&!s.file,c=o?`${n}${e}/`:`${n}${e}`,l=o&&t.has(c);r.push({path:c,name:e,depth:a,dir:o,open:l}),l&&i(s,c,a+1)}};return i(n,``,0),r}var EW={start:`\x1B[200~`,end:`\x1B[201~`};function DW(e,t){return e.engineTarget(t).tabId??e.tabs.get()[t]?.find(e=>e.kind===`engine`)?.id}async function OW(e,t,n){let r=DW(e,t);if(!r)return G(z(`files.stripNoEngine`),`error`),!1;try{return e.selection.get().tabId!==r&&e.select(t,r),await e.client.request(`term.input`,{stream:yC(t,r),data:`${EW.start}${n}${EW.end}`}),G(z(`files.stripFilled`)),!0}catch(e){return G(e instanceof Error?e.message:String(e),`error`),!1}}var kW=`w-full min-w-0 rounded-sm border-hairline border-line bg-paper px-2 py-1 font-mono text-meta text-ink outline-none placeholder:text-subtle focus-visible:border-accent`,AW=`${kW} min-h-24 resize-none leading-[1.45]`,jW=e=>`min-w-0 flex-1 cursor-text break-words text-left font-mono text-meta ${e?`text-subtle line-through`:`text-ink`}`,MW=700;function NW({model:e,task:t}){B();let n=t.todos??[],[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(t.notes??``),l=(0,g.useRef)(!1),u=(0,g.useRef)(t.notes??``),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{l.current||(u.current=t.notes??``,c(t.notes??``))},[t.notes]),(0,g.useEffect)(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);let f=n=>e.client.request(`task.notes`,{taskId:t.id,...n}).catch(e=>G(String(e),`error`)),p=e=>{d.current!==null&&window.clearTimeout(d.current),d.current=null,e!==u.current&&(u.current=e,f({notes:e}))},m=()=>{let e=r.trim();e!==``&&(i(``),f({ops:[{op:`add`,text:e}]}))},h=()=>{if(!a)return;let e=a.text.trim(),t=n.find(e=>e.id===a.id)?.text;o(null),e===``?f({ops:[{op:`remove`,id:a.id}]}):e!==t&&f({ops:[{op:`edit`,id:a.id,text:e}]})},_=IP(t);return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-2 pb-2 font-mono text-meta`,onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[n.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,V.jsx)(H,{hit:`tight`,className:e.done?`text-subtle`:void 0,"aria-label":z(e.done?`files.todoUncheck`:`files.todoCheck`,{text:e.text}),onClick:()=>void f({ops:[{op:`check`,id:e.id,done:!e.done}]}),children:e.done?`[x]`:`[ ]`}),a?.id===e.id?(0,V.jsx)(`input`,{className:kW,value:a.text,maxLength:500,autoFocus:!0,"aria-label":z(`files.todoEdit`),onChange:t=>o({id:e.id,text:t.target.value}),onBlur:h,onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&o(null)}}):(0,V.jsx)(H,{variant:`row`,className:jW(e.done),title:z(`files.todoEdit`),onClick:()=>o({id:e.id,text:e.text}),children:e.text}),(0,V.jsx)(H,{hit:`tight`,className:`text-subtle`,"aria-label":z(`files.todoRemove`,{text:e.text}),onClick:()=>void f({ops:[{op:`remove`,id:e.id}]}),children:`×`})]},e.id)),(0,V.jsx)(`input`,{className:kW,value:r,maxLength:500,placeholder:z(`files.todoAdd`),"aria-label":z(`files.todoAdd`),autoComplete:`off`,enterKeyHint:`done`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()}})]}),(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(H,{disabled:!_,title:_?z(`files.todoSendHint`,{count:FP(t).length}):z(`files.todoNoneOpen`),onClick:()=>_&&void OW(e,t.id,_),children:z(`files.todoSend`)})}),(0,V.jsx)(`textarea`,{className:AW,value:s,maxLength:2e4,spellCheck:!1,placeholder:z(`files.notesPlaceholder`),"aria-label":z(`files.notesLabel`),onFocus:()=>{l.current=!0},onChange:e=>{c(e.target.value),d.current!==null&&window.clearTimeout(d.current);let t=e.target.value;d.current=window.setTimeout(()=>p(t),MW)},onBlur:e=>{l.current=!1,p(e.target.value)}})]})}function PW(e){let t=e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived,n=e.changes;return t&&!!n&&`added`in n&&n.added+n.deleted>0}function FW(e){return[...PW(e)?[`commit`]:[],...IW(e)]}function IW(e){let t=e.pr;if(!t)return e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived&&!e.sessionPrs?.length?[`createPR`]:[];if(t.lifecycle===`merged`)return e.archived||e.kind===`main`?[]:[`archive`];if(t.lifecycle!==`open`&&t.lifecycle!==`ready_to_merge`)return[];let n=[];return((t.mergeable??``).toUpperCase()===`CONFLICTING`||e.prChip===`conflict`)&&n.push(`conflicts`),t.checkState===`failing`&&n.push(`fixCI`),(t.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`&&n.push(`comments`),n}async function LW(e,t,n){try{let r=await e.client.request(`task.prompt`,{taskId:t.id,kind:n});r.outcome===`unavailable`?G(z(`files.stripUnavailable`,{detail:r.detail??``}),`error`):r.outcome===`none`||!r.prompt?G(z(`files.stripNothing`),`error`):await OW(e,t.id,r.prompt)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}var RW={commit:`files.stripCommit`,createPR:`files.stripCreate`,conflicts:`files.stripConflicts`,fixCI:`files.stripFixCi`,comments:`files.stripComments`,archive:`files.stripArchive`};function zW({model:e,task:t}){let n=FW(t);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:n.map(n=>(0,V.jsx)(H,{onClick:()=>n===`archive`?void ZP(e,t):void LW(e,t,n),children:z(RW[n])},n))})}var BW=e=>`${e.files} file${e.files===1?``:`s`}, +${e.added} −${e.removed}${e.base?` vs ${e.base}`:``}`;function VW(e){let t=[`**${e.title}**`,`Branch \`${e.branch}\` · ${BW(e)}`];return e.pr?.url&&t.push(`PR: ${e.pr.url}`),e.checks&&t.push(`Checks: ${e.checks}`),e.text&&t.push(``,e.reported?e.text:`Last reply:\n${e.text}`),e.openTodos.length>0&&t.push(``,`Still open:`,...e.openTodos.map(e=>`- ${e}`)),t.join(`
130
- `)}function HW(e){let t=[`## Summary`,``,e.text??e.title,``,`## Changes`,``,`- ${BW(e)} on \`${e.branch}\``];return e.checks&&t.push(`- Checks: ${e.checks}`),e.openTodos.length>0&&t.push(``,`## Not done`,``,...e.openTodos.map(e=>`- [ ] ${e}`)),t.join(`
131
- `)}function UW(e){let t=[e.pass?`${e.pass} passed`:``,e.fail?`${e.fail} failed`:``,e.pending?`${e.pending} pending`:``].filter(Boolean);return t.length>0?t.join(` · `):null}async function WW(e){try{await navigator.clipboard.writeText(e),G(z(`files.report.copied`))}catch{G(z(`menu.copyFailed`),`error`)}}function GW(e){B();let{model:t,task:n}=e,[r,i]=(0,g.useState)(!e.narrow),[a,o]=(0,g.useState)(null),s=!!n.report?.summary;(0,g.useEffect)(()=>{if(s)return;let e=!0;return Fs(t,`output.read`,{taskId:n.id,limit:8}).then(t=>e&&o(YI(t)),()=>{}),()=>{e=!1}},[t,n.id,s,n.rowStatus?.since]);let c=(0,g.useMemo)(()=>{let r=Ns(t,`pr.checks`,{taskId:n.id}),i=r?.outcome===`ok`?gW(r.checks):null;return{title:n.label||n.title,branch:n.branch,base:e.base,files:new Set(e.files.map(e=>e.path)).size,added:e.files.reduce((e,t)=>e+(t.added??0),0),removed:e.files.reduce((e,t)=>e+(t.deleted??0),0),text:n.report?.summary??a,reported:s,checks:i?UW(i):n.pr?.checkState&&n.pr.checkState!==`unknown`?n.pr.checkState:null,openTodos:FP(n).map(e=>e.text),pr:n.pr?{number:n.pr.number,url:n.pr.url}:null}},[t,n,e.base,e.files,a,s]);return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1 px-2 pb-2 font-mono text-meta`,children:[(0,V.jsxs)(H,{variant:`row`,"aria-expanded":r,className:`flex items-center gap-1.5 text-left text-muted hover:text-ink`,onClick:()=>i(!r),children:[(0,V.jsx)(Ma,{right:!r}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[z(`files.report.title`),` · `,c.files,` · +`,c.added,` −`,c.removed]})]}),r&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`m-0 text-muted`,children:[c.branch,c.base?` → ${c.base}`:``,c.checks?` · ${c.checks}`:``,c.openTodos.length>0?` · ${z(`files.report.todos`,{count:c.openTodos.length})}`:``]}),c.text?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`text-subtle`,children:z(s?`files.report.claimed`:`files.report.lastReply`)}),(0,V.jsx)(`p`,{className:`m-0 max-h-24 overflow-y-auto whitespace-pre-wrap wrap-anywhere text-ink`,children:c.text})]}):(0,V.jsx)(`span`,{className:`text-subtle`,children:z(`files.report.none`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,V.jsx)(H,{hit:`tight`,onClick:()=>void WW(VW(c)),children:z(`files.report.copyNote`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>void WW(HW(c)),children:z(`files.report.copyPr`)})]})]})]})}var KW=2e3;function qW({model:e,task:t}){B();let n=t.id,r=!t.machine,[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),c=i?.running===!0;if((0,g.useEffect)(()=>{if(!r)return;let t=!0,i=()=>e.client.request(`run.status`,{taskId:n}).then(e=>t&&a(e),()=>{});i();let o=c?window.setInterval(()=>void i(),KW):0;return()=>{t=!1,window.clearInterval(o)}},[e,n,r,c]),!r||!i?.script)return null;let l=async t=>{s(!0);try{a(await e.client.request(t,{taskId:n}))}catch(e){G(e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}};return(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:[i.url&&(0,V.jsx)(H,{onClick:()=>i.url&&Hk(n,i.url),children:z(`files.run.open`,{port:i.port??``})}),(0,V.jsx)(H,{disabled:o,onClick:()=>void l(c?`run.stop`:`run.start`),children:z(c?`files.run.stop`:`files.run.run`)})]})}var JW={"session-start":{glyph:`○`,tone:`text-muted`},"turn-start":{glyph:`▶`,tone:`text-info`},"turn-complete":{glyph:`✓`,tone:`text-success`},"turn-failed":{glyph:`✗`,tone:`text-error`},"turn-interrupted":{glyph:`■`,tone:`text-warning`},"awaiting-input":{glyph:`?`,tone:`text-warning`},"session-end":{glyph:`○`,tone:`text-muted`},"tool-failed":{glyph:`!`,tone:`text-error`},"pre-compact":{glyph:`≈`,tone:`text-muted`},"post-compact":{glyph:`≈`,tone:`text-muted`},"subagent-start":{glyph:`↳`,tone:`text-muted`},"subagent-stop":{glyph:`↲`,tone:`text-muted`},commit:{glyph:`◆`,tone:`text-accent`},"pr-opened":{glyph:`⇡`,tone:`text-success`},"pr-merged":{glyph:`⇡`,tone:`text-merged`},"pr-closed":{glyph:`⇡`,tone:`text-muted`},"pr-failing":{glyph:`⇡`,tone:`text-error`},"pr-passing":{glyph:`⇡`,tone:`text-success`},"pr-conflict":{glyph:`⇡`,tone:`text-error`},"pr-changes":{glyph:`⇡`,tone:`text-warning`}},YW={glyph:`·`,tone:`text-muted`};function XW(e){return e.kind===`commit`?{to:`diff`}:e.kind.startsWith(`pr-`)?e.url?{to:`pr`,url:e.url}:null:e.tabId?{to:`tab`,tabId:e.tabId}:null}function ZW(e,t){if(!t)return[];if(!e)return[`pr-opened`];let n=[];if(e.lifecycle!==t.lifecycle&&(t.lifecycle===`merged`?n.push(`pr-merged`):t.lifecycle===`closed`&&n.push(`pr-closed`)),e.lifecycle===`unknown`)return n;e.checkState!==t.checkState&&(t.checkState===`failing`?n.push(`pr-failing`):t.checkState===`passing`&&n.push(`pr-passing`));let r=e=>(e.mergeable??``).toUpperCase()===`CONFLICTING`;r(t)&&!r(e)&&n.push(`pr-conflict`);let i=e=>(e.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`;return i(t)&&!i(e)&&n.push(`pr-changes`),n}function QW(e,t){return[...e,...t].sort((e,t)=>t.at-e.at)}var $W=_({}),eG=400,tG=15e3,nG=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function rG(e,t){if(!e||e.id!==t.id)return;let n=ZW(e.pr,t.pr);if(n.length===0)return;let r=Date.now(),i=n.map(e=>({kind:e,at:r,tail:t.pr?.number===void 0?``:`#${t.pr.number}`,...t.pr?.url?{url:t.pr.url}:{}})),a=$W.get();$W.set({...a,[t.id]:[...a[t.id]??[],...i].slice(-50)})}function iG(e){let t=(0,g.useRef)(void 0);(0,g.useEffect)(()=>{rG(t.current,e),t.current=e},[e])}function aG({model:e,task:t}){B();let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),o=v($W)[t.id],s=JSON.stringify([t.rowStatus,t.tabStatus,t.changes,t.pr,t.updatedAt]),c=(0,g.useRef)(0),l=(0,g.useRef)(()=>{});l.current=()=>{c.current=Date.now(),e.client.request(`task.timeline`,{taskId:t.id}).then(e=>{r(e.entries),a(null)},e=>a(e instanceof Error?e.message:String(e)))},(0,g.useEffect)(()=>{let e=window.setTimeout(()=>l.current(),Math.max(0,c.current+eG-Date.now()));return()=>window.clearTimeout(e)},[s]),(0,g.useEffect)(()=>{let e=window.setInterval(()=>l.current(),tG);return()=>window.clearInterval(e)},[]);let u=QW(n??[],o??[]),d=n=>{let r=XW(n);r?.to===`tab`?e.select(t.id,r.tabId):r?.to===`diff`?Vk({taskId:t.id,path:`.`,scope:`branch`}):r?.to===`pr`&&window.open(r.url,`_blank`,`noopener`)};return(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[i&&(0,V.jsx)(`p`,{className:`mono text-error`,children:i}),!i&&n!==null&&u.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(`files.activityEmpty`)}),u.map(e=>{let t=JW[e.kind]??YW,n=e.kind in JW?z(`files.activityKind.${e.kind}`):e.kind,r=XW(e);return(0,V.jsxs)(H,{variant:`row`,className:Qn({size:`file`}),disabled:!r,title:e.tail?`${n} · ${e.tail}`:n,onClick:()=>d(e),children:[(0,V.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:nG(e.at)}),(0,V.jsx)(`span`,{className:`${nr} ${t.tone}`,children:t.glyph}),(0,V.jsxs)(`span`,{className:$n,children:[n,e.tail&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,e.tail]})]})]},`${e.at}:${e.kind}:${e.tabId??``}:${e.sha??``}:${e.tail}`)})]})}function oG({tabs:e,value:t,onChange:n,className:r}){return(0,V.jsx)(`div`,{className:ke(`flex gap-1`,r),role:`tablist`,children:e.map(e=>{let r=e.id===t;return(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:ke(`relative rounded-sm px-2.5 py-0.75 font-mono text-meta font-semibold`,`touch:after:absolute touch:after:content-[''] touch:after:-inset-x-0.5 touch:after:-top-2 touch:after:-bottom-1.5`,r?`bg-inset text-ink group-focus-within/pane:text-accent`:`text-muted`),onClick:()=>n(e.id),children:e.label},e.id)})})}var sG=[`all`,`changes`,`activity`,`notes`],cG={M:`text-warning`,A:`text-success`,"?":`text-success`,D:`text-error`,R:`text-accent`};function lG({model:e,task:t,narrow:n=!1}){let r=Ko();B();let[i,a]=(0,g.useState)(`all`),[o,s]=(0,g.useState)(`working`),[c,l]=(0,g.useState)(()=>Ns(e,`files.list`,{taskId:t.id})?.files??null),[u,d]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.id})??null),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(new Set),[_,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(0),S=(0,g.useRef)(null);iG(t);let C=v(ln),w=JSON.stringify(t.changes??null);(0,g.useEffect)(()=>{let n=!0,r=e=>n&&p(e instanceof Error?e.message:String(e));return Fs(e,`files.list`,{taskId:t.id}).then(e=>{n&&(l(e.files),p(null))},r),Fs(e,`diff.files`,{taskId:t.id}).then(e=>n&&d(e),r),()=>{n=!1}},[e,t.id,w,b]);let T=u?.base??null,E=i===`all`?c!==null:u!==null,D=o===`branch`&&T!=null,O=i===`activity`||i===`notes`?[]:i===`all`?TW(c??[],m).map(e=>({path:e.path,label:e.name,depth:e.depth,dir:e.dir,open:e.open})):(u?.files??[]).filter(e=>e.scope===(D?`branch`:`working`)).map(e=>({path:e.path,label:e.path,depth:0,dir:!1,open:!1,status:e.status,added:e.added,deleted:e.deleted})),k=Math.min(_,Math.max(0,O.length-1)),A=O[k],j=(e,t)=>h(n=>{let r=new Set(n);return t??!r.has(e)?r.add(e):r.delete(e),r}),ee=e=>Vk({taskId:t.id,path:e,scope:i===`changes`&&D?`branch`:`working`}),M=n=>{if(!C?.startsWith(`${t.id}::`)){G(z(`files.mentionNoEngine`),`error`);return}e.client.request(`term.input`,{stream:C,data:`@${n} `}).catch(e=>G(String(e),`error`))},N=n=>t.machine?G(z(`files.remoteNoExternal`,{host:t.machine.label}),`error`):void e.client.request(`file.openExternal`,{taskId:t.id,path:n}).then(()=>G(z(`taskops.openedExternal`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsxs)(`div`,{className:`group/pane flex min-h-0 min-w-0 flex-1 flex-col outline-none ${n?`px-1.5 pt-2.5 pb-2`:`pt-0.5 pr-1.5 pb-1.5 pl-0`}`,tabIndex:0,ref:S,onKeyDown:e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)y(Math.min(O.length-1,k+1));else if(t===`k`||t===`ArrowUp`)y(Math.max(0,k-1));else if((t===`l`||t===`ArrowRight`)&&A?.dir)j(A.path,!0);else if((t===`h`||t===`ArrowLeft`)&&A?.dir)j(A.path,!1);else if(t===`[`||t===`]`)a(sG[(sG.indexOf(i)+(t===`]`?1:sG.length-1))%sG.length]??`all`);else if(t===`b`&&i===`changes`&&T!=null)s(o===`working`?`branch`:`working`);else if(t===`r`)x(e=>e+1);else if(t===`D`&&e.shiftKey)ee(`.`);else if(t===`d`&&A)ee(A.path);else if(t===`Enter`&&A)A.dir?j(A.path):ee(A.path);else if(t===`a`&&A)M(A.path);else if(t===`o`&&A&&!A.dir)N(A.path);else return;e.preventDefault()},children:[(0,V.jsx)(zW,{model:e,task:t}),(0,V.jsx)(wW,{model:e,task:t}),(0,V.jsx)(qW,{model:e,task:t}),(0,V.jsx)(GW,{model:e,task:t,base:T,files:u?.files??[],narrow:n}),(0,V.jsx)(oG,{className:`px-1 pb-1.5`,tabs:[{id:`all`,label:z(`files.all`)},{id:`changes`,label:z(`files.changes`)},{id:`activity`,label:z(`files.activity`)},{id:`notes`,label:z(`files.notes`)}],value:i,onChange:e=>{a(e),y(0)}}),i===`changes`&&(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-2.5 gap-y-1 px-2 pb-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:D?z(`files.scopeBranch`,{base:T??``}):z(`files.scopeWorking`)}),T==null?u&&(0,V.jsx)(`span`,{children:z(`files.noBase`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(o===`working`?`branch`:`working`),children:z(r?`files.toggleScopeTouch`:`files.toggleScope`)}),(0,V.jsx)(ST,{text:z(`files.legend`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>ee(`.`),children:z(r?`files.diffAllTouch`:`files.diffAll`)})]}),i===`activity`?(0,V.jsx)(aG,{model:e,task:t}):i===`notes`?(0,V.jsx)(NW,{model:e,task:t}):(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f&&(0,V.jsx)(`p`,{className:`mono text-error`,children:f}),!f&&E&&O.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(i===`all`?`files.emptyAll`:`files.emptyChanges`)}),O.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:Qn({selected:t===k,size:n?`file-narrow`:`file`}),style:{paddingLeft:8+e.depth*14},title:e.path,onClick:()=>{y(t),S.current?.focus(),e.dir?j(e.path):ee(e.path)},children:[e.status?(0,V.jsx)(`span`,{className:`${nr} ${cG[e.status]??``}`,children:e.status}):(0,V.jsx)(`span`,{className:`${nr} grid place-items-center text-subtle`,children:e.dir?(0,V.jsx)(Ma,{right:!e.open}):null}),(0,V.jsx)(`span`,{className:$n,children:e.label}),e.added?(0,V.jsxs)(yL,{tone:`added`,children:[`+`,e.added]}):null,e.deleted?(0,V.jsxs)(yL,{tone:`removed`,children:[`−`,e.deleted]}):null]},e.path))]})]})}function uG({children:e}){return(0,V.jsx)(`svg`,{className:`size-3.5 ${iI}`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:e})}var dG={chat:(0,V.jsx)(`path`,{d:`M3 3.5h10a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8l-3 2.5v-2.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1zM5 6.5h6M5 8.5h4`}),files:(0,V.jsx)(`path`,{d:`M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z`}),diff:(0,V.jsx)(`path`,{d:`M3.5 2.5h9a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM8 5v4M6 7h4M6 11h4`}),browser:(0,V.jsx)(`path`,{d:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM2 8h12M8 2c2.2 2 2.2 10 0 12M8 2c-2.2 2-2.2 10 0 12`})};function fG(e){if(e.kind===`files`)return z(`panel.files`);if(e.kind===`chat`)return z(`panel.chat`);if(e.kind===`diff`)return e.path===`.`?z(`panel.diff`):JO(e.path);let t=qO(e);return t?YO(t):z(`panel.browser`)}function pG(e){return e.kind===`diff`?e.path===`.`?z(`preview.whole`):e.path:e.kind===`browser`&&qO(e)||fG(e)}var mG=7.3,hG=51,gG=160;function _G(e,t){let n=0;for(let t of e){let e=0;for(let n of t)e+=(n.codePointAt(0)??0)>11903?2:1;n+=Math.min(gG,hG+e*mG)+2}return n<=t}var vG=null;function yG(e,t,n,r){let i=(t,r)=>({label:r,section:`move`,run:()=>Rk(e,e=>gk(e,n.id,t))}),a=[];return!t.bottom&&t.top.tabs.length>1?a.push(i(`bottom`,z(`panel.splitDown`))):t.bottom&&a.push(r===`top`?i(`bottom`,z(`panel.moveBottom`)):i(`top`,z(`panel.moveTop`))),a.push({label:z(`panel.close`),section:`close`,run:()=>Uk(e,n.id)}),t.top.tabs.length+(t.bottom?.tabs.length??0)>1&&a.push({label:z(`panel.closeOthers`),section:`close`,run:()=>Rk(e,e=>hk(e,n.id))}),a}function bG(e,t){return[{label:z(`panel.newChat`),run:()=>Rk(e,e=>ck(e,`chat`))},{label:z(`panel.newFiles`),run:()=>Rk(e,e=>ik(e,t))},{label:z(`panel.newDiff`),run:()=>Rk(e,e=>ok(e,`.`,`working`))},{label:z(`panel.newBrowser`),run:()=>Rk(e,e=>ak(e,t))}]}function xG({taskId:e,panel:t,group:n,tabs:r,active:i,narrow:a,children:o}){B();let[s,c]=(0,g.useState)(null),l=()=>vG?.taskId===e,u=t=>{let r=vG;vG=null,c(null),r?.taskId===e&&Rk(e,e=>gk(e,r.id,n,t))},d=t=>{let r=t.currentTarget.getBoundingClientRect();nn.set({x:r.left,y:r.bottom+2,items:bG(e,n),target:t.currentTarget})},f=(e,t)=>{if(!l())return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();c({id:t,after:e.clientX>n.left+n.width/2})},p=(0,g.useRef)(null),[m,h]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(([e])=>h(e?.contentRect.width??0));return t.observe(e),()=>t.disconnect()},[]);let _=m>0&&!_G(r.map(fG),m);return(0,g.useEffect)(()=>{p.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,r.length,_]),(0,V.jsxs)(`div`,{className:uI(a),style:{gridRow:n===`top`?1:4},onDragOver:e=>{l()&&(e.preventDefault(),c(null))},onDrop:e=>{e.preventDefault(),u()},children:[(0,V.jsx)(`div`,{className:dI,role:`tablist`,"aria-label":z(`panel.tabs`),ref:p,children:r.map((r,o)=>(0,V.jsxs)(`div`,{role:`presentation`,className:fI({active:r.id===i,compact:_}),"data-drop":s?.id===r.id?s.after?`after`:`before`:void 0,draggable:!a,onDragStart:()=>{vG={taskId:e,id:r.id}},onDragEnd:()=>{vG=null,c(null)},onDragOver:e=>f(e,r.id),onDrop:e=>{e.preventDefault(),e.stopPropagation(),u(o+(s?.id===r.id&&s.after?1:0))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),Uk(e,r.id))},onContextMenu:i=>{a||JU(i,yG(e,t,r,n))},children:[(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r.id===i,className:pI(_&&r.id!==i),title:pG(r),onClick:()=>Rk(e,e=>ek(e,r.id)),children:[(0,V.jsx)(uG,{children:dG[r.kind]}),(0,V.jsx)(`span`,{className:`${mI} ${_&&r.id!==i?`hidden`:``}`,children:fG(r)})]}),(0,V.jsx)(`button`,{type:`button`,className:`${hI} ${_&&r.id!==i?`hidden`:``}`,"aria-label":z(`panel.close`),tabIndex:-1,onClick:()=>Uk(e,r.id),children:`×`})]},r.id))}),!a&&(0,V.jsx)(`button`,{type:`button`,className:aI({tool:!0}),title:z(`panel.new`),"aria-label":z(`panel.new`),onClick:d,children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M8 3.5v9M3.5 8h9`})})}),o]})}var SG={md:`md`,markdown:`md`,html:`html`,htm:`html`,svg:`svg`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,pdf:`pdf`};function CG(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<0?null:SG[t.slice(n+1).toLowerCase()]??null}function wG(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var TG=e=>new TextDecoder().decode(wG(e));function EG(e,t){if(e===`svg`)return`image/svg+xml`;if(e===`pdf`)return`application/pdf`;let n=t.slice(t.lastIndexOf(`.`)+1).toLowerCase();return n===`jpg`||n===`jpeg`?`image/jpeg`:n===`gif`?`image/gif`:n===`webp`?`image/webp`:`image/png`}var DG=`default-src 'none'; img-src data:; style-src 'unsafe-inline'`;function OG(e){let t=`<meta http-equiv="Content-Security-Policy" content="${DG}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}var kG=/^\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/,AG=/^https?:\/\/[^\s<>)\]]+/,jG=/[\p{L}\p{N}]/u;function MG(e){let t=[],n=``,r=()=>{n&&t.push({t:`text`,v:n}),n=``},i=0;for(;i<e.length;){let a=e.slice(i),o=e[i]??``;if(o==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({t:`code`,v:e.slice(i+1,n)}),i=n+1;continue}}else if(a.startsWith(`**`)){let n=e.indexOf(`**`,i+2);if(n>i+2){r(),t.push({t:`bold`,c:MG(e.slice(i+2,n))}),i=n+2;continue}}else if(o===`*`||o===`_`&&!jG.test(e[i-1]??``)){let n=e.indexOf(o,i+1);if(n>i+1&&!/\s/.test(e[i+1]??` `)&&(o===`*`||!jG.test(e[n+1]??``))){r(),t.push({t:`em`,c:MG(e.slice(i+1,n))}),i=n+1;continue}}else if(o===`[`){let e=kG.exec(a);if(e){r(),t.push({t:`link`,href:e[2],c:MG(e[1])}),i+=e[0].length;continue}}else if(o===`h`&&!jG.test(e[i-1]??``)){let e=AG.exec(a);if(e){let n=e[0].replace(/[.,;:!?]+$/,``);r(),t.push({t:`link`,href:n,c:[{t:`text`,v:n}]}),i+=n.length;continue}}n+=o,i++}return r(),t}var NG=/^\s*(```+|~~~+)\s*([\w+#.-]*)\s*$/,PG=/^(#{1,6})\s+(.*?)\s*#*\s*$/,FG=/^(\s*)([-*+])\s+(.*)$/,IG=/^(\s*)\d+[.)]\s+(.*)$/,LG=/^\s*([-*_])(\s*\1){2,}\s*$/,RG=/^\s*\|.*\|\s*$/,zG=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/,BG=e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());function VG(e){let t=e.replace(/\r\n?/g,`
129
+ `)}}var zU=`min-h-0 w-full overflow-y-auto`,BU=`mx-auto mt-[min(16vh,8rem)] flex w-full max-w-130 flex-col gap-4 px-5 pb-7`,VU=`relative grid w-full select-none overflow-hidden font-mono text-(length:--fs-body) text-subtle [contain:layout_paint]`,HU=`col-start-1 row-start-1 m-0 whitespace-pre font-[inherit] leading-[inherit]`,UU=`invisible absolute top-0 left-0 whitespace-pre`,WU=1.3,GU=`0000000000`,KU=1e3/12;function qU(){let e=(0,g.useRef)(null),t=(0,g.useRef)(null),n=(0,g.useRef)(null),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let i=e.current,a=t.current,o=n.current,s=r.current;if(!i||!a||!o||!s)return;let c=window.matchMedia(`(prefers-reduced-motion: reduce)`),l=24,u=90,d=0,f=0,p=0,m=-1,h=!0,g=()=>{let e=RU(u,l);o.textContent=e.base,s.textContent=e.accent},_=()=>{let e=a.getBoundingClientRect().width/10;e>0&&(l=Math.min(64,Math.max(24,Math.floor(i.clientWidth/e)))),g()},v=e=>{d=requestAnimationFrame(v);let t=p+Math.floor((e-f)/KU);t!==m&&(m=t,u=t,g())},y=()=>{cancelAnimationFrame(d),d=0},b=()=>{y(),c.matches?(u=90,g()):h&&document.visibilityState===`visible`&&(f=performance.now(),p=u,m=-1,d=requestAnimationFrame(v))},x=new ResizeObserver(_);x.observe(i),_(),b();let S=new IntersectionObserver(e=>{h=e[e.length-1]?.isIntersecting??!0,b()});return S.observe(i),c.addEventListener(`change`,b),document.addEventListener(`visibilitychange`,b),()=>{y(),x.disconnect(),S.disconnect(),c.removeEventListener(`change`,b),document.removeEventListener(`visibilitychange`,b)}},[]),(0,V.jsxs)(`div`,{ref:e,"aria-hidden":`true`,"data-field":`first-run-art`,className:VU,style:{height:`${11*WU}em`,lineHeight:WU},children:[(0,V.jsx)(`span`,{ref:t,className:UU,children:GU}),(0,V.jsx)(`pre`,{ref:n,className:HU}),(0,V.jsx)(`pre`,{ref:r,className:`${HU} text-accent`})]})}function JU(e){let t=q(`doctor`,`fix.humanOnlyWhy`),n=[];if(e.git||n.push({id:`git`,label:q(`doctor`,`fix.git`),action:q(`doctor`,`fix.gitAction`),why:t}),e.engines.length===0){let r=e.signedOut.length>0;n.push({id:`engine`,label:q(`doctor`,r?`fix.noEngineLogin`:`fix.noEngine`),action:q(`doctor`,r?`fix.noEngineLoginAction`:`fix.noEngineAction`,{list:e.signedOut.map(e=>e.id).join(`, `)}),why:t})}return n}function YU({model:e}){B(),v(Kr);let[t,n]=(0,g.useState)(()=>Ns(e,`welcome.env`)??null);(0,g.useEffect)(()=>{let t=!0;return Fs(e,`welcome.env`).then(e=>t&&n(e)).catch(()=>{}),()=>{t=!1}},[e]);let r=t===null?null:t.engines.length>0?{key:`enginesFound`,warn:!1,list:t.engines.map(e=>e.name).join(`, `)}:t.signedOut.length>0?{key:`enginesSignedOut`,warn:!0,list:t.signedOut.map(e=>e.name).join(`, `)}:{key:`enginesMissing`,warn:!0,list:``},i=t!==null&&(t.engines.length===0||!t.git)?JU(t):[];return(0,V.jsx)(`div`,{className:zU,"data-field":`welcome`,children:(0,V.jsxs)(`div`,{className:BU,children:[(0,V.jsx)(qU,{}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-ink`,children:z(`firstRun.title`)}),(0,V.jsx)(`p`,{className:`m-0 font-sans text-body text-muted`,children:z(`firstRun.body`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,className:je(),"data-field":`start-first-task`,onClick:()=>KD(t?.start?.repo),children:z(`firstRun.start`)}),(0,V.jsx)(`span`,{className:`keys-only mono text-meta text-subtle`,children:ti(`task.new.global`)})]}),t!==null&&r!==null&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-sans text-meta`,children:[(0,V.jsx)(`p`,{className:`m-0 ${r.warn?`text-warning`:`text-subtle`}`,children:q(`workspace`,`welcome.${r.key}`,{list:r.list})}),!t.git&&(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:q(`workspace`,`welcome.gitMissing`)}),i.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:e.label}),(0,V.jsx)(`p`,{className:`mono m-0 text-accent`,children:e.action}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:e.why})]},e.id)),i.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:q(`common`,`failureHint`,{command:`rove doctor`})})]})]})})}function XU(e,t){e.preventDefault(),nn.set({x:e.clientX,y:e.clientY,items:t,target:e.currentTarget,fromKeyboard:e.button!==2})}function ZU({model:e,narrow:t}){let n=B(),r=v(e.tasks),i=v(e.remote),a=gE(e),o=v(e.tabs),s=v(e.tabsSettled),c=v(e.selection),l=r?.tasks??[],u=r?.attention.filter(e=>e.unread).length??0,d=c.taskId,f=new Map([...l,...i].map(e=>[e.id,e])),p=gU(),m=v(LT),h=v(AT)===`state`,_=v(RT),y=e=>(h?nO:gw)({tasks:l,remote:i,machines:a,sort:p.sort,query:e,fold:{...p.hand,selectedId:d??void 0}}),b=y(p.search.active?p.search.query:``),{groups:x}=b,S=p.search.active?b.rows:xH(vw(SU(rO(NH(b.rows,o,c.taskId,s,_)),o),p.collapsed),r?.archived??[],p.archivedOpen,{...p.hand,selectedId:d??void 0}),C=e=>e.filter(e=>e.kind!==`project`&&e.kind!==`state`&&e.kind!==`round`),w=(n===`zh`?Dr:Er).machine,T=new Set(a.filter(e=>e.state!==`online`).map(e=>e.alias)),E=x.find(e=>e.tasks.some(e=>e.kind===`main`))?.repo,D=e=>({mainTaskId:x.find(t=>t.repo===e)?.tasks.find(e=>e.kind===`main`)?.id??null,label:zC(e),first:e===E}),O=jH(e,l,!p.search.active&&!h,p.sort==="default",D),k=O.places(S),A=()=>W.set((0,V.jsx)(FP,{model:e})),j=bU(e,S,p,{selectedId:d,onNewTask:KD,onSettings:A}),ee=_!==null&&S.some(e=>e.id===_),M=j.setCursor;(0,g.useEffect)(()=>{ee&&_!==null&&M(_)},[ee,_,M]);let N=C(y(``).rows).length,P=(0,g.useRef)(null),F=v(tI)&&!t,I=v(nI)&&F,te=t?l.find(e=>e.id===c.taskId&&!e.deleting)??null:null;return(0,V.jsxs)(`nav`,{className:`${QT} ${F?`is-folded`:``}`,ref:P,inert:F&&!I,"aria-hidden":F&&!I,onMouseEnter:F?()=>iI(!0):void 0,onMouseLeave:F?()=>iI(!1):void 0,tabIndex:0,onKeyDown:e=>{OF(`sidebar`),j.onKeyDown(e)},children:[(0,V.jsxs)(`header`,{className:$T,children:[(0,V.jsxs)(`span`,{className:`${zt} mr-auto`,children:[(0,V.jsx)(`span`,{className:Bt,children:`[`}),` rove `,(0,V.jsx)(`span`,{className:Bt,children:`]`})]}),(0,V.jsxs)(`span`,{className:`relative`,children:[(0,V.jsx)(`button`,{type:`button`,className:`m-0 text-meta font-medium normal-nums inbox-chip relative ${Xn} ${He} ${u>0?`text-accent`:`text-muted`}`,onClick:()=>W.set((0,V.jsx)(DT,{model:e})),children:z(`rail.inbox`,{count:u})}),(0,V.jsx)(xF,{model:e,bindingId:`inbox.show`,head:!0})]}),(0,V.jsx)(kM,{})]}),m&&(0,V.jsxs)(`div`,{className:`flex gap-1 px-3.5 pb-2 text-meta mono`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:q(`tasks`,`moveChip`).trim()}),(0,V.jsx)(`span`,{className:`keys-only ml-1.5 text-muted`,children:(0,V.jsx)(ST,{text:z(`taskops.moveHint`)})})]}),p.search.active&&(0,V.jsx)(wU,{query:p.search.query,count:`${C(S).length}/${N}`,onChange:e=>p.setSearch(t=>({...t,query:e}))}),(0,V.jsx)(JI,{model:e}),(0,V.jsx)(fH,{model:e}),(0,V.jsxs)(`div`,{"data-rail-body":!0,className:rE(O.dragging!==null),...O.body,children:[r&&l.length===0&&i.length===0&&t&&(0,V.jsx)(YU,{model:e}),r&&l.length===0&&i.length===0&&!t&&(0,V.jsx)(`p`,{className:`m-0 px-2 py-3 font-mono text-meta text-subtle`,children:z(`rail.empty`)}),te&&(0,V.jsx)(NI,{title:te.title}),S.map((t,n)=>t.kind===`round`?(0,V.jsx)(CU,{row:t,guides:t.depth>1?kH(S,n):void 0,repo:h&&t.depth===1?eO(t.tasks[0]):void 0,cursor:t.id===j.cursor,place:k(t),onClick:()=>j.setCursor(t.id)},t.id):t.kind===`pane`?(0,V.jsx)(JH,{model:e,row:t,guides:kH(S,n),cursor:t.id===j.cursor,place:k(t),onClick:()=>{j.setCursor(t.id),qH(e,t),pa()},onMenu:n=>{j.setCursor(t.id),XU(n,UH(e,t.task.id,t.tab,t.leaf))}},t.id):(0,V.jsx)(QU,{row:t,guides:t.kind===`task`&&t.depth>1?kH(S,n):void 0,cloud:pE(t,a,w),repo:h&&t.kind===`task`&&t.depth===1?eO(t.task):void 0,tabs:t.kind===`task`?o[t.task.id]:void 0,selected:t.id===d,cursor:t.id===j.cursor,stale:t.machine!==void 0&&T.has(t.machine),collapsed:(t.kind===`project`||t.kind===`state`)&&p.collapsed.has(t.id),drag:O.props(t),dragging:O.dragging===t.id,place:k(t),onNewTask:t.kind===`project`?t.noProject?qD:()=>KD(t.repo,t.machine):void 0,moving:m&&t.machine===void 0&&(t.kind===`project`?!t.noProject&&D(t.repo).mainTaskId===j.cursor:t.id===j.cursor&&(t.kind!==`task`||t.task.kind!==`main`)),prTasks:t.kind===`task`?[t.task,...(t.fold?.descendantIds??[]).flatMap(e=>f.get(e)??[])]:void 0,rollup:t.kind===`task`&&t.fold?.collapsed?GF([t.task,...t.fold.descendantIds.flatMap(e=>f.get(e)??[])]):void 0,onToggleFold:()=>{t.kind===`task`&&p.toggleTaskFold(t.id,t.fold?.collapsed===!0),t.kind===`archived`&&p.toggleArchived()},onClick:()=>{j.setCursor(t.id),t.kind===`archived`&&p.toggleArchived(),(t.kind===`project`||t.kind===`state`)&&p.toggleProject(t.id),t.kind===`task`&&yU(e,t.task.id)},onMenu:n=>{if(t.kind!==`project`||t.machine===void 0){if(t.kind===`project`&&t.noProject){XU(n,aU(e));return}if(t.kind===`project`){let r=D(t.repo);r.mainTaskId&&S.some(e=>e.id===r.mainTaskId)&&j.setCursor(r.mainTaskId),XU(n,iU(e,t.repo,r));return}t.kind===`task`&&(j.setCursor(t.id),XU(n,tW(eW(cU(e,t.task,null),t.fold,()=>p.toggleTaskFold(t.id,t.fold?.collapsed===!0)),KH(e,t.task.id))))}}},t.id))]}),(0,V.jsx)(MH,{model:e,narrow:t,onSettings:A}),(0,V.jsx)(PI,{pane:`sidebar`}),!t&&!F&&(0,V.jsx)(OI,{rail:P})]})}function QU(e){let{row:t}=e,n=OU(t.kind===`task`?t.task.label:``,e.cursor&&t.kind===`task`),r=e.cursor?iE:``;if(t.kind===`project`||t.kind===`state`)return(0,V.jsxs)(`h2`,{className:aE({moving:e.moving,dragging:e.dragging}),onContextMenu:e.onMenu,...e.place,...e.drag,children:[(0,V.jsxs)(`button`,{type:`button`,className:sE,title:t.kind===`project`&&!t.noProject?t.repo:void 0,"aria-expanded":!e.collapsed,onClick:e.onClick,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.kind===`state`&&(0,V.jsx)(`span`,{className:`font-normal text-subtle`,children:t.count}),(0,V.jsx)(Ma,{right:e.collapsed,className:cE(!!e.collapsed)})]}),e.onNewTask&&t.kind===`project`&&(0,V.jsx)(`button`,{type:`button`,className:lE,title:z(`rail.newTask`),onClick:e.onNewTask,children:`+`})]});if(t.kind===`archived`)return(0,V.jsx)(`button`,{type:`button`,className:`${Qn({moving:e.moving||e.dragging})} ${r}`,"aria-expanded":t.expanded,onClick:e.onClick,...e.place,children:(0,V.jsx)(`span`,{className:`${er} ${e.stale?`text-subtle`:`text-muted`}`,children:q(`tasks`,`archivedRow`,{count:t.count})})});let i=t.task,a=i.rowStatus?.kind===`running`,o=IP(i);return(0,V.jsxs)(`button`,{type:`button`,ref:n.ref,className:`${Qn({selected:e.selected,moving:e.moving||e.dragging})} ${r}`,onClick:e.onClick,onContextMenu:e.onMenu,onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,...e.place,...e.drag,children:[n.tip,e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:KT(e)},t))}),(0,V.jsx)(`span`,{className:`${er} ${e.stale?`text-subtle`:``} ${a?tr:``}`,children:t.attempt??i.label}),(0,V.jsxs)(`span`,{className:`${rr} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),t.level!==void 0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:t.level}),(i.extraRepoCount??0)>0&&(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.extraRepos`,{count:i.extraRepoCount??0}),children:[`+`,i.extraRepoCount]}),o&&(0,V.jsxs)(`span`,{className:`text-subtle tabular-nums`,title:z(`rail.todos`,o),children:[o.done,`/`,o.total]}),t.fold?.collapsed&&(0,V.jsx)($U,{count:t.fold.count,onUnfold:e.onToggleFold}),i.kept&&(0,V.jsx)(`span`,{className:`text-accent`,title:z(`compare.kept`),children:`✓`}),i.pinned&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`▴`}),i.startsAt&&(0,V.jsx)(kU,{at:i.startsAt}),(0,V.jsx)(yH,{tasks:e.prTasks??[i],onOpen:n.hide}),(0,V.jsx)(QL,{status:t.fold?.collapsed?e.rollup:i.rowStatus}),e.cloud&&(0,V.jsx)(mE,{label:e.cloud})]})]})}function $U(e){let t=q(`tasks`,`menu.expandChildren`);return(0,V.jsxs)(`span`,{role:`button`,tabIndex:-1,"aria-label":t,"aria-expanded":!1,className:`chip text-muted ${qT}`,title:t,onClick:t=>{t.stopPropagation(),e.onUnfold()},children:[e.count,(0,V.jsx)(Ma,{right:!0})]})}function eW(e,t,n){if(!t)return e;let r={label:q(`tasks`,t.collapsed?`menu.expandChildren`:`menu.collapseChildren`),section:`open`,run:n},i=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,i+1),r,...e.slice(i+1)]}function tW(e,t){let n=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,n+1),...t,...e.slice(n+1)]}function nW(e){return e===`localhost`||e.endsWith(`.localhost`)||e===`[::1]`||/^127(\.\d{1,3}){3}$/.test(e)}var rW=/^(localhost|127(\.\d{1,3}){3}|\[::1\])(:\d+)?([/?#]|$)/i,iW=/^[a-z][a-z0-9+.-]*:(?!\d+([/?#]|$))/i;function aW(e){let t=e.trim();if(!t||/\s/.test(t)||iW.test(t)&&!/^https?:\/\//i.test(t))return null;let n=/^https?:\/\//i.test(t)?t:rW.test(t)?`http://${t}`:`https://${t.replace(/^\/\//,``)}`;try{let e=new URL(n);return e.hostname?e.href:null}catch{return null}}function oW(e,t,n=nW(t.hostname)){let r=new URL(e);return r.origin===t.origin?`self`:nW(r.hostname)?n?`yes`:`remote`:r.protocol===`https:`?`yes`:`unreachable`}function sW(e,t,n){let r=new URL(e).host;return t===`self`?{key:`self`,host:r}:t===`remote`?{key:`remote`,host:r}:t===`unreachable`?{key:`noFrame`,host:r}:n&&!n.reachable?{key:`unreachable`,host:r}:n&&!n.frameable?{key:`refuses`,host:r}:null}var cW=6e4,lW=new Map;function uW(e){let t=lW.get(e);return t&&Date.now()-t.at<cW?t:null}function dW(e,t,n){let[,r]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(!n||uW(t))return;let i=!0;return e.request(`browser.probe`,{url:t,origin:window.location.origin}).then(e=>lW.set(t,{probe:e,at:Date.now()}),()=>lW.set(t,{probe:null,at:Date.now()})).then(()=>i&&r(e=>e+1)),()=>{i=!1}},[e,t,n]);let i=n?uW(t):null;return{pending:n&&!i,probe:i?.probe??null}}function fW({d:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e})})}var pW=`M6.5 3.5h-3v9h9v-3M9.5 3.5h3v3M12.5 3.5l-5 5`;function mW({model:e,tab:t,onNavigate:n,onStep:r}){B();let i=qO(t),[a,o]=(0,g.useState)(i),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(0),d=v(e.client.conn).hello?.peer?.local,f=i?oW(i,window.location,d):null;(0,g.useEffect)(()=>{o(i),c(!1)},[i]);let p=e=>{let t=aW(e);c(t===null&&e.trim()!==``),t!==null&&(o(t),t===i?u(l+1):n(t))},m=i?new URL(i).hostname:``,h=f===`yes`&&i.startsWith(`https:`)&&!nW(m),{pending:_,probe:y}=dW(e.client,i,h),b=i&&f?sW(i,f,y):null,x=f===`yes`&&!b&&!_,S=b?z(`browser.${b.key}`,{host:b.host}):f===null?z(s?`browser.invalid`:`browser.empty`):null;return(0,V.jsxs)(`div`,{className:SI,children:[(0,V.jsxs)(`form`,{className:CI,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,V.jsx)(`button`,{type:`button`,className:sI({small:!0}),disabled:t.at<=0,title:z(`browser.back`),"aria-label":z(`browser.back`),onClick:()=>r(t.at-1),children:(0,V.jsx)(fW,{d:`M10 3.5 5.5 8l4.5 4.5`})}),(0,V.jsx)(`button`,{type:`button`,className:sI({small:!0}),disabled:t.at>=t.urls.length-1,title:z(`browser.forward`),"aria-label":z(`browser.forward`),onClick:()=>r(t.at+1),children:(0,V.jsx)(fW,{d:`M6 3.5 10.5 8 6 12.5`})}),(0,V.jsx)(`button`,{type:`button`,className:sI({small:!0}),disabled:!x,title:z(`browser.reload`),"aria-label":z(`browser.reload`),onClick:()=>u(l+1),children:(0,V.jsx)(fW,{d:`M12.5 8a4.5 4.5 0 1 1-1.4-3.3M12.5 2.5v2.7H9.8`})}),(0,V.jsx)(`input`,{className:`browser-url mono ${wI}`,value:a,placeholder:z(`browser.placeholder`),"aria-label":z(`browser.address`),"aria-invalid":s,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,inputMode:`url`,onChange:e=>o(e.target.value)}),i?(0,V.jsx)(`a`,{className:sI({small:!0}),href:i,target:`_blank`,rel:`noopener noreferrer`,title:z(`browser.openTab`),"aria-label":z(`browser.openTab`),children:(0,V.jsx)(fW,{d:pW})}):(0,V.jsx)(`button`,{type:`button`,className:sI({small:!0}),disabled:!0,"aria-label":z(`browser.openTab`),children:(0,V.jsx)(fW,{d:pW})})]}),x?(0,V.jsx)(`iframe`,{className:TI,src:i,title:i,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,referrerPolicy:`no-referrer`},`${i}#${l}`):S?(0,V.jsx)(`p`,{className:xI,children:S}):null]})}var hW=3;function gW({model:e,task:t}){B();let n=t.autoFixCi,r=n=>void e.client.request(`task.autoFixCi`,{taskId:t.id,enabled:n}).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsx)(`div`,{className:`flex items-center gap-3 px-2 pt-1 font-mono text-meta`,children:n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:n.stopped?CT.attention:`text-muted`,title:z(`files.autoFix.hint`),children:z(n.stopped?`files.autoFix.stopped`:`files.autoFix.count`,{n:n.attempts,max:hW})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>r(!1),children:z(`files.autoFix.off`)})]}):(0,V.jsx)(H,{hit:`tight`,title:z(`files.autoFix.hint`),onClick:()=>r(!0),children:z(`files.autoFix.on`)})})}function _W(e){let t=e.pr;return!!t&&t.number!==void 0&&!e.machine&&(t.lifecycle===`open`||t.lifecycle===`ready_to_merge`)}function vW(e){let t={fail:0,pending:0,pass:0,skipped:0};for(let n of e)t[n.state]++;return t}function yW(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h${String(n%60).padStart(2,`0`)}m`}function bW(e){let t=[],n=e.mergeState.toUpperCase();e.draft&&t.push({key:`files.merge.draft`,tone:`warning`}),e.mergeable.toUpperCase()===`CONFLICTING`||n===`DIRTY`?t.push({key:`files.merge.conflicts`,tone:`attention`}):n===`BEHIND`?t.push({key:`files.merge.behind`,tone:`warning`}):n===`UNSTABLE`?t.push({key:`files.merge.unstable`,tone:`warning`}):n===`BLOCKED`?t.push({key:`files.merge.blocked`,tone:`warning`}):n===`CLEAN`&&!e.draft&&t.push({key:`files.merge.clean`,tone:`success`});let r=e.review.toUpperCase();return r===`APPROVED`?t.push({key:`files.merge.approved`,tone:`success`}):r===`CHANGES_REQUESTED`?t.push({key:`files.merge.changes`,tone:`attention`}):r===`REVIEW_REQUIRED`&&t.push({key:`files.merge.reviewRequired`,tone:`warning`}),t}var xW=`flex flex-col gap-0.5 px-2 pb-2 font-mono text-meta`,SW=`flex items-start gap-2`,CW=`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 text-left text-ink`,wW={pass:{glyph:`✓`,tone:`success`},fail:{glyph:`✗`,tone:`attention`},pending:{glyph:`●`,tone:`warning`},skipped:{glyph:`–`,tone:`muted`}};function TW({model:e,task:t}){B();let n=t.pr,r=t.id,[i,a]=(0,g.useState)(()=>Ns(e,`pr.checks`,{taskId:r})??null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({}),[u,d]=(0,g.useState)(0),f=`${n?.number}:${n?.checkState}:${n?.mergeable}:${n?.reviewDecision}`;(0,g.useEffect)(()=>{let t=!0,n={taskId:r};return e.client.request(`pr.checks`,u>0?{...n,fresh:!0}:n).then(r=>{t&&(Ps(e,`pr.checks`,n,r),a(r))},e=>t&&a({outcome:`unavailable`,detail:e instanceof Error?e.message:String(e)})),()=>{t=!1}},[e,r,f,u]);let p=t=>{let n=`${t.runId}:${t.name}`;if(c[n]){l(({[n]:e,...t})=>t);return}l(e=>({...e,[n]:{state:`loading`}})),e.client.request(`pr.checkLog`,{taskId:r,runId:t.runId,job:t.name}).then(e=>e.outcome===`ok`?{state:`text`,text:e.tail}:e.outcome===`none`?{state:`note`,text:z(`files.checks.noLog`)}:{state:`note`,text:z(`files.checks.logUnavailable`,{detail:e.detail})}).catch(e=>({state:`note`,text:z(`files.checks.logUnavailable`,{detail:e instanceof Error?e.message:String(e)})})).then(e=>l(t=>n in t?{...t,[n]:e}:t))},m=(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>d(e=>e+1),children:z(`files.checks.refresh`)});if(!i)return(0,V.jsx)(`div`,{className:xW,children:(0,V.jsx)(`div`,{className:SW,children:(0,V.jsxs)(`span`,{className:`flex-1 text-muted`,children:[z(`files.checks.title`),` `,z(`files.checks.loading`)]})})});if(i.outcome!==`ok`)return(0,V.jsx)(`div`,{className:xW,children:(0,V.jsxs)(`div`,{className:SW,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted wrap-anywhere`,children:i.outcome===`none`?z(`files.checks.none`):z(`files.checks.unavailable`,{detail:i.detail})}),m]})});let h=vW(i.checks),_=o??(h.fail>0||h.pending>0),v=bW(i);return(0,V.jsxs)(`div`,{className:xW,children:[(0,V.jsxs)(`div`,{className:SW,children:[(0,V.jsxs)(H,{variant:`row`,className:CW,"aria-expanded":_,disabled:i.total===0,onClick:()=>s(!_),children:[i.total>0&&(0,V.jsx)(Ma,{right:!_}),(0,V.jsx)(`span`,{children:i.total===0?z(`files.checks.none`):z(`files.checks.summary`,{pass:h.pass+h.skipped,total:i.total})}),h.fail>0&&(0,V.jsx)(`span`,{className:CT.attention,children:z(`files.checks.failed`,{count:h.fail})}),h.pending>0&&(0,V.jsx)(`span`,{className:CT.warning,children:z(`files.checks.running`,{count:h.pending})}),v.map(e=>(0,V.jsx)(`span`,{className:CT[e.tone],children:z(e.key)},e.key))]}),m]}),_&&i.checks.map(e=>{let{glyph:t,tone:n}=wW[e.state],r=`${e.runId}:${e.name}`,i=c[r];return(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 pl-4`,children:[(0,V.jsx)(`span`,{className:`w-[1ch] flex-none text-center ${CT[n]}`,children:t}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),e.durationMs!==null&&(0,V.jsx)(`span`,{className:`flex-none text-subtle`,children:yW(e.durationMs)}),e.state===`fail`&&e.runId&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>p(e),children:z(i?`files.checks.hideLog`:`files.checks.log`)})]}),i&&(0,V.jsx)(`pre`,{className:`m-0 ml-4 mb-1 max-h-40 overflow-y-auto rounded-sm border-hairline border-line bg-inset px-2 py-1.5 whitespace-pre-wrap wrap-anywhere text-muted`,children:i.state===`loading`?z(`files.checks.loading`):i.text})]},`${e.name}:${e.url}`)}),_&&i.total>i.checks.length&&(0,V.jsx)(`span`,{className:`pl-4 text-subtle`,children:z(`files.checks.more`,{count:i.total-i.checks.length})})]})}function EW({model:e,task:t}){return _W(t)?(0,V.jsxs)(`div`,{onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsx)(TW,{model:e,task:t}),(0,V.jsx)(gW,{model:e,task:t})]}):null}function DW(e,t){let n={children:new Map,file:!1};for(let t of e){let e=n;for(let n of t.split(`/`)){let t=e.children.get(n);t||(t={children:new Map,file:!1},e.children.set(n,t)),e=t}e.file=!0}let r=[],i=(e,n,a)=>{let o=[...e.children].sort(([e,t],[n,r])=>{let i=t.children.size>0&&!t.file;return i===(r.children.size>0&&!r.file)?e.localeCompare(n):i?-1:1});for(let[e,s]of o){let o=s.children.size>0&&!s.file,c=o?`${n}${e}/`:`${n}${e}`,l=o&&t.has(c);r.push({path:c,name:e,depth:a,dir:o,open:l}),l&&i(s,c,a+1)}};return i(n,``,0),r}var OW={start:`\x1B[200~`,end:`\x1B[201~`};function kW(e,t){return e.engineTarget(t).tabId??e.tabs.get()[t]?.find(e=>e.kind===`engine`)?.id}async function AW(e,t,n){let r=kW(e,t);if(!r)return G(z(`files.stripNoEngine`),`error`),!1;try{return e.selection.get().tabId!==r&&e.select(t,r),await e.client.request(`term.input`,{stream:yC(t,r),data:`${OW.start}${n}${OW.end}`}),G(z(`files.stripFilled`)),!0}catch(e){return G(e instanceof Error?e.message:String(e),`error`),!1}}var jW=`w-full min-w-0 rounded-sm border-hairline border-line bg-paper px-2 py-1 font-mono text-meta text-ink outline-none placeholder:text-subtle focus-visible:border-accent`,MW=`${jW} min-h-24 resize-none leading-[1.45]`,NW=e=>`min-w-0 flex-1 cursor-text break-words text-left font-mono text-meta ${e?`text-subtle line-through`:`text-ink`}`,PW=700;function FW({model:e,task:t}){B();let n=t.todos??[],[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(t.notes??``),l=(0,g.useRef)(!1),u=(0,g.useRef)(t.notes??``),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{l.current||(u.current=t.notes??``,c(t.notes??``))},[t.notes]),(0,g.useEffect)(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);let f=n=>e.client.request(`task.notes`,{taskId:t.id,...n}).catch(e=>G(String(e),`error`)),p=e=>{d.current!==null&&window.clearTimeout(d.current),d.current=null,e!==u.current&&(u.current=e,f({notes:e}))},m=()=>{let e=r.trim();e!==``&&(i(``),f({ops:[{op:`add`,text:e}]}))},h=()=>{if(!a)return;let e=a.text.trim(),t=n.find(e=>e.id===a.id)?.text;o(null),e===``?f({ops:[{op:`remove`,id:a.id}]}):e!==t&&f({ops:[{op:`edit`,id:a.id,text:e}]})},_=RP(t);return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-2 pb-2 font-mono text-meta`,onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[n.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,V.jsx)(H,{hit:`tight`,className:e.done?`text-subtle`:void 0,"aria-label":z(e.done?`files.todoUncheck`:`files.todoCheck`,{text:e.text}),onClick:()=>void f({ops:[{op:`check`,id:e.id,done:!e.done}]}),children:e.done?`[x]`:`[ ]`}),a?.id===e.id?(0,V.jsx)(`input`,{className:jW,value:a.text,maxLength:500,autoFocus:!0,"aria-label":z(`files.todoEdit`),onChange:t=>o({id:e.id,text:t.target.value}),onBlur:h,onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&o(null)}}):(0,V.jsx)(H,{variant:`row`,className:NW(e.done),title:z(`files.todoEdit`),onClick:()=>o({id:e.id,text:e.text}),children:e.text}),(0,V.jsx)(H,{hit:`tight`,className:`text-subtle`,"aria-label":z(`files.todoRemove`,{text:e.text}),onClick:()=>void f({ops:[{op:`remove`,id:e.id}]}),children:`×`})]},e.id)),(0,V.jsx)(`input`,{className:jW,value:r,maxLength:500,placeholder:z(`files.todoAdd`),"aria-label":z(`files.todoAdd`),autoComplete:`off`,enterKeyHint:`done`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()}})]}),(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(H,{disabled:!_,title:_?z(`files.todoSendHint`,{count:LP(t).length}):z(`files.todoNoneOpen`),onClick:()=>_&&void AW(e,t.id,_),children:z(`files.todoSend`)})}),(0,V.jsx)(`textarea`,{className:MW,value:s,maxLength:2e4,spellCheck:!1,placeholder:z(`files.notesPlaceholder`),"aria-label":z(`files.notesLabel`),onFocus:()=>{l.current=!0},onChange:e=>{c(e.target.value),d.current!==null&&window.clearTimeout(d.current);let t=e.target.value;d.current=window.setTimeout(()=>p(t),PW)},onBlur:e=>{l.current=!1,p(e.target.value)}})]})}function IW(e){let t=e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived,n=e.changes;return t&&!!n&&`added`in n&&n.added+n.deleted>0}function LW(e){return[...IW(e)?[`commit`]:[],...RW(e)]}function RW(e){let t=e.pr;if(!t)return e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived&&!e.sessionPrs?.length?[`createPR`]:[];if(t.lifecycle===`merged`)return e.archived||e.kind===`main`?[]:[`archive`];if(t.lifecycle!==`open`&&t.lifecycle!==`ready_to_merge`)return[];let n=[];return((t.mergeable??``).toUpperCase()===`CONFLICTING`||e.prChip===`conflict`)&&n.push(`conflicts`),t.checkState===`failing`&&n.push(`fixCI`),(t.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`&&n.push(`comments`),n}async function zW(e,t,n){try{let r=await e.client.request(`task.prompt`,{taskId:t.id,kind:n});r.outcome===`unavailable`?G(z(`files.stripUnavailable`,{detail:r.detail??``}),`error`):r.outcome===`none`||!r.prompt?G(z(`files.stripNothing`),`error`):await AW(e,t.id,r.prompt)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}var BW={commit:`files.stripCommit`,createPR:`files.stripCreate`,conflicts:`files.stripConflicts`,fixCI:`files.stripFixCi`,comments:`files.stripComments`,archive:`files.stripArchive`};function VW({model:e,task:t}){let n=LW(t);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:n.map(n=>(0,V.jsx)(H,{onClick:()=>n===`archive`?void $P(e,t):void zW(e,t,n),children:z(BW[n])},n))})}var HW=e=>`${e.files} file${e.files===1?``:`s`}, +${e.added} −${e.removed}${e.base?` vs ${e.base}`:``}`;function UW(e){let t=[`**${e.title}**`,`Branch \`${e.branch}\` · ${HW(e)}`];return e.pr?.url&&t.push(`PR: ${e.pr.url}`),e.checks&&t.push(`Checks: ${e.checks}`),e.text&&t.push(``,e.reported?e.text:`Last reply:\n${e.text}`),e.openTodos.length>0&&t.push(``,`Still open:`,...e.openTodos.map(e=>`- ${e}`)),t.join(`
130
+ `)}function WW(e){let t=[`## Summary`,``,e.text??e.title,``,`## Changes`,``,`- ${HW(e)} on \`${e.branch}\``];return e.checks&&t.push(`- Checks: ${e.checks}`),e.openTodos.length>0&&t.push(``,`## Not done`,``,...e.openTodos.map(e=>`- [ ] ${e}`)),t.join(`
131
+ `)}function GW(e){let t=[e.pass?`${e.pass} passed`:``,e.fail?`${e.fail} failed`:``,e.pending?`${e.pending} pending`:``].filter(Boolean);return t.length>0?t.join(` · `):null}async function KW(e){try{await navigator.clipboard.writeText(e),G(z(`files.report.copied`))}catch{G(z(`menu.copyFailed`),`error`)}}function qW(e){B();let{model:t,task:n}=e,[r,i]=(0,g.useState)(!e.narrow),[a,o]=(0,g.useState)(null),s=!!n.report?.summary;(0,g.useEffect)(()=>{if(s)return;let e=!0;return Fs(t,`output.read`,{taskId:n.id,limit:8}).then(t=>e&&o(ZI(t)),()=>{}),()=>{e=!1}},[t,n.id,s,n.rowStatus?.since]);let c=(0,g.useMemo)(()=>{let r=Ns(t,`pr.checks`,{taskId:n.id}),i=r?.outcome===`ok`?vW(r.checks):null;return{title:n.label||n.title,branch:n.branch,base:e.base,files:new Set(e.files.map(e=>e.path)).size,added:e.files.reduce((e,t)=>e+(t.added??0),0),removed:e.files.reduce((e,t)=>e+(t.deleted??0),0),text:n.report?.summary??a,reported:s,checks:i?GW(i):n.pr?.checkState&&n.pr.checkState!==`unknown`?n.pr.checkState:null,openTodos:LP(n).map(e=>e.text),pr:n.pr?{number:n.pr.number,url:n.pr.url}:null}},[t,n,e.base,e.files,a,s]);return(0,V.jsxs)(`section`,{className:`flex flex-col gap-1 px-2 pb-2 font-mono text-meta`,children:[(0,V.jsxs)(H,{variant:`row`,"aria-expanded":r,className:`flex items-center gap-1.5 text-left text-muted hover:text-ink`,onClick:()=>i(!r),children:[(0,V.jsx)(Ma,{right:!r}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[z(`files.report.title`),` · `,c.files,` · +`,c.added,` −`,c.removed]})]}),r&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`m-0 text-muted`,children:[c.branch,c.base?` → ${c.base}`:``,c.checks?` · ${c.checks}`:``,c.openTodos.length>0?` · ${z(`files.report.todos`,{count:c.openTodos.length})}`:``]}),c.text?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`text-subtle`,children:z(s?`files.report.claimed`:`files.report.lastReply`)}),(0,V.jsx)(`p`,{className:`m-0 max-h-24 overflow-y-auto whitespace-pre-wrap wrap-anywhere text-ink`,children:c.text})]}):(0,V.jsx)(`span`,{className:`text-subtle`,children:z(`files.report.none`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,V.jsx)(H,{hit:`tight`,onClick:()=>void KW(UW(c)),children:z(`files.report.copyNote`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>void KW(WW(c)),children:z(`files.report.copyPr`)})]})]})]})}var JW=2e3;function YW({model:e,task:t}){B();let n=t.id,r=!t.machine,[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),c=i?.running===!0;if((0,g.useEffect)(()=>{if(!r)return;let t=!0,i=()=>e.client.request(`run.status`,{taskId:n}).then(e=>t&&a(e),()=>{});i();let o=c?window.setInterval(()=>void i(),JW):0;return()=>{t=!1,window.clearInterval(o)}},[e,n,r,c]),!r||!i?.script)return null;let l=async t=>{s(!0);try{a(await e.client.request(t,{taskId:n}))}catch(e){G(e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}};return(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:[i.url&&(0,V.jsx)(H,{onClick:()=>i.url&&Hk(n,i.url),children:z(`files.run.open`,{port:i.port??``})}),(0,V.jsx)(H,{disabled:o,onClick:()=>void l(c?`run.stop`:`run.start`),children:z(c?`files.run.stop`:`files.run.run`)})]})}var XW={"session-start":{glyph:`○`,tone:`text-muted`},"turn-start":{glyph:`▶`,tone:`text-info`},"turn-complete":{glyph:`✓`,tone:`text-success`},"turn-failed":{glyph:`✗`,tone:`text-error`},"turn-interrupted":{glyph:`■`,tone:`text-warning`},"awaiting-input":{glyph:`?`,tone:`text-warning`},"session-end":{glyph:`○`,tone:`text-muted`},"tool-failed":{glyph:`!`,tone:`text-error`},"pre-compact":{glyph:`≈`,tone:`text-muted`},"post-compact":{glyph:`≈`,tone:`text-muted`},"subagent-start":{glyph:`↳`,tone:`text-muted`},"subagent-stop":{glyph:`↲`,tone:`text-muted`},commit:{glyph:`◆`,tone:`text-accent`},"pr-opened":{glyph:`⇡`,tone:`text-success`},"pr-merged":{glyph:`⇡`,tone:`text-merged`},"pr-closed":{glyph:`⇡`,tone:`text-muted`},"pr-failing":{glyph:`⇡`,tone:`text-error`},"pr-passing":{glyph:`⇡`,tone:`text-success`},"pr-conflict":{glyph:`⇡`,tone:`text-error`},"pr-changes":{glyph:`⇡`,tone:`text-warning`}},ZW={glyph:`·`,tone:`text-muted`};function QW(e){return e.kind===`commit`?{to:`diff`}:e.kind.startsWith(`pr-`)?e.url?{to:`pr`,url:e.url}:null:e.tabId?{to:`tab`,tabId:e.tabId}:null}function $W(e,t){if(!t)return[];if(!e)return[`pr-opened`];let n=[];if(e.lifecycle!==t.lifecycle&&(t.lifecycle===`merged`?n.push(`pr-merged`):t.lifecycle===`closed`&&n.push(`pr-closed`)),e.lifecycle===`unknown`)return n;e.checkState!==t.checkState&&(t.checkState===`failing`?n.push(`pr-failing`):t.checkState===`passing`&&n.push(`pr-passing`));let r=e=>(e.mergeable??``).toUpperCase()===`CONFLICTING`;r(t)&&!r(e)&&n.push(`pr-conflict`);let i=e=>(e.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`;return i(t)&&!i(e)&&n.push(`pr-changes`),n}function eG(e,t){return[...e,...t].sort((e,t)=>t.at-e.at)}var tG=_({}),nG=400,rG=15e3,iG=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function aG(e,t){if(!e||e.id!==t.id)return;let n=$W(e.pr,t.pr);if(n.length===0)return;let r=Date.now(),i=n.map(e=>({kind:e,at:r,tail:t.pr?.number===void 0?``:`#${t.pr.number}`,...t.pr?.url?{url:t.pr.url}:{}})),a=tG.get();tG.set({...a,[t.id]:[...a[t.id]??[],...i].slice(-50)})}function oG(e){let t=(0,g.useRef)(void 0);(0,g.useEffect)(()=>{aG(t.current,e),t.current=e},[e])}function sG({model:e,task:t}){B();let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),o=v(tG)[t.id],s=JSON.stringify([t.rowStatus,t.tabStatus,t.changes,t.pr,t.updatedAt]),c=(0,g.useRef)(0),l=(0,g.useRef)(()=>{});l.current=()=>{c.current=Date.now(),e.client.request(`task.timeline`,{taskId:t.id}).then(e=>{r(e.entries),a(null)},e=>a(e instanceof Error?e.message:String(e)))},(0,g.useEffect)(()=>{let e=window.setTimeout(()=>l.current(),Math.max(0,c.current+nG-Date.now()));return()=>window.clearTimeout(e)},[s]),(0,g.useEffect)(()=>{let e=window.setInterval(()=>l.current(),rG);return()=>window.clearInterval(e)},[]);let u=eG(n??[],o??[]),d=n=>{let r=QW(n);r?.to===`tab`?e.select(t.id,r.tabId):r?.to===`diff`?Vk({taskId:t.id,path:`.`,scope:`branch`}):r?.to===`pr`&&window.open(r.url,`_blank`,`noopener`)};return(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[i&&(0,V.jsx)(`p`,{className:`mono text-error`,children:i}),!i&&n!==null&&u.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(`files.activityEmpty`)}),u.map(e=>{let t=XW[e.kind]??ZW,n=e.kind in XW?z(`files.activityKind.${e.kind}`):e.kind,r=QW(e);return(0,V.jsxs)(H,{variant:`row`,className:Qn({size:`file`}),disabled:!r,title:e.tail?`${n} · ${e.tail}`:n,onClick:()=>d(e),children:[(0,V.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:iG(e.at)}),(0,V.jsx)(`span`,{className:`${nr} ${t.tone}`,children:t.glyph}),(0,V.jsxs)(`span`,{className:$n,children:[n,e.tail&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[` `,e.tail]})]})]},`${e.at}:${e.kind}:${e.tabId??``}:${e.sha??``}:${e.tail}`)})]})}function cG({tabs:e,value:t,onChange:n,className:r}){return(0,V.jsx)(`div`,{className:ke(`flex gap-1`,r),role:`tablist`,children:e.map(e=>{let r=e.id===t;return(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:ke(`relative rounded-sm px-2.5 py-0.75 font-mono text-meta font-semibold`,`touch:after:absolute touch:after:content-[''] touch:after:-inset-x-0.5 touch:after:-top-2 touch:after:-bottom-1.5`,r?`bg-inset text-ink group-focus-within/pane:text-accent`:`text-muted`),onClick:()=>n(e.id),children:e.label},e.id)})})}var lG=[`all`,`changes`,`activity`,`notes`],uG={M:`text-warning`,A:`text-success`,"?":`text-success`,D:`text-error`,R:`text-accent`};function dG({model:e,task:t,narrow:n=!1}){let r=Ko();B();let[i,a]=(0,g.useState)(`all`),[o,s]=(0,g.useState)(`working`),[c,l]=(0,g.useState)(()=>Ns(e,`files.list`,{taskId:t.id})?.files??null),[u,d]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.id})??null),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(new Set),[_,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(0),S=(0,g.useRef)(null);oG(t);let C=v(ln),w=JSON.stringify(t.changes??null);(0,g.useEffect)(()=>{let n=!0,r=e=>n&&p(e instanceof Error?e.message:String(e));return Fs(e,`files.list`,{taskId:t.id}).then(e=>{n&&(l(e.files),p(null))},r),Fs(e,`diff.files`,{taskId:t.id}).then(e=>n&&d(e),r),()=>{n=!1}},[e,t.id,w,b]);let T=u?.base??null,E=i===`all`?c!==null:u!==null,D=o===`branch`&&T!=null,O=i===`activity`||i===`notes`?[]:i===`all`?DW(c??[],m).map(e=>({path:e.path,label:e.name,depth:e.depth,dir:e.dir,open:e.open})):(u?.files??[]).filter(e=>e.scope===(D?`branch`:`working`)).map(e=>({path:e.path,label:e.path,depth:0,dir:!1,open:!1,status:e.status,added:e.added,deleted:e.deleted})),k=Math.min(_,Math.max(0,O.length-1)),A=O[k],j=(e,t)=>h(n=>{let r=new Set(n);return t??!r.has(e)?r.add(e):r.delete(e),r}),ee=e=>Vk({taskId:t.id,path:e,scope:i===`changes`&&D?`branch`:`working`}),M=n=>{if(!C?.startsWith(`${t.id}::`)){G(z(`files.mentionNoEngine`),`error`);return}e.client.request(`term.input`,{stream:C,data:`@${n} `}).catch(e=>G(String(e),`error`))},N=n=>t.machine?G(z(`files.remoteNoExternal`,{host:t.machine.label}),`error`):void e.client.request(`file.openExternal`,{taskId:t.id,path:n}).then(()=>G(z(`taskops.openedExternal`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsxs)(`div`,{className:`group/pane flex min-h-0 min-w-0 flex-1 flex-col outline-none ${n?`px-1.5 pt-2.5 pb-2`:`pt-0.5 pr-1.5 pb-1.5 pl-0`}`,tabIndex:0,ref:S,onKeyDown:e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)y(Math.min(O.length-1,k+1));else if(t===`k`||t===`ArrowUp`)y(Math.max(0,k-1));else if((t===`l`||t===`ArrowRight`)&&A?.dir)j(A.path,!0);else if((t===`h`||t===`ArrowLeft`)&&A?.dir)j(A.path,!1);else if(t===`[`||t===`]`)a(lG[(lG.indexOf(i)+(t===`]`?1:lG.length-1))%lG.length]??`all`);else if(t===`b`&&i===`changes`&&T!=null)s(o===`working`?`branch`:`working`);else if(t===`r`)x(e=>e+1);else if(t===`D`&&e.shiftKey)ee(`.`);else if(t===`d`&&A)ee(A.path);else if(t===`Enter`&&A)A.dir?j(A.path):ee(A.path);else if(t===`a`&&A)M(A.path);else if(t===`o`&&A&&!A.dir)N(A.path);else return;e.preventDefault()},children:[(0,V.jsx)(VW,{model:e,task:t}),(0,V.jsx)(EW,{model:e,task:t}),(0,V.jsx)(YW,{model:e,task:t}),(0,V.jsx)(qW,{model:e,task:t,base:T,files:u?.files??[],narrow:n}),(0,V.jsx)(cG,{className:`px-1 pb-1.5`,tabs:[{id:`all`,label:z(`files.all`)},{id:`changes`,label:z(`files.changes`)},{id:`activity`,label:z(`files.activity`)},{id:`notes`,label:z(`files.notes`)}],value:i,onChange:e=>{a(e),y(0)}}),i===`changes`&&(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-2.5 gap-y-1 px-2 pb-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:D?z(`files.scopeBranch`,{base:T??``}):z(`files.scopeWorking`)}),T==null?u&&(0,V.jsx)(`span`,{children:z(`files.noBase`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(o===`working`?`branch`:`working`),children:z(r?`files.toggleScopeTouch`:`files.toggleScope`)}),(0,V.jsx)(ST,{text:z(`files.legend`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>ee(`.`),children:z(r?`files.diffAllTouch`:`files.diffAll`)})]}),i===`activity`?(0,V.jsx)(sG,{model:e,task:t}):i===`notes`?(0,V.jsx)(FW,{model:e,task:t}):(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f&&(0,V.jsx)(`p`,{className:`mono text-error`,children:f}),!f&&E&&O.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(i===`all`?`files.emptyAll`:`files.emptyChanges`)}),O.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:Qn({selected:t===k,size:n?`file-narrow`:`file`}),style:{paddingLeft:8+e.depth*14},title:e.path,onClick:()=>{y(t),S.current?.focus(),e.dir?j(e.path):ee(e.path)},children:[e.status?(0,V.jsx)(`span`,{className:`${nr} ${uG[e.status]??``}`,children:e.status}):(0,V.jsx)(`span`,{className:`${nr} grid place-items-center text-subtle`,children:e.dir?(0,V.jsx)(Ma,{right:!e.open}):null}),(0,V.jsx)(`span`,{className:$n,children:e.label}),e.added?(0,V.jsxs)(xL,{tone:`added`,children:[`+`,e.added]}):null,e.deleted?(0,V.jsxs)(xL,{tone:`removed`,children:[`−`,e.deleted]}):null]},e.path))]})]})}function fG({children:e}){return(0,V.jsx)(`svg`,{className:`size-3.5 ${oI}`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:e})}var pG={chat:(0,V.jsx)(`path`,{d:`M3 3.5h10a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8l-3 2.5v-2.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1zM5 6.5h6M5 8.5h4`}),files:(0,V.jsx)(`path`,{d:`M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z`}),diff:(0,V.jsx)(`path`,{d:`M3.5 2.5h9a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM8 5v4M6 7h4M6 11h4`}),browser:(0,V.jsx)(`path`,{d:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM2 8h12M8 2c2.2 2 2.2 10 0 12M8 2c-2.2 2-2.2 10 0 12`})};function mG(e){if(e.kind===`files`)return z(`panel.files`);if(e.kind===`chat`)return z(`panel.chat`);if(e.kind===`diff`)return e.path===`.`?z(`panel.diff`):JO(e.path);let t=qO(e);return t?YO(t):z(`panel.browser`)}function hG(e){return e.kind===`diff`?e.path===`.`?z(`preview.whole`):e.path:e.kind===`browser`&&qO(e)||mG(e)}var gG=7.3,_G=51,vG=160;function yG(e,t){let n=0;for(let t of e){let e=0;for(let n of t)e+=(n.codePointAt(0)??0)>11903?2:1;n+=Math.min(vG,_G+e*gG)+2}return n<=t}var bG=null;function xG(e,t,n,r){let i=(t,r)=>({label:r,section:`move`,run:()=>Rk(e,e=>gk(e,n.id,t))}),a=[];return!t.bottom&&t.top.tabs.length>1?a.push(i(`bottom`,z(`panel.splitDown`))):t.bottom&&a.push(r===`top`?i(`bottom`,z(`panel.moveBottom`)):i(`top`,z(`panel.moveTop`))),a.push({label:z(`panel.close`),section:`close`,run:()=>Uk(e,n.id)}),t.top.tabs.length+(t.bottom?.tabs.length??0)>1&&a.push({label:z(`panel.closeOthers`),section:`close`,run:()=>Rk(e,e=>hk(e,n.id))}),a}function SG(e,t){return[{label:z(`panel.newChat`),run:()=>Rk(e,e=>ck(e,`chat`))},{label:z(`panel.newFiles`),run:()=>Rk(e,e=>ik(e,t))},{label:z(`panel.newDiff`),run:()=>Rk(e,e=>ok(e,`.`,`working`))},{label:z(`panel.newBrowser`),run:()=>Rk(e,e=>ak(e,t))}]}function CG({taskId:e,panel:t,group:n,tabs:r,active:i,narrow:a,children:o}){B();let[s,c]=(0,g.useState)(null),l=()=>bG?.taskId===e,u=t=>{let r=bG;bG=null,c(null),r?.taskId===e&&Rk(e,e=>gk(e,r.id,n,t))},d=t=>{let r=t.currentTarget.getBoundingClientRect();nn.set({x:r.left,y:r.bottom+2,items:SG(e,n),target:t.currentTarget})},f=(e,t)=>{if(!l())return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();c({id:t,after:e.clientX>n.left+n.width/2})},p=(0,g.useRef)(null),[m,h]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(([e])=>h(e?.contentRect.width??0));return t.observe(e),()=>t.disconnect()},[]);let _=m>0&&!yG(r.map(mG),m);return(0,g.useEffect)(()=>{p.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,r.length,_]),(0,V.jsxs)(`div`,{className:fI(a),style:{gridRow:n===`top`?1:4},onDragOver:e=>{l()&&(e.preventDefault(),c(null))},onDrop:e=>{e.preventDefault(),u()},children:[(0,V.jsx)(`div`,{className:pI,role:`tablist`,"aria-label":z(`panel.tabs`),ref:p,children:r.map((r,o)=>(0,V.jsxs)(`div`,{role:`presentation`,className:mI({active:r.id===i,compact:_}),"data-drop":s?.id===r.id?s.after?`after`:`before`:void 0,draggable:!a,onDragStart:()=>{bG={taskId:e,id:r.id}},onDragEnd:()=>{bG=null,c(null)},onDragOver:e=>f(e,r.id),onDrop:e=>{e.preventDefault(),e.stopPropagation(),u(o+(s?.id===r.id&&s.after?1:0))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),Uk(e,r.id))},onContextMenu:i=>{a||XU(i,xG(e,t,r,n))},children:[(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r.id===i,className:hI(_&&r.id!==i),title:hG(r),onClick:()=>Rk(e,e=>ek(e,r.id)),children:[(0,V.jsx)(fG,{children:pG[r.kind]}),(0,V.jsx)(`span`,{className:`${gI} ${_&&r.id!==i?`hidden`:``}`,children:mG(r)})]}),(0,V.jsx)(`button`,{type:`button`,className:`${_I} ${_&&r.id!==i?`hidden`:``}`,"aria-label":z(`panel.close`),tabIndex:-1,onClick:()=>Uk(e,r.id),children:`×`})]},r.id))}),!a&&(0,V.jsx)(`button`,{type:`button`,className:sI({tool:!0}),title:z(`panel.new`),"aria-label":z(`panel.new`),onClick:d,children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M8 3.5v9M3.5 8h9`})})}),o]})}var wG={md:`md`,markdown:`md`,html:`html`,htm:`html`,svg:`svg`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,pdf:`pdf`};function TG(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<0?null:wG[t.slice(n+1).toLowerCase()]??null}function EG(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var DG=e=>new TextDecoder().decode(EG(e));function OG(e,t){if(e===`svg`)return`image/svg+xml`;if(e===`pdf`)return`application/pdf`;let n=t.slice(t.lastIndexOf(`.`)+1).toLowerCase();return n===`jpg`||n===`jpeg`?`image/jpeg`:n===`gif`?`image/gif`:n===`webp`?`image/webp`:`image/png`}var kG=`default-src 'none'; img-src data:; style-src 'unsafe-inline'`;function AG(e){let t=`<meta http-equiv="Content-Security-Policy" content="${kG}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}var jG=/^\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/,MG=/^https?:\/\/[^\s<>)\]]+/,NG=/[\p{L}\p{N}]/u;function PG(e){let t=[],n=``,r=()=>{n&&t.push({t:`text`,v:n}),n=``},i=0;for(;i<e.length;){let a=e.slice(i),o=e[i]??``;if(o==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({t:`code`,v:e.slice(i+1,n)}),i=n+1;continue}}else if(a.startsWith(`**`)){let n=e.indexOf(`**`,i+2);if(n>i+2){r(),t.push({t:`bold`,c:PG(e.slice(i+2,n))}),i=n+2;continue}}else if(o===`*`||o===`_`&&!NG.test(e[i-1]??``)){let n=e.indexOf(o,i+1);if(n>i+1&&!/\s/.test(e[i+1]??` `)&&(o===`*`||!NG.test(e[n+1]??``))){r(),t.push({t:`em`,c:PG(e.slice(i+1,n))}),i=n+1;continue}}else if(o===`[`){let e=jG.exec(a);if(e){r(),t.push({t:`link`,href:e[2],c:PG(e[1])}),i+=e[0].length;continue}}else if(o===`h`&&!NG.test(e[i-1]??``)){let e=MG.exec(a);if(e){let n=e[0].replace(/[.,;:!?]+$/,``);r(),t.push({t:`link`,href:n,c:[{t:`text`,v:n}]}),i+=n.length;continue}}n+=o,i++}return r(),t}var FG=/^\s*(```+|~~~+)\s*([\w+#.-]*)\s*$/,IG=/^(#{1,6})\s+(.*?)\s*#*\s*$/,LG=/^(\s*)([-*+])\s+(.*)$/,RG=/^(\s*)\d+[.)]\s+(.*)$/,zG=/^\s*([-*_])(\s*\1){2,}\s*$/,BG=/^\s*\|.*\|\s*$/,VG=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/,HG=e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());function UG(e){let t=e.replace(/\r\n?/g,`
132
132
  `).split(`
133
- `),n=[],r=[],i=()=>{r.length>0&&n.push({t:`para`,c:MG(r.join(`
134
- `))}),r=[]};for(let e=0;e<t.length;e++){let a=t[e],o=NG.exec(a);if(o){i();let r=o[1][0],a=[];for(e++;e<t.length&&!RegExp(`^\\s*${r}{3,}\\s*$`).test(t[e]);e++)a.push(t[e]);n.push({t:`code`,lang:o[2]??``,v:a.join(`
135
- `)});continue}if(a.trim()===``){i();continue}let s=PG.exec(a);if(s){i(),n.push({t:`heading`,level:s[1].length,c:MG(s[2])});continue}if(LG.test(a)){i(),n.push({t:`hr`});continue}if(RG.test(a)){i();let r=[];for(;e<t.length&&RG.test(t[e]);e++){let n=t[e];zG.test(n)||r.push(BG(n))}e--,n.push({t:`table`,rows:r.map(e=>e.map(e=>MG(e)))});continue}if(a.startsWith(`>`)){i();let r=[];for(;e<t.length&&t[e].startsWith(`>`);e++)r.push(t[e].replace(/^>\s?/,``));e--,n.push({t:`quote`,c:MG(r.join(`
136
- `))});continue}let c=FG.exec(a),l=c?null:IG.exec(a);if(c||l){i();let r=!c,a=[];for(;e<t.length;e++){let n=r?IG.exec(t[e]):FG.exec(t[e]);if(!n)break;let i=n[1].length;a.push({depth:Math.min(3,Math.floor(i/2)),c:MG(r?n[2]:n[3])})}e--,n.push({t:`list`,ordered:r,items:a});continue}r.push(a)}return i(),n}var HG=`flex min-h-0 min-w-0 flex-1 flex-col font-sans text-body`,UG=`flex flex-none flex-wrap items-center gap-x-3 gap-y-1 px-3 pb-1.5 font-mono text-meta`,WG=`min-w-0 flex-1 basis-32 py-1 text-meta`,GG=`min-h-0 flex-1 overflow-y-auto px-3 pb-3`,KG=`m-0 px-3 py-2 font-mono text-meta text-subtle`,qG=`m-0 whitespace-pre-wrap px-3 pb-3 font-mono text-meta leading-[1.45] text-muted wrap-anywhere`,JG=e=>`group/entry mt-3 rounded-sm border-l-2 py-0.5 pl-2.5 ${e.flash?`border-accent bg-accent-soft`:e.current?`border-line-active`:`border-transparent`}`,YG=`mb-0.5 flex items-center gap-2 font-mono text-meta`,XG=e=>e===`user`?`text-accent`:`text-muted`,ZG=`text-subtle`,QG=`ml-auto opacity-0 group-hover/entry:opacity-100 focus-visible:opacity-100 touch:opacity-100`,$G=`m-0 mt-0.5 flex min-w-0 items-baseline gap-1.5 font-mono text-meta text-subtle`,eK=`flex-none text-muted`,tK=`min-w-0 flex-1 truncate`,nK=`leading-[1.5] wrap-anywhere`,rK=`m-0 mb-2 whitespace-pre-wrap last:mb-0`,iK=`m-0 mt-3 mb-1.5 font-semibold first:mt-0`,aK=`m-0 mb-2 flex flex-col gap-0.5 pl-5 last:mb-0`,oK=`m-0 mb-2 border-l-2 border-line pl-2.5 whitespace-pre-wrap text-muted last:mb-0`,sK=`m-0 mb-2 overflow-x-auto rounded-sm border-hairline border-line bg-inset px-2.5 py-2 font-mono text-meta leading-[1.45] last:mb-0`,cK=`rounded-xs bg-inset px-1 font-mono text-meta`,lK=`text-accent underline`,uK=`mb-2 block max-w-full overflow-x-auto border-collapse font-mono text-meta last:mb-0`,dK=`border-hairline border-line px-2 py-0.5 text-left align-top`,fK=`my-2 border-0 border-t border-line`;function pK(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase(),i=[],a=0;for(let t=r.indexOf(n);t>=0;t=r.indexOf(n,a))t>a&&i.push(e.slice(a,t)),i.push((0,V.jsx)(`mark`,{className:jO,"data-hit":``,children:e.slice(t,t+n.length)},t)),a=t+n.length;return i.push(e.slice(a)),g.Children.toArray(i)}var mK=[`h3`,`h3`,`h4`,`h5`,`h6`,`h6`];function hK({level:e,children:t}){let n=mK[Math.min(5,Math.max(0,e-1))]??`h6`;return(0,V.jsx)(n,{className:iK,children:t})}function gK(e,t){return e.map((e,n)=>(0,V.jsx)(g.Fragment,{children:t(e)},n))}function _K({nodes:e,needle:t}){return gK(e,e=>e.t===`text`?pK(e.v,t):e.t===`code`?(0,V.jsx)(`code`,{className:cK,children:pK(e.v,t)}):e.t===`bold`?(0,V.jsx)(`strong`,{children:(0,V.jsx)(_K,{nodes:e.c,needle:t})}):e.t===`em`?(0,V.jsx)(`em`,{children:(0,V.jsx)(_K,{nodes:e.c,needle:t})}):(0,V.jsx)(`a`,{className:lK,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:(0,V.jsx)(_K,{nodes:e.c,needle:t})}))}function vK({block:e,needle:t}){switch(e.t){case`heading`:return(0,V.jsx)(hK,{level:e.level,children:(0,V.jsx)(_K,{nodes:e.c,needle:t})});case`para`:return(0,V.jsx)(`p`,{className:rK,children:(0,V.jsx)(_K,{nodes:e.c,needle:t})});case`code`:return(0,V.jsx)(`pre`,{className:sK,children:(0,V.jsx)(`code`,{children:pK(e.v,t)})});case`quote`:return(0,V.jsx)(`blockquote`,{className:oK,children:(0,V.jsx)(_K,{nodes:e.c,needle:t})});case`hr`:return(0,V.jsx)(`hr`,{className:fK});case`list`:{let n=e.ordered?`ol`:`ul`;return(0,V.jsx)(n,{className:`${aK} ${e.ordered?`list-decimal`:`list-disc`}`,children:gK(e.items,e=>(0,V.jsx)(`li`,{style:{marginLeft:`${e.depth*1.25}rem`},children:(0,V.jsx)(_K,{nodes:e.c,needle:t})}))})}case`table`:return(0,V.jsx)(`table`,{className:uK,children:(0,V.jsx)(`tbody`,{children:gK(e.rows,e=>(0,V.jsx)(`tr`,{children:gK(e,e=>(0,V.jsx)(`td`,{className:dK,children:(0,V.jsx)(_K,{nodes:e,needle:t})}))}))})})}}function yK({source:e,needle:t=``}){let n=(0,g.useMemo)(()=>VG(e),[e]);return(0,V.jsx)(`div`,{className:nK,children:gK(n,e=>(0,V.jsx)(vK,{block:e,needle:t}))})}function bK(e){if(e instanceof r_){if(e.code===`TOO_LARGE`){let t=e.detail?.size;return sL(z(`artifact.tooLarge`),{size:typeof t==`number`?`${(t/1048576).toFixed(1)} MB`:`5 MB+`})}if(e.code===`NOT_PREVIEWABLE`)return z(`artifact.notPreviewable`);if(e.code===`NOT_FOUND`)return z(`artifact.gone`)}return sL(z(`artifact.failed`),{error:e instanceof Error?e.message:String(e)})}function xK(e,t,n,r){let[i,a]=(0,g.useState)({kind:`loading`});return(0,g.useEffect)(()=>{let r=!0;return e.client.request(`file.read`,{taskId:t,path:n}).then(e=>r&&a({kind:`ready`,file:e}),e=>r&&a({kind:`failed`,text:bK(e)})),()=>{r=!1}},[e,t,n,r]),i}function SK(e,t){let n=(0,g.useMemo)(()=>e===null?null:URL.createObjectURL(new Blob([wG(e)],{type:t})),[e,t]);return(0,g.useEffect)(()=>()=>void(n&&URL.revokeObjectURL(n)),[n]),n}function CK({model:e,taskId:t,path:n,kind:r,changeKey:i}){B();let a=xK(e,t,n,i),o=SK(a.kind===`ready`&&(r===`svg`||r===`image`||r===`pdf`)?a.file.base64:null,r===`md`||r===`html`?``:EG(r,n));return a.kind===`loading`?(0,V.jsx)(`p`,{className:Wt,children:z(`artifact.loading`)}):a.kind===`failed`?(0,V.jsx)(`p`,{className:`${Wt} text-error`,children:a.text}):r===`md`?(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:(0,V.jsx)(yK,{source:TG(a.file.base64)})}):r===`html`?(0,V.jsx)(`iframe`,{title:n,sandbox:``,srcDoc:OG(TG(a.file.base64)),style:{colorScheme:`light`,background:`#fff`},className:`min-h-0 w-full flex-1 border-none`}):o?r===`pdf`?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`a`,{className:`${Xt} px-3 py-1 font-mono text-meta`,href:o,target:`_blank`,rel:`noreferrer noopener`,children:z(`artifact.open`)}),(0,V.jsx)(`iframe`,{title:n,src:o,className:`min-h-0 w-full flex-1 border-none`})]}):(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,V.jsx)(`img`,{src:o,alt:n,className:`max-w-full`})}):null}function wK(e,t,n){let r=[{ref:null,suggestion:{key:`default`,text:t,dim:z(`review.baseDefault`),accent:!0}}],i=(e,n)=>{for(let i of e)i!==t&&r.push({ref:i,suggestion:{key:`${n}:${i}`,text:i,dim:n}})};i(e?.branches??[],z(`review.baseBranch`)),i(e?.remotes??[],z(`review.baseRemote`)),i(e?.tags??[],z(`review.baseTag`));for(let t of e?.commits??[])r.push({ref:t.sha,suggestion:{key:`commit:${t.sha}`,text:t.sha,dim:t.subject}});let a=n.trim().toLowerCase();if(a===``)return r.slice(0,40);let o=r.filter(e=>`${e.suggestion.text} ${e.suggestion.dim??``}`.toLowerCase().includes(a)),s=e=>e.suggestion.text.toLowerCase()===a?0:1;return o.sort((e,t)=>s(e)-s(t)).slice(0,40)}function TK(e){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null),s=e.model.client;(0,g.useEffect)(()=>{if(!t)return;let n=!0;return Fs(s,`diff.refs`,{taskId:e.taskId}).then(e=>n&&o(e),()=>{}),()=>{n=!1}},[t,s,e.taskId]);let c=wK(a,e.base,r),l=t=>{e.onPick(t),n(!1),i(``)};return(0,V.jsxs)(`span`,{className:`relative`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&t&&n(!1)},children:[(0,V.jsx)(H,{hit:`tight`,"aria-expanded":t,title:z(`review.baseHint`),className:e.custom?``:`opacity-60 aria-expanded:opacity-100`,onClick:()=>n(!t),children:z(`review.basePicker`,{base:e.custom??e.base})}),t&&(0,V.jsx)(`div`,{className:`absolute top-full left-0 z-3 mt-1 w-64 max-w-full rounded-sm border-hairline border-line-active bg-surface p-1 shadow-popover`,children:(0,V.jsx)(xD,{field:`diff-base`,autoFocus:!0,value:r,onChange:i,items:c.map(e=>e.suggestion),open:!0,placeholder:z(`review.basePlaceholder`),onPick:e=>l(c[e]?.ref??null),onEnter:()=>l(r.trim()===``?null:r.trim())})})]})}var EK=`rove.diffBase`;function DK(){try{let e=JSON.parse(localStorage.getItem(EK)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function OK(e){return DK()[e]??null}function kK(e,t){let n=DK();t===null?delete n[e]:n[e]=t;try{localStorage.setItem(EK,JSON.stringify(n))}catch{}}function AK(e){let[t,n]=(0,g.useState)(()=>OK(e.taskId));return[t,t=>{kK(e.taskId,t),n(t),t!==null&&e.scope!==`task`&&Vk({taskId:e.taskId,path:e.path,scope:`task`})}]}var jK={add:`bg-diff-added-bg`,del:`bg-diff-removed-bg`},MK={add:`text-diff-added`,del:`text-diff-removed`};function NK(e,t){let n=t.cursor?`bg-inset group-focus/preview:bg-accent-soft`:t.noted?`bg-inset`:jK[e]??``;return`relative grid ${e===`file`||e===`note`?`cursor-pointer`:`cursor-default`} grid-cols-[4ch_4ch_2ch_1fr] gap-x-2 gap-y-0 whitespace-pre px-3 narrow:grid-cols-[3ch_3ch_1ch_1fr] narrow:gap-x-1 narrow:px-1.5 ${n} ${e===`file`?`mt-2 border-t-hairline border-line pt-1 font-bold text-ink`:e===`hunk`||e===`meta`?`text-subtle`:``}`}var PK=`text-right text-subtle`,FK=(e,t)=>t?`text-accent`:MK[e]??``,IK=e=>`min-w-0 narrow:whitespace-pre-wrap narrow:wrap-anywhere ${MK[e]??``}`,LK=`min-w-0 whitespace-pre-wrap wrap-anywhere text-accent`,RK=`flex min-w-0 items-baseline gap-2`;function zK(e){return(0,V.jsxs)(`div`,{className:`flex items-center ${e.viewed?`opacity-60`:``}`,children:[(0,V.jsxs)(H,{variant:`row`,"data-row":e.index,"aria-expanded":!e.closed,"aria-label":z(e.closed?`review.unfold`:`review.fold`,{path:e.name}),className:`${NK(`file`,{cursor:e.cursor,noted:!1})} min-w-0 flex-1 text-left`,onClick:e.onToggleFold,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{className:`grid place-items-center text-subtle`,children:(0,V.jsx)(Ma,{right:e.closed})}),(0,V.jsxs)(`span`,{className:RK,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),e.added?(0,V.jsxs)(yL,{tone:`added`,children:[`+`,e.added]}):null,e.removed?(0,V.jsxs)(yL,{tone:`removed`,children:[`−`,e.removed]}):null]})]}),e.path&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none px-2`,"aria-pressed":e.viewed,"aria-label":z(e.viewed?`review.unmarkViewed`:`review.markViewed`,{path:e.name}),onClick:e.onToggleViewed,children:e.viewed?z(`review.viewedOn`):z(`review.viewed`)})]})}function BK(e){return(0,V.jsxs)(`div`,{className:`absolute top-full right-3 z-1 flex gap-1.5`,children:[(0,V.jsx)(H,{variant:`floating`,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),e.onComment()},children:z(`review.comment`)}),e.showRange&&(0,V.jsx)(H,{variant:`floating`,onClick:t=>{t.stopPropagation(),e.onRange()},children:z(`review.range`)}),e.ranged&&(0,V.jsx)(H,{variant:`floating`,title:z(`preview.askInChatHint`),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),e.onAsk()},children:z(`preview.askInChat`)})]})}function VK({note:e,onEdit:t}){return(0,V.jsxs)(H,{variant:`row`,className:`${NK(`note`,{cursor:!1,noted:!1})} w-full text-left`,onClick:t,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{className:`text-accent`,children:`●`}),(0,V.jsx)(`span`,{className:LK,children:e.body})]})}function HK(e){return(0,V.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-1 px-2 pt-1.5 font-mono text-meta`,children:[e.scopes&&(0,V.jsx)(oG,{className:`flex-wrap`,tabs:e.scopes,value:e.scope,onChange:e.onScope}),e.picker,(0,V.jsx)(H,{hit:`tight`,"aria-pressed":e.ignoreWs,title:z(`review.ignoreWsHint`),className:`opacity-60 aria-pressed:underline aria-pressed:opacity-100`,onClick:e.onToggleWs,children:z(`review.ignoreWs`)}),(0,V.jsxs)(`span`,{className:`flex min-w-0 basis-full flex-wrap items-center gap-x-1.5 text-muted`,children:[z(`review.totals`,{files:e.files,added:e.added,removed:e.removed}),e.shape&&(0,V.jsxs)(`span`,{children:[`· `,e.shape]}),e.files>0&&(0,V.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`· `,z(`review.viewedCount`,{done:e.viewed,files:e.files})]})]}),(0,V.jsxs)(`span`,{className:`ml-auto flex items-center gap-x-3`,children:[e.files>1&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onNextFile,children:z(`review.nextFile`)}),e.onNextComment&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onNextComment,children:z(`review.nextComment`)}),e.files>1&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onFoldAll,children:e.allFolded?z(`review.unfoldAll`):z(`review.foldAll`)})]})]})}var UK=`rove.diffViewed`,WK=(e,t)=>`${e}\0${t}`;function GK(e){let t=2166136261;for(let n of e){let e=`${n.kind}${n.text}\n`;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619)}return(t>>>0).toString(16)}function KK(e){let t=new Map,n=-1,r=r=>{let i=n>=0?e[n]?.path:null;i&&t.set(i,GK(e.slice(n+1,r)))};return e.forEach((e,t)=>{e.kind===`file`&&(r(t),n=t)}),r(e.length),t}function qK(){try{let e=JSON.parse(localStorage.getItem(UK)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function JK(e){try{localStorage.setItem(UK,JSON.stringify(e))}catch{}}function YK(e,t,n){let r=new Set;for(let[i,a]of n)e[WK(t,i)]===a&&r.add(i);return r}function XK(e,t,n,r){let i={...e};return r===void 0?delete i[WK(t,n)]:i[WK(t,n)]=r,i}function ZK(e,t){return e.find(e=>e>t)??e[0]??null}var QK=`rove.diffIgnoreWs`;function $K(){try{return localStorage.getItem(QK)===`1`}catch{return!1}}function eq(e){try{localStorage.setItem(QK,e?`1`:`0`)}catch{}}var tq=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function nq(e,t=null,n=!1){let r=[],i=0,a=0,o=t,s=!1;for(let t of e.replace(/\n$/,``).split(`
137
- `)){if(t.startsWith(`diff --git `)){let e=/ b\/(.+)$/.exec(t);o=e?e[1]:o,s=!1,r.push({kind:`file`,text:o??t,oldNo:null,newNo:null,path:o});continue}let e=tq.exec(t);if(e){i=Number(e[1]),a=Number(e[2]),s=!0,r.push({kind:`hunk`,text:t,oldNo:null,newNo:null,path:o});continue}if(!s){r.push({kind:`meta`,text:t,oldNo:null,newNo:null,path:o});continue}t.startsWith(`+`)?r.push({kind:`add`,text:t.slice(1),oldNo:null,newNo:a++,path:o}):t.startsWith(`-`)?r.push({kind:`del`,text:t.slice(1),oldNo:i++,newNo:null,path:o,...n?{foreignOld:!0}:{}}):t.startsWith(`\\`)?r.push({kind:`meta`,text:t,oldNo:null,newNo:null,path:o}):r.push({kind:`ctx`,text:t.slice(1),oldNo:i++,newNo:a++,path:o})}return r}function rq(e,t){return e.replace(/\n$/,``).split(`
138
- `).map((e,n)=>({kind:`ctx`,text:e,oldNo:null,newNo:n+1,path:t}))}function iq(e){return e.kind===`del`?e.foreignOld?null:e.oldNo:e.kind===`add`||e.kind===`ctx`?e.newNo:null}function aq(e){let t=e.startLine?`lines ${e.startLine}-${e.line}`:`line ${e.line}`;return`@${e.path} (${t}) `}function oq(e,t,n){let r=e[t],i=r?iq(r):null;if(!r?.path||i===null)return null;if(n===null||n===t)return{path:r.path,line:i};let a=e[Math.min(n,t)],o=e[Math.max(n,t)],s=a?iq(a):null,c=o?iq(o):null;return s===null||c===null||a?.path!==o?.path?{path:r.path,line:i}:s===c?{path:r.path,line:c}:{path:r.path,startLine:Math.min(s,c),line:Math.max(s,c)}}function sq(e,t,n){let r=oq(e,t,n);if(!r)return null;let i=r.startLine!==void 0&&n!==null;return{...r,first:i?Math.min(n,t):t,last:i?Math.max(n,t):t}}function cq(e,t){let n=[],r=!1;return e.forEach((e,i)=>{e.kind===`file`&&(r=e.path!==null&&t.has(e.path)),(!r||e.kind===`file`)&&n.push(i)}),n}function lq(e){let t=new Map,n=-1;return e.forEach((e,r)=>{if(e.kind===`file`){n=r,t.set(r,{added:0,removed:0});return}let i=t.get(n);i&&(e.kind===`add`?i.added++:e.kind===`del`&&i.removed++)}),t}var uq=[`source`,`tests`,`config`,`docs`,`generated`],dq=/(^|\/)(bun\.lockb?|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|poetry\.lock|uv\.lock|Gemfile\.lock|go\.sum|composer\.lock)$/,fq=/(^|\/)(dist|build|generated|__generated__|\.next)\/|\.min\.(js|css)$|\.snap$|\.generated\.|\.pb\.go$|\.map$/,pq=/(^|\/)(tests?|__tests__|spec|e2e)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]+\.py$/,mq=/\.(md|mdx|rst|txt)$|(^|\/)docs\//i,hq=/(^|\/)(\.[\w.-]+rc(\.\w+)?|[\w.-]*\.config\.[cm]?[jt]s|tsconfig[\w.-]*\.json|package\.json|biome\.json|Dockerfile|Makefile)$|\.(ya?ml|toml|ini|env)$|(^|\/)\.(github|changeset|vscode)\//,gq=e=>dq.test(e);function _q(e){return dq.test(e)||fq.test(e)?`generated`:pq.test(e)?`tests`:mq.test(e)?`docs`:hq.test(e)?`config`:`source`}var vq=e=>_q(e)===`generated`;function yq(e){let t=e.filter(e=>_q(e.path)!==`generated`),n=t.reduce((e,t)=>e+t.lines,0);return t.length===0?1:((e,t)=>e<=2&&t<=30?1:e<=5&&t<=150?2:e<=10&&t<=400?3:e<=20&&t<=1e3?4:5)(t.length,n)}function bq(e){let t=[],n=(e,n)=>n>0&&t.push({group:e,count:n});for(let t of uq)t===`generated`?(n(`lockfile`,e.filter(gq).length),n(`generated`,e.filter(e=>_q(e)===`generated`&&!gq(e)).length)):n(t,e.filter(e=>_q(e)===t).length);return t}function xq(e){let t=[];for(let n of e)(n.kind===`file`||t.length===0)&&t.push([]),t[t.length-1]?.push(n);let n=e=>uq.indexOf(_q(e[0]?.path??``));return t.map((e,t)=>({file:e,i:t})).sort((e,t)=>n(e.file)-n(t.file)||e.i-t.i).flatMap(({file:e})=>e)}function Sq(e){return bq(e.map(e=>e.path)).map(({group:e,count:t})=>({key:e===`lockfile`?t===1?`lockfile`:`lockfiles`:e,count:t}))}function Cq(e,t){let n=[...e.entries()].flatMap(([e,n])=>{let r=t[e]?.path;return r?[{path:r,lines:n.added+n.removed}]:[]});return n.length<2?``:[z(`review.shape.effort`,{n:yq(n)}),...Sq(n).map(e=>z(`review.shape.${e.key}`,{count:e.count}))].join(` · `)}function wq(e,t,n){if(!e||typeof e!=`object`||!(`kind`in e))return{kind:`text`,text:z(`preview.unknown`)};let r=`text`in e&&typeof e.text==`string`?e.text:``;switch(e.kind){case`diff`:{let e=nq(r,t===`.`?null:t,n);return{kind:`rows`,rows:t===`.`?xq(e):e,diff:!0}}case`code`:return{kind:`rows`,rows:rq(r,t),diff:!1};case`binary`:return{kind:`text`,text:z(`preview.binary`)};case`empty`:return{kind:`text`,text:z(`preview.empty`)};case`error`:return{kind:`text`,text:`message`in e?String(e.message):z(`preview.unknown`),error:!0};default:return{kind:`text`,text:z(`preview.noHunks`,{kind:String(e.kind)})}}}function Tq(e){return e instanceof r_&&e.code===`UNKNOWN_OP`?Error(z(`review.notSupported`)):e instanceof Error?e:Error(String(e))}var Eq={add:`+`,del:`-`},Dq=40,Oq=160,kq=e=>`${Eq[e.kind]??` `}${e.text.slice(0,Oq)}`,Aq=e=>e.startLine!==void 0&&e.startLine!==e.line?`${e.filePath}:${e.startLine}-${e.line}`:`${e.filePath}:${e.line}`;function jq(e,t,n){let r=[];for(let i=t;i<=n&&r.length<Dq;i++){let t=e[i];t&&iq(t)!==null&&r.push(kq(t))}return r.join(`
139
- `)}function Mq(e,t){let n=e.startLine??e.line,r=t.flatMap((t,n)=>t.path===e.filePath&&iq(t)!==null?[n]:[]);if(!e.code){let i=r.filter(r=>{let i=iq(t[r]);return i>=n&&i<=e.line}),a=i[0],o=i[i.length-1];return a===void 0||o===void 0?null:{first:a,last:o}}let i=e.code.split(`
140
- `);for(let e=0;e+i.length<=r.length;e++){let a=r.slice(e,e+i.length),o=a[0],s=a[a.length-1];if(o!==void 0&&s!==void 0&&iq(t[o])===n&&a.every((e,n)=>kq(t[e])===i[n]))return{first:o,last:s}}return null}function Nq(e,t,n){return Mq(e,t)?`ok`:t.some(t=>t.path===e.filePath)||n?`moved`:`unknown`}function Pq({notes:e,states:t,sending:n,onShow:r,onEdit:i,onDrop:a,onSend:o}){B();let[s,c]=(0,g.useState)(!1);if(e.length===0)return null;let l=e.length;return(0,V.jsxs)(`div`,{className:`flex max-h-2/5 min-h-0 flex-none flex-col border-t-hairline border-line font-mono text-meta`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 narrow:px-2`,children:[(0,V.jsxs)(H,{variant:`row`,className:`flex min-w-0 flex-1 items-center gap-2 text-left text-ink`,"aria-expanded":s,onClick:()=>c(!s),children:[(0,V.jsx)(Ma,{right:!s}),(0,V.jsx)(`span`,{children:l===1?z(`review.countOne`):z(`review.count`,{count:l})})]}),(0,V.jsx)(H,{disabled:n,onClick:o,children:n?z(`review.sending`):z(`review.send`,{count:l})})]}),s&&(0,V.jsx)(`ul`,{className:`m-0 min-h-0 list-none overflow-y-auto p-0 pb-1`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`flex flex-col gap-0.5 px-3 py-1 narrow:px-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,V.jsx)(H,{variant:`row`,className:`min-w-0 flex-1 truncate text-left text-ink hover:underline`,title:z(`review.show`),onClick:()=>r(e),children:Aq(e)}),t.get(e.id)===`moved`&&(0,V.jsx)(`span`,{title:z(`review.movedHint`),children:(0,V.jsx)(yL,{tone:`warning`,children:z(`review.moved`)})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>i(e),children:z(`review.edit`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>a(e),children:z(`review.drop`)})]}),(0,V.jsx)(`p`,{className:`m-0 line-clamp-2 whitespace-pre-wrap wrap-anywhere text-muted`,children:e.body})]},e.id))})]})}var Fq=[];function Iq({model:e,view:t,active:n,restored:r,onClose:i}){B();let a=Ko(),[o,s]=(0,g.useState)($K),[c,l]=(0,g.useState)(qK),[u,d]=AK(t),f=t.scope===`task`?u:null,p=f!==null,m={taskId:t.taskId,path:t.path,scope:t.scope,...o?{ignoreWhitespace:!0}:{},...f?{base:f}:{}},[h,_]=(0,g.useState)(()=>{let n=Ns(e,`diff.file`,m);return n===void 0?null:wq(n,t.path,p)}),[y,b]=(0,g.useState)(()=>Ns(e,`review.list`,{taskId:t.taskId})?.notes??[]),[x,S]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.taskId})?.base??null),[C,w]=(0,g.useState)(0),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(new Set),[j,ee]=(0,g.useState)(!1),[M,N]=(0,g.useState)(0),P=(0,g.useRef)(null),F=e.client;(0,g.useEffect)(()=>{let e=!0;return Fs(F,`diff.file`,m).then(n=>e&&_(wq(n,t.path,p)),t=>{if(e){if(f&&t instanceof r_&&t.code===`BAD_REF`){d(null),G(t.message,`error`);return}_({kind:`text`,text:t instanceof Error?t.message:String(t),error:!0})}}),()=>{e=!1}},[F,t.taskId,t.path,t.scope,o,f,M]),(0,g.useEffect)(()=>{let e=!0;return Fs(F,`diff.files`,{taskId:t.taskId}).then(t=>e&&S(t.base),()=>{}),()=>{e=!1}},[F,t.taskId,M]);let I=()=>void Fs(F,`review.list`,{taskId:t.taskId}).then(e=>b(e.notes));(0,g.useEffect)(I,[F,t.taskId,M]);let te=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n&&(te.current||!r)&&P.current?.focus(),te.current=!0},[n,r]);let L=h?.kind===`rows`?h.rows:Fq,ne=h?.kind===`rows`&&h.diff,re=(0,g.useMemo)(()=>L.map((e,t)=>`row-${t}`),[L]),ie=(0,g.useMemo)(()=>cq(L,k),[L,k]),R=(0,g.useMemo)(()=>lq(L),[L]),ae=(0,g.useMemo)(()=>KK(L),[L]),oe=(0,g.useMemo)(()=>YK(c,t.taskId,ae),[c,t.taskId,ae]),se=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=[...ae.keys()].filter(e=>vq(e)&&!se.current.has(e));if(e.length!==0){for(let t of e)se.current.add(t);A(t=>new Set([...t,...e]))}},[ae]);let ce=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=ce.current;ce.current=oe;let t=[...oe].filter(t=>!e.has(t)),n=[...e].filter(e=>!oe.has(e));(t.length!==0||n.length!==0)&&A(e=>new Set([...[...e].filter(e=>!n.includes(e)),...t]))},[oe]);let le=(0,g.useMemo)(()=>y.filter(e=>e.sentAt===void 0),[y]),ue=(0,g.useMemo)(()=>le.map(e=>({note:e,at:Mq(e,L)})),[le,L]),de=(0,g.useMemo)(()=>{let e=new Set;for(let{at:t}of ue)if(t)for(let n=t.first;n<=t.last;n++)e.add(n);return e},[ue]),fe=(0,g.useMemo)(()=>{let e=new Map;for(let{note:t,at:n}of ue)n&&e.set(n.last,[...e.get(n.last)??[],t]);return e},[ue]),pe=t.path===`.`&&h!==null&&!(h.kind===`text`&&h.error),me=(0,g.useMemo)(()=>{let e=new Map;for(let{note:t}of ue)e.set(t.id,Nq(t,L,pe));return e},[ue,L,pe]);(0,g.useEffect)(()=>{if(ie.includes(C))return;let e=C;for(;e>0&&L[e]?.kind!==`file`;)e--;w(e),E(null)},[ie,C,L]),(0,g.useEffect)(()=>{P.current?.querySelector(`[data-row="${C}"]`)?.scrollIntoView({block:`nearest`})},[C]);let he=sq(L,C,T),ge=e=>A(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),_e=[...R.keys()].flatMap(e=>L[e]?.path?[L[e]?.path]:[]),ve=(0,g.useMemo)(()=>Cq(R,L),[R,L]),ye=_e.length>0&&_e.every(e=>k.has(e)),be=[...R.values()].reduce((e,t)=>({added:e.added+t.added,removed:e.removed+t.removed}),{added:0,removed:0}),xe=e=>{let n=XK(c,t.taskId,e,oe.has(e)?void 0:ae.get(e));l(n),JK(n)},Se=()=>{eq(!o),s(!o)},Ce=()=>{if(!he)return;let e=Aq({filePath:he.path,startLine:he.startLine,line:he.line});W.set((0,V.jsx)(or,{multiline:!0,title:z(`preview.noteTitle`,{location:e}),submitLabel:z(`preview.noteSubmit`),onSubmit:async e=>{await F.request(`review.add`,{taskId:t.taskId,filePath:he.path,line:he.line,...he.startLine?{startLine:he.startLine}:{},code:jq(L,he.first,he.last),body:e}),E(null),O(!1),I(),P.current?.focus()}}))},we=e=>W.set((0,V.jsx)(or,{multiline:!0,title:z(`review.editTitle`,{location:Aq(e)}),initial:e.body,submitLabel:z(`review.editSubmit`),onSubmit:async n=>{await F.request(`review.edit`,{taskId:t.taskId,id:e.id,body:n}).catch(e=>{throw Tq(e)}),I(),P.current?.focus()}})),Te=e=>void F.request(`review.remove`,{taskId:t.taskId,id:e.id}).then(I).catch(e=>G(Tq(e).message,`error`)),Ee=v(ln),De=()=>{let e=oq(L,C,T);if(e){if(!Ee?.startsWith(`${t.taskId}::`)){G(z(`files.mentionNoEngine`),`error`);return}F.request(`term.input`,{stream:Ee,data:aq(e)}).then(()=>{E(null),ia(Ee)?.focus()}).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},Oe=e=>{let n=Mq(e,L),r=L.findIndex(t=>t.kind===`file`&&t.path===e.filePath);n?(A(t=>new Set([...t].filter(t=>t!==e.filePath))),w(n.first)):t.path===`.`&&r>=0?w(r):t.path!==e.filePath&&t.path!==`.`&&Vk({taskId:t.taskId,path:e.filePath,scope:t.scope}),E(null),O(!1)},ke=()=>{ee(!0),F.request(`review.send`,e.engineTarget(t.taskId)).then(e=>{G(e.delivered?z(`preview.sent`,{count:e.sent}):z(`preview.notSent`,{reason:e.reason??``}),e.delivered?`info`:`error`),I()}).catch(e=>G(e instanceof Error?e.message:String(e),`error`)).finally(()=>ee(!1))},Ae=()=>{let e=ZK([...R.keys()],C);e!==null&&(w(e),E(null),O(!1))},je=()=>{let e=ZK(ue.flatMap(({at:e})=>e?[e.first]:[]).sort((e,t)=>e-t),C);if(e===null)return;let t=L[e]?.path;t&&A(e=>new Set([...e].filter(e=>e!==t))),w(e),E(null),O(!1)},Me=e=>w(t=>{let n=Math.max(0,ie.indexOf(t));return ie[Math.min(ie.length-1,Math.max(0,n+e))]??t}),Ne=e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)Me(1);else if(t===`k`||t===`ArrowUp`)Me(-1);else if(t===`v`)E(e=>e===null?C:null),O(!0);else if(t===`c`&&!e.ctrlKey)Ce();else if(t===`x`){let e=ue.find(({at:e})=>e&&C>=e.first&&C<=e.last);e&&Te(e.note)}else if(t===`s`)ke();else if(t===`z`){let e=L[C]?.path;e&&ne&&ge(e)}else if(t===`r`)N(e=>e+1);else if(t===`q`||t===`Escape`)i();else if(e.ctrlKey&&!e.metaKey&&t.toLowerCase()===`c`&&!window.getSelection()?.toString())i();else return;e.preventDefault()},H=()=>{let e=window.getSelection();if(!e||e.isCollapsed)return;let t=e=>(e instanceof Element?e:e?.parentElement)?.closest(`[data-row]`),n=t(e.anchorNode),r=t(e.focusNode);!n||!r||(E(Number(n.dataset.row)),w(Number(r.dataset.row)),O(!0))},Pe=T===null?C:Math.min(T,C),Fe=T===null?C:Math.max(T,C),Ie=[{id:`working`,label:z(`review.scopeWorking`)},{id:`branch`,label:z(`review.scopeBranch`)},{id:`task`,label:z(`review.scopeTask`,{base:u??x??``})}];return(0,V.jsxs)(`div`,{className:`group/preview flex min-h-0 min-w-0 flex-1 flex-col outline-none`,tabIndex:0,ref:P,onKeyDown:Ne,children:[ne&&(0,V.jsx)(HK,{scopes:x===null?null:Ie,scope:t.scope,onScope:e=>Vk({taskId:t.taskId,path:t.path,scope:e}),picker:x!==null&&(0,V.jsx)(TK,{taskId:t.taskId,model:e,base:x,custom:u,onPick:d}),ignoreWs:o,onToggleWs:Se,files:_e.length,shape:ve,added:be.added,removed:be.removed,viewed:oe.size,allFolded:ye,onFoldAll:()=>A(ye?new Set:new Set(_e)),onNextFile:Ae,onNextComment:ue.some(({at:e})=>e)?je:null}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto py-1.5 font-mono text-meta/normal`,onMouseUp:H,children:[!h&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(`preview.loading`)}),h?.kind===`text`&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle ${h.error?`text-error`:``}`,children:h.text}),ie.map(e=>{let t=L[e],n=e>=Pe&&e<=Fe;if(t.kind===`file`){let r=R.get(e),i=t.path;return(0,V.jsx)(zK,{index:e,name:t.text,path:i,closed:i!==null&&k.has(i),viewed:i!==null&&oe.has(i),cursor:n,added:r?.added??0,removed:r?.removed??0,onToggleFold:()=>{w(e),E(null),O(!1),i&&ge(i)},onToggleViewed:()=>i&&xe(i)},re[e])}let r=de.has(e);return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{"data-row":e,className:NK(t.kind,{cursor:n,noted:r}),onClick:t=>{window.getSelection()?.isCollapsed!==!1&&(t.shiftKey?E(e=>e??C):(!a||T===null)&&E(null),w(e),O(!0))},children:[(0,V.jsx)(`span`,{className:PK,children:t.oldNo??``}),(0,V.jsx)(`span`,{className:PK,children:t.newNo??``}),(0,V.jsx)(`span`,{className:FK(t.kind,r),children:t.kind===`add`?`+`:t.kind===`del`?`−`:r?`●`:` `}),(0,V.jsx)(`span`,{className:IK(t.kind),children:t.text}),D&&he&&e===Fe&&(0,V.jsx)(BK,{showRange:a&&T===null,ranged:T!==null,onComment:Ce,onRange:()=>E(C),onAsk:De})]}),fe.get(e)?.map(e=>(0,V.jsx)(VK,{note:e,onEdit:()=>we(e)},e.id))]},re[e])})]}),(0,V.jsx)(Pq,{notes:le,states:me,sending:j,onShow:Oe,onEdit:we,onDrop:Te,onSend:ke})]})}function Lq(e){B();let{model:t,view:n}=e,r=n.path===`.`?null:CG(n.path),[i,a]=(0,g.useState)(null),o=v(t.tasks);if(!r)return(0,V.jsx)(Iq,{...e});let s=i===n.path,c=JSON.stringify(o?.tasks.find(e=>e.id===n.taskId)?.changes??null);return(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex gap-x-3 px-2.5 py-1`,children:[(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":!s,onClick:()=>a(null),children:`[ ${z(`artifact.preview`)} ]`}),(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":s,onClick:()=>a(n.path),children:`[ ${z(`artifact.source`)} ]`})]}),s?(0,V.jsx)(Iq,{...e}):(0,V.jsx)(CK,{model:t,taskId:n.taskId,path:n.path,kind:r,changeKey:c})]})}var Rq={entries:[],failed:new Set},zq=[`command`,`cmd`,`file_path`,`path`,`pattern`,`query`,`url`,`description`,`prompt`],Bq=100;function Vq(e){let t=(e.split(`
141
- `).find(e=>e.trim()!==``)??``).trim();return t.length>Bq?`${t.slice(0,99)}…`:t}function Hq(e){if(typeof e==`string`)return Vq(e);if(!e||typeof e!=`object`)return``;let t=e,n=e=>typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(` `):``;for(let e of zq){let r=n(t[e]);if(r.trim())return Vq(r)}for(let e of Object.values(t)){let t=n(e);if(t.trim())return Vq(t)}return``}function Uq(e){return e===`user`||e===`assistant`||e===`system`?e:null}function Wq(e,t){let n=[],r=[];return e.forEach((e,i)=>{let a=Uq(e.role);if(!a)return;let o=[],s=[];for(let t of e.blocks??[])t.type===`text`&&t.text?.trim()?o.push(t.text.trim()):t.type===`tool_call`?s.push({callId:t.callId??``,name:t.name??`tool`,summary:Hq(t.input)}):t.type===`tool_result`&&t.isError&&t.callId&&r.push(t.callId);(o.length!==0||s.length!==0)&&n.push({index:t+i,role:a,at:e.timestamp??``,text:o.join(`
142
-
143
- `),tools:s})}),{entries:n,failed:r}}function Gq(e,t,n){let r=Wq(t,n),i=new Map(e.entries.map(e=>[e.index,e]));for(let e of r.entries)i.set(e.index,e);let a=r.failed.length>0?new Set([...e.failed,...r.failed]):e.failed;return{entries:[...i.values()].sort((e,t)=>e.index-t.index),failed:a}}function Kq(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.text.toLowerCase().includes(n)||e.tools.some(e=>`${e.name} ${e.summary}`.toLowerCase().includes(n))).map(e=>e.index):[]}var qq=e=>e.replace(/[*_`]+/g,``).replace(/[…\s]+/g,` `).trim().toLowerCase();function Jq(e,t){let n=e.find(e=>e.at===t.at&&e.role===t.role);if(n)return n.index;let r=qq(t.snippet);return r?e.find(e=>e.role===t.role&&qq(e.text).includes(r))?.index??null:null}function Yq(e,t){let n=e[0];if(!n)return!0;let[r,i]=[Date.parse(n.at),Date.parse(t.at)];return Number.isNaN(r)||Number.isNaN(i)?!0:r>i}function Xq(e,t){let n=e.tools.map(e=>`- \`${e.name}\`${e.summary?` ${e.summary}`:``}${t.has(e.callId)?` (failed)`:``}`);return[e.text,n.join(`
133
+ `),n=[],r=[],i=()=>{r.length>0&&n.push({t:`para`,c:PG(r.join(`
134
+ `))}),r=[]};for(let e=0;e<t.length;e++){let a=t[e],o=FG.exec(a);if(o){i();let r=o[1][0],a=[];for(e++;e<t.length&&!RegExp(`^\\s*${r}{3,}\\s*$`).test(t[e]);e++)a.push(t[e]);n.push({t:`code`,lang:o[2]??``,v:a.join(`
135
+ `)});continue}if(a.trim()===``){i();continue}let s=IG.exec(a);if(s){i(),n.push({t:`heading`,level:s[1].length,c:PG(s[2])});continue}if(zG.test(a)){i(),n.push({t:`hr`});continue}if(BG.test(a)){i();let r=[];for(;e<t.length&&BG.test(t[e]);e++){let n=t[e];VG.test(n)||r.push(HG(n))}e--,n.push({t:`table`,rows:r.map(e=>e.map(e=>PG(e)))});continue}if(a.startsWith(`>`)){i();let r=[];for(;e<t.length&&t[e].startsWith(`>`);e++)r.push(t[e].replace(/^>\s?/,``));e--,n.push({t:`quote`,c:PG(r.join(`
136
+ `))});continue}let c=LG.exec(a),l=c?null:RG.exec(a);if(c||l){i();let r=!c,a=[];for(;e<t.length;e++){let n=r?RG.exec(t[e]):LG.exec(t[e]);if(!n)break;let i=n[1].length;a.push({depth:Math.min(3,Math.floor(i/2)),c:PG(r?n[2]:n[3])})}e--,n.push({t:`list`,ordered:r,items:a});continue}r.push(a)}return i(),n}var WG=`flex min-h-0 min-w-0 flex-1 flex-col font-sans text-body`,GG=`flex flex-none flex-wrap items-center gap-x-3 gap-y-1 px-3 pb-1.5 font-mono text-meta`,KG=`min-w-0 flex-1 basis-32 py-1 text-meta`,qG=`min-h-0 flex-1 overflow-y-auto px-3 pb-3`,JG=`m-0 px-3 py-2 font-mono text-meta text-subtle`,YG=`m-0 whitespace-pre-wrap px-3 pb-3 font-mono text-meta leading-[1.45] text-muted wrap-anywhere`,XG=e=>`group/entry mt-3 rounded-sm border-l-2 py-0.5 pl-2.5 ${e.flash?`border-accent bg-accent-soft`:e.current?`border-line-active`:`border-transparent`}`,ZG=`mb-0.5 flex items-center gap-2 font-mono text-meta`,QG=e=>e===`user`?`text-accent`:`text-muted`,$G=`text-subtle`,eK=`ml-auto opacity-0 group-hover/entry:opacity-100 focus-visible:opacity-100 touch:opacity-100`,tK=`m-0 mt-0.5 flex min-w-0 items-baseline gap-1.5 font-mono text-meta text-subtle`,nK=`flex-none text-muted`,rK=`min-w-0 flex-1 truncate`,iK=`leading-[1.5] wrap-anywhere`,aK=`m-0 mb-2 whitespace-pre-wrap last:mb-0`,oK=`m-0 mt-3 mb-1.5 font-semibold first:mt-0`,sK=`m-0 mb-2 flex flex-col gap-0.5 pl-5 last:mb-0`,cK=`m-0 mb-2 border-l-2 border-line pl-2.5 whitespace-pre-wrap text-muted last:mb-0`,lK=`m-0 mb-2 overflow-x-auto rounded-sm border-hairline border-line bg-inset px-2.5 py-2 font-mono text-meta leading-[1.45] last:mb-0`,uK=`rounded-xs bg-inset px-1 font-mono text-meta`,dK=`text-accent underline`,fK=`mb-2 block max-w-full overflow-x-auto border-collapse font-mono text-meta last:mb-0`,pK=`border-hairline border-line px-2 py-0.5 text-left align-top`,mK=`my-2 border-0 border-t border-line`;function hK(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase(),i=[],a=0;for(let t=r.indexOf(n);t>=0;t=r.indexOf(n,a))t>a&&i.push(e.slice(a,t)),i.push((0,V.jsx)(`mark`,{className:jO,"data-hit":``,children:e.slice(t,t+n.length)},t)),a=t+n.length;return i.push(e.slice(a)),g.Children.toArray(i)}var gK=[`h3`,`h3`,`h4`,`h5`,`h6`,`h6`];function _K({level:e,children:t}){let n=gK[Math.min(5,Math.max(0,e-1))]??`h6`;return(0,V.jsx)(n,{className:oK,children:t})}function vK(e,t){return e.map((e,n)=>(0,V.jsx)(g.Fragment,{children:t(e)},n))}function yK({nodes:e,needle:t}){return vK(e,e=>e.t===`text`?hK(e.v,t):e.t===`code`?(0,V.jsx)(`code`,{className:uK,children:hK(e.v,t)}):e.t===`bold`?(0,V.jsx)(`strong`,{children:(0,V.jsx)(yK,{nodes:e.c,needle:t})}):e.t===`em`?(0,V.jsx)(`em`,{children:(0,V.jsx)(yK,{nodes:e.c,needle:t})}):(0,V.jsx)(`a`,{className:dK,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:(0,V.jsx)(yK,{nodes:e.c,needle:t})}))}function bK({block:e,needle:t}){switch(e.t){case`heading`:return(0,V.jsx)(_K,{level:e.level,children:(0,V.jsx)(yK,{nodes:e.c,needle:t})});case`para`:return(0,V.jsx)(`p`,{className:aK,children:(0,V.jsx)(yK,{nodes:e.c,needle:t})});case`code`:return(0,V.jsx)(`pre`,{className:lK,children:(0,V.jsx)(`code`,{children:hK(e.v,t)})});case`quote`:return(0,V.jsx)(`blockquote`,{className:cK,children:(0,V.jsx)(yK,{nodes:e.c,needle:t})});case`hr`:return(0,V.jsx)(`hr`,{className:mK});case`list`:{let n=e.ordered?`ol`:`ul`;return(0,V.jsx)(n,{className:`${sK} ${e.ordered?`list-decimal`:`list-disc`}`,children:vK(e.items,e=>(0,V.jsx)(`li`,{style:{marginLeft:`${e.depth*1.25}rem`},children:(0,V.jsx)(yK,{nodes:e.c,needle:t})}))})}case`table`:return(0,V.jsx)(`table`,{className:fK,children:(0,V.jsx)(`tbody`,{children:vK(e.rows,e=>(0,V.jsx)(`tr`,{children:vK(e,e=>(0,V.jsx)(`td`,{className:pK,children:(0,V.jsx)(yK,{nodes:e,needle:t})}))}))})})}}function xK({source:e,needle:t=``}){let n=(0,g.useMemo)(()=>UG(e),[e]);return(0,V.jsx)(`div`,{className:iK,children:vK(n,e=>(0,V.jsx)(bK,{block:e,needle:t}))})}function SK(e){if(e instanceof r_){if(e.code===`TOO_LARGE`){let t=e.detail?.size;return lL(z(`artifact.tooLarge`),{size:typeof t==`number`?`${(t/1048576).toFixed(1)} MB`:`5 MB+`})}if(e.code===`NOT_PREVIEWABLE`)return z(`artifact.notPreviewable`);if(e.code===`NOT_FOUND`)return z(`artifact.gone`)}return lL(z(`artifact.failed`),{error:e instanceof Error?e.message:String(e)})}function CK(e,t,n,r){let[i,a]=(0,g.useState)({kind:`loading`});return(0,g.useEffect)(()=>{let r=!0;return e.client.request(`file.read`,{taskId:t,path:n}).then(e=>r&&a({kind:`ready`,file:e}),e=>r&&a({kind:`failed`,text:SK(e)})),()=>{r=!1}},[e,t,n,r]),i}function wK(e,t){let n=(0,g.useMemo)(()=>e===null?null:URL.createObjectURL(new Blob([EG(e)],{type:t})),[e,t]);return(0,g.useEffect)(()=>()=>void(n&&URL.revokeObjectURL(n)),[n]),n}function TK({model:e,taskId:t,path:n,kind:r,changeKey:i}){B();let a=CK(e,t,n,i),o=wK(a.kind===`ready`&&(r===`svg`||r===`image`||r===`pdf`)?a.file.base64:null,r===`md`||r===`html`?``:OG(r,n));return a.kind===`loading`?(0,V.jsx)(`p`,{className:Wt,children:z(`artifact.loading`)}):a.kind===`failed`?(0,V.jsx)(`p`,{className:`${Wt} text-error`,children:a.text}):r===`md`?(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:(0,V.jsx)(xK,{source:DG(a.file.base64)})}):r===`html`?(0,V.jsx)(`iframe`,{title:n,sandbox:``,srcDoc:AG(DG(a.file.base64)),style:{colorScheme:`light`,background:`#fff`},className:`min-h-0 w-full flex-1 border-none`}):o?r===`pdf`?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`a`,{className:`${Xt} px-3 py-1 font-mono text-meta`,href:o,target:`_blank`,rel:`noreferrer noopener`,children:z(`artifact.open`)}),(0,V.jsx)(`iframe`,{title:n,src:o,className:`min-h-0 w-full flex-1 border-none`})]}):(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,V.jsx)(`img`,{src:o,alt:n,className:`max-w-full`})}):null}function EK(e,t,n){let r=[{ref:null,suggestion:{key:`default`,text:t,dim:z(`review.baseDefault`),accent:!0}}],i=(e,n)=>{for(let i of e)i!==t&&r.push({ref:i,suggestion:{key:`${n}:${i}`,text:i,dim:n}})};i(e?.branches??[],z(`review.baseBranch`)),i(e?.remotes??[],z(`review.baseRemote`)),i(e?.tags??[],z(`review.baseTag`));for(let t of e?.commits??[])r.push({ref:t.sha,suggestion:{key:`commit:${t.sha}`,text:t.sha,dim:t.subject}});let a=n.trim().toLowerCase();if(a===``)return r.slice(0,40);let o=r.filter(e=>`${e.suggestion.text} ${e.suggestion.dim??``}`.toLowerCase().includes(a)),s=e=>e.suggestion.text.toLowerCase()===a?0:1;return o.sort((e,t)=>s(e)-s(t)).slice(0,40)}function DK(e){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null),s=e.model.client;(0,g.useEffect)(()=>{if(!t)return;let n=!0;return Fs(s,`diff.refs`,{taskId:e.taskId}).then(e=>n&&o(e),()=>{}),()=>{n=!1}},[t,s,e.taskId]);let c=EK(a,e.base,r),l=t=>{e.onPick(t),n(!1),i(``)};return(0,V.jsxs)(`span`,{className:`relative`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&t&&n(!1)},children:[(0,V.jsx)(H,{hit:`tight`,"aria-expanded":t,title:z(`review.baseHint`),className:e.custom?``:`opacity-60 aria-expanded:opacity-100`,onClick:()=>n(!t),children:z(`review.basePicker`,{base:e.custom??e.base})}),t&&(0,V.jsx)(`div`,{className:`absolute top-full left-0 z-3 mt-1 w-64 max-w-full rounded-sm border-hairline border-line-active bg-surface p-1 shadow-popover`,children:(0,V.jsx)(xD,{field:`diff-base`,autoFocus:!0,value:r,onChange:i,items:c.map(e=>e.suggestion),open:!0,placeholder:z(`review.basePlaceholder`),onPick:e=>l(c[e]?.ref??null),onEnter:()=>l(r.trim()===``?null:r.trim())})})]})}var OK=`rove.diffBase`;function kK(){try{let e=JSON.parse(localStorage.getItem(OK)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function AK(e){return kK()[e]??null}function jK(e,t){let n=kK();t===null?delete n[e]:n[e]=t;try{localStorage.setItem(OK,JSON.stringify(n))}catch{}}function MK(e){let[t,n]=(0,g.useState)(()=>AK(e.taskId));return[t,t=>{jK(e.taskId,t),n(t),t!==null&&e.scope!==`task`&&Vk({taskId:e.taskId,path:e.path,scope:`task`})}]}var NK={add:`bg-diff-added-bg`,del:`bg-diff-removed-bg`},PK={add:`text-diff-added`,del:`text-diff-removed`};function FK(e,t){let n=t.cursor?`bg-inset group-focus/preview:bg-accent-soft`:t.noted?`bg-inset`:NK[e]??``;return`relative grid ${e===`file`||e===`note`?`cursor-pointer`:`cursor-default`} grid-cols-[4ch_4ch_2ch_1fr] gap-x-2 gap-y-0 whitespace-pre px-3 narrow:grid-cols-[3ch_3ch_1ch_1fr] narrow:gap-x-1 narrow:px-1.5 ${n} ${e===`file`?`mt-2 border-t-hairline border-line pt-1 font-bold text-ink`:e===`hunk`||e===`meta`?`text-subtle`:``}`}var IK=`text-right text-subtle`,LK=(e,t)=>t?`text-accent`:PK[e]??``,RK=e=>`min-w-0 narrow:whitespace-pre-wrap narrow:wrap-anywhere ${PK[e]??``}`,zK=`min-w-0 whitespace-pre-wrap wrap-anywhere text-accent`,BK=`flex min-w-0 items-baseline gap-2`;function VK(e){return(0,V.jsxs)(`div`,{className:`flex items-center ${e.viewed?`opacity-60`:``}`,children:[(0,V.jsxs)(H,{variant:`row`,"data-row":e.index,"aria-expanded":!e.closed,"aria-label":z(e.closed?`review.unfold`:`review.fold`,{path:e.name}),className:`${FK(`file`,{cursor:e.cursor,noted:!1})} min-w-0 flex-1 text-left`,onClick:e.onToggleFold,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{className:`grid place-items-center text-subtle`,children:(0,V.jsx)(Ma,{right:e.closed})}),(0,V.jsxs)(`span`,{className:BK,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),e.added?(0,V.jsxs)(xL,{tone:`added`,children:[`+`,e.added]}):null,e.removed?(0,V.jsxs)(xL,{tone:`removed`,children:[`−`,e.removed]}):null]})]}),e.path&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none px-2`,"aria-pressed":e.viewed,"aria-label":z(e.viewed?`review.unmarkViewed`:`review.markViewed`,{path:e.name}),onClick:e.onToggleViewed,children:e.viewed?z(`review.viewedOn`):z(`review.viewed`)})]})}function HK(e){return(0,V.jsxs)(`div`,{className:`absolute top-full right-3 z-1 flex gap-1.5`,children:[(0,V.jsx)(H,{variant:`floating`,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),e.onComment()},children:z(`review.comment`)}),e.showRange&&(0,V.jsx)(H,{variant:`floating`,onClick:t=>{t.stopPropagation(),e.onRange()},children:z(`review.range`)}),e.ranged&&(0,V.jsx)(H,{variant:`floating`,title:z(`preview.askInChatHint`),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),e.onAsk()},children:z(`preview.askInChat`)})]})}function UK({note:e,onEdit:t}){return(0,V.jsxs)(H,{variant:`row`,className:`${FK(`note`,{cursor:!1,noted:!1})} w-full text-left`,onClick:t,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{className:`text-accent`,children:`●`}),(0,V.jsx)(`span`,{className:zK,children:e.body})]})}function WK(e){return(0,V.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-1 px-2 pt-1.5 font-mono text-meta`,children:[e.scopes&&(0,V.jsx)(cG,{className:`flex-wrap`,tabs:e.scopes,value:e.scope,onChange:e.onScope}),e.picker,(0,V.jsx)(H,{hit:`tight`,"aria-pressed":e.ignoreWs,title:z(`review.ignoreWsHint`),className:`opacity-60 aria-pressed:underline aria-pressed:opacity-100`,onClick:e.onToggleWs,children:z(`review.ignoreWs`)}),(0,V.jsxs)(`span`,{className:`flex min-w-0 basis-full flex-wrap items-center gap-x-1.5 text-muted`,children:[z(`review.totals`,{files:e.files,added:e.added,removed:e.removed}),e.shape&&(0,V.jsxs)(`span`,{children:[`· `,e.shape]}),e.files>0&&(0,V.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`· `,z(`review.viewedCount`,{done:e.viewed,files:e.files})]})]}),(0,V.jsxs)(`span`,{className:`ml-auto flex items-center gap-x-3`,children:[e.files>1&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onNextFile,children:z(`review.nextFile`)}),e.onNextComment&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onNextComment,children:z(`review.nextComment`)}),e.files>1&&(0,V.jsx)(H,{hit:`tight`,onClick:e.onFoldAll,children:e.allFolded?z(`review.unfoldAll`):z(`review.foldAll`)})]})]})}var GK=`rove.diffViewed`,KK=(e,t)=>`${e}\0${t}`;function qK(e){let t=2166136261;for(let n of e){let e=`${n.kind}${n.text}\n`;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619)}return(t>>>0).toString(16)}function JK(e){let t=new Map,n=-1,r=r=>{let i=n>=0?e[n]?.path:null;i&&t.set(i,qK(e.slice(n+1,r)))};return e.forEach((e,t)=>{e.kind===`file`&&(r(t),n=t)}),r(e.length),t}function YK(){try{let e=JSON.parse(localStorage.getItem(GK)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function XK(e){try{localStorage.setItem(GK,JSON.stringify(e))}catch{}}function ZK(e,t,n){let r=new Set;for(let[i,a]of n)e[KK(t,i)]===a&&r.add(i);return r}function QK(e,t,n,r){let i={...e};return r===void 0?delete i[KK(t,n)]:i[KK(t,n)]=r,i}function $K(e,t){return e.find(e=>e>t)??e[0]??null}var eq=`rove.diffIgnoreWs`;function tq(){try{return localStorage.getItem(eq)===`1`}catch{return!1}}function nq(e){try{localStorage.setItem(eq,e?`1`:`0`)}catch{}}var rq=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function iq(e,t=null,n=!1){let r=[],i=0,a=0,o=t,s=!1;for(let t of e.replace(/\n$/,``).split(`
137
+ `)){if(t.startsWith(`diff --git `)){let e=/ b\/(.+)$/.exec(t);o=e?e[1]:o,s=!1,r.push({kind:`file`,text:o??t,oldNo:null,newNo:null,path:o});continue}let e=rq.exec(t);if(e){i=Number(e[1]),a=Number(e[2]),s=!0,r.push({kind:`hunk`,text:t,oldNo:null,newNo:null,path:o});continue}if(!s){r.push({kind:`meta`,text:t,oldNo:null,newNo:null,path:o});continue}t.startsWith(`+`)?r.push({kind:`add`,text:t.slice(1),oldNo:null,newNo:a++,path:o}):t.startsWith(`-`)?r.push({kind:`del`,text:t.slice(1),oldNo:i++,newNo:null,path:o,...n?{foreignOld:!0}:{}}):t.startsWith(`\\`)?r.push({kind:`meta`,text:t,oldNo:null,newNo:null,path:o}):r.push({kind:`ctx`,text:t.slice(1),oldNo:i++,newNo:a++,path:o})}return r}function aq(e,t){return e.replace(/\n$/,``).split(`
138
+ `).map((e,n)=>({kind:`ctx`,text:e,oldNo:null,newNo:n+1,path:t}))}function oq(e){return e.kind===`del`?e.foreignOld?null:e.oldNo:e.kind===`add`||e.kind===`ctx`?e.newNo:null}function sq(e){let t=e.startLine?`lines ${e.startLine}-${e.line}`:`line ${e.line}`;return`@${e.path} (${t}) `}function cq(e,t,n){let r=e[t],i=r?oq(r):null;if(!r?.path||i===null)return null;if(n===null||n===t)return{path:r.path,line:i};let a=e[Math.min(n,t)],o=e[Math.max(n,t)],s=a?oq(a):null,c=o?oq(o):null;return s===null||c===null||a?.path!==o?.path?{path:r.path,line:i}:s===c?{path:r.path,line:c}:{path:r.path,startLine:Math.min(s,c),line:Math.max(s,c)}}function lq(e,t,n){let r=cq(e,t,n);if(!r)return null;let i=r.startLine!==void 0&&n!==null;return{...r,first:i?Math.min(n,t):t,last:i?Math.max(n,t):t}}function uq(e,t){let n=[],r=!1;return e.forEach((e,i)=>{e.kind===`file`&&(r=e.path!==null&&t.has(e.path)),(!r||e.kind===`file`)&&n.push(i)}),n}function dq(e){let t=new Map,n=-1;return e.forEach((e,r)=>{if(e.kind===`file`){n=r,t.set(r,{added:0,removed:0});return}let i=t.get(n);i&&(e.kind===`add`?i.added++:e.kind===`del`&&i.removed++)}),t}var fq=[`source`,`tests`,`config`,`docs`,`generated`],pq=/(^|\/)(bun\.lockb?|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|poetry\.lock|uv\.lock|Gemfile\.lock|go\.sum|composer\.lock)$/,mq=/(^|\/)(dist|build|generated|__generated__|\.next)\/|\.min\.(js|css)$|\.snap$|\.generated\.|\.pb\.go$|\.map$/,hq=/(^|\/)(tests?|__tests__|spec|e2e)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]+\.py$/,gq=/\.(md|mdx|rst|txt)$|(^|\/)docs\//i,_q=/(^|\/)(\.[\w.-]+rc(\.\w+)?|[\w.-]*\.config\.[cm]?[jt]s|tsconfig[\w.-]*\.json|package\.json|biome\.json|Dockerfile|Makefile)$|\.(ya?ml|toml|ini|env)$|(^|\/)\.(github|changeset|vscode)\//,vq=e=>pq.test(e);function yq(e){return pq.test(e)||mq.test(e)?`generated`:hq.test(e)?`tests`:gq.test(e)?`docs`:_q.test(e)?`config`:`source`}var bq=e=>yq(e)===`generated`;function xq(e){let t=e.filter(e=>yq(e.path)!==`generated`),n=t.reduce((e,t)=>e+t.lines,0);return t.length===0?1:((e,t)=>e<=2&&t<=30?1:e<=5&&t<=150?2:e<=10&&t<=400?3:e<=20&&t<=1e3?4:5)(t.length,n)}function Sq(e){let t=[],n=(e,n)=>n>0&&t.push({group:e,count:n});for(let t of fq)t===`generated`?(n(`lockfile`,e.filter(vq).length),n(`generated`,e.filter(e=>yq(e)===`generated`&&!vq(e)).length)):n(t,e.filter(e=>yq(e)===t).length);return t}function Cq(e){let t=[];for(let n of e)(n.kind===`file`||t.length===0)&&t.push([]),t[t.length-1]?.push(n);let n=e=>fq.indexOf(yq(e[0]?.path??``));return t.map((e,t)=>({file:e,i:t})).sort((e,t)=>n(e.file)-n(t.file)||e.i-t.i).flatMap(({file:e})=>e)}function wq(e){return Sq(e.map(e=>e.path)).map(({group:e,count:t})=>({key:e===`lockfile`?t===1?`lockfile`:`lockfiles`:e,count:t}))}function Tq(e,t){let n=[...e.entries()].flatMap(([e,n])=>{let r=t[e]?.path;return r?[{path:r,lines:n.added+n.removed}]:[]});return n.length<2?``:[z(`review.shape.effort`,{n:xq(n)}),...wq(n).map(e=>z(`review.shape.${e.key}`,{count:e.count}))].join(` · `)}function Eq(e,t,n){if(!e||typeof e!=`object`||!(`kind`in e))return{kind:`text`,text:z(`preview.unknown`)};let r=`text`in e&&typeof e.text==`string`?e.text:``;switch(e.kind){case`diff`:{let e=iq(r,t===`.`?null:t,n);return{kind:`rows`,rows:t===`.`?Cq(e):e,diff:!0}}case`code`:return{kind:`rows`,rows:aq(r,t),diff:!1};case`binary`:return{kind:`text`,text:z(`preview.binary`)};case`empty`:return{kind:`text`,text:z(`preview.empty`)};case`error`:return{kind:`text`,text:`message`in e?String(e.message):z(`preview.unknown`),error:!0};default:return{kind:`text`,text:z(`preview.noHunks`,{kind:String(e.kind)})}}}function Dq(e){return e instanceof r_&&e.code===`UNKNOWN_OP`?Error(z(`review.notSupported`)):e instanceof Error?e:Error(String(e))}var Oq={add:`+`,del:`-`},kq=40,Aq=160,jq=e=>`${Oq[e.kind]??` `}${e.text.slice(0,Aq)}`,Mq=e=>e.startLine!==void 0&&e.startLine!==e.line?`${e.filePath}:${e.startLine}-${e.line}`:`${e.filePath}:${e.line}`;function Nq(e,t,n){let r=[];for(let i=t;i<=n&&r.length<kq;i++){let t=e[i];t&&oq(t)!==null&&r.push(jq(t))}return r.join(`
139
+ `)}function Pq(e,t){let n=e.startLine??e.line,r=t.flatMap((t,n)=>t.path===e.filePath&&oq(t)!==null?[n]:[]);if(!e.code){let i=r.filter(r=>{let i=oq(t[r]);return i>=n&&i<=e.line}),a=i[0],o=i[i.length-1];return a===void 0||o===void 0?null:{first:a,last:o}}let i=e.code.split(`
140
+ `);for(let e=0;e+i.length<=r.length;e++){let a=r.slice(e,e+i.length),o=a[0],s=a[a.length-1];if(o!==void 0&&s!==void 0&&oq(t[o])===n&&a.every((e,n)=>jq(t[e])===i[n]))return{first:o,last:s}}return null}function Fq(e,t,n){return Pq(e,t)?`ok`:t.some(t=>t.path===e.filePath)||n?`moved`:`unknown`}function Iq({notes:e,states:t,sending:n,onShow:r,onEdit:i,onDrop:a,onSend:o}){B();let[s,c]=(0,g.useState)(!1);if(e.length===0)return null;let l=e.length;return(0,V.jsxs)(`div`,{className:`flex max-h-2/5 min-h-0 flex-none flex-col border-t-hairline border-line font-mono text-meta`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 narrow:px-2`,children:[(0,V.jsxs)(H,{variant:`row`,className:`flex min-w-0 flex-1 items-center gap-2 text-left text-ink`,"aria-expanded":s,onClick:()=>c(!s),children:[(0,V.jsx)(Ma,{right:!s}),(0,V.jsx)(`span`,{children:l===1?z(`review.countOne`):z(`review.count`,{count:l})})]}),(0,V.jsx)(H,{disabled:n,onClick:o,children:n?z(`review.sending`):z(`review.send`,{count:l})})]}),s&&(0,V.jsx)(`ul`,{className:`m-0 min-h-0 list-none overflow-y-auto p-0 pb-1`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`flex flex-col gap-0.5 px-3 py-1 narrow:px-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,V.jsx)(H,{variant:`row`,className:`min-w-0 flex-1 truncate text-left text-ink hover:underline`,title:z(`review.show`),onClick:()=>r(e),children:Mq(e)}),t.get(e.id)===`moved`&&(0,V.jsx)(`span`,{title:z(`review.movedHint`),children:(0,V.jsx)(xL,{tone:`warning`,children:z(`review.moved`)})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>i(e),children:z(`review.edit`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>a(e),children:z(`review.drop`)})]}),(0,V.jsx)(`p`,{className:`m-0 line-clamp-2 whitespace-pre-wrap wrap-anywhere text-muted`,children:e.body})]},e.id))})]})}var Lq=[];function Rq({model:e,view:t,active:n,restored:r,onClose:i}){B();let a=Ko(),[o,s]=(0,g.useState)(tq),[c,l]=(0,g.useState)(YK),[u,d]=MK(t),f=t.scope===`task`?u:null,p=f!==null,m={taskId:t.taskId,path:t.path,scope:t.scope,...o?{ignoreWhitespace:!0}:{},...f?{base:f}:{}},[h,_]=(0,g.useState)(()=>{let n=Ns(e,`diff.file`,m);return n===void 0?null:Eq(n,t.path,p)}),[y,b]=(0,g.useState)(()=>Ns(e,`review.list`,{taskId:t.taskId})?.notes??[]),[x,S]=(0,g.useState)(()=>Ns(e,`diff.files`,{taskId:t.taskId})?.base??null),[C,w]=(0,g.useState)(0),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(new Set),[j,ee]=(0,g.useState)(!1),[M,N]=(0,g.useState)(0),P=(0,g.useRef)(null),F=e.client;(0,g.useEffect)(()=>{let e=!0;return Fs(F,`diff.file`,m).then(n=>e&&_(Eq(n,t.path,p)),t=>{if(e){if(f&&t instanceof r_&&t.code===`BAD_REF`){d(null),G(t.message,`error`);return}_({kind:`text`,text:t instanceof Error?t.message:String(t),error:!0})}}),()=>{e=!1}},[F,t.taskId,t.path,t.scope,o,f,M]),(0,g.useEffect)(()=>{let e=!0;return Fs(F,`diff.files`,{taskId:t.taskId}).then(t=>e&&S(t.base),()=>{}),()=>{e=!1}},[F,t.taskId,M]);let I=()=>void Fs(F,`review.list`,{taskId:t.taskId}).then(e=>b(e.notes));(0,g.useEffect)(I,[F,t.taskId,M]);let te=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n&&(te.current||!r)&&P.current?.focus(),te.current=!0},[n,r]);let L=h?.kind===`rows`?h.rows:Lq,ne=h?.kind===`rows`&&h.diff,re=(0,g.useMemo)(()=>L.map((e,t)=>`row-${t}`),[L]),ie=(0,g.useMemo)(()=>uq(L,k),[L,k]),R=(0,g.useMemo)(()=>dq(L),[L]),ae=(0,g.useMemo)(()=>JK(L),[L]),oe=(0,g.useMemo)(()=>ZK(c,t.taskId,ae),[c,t.taskId,ae]),se=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=[...ae.keys()].filter(e=>bq(e)&&!se.current.has(e));if(e.length!==0){for(let t of e)se.current.add(t);A(t=>new Set([...t,...e]))}},[ae]);let ce=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=ce.current;ce.current=oe;let t=[...oe].filter(t=>!e.has(t)),n=[...e].filter(e=>!oe.has(e));(t.length!==0||n.length!==0)&&A(e=>new Set([...[...e].filter(e=>!n.includes(e)),...t]))},[oe]);let le=(0,g.useMemo)(()=>y.filter(e=>e.sentAt===void 0),[y]),ue=(0,g.useMemo)(()=>le.map(e=>({note:e,at:Pq(e,L)})),[le,L]),de=(0,g.useMemo)(()=>{let e=new Set;for(let{at:t}of ue)if(t)for(let n=t.first;n<=t.last;n++)e.add(n);return e},[ue]),fe=(0,g.useMemo)(()=>{let e=new Map;for(let{note:t,at:n}of ue)n&&e.set(n.last,[...e.get(n.last)??[],t]);return e},[ue]),pe=t.path===`.`&&h!==null&&!(h.kind===`text`&&h.error),me=(0,g.useMemo)(()=>{let e=new Map;for(let{note:t}of ue)e.set(t.id,Fq(t,L,pe));return e},[ue,L,pe]);(0,g.useEffect)(()=>{if(ie.includes(C))return;let e=C;for(;e>0&&L[e]?.kind!==`file`;)e--;w(e),E(null)},[ie,C,L]),(0,g.useEffect)(()=>{P.current?.querySelector(`[data-row="${C}"]`)?.scrollIntoView({block:`nearest`})},[C]);let he=lq(L,C,T),ge=e=>A(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),_e=[...R.keys()].flatMap(e=>L[e]?.path?[L[e]?.path]:[]),ve=(0,g.useMemo)(()=>Tq(R,L),[R,L]),ye=_e.length>0&&_e.every(e=>k.has(e)),be=[...R.values()].reduce((e,t)=>({added:e.added+t.added,removed:e.removed+t.removed}),{added:0,removed:0}),xe=e=>{let n=QK(c,t.taskId,e,oe.has(e)?void 0:ae.get(e));l(n),XK(n)},Se=()=>{nq(!o),s(!o)},Ce=()=>{if(!he)return;let e=Mq({filePath:he.path,startLine:he.startLine,line:he.line});W.set((0,V.jsx)(or,{multiline:!0,title:z(`preview.noteTitle`,{location:e}),submitLabel:z(`preview.noteSubmit`),onSubmit:async e=>{await F.request(`review.add`,{taskId:t.taskId,filePath:he.path,line:he.line,...he.startLine?{startLine:he.startLine}:{},code:Nq(L,he.first,he.last),body:e}),E(null),O(!1),I(),P.current?.focus()}}))},we=e=>W.set((0,V.jsx)(or,{multiline:!0,title:z(`review.editTitle`,{location:Mq(e)}),initial:e.body,submitLabel:z(`review.editSubmit`),onSubmit:async n=>{await F.request(`review.edit`,{taskId:t.taskId,id:e.id,body:n}).catch(e=>{throw Dq(e)}),I(),P.current?.focus()}})),Te=e=>void F.request(`review.remove`,{taskId:t.taskId,id:e.id}).then(I).catch(e=>G(Dq(e).message,`error`)),Ee=v(ln),De=()=>{let e=cq(L,C,T);if(e){if(!Ee?.startsWith(`${t.taskId}::`)){G(z(`files.mentionNoEngine`),`error`);return}F.request(`term.input`,{stream:Ee,data:sq(e)}).then(()=>{E(null),ia(Ee)?.focus()}).catch(e=>G(e instanceof Error?e.message:String(e),`error`))}},Oe=e=>{let n=Pq(e,L),r=L.findIndex(t=>t.kind===`file`&&t.path===e.filePath);n?(A(t=>new Set([...t].filter(t=>t!==e.filePath))),w(n.first)):t.path===`.`&&r>=0?w(r):t.path!==e.filePath&&t.path!==`.`&&Vk({taskId:t.taskId,path:e.filePath,scope:t.scope}),E(null),O(!1)},ke=()=>{ee(!0),F.request(`review.send`,e.engineTarget(t.taskId)).then(e=>{G(e.delivered?z(`preview.sent`,{count:e.sent}):z(`preview.notSent`,{reason:e.reason??``}),e.delivered?`info`:`error`),I()}).catch(e=>G(e instanceof Error?e.message:String(e),`error`)).finally(()=>ee(!1))},Ae=()=>{let e=$K([...R.keys()],C);e!==null&&(w(e),E(null),O(!1))},je=()=>{let e=$K(ue.flatMap(({at:e})=>e?[e.first]:[]).sort((e,t)=>e-t),C);if(e===null)return;let t=L[e]?.path;t&&A(e=>new Set([...e].filter(e=>e!==t))),w(e),E(null),O(!1)},Me=e=>w(t=>{let n=Math.max(0,ie.indexOf(t));return ie[Math.min(ie.length-1,Math.max(0,n+e))]??t}),Ne=e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)Me(1);else if(t===`k`||t===`ArrowUp`)Me(-1);else if(t===`v`)E(e=>e===null?C:null),O(!0);else if(t===`c`&&!e.ctrlKey)Ce();else if(t===`x`){let e=ue.find(({at:e})=>e&&C>=e.first&&C<=e.last);e&&Te(e.note)}else if(t===`s`)ke();else if(t===`z`){let e=L[C]?.path;e&&ne&&ge(e)}else if(t===`r`)N(e=>e+1);else if(t===`q`||t===`Escape`)i();else if(e.ctrlKey&&!e.metaKey&&t.toLowerCase()===`c`&&!window.getSelection()?.toString())i();else return;e.preventDefault()},H=()=>{let e=window.getSelection();if(!e||e.isCollapsed)return;let t=e=>(e instanceof Element?e:e?.parentElement)?.closest(`[data-row]`),n=t(e.anchorNode),r=t(e.focusNode);!n||!r||(E(Number(n.dataset.row)),w(Number(r.dataset.row)),O(!0))},Pe=T===null?C:Math.min(T,C),Fe=T===null?C:Math.max(T,C),Ie=[{id:`working`,label:z(`review.scopeWorking`)},{id:`branch`,label:z(`review.scopeBranch`)},{id:`task`,label:z(`review.scopeTask`,{base:u??x??``})}];return(0,V.jsxs)(`div`,{className:`group/preview flex min-h-0 min-w-0 flex-1 flex-col outline-none`,tabIndex:0,ref:P,onKeyDown:Ne,children:[ne&&(0,V.jsx)(WK,{scopes:x===null?null:Ie,scope:t.scope,onScope:e=>Vk({taskId:t.taskId,path:t.path,scope:e}),picker:x!==null&&(0,V.jsx)(DK,{taskId:t.taskId,model:e,base:x,custom:u,onPick:d}),ignoreWs:o,onToggleWs:Se,files:_e.length,shape:ve,added:be.added,removed:be.removed,viewed:oe.size,allFolded:ye,onFoldAll:()=>A(ye?new Set:new Set(_e)),onNextFile:Ae,onNextComment:ue.some(({at:e})=>e)?je:null}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto py-1.5 font-mono text-meta/normal`,onMouseUp:H,children:[!h&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(`preview.loading`)}),h?.kind===`text`&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle ${h.error?`text-error`:``}`,children:h.text}),ie.map(e=>{let t=L[e],n=e>=Pe&&e<=Fe;if(t.kind===`file`){let r=R.get(e),i=t.path;return(0,V.jsx)(VK,{index:e,name:t.text,path:i,closed:i!==null&&k.has(i),viewed:i!==null&&oe.has(i),cursor:n,added:r?.added??0,removed:r?.removed??0,onToggleFold:()=>{w(e),E(null),O(!1),i&&ge(i)},onToggleViewed:()=>i&&xe(i)},re[e])}let r=de.has(e);return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{"data-row":e,className:FK(t.kind,{cursor:n,noted:r}),onClick:t=>{window.getSelection()?.isCollapsed!==!1&&(t.shiftKey?E(e=>e??C):(!a||T===null)&&E(null),w(e),O(!0))},children:[(0,V.jsx)(`span`,{className:IK,children:t.oldNo??``}),(0,V.jsx)(`span`,{className:IK,children:t.newNo??``}),(0,V.jsx)(`span`,{className:LK(t.kind,r),children:t.kind===`add`?`+`:t.kind===`del`?`−`:r?`●`:` `}),(0,V.jsx)(`span`,{className:RK(t.kind),children:t.text}),D&&he&&e===Fe&&(0,V.jsx)(HK,{showRange:a&&T===null,ranged:T!==null,onComment:Ce,onRange:()=>E(C),onAsk:De})]}),fe.get(e)?.map(e=>(0,V.jsx)(UK,{note:e,onEdit:()=>we(e)},e.id))]},re[e])})]}),(0,V.jsx)(Iq,{notes:le,states:me,sending:j,onShow:Oe,onEdit:we,onDrop:Te,onSend:ke})]})}function zq(e){B();let{model:t,view:n}=e,r=n.path===`.`?null:TG(n.path),[i,a]=(0,g.useState)(null),o=v(t.tasks);if(!r)return(0,V.jsx)(Rq,{...e});let s=i===n.path,c=JSON.stringify(o?.tasks.find(e=>e.id===n.taskId)?.changes??null);return(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex gap-x-3 px-2.5 py-1`,children:[(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":!s,onClick:()=>a(null),children:`[ ${z(`artifact.preview`)} ]`}),(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":s,onClick:()=>a(n.path),children:`[ ${z(`artifact.source`)} ]`})]}),s?(0,V.jsx)(Rq,{...e}):(0,V.jsx)(TK,{model:t,taskId:n.taskId,path:n.path,kind:r,changeKey:c})]})}var Bq={entries:[],failed:new Set},Vq=[`command`,`cmd`,`file_path`,`path`,`pattern`,`query`,`url`,`description`,`prompt`],Hq=100;function Uq(e){let t=(e.split(`
141
+ `).find(e=>e.trim()!==``)??``).trim();return t.length>Hq?`${t.slice(0,99)}…`:t}function Wq(e){if(typeof e==`string`)return Uq(e);if(!e||typeof e!=`object`)return``;let t=e,n=e=>typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(` `):``;for(let e of Vq){let r=n(t[e]);if(r.trim())return Uq(r)}for(let e of Object.values(t)){let t=n(e);if(t.trim())return Uq(t)}return``}function Gq(e){return e===`user`||e===`assistant`||e===`system`?e:null}function Kq(e,t){let n=[],r=[];return e.forEach((e,i)=>{let a=Gq(e.role);if(!a)return;let o=[],s=[];for(let t of e.blocks??[])t.type===`text`&&t.text?.trim()?o.push(t.text.trim()):t.type===`tool_call`?s.push({callId:t.callId??``,name:t.name??`tool`,summary:Wq(t.input)}):t.type===`tool_result`&&t.isError&&t.callId&&r.push(t.callId);(o.length!==0||s.length!==0)&&n.push({index:t+i,role:a,at:e.timestamp??``,text:o.join(`
142
+
143
+ `),tools:s})}),{entries:n,failed:r}}function qq(e,t,n){let r=Kq(t,n),i=new Map(e.entries.map(e=>[e.index,e]));for(let e of r.entries)i.set(e.index,e);let a=r.failed.length>0?new Set([...e.failed,...r.failed]):e.failed;return{entries:[...i.values()].sort((e,t)=>e.index-t.index),failed:a}}function Jq(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.text.toLowerCase().includes(n)||e.tools.some(e=>`${e.name} ${e.summary}`.toLowerCase().includes(n))).map(e=>e.index):[]}var Yq=e=>e.replace(/[*_`]+/g,``).replace(/[…\s]+/g,` `).trim().toLowerCase();function Xq(e,t){let n=e.find(e=>e.at===t.at&&e.role===t.role);if(n)return n.index;let r=Yq(t.snippet);return r?e.find(e=>e.role===t.role&&Yq(e.text).includes(r))?.index??null:null}function Zq(e,t){let n=e[0];if(!n)return!0;let[r,i]=[Date.parse(n.at),Date.parse(t.at)];return Number.isNaN(r)||Number.isNaN(i)?!0:r>i}function Qq(e,t){let n=e.tools.map(e=>`- \`${e.name}\`${e.summary?` ${e.summary}`:``}${t.has(e.callId)?` (failed)`:``}`);return[e.text,n.join(`
144
144
  `)].filter(e=>e!==``).join(`
145
145
 
146
- `)}function Zq(e,t){return e.text===``?Xq(e,t):e.text}function Qq(e,t,n,r){return`# ${e}\n\n${t.map(e=>`${`## ${r[e.role]}${e.at?` · ${e.at}`:``}`}\n\n${Xq(e,n)}`).join(`
146
+ `)}function $q(e,t){return e.text===``?Qq(e,t):e.text}function eJ(e,t,n,r){return`# ${e}\n\n${t.map(e=>`${`## ${r[e.role]}${e.at?` · ${e.at}`:``}`}\n\n${Qq(e,n)}`).join(`
147
147
 
148
- `)}\n`}var $q=50;function eJ(e,t){let[n,r]=(0,g.useState)({kind:`loading`}),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(n);o.current=n;let s=(0,g.useRef)(!1),c=(0,g.useRef)(0),l=(0,g.useCallback)(n=>e.client.request(`output.read`,{taskId:t,limit:$q,...n}),[e,t]),u=(0,g.useCallback)(async()=>{let e=++c.current;s.current=!0;try{let t=await l({});if(e!==c.current)return;if(t.source===`terminal`||!t.history){r({kind:`terminal`,tail:t.terminal?.tail??[]});return}let n=Gq(Rq,t.history.messages??[],t.history.firstIndex??0);r({kind:`ready`,transcript:n,cursor:t.cursor??null,older:t.olderCursor??null})}catch(t){e===c.current&&r({kind:`error`,message:K(t)})}finally{e===c.current&&(s.current=!1)}},[l]);(0,g.useEffect)(()=>(r({kind:`loading`}),u(),()=>{c.current++,s.current=!1}),[u]);let d=(0,g.useCallback)(async()=>{let e=o.current;if(s.current)return;if(e.kind===`terminal`)return u();if(e.kind!==`ready`||!e.cursor)return;let t=c.current;s.current=!0;try{let n=await l({cursor:e.cursor,source:`history`});if(t!==c.current)return;r(e=>e.kind===`ready`?{...e,transcript:Gq(e.transcript,n.history?.messages??[],n.history?.firstIndex??0),cursor:n.cursor??e.cursor}:e)}catch{t===c.current&&(s.current=!1,await u())}finally{t===c.current&&(s.current=!1)}},[l,u]);return{state:n,paging:i,loadOlder:(0,g.useCallback)(async()=>{let e=o.current;if(s.current||e.kind!==`ready`||!e.older)return;let t=c.current;s.current=!0,a(!0);try{let n=await l({cursor:e.older,source:`history`});if(t!==c.current)return;r(e=>e.kind===`ready`?{...e,transcript:Gq(e.transcript,n.history?.messages??[],n.history?.firstIndex??0),older:n.olderCursor??null}:e)}catch(e){t===c.current&&r({kind:`error`,message:K(e)})}finally{t===c.current&&(s.current=!1,a(!1))}},[l]),loadAll:(0,g.useCallback)(async()=>{let e=o.current;if(e.kind!==`ready`)return null;if(s.current||!e.older)return e.transcript;let t=c.current;s.current=!0,a(!0);let n=[],i=e.transcript;try{for(let r=e.older;r&&t===c.current;){let e=await l({cursor:r,source:`history`}),t={messages:e.history?.messages??[],firstIndex:e.history?.firstIndex??0};n.push(t),i=Gq(i,t.messages,t.firstIndex),r=e.olderCursor??null}return t===c.current?(r(e=>e.kind===`ready`?{...e,transcript:n.reduce((e,t)=>Gq(e,t.messages,t.firstIndex),e.transcript),older:null}:e),i):null}catch(e){return t===c.current&&r({kind:`error`,message:K(e)}),null}finally{t===c.current&&(s.current=!1,a(!1))}},[l]),refresh:d,reload:(0,g.useCallback)(()=>{r({kind:`loading`}),u()},[u])}}var tJ=3e3,nJ=80,rJ=2500;function iJ(e,t){let n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}var aJ=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})};function oJ(e){let{entry:t}=e,n=z(t.role===`user`?`transcript.you`:t.role===`assistant`?`transcript.agent`:`transcript.system`);return(0,V.jsxs)(`article`,{className:JG(e),"data-index":t.index,children:[(0,V.jsxs)(`header`,{className:YG,children:[(0,V.jsx)(`span`,{className:XG(t.role),children:n}),(0,V.jsx)(`span`,{className:ZG,children:aJ(t.at)}),(0,V.jsx)(H,{className:QG,onClick:e.onCopy,children:z(`transcript.copy`)})]}),t.text!==``&&(0,V.jsx)(yK,{source:t.text,needle:e.needle}),t.tools.map((t,n)=>(0,V.jsxs)(`p`,{className:$G,title:`${t.name} ${t.summary}`,children:[(0,V.jsx)(`span`,{className:eK,children:pK(t.name,e.needle)}),(0,V.jsx)(`span`,{className:tK,children:pK(t.summary,e.needle)}),e.failed.has(t.callId)&&(0,V.jsx)(`span`,{className:`flex-none text-error`,children:z(`transcript.failed`)})]},n))]})}function sJ({model:e,task:t,active:n}){B();let r=eJ(e,t.id),{state:i}=r,[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(null),d=(0,g.useRef)(null),f=(0,g.useRef)(!0),p=(0,g.useRef)(null),m=v(Gk),h=i.kind===`ready`?i:null,_=(0,g.useMemo)(()=>h?.transcript.entries??[],[h?.transcript]),y=h?.transcript.failed??new Set,b=(0,g.useMemo)(()=>Kq(_,a),[_,a]),x=b.length===0?0:Math.min(s,b.length-1),S=b[x]??null,C=e=>{f.current=!1,d.current?.querySelector(`[data-index="${e}"]`)?.scrollIntoView({block:`center`})},w=t.rowStatus?.kind,T=w===`running`||w===`needs-input`,{refresh:E}=r;(0,g.useEffect)(()=>{n&&E()},[n,w,E]),(0,g.useEffect)(()=>{if(!n||!T)return;let e=setInterval(()=>void E(),tJ);return()=>clearInterval(e)},[n,T,E]),(0,g.useLayoutEffect)(()=>{let e=d.current;e&&(p.current?(e.scrollTop=p.current.top+(e.scrollHeight-p.current.height),p.current=null):f.current&&(e.scrollTop=e.scrollHeight))},[_]);let D=async()=>{let e=d.current;e&&(p.current={height:e.scrollHeight,top:e.scrollTop}),await r.loadOlder()};(0,g.useEffect)(()=>{if(!m||m.taskId!==t.id||!h||!n)return;let e=Jq(_,m.hit);e===null?h.older&&Yq(_,m.hit)?D():Gk.set(null):(u(e),C(e),Gk.set(null))},[m,h,_,n,t.id]),(0,g.useEffect)(()=>{if(l===null)return;let e=setTimeout(()=>u(null),rJ);return()=>clearTimeout(e)},[l]),(0,g.useEffect)(()=>{c(0);let e=Kq(_,a)[0];e!==void 0&&C(e)},[a]);let O=e=>{if(b.length===0)return;let t=(x+e+b.length)%b.length;c(t),C(b[t])},k=e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),O(e.shiftKey?-1:1)):e.key===`Escape`&&a!==``&&(e.stopPropagation(),o(``))},A=e=>void navigator.clipboard.writeText(Zq(e,y)).then(()=>G(z(`transcript.copied`)),()=>G(z(`menu.copyFailed`),`error`)),j=async()=>{let e=await r.loadAll();if(!e)return;let n={user:z(`transcript.you`),assistant:z(`transcript.agent`),system:z(`transcript.system`)};iJ(`${t.label.replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-|-$/g,``)||`conversation`}.md`,Qq(t.label,e.entries,e.failed,n))};return i.kind===`loading`?(0,V.jsx)(`div`,{className:HG,children:(0,V.jsx)(`p`,{className:KG,children:z(`transcript.loading`)})}):i.kind===`error`?(0,V.jsxs)(`div`,{className:HG,children:[(0,V.jsx)(`p`,{className:`${KG} text-error`,children:z(`transcript.error`,{error:i.message})}),(0,V.jsx)(`p`,{className:KG,children:(0,V.jsx)(H,{onClick:r.reload,children:z(`transcript.retry`)})})]}):i.kind===`terminal`?(0,V.jsxs)(`div`,{className:HG,children:[(0,V.jsx)(`p`,{className:KG,children:z(`transcript.noHistory`)}),(0,V.jsx)(`pre`,{className:`${qG} min-h-0 flex-1 overflow-y-auto`,children:i.tail.join(`
149
- `)})]}):(0,V.jsxs)(`div`,{className:HG,children:[(0,V.jsxs)(`div`,{className:UG,children:[(0,V.jsx)(`input`,{className:`${Qt} ${WG}`,value:a,placeholder:z(`transcript.findPlaceholder`),"aria-label":z(`transcript.findPlaceholder`),spellCheck:!1,autoComplete:`off`,onChange:e=>o(e.target.value),onKeyDown:k}),a.trim()!==``&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`whitespace-nowrap text-muted`,children:b.length===0?z(`transcript.findNone`):z(`transcript.findCount`,{at:x+1,total:b.length})}),(0,V.jsx)(H,{onClick:()=>O(-1),disabled:b.length===0,children:z(`transcript.prev`)}),(0,V.jsx)(H,{onClick:()=>O(1),disabled:b.length===0,children:z(`transcript.next`)})]}),(0,V.jsx)(H,{onClick:()=>void j(),disabled:_.length===0,children:z(`transcript.export`)})]}),(0,V.jsxs)(`div`,{ref:d,className:GG,onScroll:e=>{let t=e.currentTarget;f.current=t.scrollHeight-t.scrollTop-t.clientHeight<nJ,t.scrollTop<nJ&&h?.older&&!r.paging&&D()},children:[h?.older&&(0,V.jsx)(`p`,{className:`m-0 px-3 py-2 font-mono text-meta text-subtle`,children:(0,V.jsx)(H,{onClick:()=>void D(),disabled:r.paging,children:z(`transcript.older`)})}),_.length===0&&(0,V.jsx)(`p`,{className:`m-0 px-3 py-2 font-mono text-meta text-subtle`,children:z(`transcript.empty`)}),_.map(e=>(0,V.jsx)(oJ,{entry:e,failed:y,needle:a,flash:l===e.index,current:S===e.index,onCopy:()=>A(e)},e.index))]})]})}function cJ(){B();let e=v(Wa),t=z(e?`panel.restore`:`panel.expand`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:aI({tool:!0}),title:t,"aria-label":t,"aria-pressed":e,onClick:()=>Wa.set(!e),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e?`M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5l4-4M6.5 9.5l-4 4`:`M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5l-4.5 4.5M2.5 13.5 7 9`})})}),(0,V.jsx)(`button`,{type:`button`,className:aI({tool:!0}),title:z(`panel.hide`),"aria-label":z(`panel.hide`),onClick:()=>Ua.set(!1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})})]})}function lJ({panel:e}){B();let t=(0,g.useRef)(null);return(0,V.jsx)(wI,{edge:`left`,title:z(`panel.resize`),onPointerDown:n=>{t.current={x:n.clientX,width:e.current?.getBoundingClientRect().width??0},e.current?.classList.add(`is-resizing`),n.currentTarget.setPointerCapture(n.pointerId),Cn(!0)},onPointerMove:e=>{let n=t.current;if(!n||e.clientX===n.x)return;let r=$F.get()?0:rI(QF.get()??280);Ha.set(Ga(n.width-(e.clientX-n.x),r))},onLostPointerCapture:()=>{t.current=null,e.current?.classList.remove(`is-resizing`),Cn(!1)},onDoubleClick:()=>Ha.set(null)})}function uJ({taskId:e,body:t}){B();let n=(0,g.useRef)(!1);return(0,V.jsx)(`div`,{className:_I,title:z(`panel.resizeSplit`),onPointerDown:e=>{n.current=!0,t.current?.classList.add(`is-resizing`),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:r=>{let i=t.current?.getBoundingClientRect(),a=t.current?.querySelectorAll(`.side-head`);if(!n.current||!i||a?.length!==2)return;let o=a[0]?.getBoundingClientRect(),s=a[1]?.getBoundingClientRect();if(!o||!s)return;let c=r.currentTarget.getBoundingClientRect().height,l=i.bottom-o.bottom-s.height-c;l>0&&Rk(e,e=>_k(e,(r.clientY-o.bottom-c/2)/l))},onLostPointerCapture:()=>{n.current=!1,t.current?.classList.remove(`is-resizing`)},onDoubleClick:()=>Rk(e,e=>_k(e,.5))})}function dJ({model:e,task:t,tab:n,narrow:r,active:i,restored:a}){return n.kind===`files`?(0,V.jsx)(lG,{model:e,task:t,narrow:r}):n.kind===`chat`?(0,V.jsx)(sJ,{model:e,task:t,active:i}):n.kind===`diff`?(0,V.jsx)(Lq,{model:e,view:{taskId:t.id,path:n.path,scope:n.scope},active:i,restored:a,onClose:()=>Uk(t.id,n.id)},`${t.id}:${n.path}:${n.scope}`):(0,V.jsx)(fW,{model:e,tab:n,onNavigate:e=>Rk(t.id,t=>fk(t,n.id,e)),onStep:e=>Rk(t.id,t=>pk(t,n.id,e))})}function fJ({model:e,task:t,narrow:n}){B();let r=Lk(t.id),i=v(za),a=v(Wa),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=i===`terminal`?`files`:i,l=WO(r),u=n?KO(r,c):null;(0,g.useEffect)(()=>{n&&!u&&Rk(t.id,e=>ck(e,c))},[n,u,c,t.id]);let d=n?u?[u.id]:[]:UO(r).flatMap(([,e])=>e.active?[e.active]:[]),f=(0,g.useRef)([]);f.current=vk(f.current,d,l);let p=(0,g.useRef)(new Set(d)),m=!n&&r.bottom!==null,h=m?`auto minmax(0, ${r.ratio*100}fr) var(--divider) auto minmax(0, ${(1-r.ratio)*100}fr)`:`auto minmax(0, 1fr)`,_=l.filter(e=>e.kind===c),y=!n&&r.top.tabs.length===0;return(0,V.jsxs)(`aside`,{className:cI(n),ref:o,children:[!n&&!a&&(0,V.jsx)(lJ,{panel:o}),(0,V.jsxs)(`div`,{className:lI,ref:s,style:{gridTemplateRows:h},children:[n?(_.length>1||c===`diff`)&&(0,V.jsx)(xG,{taskId:t.id,panel:r,group:`top`,tabs:_,active:u?.id??null,narrow:!0}):UO(r).map(([e,n])=>(0,V.jsx)(xG,{taskId:t.id,panel:r,group:e,tabs:n.tabs,active:n.active,narrow:!1,children:e===`top`&&(0,V.jsx)(cJ,{})},e)),y&&(0,V.jsx)(`p`,{className:`row-2 m-auto flex max-w-[44ch] flex-col items-center gap-2.5 p-4 text-center font-mono text-meta leading-[1.5] text-subtle normal-nums`,children:z(`panel.empty`)}),m&&(0,V.jsx)(uJ,{taskId:t.id,body:s}),l.filter(e=>f.current.includes(e.id)).map(i=>(0,V.jsx)(`div`,{className:vI,hidden:!d.includes(i.id),style:{gridRow:GO(r,i.id)?.name===`bottom`&&!n?5:2},children:(0,V.jsx)(dJ,{model:e,task:t,tab:i,narrow:n,active:d.includes(i.id),restored:p.current.has(i.id)})},i.id))]})]})}function pJ({model:e,task:t,remoteHost:n,narrow:r=!1}){let i=v(un),a=v(Ua);return!r&&(i||!a)?null:t?(0,V.jsx)(fJ,{model:e,task:t,narrow:r},t.id):n?(0,V.jsx)(`aside`,{className:cI(!1),children:(0,V.jsx)(hE,{host:n,onMachines:()=>vO(e)})}):null}var mJ=1500;function hJ({model:e}){let t=e.client,n=v(t.conn),[r,i]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{if(n.state!==`connecting`)return i(!1);let e=window.setTimeout(()=>i(!0),mJ);return()=>window.clearTimeout(e)},[n.state]),n.state===`open`||n.state===`connecting`&&!r?null:(0,V.jsxs)(`footer`,{className:Nt,children:[(0,V.jsx)(`span`,{className:Pt(n.state===`retrying`)}),(0,V.jsx)(`span`,{children:n.state===`retrying`?z(`status.retrying`,{count:n.failures}):z(`status.connecting`)}),n.state===`retrying`&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>t.retryNow(),children:z(`status.retry`)})]})}function gJ({model:e,taskId:t,groupId:n}){B();let r=v(e.tasks),i=r?qI(r.tasks,n):[];return i.length<2||!i.some(e=>e.id===t)?null:(0,V.jsxs)(`nav`,{className:kL,"aria-label":z(`compare.menu`),children:[i.map((n,r)=>(0,V.jsxs)(H,{variant:`pill`,hit:`tight`,"aria-current":n.id===t,onClick:()=>e.select(n.id),children:[`[ `,(0,V.jsx)(XL,{status:n.rowStatus}),r+1,` `,n.engine?.name??n.label,n.kept&&(0,V.jsx)(`span`,{className:`text-accent`,children:`✓`}),` ]`]},n.id)),(0,V.jsx)(H,{hit:`tight`,className:`ml-auto flex-none whitespace-nowrap`,onClick:()=>ga(n),children:z(`compare.strip`)})]})}var _J=new Set,vJ=2e3;function yJ(e){_J.add(e)}function bJ(e,t=vJ){setTimeout(()=>_J.delete(e),t)}var xJ=e=>_J.has(e),SJ=new Map,CJ=new Set,wJ=(e,t)=>`${e}/${t}`,TJ=e=>SJ.get(e)??``;function EJ(e,t){t===``?SJ.delete(e):SJ.set(e,t);for(let e of CJ)e()}function DJ(e){return CJ.add(e),()=>CJ.delete(e)}function OJ(e,t){let n=TJ(e).trimEnd();EJ(e,n===``?t:`${n}\n\n${t}`)}var kJ=3e3,AJ=32;function jJ(e){let{model:t,taskId:n,tabId:r,revision:i}=e,[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(0);if((0,g.useEffect)(()=>{let e=!0,i=()=>t.client.request(`queue.list`,{taskId:n}).then(t=>e&&o(t.items.filter(e=>e.tabId===r)),()=>e&&o([]));i();let a=window.setInterval(i,kJ);return()=>{e=!1,window.clearInterval(a)}},[t,n,r,i,s]),a.length===0)return null;let l=e=>void t.client.request(`queue.cancel`,{id:e}).finally(()=>c(e=>e+1));return(0,V.jsx)(`div`,{className:En,"data-field":`queued`,children:a.map(e=>(0,V.jsxs)(`span`,{className:Dn(!1),title:e.text,children:[`${z(`layout.queuedChip`)} · ${e.text.length>AJ?`${e.text.slice(0,AJ)}…`:e.text} `,(0,V.jsx)(H,{hit:`tight`,"aria-label":z(`layout.queueCancel`),title:z(`layout.queueCancel`),onClick:()=>l(e.id),children:`×`})]},e.id))})}var MJ=`relative hidden [border-top:var(--hairline)_solid_var(--line)] bg-surface px-1.5 py-1.5 touch:flex`,NJ=`absolute inset-x-1.5 bottom-full z-5 mb-1`,PJ=`absolute inset-x-1.5 bottom-full z-6 mb-1`,FJ=`flex min-w-0 flex-1 items-stretch gap-1.5`,IJ=`h-10 min-w-0 flex-1 resize-none rounded-sm border-hairline border-line bg-inset px-2 py-2 font-sans text-display leading-[1.35] text-ink outline-none focus:border-focus disabled:opacity-60`,LJ=`h-10 shrink-0 rounded-sm bg-accent px-3.5 font-sans text-meta font-semibold text-paper touch-manipulation active:scale-97 motion-reduce:active:scale-none disabled:opacity-50`,RJ=`flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-sm border-hairline border-line bg-inset text-muted touch-manipulation has-[:disabled]:opacity-60`;function zJ(){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,className:`size-4 fill-none stroke-current stroke-[1.4]`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M10.5 4.5 5.8 9.2a1.4 1.4 0 0 0 2 2l5-5a2.8 2.8 0 0 0-4-4l-5.2 5.2a4.2 4.2 0 0 0 6 6L13 9`})})}function BJ(e){return(0,V.jsxs)(`form`,{className:MJ,"data-composer":e.composerKey,onSubmit:t=>{t.preventDefault(),e.onSend()},children:[e.attached&&(0,V.jsx)(`div`,{className:NJ,children:e.attached}),e.suggest&&(0,V.jsx)(`div`,{className:PJ,children:e.suggest}),(0,V.jsxs)(`div`,{className:FJ,children:[e.attach,(0,V.jsx)(`textarea`,{ref:e.fieldRef,className:IJ,rows:1,value:e.value,placeholder:e.placeholder,disabled:e.busy,enterKeyHint:`send`,onChange:e.onChange,onSelect:e.onSelect,onKeyDown:e.onKeyDown,onPaste:e.onPaste}),(0,V.jsx)(`button`,{type:`submit`,className:LJ,disabled:e.busy||!e.ready,children:e.sendLabel})]})]})}function VJ({model:e,taskId:t,tabId:n}){let r=v(e.tasks)?.tasks.some(e=>e.id===t)??!1,i=wJ(t,n),a=(0,g.useSyncExternalStore)(DJ,()=>TJ(i)),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(0),{attachments:u,attach:d,remove:f,clear:p}=Uo(e,e=>G(e,`error`)),m=(0,g.useRef)(null),h=GD({value:a,onChange:e=>EJ(i,e),area:m,listClassName:`m-0`}),_=async()=>{let r=Vo(a.trim(),u).trim();if(r){s(!0);try{let a=await e.client.request(`tab.send`,{taskId:t,tabId:n,prompt:r,queue:!0});if(!a.delivered&&!a.queued){G(z(`layout.composerNotSent`,{reason:a.reason??``}),`error`);return}a.queued&&(G(z(`layout.composerQueued`,{position:a.position??1})),l(e=>e+1)),EJ(i,``),p()}catch(e){let t=e instanceof r_?e.code:void 0;G(t===`UNKNOWN_OP`?z(`layout.composerOldBridge`):t===`AWAITING_PERMISSION`?z(`layout.composerAtMenu`):e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}}};if(!r)return null;let y=e=>void d(e);return(0,V.jsx)(BJ,{value:a,placeholder:z(`layout.composerPlaceholder`),sendLabel:z(`layout.composerSend`),busy:o,ready:a.trim()!==``||u.length>0,attached:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(jJ,{model:e,taskId:t,tabId:n,revision:c}),(0,V.jsx)(Wo,{attachments:u,onRemove:f})]}),attach:(0,V.jsxs)(Bo,{className:RJ,title:z(`layout.composerAttach`),disabled:o,onFiles:y,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:z(`layout.composerAttach`)}),(0,V.jsx)(zJ,{})]}),composerKey:i,fieldRef:m,suggest:h.list,...h.field,onPaste:zo(y).onPaste,onSend:()=>void _()})}var HJ={up:`layout.termKeyUp`,down:`layout.termKeyDown`,left:`layout.termKeyLeft`,right:`layout.termKeyRight`,interrupt:`layout.termKeyInterrupt`,enter:`layout.termKeyEnter`};function UJ({handle:e,atMenu:t}){B();let[n,r]=(0,g.useState)(!1);(0,g.useEffect)(()=>{e.armCtrl(n?()=>r(!1):null)},[e,n]),(0,g.useEffect)(()=>()=>e.armCtrl(null),[e]);let{term:i}=e,a=e=>(0,V.jsx)(`button`,{type:`button`,className:et(!1),"aria-label":HJ[e.id]?z(HJ[e.id]):void 0,onClick:()=>{r(!1),i.input(e.bytes(i.modes.applicationCursorKeysMode),!0)},children:e.cap},e.id);return(0,V.jsxs)(`div`,{className:`mono ${$e}`,role:`toolbar`,"aria-label":z(`layout.termKeys`),onPointerDown:e=>e.preventDefault(),children:[t&&yv.map(a),(0,V.jsx)(`button`,{type:`button`,className:et(n),"aria-pressed":n,onClick:()=>r(!n),children:`ctrl`}),_v.filter(e=>!(t&&yv.includes(e))).map(a)]})}function WJ(e){switch(e.kind){case`restored`:return z(`workspace.restored`);case`notLive`:return z(`workspace.tabNotLive`);case`exited`:return z(`workspace.exited`,{code:e.code??`?`});case`failed`:return z(`workspace.attachFailed`,{message:e.message});case`none`:return``}}function GJ(e){B();let{notice:t,engineExit:n,model:r,taskId:i,tabId:a,revive:o}=e,s=t.kind===`none`?n:null,c=t.kind===`none`&&!s&&e.usageLimit===!0&&!o.error;if(t.kind===`none`&&!s&&!c)return null;let l=t.kind===`notLive`||t.kind===`restored`||t.kind===`exited`,u=t.kind===`exited`||s!==null,d=o.error?z(`workspace.reopenFailed`,{message:o.error}):s?z(`workspace.engineExited`,{code:s.code??`?`}):c?z(`workspace.usageLimit`):WJ(t);return(0,V.jsxs)(`div`,{className:Mt(t.kind===`failed`||!!o.error),children:[(0,V.jsx)(`span`,{children:d}),e.onReopen&&(l||s)&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,disabled:o.busy,onClick:()=>e.onReopen?.(s!==null),children:o.busy?z(`workspace.reopening`):z(s?`workspace.retry`:`workspace.reopen`)}),t.kind===`failed`&&e.onRetryAttach&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:e.onRetryAttach,children:z(`workspace.retry`)}),c&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i,context:`continue`,sourceTabId:a})),children:z(`menu.continueEngine`)}),(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:e.onDismissLimit,children:z(`workspace.dismiss`)})]}),u&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>W.set((0,V.jsx)(NP,{model:r,section:`engines`})),children:z(`workspace.engineSettings`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i})),children:z(`menu.newChatPick`)}),(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i,context:`continue`,sourceTabId:a})),children:z(`menu.continueEngine`)})]})]})}function KJ(e){let t=e.split(`
148
+ `)}\n`}var tJ=50;function nJ(e,t){let[n,r]=(0,g.useState)({kind:`loading`}),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(n);o.current=n;let s=(0,g.useRef)(!1),c=(0,g.useRef)(0),l=(0,g.useCallback)(n=>e.client.request(`output.read`,{taskId:t,limit:tJ,...n}),[e,t]),u=(0,g.useCallback)(async()=>{let e=++c.current;s.current=!0;try{let t=await l({});if(e!==c.current)return;if(t.source===`terminal`||!t.history){r({kind:`terminal`,tail:t.terminal?.tail??[]});return}let n=qq(Bq,t.history.messages??[],t.history.firstIndex??0);r({kind:`ready`,transcript:n,cursor:t.cursor??null,older:t.olderCursor??null})}catch(t){e===c.current&&r({kind:`error`,message:K(t)})}finally{e===c.current&&(s.current=!1)}},[l]);(0,g.useEffect)(()=>(r({kind:`loading`}),u(),()=>{c.current++,s.current=!1}),[u]);let d=(0,g.useCallback)(async()=>{let e=o.current;if(s.current)return;if(e.kind===`terminal`)return u();if(e.kind!==`ready`||!e.cursor)return;let t=c.current;s.current=!0;try{let n=await l({cursor:e.cursor,source:`history`});if(t!==c.current)return;r(e=>e.kind===`ready`?{...e,transcript:qq(e.transcript,n.history?.messages??[],n.history?.firstIndex??0),cursor:n.cursor??e.cursor}:e)}catch{t===c.current&&(s.current=!1,await u())}finally{t===c.current&&(s.current=!1)}},[l,u]);return{state:n,paging:i,loadOlder:(0,g.useCallback)(async()=>{let e=o.current;if(s.current||e.kind!==`ready`||!e.older)return;let t=c.current;s.current=!0,a(!0);try{let n=await l({cursor:e.older,source:`history`});if(t!==c.current)return;r(e=>e.kind===`ready`?{...e,transcript:qq(e.transcript,n.history?.messages??[],n.history?.firstIndex??0),older:n.olderCursor??null}:e)}catch(e){t===c.current&&r({kind:`error`,message:K(e)})}finally{t===c.current&&(s.current=!1,a(!1))}},[l]),loadAll:(0,g.useCallback)(async()=>{let e=o.current;if(e.kind!==`ready`)return null;if(s.current||!e.older)return e.transcript;let t=c.current;s.current=!0,a(!0);let n=[],i=e.transcript;try{for(let r=e.older;r&&t===c.current;){let e=await l({cursor:r,source:`history`}),t={messages:e.history?.messages??[],firstIndex:e.history?.firstIndex??0};n.push(t),i=qq(i,t.messages,t.firstIndex),r=e.olderCursor??null}return t===c.current?(r(e=>e.kind===`ready`?{...e,transcript:n.reduce((e,t)=>qq(e,t.messages,t.firstIndex),e.transcript),older:null}:e),i):null}catch(e){return t===c.current&&r({kind:`error`,message:K(e)}),null}finally{t===c.current&&(s.current=!1,a(!1))}},[l]),refresh:d,reload:(0,g.useCallback)(()=>{r({kind:`loading`}),u()},[u])}}var rJ=3e3,iJ=80,aJ=2500;function oJ(e,t){let n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}var sJ=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})};function cJ(e){let{entry:t}=e,n=z(t.role===`user`?`transcript.you`:t.role===`assistant`?`transcript.agent`:`transcript.system`);return(0,V.jsxs)(`article`,{className:XG(e),"data-index":t.index,children:[(0,V.jsxs)(`header`,{className:ZG,children:[(0,V.jsx)(`span`,{className:QG(t.role),children:n}),(0,V.jsx)(`span`,{className:$G,children:sJ(t.at)}),(0,V.jsx)(H,{className:eK,onClick:e.onCopy,children:z(`transcript.copy`)})]}),t.text!==``&&(0,V.jsx)(xK,{source:t.text,needle:e.needle}),t.tools.map((t,n)=>(0,V.jsxs)(`p`,{className:tK,title:`${t.name} ${t.summary}`,children:[(0,V.jsx)(`span`,{className:nK,children:hK(t.name,e.needle)}),(0,V.jsx)(`span`,{className:rK,children:hK(t.summary,e.needle)}),e.failed.has(t.callId)&&(0,V.jsx)(`span`,{className:`flex-none text-error`,children:z(`transcript.failed`)})]},n))]})}function lJ({model:e,task:t,active:n}){B();let r=nJ(e,t.id),{state:i}=r,[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(null),d=(0,g.useRef)(null),f=(0,g.useRef)(!0),p=(0,g.useRef)(null),m=v(Gk),h=i.kind===`ready`?i:null,_=(0,g.useMemo)(()=>h?.transcript.entries??[],[h?.transcript]),y=h?.transcript.failed??new Set,b=(0,g.useMemo)(()=>Jq(_,a),[_,a]),x=b.length===0?0:Math.min(s,b.length-1),S=b[x]??null,C=e=>{f.current=!1,d.current?.querySelector(`[data-index="${e}"]`)?.scrollIntoView({block:`center`})},w=t.rowStatus?.kind,T=w===`running`||w===`needs-input`,{refresh:E}=r;(0,g.useEffect)(()=>{n&&E()},[n,w,E]),(0,g.useEffect)(()=>{if(!n||!T)return;let e=setInterval(()=>void E(),rJ);return()=>clearInterval(e)},[n,T,E]),(0,g.useLayoutEffect)(()=>{let e=d.current;e&&(p.current?(e.scrollTop=p.current.top+(e.scrollHeight-p.current.height),p.current=null):f.current&&(e.scrollTop=e.scrollHeight))},[_]);let D=async()=>{let e=d.current;e&&(p.current={height:e.scrollHeight,top:e.scrollTop}),await r.loadOlder()};(0,g.useEffect)(()=>{if(!m||m.taskId!==t.id||!h||!n)return;let e=Xq(_,m.hit);e===null?h.older&&Zq(_,m.hit)?D():Gk.set(null):(u(e),C(e),Gk.set(null))},[m,h,_,n,t.id]),(0,g.useEffect)(()=>{if(l===null)return;let e=setTimeout(()=>u(null),aJ);return()=>clearTimeout(e)},[l]),(0,g.useEffect)(()=>{c(0);let e=Jq(_,a)[0];e!==void 0&&C(e)},[a]);let O=e=>{if(b.length===0)return;let t=(x+e+b.length)%b.length;c(t),C(b[t])},k=e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),O(e.shiftKey?-1:1)):e.key===`Escape`&&a!==``&&(e.stopPropagation(),o(``))},A=e=>void navigator.clipboard.writeText($q(e,y)).then(()=>G(z(`transcript.copied`)),()=>G(z(`menu.copyFailed`),`error`)),j=async()=>{let e=await r.loadAll();if(!e)return;let n={user:z(`transcript.you`),assistant:z(`transcript.agent`),system:z(`transcript.system`)};oJ(`${t.label.replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-|-$/g,``)||`conversation`}.md`,eJ(t.label,e.entries,e.failed,n))};return i.kind===`loading`?(0,V.jsx)(`div`,{className:WG,children:(0,V.jsx)(`p`,{className:JG,children:z(`transcript.loading`)})}):i.kind===`error`?(0,V.jsxs)(`div`,{className:WG,children:[(0,V.jsx)(`p`,{className:`${JG} text-error`,children:z(`transcript.error`,{error:i.message})}),(0,V.jsx)(`p`,{className:JG,children:(0,V.jsx)(H,{onClick:r.reload,children:z(`transcript.retry`)})})]}):i.kind===`terminal`?(0,V.jsxs)(`div`,{className:WG,children:[(0,V.jsx)(`p`,{className:JG,children:z(`transcript.noHistory`)}),(0,V.jsx)(`pre`,{className:`${YG} min-h-0 flex-1 overflow-y-auto`,children:i.tail.join(`
149
+ `)})]}):(0,V.jsxs)(`div`,{className:WG,children:[(0,V.jsxs)(`div`,{className:GG,children:[(0,V.jsx)(`input`,{className:`${Qt} ${KG}`,value:a,placeholder:z(`transcript.findPlaceholder`),"aria-label":z(`transcript.findPlaceholder`),spellCheck:!1,autoComplete:`off`,onChange:e=>o(e.target.value),onKeyDown:k}),a.trim()!==``&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`whitespace-nowrap text-muted`,children:b.length===0?z(`transcript.findNone`):z(`transcript.findCount`,{at:x+1,total:b.length})}),(0,V.jsx)(H,{onClick:()=>O(-1),disabled:b.length===0,children:z(`transcript.prev`)}),(0,V.jsx)(H,{onClick:()=>O(1),disabled:b.length===0,children:z(`transcript.next`)})]}),(0,V.jsx)(H,{onClick:()=>void j(),disabled:_.length===0,children:z(`transcript.export`)})]}),(0,V.jsxs)(`div`,{ref:d,className:qG,onScroll:e=>{let t=e.currentTarget;f.current=t.scrollHeight-t.scrollTop-t.clientHeight<iJ,t.scrollTop<iJ&&h?.older&&!r.paging&&D()},children:[h?.older&&(0,V.jsx)(`p`,{className:`m-0 px-3 py-2 font-mono text-meta text-subtle`,children:(0,V.jsx)(H,{onClick:()=>void D(),disabled:r.paging,children:z(`transcript.older`)})}),_.length===0&&(0,V.jsx)(`p`,{className:`m-0 px-3 py-2 font-mono text-meta text-subtle`,children:z(`transcript.empty`)}),_.map(e=>(0,V.jsx)(cJ,{entry:e,failed:y,needle:a,flash:l===e.index,current:S===e.index,onCopy:()=>A(e)},e.index))]})]})}function uJ(){B();let e=v(Wa),t=z(e?`panel.restore`:`panel.expand`);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:sI({tool:!0}),title:t,"aria-label":t,"aria-pressed":e,onClick:()=>Wa.set(!e),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e?`M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5l4-4M6.5 9.5l-4 4`:`M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5l-4.5 4.5M2.5 13.5 7 9`})})}),(0,V.jsx)(`button`,{type:`button`,className:sI({tool:!0}),title:z(`panel.hide`),"aria-label":z(`panel.hide`),onClick:()=>Ua.set(!1),children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})})]})}function dJ({panel:e}){B();let t=(0,g.useRef)(null);return(0,V.jsx)(EI,{edge:`left`,title:z(`panel.resize`),onPointerDown:n=>{t.current={x:n.clientX,width:e.current?.getBoundingClientRect().width??0},e.current?.classList.add(`is-resizing`),n.currentTarget.setPointerCapture(n.pointerId),Cn(!0)},onPointerMove:e=>{let n=t.current;if(!n||e.clientX===n.x)return;let r=tI.get()?0:aI(eI.get()??280);Ha.set(Ga(n.width-(e.clientX-n.x),r))},onLostPointerCapture:()=>{t.current=null,e.current?.classList.remove(`is-resizing`),Cn(!1)},onDoubleClick:()=>Ha.set(null)})}function fJ({taskId:e,body:t}){B();let n=(0,g.useRef)(!1);return(0,V.jsx)(`div`,{className:yI,title:z(`panel.resizeSplit`),onPointerDown:e=>{n.current=!0,t.current?.classList.add(`is-resizing`),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:r=>{let i=t.current?.getBoundingClientRect(),a=t.current?.querySelectorAll(`.side-head`);if(!n.current||!i||a?.length!==2)return;let o=a[0]?.getBoundingClientRect(),s=a[1]?.getBoundingClientRect();if(!o||!s)return;let c=r.currentTarget.getBoundingClientRect().height,l=i.bottom-o.bottom-s.height-c;l>0&&Rk(e,e=>_k(e,(r.clientY-o.bottom-c/2)/l))},onLostPointerCapture:()=>{n.current=!1,t.current?.classList.remove(`is-resizing`)},onDoubleClick:()=>Rk(e,e=>_k(e,.5))})}function pJ({model:e,task:t,tab:n,narrow:r,active:i,restored:a}){return n.kind===`files`?(0,V.jsx)(dG,{model:e,task:t,narrow:r}):n.kind===`chat`?(0,V.jsx)(lJ,{model:e,task:t,active:i}):n.kind===`diff`?(0,V.jsx)(zq,{model:e,view:{taskId:t.id,path:n.path,scope:n.scope},active:i,restored:a,onClose:()=>Uk(t.id,n.id)},`${t.id}:${n.path}:${n.scope}`):(0,V.jsx)(mW,{model:e,tab:n,onNavigate:e=>Rk(t.id,t=>fk(t,n.id,e)),onStep:e=>Rk(t.id,t=>pk(t,n.id,e))})}function mJ({model:e,task:t,narrow:n}){B();let r=Lk(t.id),i=v(za),a=v(Wa),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=i===`terminal`?`files`:i,l=WO(r),u=n?KO(r,c):null;(0,g.useEffect)(()=>{n&&!u&&Rk(t.id,e=>ck(e,c))},[n,u,c,t.id]);let d=n?u?[u.id]:[]:UO(r).flatMap(([,e])=>e.active?[e.active]:[]),f=(0,g.useRef)([]);f.current=vk(f.current,d,l);let p=(0,g.useRef)(new Set(d)),m=!n&&r.bottom!==null,h=m?`auto minmax(0, ${r.ratio*100}fr) var(--divider) auto minmax(0, ${(1-r.ratio)*100}fr)`:`auto minmax(0, 1fr)`,_=l.filter(e=>e.kind===c),y=!n&&r.top.tabs.length===0;return(0,V.jsxs)(`aside`,{className:uI(n),ref:o,children:[!n&&!a&&(0,V.jsx)(dJ,{panel:o}),(0,V.jsxs)(`div`,{className:dI,ref:s,style:{gridTemplateRows:h},children:[n?(_.length>1||c===`diff`)&&(0,V.jsx)(CG,{taskId:t.id,panel:r,group:`top`,tabs:_,active:u?.id??null,narrow:!0}):UO(r).map(([e,n])=>(0,V.jsx)(CG,{taskId:t.id,panel:r,group:e,tabs:n.tabs,active:n.active,narrow:!1,children:e===`top`&&(0,V.jsx)(uJ,{})},e)),y&&(0,V.jsx)(`p`,{className:`row-2 m-auto flex max-w-[44ch] flex-col items-center gap-2.5 p-4 text-center font-mono text-meta leading-[1.5] text-subtle normal-nums`,children:z(`panel.empty`)}),m&&(0,V.jsx)(fJ,{taskId:t.id,body:s}),l.filter(e=>f.current.includes(e.id)).map(i=>(0,V.jsx)(`div`,{className:bI,hidden:!d.includes(i.id),style:{gridRow:GO(r,i.id)?.name===`bottom`&&!n?5:2},children:(0,V.jsx)(pJ,{model:e,task:t,tab:i,narrow:n,active:d.includes(i.id),restored:p.current.has(i.id)})},i.id))]})]})}function hJ({model:e,task:t,remoteHost:n,narrow:r=!1}){let i=v(un),a=v(Ua);return!r&&(i||!a)?null:t?(0,V.jsx)(mJ,{model:e,task:t,narrow:r},t.id):n?(0,V.jsx)(`aside`,{className:uI(!1),children:(0,V.jsx)(hE,{host:n,onMachines:()=>vO(e)})}):null}var gJ=1500;function _J({model:e}){let t=e.client,n=v(t.conn),[r,i]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{if(n.state!==`connecting`)return i(!1);let e=window.setTimeout(()=>i(!0),gJ);return()=>window.clearTimeout(e)},[n.state]),n.state===`open`||n.state===`connecting`&&!r?null:(0,V.jsxs)(`footer`,{className:Nt,children:[(0,V.jsx)(`span`,{className:Pt(n.state===`retrying`)}),(0,V.jsx)(`span`,{children:n.state===`retrying`?z(`status.retrying`,{count:n.failures}):z(`status.connecting`)}),n.state===`retrying`&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>t.retryNow(),children:z(`status.retry`)})]})}function vJ({model:e,taskId:t,groupId:n}){B();let r=v(e.tasks),i=r?YI(r.tasks,n):[];return i.length<2||!i.some(e=>e.id===t)?null:(0,V.jsxs)(`nav`,{className:jL,"aria-label":z(`compare.menu`),children:[i.map((n,r)=>(0,V.jsxs)(H,{variant:`pill`,hit:`tight`,"aria-current":n.id===t,onClick:()=>e.select(n.id),children:[`[ `,(0,V.jsx)(QL,{status:n.rowStatus}),r+1,` `,n.engine?.name??n.label,n.kept&&(0,V.jsx)(`span`,{className:`text-accent`,children:`✓`}),` ]`]},n.id)),(0,V.jsx)(H,{hit:`tight`,className:`ml-auto flex-none whitespace-nowrap`,onClick:()=>ga(n),children:z(`compare.strip`)})]})}var yJ=new Set,bJ=2e3;function xJ(e){yJ.add(e)}function SJ(e,t=bJ){setTimeout(()=>yJ.delete(e),t)}var CJ=e=>yJ.has(e),wJ=new Map,TJ=new Set,EJ=(e,t)=>`${e}/${t}`,DJ=e=>wJ.get(e)??``;function OJ(e,t){t===``?wJ.delete(e):wJ.set(e,t);for(let e of TJ)e()}function kJ(e){return TJ.add(e),()=>TJ.delete(e)}function AJ(e,t){let n=DJ(e).trimEnd();OJ(e,n===``?t:`${n}\n\n${t}`)}var jJ=3e3,MJ=32;function NJ(e){let{model:t,taskId:n,tabId:r,revision:i}=e,[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(0);if((0,g.useEffect)(()=>{let e=!0,i=()=>t.client.request(`queue.list`,{taskId:n}).then(t=>e&&o(t.items.filter(e=>e.tabId===r)),()=>e&&o([]));i();let a=window.setInterval(i,jJ);return()=>{e=!1,window.clearInterval(a)}},[t,n,r,i,s]),a.length===0)return null;let l=e=>void t.client.request(`queue.cancel`,{id:e}).finally(()=>c(e=>e+1));return(0,V.jsx)(`div`,{className:En,"data-field":`queued`,children:a.map(e=>(0,V.jsxs)(`span`,{className:Dn(!1),title:e.text,children:[`${z(`layout.queuedChip`)} · ${e.text.length>MJ?`${e.text.slice(0,MJ)}…`:e.text} `,(0,V.jsx)(H,{hit:`tight`,"aria-label":z(`layout.queueCancel`),title:z(`layout.queueCancel`),onClick:()=>l(e.id),children:`×`})]},e.id))})}var PJ=`relative hidden [border-top:var(--hairline)_solid_var(--line)] bg-surface px-1.5 py-1.5 touch:flex`,FJ=`absolute inset-x-1.5 bottom-full z-5 mb-1`,IJ=`absolute inset-x-1.5 bottom-full z-6 mb-1`,LJ=`flex min-w-0 flex-1 items-stretch gap-1.5`,RJ=`h-10 min-w-0 flex-1 resize-none rounded-sm border-hairline border-line bg-inset px-2 py-2 font-sans text-display leading-[1.35] text-ink outline-none focus:border-focus disabled:opacity-60`,zJ=`h-10 shrink-0 rounded-sm bg-accent px-3.5 font-sans text-meta font-semibold text-paper touch-manipulation active:scale-97 motion-reduce:active:scale-none disabled:opacity-50`,BJ=`flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-sm border-hairline border-line bg-inset text-muted touch-manipulation has-[:disabled]:opacity-60`;function VJ(){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,className:`size-4 fill-none stroke-current stroke-[1.4]`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M10.5 4.5 5.8 9.2a1.4 1.4 0 0 0 2 2l5-5a2.8 2.8 0 0 0-4-4l-5.2 5.2a4.2 4.2 0 0 0 6 6L13 9`})})}function HJ(e){return(0,V.jsxs)(`form`,{className:PJ,"data-composer":e.composerKey,onSubmit:t=>{t.preventDefault(),e.onSend()},children:[e.attached&&(0,V.jsx)(`div`,{className:FJ,children:e.attached}),e.suggest&&(0,V.jsx)(`div`,{className:IJ,children:e.suggest}),(0,V.jsxs)(`div`,{className:LJ,children:[e.attach,(0,V.jsx)(`textarea`,{ref:e.fieldRef,className:RJ,rows:1,value:e.value,placeholder:e.placeholder,disabled:e.busy,enterKeyHint:`send`,onChange:e.onChange,onSelect:e.onSelect,onKeyDown:e.onKeyDown,onPaste:e.onPaste}),(0,V.jsx)(`button`,{type:`submit`,className:zJ,disabled:e.busy||!e.ready,children:e.sendLabel})]})]})}function UJ({model:e,taskId:t,tabId:n}){let r=v(e.tasks)?.tasks.some(e=>e.id===t)??!1,i=EJ(t,n),a=(0,g.useSyncExternalStore)(kJ,()=>DJ(i)),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(0),{attachments:u,attach:d,remove:f,clear:p}=Uo(e,e=>G(e,`error`)),m=(0,g.useRef)(null),h=GD({value:a,onChange:e=>OJ(i,e),area:m,listClassName:`m-0`}),_=async()=>{let r=Vo(a.trim(),u).trim();if(r){s(!0);try{let a=await e.client.request(`tab.send`,{taskId:t,tabId:n,prompt:r,queue:!0});if(!a.delivered&&!a.queued){G(z(`layout.composerNotSent`,{reason:a.reason??``}),`error`);return}a.queued&&(G(z(`layout.composerQueued`,{position:a.position??1})),l(e=>e+1)),OJ(i,``),p()}catch(e){let t=e instanceof r_?e.code:void 0;G(t===`UNKNOWN_OP`?z(`layout.composerOldBridge`):t===`AWAITING_PERMISSION`?z(`layout.composerAtMenu`):e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}}};if(!r)return null;let y=e=>void d(e);return(0,V.jsx)(HJ,{value:a,placeholder:z(`layout.composerPlaceholder`),sendLabel:z(`layout.composerSend`),busy:o,ready:a.trim()!==``||u.length>0,attached:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(NJ,{model:e,taskId:t,tabId:n,revision:c}),(0,V.jsx)(Wo,{attachments:u,onRemove:f})]}),attach:(0,V.jsxs)(Bo,{className:BJ,title:z(`layout.composerAttach`),disabled:o,onFiles:y,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:z(`layout.composerAttach`)}),(0,V.jsx)(VJ,{})]}),composerKey:i,fieldRef:m,suggest:h.list,...h.field,onPaste:zo(y).onPaste,onSend:()=>void _()})}var WJ={up:`layout.termKeyUp`,down:`layout.termKeyDown`,left:`layout.termKeyLeft`,right:`layout.termKeyRight`,interrupt:`layout.termKeyInterrupt`,enter:`layout.termKeyEnter`};function GJ({handle:e,atMenu:t}){B();let[n,r]=(0,g.useState)(!1);(0,g.useEffect)(()=>{e.armCtrl(n?()=>r(!1):null)},[e,n]),(0,g.useEffect)(()=>()=>e.armCtrl(null),[e]);let{term:i}=e,a=e=>(0,V.jsx)(`button`,{type:`button`,className:et(!1),"aria-label":WJ[e.id]?z(WJ[e.id]):void 0,onClick:()=>{r(!1),i.input(e.bytes(i.modes.applicationCursorKeysMode),!0)},children:e.cap},e.id);return(0,V.jsxs)(`div`,{className:`mono ${$e}`,role:`toolbar`,"aria-label":z(`layout.termKeys`),onPointerDown:e=>e.preventDefault(),children:[t&&yv.map(a),(0,V.jsx)(`button`,{type:`button`,className:et(n),"aria-pressed":n,onClick:()=>r(!n),children:`ctrl`}),_v.filter(e=>!(t&&yv.includes(e))).map(a)]})}function KJ(e){switch(e.kind){case`restored`:return z(`workspace.restored`);case`notLive`:return z(`workspace.tabNotLive`);case`exited`:return z(`workspace.exited`,{code:e.code??`?`});case`failed`:return z(`workspace.attachFailed`,{message:e.message});case`none`:return``}}function qJ(e){B();let{notice:t,engineExit:n,model:r,taskId:i,tabId:a,revive:o}=e,s=t.kind===`none`?n:null,c=t.kind===`none`&&!s&&e.usageLimit===!0&&!o.error;if(t.kind===`none`&&!s&&!c)return null;let l=t.kind===`notLive`||t.kind===`restored`||t.kind===`exited`,u=t.kind===`exited`||s!==null,d=o.error?z(`workspace.reopenFailed`,{message:o.error}):s?z(`workspace.engineExited`,{code:s.code??`?`}):c?z(`workspace.usageLimit`):KJ(t);return(0,V.jsxs)(`div`,{className:Mt(t.kind===`failed`||!!o.error),children:[(0,V.jsx)(`span`,{children:d}),e.onReopen&&(l||s)&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,disabled:o.busy,onClick:()=>e.onReopen?.(s!==null),children:o.busy?z(`workspace.reopening`):z(s?`workspace.retry`:`workspace.reopen`)}),t.kind===`failed`&&e.onRetryAttach&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:e.onRetryAttach,children:z(`workspace.retry`)}),c&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i,context:`continue`,sourceTabId:a})),children:z(`menu.continueEngine`)}),(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:e.onDismissLimit,children:z(`workspace.dismiss`)})]}),u&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>W.set((0,V.jsx)(FP,{model:r,section:`engines`})),children:z(`workspace.engineSettings`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i})),children:z(`menu.newChatPick`)}),(0,V.jsx)(H,{variant:`link`,hit:`tight`,onClick:()=>W.set((0,V.jsx)(RC,{model:r,taskId:i,context:`continue`,sourceTabId:a})),children:z(`menu.continueEngine`)})]})]})}function JJ(e){let t=e.split(`
150
150
  `).map(e=>e.trimEnd());for(;t[0]===``;)t.shift();for(;t.at(-1)===``;)t.pop();if(t.length===0)return null;let n=Math.max(0,...Array.from(t.join(`
151
151
  `).matchAll(/`+/g),e=>e[0].length)),r="`".repeat(Math.max(3,n+1));return`${r}\n${t.join(`
152
- `)}\n${r}\n`}function qJ(e){let t=document.querySelector(`[data-composer="${CSS.escape(e)}"]`);return t&&t.offsetParent!==null?t:null}function JJ(e,t,n,r){let i=KJ(e.term.getSelection());if(i===null)return!1;let a=wJ(t,n),o=qJ(a);if(o){OJ(a,i),e.term.clearSelection();let t=o.querySelector(`textarea`);return t?.focus(),t?.setSelectionRange(t.value.length,t.value.length),!0}return r?(G(z(`quote.atMenu`),`error`),!1):e.term.modes.bracketedPasteMode?(e.term.paste(i),e.term.clearSelection(),e.term.focus(),!0):(G(z(`quote.notReady`),`error`),!1)}async function YJ(e,t,n){let r=kR(n);r.length<n.length&&G(z(`layout.dropUnsupported`),`error`);for(let n of r)try{t.term.paste(`${await jR(e,n)} `)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}t.term.focus()}async function XJ(){if(!navigator.clipboard?.read)throw Error(z(`layout.pasteNeedsHttps`));let e=[];for(let t of await navigator.clipboard.read())for(let n of t.types)(n.startsWith(`image/`)||n===`application/pdf`)&&e.push(new File([await t.getType(n)],`clipboard`,{type:n}));return kR(e)}async function ZJ(e,t){let n;try{n=await XJ()}catch(e){G(z(`layout.pasteNoAccess`,{error:e instanceof Error?e.message:String(e)}),`error`);return}n.length===0?G(z(`layout.pasteNoImage`),`error`):await YJ(e,t,n)}async function QJ(e){try{return await navigator.clipboard.writeText(e),!0}catch{return G(z(`menu.copyFailed`),`error`),!1}}function $J(e){let{client:t,taskId:n,tabId:r,leafId:i}=e,a=v(e.model.tasks)?.tasks.find(e=>e.id===n)?.tabStatus?.[r]?.kind===`needs-input`;B();let o=(0,g.useRef)(null),[s,c]=(0,g.useState)({kind:`none`}),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(0),[p,m]=(0,g.useState)({busy:!1,error:null}),h=(0,g.useRef)(e);h.current=e,(0,g.useEffect)(()=>{let e=o.current;if(!e)return;let a=null,s=!1,l=[document.fonts.load(`13px "JetBrains Mono"`),document.fonts.load(`bold 13px "JetBrains Mono"`)];document.fonts.load(`13px "${L_}"`,String.fromCodePoint(57504)).catch(()=>{});let d=()=>{s||(a=lT({client:t,host:e,taskId:n,tabId:r,leafId:i,focusOnMount:h.current.focused!==!1},{setNotice:c,onScrolled:f,onFocusChange:e=>{if(!a)return;let{stream:t}=a.handle;e?(h.current.onActivate?.(),na.set(ia(t)??null)):na.get()?.stream===t&&na.set(null)},onExit:()=>{xJ(yC(n,r,i))||h.current.onExit?.()},copyText:QJ,pasteImage:async()=>{a&&await ZJ(t,a.handle)}}),u(a.handle))};return cT(t,n,r,i)?d():Promise.allSettled(l).then(d),()=>{s=!0,u(null),a?.release()}},[t,n,r,i]);let[_,y]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!l)return;y(l.term.hasSelection());let e=l.term.onSelectionChange(()=>y(l.term.hasSelection()));return()=>{e.dispose(),y(!1)}},[l]),(0,g.useEffect)(()=>{if(!l)return;let{term:e,stream:a}=l,o={stream:a,focus:()=>e.focus(),input:t=>e.input(t,!0),reattach:()=>l.reattach(),scrollPages:e=>l.scrollLines(e*10),hasSelection:()=>e.hasSelection(),copySelection:()=>{let t=e.getSelection();return t.trim().length!==0&&(QJ(t),e.clearSelection(),!0)},reset:()=>{let o={cols:e.cols,rows:e.rows};W.set((0,V.jsx)(sr,{title:yo(`reset.title`),body:yo(`reset.body`),confirmLabel:z(`workspace.reset`),onConfirm:async()=>{yJ(a);try{await t.request(`tab.split`,{taskId:n,tabId:r,action:`reset`,leafId:i??`leaf-1`,...o}),await l.reattach(),e.focus()}finally{bJ(a)}}}))},size:()=>({cols:e.cols,rows:e.rows})},s=ra(o);return document.activeElement===e.textarea&&na.set(o),()=>{s()}},[l,t,n,r,i]),(0,g.useEffect)(()=>{e.focused&&l&&document.activeElement!==l.term.textarea&&l.term.focus()},[e.focused,l]);let b=!i||i===`leaf-1`,[x,S]=(0,g.useState)(null),C=e.engineExit?.since===x,[w,T]=(0,g.useState)(null),E=e.usageLimit&&e.usageLimit.since!==w?e.usageLimit:null,D=(0,g.useRef)(!1),O=async(i,a)=>{if(!D.current){D.current=!0,m({busy:!0,error:null});try{await t.request(`term.revive`,{taskId:n,tabId:r,...a?{restartExited:a}:{}}),await i.reattach(),i.term.focus(),S(e.engineExit?.since??null),m({busy:!1,error:null})}catch(e){m({busy:!1,error:e instanceof Error?e.message:String(e)})}finally{D.current=!1}}};return(0,V.jsxs)(`div`,{className:Et,"data-stream":yC(n,r,i),onDragOver:e=>e.dataTransfer.types.includes(`Files`)&&e.preventDefault(),onDrop:e=>{!e.dataTransfer.files.length||!l||(e.preventDefault(),YJ(t,l,Array.from(e.dataTransfer.files)))},onPasteCapture:e=>{if(!l)return;let n=kR(e.clipboardData.files);(n.length!==0||e.clipboardData.getData(`text/plain`)===``)&&(e.preventDefault(),e.stopPropagation(),n.length>0?YJ(t,l,n):ZJ(t,l))},children:[(0,V.jsxs)(`div`,{className:Dt,children:[(0,V.jsx)(`div`,{className:Ot,ref:o}),(0,V.jsx)(GJ,{notice:s,engineExit:C?null:e.engineExit??null,model:e.model,taskId:n,tabId:r,revive:p,onReopen:b&&l?e=>void O(l,e):void 0,onRetryAttach:l?()=>void l.reattach():void 0,usageLimit:E!==null,onDismissLimit:E?()=>T(E.since):void 0}),_&&e.composer&&l&&(0,V.jsx)(H,{variant:`floating`,className:`absolute top-2.5 right-2.5 z-4`,title:z(`quote.title`),onClick:()=>JJ(l,n,r,a),children:z(`quote.action`)}),d>0&&l&&(0,V.jsxs)(`div`,{className:`mono absolute right-2.5 bottom-2.5 z-4 flex gap-3 rounded-sm border-hairline border-line bg-inset px-2.5 py-1 text-meta`,children:[(0,V.jsx)(`span`,{className:`text-warning`,children:yo(`scrolledBack`,{lines:d})}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>l.scrollToTop(),children:yo(`scrollFirst`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>l.scrollToBottom(),children:yo(`scrollLatest`)})]})]}),e.composer&&(0,V.jsx)(VJ,{model:e.model,taskId:n,tabId:r}),l&&(0,V.jsx)(UJ,{handle:l,atMenu:a})]})}var eY=e=>IH(e)!==null,tY=e=>bw(IH(e)?.tab.split);function nY(e){let t=IH(e),n=t?.tab.split;return t&&n?{...t,split:n,leaf:NH(t.taskId,t.tab,n)}:null}qi(()=>[{id:`workspace.split.right`,chords:[`ctrl+\\`],prefix:!1,surface:`workspace`,live:eY,run:e=>{let t=IH(e);t&&RH(e,t.taskId,t.tab,`right`)}},{id:`workspace.split.down`,chords:[`ctrl+=`],prefix:!1,surface:`workspace`,live:eY,run:e=>{let t=IH(e);t&&RH(e,t.taskId,t.tab,`down`)}},{id:`workspace.split.focus-next`,chords:[`f3`],prefix:!1,surface:`workspace`,live:tY,run:e=>{let t=nY(e);t&&FH(t.taskId,t.tab,t.split,Sw(t.split,t.leaf))}},{id:`workspace.split.close`,chords:[`w`],prefix:!0,surface:`workspace`,live:tY,run:e=>{let t=nY(e);t&&zH(e,t.taskId,t.tab,t.leaf)}},{id:`workspace.split.rename`,chords:[`f2`],prefix:!1,surface:`workspace`,live:tY,run:e=>{let t=nY(e);t&&BH(e,t.taskId,t.tab,t.leaf)}}]);var rY=[{id:`leaf-1`,x:0,y:0,w:1,h:1,left:!1,top:!1}];function iY({model:e,taskId:t,tab:n}){let r=n.split;v(MH);let i=r?NH(t,n,r):`leaf-1`,a=r?Cw(r,_w(n)):new Map,o=bw(r),{prefs:s}=A_(),c=v(e.tasks)?.tasks.find(e=>e.id===t)?.tabStatus?.[n.id]??n.status,l=n.kind===`engine`&&c?.reason===`dead`?c.since:null;(0,g.useEffect)(()=>{l!==null&&e.refreshTabsNow()},[l,e]);let u=l!==null&&n.alive!==!1?{code:n.exit?.code??null,since:l}:null,d=n.kind===`engine`&&c?.reason===`rate_limited`?{since:c.since}:null;return(0,V.jsx)(`div`,{className:Je,children:(r?xw(r.root):rY).map(c=>(0,V.jsxs)(`div`,{className:Ze(o?s.splitStyle:null,{left:c.left,top:c.top,active:c.id===i}),style:{left:`calc(${c.x*100}% + var(--ml, 0px))`,top:`calc(${c.y*100}% + var(--mt, 0px))`,width:`calc(${c.w*100}% - var(--ml, 0px))`,height:`calc(${c.h*100}% - var(--mt, 0px))`},children:[(0,V.jsx)($J,{client:e.client,model:e,engineExit:c.id===`leaf-1`?u:null,usageLimit:c.id===`leaf-1`?d:null,composer:n.kind===`engine`&&c.id===`leaf-1`,taskId:t,tabId:n.id,leafId:c.id,focused:c.id===i,onActivate:()=>r&&PH(t,n.id,r,c.id),onExit:()=>{o?LH(e,{taskId:t,tabId:n.id,action:`close`,leafId:c.id}):n.kind!==`engine`&&e.client.request(`tab.close`,{taskId:t,tabId:n.id}).then(()=>e.refreshTabsNow()).catch(()=>{})}}),o&&(0,V.jsx)(`span`,{className:Qe(s.splitStyle===`rule`,c.id===i),onContextMenu:r=>JU(r,UH(e,t,n,c.id)),children:a.get(c.id)})]},c.id))})}var aY=/^[0-9a-f]{7,40}$/i;function oY(e,t){return t.sharesWorkspaceOf||!t.baseRef?null:e.find(e=>e.id!==t.id&&e.branch!==``&&e.branch===t.baseRef)||(aY.test(t.baseRef)&&t.parentTaskId?e.find(e=>e.id===t.parentTaskId)??null:null)}function sY(e,t){let n=[];for(let r=oY(e,t);r&&n.length<20&&!n.includes(r);r=oY(e,r))n.unshift(r);let r=e.filter(n=>!n.deleting&&oY(e,n)?.id===t.id).sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``));if(n.length===0&&r.length===0)return null;let i=n[0]??t,a=i.baseRef&&!aY.test(i.baseRef)?i.baseRef:null;return{nodes:[...n,t,...r],at:n.length,base:a}}var cY=e=>e.pr?.lifecycle===`merged`;function lY(e){return e.nodes.find(e=>!cY(e))??null}function uY({model:e,taskId:t}){B();let n=v(e.tasks)?.tasks??[],r=n.find(e=>e.id===t),i=r?sY(n,r):null;if(!i)return null;let a=lY(i);return(0,V.jsxs)(`nav`,{className:kL,"aria-label":z(`compare.stackLabel`),children:[i.base&&(0,V.jsxs)(`span`,{className:`text-subtle`,children:[i.base,` ←`]}),i.nodes.map((n,r)=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-x-3.5`,children:[r>0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`←`}),(0,V.jsxs)(H,{variant:`pill`,hit:`tight`,"aria-current":n.id===t,onClick:()=>e.select(n.id),children:[`[ `,(0,V.jsx)(XL,{status:n.rowStatus}),n.label||n.title,cY(n)?(0,V.jsx)(`span`,{className:`text-accent`,children:`✓`}):n.pr?.number?(0,V.jsx)(`span`,{children:`PR`}):null,` ]`]})]},n.id)),a&&!a.machine&&(0,V.jsx)(H,{hit:`tight`,className:`ml-auto flex-none whitespace-nowrap`,onClick:()=>void HP(e,a),children:z(`compare.landBottom`)})]})}function dY(e,t){return e===`never`?!1:e!==`multipleOnly`||t>=2}function fY({taskId:e}){B();let t=Lk(e),n=v(Ua),r=v(un),i=n&&!r?lk(t):null;return(0,V.jsx)(`div`,{className:gI,children:Ra.map(t=>(0,V.jsx)(`button`,{type:`button`,className:aI({on:i===t}),title:z(`panel.${t}`),"aria-label":z(`panel.${t}`),"aria-pressed":i===t,onClick:()=>Bk(e,t),children:(0,V.jsx)(uG,{children:dG[t]})},t))})}function pY({model:e,task:t,tabs:n,narrow:r}){let i=v(e.selection),{prefs:a}=A_(),o=!dY(a.tabStrip,n.length);return(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 font-mono text-meta/body transition-padding-left duration-220 ease-snap motion-reduce:transition-none rail-folded:min-h-6.5 rail-folded:pl-23`,role:`tablist`,children:[n.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===i.tabId,className:`group/tab flex items-center gap-1.5 whitespace-nowrap rounded-sm px-2.5 py-1 active:scale-97 motion-reduce:active:scale-none touch:select-none touch:touch-callout-none ${o?`hidden`:``} ${n.id===i.tabId?`bg-inset text-ink`:`text-muted hover:bg-hover data-menu-open:bg-hover`}`,onClick:()=>e.select(t.id,n.id),onContextMenu:r=>JU(r,oU(e,t,n)),children:[(0,V.jsx)(`span`,{className:`text-subtle group-aria-selected/tab:text-accent`,children:r+1}),_w(n)]},n.id)),!r&&(0,V.jsx)(fY,{taskId:t.id})]})}function mY(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??e))}function hY({model:e}){let t=B()===`zh`?Fr:Pr,n=e.client,[r,i]=(0,g.useState)(()=>(Ns(n,`worktrees.list`,{network:!0})??Ns(n,`worktrees.list`,{network:!1}))?.projects??null),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0,t=!1,r=r=>Fs(n,`worktrees.list`,{network:r}).then(n=>{if(!(!e||!r&&t)&&(r&&(t=!0),i(n.projects),r)){let e=new Set(n.projects.flatMap(e=>e.worktrees.map(e=>e.path)));o(t=>t.filter(t=>e.has(t)))}}).catch(()=>{});return r(!1),r(!0),()=>{e=!1}},[n,l]),(0,g.useEffect)(()=>d.current?.focus(),[]);let f=(r??[]).map(e=>({...e,worktrees:e.worktrees.filter(e=>!a.includes(e.path))})),p=f.flatMap(e=>e.worktrees),m=Math.min(s,Math.max(0,p.length-1));(0,g.useEffect)(()=>{d.current?.querySelector(`[data-row="${m}"]`)?.scrollIntoView({block:`nearest`})},[m]);let h=(0,g.useCallback)(()=>u(e=>e+1),[]),_=async(e,r)=>{o(t=>[...t,e.path]);try{let i=await n.request(`worktrees.remove`,{path:e.path,force:r});i.residue&&G(mY(t.delete.residue,i.residue)),h()}catch(n){o(t=>t.filter(t=>t!==e.path));let i=n&&typeof n==`object`&&`code`in n?n.code:null;if(!r&&i===`DIRTY_WORKTREE`){W.set((0,V.jsx)(sr,{title:t.delete.forceTitle,body:`${mY(t.delete.forceBody,{branch:e.branch||e.path})}\n\n${mY(t.delete.forceReason,{reason:K(n)})}`,confirmLabel:t.delete.button,onConfirm:()=>_(e,!0)}));return}G(mY(t.delete.failed,{error:K(n)}),`error`)}},v=e=>W.set((0,V.jsx)(sr,{title:t.delete.confirmTitle,body:mY(t.delete.confirmBody,{branch:e.branch||e.path}),confirmLabel:t.delete.button,onConfirm:async()=>{_(e,!1)}})),y=n=>{if(!n.taskId){G(t.land.noTask,`error`);return}HP(e,{id:n.taskId,title:n.branch,branch:n.branch},h)},b=e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`&&!window.getSelection()?.toString())return e.preventDefault(),on.set(null);if(e.metaKey||e.ctrlKey||e.altKey)return;let t=p[m];if(e.key===`j`||e.key===`ArrowDown`)c(Math.min(p.length-1,m+1));else if(e.key===`k`||e.key===`ArrowUp`)c(Math.max(0,m-1));else if(e.key===`d`&&t)v(t);else if(e.key===`l`&&t)y(t);else if(e.key===`q`||e.key===`Escape`)on.set(null);else return;e.preventDefault()},x=0;return(0,V.jsxs)(`div`,{className:aM,tabIndex:0,ref:d,onKeyDown:b,children:[(0,V.jsx)(`h1`,{className:oM,children:t.title}),r===null?(0,V.jsx)(`p`,{className:`text-muted`,children:t.loading}):f.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.noProjects}):f.map(e=>{let n=x;return x+=e.worktrees.length,(0,V.jsxs)(`section`,{className:Kj,children:[(0,V.jsxs)(`h2`,{className:`mt-1.5 mr-2 mb-1 ml-0 flex items-center gap-1 font-mono text-meta font-semibold normal-nums text-subtle`,children:[(0,V.jsx)(`span`,{children:e.repo}),(0,V.jsx)(`span`,{className:`rule`})]}),e.worktrees.length===0&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:t.noWorktrees}),e.worktrees.map((e,r)=>{let i=n+r;return(0,V.jsxs)(`div`,{"data-row":i,className:qj(i===m),onClick:()=>c(i),children:[(0,V.jsxs)(`div`,{className:Jj,children:[(0,V.jsx)(`span`,{className:Xj,children:e.branch||t.row.detached}),e.roveManaged&&(0,V.jsx)(`span`,{className:`chip text-muted`,children:t.badge.roveManaged}),e.dirty===!0&&(0,V.jsx)(`span`,{className:`chip text-warning`,children:t.badge.dirty}),e.dirty===null&&(0,V.jsx)(`span`,{className:`chip text-muted`,children:t.badge.dirtyUnknown}),(0,V.jsx)(`span`,{className:`chip ${e.branchOnRemote===!0?`text-success`:e.branchOnRemote===!1?`text-warning`:`text-muted`}`,children:e.branchOnRemote===!0?t.badge.remoteOn:e.branchOnRemote===!1?t.badge.remoteOff:t.badge.remoteUnknown}),e.verdictReason!==`dirty`&&e.verdictReason!==`fresh`&&(0,V.jsx)(`span`,{className:`chip ${e.verdict===`merged`?`text-success`:e.verdict===`stale`?`text-warning`:`text-accent`}`,children:t.verdict[e.verdictReason]??e.verdictReason})]}),(0,V.jsxs)(`div`,{className:`${Yj} mono text-muted`,children:[(0,V.jsx)(`span`,{className:Zj,children:e.path}),e.createdAtMs>0&&(0,V.jsx)(`span`,{children:mY(t.row.created,{age:Mo(Date.now()-e.createdAtMs)})})]}),i===m&&(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[length:var(--fs-body)]`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>v(e),children:t.delete.button}),e.taskId&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>y(e),children:t.land.button})]})]},e.path)})]},e.repo)}),(0,V.jsx)(`p`,{className:`${Qj} mono keys-only text-muted`,children:(0,V.jsx)(ST,{text:`j/k · d ${t.delete.button} · l ${t.land.button} · q/esc`})})]})}function gY({model:e,narrow:t}){let n=v(e.selection),r=v(e.tabs),i=v(e.tasks),a=v(e.remote),o=a.find(e=>e.id===n.taskId&&!e.machine?.stale),s=Pi(i,n.taskId)??o??null,c=o?void 0:a.find(e=>e.id===n.taskId),l=s?r[s.id]??[]:[],u=s?s.id in r:!1,d=v(on),f=XM(s?.id),p=s?.rowStatus?.kind===`running`,m=v(dn),h=v(za)!==`terminal`&&t&&!!s;return(0,g.useEffect)(()=>{let t=e.selection.get();return e.selection.subscribe(()=>{dn.set(null);let n=e.selection.get();(n.taskId!==t.taskId||n.tabId!==t.tabId)&&za.set(`terminal`),t=n})},[e]),(0,g.useEffect)(()=>FF(e),[e]),d===`update`?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(AI,{}),(0,V.jsx)(OM,{client:e.client})]}):d===`worktrees`?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(AI,{}),(0,V.jsx)(hY,{model:e})]}):d?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(AI,{}),(0,V.jsx)(dH,{model:e,page:d})]}):m?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(AI,{}),(0,V.jsx)(`div`,{className:wt,children:(0,V.jsx)(XD,{model:e,seed:m},`${m.machine??``}\0${m.repo??``}\0${m.ungrouped?`u`:``}\0${m.retryOf?.id??``}`)})]}):(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(AI,{taskId:s?.id}),s&&(0,V.jsx)(pY,{model:e,task:s,tabs:l,narrow:t}),s&&!s.groupId&&(0,V.jsx)(uY,{model:e,taskId:s.id}),s?.groupId&&(0,V.jsx)(gJ,{model:e,taskId:s.id,groupId:s.groupId}),(0,V.jsxs)(`div`,{className:`${wt} ${p?Tt:``}`,style:f?{"--task-ink":f}:void 0,children:[!t&&!s&&!c&&i&&i.tasks.length+a.length===0&&(0,V.jsx)(qU,{model:e}),!s&&!c&&i&&i.tasks.length+a.length>0&&(0,V.jsx)(`p`,{className:xt,children:z(`workspace.pickTask`)}),c?.machine&&(0,V.jsx)(`div`,{className:St,children:(0,V.jsx)(hE,{host:c.machine.label,onMachines:()=>vO(e)})}),s&&u&&l.length===0&&!h&&(0,V.jsxs)(`div`,{className:St,children:[(0,V.jsx)(`p`,{children:z(`workspace.noTabs`)}),(0,V.jsx)(H,{variant:`filled`,onClick:()=>void NC(e,s.id,{kind:`engine`}).catch(e=>G(String(e),`error`)),children:s.engine?z(`workspace.startEngine`,{engine:s.engine.name}):z(`workspace.startSession`)}),` `,(0,V.jsx)(H,{variant:`filled`,onClick:()=>void MC(e,s.id),children:z(`menu.newChat`)}),` `,(0,V.jsx)(H,{variant:`filled`,onClick:()=>W.set((0,V.jsx)(RC,{model:e,taskId:s.id})),children:z(`menu.newChatPick`)})]}),s&&h&&(0,V.jsx)(pJ,{model:e,task:s,narrow:!0}),s&&n.tabId&&l.some(e=>e.id===n.tabId)&&(0,V.jsx)(`div`,{className:`min-w-0 flex-1 ${h?`hidden`:`flex`}`,children:(0,V.jsx)(iY,{model:e,taskId:s.id,tab:l.find(e=>e.id===n.tabId)??l[0]},`${s.id}::${n.tabId}`)})]})]})}function _Y({model:e}){B();let t=v(e.client.conn);return t.hello===null&&t.failures>=2?(0,V.jsx)(vY,{}):(0,V.jsx)(yY,{model:e})}function vY(){let[e,t]=(0,g.useState)(null);return(0,g.useEffect)(()=>{Da().then(t)},[]),e===null?null:e?(0,V.jsx)(ja,{}):(0,V.jsx)(en,{failing:!0})}function yY({model:e}){fF(e);let t=v(e.client.conn).hello;(0,g.useEffect)(()=>{t&&(EM(e.client),MM(e.client,t.roveVersion))},[t,e.client]),zw(e),Iw(e),la(),Xr(e.client),xF(e),li(e.client),bN(e.client),(0,g.useEffect)(()=>{e.onSelect=pa;let t=dn.subscribe(()=>{dn.get()!==null&&pa()});return mn(),t},[e]),(0,g.useEffect)(()=>ZN(e),[e]);let n=v(un),r=v(e.selection),i=v(e.tasks),a=v(e.remote),o=xa(),s=v($F),c=v(eI),l=v(QF),u=v(fa),d=v(Ha),f=v(Ua),p=v(Wa),m=v(on),h=v(bn)===`drag`,_=v(dn)!==null,y=a.find(e=>e.id===r.taskId&&!e.machine?.stale),b=Pi(i,r.taskId)??y??null,x=y?void 0:a.find(e=>e.id===r.taskId),S=o?Sa(u,!!b||!!x,m!==null||_):null;(0,g.useEffect)(()=>e.setTaskShown(S===null||S===`content`&&m===null&&!_),[e,S,m,_]);let C=rI(l??280),w={"--rail-w":`${s?0:C}px`,"--rail-open-w":`${C}px`,"--panel-w":d===null?void 0:`${Ga(d,s?0:C)}px`};return(0,V.jsxs)(`div`,{className:Le,children:[(0,V.jsx)(di,{onRefresh:()=>ui(e.client)}),(0,V.jsxs)(`div`,{className:Re({zen:n||!f||!b&&!x||o,expanded:p&&!n&&!o,surface:S,folded:s&&!o,peek:s&&c&&!o,dragging:h}),style:o?void 0:w,children:[!o&&(0,V.jsx)(OI,{model:e}),s&&!o&&(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-5 col-1 row-1 w-2.5`,onMouseEnter:()=>nI(!0),onMouseLeave:()=>nI(!1)}),(0,V.jsx)(YU,{model:e,narrow:o}),(0,V.jsx)(gY,{model:e,narrow:o}),!o&&(0,V.jsx)(pJ,{model:e,task:b,remoteHost:x?.machine?.label}),(0,V.jsx)(hJ,{model:e}),(0,V.jsx)(La,{}),(0,V.jsx)(_F,{model:e}),(0,V.jsx)(Ri,{model:e})]})]})}var bY=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function xY(e){return[...e.querySelectorAll(bY)].filter(e=>e.tabIndex>=0&&e.offsetParent!==null)}function SY(){window.addEventListener(`keydown`,e=>{if(e.key!==`Tab`||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey)return;let t=[...document.querySelectorAll(`.overlay:not(.is-leaving)`)].at(-1);if(!t)return;let n=xY(t);if(n.length===0)return;let r=document.activeElement,i=r instanceof HTMLElement&&t.contains(r),a=e.shiftKey?n.filter(e=>i&&!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)).at(-1)??n.at(-1):n.find(e=>i&&!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))??n[0];e.preventDefault(),a?.focus()})}function CY(e){if(!_n())for(let t of document.querySelectorAll(`${e}:not(.is-leaving)`)){let e=t.cloneNode(!0);e.classList.add(`is-leaving`),e.inert=!0,e.setAttribute(`aria-hidden`,`true`),document.body.append(e);let n=t.querySelectorAll(`*`),r=e.querySelectorAll(`*`);n.forEach((e,t)=>{let n=r[t];e.scrollTop&&(n.scrollTop=e.scrollTop),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(n.value=e.value)}),window.setTimeout(()=>e.remove(),200)}}function wY(e){for(let t of document.querySelectorAll(`${e}.is-leaving`))t.remove()}function TY(){for(let e of document.querySelectorAll(`.overlay:not(.is-leaving)`))for(let t of e.getAnimations())t instanceof CSSAnimation&&t.animationName===`fade-in`&&t.finish()}function EY(){let e=W.get(),t=-1/0;W.subscribe(()=>{let n=W.get();if(n===null&&e!==null)t=performance.now(),CY(`.overlay`);else if(n!==null){let n=e!==null||performance.now()-t<140;wY(`.overlay`),n&&requestAnimationFrame(TY)}e=n});let n=nn.get();nn.subscribe(()=>{let e=nn.get();e===null&&n!==null?CY(`.menu`):e!==null&&wY(`.menu`),n=e});let r=Jw.get().guide;Jw.subscribe(()=>{let e=Jw.get().guide;e===null&&r!==null?CY(`.prefix-guide`):e!==null&&wY(`.prefix-guide`),r=e})}var DY=500,OY=10,kY=`input, textarea, select, [contenteditable], .xterm`,AY=[`mousedown`,`mouseup`,`click`,`contextmenu`];function jY(){let e=null,t=()=>{e&&window.clearTimeout(e.timer),e=null},n=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()},t=()=>{for(let t of AY)document.removeEventListener(t,e,!0);document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,t,!0)};for(let t of AY)document.addEventListener(t,e,!0);document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,t,!0)};document.addEventListener(`pointerdown`,r=>{if(t(),r.pointerType!==`touch`||!(r.target instanceof Element)||r.target.closest(kY))return;let i=r.target,a={x:r.clientX,y:r.clientY,native:!1,timer:window.setTimeout(()=>{e=null,!(a.native||!i.isConnected)&&(i.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:a.x,clientY:a.y,button:2})),n())},DY)};e=a},!0),document.addEventListener(`pointermove`,n=>{e&&Math.hypot(n.clientX-e.x,n.clientY-e.y)>OY&&t()},!0),document.addEventListener(`pointerup`,t,!0),document.addEventListener(`pointercancel`,t,!0),document.addEventListener(`contextmenu`,t=>{e&&t.isTrusted&&(e.native=!0)},!0)}function MY(e,t){e.viewingExtras=()=>Ok({narrow:ya(),panelOpen:Ua.get(),zen:un.get()});let n=()=>e.reportViewing();Ua.subscribe(n),un.subscribe(n),ba(n),t.on(`panel`,t=>{Dk(t)&&Wk(t,e.selection.get().taskId)})}function NY(e){let t=e;return!!t&&typeof t.promptId==`string`&&typeof t.title==`string`}function PY({client:e,prompt:t}){let n=(B()===`zh`?dr:ur).prompt,[r,i]=(0,g.useState)(t.initial??``),a=(0,g.useRef)(!1),{busy:o,error:s,submit:c}=ar();return(0,g.useEffect)(()=>()=>{a.current||e.request(`ui.promptReply`,{promptId:t.promptId}).catch(()=>{})},[e,t.promptId]),(0,V.jsx)(ir,{title:t.title,children:(0,V.jsxs)(`form`,{className:Pn,onSubmit:n=>{n.preventDefault(),c(async()=>{await e.request(`ui.promptReply`,{promptId:t.promptId,value:r}),a.current=!0})},children:[(0,V.jsx)(`input`,{className:Qt,"aria-label":n.fieldLabel,autoFocus:!0,spellCheck:!1,value:r,placeholder:t.placeholder,onChange:e=>i(e.target.value)}),s&&(0,V.jsx)(`p`,{className:`text-error`,children:s}),(0,V.jsx)(lr,{busy:o,submitLabel:n.submitLabel})]})})}function FY(e,t){W.get()||W.set((0,V.jsx)(PY,{client:e,prompt:t},t.promptId))}var IY=`rove-web.reloadedFor`;function LY(e,t,n){return e===null?`adopt`:t===e||t===n?`stay`:`reload`}function RY(){let e=null;try{e=window.sessionStorage}catch{}return{storage:e,reload:()=>window.location.reload()}}function zY(e,t=RY()){let n=null,r=null,i=()=>{try{return t.storage?.getItem(IY)??r}catch{return r}};return e.conn.subscribe(()=>{let{state:a,hello:o}=e.conn.get();if(a!==`open`||!o)return;let s=LY(n,o.roveVersion,i());if(s===`adopt`&&(n=o.roveVersion),s===`reload`){r=o.roveVersion;try{t.storage?.setItem(IY,o.roveVersion)}catch{}t.reload()}})}function BY(){let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{t.style.setProperty(`--vvh`,`${e.height*e.scale}px`),e.scale===1&&window.scrollY!==0&&window.scrollTo(0,0)};e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),window.addEventListener(`scroll`,n,{passive:!0}),n()}var VY=(0,h.createRoot)(document.getElementById(`root`));BY(),jY(),F_(),EY(),SY();var HY=a();if(!HY)Da().then(e=>VY.render((0,V.jsx)(g.StrictMode,{children:e?(0,V.jsx)(ja,{}):(0,V.jsx)(en,{})})));else{let e=new s_(c_(),HY),t=new Ii(e);e.on(`prompt`,t=>{NY(t)&&FY(e,t)}),MY(t,e),zY(e),e.start(),VY.render((0,V.jsx)(g.StrictMode,{children:(0,V.jsx)(_Y,{model:t})}))}
152
+ `)}\n${r}\n`}function YJ(e){let t=document.querySelector(`[data-composer="${CSS.escape(e)}"]`);return t&&t.offsetParent!==null?t:null}function XJ(e,t,n,r){let i=JJ(e.term.getSelection());if(i===null)return!1;let a=EJ(t,n),o=YJ(a);if(o){AJ(a,i),e.term.clearSelection();let t=o.querySelector(`textarea`);return t?.focus(),t?.setSelectionRange(t.value.length,t.value.length),!0}return r?(G(z(`quote.atMenu`),`error`),!1):e.term.modes.bracketedPasteMode?(e.term.paste(i),e.term.clearSelection(),e.term.focus(),!0):(G(z(`quote.notReady`),`error`),!1)}async function ZJ(e,t,n){let r=jR(n);r.length<n.length&&G(z(`layout.dropUnsupported`),`error`);for(let n of r)try{t.term.paste(`${await NR(e,n)} `)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}t.term.focus()}async function QJ(){if(!navigator.clipboard?.read)throw Error(z(`layout.pasteNeedsHttps`));let e=[];for(let t of await navigator.clipboard.read())for(let n of t.types)(n.startsWith(`image/`)||n===`application/pdf`)&&e.push(new File([await t.getType(n)],`clipboard`,{type:n}));return jR(e)}async function $J(e,t){let n;try{n=await QJ()}catch(e){G(z(`layout.pasteNoAccess`,{error:e instanceof Error?e.message:String(e)}),`error`);return}n.length===0?G(z(`layout.pasteNoImage`),`error`):await ZJ(e,t,n)}async function eY(e){try{return await navigator.clipboard.writeText(e),!0}catch{return G(z(`menu.copyFailed`),`error`),!1}}function tY(e){let{client:t,taskId:n,tabId:r,leafId:i}=e,a=v(e.model.tasks)?.tasks.find(e=>e.id===n)?.tabStatus?.[r]?.kind===`needs-input`;B();let o=(0,g.useRef)(null),[s,c]=(0,g.useState)({kind:`none`}),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(0),[p,m]=(0,g.useState)({busy:!1,error:null}),h=(0,g.useRef)(e);h.current=e,(0,g.useEffect)(()=>{let e=o.current;if(!e)return;let a=null,s=!1,l=[document.fonts.load(`13px "JetBrains Mono"`),document.fonts.load(`bold 13px "JetBrains Mono"`)];document.fonts.load(`13px "${L_}"`,String.fromCodePoint(57504)).catch(()=>{});let d=()=>{s||(a=lT({client:t,host:e,taskId:n,tabId:r,leafId:i,focusOnMount:h.current.focused!==!1},{setNotice:c,onScrolled:f,onFocusChange:e=>{if(!a)return;let{stream:t}=a.handle;e?(h.current.onActivate?.(),na.set(ia(t)??null)):na.get()?.stream===t&&na.set(null)},onExit:()=>{CJ(yC(n,r,i))||h.current.onExit?.()},copyText:eY,pasteImage:async()=>{a&&await $J(t,a.handle)}}),u(a.handle))};return cT(t,n,r,i)?d():Promise.allSettled(l).then(d),()=>{s=!0,u(null),a?.release()}},[t,n,r,i]);let[_,y]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!l)return;y(l.term.hasSelection());let e=l.term.onSelectionChange(()=>y(l.term.hasSelection()));return()=>{e.dispose(),y(!1)}},[l]),(0,g.useEffect)(()=>{if(!l)return;let{term:e,stream:a}=l,o={stream:a,focus:()=>e.focus(),input:t=>e.input(t,!0),reattach:()=>l.reattach(),scrollPages:e=>l.scrollLines(e*10),hasSelection:()=>e.hasSelection(),copySelection:()=>{let t=e.getSelection();return t.trim().length!==0&&(eY(t),e.clearSelection(),!0)},reset:()=>{let o={cols:e.cols,rows:e.rows};W.set((0,V.jsx)(sr,{title:yo(`reset.title`),body:yo(`reset.body`),confirmLabel:z(`workspace.reset`),onConfirm:async()=>{xJ(a);try{await t.request(`tab.split`,{taskId:n,tabId:r,action:`reset`,leafId:i??`leaf-1`,...o}),await l.reattach(),e.focus()}finally{SJ(a)}}}))},size:()=>({cols:e.cols,rows:e.rows})},s=ra(o);return document.activeElement===e.textarea&&na.set(o),()=>{s()}},[l,t,n,r,i]),(0,g.useEffect)(()=>{e.focused&&l&&document.activeElement!==l.term.textarea&&l.term.focus()},[e.focused,l]);let b=!i||i===`leaf-1`,[x,S]=(0,g.useState)(null),C=e.engineExit?.since===x,[w,T]=(0,g.useState)(null),E=e.usageLimit&&e.usageLimit.since!==w?e.usageLimit:null,D=(0,g.useRef)(!1),O=async(i,a)=>{if(!D.current){D.current=!0,m({busy:!0,error:null});try{await t.request(`term.revive`,{taskId:n,tabId:r,...a?{restartExited:a}:{}}),await i.reattach(),i.term.focus(),S(e.engineExit?.since??null),m({busy:!1,error:null})}catch(e){m({busy:!1,error:e instanceof Error?e.message:String(e)})}finally{D.current=!1}}};return(0,V.jsxs)(`div`,{className:Et,"data-stream":yC(n,r,i),onDragOver:e=>e.dataTransfer.types.includes(`Files`)&&e.preventDefault(),onDrop:e=>{!e.dataTransfer.files.length||!l||(e.preventDefault(),ZJ(t,l,Array.from(e.dataTransfer.files)))},onPasteCapture:e=>{if(!l)return;let n=jR(e.clipboardData.files);(n.length!==0||e.clipboardData.getData(`text/plain`)===``)&&(e.preventDefault(),e.stopPropagation(),n.length>0?ZJ(t,l,n):$J(t,l))},children:[(0,V.jsxs)(`div`,{className:Dt,children:[(0,V.jsx)(`div`,{className:Ot,ref:o}),(0,V.jsx)(qJ,{notice:s,engineExit:C?null:e.engineExit??null,model:e.model,taskId:n,tabId:r,revive:p,onReopen:b&&l?e=>void O(l,e):void 0,onRetryAttach:l?()=>void l.reattach():void 0,usageLimit:E!==null,onDismissLimit:E?()=>T(E.since):void 0}),_&&e.composer&&l&&(0,V.jsx)(H,{variant:`floating`,className:`absolute top-2.5 right-2.5 z-4`,title:z(`quote.title`),onClick:()=>XJ(l,n,r,a),children:z(`quote.action`)}),d>0&&l&&(0,V.jsxs)(`div`,{className:`mono absolute right-2.5 bottom-2.5 z-4 flex gap-3 rounded-sm border-hairline border-line bg-inset px-2.5 py-1 text-meta`,children:[(0,V.jsx)(`span`,{className:`text-warning`,children:yo(`scrolledBack`,{lines:d})}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>l.scrollToTop(),children:yo(`scrollFirst`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>l.scrollToBottom(),children:yo(`scrollLatest`)})]})]}),e.composer&&(0,V.jsx)(UJ,{model:e.model,taskId:n,tabId:r}),l&&(0,V.jsx)(GJ,{handle:l,atMenu:a})]})}var nY=e=>RH(e)!==null,rY=e=>bw(RH(e)?.tab.split);function iY(e){let t=RH(e),n=t?.tab.split;return t&&n?{...t,split:n,leaf:FH(t.taskId,t.tab,n)}:null}qi(()=>[{id:`workspace.split.right`,chords:[`ctrl+\\`],prefix:!1,surface:`workspace`,live:nY,run:e=>{let t=RH(e);t&&BH(e,t.taskId,t.tab,`right`)}},{id:`workspace.split.down`,chords:[`ctrl+=`],prefix:!1,surface:`workspace`,live:nY,run:e=>{let t=RH(e);t&&BH(e,t.taskId,t.tab,`down`)}},{id:`workspace.split.focus-next`,chords:[`f3`],prefix:!1,surface:`workspace`,live:rY,run:e=>{let t=iY(e);t&&LH(t.taskId,t.tab,t.split,Sw(t.split,t.leaf))}},{id:`workspace.split.close`,chords:[`w`],prefix:!0,surface:`workspace`,live:rY,run:e=>{let t=iY(e);t&&VH(e,t.taskId,t.tab,t.leaf)}},{id:`workspace.split.rename`,chords:[`f2`],prefix:!1,surface:`workspace`,live:rY,run:e=>{let t=iY(e);t&&HH(e,t.taskId,t.tab,t.leaf)}}]);var aY=[{id:`leaf-1`,x:0,y:0,w:1,h:1,left:!1,top:!1}];function oY({model:e,taskId:t,tab:n}){let r=n.split;v(PH);let i=r?FH(t,n,r):`leaf-1`,a=r?Cw(r,_w(n)):new Map,o=bw(r),{prefs:s}=A_(),c=v(e.tasks)?.tasks.find(e=>e.id===t)?.tabStatus?.[n.id]??n.status,l=n.kind===`engine`&&c?.reason===`dead`?c.since:null;(0,g.useEffect)(()=>{l!==null&&e.refreshTabsNow()},[l,e]);let u=l!==null&&n.alive!==!1?{code:n.exit?.code??null,since:l}:null,d=n.kind===`engine`&&c?.reason===`rate_limited`?{since:c.since}:null;return(0,V.jsx)(`div`,{className:Je,children:(r?xw(r.root):aY).map(c=>(0,V.jsxs)(`div`,{className:Ze(o?s.splitStyle:null,{left:c.left,top:c.top,active:c.id===i}),style:{left:`calc(${c.x*100}% + var(--ml, 0px))`,top:`calc(${c.y*100}% + var(--mt, 0px))`,width:`calc(${c.w*100}% - var(--ml, 0px))`,height:`calc(${c.h*100}% - var(--mt, 0px))`},children:[(0,V.jsx)(tY,{client:e.client,model:e,engineExit:c.id===`leaf-1`?u:null,usageLimit:c.id===`leaf-1`?d:null,composer:n.kind===`engine`&&c.id===`leaf-1`,taskId:t,tabId:n.id,leafId:c.id,focused:c.id===i,onActivate:()=>r&&IH(t,n.id,r,c.id),onExit:()=>{o?zH(e,{taskId:t,tabId:n.id,action:`close`,leafId:c.id}):n.kind!==`engine`&&e.client.request(`tab.close`,{taskId:t,tabId:n.id}).then(()=>e.refreshTabsNow()).catch(()=>{})}}),o&&(0,V.jsx)(`span`,{className:Qe(s.splitStyle===`rule`,c.id===i),onContextMenu:r=>XU(r,GH(e,t,n,c.id)),children:a.get(c.id)})]},c.id))})}var sY=/^[0-9a-f]{7,40}$/i;function cY(e,t){return t.sharesWorkspaceOf||!t.baseRef?null:e.find(e=>e.id!==t.id&&e.branch!==``&&e.branch===t.baseRef)||(sY.test(t.baseRef)&&t.parentTaskId?e.find(e=>e.id===t.parentTaskId)??null:null)}function lY(e,t){let n=[];for(let r=cY(e,t);r&&n.length<20&&!n.includes(r);r=cY(e,r))n.unshift(r);let r=e.filter(n=>!n.deleting&&cY(e,n)?.id===t.id).sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``));if(n.length===0&&r.length===0)return null;let i=n[0]??t,a=i.baseRef&&!sY.test(i.baseRef)?i.baseRef:null;return{nodes:[...n,t,...r],at:n.length,base:a}}var uY=e=>e.pr?.lifecycle===`merged`;function dY(e){return e.nodes.find(e=>!uY(e))??null}function fY({model:e,taskId:t}){B();let n=v(e.tasks)?.tasks??[],r=n.find(e=>e.id===t),i=r?lY(n,r):null;if(!i)return null;let a=dY(i);return(0,V.jsxs)(`nav`,{className:jL,"aria-label":z(`compare.stackLabel`),children:[i.base&&(0,V.jsxs)(`span`,{className:`text-subtle`,children:[i.base,` ←`]}),i.nodes.map((n,r)=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-x-3.5`,children:[r>0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`←`}),(0,V.jsxs)(H,{variant:`pill`,hit:`tight`,"aria-current":n.id===t,onClick:()=>e.select(n.id),children:[`[ `,(0,V.jsx)(QL,{status:n.rowStatus}),n.label||n.title,uY(n)?(0,V.jsx)(`span`,{className:`text-accent`,children:`✓`}):n.pr?.number?(0,V.jsx)(`span`,{children:`PR`}):null,` ]`]})]},n.id)),a&&!a.machine&&(0,V.jsx)(H,{hit:`tight`,className:`ml-auto flex-none whitespace-nowrap`,onClick:()=>void WP(e,a),children:z(`compare.landBottom`)})]})}function pY(e,t){return e===`never`?!1:e!==`multipleOnly`||t>=2}function mY({taskId:e}){B();let t=Lk(e),n=v(Ua),r=v(un),i=n&&!r?lk(t):null;return(0,V.jsx)(`div`,{className:vI,children:Ra.map(t=>(0,V.jsx)(`button`,{type:`button`,className:sI({on:i===t}),title:z(`panel.${t}`),"aria-label":z(`panel.${t}`),"aria-pressed":i===t,onClick:()=>Bk(e,t),children:(0,V.jsx)(fG,{children:pG[t]})},t))})}function hY({model:e,task:t,tabs:n,narrow:r}){let i=v(e.selection),{prefs:a}=A_(),o=!pY(a.tabStrip,n.length);return(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 font-mono text-meta/body transition-padding-left duration-220 ease-snap motion-reduce:transition-none rail-folded:min-h-6.5 rail-folded:pl-23`,role:`tablist`,children:[n.map((n,r)=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.id===i.tabId,className:`group/tab flex items-center gap-1.5 whitespace-nowrap rounded-sm px-2.5 py-1 active:scale-97 motion-reduce:active:scale-none touch:select-none touch:touch-callout-none ${o?`hidden`:``} ${n.id===i.tabId?`bg-inset text-ink`:`text-muted hover:bg-hover data-menu-open:bg-hover`}`,onClick:()=>e.select(t.id,n.id),onContextMenu:r=>XU(r,cU(e,t,n)),children:[(0,V.jsx)(`span`,{className:`text-subtle group-aria-selected/tab:text-accent`,children:r+1}),_w(n)]},n.id)),!r&&(0,V.jsx)(mY,{taskId:t.id})]})}function gY(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??e))}function _Y({model:e}){let t=B()===`zh`?Fr:Pr,n=e.client,[r,i]=(0,g.useState)(()=>(Ns(n,`worktrees.list`,{network:!0})??Ns(n,`worktrees.list`,{network:!1}))?.projects??null),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0,t=!1,r=r=>Fs(n,`worktrees.list`,{network:r}).then(n=>{if(!(!e||!r&&t)&&(r&&(t=!0),i(n.projects),r)){let e=new Set(n.projects.flatMap(e=>e.worktrees.map(e=>e.path)));o(t=>t.filter(t=>e.has(t)))}}).catch(()=>{});return r(!1),r(!0),()=>{e=!1}},[n,l]),(0,g.useEffect)(()=>d.current?.focus(),[]);let f=(r??[]).map(e=>({...e,worktrees:e.worktrees.filter(e=>!a.includes(e.path))})),p=f.flatMap(e=>e.worktrees),m=Math.min(s,Math.max(0,p.length-1));(0,g.useEffect)(()=>{d.current?.querySelector(`[data-row="${m}"]`)?.scrollIntoView({block:`nearest`})},[m]);let h=(0,g.useCallback)(()=>u(e=>e+1),[]),_=async(e,r)=>{o(t=>[...t,e.path]);try{let i=await n.request(`worktrees.remove`,{path:e.path,force:r});i.residue&&G(gY(t.delete.residue,i.residue)),h()}catch(n){o(t=>t.filter(t=>t!==e.path));let i=n&&typeof n==`object`&&`code`in n?n.code:null;if(!r&&i===`DIRTY_WORKTREE`){W.set((0,V.jsx)(sr,{title:t.delete.forceTitle,body:`${gY(t.delete.forceBody,{branch:e.branch||e.path})}\n\n${gY(t.delete.forceReason,{reason:K(n)})}`,confirmLabel:t.delete.button,onConfirm:()=>_(e,!0)}));return}G(gY(t.delete.failed,{error:K(n)}),`error`)}},v=e=>W.set((0,V.jsx)(sr,{title:t.delete.confirmTitle,body:gY(t.delete.confirmBody,{branch:e.branch||e.path}),confirmLabel:t.delete.button,onConfirm:async()=>{_(e,!1)}})),y=n=>{if(!n.taskId){G(t.land.noTask,`error`);return}WP(e,{id:n.taskId,title:n.branch,branch:n.branch},h)},b=e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`&&!window.getSelection()?.toString())return e.preventDefault(),on.set(null);if(e.metaKey||e.ctrlKey||e.altKey)return;let t=p[m];if(e.key===`j`||e.key===`ArrowDown`)c(Math.min(p.length-1,m+1));else if(e.key===`k`||e.key===`ArrowUp`)c(Math.max(0,m-1));else if(e.key===`d`&&t)v(t);else if(e.key===`l`&&t)y(t);else if(e.key===`q`||e.key===`Escape`)on.set(null);else return;e.preventDefault()},x=0;return(0,V.jsxs)(`div`,{className:sM,tabIndex:0,ref:d,onKeyDown:b,children:[(0,V.jsx)(`h1`,{className:cM,children:t.title}),r===null?(0,V.jsx)(`p`,{className:`text-muted`,children:t.loading}):f.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:t.noProjects}):f.map(e=>{let n=x;return x+=e.worktrees.length,(0,V.jsxs)(`section`,{className:Jj,children:[(0,V.jsxs)(`h2`,{className:`mt-1.5 mr-2 mb-1 ml-0 flex items-center gap-1 font-mono text-meta font-semibold normal-nums text-subtle`,children:[(0,V.jsx)(`span`,{children:e.repo}),(0,V.jsx)(`span`,{className:`rule`})]}),e.worktrees.length===0&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:t.noWorktrees}),e.worktrees.map((e,r)=>{let i=n+r;return(0,V.jsxs)(`div`,{"data-row":i,className:Yj(i===m),onClick:()=>c(i),children:[(0,V.jsxs)(`div`,{className:Xj,children:[(0,V.jsx)(`span`,{className:Qj,children:e.branch||t.row.detached}),e.roveManaged&&(0,V.jsx)(`span`,{className:`chip text-muted`,children:t.badge.roveManaged}),e.dirty===!0&&(0,V.jsx)(`span`,{className:`chip text-warning`,children:t.badge.dirty}),e.dirty===null&&(0,V.jsx)(`span`,{className:`chip text-muted`,children:t.badge.dirtyUnknown}),(0,V.jsx)(`span`,{className:`chip ${e.branchOnRemote===!0?`text-success`:e.branchOnRemote===!1?`text-warning`:`text-muted`}`,children:e.branchOnRemote===!0?t.badge.remoteOn:e.branchOnRemote===!1?t.badge.remoteOff:t.badge.remoteUnknown}),e.verdictReason!==`dirty`&&e.verdictReason!==`fresh`&&(0,V.jsx)(`span`,{className:`chip ${e.verdict===`merged`?`text-success`:e.verdict===`stale`?`text-warning`:`text-accent`}`,children:t.verdict[e.verdictReason]??e.verdictReason})]}),(0,V.jsxs)(`div`,{className:`${Zj} mono text-muted`,children:[(0,V.jsx)(`span`,{className:$j,children:e.path}),e.createdAtMs>0&&(0,V.jsx)(`span`,{children:gY(t.row.created,{age:Mo(Date.now()-e.createdAtMs)})})]}),i===m&&(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[length:var(--fs-body)]`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>v(e),children:t.delete.button}),e.taskId&&(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>y(e),children:t.land.button})]})]},e.path)})]},e.repo)}),(0,V.jsx)(`p`,{className:`${eM} mono keys-only text-muted`,children:(0,V.jsx)(ST,{text:`j/k · d ${t.delete.button} · l ${t.land.button} · q/esc`})})]})}function vY({model:e,narrow:t}){let n=v(e.selection),r=v(e.tabs),i=v(e.tasks),a=v(e.remote),o=a.find(e=>e.id===n.taskId&&!e.machine?.stale),s=Pi(i,n.taskId)??o??null,c=o?void 0:a.find(e=>e.id===n.taskId),l=s?r[s.id]??[]:[],u=s?s.id in r:!1,d=v(on),f=QM(s?.id),p=s?.rowStatus?.kind===`running`,m=v(dn),h=v(za)!==`terminal`&&t&&!!s;return(0,g.useEffect)(()=>{let t=e.selection.get();return e.selection.subscribe(()=>{dn.set(null);let n=e.selection.get();(n.taskId!==t.taskId||n.tabId!==t.tabId)&&za.set(`terminal`),t=n})},[e]),(0,g.useEffect)(()=>LF(e),[e]),d===`update`?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(MI,{}),(0,V.jsx)(AM,{client:e.client})]}):d===`worktrees`?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(MI,{}),(0,V.jsx)(_Y,{model:e})]}):d?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(MI,{}),(0,V.jsx)(pH,{model:e,page:d})]}):m?(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(MI,{}),(0,V.jsx)(`div`,{className:wt,children:(0,V.jsx)(XD,{model:e,seed:m},`${m.machine??``}\0${m.repo??``}\0${m.ungrouped?`u`:``}\0${m.retryOf?.id??``}`)})]}):(0,V.jsxs)(`main`,{className:`${Ct} ${Be}`,children:[t&&(0,V.jsx)(MI,{taskId:s?.id}),s&&(0,V.jsx)(hY,{model:e,task:s,tabs:l,narrow:t}),s&&!s.groupId&&(0,V.jsx)(fY,{model:e,taskId:s.id}),s?.groupId&&(0,V.jsx)(vJ,{model:e,taskId:s.id,groupId:s.groupId}),(0,V.jsxs)(`div`,{className:`${wt} ${p?Tt:``}`,style:f?{"--task-ink":f}:void 0,children:[!t&&!s&&!c&&i&&i.tasks.length+a.length===0&&(0,V.jsx)(YU,{model:e}),!s&&!c&&i&&i.tasks.length+a.length>0&&(0,V.jsx)(`p`,{className:xt,children:z(`workspace.pickTask`)}),c?.machine&&(0,V.jsx)(`div`,{className:St,children:(0,V.jsx)(hE,{host:c.machine.label,onMachines:()=>vO(e)})}),s&&u&&l.length===0&&!h&&(0,V.jsxs)(`div`,{className:St,children:[(0,V.jsx)(`p`,{children:z(`workspace.noTabs`)}),(0,V.jsx)(H,{variant:`filled`,onClick:()=>void NC(e,s.id,{kind:`engine`}).catch(e=>G(String(e),`error`)),children:s.engine?z(`workspace.startEngine`,{engine:s.engine.name}):z(`workspace.startSession`)}),` `,(0,V.jsx)(H,{variant:`filled`,onClick:()=>void MC(e,s.id),children:z(`menu.newChat`)}),` `,(0,V.jsx)(H,{variant:`filled`,onClick:()=>W.set((0,V.jsx)(RC,{model:e,taskId:s.id})),children:z(`menu.newChatPick`)})]}),s&&h&&(0,V.jsx)(hJ,{model:e,task:s,narrow:!0}),s&&n.tabId&&l.some(e=>e.id===n.tabId)&&(0,V.jsx)(`div`,{className:`min-w-0 flex-1 ${h?`hidden`:`flex`}`,children:(0,V.jsx)(oY,{model:e,taskId:s.id,tab:l.find(e=>e.id===n.tabId)??l[0]},`${s.id}::${n.tabId}`)})]})]})}function yY({model:e}){B();let t=v(e.client.conn);return t.hello===null&&t.failures>=2?(0,V.jsx)(bY,{}):(0,V.jsx)(xY,{model:e})}function bY(){let[e,t]=(0,g.useState)(null);return(0,g.useEffect)(()=>{Da().then(t)},[]),e===null?null:e?(0,V.jsx)(ja,{}):(0,V.jsx)(en,{failing:!0})}function xY({model:e}){mF(e);let t=v(e.client.conn).hello;(0,g.useEffect)(()=>{t&&(OM(e.client),PM(e.client,t.roveVersion))},[t,e.client]),zw(e),Iw(e),la(),Xr(e.client),CF(e),li(e.client),SN(e.client),(0,g.useEffect)(()=>{e.onSelect=pa;let t=dn.subscribe(()=>{dn.get()!==null&&pa()});return mn(),t},[e]),(0,g.useEffect)(()=>$N(e),[e]);let n=v(un),r=v(e.selection),i=v(e.tasks),a=v(e.remote),o=xa(),s=v(tI),c=v(nI),l=v(eI),u=v(fa),d=v(Ha),f=v(Ua),p=v(Wa),m=v(on),h=v(bn)===`drag`,_=v(dn)!==null,y=a.find(e=>e.id===r.taskId&&!e.machine?.stale),b=Pi(i,r.taskId)??y??null,x=y?void 0:a.find(e=>e.id===r.taskId),S=o?Sa(u,!!b||!!x,m!==null||_):null;(0,g.useEffect)(()=>e.setTaskShown(S===null||S===`content`&&m===null&&!_),[e,S,m,_]);let C=aI(l??280),w={"--rail-w":`${s?0:C}px`,"--rail-open-w":`${C}px`,"--panel-w":d===null?void 0:`${Ga(d,s?0:C)}px`};return(0,V.jsxs)(`div`,{className:Le,children:[(0,V.jsx)(di,{onRefresh:()=>ui(e.client)}),(0,V.jsxs)(`div`,{className:Re({zen:n||!f||!b&&!x||o,expanded:p&&!n&&!o,surface:S,folded:s&&!o,peek:s&&c&&!o,dragging:h}),style:o?void 0:w,children:[!o&&(0,V.jsx)(AI,{model:e}),s&&!o&&(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-5 col-1 row-1 w-2.5`,onMouseEnter:()=>iI(!0),onMouseLeave:()=>iI(!1)}),(0,V.jsx)(ZU,{model:e,narrow:o}),(0,V.jsx)(vY,{model:e,narrow:o}),!o&&(0,V.jsx)(hJ,{model:e,task:b,remoteHost:x?.machine?.label}),(0,V.jsx)(_J,{model:e}),(0,V.jsx)(La,{}),(0,V.jsx)(yF,{model:e}),(0,V.jsx)(Ri,{model:e})]})]})}var SY=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function CY(e){return[...e.querySelectorAll(SY)].filter(e=>e.tabIndex>=0&&e.offsetParent!==null)}function wY(){window.addEventListener(`keydown`,e=>{if(e.key!==`Tab`||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey)return;let t=[...document.querySelectorAll(`.overlay:not(.is-leaving)`)].at(-1);if(!t)return;let n=CY(t);if(n.length===0)return;let r=document.activeElement,i=r instanceof HTMLElement&&t.contains(r),a=e.shiftKey?n.filter(e=>i&&!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)).at(-1)??n.at(-1):n.find(e=>i&&!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))??n[0];e.preventDefault(),a?.focus()})}function TY(e){if(!_n())for(let t of document.querySelectorAll(`${e}:not(.is-leaving)`)){let e=t.cloneNode(!0);e.classList.add(`is-leaving`),e.inert=!0,e.setAttribute(`aria-hidden`,`true`),document.body.append(e);let n=t.querySelectorAll(`*`),r=e.querySelectorAll(`*`);n.forEach((e,t)=>{let n=r[t];e.scrollTop&&(n.scrollTop=e.scrollTop),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(n.value=e.value)}),window.setTimeout(()=>e.remove(),200)}}function EY(e){for(let t of document.querySelectorAll(`${e}.is-leaving`))t.remove()}function DY(){for(let e of document.querySelectorAll(`.overlay:not(.is-leaving)`))for(let t of e.getAnimations())t instanceof CSSAnimation&&t.animationName===`fade-in`&&t.finish()}function OY(){let e=W.get(),t=-1/0;W.subscribe(()=>{let n=W.get();if(n===null&&e!==null)t=performance.now(),TY(`.overlay`);else if(n!==null){let n=e!==null||performance.now()-t<140;EY(`.overlay`),n&&requestAnimationFrame(DY)}e=n});let n=nn.get();nn.subscribe(()=>{let e=nn.get();e===null&&n!==null?TY(`.menu`):e!==null&&EY(`.menu`),n=e});let r=Jw.get().guide;Jw.subscribe(()=>{let e=Jw.get().guide;e===null&&r!==null?TY(`.prefix-guide`):e!==null&&EY(`.prefix-guide`),r=e})}var kY=500,AY=10,jY=`input, textarea, select, [contenteditable], .xterm`,MY=[`mousedown`,`mouseup`,`click`,`contextmenu`];function NY(){let e=null,t=()=>{e&&window.clearTimeout(e.timer),e=null},n=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()},t=()=>{for(let t of MY)document.removeEventListener(t,e,!0);document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,t,!0)};for(let t of MY)document.addEventListener(t,e,!0);document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,t,!0)};document.addEventListener(`pointerdown`,r=>{if(t(),r.pointerType!==`touch`||!(r.target instanceof Element)||r.target.closest(jY))return;let i=r.target,a={x:r.clientX,y:r.clientY,native:!1,timer:window.setTimeout(()=>{e=null,!(a.native||!i.isConnected)&&(i.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:a.x,clientY:a.y,button:2})),n())},kY)};e=a},!0),document.addEventListener(`pointermove`,n=>{e&&Math.hypot(n.clientX-e.x,n.clientY-e.y)>AY&&t()},!0),document.addEventListener(`pointerup`,t,!0),document.addEventListener(`pointercancel`,t,!0),document.addEventListener(`contextmenu`,t=>{e&&t.isTrusted&&(e.native=!0)},!0)}function PY(e,t){e.viewingExtras=()=>Ok({narrow:ya(),panelOpen:Ua.get(),zen:un.get()});let n=()=>e.reportViewing();Ua.subscribe(n),un.subscribe(n),ba(n),t.on(`panel`,t=>{Dk(t)&&Wk(t,e.selection.get().taskId)})}function FY(e){let t=e;return!!t&&typeof t.promptId==`string`&&typeof t.title==`string`}function IY({client:e,prompt:t}){let n=(B()===`zh`?dr:ur).prompt,[r,i]=(0,g.useState)(t.initial??``),a=(0,g.useRef)(!1),{busy:o,error:s,submit:c}=ar();return(0,g.useEffect)(()=>()=>{a.current||e.request(`ui.promptReply`,{promptId:t.promptId}).catch(()=>{})},[e,t.promptId]),(0,V.jsx)(ir,{title:t.title,children:(0,V.jsxs)(`form`,{className:Pn,onSubmit:n=>{n.preventDefault(),c(async()=>{await e.request(`ui.promptReply`,{promptId:t.promptId,value:r}),a.current=!0})},children:[(0,V.jsx)(`input`,{className:Qt,"aria-label":n.fieldLabel,autoFocus:!0,spellCheck:!1,value:r,placeholder:t.placeholder,onChange:e=>i(e.target.value)}),s&&(0,V.jsx)(`p`,{className:`text-error`,children:s}),(0,V.jsx)(lr,{busy:o,submitLabel:n.submitLabel})]})})}function LY(e,t){W.get()||W.set((0,V.jsx)(IY,{client:e,prompt:t},t.promptId))}var RY=`rove-web.reloadedFor`;function zY(e,t,n){return e===null?`adopt`:t===e||t===n?`stay`:`reload`}function BY(){let e=null;try{e=window.sessionStorage}catch{}return{storage:e,reload:()=>window.location.reload()}}function VY(e,t=BY()){let n=null,r=null,i=()=>{try{return t.storage?.getItem(RY)??r}catch{return r}};return e.conn.subscribe(()=>{let{state:a,hello:o}=e.conn.get();if(a!==`open`||!o)return;let s=zY(n,o.roveVersion,i());if(s===`adopt`&&(n=o.roveVersion),s===`reload`){r=o.roveVersion;try{t.storage?.setItem(RY,o.roveVersion)}catch{}t.reload()}})}function HY(){let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{t.style.setProperty(`--vvh`,`${e.height*e.scale}px`),e.scale===1&&window.scrollY!==0&&window.scrollTo(0,0)};e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),window.addEventListener(`scroll`,n,{passive:!0}),n()}var UY=(0,h.createRoot)(document.getElementById(`root`));HY(),NY(),F_(),OY(),wY();var WY=a();if(!WY)Da().then(e=>UY.render((0,V.jsx)(g.StrictMode,{children:e?(0,V.jsx)(ja,{}):(0,V.jsx)(en,{})})));else{let e=new s_(c_(),WY),t=new Ii(e);e.on(`prompt`,t=>{FY(t)&&LY(e,t)}),PY(t,e),VY(e),e.start(),UY.render((0,V.jsx)(g.StrictMode,{children:(0,V.jsx)(yY,{model:t})}))}