@staff0rd/assist 0.606.1 → 0.607.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -137,7 +137,7 @@ Every command supports `--help` for full detail on its flags and behaviour.
137
137
  - `--announce` - Announce the PR in Slack (`/prs-slack <n> --no-confirm`) at the tail of the chain: the Address Comments session announces once every thread is processed when one was started, otherwise a `/prs-slack` session is started directly. Announces exactly once, and only inside an assist session
138
138
  - `--verbose` - Per-line log output instead of the stacked-spinner UI (automatic in CI)
139
139
  - `assist github commits <org> [--since <date>] [--top <n>] [--json]` - Report commit activity across a GitHub organisation: repos ranked by commits, top committers, and a per-repo author breakdown
140
- - `assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--project <number>] [--status <name>] [--label <name>]` - Create a GitHub issue on the current repo (or `-R`'s). There is no What/Why/How template — an issue reports a problem, and the target repo's own issue template is unknowable from here. The title and body are rejected if they reference Claude or an assist backlog item, and in a web session they are previewed for approve/reject first (with inline comments); nothing is created until it is approved. `--type` sets the native issue type after creation, `--project` adds the issue to the repo owner's project of that number, `--status` sets that project item's Status, and `--label` applies repo labels (repeat the flag or pass a comma-separated list). All four are resolved before the preview — including the token's `project` OAuth scope, whose remediation is `gh auth refresh -h github.com -s project` — so an unknown name, a missing scope, or `--status` without `--project` creates nothing. The preview pane names the repo, type, project, status and labels above the body without adding them to the posted body. Raw `gh issue create` is denied in favour of this command
140
+ - `assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--parent <issue>] [--project <number>] [--status <name>] [--label <name>]` - Create a GitHub issue on the current repo (or `-R`'s). There is no What/Why/How template — an issue reports a problem, and the target repo's own issue template is unknowable from here. The title and body are rejected if they reference Claude or an assist backlog item, and in a web session they are previewed for approve/reject first (with inline comments); nothing is created until it is approved. `--type` sets the native issue type after creation, `--parent` files the new issue as a sub-issue of the referenced issue (`owner/repo#number`, a github.com issue URL, or a bare number read against `--repo` or the current repo; a parent in another repository is allowed), `--project` adds the issue to the repo owner's project of that number, `--status` sets that project item's Status, and `--label` applies repo labels (repeat the flag or pass a comma-separated list). All five are resolved before the preview — including the token's `project` OAuth scope, whose remediation is `gh auth refresh -h github.com -s project` — so an unknown name, an unreadable parent, a missing scope, or `--status` without `--project` creates nothing. The preview pane names the repo, type, parent, project, status and labels above the body without adding them to the posted body. Raw `gh issue create` is denied in favour of this command
141
141
  - `assist github issue edit <number> [-R <owner>/<repo>] [--fresh]` - Rework an existing GitHub issue's body in the web preview pane. Fetches the issue's current `title`, `body` and `updatedAt` with `gh issue view`, writes the body to a working file under `~/.assist/github-issues/`, and previews it for approve/reject. Approving pushes the pane's markdown back with `gh issue edit --body-file`; nothing is pushed if the issue was updated on GitHub after it was fetched (the working file is named instead, so nobody else's edit is clobbered) or if the preview is rejected. Rejecting writes the pane's markdown — collapses included — to the working file and names it in the output, so the revision is made in that file rather than composed from scratch; a re-run resumes from the working file while the issue has not moved on GitHub, and `--fresh` discards it and re-fetches. Outside a web session there is no pane to edit in, so the command just prints the issue — callers never need to detect the session themselves. Only the body is touched — the title, labels, assignees and state are left alone
142
142
  - `assist github issue comment <number> --body <body> [-R <owner>/<repo>]` - Comment on a GitHub issue on the current repo (or `-R`'s); a body of `-` reads it from stdin. The body is rejected if it references Claude or an assist backlog item, and in a web session it is previewed for approve/reject first (with inline comments); nothing is posted until it is approved. Raw `gh issue comment` is denied in favour of this command
143
143
  - `assist github issue fix-structure <target> [-R <owner>/<repo>] [--level <level>] [--type-chain <names>] [--strip-label <label>...] [--apply]` - Normalise the issue types across one issue subtree, reading and writing nothing outside it. `<target>` is `owner/repo#number`, a github.com issue URL, or a bare number with `-R`; a bare number with no repo is refused rather than guessed. Walks the subtree via sub-issues level by level (a single deep query blows the GraphQL node limit) and reports the type each issue should carry: every level below the target is typed to the next level down the chain, matching type names loosely so `Subtask` and `Sub-task` both bind to the leaf. The chain defaults to `Epic` > `Story` > `Subtask`; `--type-chain Initiative,Feature,Task` replaces it, parent level first, and every level named must already exist as an issue type on the organisation or the run fails listing the ones that do. Untyped issues are typed rather than skipped, and cross-repo children are handled in the one run. The target's own level is inferred from its issue type, so aiming at a story types its children as subtasks; when its type is not in the chain the level cannot be inferred and the command exits non-zero naming the type it has. `--level` asserts the position instead, which also types the target itself. No label is touched unless `--strip-label` names it; it is repeatable, matched case-insensitively, and each label is removed by the id found on that issue, since label ids differ per repository. Anything nested below the leaf level fails the run before a single write, naming the offender and its parent; nothing is ever re-parented. Without `--apply` nothing is written. `--apply` announces each write before it is issued and flushes it, so a long run shows progress, then re-walks the subtree and fails with a non-zero exit if any drift remains
@@ -3971,7 +3971,7 @@ ${h.join(`
3971
3971
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),NIe&&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),r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n||!t?!1:this._areCoordsInSelection(t,r,n)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n?!1:this._areCoordsInSelection([e,t],r,n)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=orr(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,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=OIe(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-NMe),NMe),t/=NMe,t/Math.abs(t)+Math.round(t*(w6n-1)))}shouldForceSelection(e){return jue?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(),_6n)}_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&&!(jue&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let n=r.lines.get(this._model.selectionEnd[1]);n&&n.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<k6n&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let n=g6n(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let n=0;t>=n;n++){let i=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:i>1&&t!==n&&(r+=i-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(e[1]);if(!o)return;let a=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(o,e[0]),l=s,u=e[0]-s,h=0,f=0,d=0,p=0;if(a.charAt(s)===" "){for(;s>0&&a.charAt(s-1)===" ";)s--;for(;l<a.length&&a.charAt(l+1)===" ";)l++}else{let y=e[0],v=e[0];o.getWidth(y)===0&&(h++,y--),o.getWidth(v)===2&&(f++,v++);let b=o.getString(v).length;for(b>1&&(p+=b-1,l+=b-1);y>0&&s>0&&!this._isCharWordSeparator(o.loadCell(y-1,this._workCell));){o.loadCell(y-1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,y--):x>1&&(d+=x-1,s-=x-1),s--,y--}for(;v<o.length&&l+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===2?(f++,v++):x>1&&(p+=x-1,l+=x-1),l++,v++}}l++;let m=s+u-h+d,g=Math.min(this._bufferService.cols,l-s+h+f-d-p);if(!(!t&&a.slice(s,l).trim()==="")){if(r&&m===0&&o.getCodePoint(0)!==32){let y=i.lines.get(e[1]-1);if(y&&o.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;m-=b,g+=b}}}if(n&&m+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let y=i.lines.get(e[1]+1);if(y?.isWrapped&&y.getCodePoint(0)!==32){let v=this._getWordAt([0,e[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:m,length:g}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=orr(r,this._bufferService.cols)}};yIe=Ja([vr(3,uh),vr(4,TE),vr(5,RIe),vr(6,hh),vr(7,mx),vr(8,px)],yIe);var arr=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},srr=class{constructor(){this._color=new arr,this._css=new arr}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},fl=Object.freeze((()=>{let e=[Aa.toColor("#2e3436"),Aa.toColor("#cc0000"),Aa.toColor("#4e9a06"),Aa.toColor("#c4a000"),Aa.toColor("#3465a4"),Aa.toColor("#75507b"),Aa.toColor("#06989a"),Aa.toColor("#d3d7cf"),Aa.toColor("#555753"),Aa.toColor("#ef2929"),Aa.toColor("#8ae234"),Aa.toColor("#fce94f"),Aa.toColor("#729fcf"),Aa.toColor("#ad7fa8"),Aa.toColor("#34e2e2"),Aa.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],i=t[r/6%6|0],o=t[r%6];e.push({css:Us.toCss(n,i,o),rgba:Us.toRgba(n,i,o)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:Us.toCss(n,n,n),rgba:Us.toRgba(n,n,n)})}return e})()),mE=Aa.toColor("#ffffff"),dV=Aa.toColor("#000000"),lrr=Aa.toColor("#ffffff"),crr=dV,sV={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},A6n=mE,vIe=class extends Nn{constructor(e){super(),this._optionsService=e,this._contrastCache=new srr,this._halfContrastCache=new srr,this._onChangeColors=this._register(new ar),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:mE,background:dV,cursor:lrr,cursorAccent:crr,selectionForeground:void 0,selectionBackgroundTransparent:sV,selectionBackgroundOpaque:Go.blend(dV,sV),selectionInactiveBackgroundTransparent:sV,selectionInactiveBackgroundOpaque:Go.blend(dV,sV),scrollbarSliderBackground:Go.opacity(mE,.2),scrollbarSliderHoverBackground:Go.opacity(mE,.4),scrollbarSliderActiveBackground:Go.opacity(mE,.5),overviewRulerBorder:mE,ansi:fl.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=uo(e.foreground,mE),t.background=uo(e.background,dV),t.cursor=Go.blend(t.background,uo(e.cursor,lrr)),t.cursorAccent=Go.blend(t.background,uo(e.cursorAccent,crr)),t.selectionBackgroundTransparent=uo(e.selectionBackground,sV),t.selectionBackgroundOpaque=Go.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=uo(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Go.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?uo(e.selectionForeground,rrr):void 0,t.selectionForeground===rrr&&(t.selectionForeground=void 0),Go.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Go.opacity(t.selectionBackgroundTransparent,.3)),Go.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Go.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=uo(e.scrollbarSliderBackground,Go.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=uo(e.scrollbarSliderHoverBackground,Go.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=uo(e.scrollbarSliderActiveBackground,Go.opacity(t.foreground,.5)),t.overviewRulerBorder=uo(e.overviewRulerBorder,A6n),t.ansi=fl.slice(),t.ansi[0]=uo(e.black,fl[0]),t.ansi[1]=uo(e.red,fl[1]),t.ansi[2]=uo(e.green,fl[2]),t.ansi[3]=uo(e.yellow,fl[3]),t.ansi[4]=uo(e.blue,fl[4]),t.ansi[5]=uo(e.magenta,fl[5]),t.ansi[6]=uo(e.cyan,fl[6]),t.ansi[7]=uo(e.white,fl[7]),t.ansi[8]=uo(e.brightBlack,fl[8]),t.ansi[9]=uo(e.brightRed,fl[9]),t.ansi[10]=uo(e.brightGreen,fl[10]),t.ansi[11]=uo(e.brightYellow,fl[11]),t.ansi[12]=uo(e.brightBlue,fl[12]),t.ansi[13]=uo(e.brightMagenta,fl[13]),t.ansi[14]=uo(e.brightCyan,fl[14]),t.ansi[15]=uo(e.brightWhite,fl[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<r;n++)t.ansi[n+16]=uo(e.extendedAnsi[n],fl[n+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 t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];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()}}};vIe=Ja([vr(0,hh)],vIe);function uo(e,t){if(e!==void 0)try{return Aa.toColor(e)}catch{}return t}var P6n=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},L6n=class{constructor(){this._services=new P6n,this._services.set(EIe,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=ZEn(e).sort((o,a)=>o.index-a.index),n=[];for(let o of r){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);n.push(a)}let i=r.length>0?r[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},M6n={trace:0,debug:1,info:2,warn:3,error:4,off:5},I6n="xterm.js: ",bIe=class extends Nn{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),D6n=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=M6n[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":I6n)+t,...r)}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)}};bIe=Ja([vr(0,hh)],bIe);var D6n,urr=class extends Nn{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ar),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ar),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ar),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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 new 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,...r){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 n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let n=this._length+r.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));let n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+r,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},zn=3,zs=Object.freeze(new CV),Pue=0,BMe=2,pV=class wnr{constructor(t,r,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*zn);let i=r||dm.fromCharData([0,Drr,1,0]);for(let o=0;o<t;++o)this.setCell(o,i);this.length=t}get(t){let r=this._data[t*zn+0],n=r&2097151;return[this._data[t*zn+1],r&2097152?this._combined[t]:n?zC(n):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,r){this._data[t*zn+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*zn+0]=t|2097152|r[2]<<22):this._data[t*zn+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*zn+0]>>22}hasWidth(t){return this._data[t*zn+0]&12582912}getFg(t){return this._data[t*zn+1]}getBg(t){return this._data[t*zn+2]}hasContent(t){return this._data[t*zn+0]&4194303}getCodePoint(t){let r=this._data[t*zn+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*zn+0]&2097152}getString(t){let r=this._data[t*zn+0];return r&2097152?this._combined[t]:r&2097151?zC(r&2097151):""}isProtected(t){return this._data[t*zn+2]&536870912}loadCell(t,r){return Pue=t*zn,r.content=this._data[Pue+0],r.fg=this._data[Pue+1],r.bg=this._data[Pue+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*zn+0]=r.content,this._data[t*zn+1]=r.fg,this._data[t*zn+2]=r.bg}setCellFromCodepoint(t,r,n,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*zn+0]=r|n<<22,this._data[t*zn+1]=i.fg,this._data[t*zn+2]=i.bg}addCodepointToCell(t,r,n){let i=this._data[t*zn+0];i&2097152?this._combined[t]+=zC(r):i&2097151?(this._combined[t]=zC(i&2097151)+zC(r),i&=-2097152,i|=2097152):i=r|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[t*zn+0]=i}insertCells(t,r,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length-t){let i=new dm;for(let o=this.length-t-r-1;o>=0;--o)this.setCell(t+r+o,this.loadCell(t+o,i));for(let o=0;o<r;++o)this.setCell(t+o,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,r,n){if(t%=this.length,r<this.length-t){let i=new dm;for(let o=0;o<this.length-t-r;++o)this.setCell(t+o,this.loadCell(t+r+o,i));for(let o=this.length-r;o<this.length;++o)this.setCell(o,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,r,n,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.setCell(t++,n)}resize(t,r){if(t===this.length)return this._data.length*4*BMe<this._data.buffer.byteLength;let n=t*zn;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,r)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let s=parseInt(i[a],10);s>=t&&delete this._combined[s]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let s=parseInt(o[a],10);s>=t&&delete this._extendedAttrs[s]}}return this.length=t,n*4*BMe<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*BMe<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new wnr(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*zn+0]&4194303)return t+(this._data[t*zn+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*zn+0]&4194303||this._data[t*zn+2]&50331648)return t+(this._data[t*zn+0]>>22);return 0}copyCellsFrom(t,r,n,i,o){let a=t._data;if(o)for(let l=i-1;l>=0;l--){for(let u=0;u<zn;u++)this._data[(n+l)*zn+u]=a[(r+l)*zn+u];a[(r+l)*zn+2]&268435456&&(this._extendedAttrs[n+l]=t._extendedAttrs[r+l])}else for(let l=0;l<i;l++){for(let u=0;u<zn;u++)this._data[(n+l)*zn+u]=a[(r+l)*zn+u];a[(r+l)*zn+2]&268435456&&(this._extendedAttrs[n+l]=t._extendedAttrs[r+l])}let s=Object.keys(t._combined);for(let l=0;l<s.length;l++){let u=parseInt(s[l],10);u>=r&&(this._combined[u-r+n]=t._combined[u])}}translateToString(t,r,n,i){r=r??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;r<n;){let a=this._data[r*zn+0],s=a&2097151,l=a&2097152?this._combined[r]:s?zC(s):UC;if(o+=l,i)for(let u=0;u<l.length;++u)i.push(r);r+=a>>22||1}return i&&i.push(r),o}};function O6n(e,t,r,n,i,o){let a=[];for(let s=0;s<e.length-1;s++){let l=s,u=e.get(++l);if(!u.isWrapped)continue;let h=[e.get(s)];for(;l<e.length&&u.isWrapped;)h.push(u),u=e.get(++l);if(!o&&n>=s&&n<l){s+=h.length-1;continue}let f=0,d=SV(h,f,t),p=1,m=0;for(;p<h.length;){let y=SV(h,p,t),v=y-m,b=r-d,x=Math.min(v,b);h[f].copyCellsFrom(h[p],m,d,x,!1),d+=x,d===r&&(f++,d=0),m+=x,m===y&&(p++,m=0),d===0&&f!==0&&h[f-1].getWidth(r-1)===2&&(h[f].copyCellsFrom(h[f-1],r-1,d++,1,!1),h[f-1].setCell(r-1,i))}h[f].replaceCells(d,r,i);let g=0;for(let y=h.length-1;y>0&&(y>f||h[y].getTrimmedLength()===0);y--)g++;g>0&&(a.push(s+h.length-g),a.push(g)),s+=h.length-1}return a}function N6n(e,t){let r=[],n=0,i=t[n],o=0;for(let a=0;a<e.length;a++)if(i===a){let s=t[++n];e.onDeleteEmitter.fire({index:a-o,amount:s}),a+=s-1,o+=s,i=t[++n]}else r.push(a);return{layout:r,countRemoved:o}}function B6n(e,t){let r=[];for(let n=0;n<t.length;n++)r.push(e.get(t[n]));for(let n=0;n<r.length;n++)e.set(n,r[n]);e.length=t.length}function F6n(e,t,r){let n=[],i=e.map((l,u)=>SV(e,u,t)).reduce((l,u)=>l+u),o=0,a=0,s=0;for(;s<i;){if(i-s<r){n.push(i-s);break}o+=r;let l=SV(e,a,t);o>l&&(o-=l,a++);let u=e[a].getWidth(o-1)===2;u&&o--;let h=u?r-1:r;n.push(h),s+=h}return n}function SV(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,i=e[t+1].getWidth(0)===2;return n&&i?r-1:r}var _nr=class knr{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=knr._nextId++,this._onDispose=this.register(new ar),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),bE(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};_nr._nextId=1;var $6n=_nr,pl={},gE=pl.B;pl[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};pl.A={"#":"\xA3"};pl.B=void 0;pl[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};pl.C=pl[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};pl.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};pl.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};pl.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};pl.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};pl.E=pl[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};pl.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};pl.H=pl[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};pl["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};var hrr=4294967295,frr=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=zs.clone(),this.savedCharset=gE,this.markers=[],this._nullCell=dm.fromCharData([0,Drr,1,0]),this._whitespaceCell=dm.fromCharData([0,UC,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Yue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new urr(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 Uue),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 Uue),this._whitespaceCell}getBlankLine(e,t){return new pV(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>hrr?hrr:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=zs);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 urr(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(zs),n=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)n+=+this.lines.get(a).resize(e,r);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)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 pV(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new pV(e,r)));else for(let a=this._rows;a>t;a--)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 a=this.lines.length-i;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),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 o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.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 r=this._optionsService.rawOptions.reflowCursorLine,n=O6n(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(zs),r);if(n.length>0){let i=N6n(this.lines,n);B6n(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let n=this.getNullCell(zs),i=r;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new pV(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(zs),i=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let s=this.lines.get(a);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let l=[s];for(;s.isWrapped&&a>0;)s=this.lines.get(--a),l.unshift(s);if(!r){let x=this.ybase+this.y;if(x>=a&&x<a+l.length)continue}let u=l[l.length-1].getTrimmedLength(),h=F6n(l,this._cols,e),f=h.length-l.length,d;this.ybase===0&&this.y!==this.lines.length-1?d=Math.max(0,this.y-this.lines.maxLength+f):d=Math.max(0,this.lines.length-this.lines.maxLength+f);let p=[];for(let x=0;x<f;x++){let S=this.getBlankLine(zs,!0);p.push(S)}p.length>0&&(i.push({start:a+l.length+o,newLines:p}),o+=p.length),l.push(...p);let m=h.length-1,g=h[m];g===0&&(m--,g=h[m]);let y=l.length-f-1,v=u;for(;y>=0;){let x=Math.min(v,g);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[y],v-x,g-x,x,!0),g-=x,g===0&&(m--,g=h[m]),v-=x,v===0){y--;let S=Math.max(y,0);v=SV(l,S,this._cols)}}for(let x=0;x<l.length;x++)h[x]<e&&l[x].setCell(h[x],n);let b=f-d;for(;b-- >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+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f,this.ybase+t-1)}if(i.length>0){let a=[],s=[];for(let g=0;g<this.lines.length;g++)s.push(this.lines.get(g));let l=this.lines.length,u=l-1,h=0,f=i[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let d=0;for(let g=Math.min(this.lines.maxLength-1,l+o-1);g>=0;g--)if(f&&f.start>u+d){for(let y=f.newLines.length-1;y>=0;y--)this.lines.set(g--,f.newLines[y]);g++,a.push({index:u+1,amount:f.newLines.length}),d+=f.newLines.length,f=i[++h]}else this.lines.set(g,s[u--]);let p=0;for(let g=a.length-1;g>=0;g--)a[g].index+=p,this.lines.onInsertEmitter.fire(a[g]),p+=a[g].amount;let m=Math.max(0,l+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,r=0,n){let i=this.lines.get(e);return i?i.translateToString(t,r,n):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(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 $6n(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},z6n=class extends Nn{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ar),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 frr(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new frr(!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)}},Enr=2,Rnr=1,xIe=class extends Nn{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ar),this.onResize=this._onResize.event,this._onScroll=this._register(new ar),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Enr),this.rows=Math.max(e.rawOptions.rows||0,Rnr),this.buffers=this._register(new z6n(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=r.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let i=r.ybase+r.scrollTop,o=r.ybase+r.scrollBottom;if(r.scrollTop===0){let a=r.lines.isFull;o===r.lines.length-1?a?r.lines.recycle().copyFrom(n):r.lines.push(n.clone()):r.lines.splice(o+1,0,n.clone()),a?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let a=o-i+1;r.lines.shiftElements(i+1,a-1,-1),r.lines.set(o,n.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let n=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),n!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};xIe=Ja([vr(0,hh)],xIe);var tO={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:jue,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},U6n=["normal","bold","100","200","300","400","500","600","700","800","900"],H6n=class extends Nn{constructor(e){super(),this._onOptionChange=this._register(new ar),this.onOptionChange=this._onOptionChange.event;let t={...tO};for(let r in e)if(r in t)try{let n=e[r];t[r]=this._sanitizeAndValidateOption(r,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(qo(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in tO))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,n)=>{if(!(r in tO))throw new Error(`No option with key "${r}"`);n=this._sanitizeAndValidateOption(r,n),this.rawOptions[r]!==n&&(this.rawOptions[r]=n,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let n={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=tO[e]),!W6n(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=tO[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=U6n.includes(t)?t:tO[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new 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 new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function W6n(e){return e==="block"||e==="underline"||e==="bar"}function mV(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let n in e)r[n]=t<=1?e[n]:e[n]&&mV(e[n],t-1);return r}var drr=Object.freeze({insertMode:!1}),prr=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),TIe=class extends Nn{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ar),this.onData=this._onData.event,this._onUserInput=this._register(new ar),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ar),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ar),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=mV(drr),this.decPrivateModes=mV(prr)}reset(){this.modes=mV(drr),this.decPrivateModes=mV(prr)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.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(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};TIe=Ja([vr(0,uh),vr(1,$rr),vr(2,hh)],TIe);var mrr={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 FMe(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var $Me=String.fromCharCode,grr={DEFAULT:e=>{let t=[FMe(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${$Me(t[0])}${$Me(t[1])}${$Me(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${FMe(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${FMe(e,!0)};${e.x};${e.y}${t}`}},SIe=class extends Nn{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ar),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(mrr))this.addProtocol(n,mrr[n]);for(let n of Object.keys(grr))this.addEncoding(n,grr[n]);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 new 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 new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let n=t/r,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+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,r){if(r){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)}};SIe=Ja([vr(0,uh),vr(1,TE),vr(2,hh)],SIe);var zMe=[[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]],V6n=[[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]],dl;function G6n(e,t){let r=0,n=t.length-1,i;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(i=r+n>>1,e>t[i][1])r=i+1;else if(e<t[i][0])n=i-1;else return!0;return!1}var q6n=class{constructor(){if(this.version="6",!dl){dl=new Uint8Array(65536),dl.fill(1),dl[0]=0,dl.fill(0,1,32),dl.fill(0,127,160),dl.fill(2,4352,4448),dl[9001]=2,dl[9002]=2,dl.fill(2,11904,42192),dl[12351]=1,dl.fill(2,44032,55204),dl.fill(2,63744,64256),dl.fill(2,65040,65050),dl.fill(2,65072,65136),dl.fill(2,65280,65377),dl.fill(2,65504,65511);for(let e=0;e<zMe.length;++e)dl.fill(0,zMe[e][0],zMe[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?dl[e]:G6n(e,V6n)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let i=yE.extractWidth(t);i===0?n=!1:i>r&&(r=i)}return yE.createPropertyValue(0,r,n)}},yE=class zue{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ar,this.onChange=this._onChange.event;let t=new q6n;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,i=t.length;for(let o=0;o<i;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=i)return r+this.wcwidth(a);let u=t.charCodeAt(o);56320<=u&&u<=57343?a=(a-55296)*1024+u-56320+65536:r+=this.wcwidth(u)}let s=this.charProperties(a,n),l=zue.extractWidth(s);zue.extractShouldJoin(s)&&(l-=zue.extractWidth(n)),r+=l,n=s}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},j6n=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 yrr(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var lV=2147483647,Y6n=256,Anr=class CIe{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>Y6n)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new CIe;if(!t.length)return r;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let i=t[n];if(Array.isArray(i))for(let o=0;o<i.length;++o)r.addSubParam(i[o]);else r.addParam(i)}return r}clone(){let t=new CIe(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 t=[];for(let r=0;r<this.length;++r){t.push(this.params[r]);let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>lV?lV:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>lV?lV:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-r>0?this._subParams.subarray(r,n):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&(t[r]=this._subParams.slice(n,i))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[r-1];n[r-1]=~i?Math.min(i*10+t,lV):t}},cV=[],K6n=class{constructor(){this._state=0,this._active=cV,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=cV}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=cV,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||cV,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Xue(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){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&&r-t>0&&this._put(e,t,r)}}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 r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].end(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=cV,this._id=-1,this._state=0}}},Dd=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Xue(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},uV=[],X6n=class{constructor(){this._handlers=Object.create(null),this._active=uV,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=uV}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=uV,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||uV,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Xue(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].unhook(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=uV,this._ident=0}},gV=new Anr;gV.addParam(0);var vrr=class{constructor(e){this._handler=e,this._data="",this._params=gV,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():gV,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Xue(e,t,r),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(r=>(this._params=gV,this._data="",this._hitLimit=!1,r));return this._params=gV,this._data="",this._hitLimit=!1,t}},Z6n=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,n){this.table[t<<8|e]=r<<4|n}addMany(e,t,r,n){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=r<<4|n}},fm=160,Q6n=(function(){let e=new Z6n(4095),t=Array.apply(null,Array(256)).map((s,l)=>l),r=(s,l)=>t.slice(s,l),n=r(32,127),i=r(0,24);i.push(25),i.push.apply(i,r(28,32));let o=r(0,14),a;e.setDefault(1,0),e.addMany(n,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(r(128,144),a,3,0),e.addMany(r(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,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(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,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(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(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(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(fm,0,2,0),e.add(fm,8,5,8),e.add(fm,6,0,6),e.add(fm,11,0,11),e.add(fm,13,13,13),e})(),J6n=class extends Nn{constructor(e=Q6n){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 Anr,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(qo(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new K6n),this._dcsParser=this._register(new X6n),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let o=e.intermediates.charCodeAt(i);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=n,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let n=this._escHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let n=this._csiHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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,r,n,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(e,t,r){let n=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let s=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&l>-1){for(;l>=0&&(a=s[l](this._params),a!==!0);l--)if(a instanceof Promise)return this._parseStack.handlerPos=l,a}this._parseStack.handlers=[];break;case 4:if(r===!1&&l>-1){for(;l>=0&&(a=s[l](),a!==!0);l--)if(a instanceof Promise)return this._parseStack.handlerPos=l,a}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,r),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,r),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let s=o;s<t;++s){switch(n=e[s],i=this._transitions.table[this.currentState<<8|(n<160?n:fm)],i>>4){case 2:for(let d=s+1;;++d){if(d>=t||(n=e[d])<32||n>126&&n<fm){this._printHandler(e,s,d),s=d-1;break}if(++d>=t||(n=e[d])<32||n>126&&n<fm){this._printHandler(e,s,d),s=d-1;break}if(++d>=t||(n=e[d])<32||n>126&&n<fm){this._printHandler(e,s,d),s=d-1;break}if(++d>=t||(n=e[d])<32||n>126&&n<fm){this._printHandler(e,s,d),s=d-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|n],u=l?l.length-1:-1;for(;u>=0&&(a=l[u](this._params),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(3,l,u,i,s),a;u<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++s<t&&(n=e[s])>47&&n<60);s--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],f=h?h.length-1:-1;for(;f>=0&&(a=h[f](),a!==!0);f--)if(a instanceof Promise)return this._preserveStack(4,h,f,i,s),a;f<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let d=s+1;;++d)if(d>=t||(n=e[d])===24||n===26||n===27||n>127&&n<fm){this._dcsParser.put(e,s,d),s=d-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,i,s),a;n===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 d=s+1;;d++)if(d>=t||(n=e[d])<32||n>127&&n<fm){this._oscParser.put(e,s,d),s=d-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,i,s),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},eAn=/^([\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})$/,tAn=/^[\da-f]+$/;function brr(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=eAn.exec(t);if(r){let n=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/n*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/n*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),tAn.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,n=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(t.slice(r*i,r*i+r),16);n[i]=r===1?o<<4:r===2?o:r===3?o>>4:o>>8}return n}}function UMe(e,t){let r=e.toString(16),n=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function rAn(e,t=16){let[r,n,i]=e;return`rgb:${UMe(r,t)}/${UMe(n,t)}/${UMe(i,t)}`}var nAn={"(":0,")":1,"*":2,"+":3,"-":1,".":2},$C=131072,xrr=10;function Trr(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 Srr=5e3,Crr=0,iAn=class extends Nn{constructor(e,t,r,n,i,o,a,s,l=new J6n){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=n,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=s,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new KEn,this._utf8Decoder=new XEn,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=zs.clone(),this._eraseAttrDataInternal=zs.clone(),this._onRequestBell=this._register(new ar),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ar),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ar),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ar),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ar),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ar),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ar),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ar),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ar),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ar),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ar),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ar),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ar),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 wIe(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(u=>this._activeBuffer=u.activeBuffer)),this._parser.setCsiHandlerFallback((u,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(u),params:h.toArray()})}),this._parser.setEscHandlerFallback(u=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(u)})}),this._parser.setExecuteHandlerFallback(u=>{this._logService.debug("Unknown EXECUTE code: ",{code:u})}),this._parser.setOscHandlerFallback((u,h,f)=>{this._logService.debug("Unknown OSC code: ",{identifier:u,action:h,data:f})}),this._parser.setDcsHandlerFallback((u,h,f)=>{h==="HOOK"&&(f=f.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(u),action:h,payload:f})}),this._parser.setPrintHandler((u,h,f)=>this.print(u,h,f)),this._parser.registerCsiHandler({final:"@"},u=>this.insertChars(u)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},u=>this.scrollLeft(u)),this._parser.registerCsiHandler({final:"A"},u=>this.cursorUp(u)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},u=>this.scrollRight(u)),this._parser.registerCsiHandler({final:"B"},u=>this.cursorDown(u)),this._parser.registerCsiHandler({final:"C"},u=>this.cursorForward(u)),this._parser.registerCsiHandler({final:"D"},u=>this.cursorBackward(u)),this._parser.registerCsiHandler({final:"E"},u=>this.cursorNextLine(u)),this._parser.registerCsiHandler({final:"F"},u=>this.cursorPrecedingLine(u)),this._parser.registerCsiHandler({final:"G"},u=>this.cursorCharAbsolute(u)),this._parser.registerCsiHandler({final:"H"},u=>this.cursorPosition(u)),this._parser.registerCsiHandler({final:"I"},u=>this.cursorForwardTab(u)),this._parser.registerCsiHandler({final:"J"},u=>this.eraseInDisplay(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},u=>this.eraseInDisplay(u,!0)),this._parser.registerCsiHandler({final:"K"},u=>this.eraseInLine(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},u=>this.eraseInLine(u,!0)),this._parser.registerCsiHandler({final:"L"},u=>this.insertLines(u)),this._parser.registerCsiHandler({final:"M"},u=>this.deleteLines(u)),this._parser.registerCsiHandler({final:"P"},u=>this.deleteChars(u)),this._parser.registerCsiHandler({final:"S"},u=>this.scrollUp(u)),this._parser.registerCsiHandler({final:"T"},u=>this.scrollDown(u)),this._parser.registerCsiHandler({final:"X"},u=>this.eraseChars(u)),this._parser.registerCsiHandler({final:"Z"},u=>this.cursorBackwardTab(u)),this._parser.registerCsiHandler({final:"`"},u=>this.charPosAbsolute(u)),this._parser.registerCsiHandler({final:"a"},u=>this.hPositionRelative(u)),this._parser.registerCsiHandler({final:"b"},u=>this.repeatPrecedingCharacter(u)),this._parser.registerCsiHandler({final:"c"},u=>this.sendDeviceAttributesPrimary(u)),this._parser.registerCsiHandler({prefix:">",final:"c"},u=>this.sendDeviceAttributesSecondary(u)),this._parser.registerCsiHandler({final:"d"},u=>this.linePosAbsolute(u)),this._parser.registerCsiHandler({final:"e"},u=>this.vPositionRelative(u)),this._parser.registerCsiHandler({final:"f"},u=>this.hVPosition(u)),this._parser.registerCsiHandler({final:"g"},u=>this.tabClear(u)),this._parser.registerCsiHandler({final:"h"},u=>this.setMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"h"},u=>this.setModePrivate(u)),this._parser.registerCsiHandler({final:"l"},u=>this.resetMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"l"},u=>this.resetModePrivate(u)),this._parser.registerCsiHandler({final:"m"},u=>this.charAttributes(u)),this._parser.registerCsiHandler({final:"n"},u=>this.deviceStatus(u)),this._parser.registerCsiHandler({prefix:"?",final:"n"},u=>this.deviceStatusPrivate(u)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},u=>this.softReset(u)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},u=>this.setCursorStyle(u)),this._parser.registerCsiHandler({final:"r"},u=>this.setScrollRegion(u)),this._parser.registerCsiHandler({final:"s"},u=>this.saveCursor(u)),this._parser.registerCsiHandler({final:"t"},u=>this.windowOptions(u)),this._parser.registerCsiHandler({final:"u"},u=>this.restoreCursor(u)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},u=>this.insertColumns(u)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},u=>this.deleteColumns(u)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},u=>this.selectProtected(u)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},u=>this.requestMode(u,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},u=>this.requestMode(u,!1)),this._parser.setExecuteHandler(Ft.BEL,()=>this.bell()),this._parser.setExecuteHandler(Ft.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ft.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Ft.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ft.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Ft.BS,()=>this.backspace()),this._parser.setExecuteHandler(Ft.HT,()=>this.tab()),this._parser.setExecuteHandler(Ft.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Ft.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Fue.IND,()=>this.index()),this._parser.setExecuteHandler(Fue.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Fue.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Dd(u=>(this.setTitle(u),this.setIconName(u),!0))),this._parser.registerOscHandler(1,new Dd(u=>this.setIconName(u))),this._parser.registerOscHandler(2,new Dd(u=>this.setTitle(u))),this._parser.registerOscHandler(4,new Dd(u=>this.setOrReportIndexedColor(u))),this._parser.registerOscHandler(8,new Dd(u=>this.setHyperlink(u))),this._parser.registerOscHandler(10,new Dd(u=>this.setOrReportFgColor(u))),this._parser.registerOscHandler(11,new Dd(u=>this.setOrReportBgColor(u))),this._parser.registerOscHandler(12,new Dd(u=>this.setOrReportCursorColor(u))),this._parser.registerOscHandler(104,new Dd(u=>this.restoreIndexedColor(u))),this._parser.registerOscHandler(110,new Dd(u=>this.restoreFgColor(u))),this._parser.registerOscHandler(111,new Dd(u=>this.restoreBgColor(u))),this._parser.registerOscHandler(112,new Dd(u=>this.restoreCursorColor(u))),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 u in pl)this._parser.registerEscHandler({intermediates:"(",final:u},()=>this.selectCharset("("+u)),this._parser.registerEscHandler({intermediates:")",final:u},()=>this.selectCharset(")"+u)),this._parser.registerEscHandler({intermediates:"*",final:u},()=>this.selectCharset("*"+u)),this._parser.registerEscHandler({intermediates:"+",final:u},()=>this.selectCharset("+"+u)),this._parser.registerEscHandler({intermediates:"-",final:u},()=>this.selectCharset("-"+u)),this._parser.registerEscHandler({intermediates:".",final:u},()=>this.selectCharset("."+u)),this._parser.registerEscHandler({intermediates:"/",final:u},()=>this.selectCharset("/"+u));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(u=>(this._logService.error("Parsing error: ",u),u)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new vrr((u,h)=>this.requestStatusString(u,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),Srr))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Srr} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,n=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>$C&&(o=this._parseStack.position+$C)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,u=>String.fromCharCode(u)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(u=>u.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<$C&&(this._parseBuffer=new Uint32Array(Math.min(e.length,$C))),a||this._dirtyRowTracker.clearRange(),e.length>$C)for(let u=o;u<e.length;u+=$C){let h=u+$C<e.length?u+$C:e.length,f=typeof e=="string"?this._stringDecoder.decode(e.substring(u,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(u,h),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,f))return this._preserveStack(n,i,f,u),this._logSlowResolvingAsync(r),r}else if(!a){let u=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,i,u,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,r){let n,i,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,h=this._curAttrData,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&f.getWidth(this._activeBuffer.x-1)===2&&f.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let d=this._parser.precedingJoinState;for(let p=t;p<r;++p){if(n=e[p],n<127&&o){let v=o[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let m=this._unicodeService.charProperties(n,d);i=yE.extractWidth(m);let g=yE.extractShouldJoin(m),y=g?yE.extractWidth(d):0;if(d=m,a&&this._onA11yChar.fire(zC(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-y>s){if(l){let v=f,b=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&f instanceof pV&&f.copyCellsFrom(v,b,0,y,!1);b<s;)v.setCellFromCodepoint(b++,0,1,h)}else if(this._activeBuffer.x=s-1,i===2)continue}if(g&&this._activeBuffer.x){let v=f.getWidth(this._activeBuffer.x-1)?1:2;f.addCodepointToCell(this._activeBuffer.x-v,n,i);for(let b=i-y;--b>=0;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(u&&(f.insertCells(this._activeBuffer.x,i-y,this._activeBuffer.getNullCell(h)),f.getWidth(s-1)===2&&f.setCellFromCodepoint(s-1,0,1,h)),f.setCellFromCodepoint(this._activeBuffer.x++,n,i,h),i>0)for(;--i;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=d,this._activeBuffer.x<s&&r-t>0&&f.getWidth(this._activeBuffer.x)===0&&!f.hasContent(this._activeBuffer.x)&&f.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>Trr(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new vrr(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Dd(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,r,n=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}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);break}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 r=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(i-1,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}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 r=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(r,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}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(zs));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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=e.params[0]||1,n=yE.extractWidth(t),i=this._activeBuffer.x-n,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),a=new Uint32Array(o.length*r),s=0;for(let u=0;u<o.length;){let h=o.codePointAt(u)||0;a[s++]=h,u+=h>65535?2:1}let l=s;for(let u=1;u<r;++u)a.copyWithin(l,0,s),l+=s;return this.print(a,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Ft.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Ft.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Ft.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Ft.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Ft.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;break}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,gE),this._charsetService.setgCharset(1,gE),this._charsetService.setgCharset(2,gE),this._charsetService.setgCharset(3,gE);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;break}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;break}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);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:s,cols:l}=this._bufferService,{active:u,alt:h}=s,f=this._optionsService.rawOptions,d=(g,y)=>(a.triggerDataEvent(`${Ft.ESC}[${t?"":"?"}${g};${y}$y`),!0),p=g=>g?1:2,m=e.params[0];return t?m===2?d(m,4):m===4?d(m,p(a.modes.insertMode)):m===12?d(m,3):m===20?d(m,p(f.convertEol)):d(m,0):m===1?d(m,p(n.applicationCursorKeys)):m===3?d(m,f.windowOptions.setWinLines?l===80?2:l===132?1:0:0):m===6?d(m,p(n.origin)):m===7?d(m,p(n.wraparound)):m===8?d(m,3):m===9?d(m,p(i==="X10")):m===12?d(m,p(f.cursorBlink)):m===25?d(m,p(!a.isCursorHidden)):m===45?d(m,p(n.reverseWraparound)):m===66?d(m,p(n.applicationKeypad)):m===67?d(m,4):m===1e3?d(m,p(i==="VT200")):m===1002?d(m,p(i==="DRAG")):m===1003?d(m,p(i==="ANY")):m===1004?d(m,p(n.sendFocus)):m===1005?d(m,4):m===1006?d(m,p(o==="SGR")):m===1015?d(m,4):m===1016?d(m,p(o==="SGR_PIXELS")):m===1048?d(m,1):m===47||m===1047||m===1049?d(m,p(u===h)):m===2004?d(m,p(n.bracketedPasteMode)):m===2026?d(m,p(n.synchronizedOutput)):d(m,0)}_updateAttrColor(e,t,r,n,i){return t===2?(e|=50331648,e&=-16777216,e|=CV.fromColorRGB([r,n,i])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let n=[0,0,-1,0,0,0],i=0,o=0;do{if(n[o+i]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),s=0;do n[1]===5&&(i=1),n[o+s+1+i]=a[s];while(++s<a.length&&s+o+1+i<n.length);break}if(n[1]===5&&o+i>=2||n[1]===2&&o+i>=5)break;n[1]&&(i=1)}while(++o+t<e.length&&o+i<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:r.fg=this._updateAttrColor(r.fg,n[1],n[3],n[4],n[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,n[1],n[3],n[4],n[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,n[1],n[3],n[4],n[5])}return o}_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=zs.fg,e.bg=zs.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,r,n=this._curAttrData;for(let i=0;i<t;i++)r=e.params[i],r>=30&&r<=37?(n.fg&=-50331904,n.fg|=16777216|r-30):r>=40&&r<=47?(n.bg&=-50331904,n.bg|=16777216|r-40):r>=90&&r<=97?(n.fg&=-50331904,n.fg|=16777216|r-90|8):r>=100&&r<=107?(n.bg&=-50331904,n.bg|=16777216|r-100|8):r===0?this._processSGR0(n):r===1?n.fg|=134217728:r===3?n.bg|=67108864:r===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,n)):r===5?n.fg|=536870912:r===7?n.fg|=67108864:r===8?n.fg|=1073741824:r===9?n.fg|=2147483648:r===2?n.bg|=134217728:r===21?this._processUnderline(2,n):r===22?(n.fg&=-134217729,n.bg&=-134217729):r===23?n.bg&=-67108865:r===24?(n.fg&=-268435457,this._processUnderline(0,n)):r===25?n.fg&=-536870913:r===27?n.fg&=-67108865:r===28?n.fg&=-1073741825:r===29?n.fg&=2147483647:r===39?(n.fg&=-67108864,n.fg|=zs.fg&16777215):r===49?(n.bg&=-67108864,n.bg|=zs.bg&16777215):r===38||r===48||r===58?i+=this._extractColor(e,i,n):r===53?n.bg|=1073741824:r===55?n.bg&=-1073741825:r===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):r===100?(n.fg&=-67108864,n.fg|=zs.fg&16777215,n.bg&=-67108864,n.bg|=zs.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Ft.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ft.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ft.ESC}[?${t};${r}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}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=zs.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";break}let r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Trr(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(`${Ft.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>xrr&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>xrr&&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());break}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=[],r=e.split(";");for(;r.length>1;){let n=r.shift(),i=r.shift();if(/^\d+$/.exec(n)){let o=parseInt(n);if(wrr(o))if(i==="?")t.push({type:0,index:o});else{let a=brr(i);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(r,n):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),n,i=r.findIndex(o=>o.startsWith("id="));return i!==-1&&(n=r[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,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 r=e.split(";");for(let n=0;n<r.length&&!(t>=this._specialColors.length);++n,++t)if(r[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=brr(r[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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=[],r=e.split(";");for(let n=0;n<r.length;++n)if(/^\d+$/.exec(r[n])){let i=parseInt(r[n]);wrr(i)&&t.push({type:2,index:i})}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,gE),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(nAn[e[0]],pl[e[1]]||gE),!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=zs.clone(),this._eraseAttrDataInternal=zs.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 dm;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let r=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(r);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=a=>(this._coreService.triggerDataEvent(`${Ft.ESC}${a}${Ft.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},wIe=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&&(Crr=e,e=t,t=Crr),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};wIe=Ja([vr(0,uh)],wIe);function wrr(e){return 0<=e&&e<256}var oAn=5e7,_rr=12,aAn=50,sAn=class extends Nn{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 ar),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>oAn)throw new 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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,t);if(i){let a=s=>performance.now()-r>=_rr?setTimeout(()=>this._innerWrite(0,s)):this._innerWrite(r,s);i.catch(s=>(queueMicrotask(()=>{throw s}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-r>=_rr)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>aAn&&(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()}},_Ie=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 s=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(l,s)),this._dataByLinkId.set(l.id,l),l.id}let r=e,n=this._getEntryIdKey(r),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);r.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(r,n))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};_Ie=Ja([vr(0,uh)],_Ie);var krr=!1,lAn=class extends Nn{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new nO),this._onBinary=this._register(new ar),this.onBinary=this._onBinary.event,this._onData=this._register(new ar),this.onData=this._onData.event,this._onLineFeed=this._register(new ar),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ar),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ar),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ar),this._instantiationService=new L6n,this.optionsService=this._register(new H6n(e)),this._instantiationService.setService(hh,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(xIe)),this._instantiationService.setService(uh,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bIe)),this._instantiationService.setService($rr,this._logService),this.coreService=this._register(this._instantiationService.createInstance(TIe)),this._instantiationService.setService(TE,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(SIe)),this._instantiationService.setService(Frr,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(yE)),this._instantiationService.setService(e3n,this.unicodeService),this._charsetService=this._instantiationService.createInstance(j6n),this._instantiationService.setService(JEn,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_Ie),this._instantiationService.setService(zrr,this._oscLinkService),this._inputHandler=this._register(new iAn(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Hc.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Hc.forward(this._bufferService.onResize,this._onResize)),this._register(Hc.forward(this.coreService.onData,this._onData)),this._register(Hc.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 sAn((t,r)=>this._inputHandler.parse(t,r))),this._register(Hc.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ar),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&&!krr&&(this._logService.warn("writeSync is unreliable and will be removed soon."),krr=!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,Enr),t=Math.max(t,Rnr),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(yrr.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(yrr(this._bufferService),!1))),this._windowsWrappingHeuristics.value=qo(()=>{for(let t of e)t.dispose()})}}},cAn={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 uAn(e,t,r,n){let i={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=Ft.ESC+"OA":i.key=Ft.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=Ft.ESC+"OD":i.key=Ft.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=Ft.ESC+"OC":i.key=Ft.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=Ft.ESC+"OB":i.key=Ft.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":Ft.DEL,e.altKey&&(i.key=Ft.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Ft.ESC+"[Z";break}i.key=Ft.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Ft.ESC+Ft.CR:Ft.CR,i.cancel=!0;break;case 27:i.key=Ft.ESC,e.altKey&&(i.key=Ft.ESC+Ft.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;o?i.key=Ft.ESC+"[1;"+(o+1)+"D":t?i.key=Ft.ESC+"OD":i.key=Ft.ESC+"[D";break;case 39:if(e.metaKey)break;o?i.key=Ft.ESC+"[1;"+(o+1)+"C":t?i.key=Ft.ESC+"OC":i.key=Ft.ESC+"[C";break;case 38:if(e.metaKey)break;o?i.key=Ft.ESC+"[1;"+(o+1)+"A":t?i.key=Ft.ESC+"OA":i.key=Ft.ESC+"[A";break;case 40:if(e.metaKey)break;o?i.key=Ft.ESC+"[1;"+(o+1)+"B":t?i.key=Ft.ESC+"OB":i.key=Ft.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Ft.ESC+"[2~");break;case 46:o?i.key=Ft.ESC+"[3;"+(o+1)+"~":i.key=Ft.ESC+"[3~";break;case 36:o?i.key=Ft.ESC+"[1;"+(o+1)+"H":t?i.key=Ft.ESC+"OH":i.key=Ft.ESC+"[H";break;case 35:o?i.key=Ft.ESC+"[1;"+(o+1)+"F":t?i.key=Ft.ESC+"OF":i.key=Ft.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Ft.ESC+"[5;"+(o+1)+"~":i.key=Ft.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Ft.ESC+"[6;"+(o+1)+"~":i.key=Ft.ESC+"[6~";break;case 112:o?i.key=Ft.ESC+"[1;"+(o+1)+"P":i.key=Ft.ESC+"OP";break;case 113:o?i.key=Ft.ESC+"[1;"+(o+1)+"Q":i.key=Ft.ESC+"OQ";break;case 114:o?i.key=Ft.ESC+"[1;"+(o+1)+"R":i.key=Ft.ESC+"OR";break;case 115:o?i.key=Ft.ESC+"[1;"+(o+1)+"S":i.key=Ft.ESC+"OS";break;case 116:o?i.key=Ft.ESC+"[15;"+(o+1)+"~":i.key=Ft.ESC+"[15~";break;case 117:o?i.key=Ft.ESC+"[17;"+(o+1)+"~":i.key=Ft.ESC+"[17~";break;case 118:o?i.key=Ft.ESC+"[18;"+(o+1)+"~":i.key=Ft.ESC+"[18~";break;case 119:o?i.key=Ft.ESC+"[19;"+(o+1)+"~":i.key=Ft.ESC+"[19~";break;case 120:o?i.key=Ft.ESC+"[20;"+(o+1)+"~":i.key=Ft.ESC+"[20~";break;case 121:o?i.key=Ft.ESC+"[21;"+(o+1)+"~":i.key=Ft.ESC+"[21~";break;case 122:o?i.key=Ft.ESC+"[23;"+(o+1)+"~":i.key=Ft.ESC+"[23~";break;case 123:o?i.key=Ft.ESC+"[24;"+(o+1)+"~":i.key=Ft.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=Ft.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Ft.DEL:e.keyCode===219?i.key=Ft.ESC:e.keyCode===220?i.key=Ft.FS:e.keyCode===221&&(i.key=Ft.GS);else if((!r||n)&&e.altKey&&!e.metaKey){let a=cAn[e.keyCode]?.[e.shiftKey?1:0];if(a)i.key=Ft.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let s=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(s);e.shiftKey&&(l=l.toUpperCase()),i.key=Ft.ESC+l}else if(e.keyCode===32)i.key=Ft.ESC+(e.ctrlKey?Ft.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let s=e.code.slice(3,4);e.shiftKey||(s=s.toLowerCase()),i.key=Ft.ESC+s,i.cancel=!0}}else r&&!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=Ft.US),e.key==="@"&&(i.key=Ft.NUL));break}return i}var ps=0,hAn=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Yue,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Yue,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((i,o)=>this._getKey(i)-this._getKey(o)),t=0,r=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(n[i]=e[t],t++):n[i]=this._array[r++];this._array=n,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||(ps=this._search(t),ps===-1)||this._getKey(this._array[ps])!==t)return!1;do if(this._array[ps]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ps),!0;while(++ps<this._array.length&&this._getKey(this._array[ps])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,o)=>i-o),t=0,r=new Array(this._array.length-e.length),n=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:r[n++]=this._array[i];this._array=r,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&&(ps=this._search(e),!(ps<0||ps>=this._array.length)&&this._getKey(this._array[ps])===e))do yield this._array[ps];while(++ps<this._array.length&&this._getKey(this._array[ps])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ps=this._search(e),!(ps<0||ps>=this._array.length)&&this._getKey(this._array[ps])===e))do t(this._array[ps]);while(++ps<this._array.length&&this._getKey(this._array[ps])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let n=t+r>>1,i=this._getKey(this._array[n]);if(i>e)r=n-1;else if(i<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},HMe=0,Err=0,fAn=class extends Nn{constructor(){super(),this._decorations=new hAn(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ar),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ar),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(qo(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dAn(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let n=0,i=0;for(let o of this._decorations.getKeyIterator(t))n=o.options.x??0,i=n+(o.options.width??1),e>=n&&e<i&&(!r||(o.options.layer??"bottom")===r)&&(yield o)}forEachDecorationAtCell(e,t,r,n){this._decorations.forEachByKey(t,i=>{HMe=i.options.x??0,Err=HMe+(i.options.width??1),e>=HMe&&e<Err&&(!r||(i.options.layer??"bottom")===r)&&n(i)})}},dAn=class extends HC{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ar),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ar),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.options.backgroundColor?this._cachedBg=Aa.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Aa.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},pAn=1e3,mAn=class{constructor(e,t=pAn){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,o=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_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)}},Rrr=20,Arr=!1,Kue=class extends Nn{constructor(e,t,r,n){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=n,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 o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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 mAn(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");Arr?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=i.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(i.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
3972
3972
  `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(bn(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(qo(()=>{Arr?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Rrr+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
3973
3973
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Rrr+1&&(this._liveRegion.textContent+=VMe.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 r=this._terminal.buffer,n=r.lines.length.toString();for(let i=e;i<=t;i++){let o=r.lines.get(r.ydisp+i),a=[],s=o?.translateToString(!0,void 0,void 0,a)||"",l=(r.ydisp+i+1).toString(),u=this._rowElements[i];u&&(s.length===0?(u.textContent="\xA0",this._rowColumns.set(u,[0,1])):(u.textContent=s,this._rowColumns.set(u,a)),u.setAttribute("aria-posinset",l),u.setAttribute("aria-setsize",n),this._alignRowWidth(u))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],i=r.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||e.relatedTarget!==n)return;let a,s;if(t===0?(a=r,s=this._rowElements.pop(),this._rowContainer.removeChild(s)):(a=this._rowElements.shift(),s=r,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),s.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}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},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,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 n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let i=({node:s,offset:l})=>{let u=s instanceof Text?s.parentNode:s,h=parseInt(u?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let d=l<f.length?f[l]:f.slice(-1)[0]+1;return d>=this._terminal.cols&&(++h,d=0),{row:h,column:d}},o=i(t),a=i(r);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);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,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};Kue=Ja([vr(1,EIe),vr(2,px),vr(3,mx)],Kue);var kIe=class extends Nn{constructor(e,t,r,n,i){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ar),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ar),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(qo(()=>{bE(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(bn(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(bn(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(bn(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(bn(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 r=e.composedPath();for(let n=0;n<r.length;n++){let i=r[n];if(i.classList.contains("xterm"))break;if(i.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(n=>{n?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(n)&&(r=this._checkLinkProviderResult(n,e,r)):i.provideLinks(e.y,o=>{if(this._isMouseOut)return;let a=o?.map(s=>({link:s}));this._activeProviderReplies?.set(n,a),r=this._checkLinkProviderResult(n,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let n=0;n<t.size;n++){let i=t.get(n);if(i)for(let o=0;o<i.length;o++){let a=i[o],s=a.link.range.start.y<e?0:a.link.range.start.x,l=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let u=s;u<=l;u++){if(r.has(u)){i.splice(o--,1);break}r.add(u)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),i=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.find(a=>this._linkAtPosition(a.link,t));o&&(r=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(s=>this._linkAtPosition(s.link,t));if(a){r=!0,this._handleNewLink(a);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&gAn(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,bE(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?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!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:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,r){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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,r){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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return r<=i&&i<=n}_positionFromMouseEvent(e,t,r){let n=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,n,i){return{x1:e,y1:t,x2:r,y2:n,cols:this._bufferService.cols,fg:i}}};kIe=Ja([vr(1,RIe),vr(2,mx),vr(3,uh),vr(4,Hrr)],kIe);function gAn(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 yAn=class extends lAn{constructor(e={}){super(e),this._linkifier=this._register(new nO),this.browser=gnr,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new nO),this._onCursorMove=this._register(new ar),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ar),this.onKey=this._onKey.event,this._onRender=this._register(new ar),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ar),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ar),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ar),this.onBell=this._onBell.event,this._onFocus=this._register(new ar),this._onBlur=this._register(new ar),this._onA11yCharEmitter=this._register(new ar),this._onA11yTabEmitter=this._register(new ar),this._onWillOpen=this._register(new ar),this._setup(),this._decorationService=this._instantiationService.createInstance(fAn),this._instantiationService.setService(wV,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(o6n),this._instantiationService.setService(Hrr,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(qMe)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Hc.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Hc.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Hc.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Hc.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(qo(()=>{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 r,n="";switch(t.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+t.index}switch(t.type){case 0:let i=Go.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${Ft.ESC}]${n};${rAn(i)}${pnr.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Us.toColor(...t.color));else{let o=r;this._themeService.modifyColors(a=>a[o]=Us.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_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(Kue,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ft.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(Ft.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 r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=t.getWidth(r),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,s=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(bn(this.element,"copy",t=>{this.hasSelection()&&jEn(t,this._selectionService)}));let e=t=>YEn(t,this.textarea,this.coreService,this.optionsService);this._register(bn(this.textarea,"paste",e)),this._register(bn(this.element,"paste",e)),ynr?this._register(bn(this.element,"mousedown",t=>{t.button===2&&Ptr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(bn(this.element,"contextmenu",t=>{Ptr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),NIe&&this._register(bn(this.element,"auxclick",t=>{t.button===1&&Irr(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(bn(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(bn(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(bn(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(bn(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(bn(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(bn(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(bn(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new 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(bn(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",WMe.get()),xnr||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(n6n,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(px,this._coreBrowserService),this._register(bn(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(bn(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(pIe,this._document,this._helperContainer),this._instantiationService.setService(Zue,this._charSizeService),this._themeService=this._instantiationService.createInstance(vIe),this._instantiationService.setService(iO,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(que),this._instantiationService.setService(Urr,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(gIe,this.rows,this.screenElement)),this._instantiationService.setService(mx,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(hIe,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(mIe),this._instantiationService.setService(RIe,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(kIe,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(cIe,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(yIe,this.element,this.screenElement,n)),this._instantiationService.setService(r3n,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(Hc.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(uIe,this.screenElement)),this._register(bn(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),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(Kue,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Gue,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Gue,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(dIe,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(o){let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let s,l;switch(o.overrideType||o.type){case"mousemove":l=32,o.buttons===void 0?(s=3,o.button!==void 0&&(s=o.button<3?o.button:3)):s=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":l=0,s=o.button<3?o.button:3;break;case"mousedown":l=1,s=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let u=o.deltaY;if(u===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;l=u<0?0:1,s=4;break;default:return!1}return l===void 0||s===void 0||s>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:s,action:l,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(r(o),o.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(o)),wheel:o=>(r(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&r(o)},mousemove:o=>{o.buttons||r(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?n.mousemove||(t.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),o&16?n.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),o&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),o&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(bn(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return r(o),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(o)})),this._register(bn(t,"wheel",o=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=Ft.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!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){Mrr(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 new 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 new 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,r){this._selectionService.setSelection(e,t,r)}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 r=uAn(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===Ft.ETX||r.key===Ft.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(vAn(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(zs));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(Ft.ESC+"[I"):this.coreService.triggerDataEvent(Ft.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Ft.ESC}[4;${r};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Ft.ESC}[6;${i};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function vAn(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bAn=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},xAn=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 dm)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},Prr=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 xAn(t)}getNullCell(){return new dm}},TAn=class extends Nn{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ar),this.onBufferChange=this._onBufferChange.event,this._normal=new Prr(this._core.buffers.normal,"normal"),this._alternate=new Prr(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 new 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)}},SAn=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,n)=>t(r,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)}},CAn=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}},wAn=["cols","rows"],Yy=0,Pnr=class extends Nn{constructor(e){super(),this._core=this._register(new yAn(e)),this._addonManager=this._register(new bAn),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],r=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:t.bind(this,n),set:r.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(e){if(wAn.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new SAn(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new CAn(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._buffer=this._register(new TAn(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";break}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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}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
3974
- `,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 WMe.get()},set promptLabel(e){WMe.set(e)},get tooMuchOutput(){return VMe.get()},set tooMuchOutput(e){VMe.set(e)}}}_verifyIntegers(...e){for(Yy of e)if(Yy===1/0||isNaN(Yy)||Yy%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Yy of e)if(Yy&&(Yy===1/0||isNaN(Yy)||Yy%1!==0||Yy<0))throw new Error("This API only accepts positive integers")}};var BIe=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\^<>`]*[^\s"':,.!?{}|\\^~[\]`()<>]/;function _An(e){try{return!!new URL(e).host}catch{return!1}}function Mnr(e,t){let r=e(t),n=e(t+1);return!!r&&!!n&&(n.isWrapped||r.isFull)}function kAn(e,t){let r=[];for(let n=t;n-t<64;n++){let i=e(n);if(!i||(r.push(i.text),!Mnr(e,n)))break}return r}function Lnr(e,t,r){let n=t;for(let i of e){if(r<i.length)return{x:r+1,y:n+1};r-=i.length,n++}}function EAn(e,t,r){let n=r[0],i=Lnr(e,t,r.index),o=Lnr(e,t,r.index+n.length-1);if(!(!_An(n)||!i||!o))return{text:n,range:{start:i,end:o}}}function RAn(e,t,r){let n=new RegExp(r.source,`${r.flags||""}g`);return[...e.join("").matchAll(n)].flatMap(o=>EAn(e,t,o)??[])}function Inr(e,t,r=BIe){if(!e(t-1))return[];let n=t-1;for(;n>0&&Mnr(e,n-1);)n--;return RAn(kAn(e,n),n,r)}function Dnr(e,t){let r=n=>{let i=e.buffer.active.getLine(n);if(!i)return;let o=e.cols,a=i.getCell(o-1);return{text:i.translateToString(!0,0,o),isWrapped:i.isWrapped,isFull:!!a&&a.getChars()!==""&&a.getChars()!==" "}};return{provideLinks(n,i){let o=Inr(r,n,BIe);i(o.map(a=>({range:a.range,text:a.text,activate:t})))}}}function Onr(e){let t=new Pnr({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', Consolas, monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4"},linkHandler:{activate:(o,a)=>{window.open(a,"_blank")}}}),r=new ler;t.loadAddon(r);let n=t.registerLinkProvider(Dnr(t,(o,a)=>{window.open(a,"_blank")}));t.open(e);let i;try{i=new Etr,i.onContextLoss(()=>{i?.dispose(),i=void 0}),t.loadAddon(i)}catch{i=void 0}return r.fit(),{term:t,fitAddon:r,dispose:()=>{n.dispose(),i?.dispose(),t.dispose()}}}function Nnr(e,t,r,n){if(e.type!=="keydown"||!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)return!0;let i=e.key.toLowerCase();return i==="c"&&t.hasSelection()?(e.preventDefault(),r.writeText(t.getSelection()),!1):i==="v"?(e.preventDefault(),r.readText().then(n),!1):!0}function rhe(e){return e.type==="keydown"&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="p"}function Bnr(e,t,r,n,i){let o=Onr(e);o.term.onData(u=>r(t,u)),o.term.attachCustomKeyEventHandler(u=>rhe(u)?!1:Nnr(u,o.term,navigator.clipboard,h=>o.term.paste(h)));let a=n(t,u=>o.term.write(u)),s=new ResizeObserver(()=>{cue(e)&&(o.fitAddon.fit(),i(t,o.term.cols,o.term.rows))});return s.observe(e),{handle:o,cleanup:()=>{s.disconnect(),a(),o.dispose()}}}function Fnr(e,t,r,n,i,o){let a=(0,EV.useRef)(null);(0,EV.useEffect)(()=>{let s=e.current;if(!s)return;let{handle:l,cleanup:u}=Bnr(s,t,n,i,o);return a.current=l,()=>{u(),a.current=null}},[e,t,i,n,o]),(0,EV.useEffect)(()=>{let s=a.current;if(!r||!s)return;let l=setTimeout(()=>{cue(e.current)&&(s.fitAddon.fit(),s.term.focus(),o(t,s.term.cols,s.term.rows))},50);return()=>clearTimeout(l)},[e,r,t,o])}var Unr=$(V(),1);function znr({sessionId:e,visible:t,onOutput:r,sendInput:n,sendResize:i}){let o=(0,$nr.useRef)(null);return Fnr(o,e,t,n,r,i),(0,Unr.jsx)(Me,{ref:o,sx:{position:"absolute",inset:"0 0 0 8px",visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none"}})}var SE=$(V(),1);function Hnr({sessions:e,activeId:t,activeLoading:r,onOutput:n,sendInput:i,sendResize:o}){return(0,SE.jsxs)(Me,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:[e.map(a=>(0,SE.jsx)(znr,{sessionId:a.id,visible:a.id===t,onOutput:n,sendInput:i,sendResize:o},a.id)),r&&(0,SE.jsx)(ser,{}),e.length===0&&(0,SE.jsx)(Me,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,SE.jsx)(tt,{variant:"body2",color:"text.disabled",children:"Create a session to get started"})})]})}var Vnr=$(V(),1);function Wnr({sessions:e,activeId:t,initialized:r,onOutput:n,sendInput:i,sendResize:o}){let a=e.find(l=>l.id===t),s=a!==void 0&&hse(a,r);return(0,Vnr.jsx)(Hnr,{sessions:e,activeId:t,activeLoading:s,onOutput:n,sendInput:i,sendResize:o})}var aO=$(V(),1),AAn={position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0};function Gnr({activeSession:e,sendPrDecision:t,showLastMessage:r,...n}){return(0,aO.jsxs)(Me,{sx:AAn,children:[(0,aO.jsx)(JJt,{session:e,sendPrDecision:t,sendInput:n.sendInput,children:(0,aO.jsx)(Wnr,{...n})}),r&&e!==void 0&&(0,aO.jsx)(oer,{message:e.lastUserMessage})]})}var qnr=$(V(),1),jnr=St((0,qnr.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build");var pm=$(V(),1);function Ynr({message:e}){return e.role==="tool"?(0,pm.jsx)(PAn,{tool:e.tool,target:e.target}):(0,pm.jsx)(LAn,{role:e.role,text:e.text})}function PAn({tool:e,target:t}){return(0,pm.jsxs)(Me,{sx:{display:"flex",alignItems:"center",gap:1,py:.5,pl:1},children:[(0,pm.jsx)(jnr,{sx:{fontSize:14,color:"text.disabled"}}),(0,pm.jsxs)(tt,{variant:"caption",sx:{color:"text.secondary",fontFamily:"monospace"},children:[(0,pm.jsx)(Me,{component:"span",sx:{color:"warning.main"},children:e}),t&&(0,pm.jsxs)(Me,{component:"span",children:[" ",t]})]})]})}function LAn({role:e,text:t}){let r=e==="user",n=r?"info.main":"success.main";return(0,pm.jsxs)(Me,{sx:{mb:1.5,pl:1.5,py:1,pr:1,borderLeft:2,borderColor:n,borderTopRightRadius:1,borderBottomRightRadius:1,bgcolor:r?"action.hover":"transparent"},children:[(0,pm.jsx)(tt,{variant:"caption",sx:{color:n,fontWeight:600,display:"block",mb:.5},children:r?"User":"Assistant"}),(0,pm.jsx)(tt,{variant:"body2",sx:{color:"text.primary",whiteSpace:"pre-wrap",overflowWrap:"anywhere",lineHeight:1.6},children:t})]})}var Qy=$(V(),1);function MAn(e){let t=new Map;return e.map(r=>{let n=r.role==="tool"?`tool:${r.tool}:${r.target}`:`${r.role}:${r.text.slice(0,40)}`,i=t.get(n)??0;return t.set(n,i+1),{...r,key:`${n}#${i}`}})}function Xnr({messages:e,loading:t}){return t?(0,Qy.jsxs)(Me,{sx:Knr,children:[(0,Qy.jsx)(ro,{size:20}),(0,Qy.jsx)(tt,{variant:"caption",color:"text.disabled",children:"Loading transcript\u2026"})]}):e.length===0?(0,Qy.jsx)(Me,{sx:Knr,children:(0,Qy.jsx)(tt,{variant:"body2",color:"text.disabled",children:"No transcript available"})}):(0,Qy.jsx)(Me,{sx:{position:"absolute",inset:0,overflowY:"auto",p:2},children:(0,Qy.jsx)(Me,{sx:{maxWidth:820,mx:"auto"},children:MAn(e).map(r=>(0,Qy.jsx)(Ynr,{message:r},r.key))})})}var Knr={position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:1.5,alignItems:"center",justifyContent:"center"};var FIe=$(V(),1);function Znr({sessionId:e,transcript:t}){let r=t?.sessionId===e;return(0,FIe.jsx)(Me,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:(0,FIe.jsx)(Xnr,{messages:r?t?.messages??[]:[],loading:!r})})}var WC=$(V(),1),IAn={flex:1,minHeight:0,display:"flex",flexDirection:"column"},DAn={flexShrink:0};function Qnr({viewingTranscriptSessionId:e,transcript:t,sendPrDecision:r,lifecycle:n,...i}){let o=hf();if(e!==null)return(0,WC.jsx)(Znr,{sessionId:e,transcript:t});let a=i.sessions.find(s=>s.id===i.activeId);return(0,WC.jsxs)(Me,{sx:IAn,children:[o&&a!==void 0&&(0,WC.jsx)(Me,{sx:DAn,children:(0,WC.jsx)(YZt,{session:a,lifecycle:n})}),(0,WC.jsx)(QZt,{sessionId:i.activeId,sessions:i.sessions,sendInput:i.sendInput,children:(0,WC.jsx)(Gnr,{...i,activeSession:a,sendPrDecision:r,showLastMessage:o})})]})}var tir=$(V(),1);function eir({socket:e}){let t=(0,Jnr.useMemo)(()=>({onRetry:e.retrySession,onRestart:e.restartSession,onDismiss:e.dismissSession,onSetAutoRun:e.setAutoRun,onSetAutoAdvance:e.setAutoAdvance}),[e.retrySession,e.restartSession,e.dismissSession,e.setAutoRun,e.setAutoAdvance]);return(0,tir.jsx)(Qnr,{lifecycle:t,sessions:e.sessions,activeId:e.activeId,initialized:e.initialized,onOutput:e.onOutput,sendInput:e.sendInput,sendResize:e.sendResize,viewingTranscriptSessionId:e.viewingTranscriptSessionId,transcript:e.transcript,sendPrDecision:e.sendPrDecision})}function $Ie(e,t,r){if(e==null)return;let n=Math.max(0,e-r),i=Math.max(0,t-n)/t;if(!(i<.05))return i}function nhe(e,t){let r=Math.max(0,e-t),n=Math.floor(r/86400),i=Math.floor(r%86400/3600),o=Math.floor(r%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function OAn(e,t,r,n){let i=$Ie(t,r,n);if(i!=null)return e/i}function VC(e,t,r,n){let i=OAn(e,t,r,n);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var CE={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};var NAn={ok:"success.main",warn:"warning.main",over:"error.main"};function GC(e){return NAn[e]}var PV=$(V(),1),BAn={ok:"success",warn:"warning",over:"error"};function rir({percentage:e,level:t}){return(0,PV.jsxs)(Me,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,PV.jsx)(_9,{variant:"determinate",value:Math.min(100,e),color:BAn[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,PV.jsxs)(Me,{sx:{minWidth:40,textAlign:"right",color:GC(t)},children:[Math.round(e),"%"]})]})}function nir(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var FAn=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function zIe(e){return FAn.format(e)}var ihe=$(V(),1);function iir({peak:e}){return(0,ihe.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,ihe.jsx)(Mn,{title:`Cycle started ${zIe(new Date(e.createdAt))}`,children:(0,ihe.jsx)("span",{children:zIe(new Date(e.resetsAt*1e3))})})})}var air=$(V(),1);function oir(){return(0,air.jsx)(An,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function sir(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${i6(e.tokensUp)} \u2193 ${i6(e.tokensDown)}`}var Ig=$(V(),1);function lir({peak:e,now:t}){let{label:r,seconds:n,tint:i}=CE[e.window],o=VC(e.usedPercentage,e.resetsAt,n,t);return(0,Ig.jsxs)(Pm,{sx:a=>({backgroundColor:i?a.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,Ig.jsxs)(Xn,{children:[r,e.resetDetected&&(0,Ig.jsx)(oir,{})]}),(0,Ig.jsx)(Xn,{sx:{minWidth:160},children:(0,Ig.jsx)(rir,{percentage:e.usedPercentage,level:o})}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:nir(e)}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:e.phaseCount??0}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:sir(e)}),(0,Ig.jsx)(iir,{peak:e})]})}var ohe=$(Re(),1);function sO(e){let[t,r]=(0,ohe.useState)(()=>Math.floor(Date.now()/1e3));return(0,ohe.useEffect)(()=>{let n=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(n)},[e]),t}var Ql=$(V(),1);function cir({peaks:e}){let t=sO(3e4);return(0,Ql.jsx)(Y9,{component:ti,children:(0,Ql.jsxs)(Vw,{size:"small",children:[(0,Ql.jsx)(K9,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,Ql.jsxs)(Pm,{children:[(0,Ql.jsx)(Xn,{children:"Window"}),(0,Ql.jsx)(Xn,{children:"Peak usage"}),(0,Ql.jsx)(Xn,{align:"right",children:(0,Ql.jsx)(Mn,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,Ql.jsx)("span",{children:"Avg context"})})}),(0,Ql.jsx)(Xn,{align:"right",children:(0,Ql.jsx)(Mn,{title:"Number of phase readings behind the average.",children:(0,Ql.jsx)("span",{children:"Phases"})})}),(0,Ql.jsx)(Xn,{align:"right",children:"Tokens spent"}),(0,Ql.jsx)(Xn,{align:"right",children:"Cycle reset"})]})}),(0,Ql.jsx)(Gw,{children:e.map(r=>(0,Ql.jsx)(lir,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var lO=$(Re(),1);function uir(e,t){let r=(0,lO.useRef)(null),[n,i]=(0,lO.useState)();return(0,lO.useLayoutEffect)(()=>{e===t&&r.current&&i(r.current.offsetHeight)},[e,t]),{ref:r,height:n}}var qC=$(V(),1);function hir({rows:e,total:t,page:r,pageSize:n,onPageChange:i}){let{ref:o,height:a}=uir(e.length,n);return(0,qC.jsxs)(qC.Fragment,{children:[(0,qC.jsx)(Me,{ref:o,sx:{minHeight:a},children:(0,qC.jsx)(cir,{peaks:e})}),(0,qC.jsx)(fpe,{component:"div",count:t,page:r,rowsPerPage:n,rowsPerPageOptions:[n],onPageChange:(s,l)=>i(l)})]})}var UIe=$(V(),1),$An=[{value:"all",label:"All"},{value:"five_hour",label:CE.five_hour.label},{value:"seven_day",label:CE.seven_day.label}];function fir({window:e,onChange:t}){return(0,UIe.jsx)(rp,{size:"small",exclusive:!0,value:e,onChange:(r,n)=>n&&t(n),"aria-label":"Filter peaks by rate-limit window",children:$An.map(r=>(0,UIe.jsx)(lc,{value:r.value,children:r.label},r.value))})}var LV=$(Re(),1);var jC=$(Re(),1);async function dir(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r!=="all"&&n.set("window",r);let i=await fetch(`/api/usage/history?${n}`);if(!i.ok)throw new Error(`Failed to load usage history (HTTP ${i.status}).`);return i.json()}function pir(e,t,r){let[n,i]=(0,jC.useState)([]),[o,a]=(0,jC.useState)(0),[s,l]=(0,jC.useState)(!1),[u,h]=(0,jC.useState)(!1),[f,d]=(0,jC.useState)(null);return(0,jC.useEffect)(()=>{let p=!1;return h(!0),dir(e,t,r).then(m=>{p||(i(m.rows),a(m.total),l(!0),h(!1))},m=>{p||(d(m instanceof Error?m:new Error(String(m))),h(!1))}),()=>{p=!0}},[e,t,r]),{rows:n,total:o,loaded:s,fetching:u,error:f}}var HIe=30;function mir(){let[e,t]=(0,LV.useState)(0),[r,n]=(0,LV.useState)("all"),i=pir(e,HIe,r),{total:o}=i;return(0,LV.useEffect)(()=>{if(o===0)return;let s=Math.ceil(o/HIe)-1;e>s&&t(s)},[e,o]),{...i,page:e,setPage:t,window:r,selectWindow:s=>{n(s),t(0)},pageSize:HIe}}var YC=$(V(),1);function gir(){let e=mir(),{window:t,total:r,error:n}=e;if(n)throw n;return(0,YC.jsxs)(rm,{loading:!e.loaded,title:"Usage history",isEmpty:r===0&&t==="all",emptyMessage:"No usage peaks recorded yet.",children:[(0,YC.jsx)(fir,{window:t,onChange:e.selectWindow}),(0,YC.jsx)(Me,{sx:{height:4,my:1},children:e.fetching&&(0,YC.jsx)(_9,{})}),t!=="all"&&r===0?(0,YC.jsxs)(tt,{color:"text.secondary",align:"center",sx:{py:6},children:["No ",CE[t].label," usage peaks recorded yet."]}):(0,YC.jsx)(hir,{rows:e.rows,total:r,page:e.page,pageSize:e.pageSize,onPageChange:e.setPage})]})}var jo=$(V(),1);function zAn({socket:e}){return(0,jo.jsx)(y9,{maxWidth:"md",sx:{py:3,px:2},children:(0,jo.jsx)(tFt,{socket:e})})}function yir({socket:e}){return(0,jo.jsx)(b_,{children:(0,jo.jsxs)(wl,{element:(0,jo.jsx)(mUt,{socket:e}),children:[(0,jo.jsx)(wl,{path:"sessions",element:(0,jo.jsx)(eir,{socket:e})}),(0,jo.jsx)(wl,{path:"backlog/*",element:(0,jo.jsx)(zAn,{socket:e})}),(0,jo.jsx)(wl,{path:"news",element:(0,jo.jsx)(LZt,{})}),(0,jo.jsx)(wl,{path:"usage",element:(0,jo.jsx)(gir,{})}),(0,jo.jsx)(wl,{path:"backups",element:(0,jo.jsx)(SUt,{})}),(0,jo.jsx)(wl,{path:"config",element:(0,jo.jsx)(iWt,{})}),(0,jo.jsx)(wl,{path:"diff",element:(0,jo.jsx)(eZt,{sessions:e.sessions,sendInput:e.sendInput})}),(0,jo.jsx)(wl,{path:"file",element:(0,jo.jsx)(EZt,{})}),(0,jo.jsx)(wl,{path:"*",element:(0,jo.jsx)(x0e,{to:"/sessions",replace:!0})})]})})}var fhe=$(Re(),1);var hhe=$(Re(),1);function vir(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var KC=$(V(),1),UAn={display:"flex",gap:1,alignItems:"center",minWidth:0},HAn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},WAn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},VAn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function GAn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function bir({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,KC.jsx)(Sh,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=GAn(i);return(0,KC.jsxs)(ui,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:UAn,children:[(0,KC.jsx)($D,{path:i}),(0,KC.jsxs)(Me,{sx:HAn,children:[(0,KC.jsx)(tt,{component:"span",sx:WAn,children:s}),(0,KC.jsx)(tt,{component:"span",color:"text.secondary",sx:VAn,children:a})]})]},i)})})}var ahe=$(V(),1),qAn={maxHeight:420,overflowY:"auto"},jAn={px:2,py:2,fontSize:13};function xir({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,ahe.jsx)(Me,{sx:qAn,children:e?(0,ahe.jsx)(tt,{color:"text.secondary",sx:jAn,children:e}):(0,ahe.jsx)(bir,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var Tir=$(V(),1);function she({inputRef:e,value:t,onChange:r,onKeyDown:n,placeholder:i,autoFocus:o}){return(0,Tir.jsx)(Qo,{autoFocus:o,inputRef:e,value:t,onChange:a=>r(a.target.value),onKeyDown:n,placeholder:i,size:"small",fullWidth:!0,slotProps:{input:{sx:{fontSize:12}}},sx:{p:.5}})}var lhe=$(Re(),1),Sir={files:[],loading:!1,error:!1};function Cir(e,t){let[r,n]=(0,lhe.useState)(Sir);return(0,lhe.useEffect)(()=>{if(!e){n(Sir);return}let i=!1;return n(a=>({...a,loading:!0})),(async()=>{try{let a=await fetch(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`);if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json();if(i)return;n({files:Array.isArray(s.files)?s.files:[],loading:!1,error:!1})}catch{i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t]),r}var che=$(Re(),1);function uhe(e,t,r,n){let[i,o]=(0,che.useState)(0);return(0,che.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var MV=$(V(),1),YAn={mt:6,alignSelf:"flex-start"};function wir({onClose:e}){let{worktreeCwd:t}=Oa(),[r,n]=(0,hhe.useState)(""),i=Cir(t,r),o=oo(),a=(0,hhe.useRef)(null),s=d=>o(`/file?${new URLSearchParams(t?{path:d,cwd:t}:{path:d})}`),{highlight:l,setHighlight:u,onKeyDown:h}=uhe(i.files,r,s,e),f=d=>{s(d),e()};return(0,MV.jsxs)(xh,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:YAn},transition:{onEntered:()=>a.current?.focus()}},children:[(0,MV.jsx)(she,{autoFocus:!0,inputRef:a,value:r,onChange:n,onKeyDown:h,placeholder:"Search files by name..."}),(0,MV.jsx)(xir,{message:vir(t,r,i),files:i.files,highlight:l,onHighlight:u,onSelect:f})]})}var kir=$(Re(),1);var _ir=!0;function Eir(e){(0,kir.useEffect)(()=>{let t=r=>{rhe(r)&&(r.preventDefault(),e())};return globalThis.addEventListener("keydown",t,_ir),()=>globalThis.removeEventListener("keydown",t,_ir)},[e])}var Air=$(V(),1);function Rir(){let[e,t]=(0,fhe.useState)(!1);return Eir((0,fhe.useCallback)(()=>t(!0),[])),e?(0,Air.jsx)(wir,{onClose:()=>t(!1)}):null}var dhe=$(V(),1);function Pir({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,dhe.jsx)(jc,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,dhe.jsx)(Ko,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,dhe.jsx)(xr,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var phe=$(V(),1);function Lir({reconnecting:e}){return(0,phe.jsx)(jc,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,phe.jsx)(Ko,{severity:"info",variant:"filled",icon:(0,phe.jsx)(ro,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var gx=$(V(),1);function Mir({socket:e,onViewLaunchedSession:t}){return(0,gx.jsxs)(gx.Fragment,{children:[(0,gx.jsx)(Rir,{}),(0,gx.jsx)(Lir,{reconnecting:e.reconnecting}),(0,gx.jsx)(ff,{error:e.error,onClose:e.clearError}),(0,gx.jsx)(Pir,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var cO=$(V(),1),KAn=["/sessions","/backlog","/news"];function Iir(){let e=Ss(),t=oo(),r=KAn.findIndex(i=>e.pathname.startsWith(i)),n=i=>{e.pathname!==i&&t(i)};return(0,cO.jsxs)(Z9,{value:r===-1?0:r,textColor:"inherit",indicatorColor:"secondary",children:[(0,cO.jsx)(Hx,{label:"Sessions",onClick:()=>n("/sessions")}),(0,cO.jsx)(Hx,{label:"Backlog",onClick:()=>n("/backlog")}),(0,cO.jsx)(Hx,{label:"News",onClick:()=>n("/news")})]})}var ghe=$(Re(),1),mhe=$(V(),1),XAn={color:"inherit"};function Dir({cwd:e}){let[t,r]=(0,ghe.useState)(null);return(0,ghe.useEffect)(()=>{if(!e){r(null);return}let n=!1;return(async()=>{try{let o=await(await fetch(`/api/github-url?cwd=${encodeURIComponent(e)}`)).json();n||r(o?.url??null)}catch{n||r(null)}})(),()=>{n=!0}},[e]),t?(0,mhe.jsx)(Mn,{title:"Open in GitHub",children:(0,mhe.jsx)(gr,{sx:XAn,onClick:()=>window.open(t,"_blank"),children:(0,mhe.jsx)(Ose,{})})}):null}var Nir=$(Re(),1);var yhe=$(V(),1);function Oir({window:e,windowSeconds:t,fallbackLabel:r,now:n}){let i=e?.used_percentage;if(i==null)return null;let o=VC(i,e?.resets_at,t,n),a=e?.resets_at!=null?nhe(e.resets_at,n):r;return(0,yhe.jsxs)(Me,{component:"span",children:[(0,yhe.jsxs)(Me,{component:"span",sx:{color:GC(o)},children:[Math.round(i),"%"]})," ",(0,yhe.jsxs)(Me,{component:"span",sx:{color:"text.secondary"},children:["(",a,")"]})]})}var XC=$(V(),1);function Bir({rateLimits:e}){let t=sO(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(n=>n.window?.used_percentage!=null);return(0,XC.jsx)(XC.Fragment,{children:r.map((n,i)=>(0,XC.jsxs)(Nir.Fragment,{children:[i>0?(0,XC.jsx)(Me,{component:"span",sx:{color:"text.secondary",mr:.5},children:","}):null,(0,XC.jsx)(Oir,{window:n.window,windowSeconds:n.windowSeconds,fallbackLabel:n.fallbackLabel,now:t})]},n.fallbackLabel))})}function ZAn(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function QAn(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function JAn(e,t,r,n){if(e>=t)return;let i=e/t;return Math.round(r-n*(1-i))}function zir(e,t,r,n){if(t==null)return{kind:"unprojectable"};let i=$Ie(t,r,n);if(i==null)return{kind:"unprojectable"};let o=VC(e,t,r,n),a=ZAn(o),s=QAn(o);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*i,at:JAn(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*i}}}function Uir(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${nhe(e.at,t)}`}var Dg=$(V(),1);function WIe({direction:e,threshold:t}){let r=e==="back",n={display:"inline-flex",gap:.5,minWidth:"6ch",justifyContent:r?"flex-end":"flex-start"};if(!t)return(0,Dg.jsx)(Me,{component:"span",sx:n});let i=(0,Dg.jsx)(Me,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,Dg.jsxs)(Me,{component:"span",sx:{color:GC(t.level)},children:[Math.round(t.pct),"%"]});return(0,Dg.jsx)(Me,{component:"span",sx:n,children:r?(0,Dg.jsxs)(Dg.Fragment,{children:[o,i]}):(0,Dg.jsxs)(Dg.Fragment,{children:[i,o]})})}var ZC=$(V(),1);function Hir({label:e,pct:t,resetsAt:r,windowSeconds:n,now:i}){let o=VC(t,r,n,i),a=zir(t,r,n,i),s=a.kind==="projected"?a:void 0;return(0,ZC.jsxs)(Me,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[(0,ZC.jsx)(Me,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,ZC.jsx)(WIe,{direction:"back",threshold:s?.recovery}),(0,ZC.jsxs)(Me,{component:"span",sx:{minWidth:"4ch",textAlign:"right",color:GC(o)},children:[Math.round(t),"%"]}),(0,ZC.jsx)(WIe,{direction:"forward",threshold:s?.worse}),(0,ZC.jsx)(Me,{component:"span",sx:{opacity:.6},children:s?s.recovery&&Uir(s.recovery,i):"no projection yet"})]})}function Wir(e){return[{label:"5h",window:e.five_hour,windowSeconds:18e3},{label:"7d",window:e.seven_day,windowSeconds:604800}].flatMap(t=>t.window?.used_percentage==null?[]:[{label:t.label,pct:t.window.used_percentage,resetsAt:t.window.resets_at,windowSeconds:t.windowSeconds}])}var IV=$(V(),1),VIe="Claude account usage (5h / 7d windows) \u2014 view history";function Vir({rateLimits:e}){let t=sO(3e4);return(0,IV.jsxs)(Me,{sx:{fontFamily:"monospace",fontSize:12},children:[Wir(e).map(r=>(0,IV.jsx)(Hir,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label)),(0,IV.jsx)(Me,{sx:{mt:.5,opacity:.6},children:VIe})]})}var DV=$(V(),1),ePn={display:"flex",alignItems:"center",ml:2,fontFamily:"monospace",fontSize:13};function tPn(e){return e?.five_hour?.used_percentage!=null||e?.seven_day?.used_percentage!=null}function Gir({rateLimits:e}){let t=tPn(e);return(0,DV.jsx)(Mn,{title:t?(0,DV.jsx)(Vir,{rateLimits:e}):VIe,children:(0,DV.jsx)(Zo,{component:Nm,to:"/usage",underline:"hover",color:"inherit",sx:ePn,children:t?(0,DV.jsx)(Bir,{rateLimits:e}):"Usage"})})}var qir=$(V(),1),jir=St((0,qir.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var vx=$(Re(),1);var uO={target:"both",label:"Restart daemon",message:"This restarts the sessions daemon and the web server, then reloads the page once the server is back."};function Yir(e){return fetch(`/api/restart?target=${e}`,{method:"POST"})}var yx=$(Re(),1);var rPn="/api/session-layout";async function nPn(){try{return(await fetch(rPn,{cache:"no-store"})).ok}catch{return!1}}async function Kir(e){let t=0;for(;!e();){if(t=await nPn()?t+1:0,t>=2)return!e();await new Promise(r=>setTimeout(r,300))}return!1}function iPn(){return{sawDisconnect:!1,waiting:!1,abandoned:!0}}function Xir(e,t,r){let n=(0,yx.useRef)(iPn()),i=(0,yx.useRef)(r);i.current=r,(0,yx.useEffect)(()=>{let s=n.current;if(!(!e||s.abandoned)){if(t){s.sawDisconnect=!0;return}!s.sawDisconnect||s.waiting||(s.waiting=!0,Kir(()=>s.abandoned).then(l=>{l&&i.current()}))}},[e,t]);let o=(0,yx.useCallback)(()=>{n.current.abandoned=!0},[]),a=(0,yx.useCallback)(()=>{n.current.abandoned=!0,n.current={sawDisconnect:!1,waiting:!1,abandoned:!1}},[]);return(0,yx.useEffect)(()=>o,[o]),{arm:a,abandon:o}}var oPn=15e3;function hO(e,t,r){let[n,i]=(0,vx.useState)(!1),[o,a]=(0,vx.useState)(null),s=(0,vx.useRef)(void 0),{arm:l,abandon:u}=Xir(n,t,()=>{clearTimeout(s.current),r?.(),globalThis.location.reload()});(0,vx.useEffect)(()=>()=>clearTimeout(s.current),[]);let h=(0,vx.useCallback)(async()=>{i(!0),l(),s.current=setTimeout(()=>{u(),i(!1),a("Web server did not come back")},oPn);try{if(!(await Yir(e)).ok)throw new Error("restart failed")}catch{u(),clearTimeout(s.current),i(!1),a("Failed to restart web server")}},[e,l,u]);return{pending:n,error:o,clearError:()=>a(null),restart:h}}var Og=$(V(),1),aPn={color:"inherit",mr:1.5};function Zir({reconnecting:e}){let{pending:t,error:r,clearError:n,restart:i}=hO("webserver",e);return(0,Og.jsxs)(Og.Fragment,{children:[(0,Og.jsx)(Mn,{title:"Restart web server",children:(0,Og.jsx)("span",{children:(0,Og.jsx)(gr,{sx:aPn,disabled:t,onClick:i,children:t?(0,Og.jsx)(ro,{size:24}):(0,Og.jsx)(jir,{})})})}),(0,Og.jsx)(ff,{error:r,onClose:n})]})}var fO=$(Re(),1);var vhe=$(Re(),1);var bhe=$(V(),1);function Qir({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=(0,vhe.useRef)(null);return(0,vhe.useEffect)(()=>{r&&o.current?.scrollIntoView({block:"nearest"})},[r]),(0,bhe.jsxs)(ui,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:[OV(e),qS(e)&&(0,bhe.jsx)($S,{})]})}var GIe=$(V(),1);function Jir({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,GIe.jsx)(Sh,{dense:!0,children:e.map((o,a)=>(0,GIe.jsx)(Qir,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var NV=$(V(),1);function OV(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var sPn={...XS};function eor({repos:e,selected:t,onSelect:r,close:n}){let[i,o]=(0,fO.useState)(""),a=(0,fO.useRef)(null);(0,fO.useEffect)(()=>{a.current?.focus()},[]);let s=i.trim().toLowerCase(),l=s?e.filter(p=>p.toLowerCase().includes(s)):e,{highlight:u,setHighlight:h,onKeyDown:f}=uhe(l,s,r,n);return(0,NV.jsxs)(ti,{elevation:4,sx:sPn,children:[(0,NV.jsx)(she,{inputRef:a,value:i,onChange:o,onKeyDown:f,placeholder:"Filter repos..."}),(0,NV.jsx)(Jir,{repos:l,selected:t,highlight:u,onHighlight:h,onSelect:p=>{r(p),n()}})]})}var dO=$(V(),1);function lPn(e){return e?qS(e)?(0,dO.jsxs)("span",{style:{display:"flex",flexGrow:1,alignItems:"center",justifyContent:"space-between",gap:6,minWidth:0},children:[OV(e),(0,dO.jsx)($S,{})]}):OV(e):"Select repo..."}function tor({repos:e,selected:t,onSelect:r}){return(0,dO.jsx)(Iy,{label:lPn(t),children:n=>(0,dO.jsx)(eor,{repos:e,selected:t,onSelect:r,close:n})})}var ror=$(Re(),1);var qIe=$(V(),1);function xhe({disabled:e,onSubmit:t,label:r="prompt",allowEmpty:n=!1}){let[i,o]=(0,ror.useState)("");return(0,qIe.jsx)(Iy,{label:r,disabled:e,onDefaultAction:n?()=>t(""):void 0,children:a=>(0,qIe.jsx)(YI,{value:i,onChange:o,onSubmit:()=>{!n&&!i.trim()||(t(i),o(""),a())}})})}var wE=$(V(),1),cPn={textTransform:"none",fontSize:11,fontWeight:600};function nor({onSelect:e,disabled:t=!1,children:r}){return(0,wE.jsxs)(wE.Fragment,{children:[n7e.filter(n=>n.nav&&n.prompt).map(n=>(0,wE.jsx)(xhe,{label:n.label,allowEmpty:!0,disabled:t,onSubmit:i=>e(n.value,i)},n.value)),r,n7e.filter(n=>n.nav&&!n.prompt).map(n=>(0,wE.jsx)(xr,{size:"small",variant:"outlined",disabled:t,onClick:()=>e(n.value),sx:cPn,children:n.label},n.value))]})}var jIe=$(Re(),1);function ior(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var The=$(V(),1),uPn={"& .MuiFormControlLabel-label":{fontSize:12}};function oor({choices:e,value:t,onChange:r}){return(0,The.jsx)(ope,{row:!0,value:t,onChange:n=>r(n.target.value),children:e.map(n=>(0,The.jsx)(If,{value:n,control:(0,The.jsx)(npe,{size:"small"}),label:FS(n),sx:uPn},n))})}var She=$(V(),1);function aor({cwd:e,disabled:t,onCreate:r,onCreateHarness:n}){let i=ior(Zae()),[o,a]=(0,jIe.useState)(""),[s,l]=(0,jIe.useState)("claude"),u=h=>{s==="claude"?r(h,e):n(s,h,e)};return(0,She.jsx)(Iy,{label:"prompt",disabled:t,onDefaultAction:()=>u(""),children:h=>(0,She.jsx)(YI,{value:o,onChange:a,header:i.length>1?(0,She.jsx)(oor,{choices:i,value:s,onChange:l}):void 0,onSubmit:()=>{u(o),a(""),h()}})})}var _E=$(V(),1);function sor({cwd:e,disabled:t,onCreate:r,onCreateDesign:n,onCreateHarness:i}){return(0,_E.jsxs)(_E.Fragment,{children:[(0,_E.jsx)(aor,{cwd:e,disabled:t,onCreate:r,onCreateHarness:i}),(0,_E.jsx)(xhe,{label:"design",allowEmpty:!0,disabled:t,onSubmit:o=>n(o,e)})]})}var mor=$(Re(),1);var BV=$(Re(),1);function Che(e){let[t,r]=(0,BV.useState)([]),[n,i]=(0,BV.useState)(!0);return(0,BV.useEffect)(()=>{if(!e){r([]),i(!1);return}let o=!1;return i(!0),fetch(`/api/pr-list?cwd=${encodeURIComponent(e)}`).then(a=>a.json()).then(a=>{o||(r(Array.isArray(a?.prs)?a.prs:[]),i(!1))}).catch(()=>{o||(r([]),i(!1))}),()=>{o=!0}},[e]),{prs:t,loading:n}}var Bd=$(V(),1);function cor({cwd:e,onPick:t}){let{prs:r,loading:n}=Che(e);return(0,Bd.jsx)(ti,{elevation:4,sx:{...XS,left:"auto",width:320},children:n?(0,Bd.jsx)(lor,{text:"Loading open PRs\u2026"}):r.length===0?(0,Bd.jsx)(lor,{text:"No open PRs"}):(0,Bd.jsx)(Sh,{dense:!0,disablePadding:!0,children:r.map(i=>(0,Bd.jsx)(hPn,{pr:i,onPick:t},i.number))})})}function hPn({pr:e,onPick:t}){return(0,Bd.jsx)(ui,{onMouseDown:r=>r.preventDefault(),onClick:()=>t(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,Bd.jsxs)(ir,{spacing:.25,sx:{minWidth:0},children:[(0,Bd.jsx)(tt,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:e.title}),(0,Bd.jsxs)(tt,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",S2(e.createdAt)]})]})})}function lor({text:e}){return(0,Bd.jsx)(Me,{sx:{p:1.5},children:(0,Bd.jsx)(tt,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var hor=$(V(),1);function uor({cwd:e,onPick:t}){return(0,hor.jsx)(cor,{cwd:e,onPick:t})}var dor=$(Re(),1);var pu=$(V(),1);function por({pr:e,onSelect:t,onCancel:r}){let[n,i]=(0,dor.useState)(HH);return(0,pu.jsxs)(xh,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,pu.jsxs)(Jd,{sx:{fontSize:15},children:["Review #",e.number,": ",e.title]}),(0,pu.jsx)(Qd,{sx:{px:0},children:(0,pu.jsxs)(Sh,{children:[Nse.map(({label:o,args:a})=>(0,pu.jsx)(ui,{onClick:()=>t([...a,...Bse(n)]),children:o},o)),(0,pu.jsx)(ns,{}),(0,pu.jsx)(Fse,{value:n,onChange:i}),(0,pu.jsx)(ns,{}),(0,pu.jsx)(ui,{onClick:()=>t(["review","--checkout-only"]),children:"Checkout"}),(0,pu.jsx)(ui,{onClick:()=>t(["review-pr-comments"]),children:"Address Comments"}),(0,pu.jsx)(ui,{onClick:()=>t(["fix-conflict"]),children:"Fix conflicts (merge)"}),(0,pu.jsx)(ui,{onClick:()=>t(["fix-conflict","--rebase"]),children:"Fix conflicts (rebase)"})]})}),(0,pu.jsx)(Zd,{children:(0,pu.jsx)(xr,{onClick:r,children:"Cancel"})})]})}var QC=$(V(),1);function gor({cwd:e,disabled:t,onSelect:r}){let{prs:n,loading:i}=Che(e),[o,a]=(0,mor.useState)(null);return i||n.length===0?null:(0,QC.jsxs)(QC.Fragment,{children:[(0,QC.jsx)(Iy,{label:"prs",disabled:t,children:s=>(0,QC.jsx)(uor,{cwd:e,onPick:l=>{a(l),s()}})}),o&&(0,QC.jsx)(por,{pr:o,onSelect:s=>{r(o,s),a(null)},onCancel:()=>a(null)})]})}var pO=$(V(),1);function yor({onStartRun:e,cwd:t}){let r=Vse(t);return!t||r.length===0?null:(0,pO.jsx)(Iy,{label:"server",children:n=>(0,pO.jsx)(ti,{elevation:4,sx:{...XS,left:"auto",width:200},children:(0,pO.jsx)(Sh,{dense:!0,disablePadding:!0,children:r.map(i=>(0,pO.jsx)(ui,{onMouseDown:o=>o.preventDefault(),onClick:()=>{e(i.name,t),n()},sx:{py:.75},children:(0,pO.jsx)(tt,{sx:{fontSize:13},children:i.name})},i.name))})})})}var kE=$(V(),1);function vor({onCreate:e,onCreateDesign:t,onCreateHarness:r,onCreateAssist:n,onStartRun:i}){let{selectedCwd:o}=Oa(),a=!o;return(0,kE.jsxs)(ir,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[(0,kE.jsxs)(nor,{disabled:a,onSelect:(s,l)=>I$t(s,o,n,()=>{},l),children:[(0,kE.jsx)(sor,{cwd:o,disabled:a,onCreate:e,onCreateDesign:t,onCreateHarness:r}),(0,kE.jsx)(gor,{cwd:o,disabled:a,onSelect:(s,l)=>n([...l,String(s.number)],o,$se(s))})]}),(0,kE.jsx)(yor,{onStartRun:i,cwd:o})]})}var Fd=$(V(),1),fPn={minHeight:48,pl:1,pr:14},dPn={width:240,ml:2};function bor({socket:e,selection:t}){let{collapsed:r,onToggleCollapsed:n}=QI();return(0,Fd.jsxs)(qw,{variant:"dense",disableGutters:!0,sx:fPn,children:[r&&(0,Fd.jsx)(Jse,{collapsed:r,onToggleCollapsed:n}),(0,Fd.jsx)(Zir,{reconnecting:e.reconnecting}),(0,Fd.jsx)(Iir,{}),(0,Fd.jsx)(Me,{sx:dPn,children:(0,Fd.jsx)(tor,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd})}),(0,Fd.jsxs)(Me,{sx:{display:"flex",ml:1,mr:2},children:[(0,Fd.jsx)(Hse,{cwd:t.selectedCwd}),(0,Fd.jsx)(Dir,{cwd:t.selectedCwd})]}),(0,Fd.jsx)(vor,{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession,onStartRun:e.startRun}),(0,Fd.jsx)(Gir,{rateLimits:e.rateLimits})]})}var khe=$(Re(),1);var xor=$(V(),1),Tor=St((0,xor.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var Sor=$(V(),1),Cor=St((0,Sor.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var wor=$(V(),1),_or=St((0,wor.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var YIe=$(V(),1);function kor({mode:e}){return e==="dark"?(0,YIe.jsx)(_or,{fontSize:"small"}):(0,YIe.jsx)(Cor,{fontSize:"small"})}var fh=$(V(),1);function Eor({mode:e,onToggleColorMode:t,onRestart:r,onUpdate:n}){return[(0,fh.jsxs)(ui,{onClick:t,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(kor,{mode:e})}),(0,fh.jsx)(A9,{children:"Toggle dark mode"})]},"color-mode"),(0,fh.jsx)(ns,{},"restart-divider"),(0,fh.jsxs)(ui,{onClick:r,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(Rse,{fontSize:"small"})}),(0,fh.jsx)(A9,{children:uO.label})]},"restart"),(0,fh.jsxs)(ui,{onClick:n,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(Tor,{fontSize:"small"})}),(0,fh.jsx)(A9,{children:"Update assist"})]},"update")]}var EE=$(V(),1);function Ror({reconnecting:e,onClose:t}){let{pending:r,error:n,clearError:i,restart:o}=hO(uO.target,e);return(0,EE.jsxs)(EE.Fragment,{children:[(0,EE.jsx)(ra,{title:uO.label,message:uO.message,confirmLabel:"Restart",busy:r,onConfirm:()=>{o()},onCancel:t}),(0,EE.jsx)(ff,{error:n,onClose:i})]})}var Por=$(V(),1);function Aor({onConfirm:e,onClose:t}){return(0,Por.jsx)(ra,{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal.",confirmLabel:"Update",onConfirm:()=>{e(),t()},onCancel:t})}var RE=$(V(),1);function Lor({restarting:e,reconnecting:t,onCloseRestart:r,updating:n,onCloseUpdate:i}){let{launchAssist:o,armUpdateReload:a}=gp();return(0,RE.jsxs)(RE.Fragment,{children:[e&&(0,RE.jsx)(Ror,{reconnecting:t,onClose:r}),n&&(0,RE.jsx)(Aor,{onConfirm:()=>{a(),o(["update"])},onClose:i})]})}var Mor=$(V(),1),Ior=St((0,Mor.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var Dor=$(V(),1),Oor=St((0,Dor.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var whe=$(V(),1);function Nor(){let e=oo();return(0,whe.jsx)(Mn,{title:"Config",children:(0,whe.jsx)(gr,{size:"small",sx:{color:"inherit"},"aria-label":"Config",onClick:()=>e("/config"),children:(0,whe.jsx)(Oor,{fontSize:"small"})})})}var KIe=$(V(),1),Bor=St([(0,KIe.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,KIe.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber");var FV="0.606.1";var _he=$(Re(),1),XIe=(0,_he.createContext)(null);function For(){return(0,_he.useContext)(XIe)}var JC=$(V(),1);function $or(){let e=For();return FV?(0,JC.jsxs)(JC.Fragment,{children:[(0,JC.jsxs)(tt,{variant:"caption",sx:{opacity:.4,userSelect:"none",lineHeight:1},children:["v",FV]}),e&&e!==FV&&(0,JC.jsx)(Mn,{title:`Daemon is running v${e}, but this page was served by v${FV}. Restart the daemon to match.`,children:(0,JC.jsx)(Bor,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})]}):null}var AE=$(V(),1);function zor({open:e,onOpen:t}){return(0,AE.jsxs)(Me,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:"inherit"},children:[(0,AE.jsx)($or,{}),(0,AE.jsx)(Nor,{}),(0,AE.jsx)(gr,{onClick:r=>t(r.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,AE.jsx)(Ior,{fontSize:"small"})})]})}var ew=$(V(),1);function Uor({mode:e,toggle:t,reconnecting:r}){let[n,i]=(0,khe.useState)(null),[o,a]=(0,khe.useState)(!1),[s,l]=(0,khe.useState)(!1),u=!!n,h=()=>i(null);return(0,ew.jsxs)(ew.Fragment,{children:[(0,ew.jsx)(zor,{open:u,onOpen:i}),(0,ew.jsx)(ep,{anchorEl:n,open:u,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:Eor({mode:e,onToggleColorMode:()=>{t(),h()},onRestart:()=>{h(),a(!0)},onUpdate:()=>{h(),l(!0)}})}),(0,ew.jsx)(Lor,{restarting:o,reconnecting:r,onCloseRestart:()=>a(!1),updating:s,onCloseUpdate:()=>l(!1)})]})}var Vor=$(Re(),1);var Wor=$(V(),1);function Hor({conflict:e,onConfirm:t,onCancel:r}){let{name:n,cwd:i,port:o}=e.existing,a=Qp(i),s=o?` on port ${o}`:"",l=a?` in ${a}`:"";return(0,Wor.jsx)(ra,{title:"Replace running server?",message:`"${n}" is already serving${s}${l}. Replace it \u2014 stop the running server and start this one?`,confirmLabel:"Replace",confirmColor:"error",onConfirm:t,onCancel:r})}var Ehe=$(V(),1);function Gor({socket:e,children:t}){let{serverConflict:r,clearServerConflict:n,retrySession:i,stopSession:o,startRun:a,discardSession:s}=e,l=(0,Vor.useMemo)(()=>({onStop:o,onStart:a,onDiscard:s}),[o,a,s]),u=()=>{r&&(r.runName?a(r.runName,r.cwd,!0,r.launchedFrom):r.sessionId&&i(r.sessionId,!0),n())};return(0,Ehe.jsxs)(QPe.Provider,{value:l,children:[t,r&&(0,Ehe.jsx)(Hor,{conflict:r,onConfirm:u,onCancel:n})]})}var PE=$(Re(),1);function Rhe(e,t,r){if(e)return t.find(n=>n.id===e)??r.find(n=>n.sessionId===e)}function qor(e,t,r,n){let i=Rhe(e,t,r);return i?.cwd&&Ay(i)===n?i.cwd:n}function jor(e,t){let r=new Set,n=new Set,i=[];for(let o of t){if(o.cwdMissing)continue;let a=zS(o),s=Ay(o);!a||!s||r.has(a)||n.has(s)||(r.add(a),n.add(s),i.push(s))}return e&&!r.has(ase(e,t))&&!n.has(e)&&i.unshift(e),i}var Yor=$(Re(),1);function Ahe(e,t,r){let n=Rhe(e,t,r);return n&&Ay(n)}function Kor(e,t,r,n){let i=Ahe(e,t,r);(0,Yor.useEffect)(()=>{i&&n(i)},[i,n])}function Xor(e,t,r,n){let[i,o]=(0,PE.useState)(e);(0,PE.useEffect)(()=>{e&&!i&&o(e)},[e,i]),Kor(r,n,t,o);let a=(0,PE.useMemo)(()=>jor(e,t),[e,t]),s=qor(r,n,t,i);return(0,PE.useMemo)(()=>({repos:a,selectedCwd:i,worktreeCwd:s,setSelectedCwd:o}),[a,i,s])}var Lhe=$(Re(),1);var tw=$(Re(),1);var Zor=$(Re(),1),Phe="assist:reloaded-after-update";function Qor(e){(0,Zor.useEffect)(()=>{globalThis.sessionStorage?.getItem(Phe)&&(globalThis.sessionStorage.removeItem(Phe),e({message:"Reloaded after updating assist",sessionId:null}))},[e])}var Ng=$(Re(),1);function Jor(e){return e.commandType==="assist"&&e.assistArgs?.[0]==="update"&&e.status==="done"}function ear(e,t){let[r,n]=(0,Ng.useState)(!1),[i,o]=(0,Ng.useState)(!1),a=(0,Ng.useRef)(!1),s=(0,Ng.useRef)(e);s.current=e;let l=(0,Ng.useRef)(new Set),u=(0,Ng.useCallback)(()=>{a.current=!1,o(!1),l.current=new Set(s.current.filter(Jor).map(h=>h.id)),n(!0)},[]);return(0,Ng.useEffect)(()=>{if(!r||i)return;if(t){a.current=!0;return}if(!a.current)return;e.some(f=>Jor(f)&&!l.current.has(f.id))&&o(!0)},[r,i,t,e]),{arm:u,completed:i}}function tar(e,t,r,n){let{arm:i,completed:o}=ear(e,t),a=(0,tw.useRef)(!1),s=(0,tw.useCallback)(()=>{globalThis.sessionStorage?.setItem(Phe,"1")},[]),{error:l,restart:u}=hO("webserver",t,s);return Qor(r),(0,tw.useEffect)(()=>{l&&n(l)},[l,n]),(0,tw.useEffect)(()=>{!o||a.current||(a.current=!0,u())},[o,u]),{armUpdateReload:(0,tw.useCallback)(()=>{a.current=!1,i()},[i])}}function rar(e){let{armUpdateReload:t}=tar(e.sessions,e.reconnecting,e.setSuccess,e.setError),r=(0,Lhe.useMemo)(()=>({launchAssist:e.createAssistSession,launchAgentInStream:e.createSessionInStream,armUpdateReload:t}),[e.createAssistSession,e.createSessionInStream,t]),n=oo(),i=(0,Lhe.useCallback)(o=>{e.selectSession(o),n("/sessions"),e.clearSuccess()},[n,e.selectSession,e.clearSuccess]);return{launch:r,viewLaunchedSession:i}}var nar=$(Re(),1);function iar(e,t,r,n){let i=Ahe(e,t,r);(0,nar.useEffect)(()=>{e&&i&&n({type:"set-active",cwd:i,sessionId:e})},[e,i,n])}var Mhe=$(Re(),1);function oar(e,t){let r=(0,Mhe.useRef)(new Map);(0,Mhe.useEffect)(()=>{let n=new Set;for(let{id:i,status:o}of e)n.add(i),r.current.get(i)!==o&&(r.current.set(i,o),console.debug(`[sessions] render session ${i} status=${o}`),t({type:"ui-status",sessionId:i,status:o}));for(let i of r.current.keys())n.has(i)||r.current.delete(i)},[e,t])}var sar=$(Re(),1);function aar(e){let t=e;if(t.type==="create")return{cwd:t.cwd,title:t.prompt?.trim()||(t.design?"New design session":"New session")};if(t.type==="create-assist"){let r=t.title?.trim();return{cwd:t.cwd,title:r||"New session",named:!!r}}return null}function lar(e,t){return(0,sar.useCallback)(r=>{let n=e.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r));let i=aar(r);i&&t(i)},[e,t])}var Jy=$(Re(),1);function car(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,auto:!0})}function uar(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,design:!0})}function har(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,harness:t})}function far(e){return(t,r,n)=>e({type:"create-assist",assistArgs:t,cwd:r,...n})}function dar(e){return(t,r,n,i)=>e({type:"resume",sessionId:t,cwd:r,name:n,harness:i})}function par(e,t){return(r,n)=>{t.delete(r),e({type:"retry",sessionId:r,replace:n})}}function mar(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function gar(e,t){return r=>{e({type:"dismiss",sessionId:r}),t.delete(r)}}function yar(e,t){return r=>{e({type:"discard",sessionId:r}),t.delete(r)}}function bar(e){return t=>e({type:"stop",sessionId:t})}function xar(e){return(t,r,n,i)=>e({type:"create-run",runName:t,cwd:r,replace:n,launchedFrom:i})}function Tar(e){return(t,r)=>e({type:"set-autorun",sessionId:t,enabled:r})}function Sar(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function Car(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function war(e){return(t,r)=>e({type:"input",sessionId:t,data:r})}function _ar(e){return(t,r,n)=>e({type:"resize",sessionId:t,cols:r,rows:n})}function kar(e,t){return(r,n)=>{let i=e.get(r);return i&&n(i),t.set(r,n),()=>t.delete(r)}}function Ear(e){return(t,r,n,i)=>e({type:"pr-decision",sessionId:t,requestId:r,decision:n,...i})}var LE=$(Re(),1);function Rar(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,joinSessionId:t,auto:!0})}function Aar(e){return{createSession:(0,LE.useMemo)(()=>car(e),[e]),createSessionInStream:(0,LE.useMemo)(()=>Rar(e),[e]),createDesignSession:(0,LE.useMemo)(()=>uar(e),[e]),createHarnessSession:(0,LE.useMemo)(()=>har(e),[e]),createAssistSession:(0,LE.useMemo)(()=>far(e),[e]),resumeSession:(0,LE.useMemo)(()=>dar(e),[e])}}var $V=$(Re(),1);function Par(e,t){let r=(0,$V.useCallback)((a,s)=>{par(e,t.current)(a,s)},[e,t]),n=(0,$V.useCallback)(a=>{mar(e,t.current)(a)},[e,t]),i=(0,$V.useCallback)(a=>{gar(e,t.current)(a)},[e,t]),o=(0,$V.useCallback)(a=>{yar(e,t.current)(a)},[e,t]);return{retrySession:r,restartSession:n,dismissSession:i,discardSession:o}}function Lar(e,t,r){let n={...Aar(e),sendInput:(0,Jy.useMemo)(()=>war(e),[e]),sendResize:(0,Jy.useMemo)(()=>_ar(e),[e]),sendPrDecision:(0,Jy.useMemo)(()=>Ear(e),[e]),setAutoRun:(0,Jy.useMemo)(()=>Tar(e),[e]),setAutoAdvance:(0,Jy.useMemo)(()=>Sar(e),[e]),setStarred:(0,Jy.useMemo)(()=>Car(e),[e]),stopSession:(0,Jy.useMemo)(()=>bar(e),[e]),startRun:(0,Jy.useMemo)(()=>xar(e),[e])},i=(0,Jy.useMemo)(()=>kar(t.current,r.current),[t,r]);return{...n,...Par(e,t),onOutput:i}}var Ihe=$(Re(),1);function Mar(e,t,r){let n=(0,Ihe.useCallback)(a=>{r(a),e({type:"fetch-transcript",sessionId:a})},[e,r]),i=(0,Ihe.useCallback)(()=>{r(null)},[r]),o=(0,Ihe.useCallback)(a=>{r(null),t(a)},[t,r]);return{viewTranscript:n,clearTranscript:i,selectSession:o}}var Bg=$(Re(),1);var Dar=$(Re(),1);function Iar(e,t,r=null){return t!==null?e.some(n=>n.id===t)?t:e[0]?.id??null:r&&e.some(n=>n.id===r)?r:e[0]?.id??null}function Oar(e,t,r){let n=Ss().pathname,i=n.startsWith("/backlog")||n.startsWith("/usage");(0,Dar.useEffect)(()=>{if(i){t(null);return}t(o=>Iar(e,o,r))},[e,t,r,i])}var ZIe=$(Re(),1);function Nar(){let[e,t]=(0,ZIe.useState)(null),[r,n]=(0,ZIe.useState)(null);return{daemonActiveId:e,setDaemonActiveId:t,daemonVersion:r,setDaemonVersion:n}}var ME=$(Re(),1);function Bar(e,t){if(!t.some(n=>e.has(n)))return e;let r=new Set(e);for(let n of t)r.delete(n);return r}function Far(e,t){let r=[];for(let n of t){let i=e.get(n.id);i!==void 0&&i!==n.startedAt&&r.push(n.id)}return r}function $ar(){let[e,t]=(0,ME.useState)(new Set),r=(0,ME.useRef)(new Map),n=(0,ME.useCallback)(o=>{t(a=>a.has(o)?a:new Set(a).add(o))},[]),i=(0,ME.useCallback)(o=>{let a=Far(r.current,o);r.current=new Map(o.map(s=>[s.id,s.startedAt])),a.length&&t(s=>Bar(s,a))},[]);return{initialized:e,markInitialized:n,syncSessions:i}}var rw=$(Re(),1);function zar(){let[e,t]=(0,rw.useState)(null),[r,n]=(0,rw.useState)(null),[i,o]=(0,rw.useState)(null),a=(0,rw.useCallback)(()=>t(null),[]),s=(0,rw.useCallback)(()=>n(null),[]),l=(0,rw.useCallback)(()=>o(null),[]);return{error:e,setError:t,clearError:a,success:r,setSuccess:n,clearSuccess:s,serverConflict:i,setServerConflict:o,clearServerConflict:l}}var e1=$(Re(),1);function Uar(e,t){return[...e,{...t,windows:qS(t.cwd),status:"launching"}]}function Dhe(e){return e.find(t=>t.status==="launching")}function Har(e){let t=Dhe(e);return t?e.filter(r=>r.id!==t.id):e}function War(e,t){let r=Dhe(e);return r?QIe(e,r.id,t):e}function QIe(e,t,r){return e.map(n=>n.id===t&&n.status==="launching"?{...n,status:"error",error:r}:n)}function Var(e,t){return e.filter(r=>r.id!==t)}var Gar=$(Re(),1);var pPn=6e4,mPn="Launch timed out \u2014 the session did not start.";function qar(e,t){(0,Gar.useEffect)(()=>{let r=e.filter(i=>i.status==="launching");if(r.length===0)return;let n=r.map(i=>setTimeout(()=>t(o=>QIe(o,i.id,mPn)),Math.max(0,pPn-(Date.now()-i.startedAt))));return()=>n.forEach(clearTimeout)},[e,t])}function jar(){let[e,t]=(0,e1.useState)([]),r=(0,e1.useRef)([]),n=(0,e1.useCallback)(l=>{r.current=l(r.current),t(r.current)},[]),i=(0,e1.useCallback)(l=>{n(u=>Uar(u,{id:crypto.randomUUID(),startedAt:Date.now(),...l}))},[n]),o=(0,e1.useCallback)(()=>{let l=Dhe(r.current);return n(Har),l?.named?l.title:void 0},[n]),a=(0,e1.useCallback)(l=>n(u=>War(u,l)),[n]),s=(0,e1.useCallback)(l=>n(u=>Var(u,l)),[n]);return qar(e,n),{pendingLaunches:e,addPendingLaunch:i,resolvePendingLaunch:o,failPendingLaunch:a,dismissPendingLaunch:s}}var Yar=$(Re(),1);function Kar(e,t){return(0,Yar.useCallback)(r=>{e(r),t(r)},[e,t])}var nw=$(Re(),1);function Xar(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function Zar(e,t){let r=e.sessionId,n=t.resolvePendingLaunch();t.setViewingTranscriptSessionId(null),t.setActiveId(r),e.isNew&&t.setSuccess({message:n?`Started ${n}`:"New session started",sessionId:r})}function Qar(e,t){let r=e.message;t.setError(r),t.failPendingLaunch(r)}function Jar(e,t){t.setSuccess({message:e.message,sessionId:null})}function esr(e,t){let r=e.sessionId,n=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,n+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function tsr(e,t){t.setServerConflict({existing:e.existing,runName:e.runName,cwd:e.cwd,sessionId:e.sessionId,launchedFrom:e.launchedFrom})}function rsr(e,t){let r=new Set(t.map(i=>i.id)),n=null;for(let i of Object.values(e))r.has(i)&&(n=i);return n}function nsr(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd);let n=e.active??{};t.setDaemonActiveId(rsr(n,r))}function isr(e,t){switch(e.type){case"sessions":nsr(e,t);break;case"created":Zar(e,t);break;case"history":t.setHistory(e.sessions);break;case"transcript":t.setTranscript({sessionId:e.sessionId,messages:e.messages});break;case"hello":t.setDaemonVersion(e.version);break;case"error":Qar(e,t);break;case"notice":Jar(e,t);break;case"run-conflict":tsr(e,t);break;case"limits":t.setRateLimits(e.rateLimits);break;case"clear":Xar(e,t);break;case"output":esr(e,t);break}}function osr(e,t={}){let r=location.protocol==="https:"?"wss:":"ws:",n=new WebSocket(`${r}//${location.host}/ws`);return n.onopen=()=>{t.onOpen?.(),n.send(JSON.stringify({type:"hello"})),n.send(JSON.stringify({type:"history"}))},n.onmessage=i=>{isr(JSON.parse(i.data),e)},n.onclose=()=>t.onClose?.(),n}function asr(e,t,r,n){let i=!1,o,a=0,s=!1,l=()=>{i||t(osr(e,{onOpen:()=>{s&&r(),s=!1,n(!1),a=0},onClose:()=>{if(i)return;s=!0,n(!0);let u=Math.min(300*2**a,2e3);a+=1,o=setTimeout(l,u)}}))};return l(),()=>{i=!0,o&&clearTimeout(o)}}function ssr(e){let t=(0,nw.useRef)(null),[r,n]=(0,nw.useState)(!1),{handleSessions:i,markInitialized:o,buffers:a,handlers:s}=e;(0,nw.useEffect)(()=>{let u=()=>{a.current?.clear();let f=s.current;if(f)for(let d of f.values())d("\x1Bc")},h=asr({...e,setSessions:i},f=>{t.current=f},u,n);return()=>{h(),t.current?.close()}},[i,o,a,s]);let l=(0,nw.useCallback)(()=>{let u=t.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function lsr(){let[e,t]=(0,Bg.useState)([]),[r,n]=(0,Bg.useState)([]),[i,o]=(0,Bg.useState)(null),a=Nar(),[s,l]=(0,Bg.useState)(null),[u,h]=(0,Bg.useState)(null),[f,d]=(0,Bg.useState)(""),p=zar(),m=jar(),[g,y]=(0,Bg.useState)(null),{initialized:v,markInitialized:b,syncSessions:x}=$ar(),S=(0,Bg.useRef)(new Map),C=(0,Bg.useRef)(new Map),w=Kar(x,t),{wsRef:_,requestHistory:k,reconnecting:L}=ssr({handleSessions:w,setHistory:n,setActiveId:o,...a,setTranscript:l,setViewingTranscriptSessionId:h,setCurrentCwd:d,...p,...m,setRateLimits:y,markInitialized:b,buffers:S,handlers:C});return Oar(e,o,a.daemonActiveId),{sessions:e,history:r,activeId:i,setActiveId:o,...a,transcript:s,viewingTranscriptSessionId:u,setViewingTranscriptSessionId:h,currentCwd:f,...p,...m,rateLimits:g,initialized:v,wsRef:_,buffers:S,handlers:C,requestHistory:k,reconnecting:L}}function csr(){let e=lsr(),{wsRef:t,buffers:r,handlers:n,addPendingLaunch:i,activeId:o,sessions:a}=e,s=lar(t,i),l=Lar(s,r,n);iar(o,a,e.history,s),oar(a,s);let u=Mar(s,e.setActiveId,e.setViewingTranscriptSessionId);return{...e,...l,...u}}var hsr=$(Re(),1);var usr="assist:sidebar-collapsed";function fsr(){let[e,t]=(0,hsr.useState)(()=>Hy(usr).length>0);return{collapsed:e,onToggleCollapsed:()=>{let r=!e;Wy(usr,r?[!0]:[]),t(r)}}}var Ohe=$(Re(),1);function dsr(){let[e,t]=(0,Ohe.useState)(!0);return(0,Ohe.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/session-layout")).json();r||t(!!i?.topBar)}catch{t(!0)}})(),()=>{r=!0}},[]),e}function psr(){let e=csr(),t=Xor(e.currentCwd,e.history,e.activeId,e.sessions),{launch:r,viewLaunchedSession:n}=rar(e),i=dsr(),o=fsr();return{socket:e,selection:t,launch:r,viewLaunchedSession:n,topBar:i,sidebarCollapse:o}}var xf=$(V(),1),gPn={zIndex:e=>e.zIndex.drawer+1},yPn={minHeight:48};function msr({mode:e,toggle:t}){let{socket:r,selection:n,launch:i,viewLaunchedSession:o,topBar:a,sidebarCollapse:s}=psr();return(0,xf.jsx)(VPe.Provider,{value:a,children:(0,xf.jsx)(y7e.Provider,{value:s,children:(0,xf.jsx)(uB.Provider,{value:n,children:(0,xf.jsxs)(O0e.Provider,{value:i,children:[(0,xf.jsx)(XIe.Provider,{value:r.daemonVersion,children:(0,xf.jsx)(Uor,{mode:e,toggle:t,reconnecting:r.reconnecting})}),(0,xf.jsx)(tde,{position:"fixed",elevation:1,sx:gPn,children:(0,xf.jsx)(bor,{socket:r,selection:n})}),(0,xf.jsx)(qw,{variant:"dense",sx:yPn}),(0,xf.jsx)(Gor,{socket:r,children:(0,xf.jsx)(yir,{socket:r})}),(0,xf.jsx)(Mir,{socket:r,onViewLaunchedSession:o})]})})})})}var gsr=$(Re(),1);function ysr(){let[e,t]=(0,gsr.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(n=>{let i=n==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",i)}catch{}return i})}}var iw=$(V(),1),vPn={MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}}};function bPn(){let{mode:e,toggle:t}=ysr(),r=(0,bsr.useMemo)(()=>Vg({palette:{mode:e,...e==="dark"&&{background:{default:"#1e1e1e",paper:"#252526"}}},components:vPn}),[e]);return(0,iw.jsxs)(jG,{theme:r,children:[(0,iw.jsx)(Oq,{}),(0,iw.jsx)(msr,{mode:e,toggle:t})]})}var xPn=E0e([{path:"*",element:(0,iw.jsx)(bPn,{})}]);function TPn(){return(0,iw.jsx)(b0e,{router:xPn})}var vsr=document.getElementById("app");vsr&&(0,xsr.createRoot)(vsr).render((0,iw.jsx)(TPn,{}));})();
3974
+ `,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 WMe.get()},set promptLabel(e){WMe.set(e)},get tooMuchOutput(){return VMe.get()},set tooMuchOutput(e){VMe.set(e)}}}_verifyIntegers(...e){for(Yy of e)if(Yy===1/0||isNaN(Yy)||Yy%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Yy of e)if(Yy&&(Yy===1/0||isNaN(Yy)||Yy%1!==0||Yy<0))throw new Error("This API only accepts positive integers")}};var BIe=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\^<>`]*[^\s"':,.!?{}|\\^~[\]`()<>]/;function _An(e){try{return!!new URL(e).host}catch{return!1}}function Mnr(e,t){let r=e(t),n=e(t+1);return!!r&&!!n&&(n.isWrapped||r.isFull)}function kAn(e,t){let r=[];for(let n=t;n-t<64;n++){let i=e(n);if(!i||(r.push(i.text),!Mnr(e,n)))break}return r}function Lnr(e,t,r){let n=t;for(let i of e){if(r<i.length)return{x:r+1,y:n+1};r-=i.length,n++}}function EAn(e,t,r){let n=r[0],i=Lnr(e,t,r.index),o=Lnr(e,t,r.index+n.length-1);if(!(!_An(n)||!i||!o))return{text:n,range:{start:i,end:o}}}function RAn(e,t,r){let n=new RegExp(r.source,`${r.flags||""}g`);return[...e.join("").matchAll(n)].flatMap(o=>EAn(e,t,o)??[])}function Inr(e,t,r=BIe){if(!e(t-1))return[];let n=t-1;for(;n>0&&Mnr(e,n-1);)n--;return RAn(kAn(e,n),n,r)}function Dnr(e,t){let r=n=>{let i=e.buffer.active.getLine(n);if(!i)return;let o=e.cols,a=i.getCell(o-1);return{text:i.translateToString(!0,0,o),isWrapped:i.isWrapped,isFull:!!a&&a.getChars()!==""&&a.getChars()!==" "}};return{provideLinks(n,i){let o=Inr(r,n,BIe);i(o.map(a=>({range:a.range,text:a.text,activate:t})))}}}function Onr(e){let t=new Pnr({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', Consolas, monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4"},linkHandler:{activate:(o,a)=>{window.open(a,"_blank")}}}),r=new ler;t.loadAddon(r);let n=t.registerLinkProvider(Dnr(t,(o,a)=>{window.open(a,"_blank")}));t.open(e);let i;try{i=new Etr,i.onContextLoss(()=>{i?.dispose(),i=void 0}),t.loadAddon(i)}catch{i=void 0}return r.fit(),{term:t,fitAddon:r,dispose:()=>{n.dispose(),i?.dispose(),t.dispose()}}}function Nnr(e,t,r,n){if(e.type!=="keydown"||!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)return!0;let i=e.key.toLowerCase();return i==="c"&&t.hasSelection()?(e.preventDefault(),r.writeText(t.getSelection()),!1):i==="v"?(e.preventDefault(),r.readText().then(n),!1):!0}function rhe(e){return e.type==="keydown"&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="p"}function Bnr(e,t,r,n,i){let o=Onr(e);o.term.onData(u=>r(t,u)),o.term.attachCustomKeyEventHandler(u=>rhe(u)?!1:Nnr(u,o.term,navigator.clipboard,h=>o.term.paste(h)));let a=n(t,u=>o.term.write(u)),s=new ResizeObserver(()=>{cue(e)&&(o.fitAddon.fit(),i(t,o.term.cols,o.term.rows))});return s.observe(e),{handle:o,cleanup:()=>{s.disconnect(),a(),o.dispose()}}}function Fnr(e,t,r,n,i,o){let a=(0,EV.useRef)(null);(0,EV.useEffect)(()=>{let s=e.current;if(!s)return;let{handle:l,cleanup:u}=Bnr(s,t,n,i,o);return a.current=l,()=>{u(),a.current=null}},[e,t,i,n,o]),(0,EV.useEffect)(()=>{let s=a.current;if(!r||!s)return;let l=setTimeout(()=>{cue(e.current)&&(s.fitAddon.fit(),s.term.focus(),o(t,s.term.cols,s.term.rows))},50);return()=>clearTimeout(l)},[e,r,t,o])}var Unr=$(V(),1);function znr({sessionId:e,visible:t,onOutput:r,sendInput:n,sendResize:i}){let o=(0,$nr.useRef)(null);return Fnr(o,e,t,n,r,i),(0,Unr.jsx)(Me,{ref:o,sx:{position:"absolute",inset:"0 0 0 8px",visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none"}})}var SE=$(V(),1);function Hnr({sessions:e,activeId:t,activeLoading:r,onOutput:n,sendInput:i,sendResize:o}){return(0,SE.jsxs)(Me,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:[e.map(a=>(0,SE.jsx)(znr,{sessionId:a.id,visible:a.id===t,onOutput:n,sendInput:i,sendResize:o},a.id)),r&&(0,SE.jsx)(ser,{}),e.length===0&&(0,SE.jsx)(Me,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,SE.jsx)(tt,{variant:"body2",color:"text.disabled",children:"Create a session to get started"})})]})}var Vnr=$(V(),1);function Wnr({sessions:e,activeId:t,initialized:r,onOutput:n,sendInput:i,sendResize:o}){let a=e.find(l=>l.id===t),s=a!==void 0&&hse(a,r);return(0,Vnr.jsx)(Hnr,{sessions:e,activeId:t,activeLoading:s,onOutput:n,sendInput:i,sendResize:o})}var aO=$(V(),1),AAn={position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0};function Gnr({activeSession:e,sendPrDecision:t,showLastMessage:r,...n}){return(0,aO.jsxs)(Me,{sx:AAn,children:[(0,aO.jsx)(JJt,{session:e,sendPrDecision:t,sendInput:n.sendInput,children:(0,aO.jsx)(Wnr,{...n})}),r&&e!==void 0&&(0,aO.jsx)(oer,{message:e.lastUserMessage})]})}var qnr=$(V(),1),jnr=St((0,qnr.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build");var pm=$(V(),1);function Ynr({message:e}){return e.role==="tool"?(0,pm.jsx)(PAn,{tool:e.tool,target:e.target}):(0,pm.jsx)(LAn,{role:e.role,text:e.text})}function PAn({tool:e,target:t}){return(0,pm.jsxs)(Me,{sx:{display:"flex",alignItems:"center",gap:1,py:.5,pl:1},children:[(0,pm.jsx)(jnr,{sx:{fontSize:14,color:"text.disabled"}}),(0,pm.jsxs)(tt,{variant:"caption",sx:{color:"text.secondary",fontFamily:"monospace"},children:[(0,pm.jsx)(Me,{component:"span",sx:{color:"warning.main"},children:e}),t&&(0,pm.jsxs)(Me,{component:"span",children:[" ",t]})]})]})}function LAn({role:e,text:t}){let r=e==="user",n=r?"info.main":"success.main";return(0,pm.jsxs)(Me,{sx:{mb:1.5,pl:1.5,py:1,pr:1,borderLeft:2,borderColor:n,borderTopRightRadius:1,borderBottomRightRadius:1,bgcolor:r?"action.hover":"transparent"},children:[(0,pm.jsx)(tt,{variant:"caption",sx:{color:n,fontWeight:600,display:"block",mb:.5},children:r?"User":"Assistant"}),(0,pm.jsx)(tt,{variant:"body2",sx:{color:"text.primary",whiteSpace:"pre-wrap",overflowWrap:"anywhere",lineHeight:1.6},children:t})]})}var Qy=$(V(),1);function MAn(e){let t=new Map;return e.map(r=>{let n=r.role==="tool"?`tool:${r.tool}:${r.target}`:`${r.role}:${r.text.slice(0,40)}`,i=t.get(n)??0;return t.set(n,i+1),{...r,key:`${n}#${i}`}})}function Xnr({messages:e,loading:t}){return t?(0,Qy.jsxs)(Me,{sx:Knr,children:[(0,Qy.jsx)(ro,{size:20}),(0,Qy.jsx)(tt,{variant:"caption",color:"text.disabled",children:"Loading transcript\u2026"})]}):e.length===0?(0,Qy.jsx)(Me,{sx:Knr,children:(0,Qy.jsx)(tt,{variant:"body2",color:"text.disabled",children:"No transcript available"})}):(0,Qy.jsx)(Me,{sx:{position:"absolute",inset:0,overflowY:"auto",p:2},children:(0,Qy.jsx)(Me,{sx:{maxWidth:820,mx:"auto"},children:MAn(e).map(r=>(0,Qy.jsx)(Ynr,{message:r},r.key))})})}var Knr={position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:1.5,alignItems:"center",justifyContent:"center"};var FIe=$(V(),1);function Znr({sessionId:e,transcript:t}){let r=t?.sessionId===e;return(0,FIe.jsx)(Me,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:(0,FIe.jsx)(Xnr,{messages:r?t?.messages??[]:[],loading:!r})})}var WC=$(V(),1),IAn={flex:1,minHeight:0,display:"flex",flexDirection:"column"},DAn={flexShrink:0};function Qnr({viewingTranscriptSessionId:e,transcript:t,sendPrDecision:r,lifecycle:n,...i}){let o=hf();if(e!==null)return(0,WC.jsx)(Znr,{sessionId:e,transcript:t});let a=i.sessions.find(s=>s.id===i.activeId);return(0,WC.jsxs)(Me,{sx:IAn,children:[o&&a!==void 0&&(0,WC.jsx)(Me,{sx:DAn,children:(0,WC.jsx)(YZt,{session:a,lifecycle:n})}),(0,WC.jsx)(QZt,{sessionId:i.activeId,sessions:i.sessions,sendInput:i.sendInput,children:(0,WC.jsx)(Gnr,{...i,activeSession:a,sendPrDecision:r,showLastMessage:o})})]})}var tir=$(V(),1);function eir({socket:e}){let t=(0,Jnr.useMemo)(()=>({onRetry:e.retrySession,onRestart:e.restartSession,onDismiss:e.dismissSession,onSetAutoRun:e.setAutoRun,onSetAutoAdvance:e.setAutoAdvance}),[e.retrySession,e.restartSession,e.dismissSession,e.setAutoRun,e.setAutoAdvance]);return(0,tir.jsx)(Qnr,{lifecycle:t,sessions:e.sessions,activeId:e.activeId,initialized:e.initialized,onOutput:e.onOutput,sendInput:e.sendInput,sendResize:e.sendResize,viewingTranscriptSessionId:e.viewingTranscriptSessionId,transcript:e.transcript,sendPrDecision:e.sendPrDecision})}function $Ie(e,t,r){if(e==null)return;let n=Math.max(0,e-r),i=Math.max(0,t-n)/t;if(!(i<.05))return i}function nhe(e,t){let r=Math.max(0,e-t),n=Math.floor(r/86400),i=Math.floor(r%86400/3600),o=Math.floor(r%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function OAn(e,t,r,n){let i=$Ie(t,r,n);if(i!=null)return e/i}function VC(e,t,r,n){let i=OAn(e,t,r,n);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var CE={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};var NAn={ok:"success.main",warn:"warning.main",over:"error.main"};function GC(e){return NAn[e]}var PV=$(V(),1),BAn={ok:"success",warn:"warning",over:"error"};function rir({percentage:e,level:t}){return(0,PV.jsxs)(Me,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,PV.jsx)(_9,{variant:"determinate",value:Math.min(100,e),color:BAn[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,PV.jsxs)(Me,{sx:{minWidth:40,textAlign:"right",color:GC(t)},children:[Math.round(e),"%"]})]})}function nir(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var FAn=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function zIe(e){return FAn.format(e)}var ihe=$(V(),1);function iir({peak:e}){return(0,ihe.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,ihe.jsx)(Mn,{title:`Cycle started ${zIe(new Date(e.createdAt))}`,children:(0,ihe.jsx)("span",{children:zIe(new Date(e.resetsAt*1e3))})})})}var air=$(V(),1);function oir(){return(0,air.jsx)(An,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function sir(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${i6(e.tokensUp)} \u2193 ${i6(e.tokensDown)}`}var Ig=$(V(),1);function lir({peak:e,now:t}){let{label:r,seconds:n,tint:i}=CE[e.window],o=VC(e.usedPercentage,e.resetsAt,n,t);return(0,Ig.jsxs)(Pm,{sx:a=>({backgroundColor:i?a.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,Ig.jsxs)(Xn,{children:[r,e.resetDetected&&(0,Ig.jsx)(oir,{})]}),(0,Ig.jsx)(Xn,{sx:{minWidth:160},children:(0,Ig.jsx)(rir,{percentage:e.usedPercentage,level:o})}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:nir(e)}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:e.phaseCount??0}),(0,Ig.jsx)(Xn,{align:"right",sx:{whiteSpace:"nowrap"},children:sir(e)}),(0,Ig.jsx)(iir,{peak:e})]})}var ohe=$(Re(),1);function sO(e){let[t,r]=(0,ohe.useState)(()=>Math.floor(Date.now()/1e3));return(0,ohe.useEffect)(()=>{let n=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(n)},[e]),t}var Ql=$(V(),1);function cir({peaks:e}){let t=sO(3e4);return(0,Ql.jsx)(Y9,{component:ti,children:(0,Ql.jsxs)(Vw,{size:"small",children:[(0,Ql.jsx)(K9,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,Ql.jsxs)(Pm,{children:[(0,Ql.jsx)(Xn,{children:"Window"}),(0,Ql.jsx)(Xn,{children:"Peak usage"}),(0,Ql.jsx)(Xn,{align:"right",children:(0,Ql.jsx)(Mn,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,Ql.jsx)("span",{children:"Avg context"})})}),(0,Ql.jsx)(Xn,{align:"right",children:(0,Ql.jsx)(Mn,{title:"Number of phase readings behind the average.",children:(0,Ql.jsx)("span",{children:"Phases"})})}),(0,Ql.jsx)(Xn,{align:"right",children:"Tokens spent"}),(0,Ql.jsx)(Xn,{align:"right",children:"Cycle reset"})]})}),(0,Ql.jsx)(Gw,{children:e.map(r=>(0,Ql.jsx)(lir,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var lO=$(Re(),1);function uir(e,t){let r=(0,lO.useRef)(null),[n,i]=(0,lO.useState)();return(0,lO.useLayoutEffect)(()=>{e===t&&r.current&&i(r.current.offsetHeight)},[e,t]),{ref:r,height:n}}var qC=$(V(),1);function hir({rows:e,total:t,page:r,pageSize:n,onPageChange:i}){let{ref:o,height:a}=uir(e.length,n);return(0,qC.jsxs)(qC.Fragment,{children:[(0,qC.jsx)(Me,{ref:o,sx:{minHeight:a},children:(0,qC.jsx)(cir,{peaks:e})}),(0,qC.jsx)(fpe,{component:"div",count:t,page:r,rowsPerPage:n,rowsPerPageOptions:[n],onPageChange:(s,l)=>i(l)})]})}var UIe=$(V(),1),$An=[{value:"all",label:"All"},{value:"five_hour",label:CE.five_hour.label},{value:"seven_day",label:CE.seven_day.label}];function fir({window:e,onChange:t}){return(0,UIe.jsx)(rp,{size:"small",exclusive:!0,value:e,onChange:(r,n)=>n&&t(n),"aria-label":"Filter peaks by rate-limit window",children:$An.map(r=>(0,UIe.jsx)(lc,{value:r.value,children:r.label},r.value))})}var LV=$(Re(),1);var jC=$(Re(),1);async function dir(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r!=="all"&&n.set("window",r);let i=await fetch(`/api/usage/history?${n}`);if(!i.ok)throw new Error(`Failed to load usage history (HTTP ${i.status}).`);return i.json()}function pir(e,t,r){let[n,i]=(0,jC.useState)([]),[o,a]=(0,jC.useState)(0),[s,l]=(0,jC.useState)(!1),[u,h]=(0,jC.useState)(!1),[f,d]=(0,jC.useState)(null);return(0,jC.useEffect)(()=>{let p=!1;return h(!0),dir(e,t,r).then(m=>{p||(i(m.rows),a(m.total),l(!0),h(!1))},m=>{p||(d(m instanceof Error?m:new Error(String(m))),h(!1))}),()=>{p=!0}},[e,t,r]),{rows:n,total:o,loaded:s,fetching:u,error:f}}var HIe=30;function mir(){let[e,t]=(0,LV.useState)(0),[r,n]=(0,LV.useState)("all"),i=pir(e,HIe,r),{total:o}=i;return(0,LV.useEffect)(()=>{if(o===0)return;let s=Math.ceil(o/HIe)-1;e>s&&t(s)},[e,o]),{...i,page:e,setPage:t,window:r,selectWindow:s=>{n(s),t(0)},pageSize:HIe}}var YC=$(V(),1);function gir(){let e=mir(),{window:t,total:r,error:n}=e;if(n)throw n;return(0,YC.jsxs)(rm,{loading:!e.loaded,title:"Usage history",isEmpty:r===0&&t==="all",emptyMessage:"No usage peaks recorded yet.",children:[(0,YC.jsx)(fir,{window:t,onChange:e.selectWindow}),(0,YC.jsx)(Me,{sx:{height:4,my:1},children:e.fetching&&(0,YC.jsx)(_9,{})}),t!=="all"&&r===0?(0,YC.jsxs)(tt,{color:"text.secondary",align:"center",sx:{py:6},children:["No ",CE[t].label," usage peaks recorded yet."]}):(0,YC.jsx)(hir,{rows:e.rows,total:r,page:e.page,pageSize:e.pageSize,onPageChange:e.setPage})]})}var jo=$(V(),1);function zAn({socket:e}){return(0,jo.jsx)(y9,{maxWidth:"md",sx:{py:3,px:2},children:(0,jo.jsx)(tFt,{socket:e})})}function yir({socket:e}){return(0,jo.jsx)(b_,{children:(0,jo.jsxs)(wl,{element:(0,jo.jsx)(mUt,{socket:e}),children:[(0,jo.jsx)(wl,{path:"sessions",element:(0,jo.jsx)(eir,{socket:e})}),(0,jo.jsx)(wl,{path:"backlog/*",element:(0,jo.jsx)(zAn,{socket:e})}),(0,jo.jsx)(wl,{path:"news",element:(0,jo.jsx)(LZt,{})}),(0,jo.jsx)(wl,{path:"usage",element:(0,jo.jsx)(gir,{})}),(0,jo.jsx)(wl,{path:"backups",element:(0,jo.jsx)(SUt,{})}),(0,jo.jsx)(wl,{path:"config",element:(0,jo.jsx)(iWt,{})}),(0,jo.jsx)(wl,{path:"diff",element:(0,jo.jsx)(eZt,{sessions:e.sessions,sendInput:e.sendInput})}),(0,jo.jsx)(wl,{path:"file",element:(0,jo.jsx)(EZt,{})}),(0,jo.jsx)(wl,{path:"*",element:(0,jo.jsx)(x0e,{to:"/sessions",replace:!0})})]})})}var fhe=$(Re(),1);var hhe=$(Re(),1);function vir(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var KC=$(V(),1),UAn={display:"flex",gap:1,alignItems:"center",minWidth:0},HAn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},WAn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},VAn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function GAn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function bir({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,KC.jsx)(Sh,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=GAn(i);return(0,KC.jsxs)(ui,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:UAn,children:[(0,KC.jsx)($D,{path:i}),(0,KC.jsxs)(Me,{sx:HAn,children:[(0,KC.jsx)(tt,{component:"span",sx:WAn,children:s}),(0,KC.jsx)(tt,{component:"span",color:"text.secondary",sx:VAn,children:a})]})]},i)})})}var ahe=$(V(),1),qAn={maxHeight:420,overflowY:"auto"},jAn={px:2,py:2,fontSize:13};function xir({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,ahe.jsx)(Me,{sx:qAn,children:e?(0,ahe.jsx)(tt,{color:"text.secondary",sx:jAn,children:e}):(0,ahe.jsx)(bir,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var Tir=$(V(),1);function she({inputRef:e,value:t,onChange:r,onKeyDown:n,placeholder:i,autoFocus:o}){return(0,Tir.jsx)(Qo,{autoFocus:o,inputRef:e,value:t,onChange:a=>r(a.target.value),onKeyDown:n,placeholder:i,size:"small",fullWidth:!0,slotProps:{input:{sx:{fontSize:12}}},sx:{p:.5}})}var lhe=$(Re(),1),Sir={files:[],loading:!1,error:!1};function Cir(e,t){let[r,n]=(0,lhe.useState)(Sir);return(0,lhe.useEffect)(()=>{if(!e){n(Sir);return}let i=!1;return n(a=>({...a,loading:!0})),(async()=>{try{let a=await fetch(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`);if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json();if(i)return;n({files:Array.isArray(s.files)?s.files:[],loading:!1,error:!1})}catch{i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t]),r}var che=$(Re(),1);function uhe(e,t,r,n){let[i,o]=(0,che.useState)(0);return(0,che.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var MV=$(V(),1),YAn={mt:6,alignSelf:"flex-start"};function wir({onClose:e}){let{worktreeCwd:t}=Oa(),[r,n]=(0,hhe.useState)(""),i=Cir(t,r),o=oo(),a=(0,hhe.useRef)(null),s=d=>o(`/file?${new URLSearchParams(t?{path:d,cwd:t}:{path:d})}`),{highlight:l,setHighlight:u,onKeyDown:h}=uhe(i.files,r,s,e),f=d=>{s(d),e()};return(0,MV.jsxs)(xh,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:YAn},transition:{onEntered:()=>a.current?.focus()}},children:[(0,MV.jsx)(she,{autoFocus:!0,inputRef:a,value:r,onChange:n,onKeyDown:h,placeholder:"Search files by name..."}),(0,MV.jsx)(xir,{message:vir(t,r,i),files:i.files,highlight:l,onHighlight:u,onSelect:f})]})}var kir=$(Re(),1);var _ir=!0;function Eir(e){(0,kir.useEffect)(()=>{let t=r=>{rhe(r)&&(r.preventDefault(),e())};return globalThis.addEventListener("keydown",t,_ir),()=>globalThis.removeEventListener("keydown",t,_ir)},[e])}var Air=$(V(),1);function Rir(){let[e,t]=(0,fhe.useState)(!1);return Eir((0,fhe.useCallback)(()=>t(!0),[])),e?(0,Air.jsx)(wir,{onClose:()=>t(!1)}):null}var dhe=$(V(),1);function Pir({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,dhe.jsx)(jc,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,dhe.jsx)(Ko,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,dhe.jsx)(xr,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var phe=$(V(),1);function Lir({reconnecting:e}){return(0,phe.jsx)(jc,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,phe.jsx)(Ko,{severity:"info",variant:"filled",icon:(0,phe.jsx)(ro,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var gx=$(V(),1);function Mir({socket:e,onViewLaunchedSession:t}){return(0,gx.jsxs)(gx.Fragment,{children:[(0,gx.jsx)(Rir,{}),(0,gx.jsx)(Lir,{reconnecting:e.reconnecting}),(0,gx.jsx)(ff,{error:e.error,onClose:e.clearError}),(0,gx.jsx)(Pir,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var cO=$(V(),1),KAn=["/sessions","/backlog","/news"];function Iir(){let e=Ss(),t=oo(),r=KAn.findIndex(i=>e.pathname.startsWith(i)),n=i=>{e.pathname!==i&&t(i)};return(0,cO.jsxs)(Z9,{value:r===-1?0:r,textColor:"inherit",indicatorColor:"secondary",children:[(0,cO.jsx)(Hx,{label:"Sessions",onClick:()=>n("/sessions")}),(0,cO.jsx)(Hx,{label:"Backlog",onClick:()=>n("/backlog")}),(0,cO.jsx)(Hx,{label:"News",onClick:()=>n("/news")})]})}var ghe=$(Re(),1),mhe=$(V(),1),XAn={color:"inherit"};function Dir({cwd:e}){let[t,r]=(0,ghe.useState)(null);return(0,ghe.useEffect)(()=>{if(!e){r(null);return}let n=!1;return(async()=>{try{let o=await(await fetch(`/api/github-url?cwd=${encodeURIComponent(e)}`)).json();n||r(o?.url??null)}catch{n||r(null)}})(),()=>{n=!0}},[e]),t?(0,mhe.jsx)(Mn,{title:"Open in GitHub",children:(0,mhe.jsx)(gr,{sx:XAn,onClick:()=>window.open(t,"_blank"),children:(0,mhe.jsx)(Ose,{})})}):null}var Nir=$(Re(),1);var yhe=$(V(),1);function Oir({window:e,windowSeconds:t,fallbackLabel:r,now:n}){let i=e?.used_percentage;if(i==null)return null;let o=VC(i,e?.resets_at,t,n),a=e?.resets_at!=null?nhe(e.resets_at,n):r;return(0,yhe.jsxs)(Me,{component:"span",children:[(0,yhe.jsxs)(Me,{component:"span",sx:{color:GC(o)},children:[Math.round(i),"%"]})," ",(0,yhe.jsxs)(Me,{component:"span",sx:{color:"text.secondary"},children:["(",a,")"]})]})}var XC=$(V(),1);function Bir({rateLimits:e}){let t=sO(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(n=>n.window?.used_percentage!=null);return(0,XC.jsx)(XC.Fragment,{children:r.map((n,i)=>(0,XC.jsxs)(Nir.Fragment,{children:[i>0?(0,XC.jsx)(Me,{component:"span",sx:{color:"text.secondary",mr:.5},children:","}):null,(0,XC.jsx)(Oir,{window:n.window,windowSeconds:n.windowSeconds,fallbackLabel:n.fallbackLabel,now:t})]},n.fallbackLabel))})}function ZAn(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function QAn(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function JAn(e,t,r,n){if(e>=t)return;let i=e/t;return Math.round(r-n*(1-i))}function zir(e,t,r,n){if(t==null)return{kind:"unprojectable"};let i=$Ie(t,r,n);if(i==null)return{kind:"unprojectable"};let o=VC(e,t,r,n),a=ZAn(o),s=QAn(o);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*i,at:JAn(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*i}}}function Uir(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${nhe(e.at,t)}`}var Dg=$(V(),1);function WIe({direction:e,threshold:t}){let r=e==="back",n={display:"inline-flex",gap:.5,minWidth:"6ch",justifyContent:r?"flex-end":"flex-start"};if(!t)return(0,Dg.jsx)(Me,{component:"span",sx:n});let i=(0,Dg.jsx)(Me,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,Dg.jsxs)(Me,{component:"span",sx:{color:GC(t.level)},children:[Math.round(t.pct),"%"]});return(0,Dg.jsx)(Me,{component:"span",sx:n,children:r?(0,Dg.jsxs)(Dg.Fragment,{children:[o,i]}):(0,Dg.jsxs)(Dg.Fragment,{children:[i,o]})})}var ZC=$(V(),1);function Hir({label:e,pct:t,resetsAt:r,windowSeconds:n,now:i}){let o=VC(t,r,n,i),a=zir(t,r,n,i),s=a.kind==="projected"?a:void 0;return(0,ZC.jsxs)(Me,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[(0,ZC.jsx)(Me,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,ZC.jsx)(WIe,{direction:"back",threshold:s?.recovery}),(0,ZC.jsxs)(Me,{component:"span",sx:{minWidth:"4ch",textAlign:"right",color:GC(o)},children:[Math.round(t),"%"]}),(0,ZC.jsx)(WIe,{direction:"forward",threshold:s?.worse}),(0,ZC.jsx)(Me,{component:"span",sx:{opacity:.6},children:s?s.recovery&&Uir(s.recovery,i):"no projection yet"})]})}function Wir(e){return[{label:"5h",window:e.five_hour,windowSeconds:18e3},{label:"7d",window:e.seven_day,windowSeconds:604800}].flatMap(t=>t.window?.used_percentage==null?[]:[{label:t.label,pct:t.window.used_percentage,resetsAt:t.window.resets_at,windowSeconds:t.windowSeconds}])}var IV=$(V(),1),VIe="Claude account usage (5h / 7d windows) \u2014 view history";function Vir({rateLimits:e}){let t=sO(3e4);return(0,IV.jsxs)(Me,{sx:{fontFamily:"monospace",fontSize:12},children:[Wir(e).map(r=>(0,IV.jsx)(Hir,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label)),(0,IV.jsx)(Me,{sx:{mt:.5,opacity:.6},children:VIe})]})}var DV=$(V(),1),ePn={display:"flex",alignItems:"center",ml:2,fontFamily:"monospace",fontSize:13};function tPn(e){return e?.five_hour?.used_percentage!=null||e?.seven_day?.used_percentage!=null}function Gir({rateLimits:e}){let t=tPn(e);return(0,DV.jsx)(Mn,{title:t?(0,DV.jsx)(Vir,{rateLimits:e}):VIe,children:(0,DV.jsx)(Zo,{component:Nm,to:"/usage",underline:"hover",color:"inherit",sx:ePn,children:t?(0,DV.jsx)(Bir,{rateLimits:e}):"Usage"})})}var qir=$(V(),1),jir=St((0,qir.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var vx=$(Re(),1);var uO={target:"both",label:"Restart daemon",message:"This restarts the sessions daemon and the web server, then reloads the page once the server is back."};function Yir(e){return fetch(`/api/restart?target=${e}`,{method:"POST"})}var yx=$(Re(),1);var rPn="/api/session-layout";async function nPn(){try{return(await fetch(rPn,{cache:"no-store"})).ok}catch{return!1}}async function Kir(e){let t=0;for(;!e();){if(t=await nPn()?t+1:0,t>=2)return!e();await new Promise(r=>setTimeout(r,300))}return!1}function iPn(){return{sawDisconnect:!1,waiting:!1,abandoned:!0}}function Xir(e,t,r){let n=(0,yx.useRef)(iPn()),i=(0,yx.useRef)(r);i.current=r,(0,yx.useEffect)(()=>{let s=n.current;if(!(!e||s.abandoned)){if(t){s.sawDisconnect=!0;return}!s.sawDisconnect||s.waiting||(s.waiting=!0,Kir(()=>s.abandoned).then(l=>{l&&i.current()}))}},[e,t]);let o=(0,yx.useCallback)(()=>{n.current.abandoned=!0},[]),a=(0,yx.useCallback)(()=>{n.current.abandoned=!0,n.current={sawDisconnect:!1,waiting:!1,abandoned:!1}},[]);return(0,yx.useEffect)(()=>o,[o]),{arm:a,abandon:o}}var oPn=15e3;function hO(e,t,r){let[n,i]=(0,vx.useState)(!1),[o,a]=(0,vx.useState)(null),s=(0,vx.useRef)(void 0),{arm:l,abandon:u}=Xir(n,t,()=>{clearTimeout(s.current),r?.(),globalThis.location.reload()});(0,vx.useEffect)(()=>()=>clearTimeout(s.current),[]);let h=(0,vx.useCallback)(async()=>{i(!0),l(),s.current=setTimeout(()=>{u(),i(!1),a("Web server did not come back")},oPn);try{if(!(await Yir(e)).ok)throw new Error("restart failed")}catch{u(),clearTimeout(s.current),i(!1),a("Failed to restart web server")}},[e,l,u]);return{pending:n,error:o,clearError:()=>a(null),restart:h}}var Og=$(V(),1),aPn={color:"inherit",mr:1.5};function Zir({reconnecting:e}){let{pending:t,error:r,clearError:n,restart:i}=hO("webserver",e);return(0,Og.jsxs)(Og.Fragment,{children:[(0,Og.jsx)(Mn,{title:"Restart web server",children:(0,Og.jsx)("span",{children:(0,Og.jsx)(gr,{sx:aPn,disabled:t,onClick:i,children:t?(0,Og.jsx)(ro,{size:24}):(0,Og.jsx)(jir,{})})})}),(0,Og.jsx)(ff,{error:r,onClose:n})]})}var fO=$(Re(),1);var vhe=$(Re(),1);var bhe=$(V(),1);function Qir({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=(0,vhe.useRef)(null);return(0,vhe.useEffect)(()=>{r&&o.current?.scrollIntoView({block:"nearest"})},[r]),(0,bhe.jsxs)(ui,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:[OV(e),qS(e)&&(0,bhe.jsx)($S,{})]})}var GIe=$(V(),1);function Jir({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,GIe.jsx)(Sh,{dense:!0,children:e.map((o,a)=>(0,GIe.jsx)(Qir,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var NV=$(V(),1);function OV(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var sPn={...XS};function eor({repos:e,selected:t,onSelect:r,close:n}){let[i,o]=(0,fO.useState)(""),a=(0,fO.useRef)(null);(0,fO.useEffect)(()=>{a.current?.focus()},[]);let s=i.trim().toLowerCase(),l=s?e.filter(p=>p.toLowerCase().includes(s)):e,{highlight:u,setHighlight:h,onKeyDown:f}=uhe(l,s,r,n);return(0,NV.jsxs)(ti,{elevation:4,sx:sPn,children:[(0,NV.jsx)(she,{inputRef:a,value:i,onChange:o,onKeyDown:f,placeholder:"Filter repos..."}),(0,NV.jsx)(Jir,{repos:l,selected:t,highlight:u,onHighlight:h,onSelect:p=>{r(p),n()}})]})}var dO=$(V(),1);function lPn(e){return e?qS(e)?(0,dO.jsxs)("span",{style:{display:"flex",flexGrow:1,alignItems:"center",justifyContent:"space-between",gap:6,minWidth:0},children:[OV(e),(0,dO.jsx)($S,{})]}):OV(e):"Select repo..."}function tor({repos:e,selected:t,onSelect:r}){return(0,dO.jsx)(Iy,{label:lPn(t),children:n=>(0,dO.jsx)(eor,{repos:e,selected:t,onSelect:r,close:n})})}var ror=$(Re(),1);var qIe=$(V(),1);function xhe({disabled:e,onSubmit:t,label:r="prompt",allowEmpty:n=!1}){let[i,o]=(0,ror.useState)("");return(0,qIe.jsx)(Iy,{label:r,disabled:e,onDefaultAction:n?()=>t(""):void 0,children:a=>(0,qIe.jsx)(YI,{value:i,onChange:o,onSubmit:()=>{!n&&!i.trim()||(t(i),o(""),a())}})})}var wE=$(V(),1),cPn={textTransform:"none",fontSize:11,fontWeight:600};function nor({onSelect:e,disabled:t=!1,children:r}){return(0,wE.jsxs)(wE.Fragment,{children:[n7e.filter(n=>n.nav&&n.prompt).map(n=>(0,wE.jsx)(xhe,{label:n.label,allowEmpty:!0,disabled:t,onSubmit:i=>e(n.value,i)},n.value)),r,n7e.filter(n=>n.nav&&!n.prompt).map(n=>(0,wE.jsx)(xr,{size:"small",variant:"outlined",disabled:t,onClick:()=>e(n.value),sx:cPn,children:n.label},n.value))]})}var jIe=$(Re(),1);function ior(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var The=$(V(),1),uPn={"& .MuiFormControlLabel-label":{fontSize:12}};function oor({choices:e,value:t,onChange:r}){return(0,The.jsx)(ope,{row:!0,value:t,onChange:n=>r(n.target.value),children:e.map(n=>(0,The.jsx)(If,{value:n,control:(0,The.jsx)(npe,{size:"small"}),label:FS(n),sx:uPn},n))})}var She=$(V(),1);function aor({cwd:e,disabled:t,onCreate:r,onCreateHarness:n}){let i=ior(Zae()),[o,a]=(0,jIe.useState)(""),[s,l]=(0,jIe.useState)("claude"),u=h=>{s==="claude"?r(h,e):n(s,h,e)};return(0,She.jsx)(Iy,{label:"prompt",disabled:t,onDefaultAction:()=>u(""),children:h=>(0,She.jsx)(YI,{value:o,onChange:a,header:i.length>1?(0,She.jsx)(oor,{choices:i,value:s,onChange:l}):void 0,onSubmit:()=>{u(o),a(""),h()}})})}var _E=$(V(),1);function sor({cwd:e,disabled:t,onCreate:r,onCreateDesign:n,onCreateHarness:i}){return(0,_E.jsxs)(_E.Fragment,{children:[(0,_E.jsx)(aor,{cwd:e,disabled:t,onCreate:r,onCreateHarness:i}),(0,_E.jsx)(xhe,{label:"design",allowEmpty:!0,disabled:t,onSubmit:o=>n(o,e)})]})}var mor=$(Re(),1);var BV=$(Re(),1);function Che(e){let[t,r]=(0,BV.useState)([]),[n,i]=(0,BV.useState)(!0);return(0,BV.useEffect)(()=>{if(!e){r([]),i(!1);return}let o=!1;return i(!0),fetch(`/api/pr-list?cwd=${encodeURIComponent(e)}`).then(a=>a.json()).then(a=>{o||(r(Array.isArray(a?.prs)?a.prs:[]),i(!1))}).catch(()=>{o||(r([]),i(!1))}),()=>{o=!0}},[e]),{prs:t,loading:n}}var Bd=$(V(),1);function cor({cwd:e,onPick:t}){let{prs:r,loading:n}=Che(e);return(0,Bd.jsx)(ti,{elevation:4,sx:{...XS,left:"auto",width:320},children:n?(0,Bd.jsx)(lor,{text:"Loading open PRs\u2026"}):r.length===0?(0,Bd.jsx)(lor,{text:"No open PRs"}):(0,Bd.jsx)(Sh,{dense:!0,disablePadding:!0,children:r.map(i=>(0,Bd.jsx)(hPn,{pr:i,onPick:t},i.number))})})}function hPn({pr:e,onPick:t}){return(0,Bd.jsx)(ui,{onMouseDown:r=>r.preventDefault(),onClick:()=>t(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,Bd.jsxs)(ir,{spacing:.25,sx:{minWidth:0},children:[(0,Bd.jsx)(tt,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:e.title}),(0,Bd.jsxs)(tt,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",S2(e.createdAt)]})]})})}function lor({text:e}){return(0,Bd.jsx)(Me,{sx:{p:1.5},children:(0,Bd.jsx)(tt,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var hor=$(V(),1);function uor({cwd:e,onPick:t}){return(0,hor.jsx)(cor,{cwd:e,onPick:t})}var dor=$(Re(),1);var pu=$(V(),1);function por({pr:e,onSelect:t,onCancel:r}){let[n,i]=(0,dor.useState)(HH);return(0,pu.jsxs)(xh,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,pu.jsxs)(Jd,{sx:{fontSize:15},children:["Review #",e.number,": ",e.title]}),(0,pu.jsx)(Qd,{sx:{px:0},children:(0,pu.jsxs)(Sh,{children:[Nse.map(({label:o,args:a})=>(0,pu.jsx)(ui,{onClick:()=>t([...a,...Bse(n)]),children:o},o)),(0,pu.jsx)(ns,{}),(0,pu.jsx)(Fse,{value:n,onChange:i}),(0,pu.jsx)(ns,{}),(0,pu.jsx)(ui,{onClick:()=>t(["review","--checkout-only"]),children:"Checkout"}),(0,pu.jsx)(ui,{onClick:()=>t(["review-pr-comments"]),children:"Address Comments"}),(0,pu.jsx)(ui,{onClick:()=>t(["fix-conflict"]),children:"Fix conflicts (merge)"}),(0,pu.jsx)(ui,{onClick:()=>t(["fix-conflict","--rebase"]),children:"Fix conflicts (rebase)"})]})}),(0,pu.jsx)(Zd,{children:(0,pu.jsx)(xr,{onClick:r,children:"Cancel"})})]})}var QC=$(V(),1);function gor({cwd:e,disabled:t,onSelect:r}){let{prs:n,loading:i}=Che(e),[o,a]=(0,mor.useState)(null);return i||n.length===0?null:(0,QC.jsxs)(QC.Fragment,{children:[(0,QC.jsx)(Iy,{label:"prs",disabled:t,children:s=>(0,QC.jsx)(uor,{cwd:e,onPick:l=>{a(l),s()}})}),o&&(0,QC.jsx)(por,{pr:o,onSelect:s=>{r(o,s),a(null)},onCancel:()=>a(null)})]})}var pO=$(V(),1);function yor({onStartRun:e,cwd:t}){let r=Vse(t);return!t||r.length===0?null:(0,pO.jsx)(Iy,{label:"server",children:n=>(0,pO.jsx)(ti,{elevation:4,sx:{...XS,left:"auto",width:200},children:(0,pO.jsx)(Sh,{dense:!0,disablePadding:!0,children:r.map(i=>(0,pO.jsx)(ui,{onMouseDown:o=>o.preventDefault(),onClick:()=>{e(i.name,t),n()},sx:{py:.75},children:(0,pO.jsx)(tt,{sx:{fontSize:13},children:i.name})},i.name))})})})}var kE=$(V(),1);function vor({onCreate:e,onCreateDesign:t,onCreateHarness:r,onCreateAssist:n,onStartRun:i}){let{selectedCwd:o}=Oa(),a=!o;return(0,kE.jsxs)(ir,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[(0,kE.jsxs)(nor,{disabled:a,onSelect:(s,l)=>I$t(s,o,n,()=>{},l),children:[(0,kE.jsx)(sor,{cwd:o,disabled:a,onCreate:e,onCreateDesign:t,onCreateHarness:r}),(0,kE.jsx)(gor,{cwd:o,disabled:a,onSelect:(s,l)=>n([...l,String(s.number)],o,$se(s))})]}),(0,kE.jsx)(yor,{onStartRun:i,cwd:o})]})}var Fd=$(V(),1),fPn={minHeight:48,pl:1,pr:14},dPn={width:240,ml:2};function bor({socket:e,selection:t}){let{collapsed:r,onToggleCollapsed:n}=QI();return(0,Fd.jsxs)(qw,{variant:"dense",disableGutters:!0,sx:fPn,children:[r&&(0,Fd.jsx)(Jse,{collapsed:r,onToggleCollapsed:n}),(0,Fd.jsx)(Zir,{reconnecting:e.reconnecting}),(0,Fd.jsx)(Iir,{}),(0,Fd.jsx)(Me,{sx:dPn,children:(0,Fd.jsx)(tor,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd})}),(0,Fd.jsxs)(Me,{sx:{display:"flex",ml:1,mr:2},children:[(0,Fd.jsx)(Hse,{cwd:t.selectedCwd}),(0,Fd.jsx)(Dir,{cwd:t.selectedCwd})]}),(0,Fd.jsx)(vor,{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession,onStartRun:e.startRun}),(0,Fd.jsx)(Gir,{rateLimits:e.rateLimits})]})}var khe=$(Re(),1);var xor=$(V(),1),Tor=St((0,xor.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var Sor=$(V(),1),Cor=St((0,Sor.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var wor=$(V(),1),_or=St((0,wor.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var YIe=$(V(),1);function kor({mode:e}){return e==="dark"?(0,YIe.jsx)(_or,{fontSize:"small"}):(0,YIe.jsx)(Cor,{fontSize:"small"})}var fh=$(V(),1);function Eor({mode:e,onToggleColorMode:t,onRestart:r,onUpdate:n}){return[(0,fh.jsxs)(ui,{onClick:t,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(kor,{mode:e})}),(0,fh.jsx)(A9,{children:"Toggle dark mode"})]},"color-mode"),(0,fh.jsx)(ns,{},"restart-divider"),(0,fh.jsxs)(ui,{onClick:r,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(Rse,{fontSize:"small"})}),(0,fh.jsx)(A9,{children:uO.label})]},"restart"),(0,fh.jsxs)(ui,{onClick:n,children:[(0,fh.jsx)(E9,{children:(0,fh.jsx)(Tor,{fontSize:"small"})}),(0,fh.jsx)(A9,{children:"Update assist"})]},"update")]}var EE=$(V(),1);function Ror({reconnecting:e,onClose:t}){let{pending:r,error:n,clearError:i,restart:o}=hO(uO.target,e);return(0,EE.jsxs)(EE.Fragment,{children:[(0,EE.jsx)(ra,{title:uO.label,message:uO.message,confirmLabel:"Restart",busy:r,onConfirm:()=>{o()},onCancel:t}),(0,EE.jsx)(ff,{error:n,onClose:i})]})}var Por=$(V(),1);function Aor({onConfirm:e,onClose:t}){return(0,Por.jsx)(ra,{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal.",confirmLabel:"Update",onConfirm:()=>{e(),t()},onCancel:t})}var RE=$(V(),1);function Lor({restarting:e,reconnecting:t,onCloseRestart:r,updating:n,onCloseUpdate:i}){let{launchAssist:o,armUpdateReload:a}=gp();return(0,RE.jsxs)(RE.Fragment,{children:[e&&(0,RE.jsx)(Ror,{reconnecting:t,onClose:r}),n&&(0,RE.jsx)(Aor,{onConfirm:()=>{a(),o(["update"])},onClose:i})]})}var Mor=$(V(),1),Ior=St((0,Mor.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var Dor=$(V(),1),Oor=St((0,Dor.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var whe=$(V(),1);function Nor(){let e=oo();return(0,whe.jsx)(Mn,{title:"Config",children:(0,whe.jsx)(gr,{size:"small",sx:{color:"inherit"},"aria-label":"Config",onClick:()=>e("/config"),children:(0,whe.jsx)(Oor,{fontSize:"small"})})})}var KIe=$(V(),1),Bor=St([(0,KIe.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,KIe.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber");var FV="0.607.0";var _he=$(Re(),1),XIe=(0,_he.createContext)(null);function For(){return(0,_he.useContext)(XIe)}var JC=$(V(),1);function $or(){let e=For();return FV?(0,JC.jsxs)(JC.Fragment,{children:[(0,JC.jsxs)(tt,{variant:"caption",sx:{opacity:.4,userSelect:"none",lineHeight:1},children:["v",FV]}),e&&e!==FV&&(0,JC.jsx)(Mn,{title:`Daemon is running v${e}, but this page was served by v${FV}. Restart the daemon to match.`,children:(0,JC.jsx)(Bor,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})]}):null}var AE=$(V(),1);function zor({open:e,onOpen:t}){return(0,AE.jsxs)(Me,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:"inherit"},children:[(0,AE.jsx)($or,{}),(0,AE.jsx)(Nor,{}),(0,AE.jsx)(gr,{onClick:r=>t(r.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,AE.jsx)(Ior,{fontSize:"small"})})]})}var ew=$(V(),1);function Uor({mode:e,toggle:t,reconnecting:r}){let[n,i]=(0,khe.useState)(null),[o,a]=(0,khe.useState)(!1),[s,l]=(0,khe.useState)(!1),u=!!n,h=()=>i(null);return(0,ew.jsxs)(ew.Fragment,{children:[(0,ew.jsx)(zor,{open:u,onOpen:i}),(0,ew.jsx)(ep,{anchorEl:n,open:u,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:Eor({mode:e,onToggleColorMode:()=>{t(),h()},onRestart:()=>{h(),a(!0)},onUpdate:()=>{h(),l(!0)}})}),(0,ew.jsx)(Lor,{restarting:o,reconnecting:r,onCloseRestart:()=>a(!1),updating:s,onCloseUpdate:()=>l(!1)})]})}var Vor=$(Re(),1);var Wor=$(V(),1);function Hor({conflict:e,onConfirm:t,onCancel:r}){let{name:n,cwd:i,port:o}=e.existing,a=Qp(i),s=o?` on port ${o}`:"",l=a?` in ${a}`:"";return(0,Wor.jsx)(ra,{title:"Replace running server?",message:`"${n}" is already serving${s}${l}. Replace it \u2014 stop the running server and start this one?`,confirmLabel:"Replace",confirmColor:"error",onConfirm:t,onCancel:r})}var Ehe=$(V(),1);function Gor({socket:e,children:t}){let{serverConflict:r,clearServerConflict:n,retrySession:i,stopSession:o,startRun:a,discardSession:s}=e,l=(0,Vor.useMemo)(()=>({onStop:o,onStart:a,onDiscard:s}),[o,a,s]),u=()=>{r&&(r.runName?a(r.runName,r.cwd,!0,r.launchedFrom):r.sessionId&&i(r.sessionId,!0),n())};return(0,Ehe.jsxs)(QPe.Provider,{value:l,children:[t,r&&(0,Ehe.jsx)(Hor,{conflict:r,onConfirm:u,onCancel:n})]})}var PE=$(Re(),1);function Rhe(e,t,r){if(e)return t.find(n=>n.id===e)??r.find(n=>n.sessionId===e)}function qor(e,t,r,n){let i=Rhe(e,t,r);return i?.cwd&&Ay(i)===n?i.cwd:n}function jor(e,t){let r=new Set,n=new Set,i=[];for(let o of t){if(o.cwdMissing)continue;let a=zS(o),s=Ay(o);!a||!s||r.has(a)||n.has(s)||(r.add(a),n.add(s),i.push(s))}return e&&!r.has(ase(e,t))&&!n.has(e)&&i.unshift(e),i}var Yor=$(Re(),1);function Ahe(e,t,r){let n=Rhe(e,t,r);return n&&Ay(n)}function Kor(e,t,r,n){let i=Ahe(e,t,r);(0,Yor.useEffect)(()=>{i&&n(i)},[i,n])}function Xor(e,t,r,n){let[i,o]=(0,PE.useState)(e);(0,PE.useEffect)(()=>{e&&!i&&o(e)},[e,i]),Kor(r,n,t,o);let a=(0,PE.useMemo)(()=>jor(e,t),[e,t]),s=qor(r,n,t,i);return(0,PE.useMemo)(()=>({repos:a,selectedCwd:i,worktreeCwd:s,setSelectedCwd:o}),[a,i,s])}var Lhe=$(Re(),1);var tw=$(Re(),1);var Zor=$(Re(),1),Phe="assist:reloaded-after-update";function Qor(e){(0,Zor.useEffect)(()=>{globalThis.sessionStorage?.getItem(Phe)&&(globalThis.sessionStorage.removeItem(Phe),e({message:"Reloaded after updating assist",sessionId:null}))},[e])}var Ng=$(Re(),1);function Jor(e){return e.commandType==="assist"&&e.assistArgs?.[0]==="update"&&e.status==="done"}function ear(e,t){let[r,n]=(0,Ng.useState)(!1),[i,o]=(0,Ng.useState)(!1),a=(0,Ng.useRef)(!1),s=(0,Ng.useRef)(e);s.current=e;let l=(0,Ng.useRef)(new Set),u=(0,Ng.useCallback)(()=>{a.current=!1,o(!1),l.current=new Set(s.current.filter(Jor).map(h=>h.id)),n(!0)},[]);return(0,Ng.useEffect)(()=>{if(!r||i)return;if(t){a.current=!0;return}if(!a.current)return;e.some(f=>Jor(f)&&!l.current.has(f.id))&&o(!0)},[r,i,t,e]),{arm:u,completed:i}}function tar(e,t,r,n){let{arm:i,completed:o}=ear(e,t),a=(0,tw.useRef)(!1),s=(0,tw.useCallback)(()=>{globalThis.sessionStorage?.setItem(Phe,"1")},[]),{error:l,restart:u}=hO("webserver",t,s);return Qor(r),(0,tw.useEffect)(()=>{l&&n(l)},[l,n]),(0,tw.useEffect)(()=>{!o||a.current||(a.current=!0,u())},[o,u]),{armUpdateReload:(0,tw.useCallback)(()=>{a.current=!1,i()},[i])}}function rar(e){let{armUpdateReload:t}=tar(e.sessions,e.reconnecting,e.setSuccess,e.setError),r=(0,Lhe.useMemo)(()=>({launchAssist:e.createAssistSession,launchAgentInStream:e.createSessionInStream,armUpdateReload:t}),[e.createAssistSession,e.createSessionInStream,t]),n=oo(),i=(0,Lhe.useCallback)(o=>{e.selectSession(o),n("/sessions"),e.clearSuccess()},[n,e.selectSession,e.clearSuccess]);return{launch:r,viewLaunchedSession:i}}var nar=$(Re(),1);function iar(e,t,r,n){let i=Ahe(e,t,r);(0,nar.useEffect)(()=>{e&&i&&n({type:"set-active",cwd:i,sessionId:e})},[e,i,n])}var Mhe=$(Re(),1);function oar(e,t){let r=(0,Mhe.useRef)(new Map);(0,Mhe.useEffect)(()=>{let n=new Set;for(let{id:i,status:o}of e)n.add(i),r.current.get(i)!==o&&(r.current.set(i,o),console.debug(`[sessions] render session ${i} status=${o}`),t({type:"ui-status",sessionId:i,status:o}));for(let i of r.current.keys())n.has(i)||r.current.delete(i)},[e,t])}var sar=$(Re(),1);function aar(e){let t=e;if(t.type==="create")return{cwd:t.cwd,title:t.prompt?.trim()||(t.design?"New design session":"New session")};if(t.type==="create-assist"){let r=t.title?.trim();return{cwd:t.cwd,title:r||"New session",named:!!r}}return null}function lar(e,t){return(0,sar.useCallback)(r=>{let n=e.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r));let i=aar(r);i&&t(i)},[e,t])}var Jy=$(Re(),1);function car(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,auto:!0})}function uar(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,design:!0})}function har(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,harness:t})}function far(e){return(t,r,n)=>e({type:"create-assist",assistArgs:t,cwd:r,...n})}function dar(e){return(t,r,n,i)=>e({type:"resume",sessionId:t,cwd:r,name:n,harness:i})}function par(e,t){return(r,n)=>{t.delete(r),e({type:"retry",sessionId:r,replace:n})}}function mar(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function gar(e,t){return r=>{e({type:"dismiss",sessionId:r}),t.delete(r)}}function yar(e,t){return r=>{e({type:"discard",sessionId:r}),t.delete(r)}}function bar(e){return t=>e({type:"stop",sessionId:t})}function xar(e){return(t,r,n,i)=>e({type:"create-run",runName:t,cwd:r,replace:n,launchedFrom:i})}function Tar(e){return(t,r)=>e({type:"set-autorun",sessionId:t,enabled:r})}function Sar(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function Car(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function war(e){return(t,r)=>e({type:"input",sessionId:t,data:r})}function _ar(e){return(t,r,n)=>e({type:"resize",sessionId:t,cols:r,rows:n})}function kar(e,t){return(r,n)=>{let i=e.get(r);return i&&n(i),t.set(r,n),()=>t.delete(r)}}function Ear(e){return(t,r,n,i)=>e({type:"pr-decision",sessionId:t,requestId:r,decision:n,...i})}var LE=$(Re(),1);function Rar(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,joinSessionId:t,auto:!0})}function Aar(e){return{createSession:(0,LE.useMemo)(()=>car(e),[e]),createSessionInStream:(0,LE.useMemo)(()=>Rar(e),[e]),createDesignSession:(0,LE.useMemo)(()=>uar(e),[e]),createHarnessSession:(0,LE.useMemo)(()=>har(e),[e]),createAssistSession:(0,LE.useMemo)(()=>far(e),[e]),resumeSession:(0,LE.useMemo)(()=>dar(e),[e])}}var $V=$(Re(),1);function Par(e,t){let r=(0,$V.useCallback)((a,s)=>{par(e,t.current)(a,s)},[e,t]),n=(0,$V.useCallback)(a=>{mar(e,t.current)(a)},[e,t]),i=(0,$V.useCallback)(a=>{gar(e,t.current)(a)},[e,t]),o=(0,$V.useCallback)(a=>{yar(e,t.current)(a)},[e,t]);return{retrySession:r,restartSession:n,dismissSession:i,discardSession:o}}function Lar(e,t,r){let n={...Aar(e),sendInput:(0,Jy.useMemo)(()=>war(e),[e]),sendResize:(0,Jy.useMemo)(()=>_ar(e),[e]),sendPrDecision:(0,Jy.useMemo)(()=>Ear(e),[e]),setAutoRun:(0,Jy.useMemo)(()=>Tar(e),[e]),setAutoAdvance:(0,Jy.useMemo)(()=>Sar(e),[e]),setStarred:(0,Jy.useMemo)(()=>Car(e),[e]),stopSession:(0,Jy.useMemo)(()=>bar(e),[e]),startRun:(0,Jy.useMemo)(()=>xar(e),[e])},i=(0,Jy.useMemo)(()=>kar(t.current,r.current),[t,r]);return{...n,...Par(e,t),onOutput:i}}var Ihe=$(Re(),1);function Mar(e,t,r){let n=(0,Ihe.useCallback)(a=>{r(a),e({type:"fetch-transcript",sessionId:a})},[e,r]),i=(0,Ihe.useCallback)(()=>{r(null)},[r]),o=(0,Ihe.useCallback)(a=>{r(null),t(a)},[t,r]);return{viewTranscript:n,clearTranscript:i,selectSession:o}}var Bg=$(Re(),1);var Dar=$(Re(),1);function Iar(e,t,r=null){return t!==null?e.some(n=>n.id===t)?t:e[0]?.id??null:r&&e.some(n=>n.id===r)?r:e[0]?.id??null}function Oar(e,t,r){let n=Ss().pathname,i=n.startsWith("/backlog")||n.startsWith("/usage");(0,Dar.useEffect)(()=>{if(i){t(null);return}t(o=>Iar(e,o,r))},[e,t,r,i])}var ZIe=$(Re(),1);function Nar(){let[e,t]=(0,ZIe.useState)(null),[r,n]=(0,ZIe.useState)(null);return{daemonActiveId:e,setDaemonActiveId:t,daemonVersion:r,setDaemonVersion:n}}var ME=$(Re(),1);function Bar(e,t){if(!t.some(n=>e.has(n)))return e;let r=new Set(e);for(let n of t)r.delete(n);return r}function Far(e,t){let r=[];for(let n of t){let i=e.get(n.id);i!==void 0&&i!==n.startedAt&&r.push(n.id)}return r}function $ar(){let[e,t]=(0,ME.useState)(new Set),r=(0,ME.useRef)(new Map),n=(0,ME.useCallback)(o=>{t(a=>a.has(o)?a:new Set(a).add(o))},[]),i=(0,ME.useCallback)(o=>{let a=Far(r.current,o);r.current=new Map(o.map(s=>[s.id,s.startedAt])),a.length&&t(s=>Bar(s,a))},[]);return{initialized:e,markInitialized:n,syncSessions:i}}var rw=$(Re(),1);function zar(){let[e,t]=(0,rw.useState)(null),[r,n]=(0,rw.useState)(null),[i,o]=(0,rw.useState)(null),a=(0,rw.useCallback)(()=>t(null),[]),s=(0,rw.useCallback)(()=>n(null),[]),l=(0,rw.useCallback)(()=>o(null),[]);return{error:e,setError:t,clearError:a,success:r,setSuccess:n,clearSuccess:s,serverConflict:i,setServerConflict:o,clearServerConflict:l}}var e1=$(Re(),1);function Uar(e,t){return[...e,{...t,windows:qS(t.cwd),status:"launching"}]}function Dhe(e){return e.find(t=>t.status==="launching")}function Har(e){let t=Dhe(e);return t?e.filter(r=>r.id!==t.id):e}function War(e,t){let r=Dhe(e);return r?QIe(e,r.id,t):e}function QIe(e,t,r){return e.map(n=>n.id===t&&n.status==="launching"?{...n,status:"error",error:r}:n)}function Var(e,t){return e.filter(r=>r.id!==t)}var Gar=$(Re(),1);var pPn=6e4,mPn="Launch timed out \u2014 the session did not start.";function qar(e,t){(0,Gar.useEffect)(()=>{let r=e.filter(i=>i.status==="launching");if(r.length===0)return;let n=r.map(i=>setTimeout(()=>t(o=>QIe(o,i.id,mPn)),Math.max(0,pPn-(Date.now()-i.startedAt))));return()=>n.forEach(clearTimeout)},[e,t])}function jar(){let[e,t]=(0,e1.useState)([]),r=(0,e1.useRef)([]),n=(0,e1.useCallback)(l=>{r.current=l(r.current),t(r.current)},[]),i=(0,e1.useCallback)(l=>{n(u=>Uar(u,{id:crypto.randomUUID(),startedAt:Date.now(),...l}))},[n]),o=(0,e1.useCallback)(()=>{let l=Dhe(r.current);return n(Har),l?.named?l.title:void 0},[n]),a=(0,e1.useCallback)(l=>n(u=>War(u,l)),[n]),s=(0,e1.useCallback)(l=>n(u=>Var(u,l)),[n]);return qar(e,n),{pendingLaunches:e,addPendingLaunch:i,resolvePendingLaunch:o,failPendingLaunch:a,dismissPendingLaunch:s}}var Yar=$(Re(),1);function Kar(e,t){return(0,Yar.useCallback)(r=>{e(r),t(r)},[e,t])}var nw=$(Re(),1);function Xar(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function Zar(e,t){let r=e.sessionId,n=t.resolvePendingLaunch();t.setViewingTranscriptSessionId(null),t.setActiveId(r),e.isNew&&t.setSuccess({message:n?`Started ${n}`:"New session started",sessionId:r})}function Qar(e,t){let r=e.message;t.setError(r),t.failPendingLaunch(r)}function Jar(e,t){t.setSuccess({message:e.message,sessionId:null})}function esr(e,t){let r=e.sessionId,n=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,n+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function tsr(e,t){t.setServerConflict({existing:e.existing,runName:e.runName,cwd:e.cwd,sessionId:e.sessionId,launchedFrom:e.launchedFrom})}function rsr(e,t){let r=new Set(t.map(i=>i.id)),n=null;for(let i of Object.values(e))r.has(i)&&(n=i);return n}function nsr(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd);let n=e.active??{};t.setDaemonActiveId(rsr(n,r))}function isr(e,t){switch(e.type){case"sessions":nsr(e,t);break;case"created":Zar(e,t);break;case"history":t.setHistory(e.sessions);break;case"transcript":t.setTranscript({sessionId:e.sessionId,messages:e.messages});break;case"hello":t.setDaemonVersion(e.version);break;case"error":Qar(e,t);break;case"notice":Jar(e,t);break;case"run-conflict":tsr(e,t);break;case"limits":t.setRateLimits(e.rateLimits);break;case"clear":Xar(e,t);break;case"output":esr(e,t);break}}function osr(e,t={}){let r=location.protocol==="https:"?"wss:":"ws:",n=new WebSocket(`${r}//${location.host}/ws`);return n.onopen=()=>{t.onOpen?.(),n.send(JSON.stringify({type:"hello"})),n.send(JSON.stringify({type:"history"}))},n.onmessage=i=>{isr(JSON.parse(i.data),e)},n.onclose=()=>t.onClose?.(),n}function asr(e,t,r,n){let i=!1,o,a=0,s=!1,l=()=>{i||t(osr(e,{onOpen:()=>{s&&r(),s=!1,n(!1),a=0},onClose:()=>{if(i)return;s=!0,n(!0);let u=Math.min(300*2**a,2e3);a+=1,o=setTimeout(l,u)}}))};return l(),()=>{i=!0,o&&clearTimeout(o)}}function ssr(e){let t=(0,nw.useRef)(null),[r,n]=(0,nw.useState)(!1),{handleSessions:i,markInitialized:o,buffers:a,handlers:s}=e;(0,nw.useEffect)(()=>{let u=()=>{a.current?.clear();let f=s.current;if(f)for(let d of f.values())d("\x1Bc")},h=asr({...e,setSessions:i},f=>{t.current=f},u,n);return()=>{h(),t.current?.close()}},[i,o,a,s]);let l=(0,nw.useCallback)(()=>{let u=t.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function lsr(){let[e,t]=(0,Bg.useState)([]),[r,n]=(0,Bg.useState)([]),[i,o]=(0,Bg.useState)(null),a=Nar(),[s,l]=(0,Bg.useState)(null),[u,h]=(0,Bg.useState)(null),[f,d]=(0,Bg.useState)(""),p=zar(),m=jar(),[g,y]=(0,Bg.useState)(null),{initialized:v,markInitialized:b,syncSessions:x}=$ar(),S=(0,Bg.useRef)(new Map),C=(0,Bg.useRef)(new Map),w=Kar(x,t),{wsRef:_,requestHistory:k,reconnecting:L}=ssr({handleSessions:w,setHistory:n,setActiveId:o,...a,setTranscript:l,setViewingTranscriptSessionId:h,setCurrentCwd:d,...p,...m,setRateLimits:y,markInitialized:b,buffers:S,handlers:C});return Oar(e,o,a.daemonActiveId),{sessions:e,history:r,activeId:i,setActiveId:o,...a,transcript:s,viewingTranscriptSessionId:u,setViewingTranscriptSessionId:h,currentCwd:f,...p,...m,rateLimits:g,initialized:v,wsRef:_,buffers:S,handlers:C,requestHistory:k,reconnecting:L}}function csr(){let e=lsr(),{wsRef:t,buffers:r,handlers:n,addPendingLaunch:i,activeId:o,sessions:a}=e,s=lar(t,i),l=Lar(s,r,n);iar(o,a,e.history,s),oar(a,s);let u=Mar(s,e.setActiveId,e.setViewingTranscriptSessionId);return{...e,...l,...u}}var hsr=$(Re(),1);var usr="assist:sidebar-collapsed";function fsr(){let[e,t]=(0,hsr.useState)(()=>Hy(usr).length>0);return{collapsed:e,onToggleCollapsed:()=>{let r=!e;Wy(usr,r?[!0]:[]),t(r)}}}var Ohe=$(Re(),1);function dsr(){let[e,t]=(0,Ohe.useState)(!0);return(0,Ohe.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/session-layout")).json();r||t(!!i?.topBar)}catch{t(!0)}})(),()=>{r=!0}},[]),e}function psr(){let e=csr(),t=Xor(e.currentCwd,e.history,e.activeId,e.sessions),{launch:r,viewLaunchedSession:n}=rar(e),i=dsr(),o=fsr();return{socket:e,selection:t,launch:r,viewLaunchedSession:n,topBar:i,sidebarCollapse:o}}var xf=$(V(),1),gPn={zIndex:e=>e.zIndex.drawer+1},yPn={minHeight:48};function msr({mode:e,toggle:t}){let{socket:r,selection:n,launch:i,viewLaunchedSession:o,topBar:a,sidebarCollapse:s}=psr();return(0,xf.jsx)(VPe.Provider,{value:a,children:(0,xf.jsx)(y7e.Provider,{value:s,children:(0,xf.jsx)(uB.Provider,{value:n,children:(0,xf.jsxs)(O0e.Provider,{value:i,children:[(0,xf.jsx)(XIe.Provider,{value:r.daemonVersion,children:(0,xf.jsx)(Uor,{mode:e,toggle:t,reconnecting:r.reconnecting})}),(0,xf.jsx)(tde,{position:"fixed",elevation:1,sx:gPn,children:(0,xf.jsx)(bor,{socket:r,selection:n})}),(0,xf.jsx)(qw,{variant:"dense",sx:yPn}),(0,xf.jsx)(Gor,{socket:r,children:(0,xf.jsx)(yir,{socket:r})}),(0,xf.jsx)(Mir,{socket:r,onViewLaunchedSession:o})]})})})})}var gsr=$(Re(),1);function ysr(){let[e,t]=(0,gsr.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(n=>{let i=n==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",i)}catch{}return i})}}var iw=$(V(),1),vPn={MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}}};function bPn(){let{mode:e,toggle:t}=ysr(),r=(0,bsr.useMemo)(()=>Vg({palette:{mode:e,...e==="dark"&&{background:{default:"#1e1e1e",paper:"#252526"}}},components:vPn}),[e]);return(0,iw.jsxs)(jG,{theme:r,children:[(0,iw.jsx)(Oq,{}),(0,iw.jsx)(msr,{mode:e,toggle:t})]})}var xPn=E0e([{path:"*",element:(0,iw.jsx)(bPn,{})}]);function TPn(){return(0,iw.jsx)(b0e,{router:xPn})}var vsr=document.getElementById("app");vsr&&(0,xsr.createRoot)(vsr).render((0,iw.jsx)(TPn,{}));})();
3975
3975
  /*! Bundled license information:
3976
3976
 
3977
3977
  react/cjs/react.production.js:
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.606.1",
9
+ version: "0.607.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -21712,6 +21712,16 @@ function addIssueToProject(projectId, contentId) {
21712
21712
  return id;
21713
21713
  }
21714
21714
 
21715
+ // src/commands/github/issue/addSubIssue.ts
21716
+ var MUTATION4 = `mutation($issueId: ID!, $subIssueId: ID!) {
21717
+ addSubIssue(input: { issueId: $issueId, subIssueId: $subIssueId }) {
21718
+ subIssue { id }
21719
+ }
21720
+ }`;
21721
+ function addSubIssue(parentId, childId) {
21722
+ runGhGraphqlJson(MUTATION4, { issueId: parentId, subIssueId: childId });
21723
+ }
21724
+
21715
21725
  // src/commands/github/issue/fetchIssueNodeId.ts
21716
21726
  var QUERY4 = `query($owner: String!, $repo: String!, $number: Int!) {
21717
21727
  repository(owner: $owner, name: $repo) {
@@ -21747,7 +21757,7 @@ function parseCreatedIssueUrl(output) {
21747
21757
  }
21748
21758
 
21749
21759
  // src/commands/github/issue/setProjectItemStatus.ts
21750
- var MUTATION4 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
21760
+ var MUTATION5 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
21751
21761
  updateProjectV2ItemFieldValue(input: {
21752
21762
  projectId: $projectId
21753
21763
  itemId: $itemId
@@ -21758,7 +21768,7 @@ var MUTATION4 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionI
21758
21768
  }
21759
21769
  }`;
21760
21770
  function setProjectItemStatus(input) {
21761
- runGhGraphqlJson(MUTATION4, input);
21771
+ runGhGraphqlJson(MUTATION5, input);
21762
21772
  }
21763
21773
 
21764
21774
  // src/commands/github/issue/applyCreatedIssueMetadata.ts
@@ -21766,11 +21776,15 @@ function applyCreatedIssueMetadata(createOutput, metadata2) {
21766
21776
  let step2 = "identifying the created issue";
21767
21777
  try {
21768
21778
  const issueId = fetchIssueNodeId(parseCreatedIssueUrl(createOutput));
21769
- const { issueType, project } = metadata2;
21779
+ const { issueType, parent, project } = metadata2;
21770
21780
  if (issueType) {
21771
21781
  step2 = `setting its issue type to ${issueType.name}`;
21772
21782
  updateIssueType(issueId, issueType.id);
21773
21783
  }
21784
+ if (parent) {
21785
+ step2 = `adding it as a sub-issue of ${parent.owner}/${parent.repo}#${parent.number}`;
21786
+ addSubIssue(parent.id, issueId);
21787
+ }
21774
21788
  if (project) {
21775
21789
  step2 = `adding it to project ${project.number} (${project.title})`;
21776
21790
  const itemId2 = addIssueToProject(project.id, issueId);
@@ -21796,11 +21810,16 @@ function applyCreatedIssueMetadata(createOutput, metadata2) {
21796
21810
  // src/commands/github/issue/issuePreviewMetadata.ts
21797
21811
  function issuePreviewMetadata(resolved) {
21798
21812
  if (!resolved) return [];
21799
- const { target, issueType, project, labels } = resolved;
21813
+ const { target, issueType, parent, project, labels } = resolved;
21800
21814
  const items2 = [
21801
21815
  { label: "Repository", value: `${target.owner}/${target.repo}` }
21802
21816
  ];
21803
21817
  if (issueType) items2.push({ label: "Type", value: issueType.name });
21818
+ if (parent)
21819
+ items2.push({
21820
+ label: "Parent",
21821
+ value: `${parent.owner}/${parent.repo}#${parent.number}`
21822
+ });
21804
21823
  if (project)
21805
21824
  items2.push({
21806
21825
  label: "Project",
@@ -21812,6 +21831,18 @@ function issuePreviewMetadata(resolved) {
21812
21831
  return items2;
21813
21832
  }
21814
21833
 
21834
+ // src/commands/github/issue/hasCreateIssueMetadataOptions.ts
21835
+ function hasCreateIssueMetadataOptions(options2) {
21836
+ if (options2.status && !options2.project) {
21837
+ throw new Error(
21838
+ "--status is a field on a project board, so it needs --project <number>"
21839
+ );
21840
+ }
21841
+ return Boolean(
21842
+ options2.type || options2.parent || options2.project || options2.label?.length
21843
+ );
21844
+ }
21845
+
21815
21846
  // src/commands/github/issue/resolveIssueLabels.ts
21816
21847
  var QUERY5 = `query($owner: String!, $repo: String!, $after: String) {
21817
21848
  repository(owner: $owner, name: $repo) {
@@ -21947,6 +21978,15 @@ function resolveIssueRepoTarget(repo) {
21947
21978
  return parseRepoSlug(repo);
21948
21979
  }
21949
21980
 
21981
+ // src/commands/github/issue/resolveCreateIssueParent.ts
21982
+ function resolveCreateIssueParent(target, parent) {
21983
+ const reference = resolveFixStructureTarget(
21984
+ parent,
21985
+ `${target.owner}/${target.repo}`
21986
+ );
21987
+ return { ...reference, id: fetchIssueNodeId(reference) };
21988
+ }
21989
+
21950
21990
  // src/commands/github/issue/readGhTokenScopes.ts
21951
21991
  import { spawnSync as spawnSync6 } from "child_process";
21952
21992
  var SCOPES_LINE = /Token scopes:\s*(.*)/;
@@ -22060,18 +22100,13 @@ function resolveCreateIssueProject(owner, projectNumber, statusName) {
22060
22100
 
22061
22101
  // src/commands/github/issue/resolveCreateIssueMetadata.ts
22062
22102
  function resolveCreateIssueMetadata(options2) {
22103
+ if (!hasCreateIssueMetadataOptions(options2)) return void 0;
22063
22104
  const labels = options2.label ?? [];
22064
- if (!options2.type && !options2.project && !options2.status && !labels.length)
22065
- return void 0;
22066
- if (options2.status && !options2.project) {
22067
- throw new Error(
22068
- "--status is a field on a project board, so it needs --project <number>"
22069
- );
22070
- }
22071
22105
  const target = resolveIssueRepoTarget(options2.repo);
22072
22106
  return {
22073
22107
  target,
22074
22108
  issueType: options2.type ? resolveIssueType(resolveOrgIssueTypes(target.owner), options2.type) : void 0,
22109
+ parent: options2.parent ? resolveCreateIssueParent(target, options2.parent) : void 0,
22075
22110
  project: options2.project ? resolveCreateIssueProject(target.owner, options2.project, options2.status) : void 0,
22076
22111
  labels: labels.length ? resolveIssueLabels(target, labels) : void 0
22077
22112
  };
@@ -22110,7 +22145,7 @@ function runGhIssueCreate(title, body, repo, labels) {
22110
22145
  }
22111
22146
 
22112
22147
  // src/commands/github/issue/createIssue.ts
22113
- var USAGE2 = "Usage: assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--project <number>] [--status <name>] [--label <name>]";
22148
+ var USAGE2 = "Usage: assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--parent <issue>] [--project <number>] [--status <name>] [--label <name>]";
22114
22149
  function preflight(options2) {
22115
22150
  try {
22116
22151
  return resolveCreateIssueMetadata(options2);
@@ -22145,6 +22180,9 @@ function registerCreateIssue(issueCommand) {
22145
22180
  ).option(
22146
22181
  "--type <name>",
22147
22182
  "Native issue type to set on the new issue (e.g. Epic)"
22183
+ ).option(
22184
+ "--parent <issue>",
22185
+ "Parent issue to file the new issue under, as owner/repo#number, a github.com issue URL, or a bare number"
22148
22186
  ).option(
22149
22187
  "--project <number>",
22150
22188
  "Number of the repo owner's GitHub Project to add the new issue to"
@@ -22158,7 +22196,7 @@ function registerCreateIssue(issueCommand) {
22158
22196
  []
22159
22197
  ).addHelpText(
22160
22198
  "after",
22161
- "\nThere is no What/Why/How template: an issue reports a problem, and the target repo's own issue template is unknowable from here. Write the body as the repo's maintainers would expect.\nIn an assist web session the title and body are previewed for approve/reject first (with inline comments); nothing is created until it is approved.\n--type, --project, --status and --label are all resolved before the preview, so an unknown name, a missing project scope or --status without --project creates nothing.\nThe project scope is needed for --project: gh auth refresh -h github.com -s project"
22199
+ "\nThere is no What/Why/How template: an issue reports a problem, and the target repo's own issue template is unknowable from here. Write the body as the repo's maintainers would expect.\nIn an assist web session the title and body are previewed for approve/reject first (with inline comments); nothing is created until it is approved.\n--type, --parent, --project, --status and --label are all resolved before the preview, so an unknown name, an unreadable parent, a missing project scope or --status without --project creates nothing.\nA bare --parent number is read against --repo, or the current repo; a parent in another repository is allowed.\nThe project scope is needed for --project: gh auth refresh -h github.com -s project"
22162
22200
  ).action(createIssue);
22163
22201
  }
22164
22202
 
@@ -29076,15 +29114,15 @@ function runReviewSubmission(mutation, body) {
29076
29114
  }
29077
29115
 
29078
29116
  // src/commands/review/submitBodyOnlyReview.ts
29079
- var MUTATION5 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
29117
+ var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
29080
29118
  function submitBodyOnlyReview(body) {
29081
- runReviewSubmission(MUTATION5, body);
29119
+ runReviewSubmission(MUTATION6, body);
29082
29120
  }
29083
29121
 
29084
29122
  // src/commands/review/submitPendingReview.ts
29085
- var MUTATION6 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
29123
+ var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
29086
29124
  function submitPendingReview(body) {
29087
- runReviewSubmission(MUTATION6, body);
29125
+ runReviewSubmission(MUTATION7, body);
29088
29126
  }
29089
29127
 
29090
29128
  // src/commands/review/postAndMaybeSubmit.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.606.1",
3
+ "version": "0.607.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {