nomoreide 0.1.87 → 0.1.88
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.
|
@@ -115,7 +115,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
115
115
|
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ut(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(is(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<bC+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
116
116
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===bC+1&&(this._liveRegion.textContent+=Fv.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let a=e;a<=t;a++){let l=s.lines.get(s.ydisp+a),c=[],d=l?.translateToString(!0,void 0,void 0,c)||"",f=(s.ydisp+a+1).toString(),h=this._rowElements[a];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",f),h.setAttribute("aria-setsize",i),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],a=s.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===l||e.relatedTarget!==i)return;let c,d;if(t===0?(c=s,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=s,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let a=({node:d,offset:f})=>{let h=d instanceof Text?d.parentNode:d,g=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let p=this._rowColumns.get(h);if(!p)return console.warn("columns is null. Race condition?"),null;let b=f<p.length?p[f]:p.slice(-1)[0]+1;return b>=this._terminal.cols&&(++g,b=0),{row:g,column:b}},l=a(t),c=a(s);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.column+c.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,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};Tf=ps([Ge(1,I0),Ge(2,$r),Ge(3,Fr)],Tf);var Sx=class extends xt{constructor(e,t,s,i,a){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ie),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ie),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(is(()=>{_o(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(ut(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ut(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ut(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ut(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 s=e.composedPath();for(let i=0;i<s.length;i++){let a=s[i];if(a.classList.contains("xterm"))break;if(a.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(i=>{i?.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,a]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):a.provideLinks(e.y,l=>{if(this._isMouseOut)return;let c=l?.map(d=>({link:d}));this._activeProviderReplies?.set(i,c),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let a=t.get(i);if(a)for(let l=0;l<a.length;l++){let c=a[l],d=c.link.range.start.y<e?0:c.link.range.start.x,f=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let h=d;h<=f;h++){if(s.has(h)){a.splice(l--,1);break}s.add(h)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),a=!1;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(a=!0);if(!a&&i){let l=i.find(c=>this._linkAtPosition(c.link,t));l&&(s=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let l=0;l<this._activeProviderReplies.size;l++){let c=this._activeProviderReplies.get(l)?.find(d=>this._linkAtPosition(d.link,t));if(c){s=!0,this._handleNewLink(c);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&mK(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,_o(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:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(i,a),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,s){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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,s){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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return s<=a&&a<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,a){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:a}}};Sx=ps([Ge(1,H0),Ge(2,Fr),Ge(3,Sn),Ge(4,I5)],Sx);function mK(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 pK=class extends aK{constructor(e={}){super(e),this._linkifier=this._register(new Al),this.browser=iA,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Al),this._onCursorMove=this._register(new Ie),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ie),this.onKey=this._onKey.event,this._onRender=this._register(new Ie),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ie),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ie),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ie),this.onBell=this._onBell.event,this._onFocus=this._register(new Ie),this._onBlur=this._register(new Ie),this._onA11yCharEmitter=this._register(new Ie),this._onA11yTabEmitter=this._register(new Ie),this._onWillOpen=this._register(new Ie),this._setup(),this._decorationService=this._instantiationService.createInstance(uK),this._instantiationService.setService(Hu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(iW),this._instantiationService.setService(I5,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(qv)),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(nn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(nn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(nn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(nn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(is(()=>{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 s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let a=Jt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${Re.ESC}]${i};${eK(a)}${sA.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=Ds.toColor(...t.color));else{let l=s;this._themeService.modifyColors(c=>c[l]=Ds.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(Tf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Re.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(Re.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 s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,a=t.getWidth(s),l=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=l+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ut(this.element,"copy",t=>{this.hasSelection()&&xG(t,this._selectionService)}));let e=t=>yG(t,this.textarea,this.coreService,this.optionsService);this._register(ut(this.textarea,"paste",e)),this._register(ut(this.element,"paste",e)),rA?this._register(ut(this.element,"mousedown",t=>{t.button===2&&E2(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ut(this.element,"contextmenu",t=>{E2(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),K0&&this._register(ut(this.element,"auxclick",t=>{t.button===1&&T5(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ut(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ut(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ut(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ut(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ut(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ut(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ut(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(ut(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",$v.get()),lA||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sW,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService($r,this._coreBrowserService),this._register(ut(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(ut(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(dx,this._document,this._helperContainer),this._instantiationService.setService(mm,this._charSizeService),this._themeService=this._instantiationService.createInstance(px),this._instantiationService.setService(Pl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ef),this._instantiationService.setService(B5,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(fx,this.rows,this.screenElement)),this._instantiationService.setService(Fr,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(lx,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(hx),this._instantiationService.setService(H0,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Sx,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(ax,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(mx,this.element,this.screenElement,i)),this._instantiationService.setService(jG,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(nn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ox,this.screenElement)),this._register(ut(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(Tf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nf,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nf,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ux,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(l){let c=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!c)return!1;let d,f;switch(l.overrideType||l.type){case"mousemove":f=32,l.buttons===void 0?(d=3,l.button!==void 0&&(d=l.button<3?l.button:3)):d=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":f=0,d=l.button<3?l.button:3;break;case"mousedown":f=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let h=l.deltaY;if(h===0||e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;f=h<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:f,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:l=>(s(l),l.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(l)),wheel:l=>(s(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&s(l)},mousemove:l=>{l.buttons||s(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),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()),l&8?i.mousemove||(t.addEventListener("mousemove",a.mousemove),i.mousemove=a.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),l&16?i.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),i.wheel=a.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),l&2?i.mouseup||(i.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),l&4?i.mousedrag||(i.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ut(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return s(l),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(l)})),this._register(ut(t,"wheel",l=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(l,!0);let c=Re.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(l,!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){A5(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,s){this._selectionService.setSelection(e,t,s)}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 s=lK(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===Re.ETX||s.key===Re.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(gK(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(Ts));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(Re.ESC+"[I"):this.coreService.triggerDataEvent(Re.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Re.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Re.ESC}[6;${a};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function gK(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bK=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;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)}},vK=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 yi)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},vC=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 vK(t)}getNullCell(){return new yi}},xK=class extends xt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ie),this.onBufferChange=this._onBufferChange.event,this._normal=new vC(this._core.buffers.normal,"normal"),this._alternate=new vC(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)}},yK=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.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)}},_K=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}},wK=["cols","rows"],Ki=0,SK=class extends xt{constructor(e){super(),this._core=this._register(new pK(e)),this._addonManager=this._register(new bK),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,a)=>{this._checkReadonlyOptions(i),this._core.options[i]=a};for(let i in this._core.options){let a={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,a)}}_checkReadonlyOptions(e){if(wK.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 yK(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _K(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 xK(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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
|
|
117
117
|
`,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 $v.get()},set promptLabel(e){$v.set(e)},get tooMuchOutput(){return Fv.get()},set tooMuchOutput(e){Fv.set(e)}}}_verifyIntegers(...e){for(Ki of e)if(Ki===1/0||isNaN(Ki)||Ki%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ki of e)if(Ki&&(Ki===1/0||isNaN(Ki)||Ki%1!==0||Ki<0))throw new Error("This API only accepts positive integers")}};const kK={fontSize:13,cursorStyle:"block",scrollback:5e3,copyOnSelect:!1},wb={state:"connecting",cwd:fo("terminal.localWorkspace"),detail:fo("terminal.openingShell")},Rf=1;function CK(e){return{focus:e.focus,input:e.sendInput,refit:e.refit,restart:()=>e.sendControl("restart"),stop:()=>e.sendControl("stop")}}function NK(e,t,s){if(!e||e.readyState!==Rf)return;const i=t?.proposeDimensions();e.send(JSON.stringify({cols:i?.cols,rows:i?.rows,type:s}))}function EK(e,t){if(!e)return;const s=t.schedule(()=>{t.refit(),t.focus()});return()=>t.cancel(s)}function jK(e){const t=e.location??window.location,s=e.createSocket??(g=>new WebSocket(g));e.reportStatus(e.initialStatus);const i=s(AK(e.sessionId,t));let a=!1,l;const c=[],d=e.scheduleInitialInput??(g=>{const p=window.setTimeout(g,200);return()=>window.clearTimeout(p)}),f=()=>{l?.(),l=d(()=>{l=void 0,(e.claimInitialInput?.()??[]).forEach((p,b)=>{const v=()=>i.send(JSON.stringify({data:p,type:"input"}));if(b===0)v();else{const _=e.scheduleInput??((S,C)=>{const N=window.setTimeout(S,C);return()=>window.clearTimeout(N)});c.push(_(v,b*(e.initialInputIntervalMs??75)))}})})},h=e.terminal.onData(g=>{a||i.readyState===Rf&&i.send(JSON.stringify({data:g,type:"input"}))});return i.addEventListener("open",()=>{a||(e.reportStatus(g=>({...g,state:"running",detail:fo("terminal.shellConnected")})),e.sendResize())}),i.addEventListener("message",g=>{if(a)return;const p=TK(g.data);if(p){if(p.type==="output"){e.terminal.write(p.data),f();return}if(p.type==="error"){e.reportStatus(b=>({...b,state:"error",detail:p.error}));return}e.reportStatus(b=>({state:p.state==="idle"?"connecting":p.state,cwd:p.cwd??b.cwd,detail:p.error??p.shell??fo("terminal.shellConnected")}))}}),i.addEventListener("close",()=>{a||e.reportStatus(g=>({...g,state:g.state==="exited"?g.state:"exited",detail:fo("terminal.socketClosed")}))}),i.addEventListener("error",()=>{a||e.reportStatus(g=>({...g,state:"error",detail:fo("terminal.socketError")}))}),{socket:i,dispose:()=>{a||(a=!0,l?.(),c.forEach(g=>{g()}),h.dispose(),i.close())}}}const vA=x.forwardRef(function({sessionId:t,active:s,claimInitialInput:i,initialInputIntervalMs:a,onStatusChange:l,displaySettings:c=kK},d){const f=x.useRef(null),h=x.useRef(null),g=x.useRef(null),p=x.useRef(null),b=x.useRef(l),v=x.useRef(c),_=x.useRef(wb),S=Ls();x.useEffect(()=>{b.current=l},[l]);const C=x.useCallback(E=>{const T=typeof E=="function"?E(_.current):E;_.current=T,b.current?.(T)},[]),N=x.useCallback(()=>{const E=g.current;if(!E)return;E.fit();const T=E.proposeDimensions();if(!T)return;if(S){hO(t,T.cols,T.rows);return}const L=p.current;L?.readyState===Rf&&L.send(JSON.stringify({cols:T.cols,rows:T.rows,type:"resize"}))},[S,t]);x.useEffect(()=>{v.current=c;const E=h.current;E&&(E.options.fontSize=c.fontSize,E.options.cursorStyle=c.cursorStyle,E.options.scrollback=c.scrollback,N())},[c.copyOnSelect,c.cursorStyle,c.fontSize,c.scrollback,N]);const A=x.useCallback(E=>{S||NK(p.current,g.current,E)},[S]),j=x.useCallback(E=>{if(S){Og(t,E);return}const T=p.current;T?.readyState===Rf&&T.send(JSON.stringify({data:E,type:"input"}))},[S,t]);return x.useImperativeHandle(d,()=>CK({focus:()=>h.current?.focus(),refit:N,sendControl:A,sendInput:j}),[A,j,N]),x.useEffect(()=>{const E=f.current;if(!E)return;const T=new SK({allowProposedApi:!0,cursorBlink:!0,cursorStyle:v.current.cursorStyle,fontFamily:'"SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace',fontSize:v.current.fontSize,lineHeight:1.25,scrollback:v.current.scrollback,theme:{background:"#090909",black:"#090909",blue:"#69a7ff",brightBlack:"#5f6368",brightBlue:"#8ab4f8",brightCyan:"#7ddfd7",brightGreen:"#8fdc8a",brightMagenta:"#d7a2ff",brightRed:"#ff8a80",brightWhite:"#ffffff",brightYellow:"#ffd166",cyan:"#62d0c8",foreground:"#f2f2f2",green:"#7ac77f",magenta:"#c792ea",red:"#ff6b6b",selectionBackground:"#ffffff33",white:"#e8eaed",yellow:"#f7c948"}}),L=new mG;T.loadAddon(L),T.open(E),h.current=T,g.current=L;const H=T.onSelectionChange(()=>{if(!v.current.copyOnSelect)return;const z=T.getSelection();if(z)try{navigator.clipboard?.writeText(z).catch(()=>{})}catch{}});let P;if(S){C(wb);let z=null,G=!1,D;const q=T.onData(W=>{Og(t,W)});mO(t,W=>{T.write(W),D!==void 0&&window.clearTimeout(D),D=window.setTimeout(()=>{D=void 0,(async()=>{const I=i?.()??[];for(let Y=0;Y<I.length;Y+=1)Y>0&&await new Promise($=>window.setTimeout($,a??75)),await Og(t,I[Y])})()},200)}).then(W=>{if(G){W();return}z=W,C(I=>({...I,state:"running",detail:fo("terminal.shellConnected")})),dO(t),N()},W=>{G||C(I=>({...I,state:"error",detail:W instanceof Error?W.message:String(W)}))}),P=()=>{G=!0,D!==void 0&&window.clearTimeout(D),q.dispose(),z?.()}}else{const z=jK({claimInitialInput:i,initialInputIntervalMs:a,initialStatus:wb,reportStatus:C,sendResize:N,sessionId:t,terminal:T});p.current=z.socket,P=()=>{z.dispose(),p.current=null}}window.addEventListener("resize",N);const F=window.setTimeout(N,0),M=new ResizeObserver(()=>N());return M.observe(E),()=>{window.removeEventListener("resize",N),window.clearTimeout(F),M.disconnect(),P(),H.dispose(),T.dispose(),h.current=null,g.current=null}},[C,t,N,S]),x.useEffect(()=>EK(s,{cancel:E=>window.clearTimeout(E),focus:()=>h.current?.focus(),refit:N,schedule:E=>window.setTimeout(E,0)}),[s,N]),n.jsx("section",{"aria-label":"terminal viewport",className:re("h-full min-h-0 overflow-hidden bg-[#090909] px-3 py-0.5",!s&&"hidden"),children:n.jsx("div",{className:"h-full w-full",ref:f})})});function AK(e,t){const s=t.protocol==="https:"?"wss:":"ws:",i=encodeURIComponent(e);return`${s}//${t.host}/api/terminal/socket?id=${i}`}function TK(e){if(typeof e!="string")return null;try{const t=JSON.parse(e);return typeof t?.type=="string"?t:null}catch{return null}}const RK={skills:"agent-env",mcps:"agent-env",plugins:"agent-env",hooks:"agent"};function xA(e,t){return t?t.needsAuth||t.failed?[t.needsAuth?e("dock.mcpNeedsAuth",{count:t.needsAuth}):"",t.failed?e("dock.mcpFailed",{count:t.failed}):""].filter(Boolean).join(" · "):t.checked?e("dock.mcpConnected"):void 0:e("dock.mcpAuthChecking")}function yA({auth:e,mcps:t}){return t===0?null:e?e.failed?n.jsx("span",{className:"size-1.5 rounded-full bg-red-500"}):e.needsAuth?n.jsx("span",{className:"size-1.5 rounded-full bg-amber-500"}):e.checked?n.jsx("span",{className:"size-1.5 rounded-full bg-emerald-500"}):null:n.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-muted-foreground/50"})}function MK(e){if(!e)return null;const t=e==="failed"?"bg-red-500":e==="needs-auth"?"bg-amber-500":e==="unknown"?"bg-muted-foreground/50":"bg-emerald-500";return n.jsx("span",{className:re("size-1.5 shrink-0 rounded-full",t)})}function DK(e){const t=e.getBoundingClientRect();return{left:Math.max(8,Math.min(t.left,window.innerWidth-296)),top:t.top,bottom:t.bottom,up:window.innerHeight-t.bottom<300}}function LK({anchor:e,items:t,mcpAuth:s,onClose:i,onInsert:a,onManage:l}){const c=J(),d=x.useRef(null);return x.useEffect(()=>{function f(p){const b=p.target;d.current?.contains(b)||b.closest?.("[data-capability-trigger]")||i()}function h(p){p.key==="Escape"&&i()}function g(p){d.current?.contains(p.target)||i()}return document.addEventListener("mousedown",f),document.addEventListener("keydown",h),window.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",h),window.removeEventListener("scroll",g,!0)}},[i]),Hi.createPortal(n.jsxs("div",{className:"fixed z-50 w-72 overflow-hidden rounded-md border border-border bg-card shadow-md","data-capability-menu":!0,ref:d,style:e.up?{left:e.left,bottom:window.innerHeight-e.top+4}:{left:e.left,top:e.bottom+4},children:[n.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:t.length===0?n.jsx("div",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:c("dock.capabilityEmpty")}):t.map((f,h)=>{const g=f.insert,p=n.jsxs(n.Fragment,{children:[s?MK(s[f.name]):null,n.jsx("span",{className:re("truncate font-mono text-xs",f.sub&&"pl-4"),children:f.name}),f.detail?n.jsx("span",{className:"ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[10px] text-muted-foreground",children:f.detail}):null]}),b=`${f.name}-${h}`;return g&&a?n.jsx("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left transition-colors hover:bg-muted",onClick:()=>{a(g),i()},type:"button",children:p},b):n.jsx("div",{className:"flex w-full items-center gap-2 px-2 py-1.5",children:p},b)})}),l?n.jsx("button",{className:"flex w-full items-center border-t border-border px-2 py-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>{l(),i()},type:"button",children:c("dock.capabilityManage")}):null]}),document.body)}function _A(e,t,s){const[i,a]=x.useState(null),l=d=>f=>{const h=DK(f.currentTarget);a(g=>g?.key===d?null:{key:d,anchor:h})},c=i&&e.items?n.jsx(LK,{anchor:i.anchor,items:e.items[i.key],mcpAuth:i.key==="mcps"?e.mcpAuth:void 0,onClose:()=>a(null),onInsert:t,onManage:s?()=>s(RK[i.key]):void 0}):null;return{openKey:i?.key??null,toggle:l,dropdown:c}}function OK({capabilities:e,providerLabel:t,onInsert:s,onNavigate:i}){const a=J(),{counts:l,auth:c}=e,{openKey:d,toggle:f,dropdown:h}=_A(e,s,i);return l?n.jsxs("nav",{"aria-label":a("dock.capabilitiesAria",{name:t??"Agent"}),className:"mt-2 flex flex-wrap items-center gap-1.5",children:[n.jsx(Ah,{count:l.skills,expanded:d==="skills",icon:n.jsx(Bn,{}),label:a("agentEnv.skills"),onClick:f("skills")}),n.jsx(Ah,{count:l.mcps,expanded:d==="mcps",icon:n.jsx(Yf,{}),label:a("agentEnv.mcpServers"),onClick:f("mcps"),title:xA(a,c),trailing:n.jsx(yA,{auth:c,mcps:l.mcps})}),n.jsx(Ah,{count:l.plugins,expanded:d==="plugins",icon:n.jsx(Tu,{}),label:a("agentEnv.plugins"),onClick:f("plugins")}),n.jsx(Ah,{count:l.hooks,expanded:d==="hooks",icon:n.jsx(Qx,{}),label:a("dock.hooks"),onClick:f("hooks")}),h]}):null}function PK({capabilities:e,providerLabel:t,onInsert:s,onNavigate:i}){const a=J(),{counts:l,auth:c}=e,{openKey:d,toggle:f,dropdown:h}=_A(e,s,i);if(!l)return null;const g=(b,v,_,S,C)=>n.jsxs("button",{"aria-expanded":d===b,className:"flex h-7 items-center gap-1 rounded-sm px-1.5 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3","data-capability-trigger":!0,onClick:f(b),title:S,type:"button",children:[v,n.jsx("span",{children:_}),C]}),p=[`${a("agentEnv.mcpServers")}: ${l.mcps}`,xA(a,c)].filter(Boolean).join(" · ");return n.jsxs("nav",{"aria-label":a("dock.capabilitiesAria",{name:t??"Agent"}),className:"hidden shrink-0 items-center gap-0.5 border-l border-border px-1 sm:flex",children:[g("skills",n.jsx(Bn,{}),l.skills,`${a("agentEnv.skills")}: ${l.skills}`),g("mcps",n.jsx(Yf,{}),l.mcps,p,n.jsx(yA,{auth:c,mcps:l.mcps})),g("plugins",n.jsx(Tu,{}),l.plugins,`${a("agentEnv.plugins")}: ${l.plugins}`),g("hooks",n.jsx(Qx,{}),l.hooks,`${a("dock.hooks")}: ${l.hooks}`),h]})}function Ah({count:e,expanded:t,icon:s,label:i,onClick:a,title:l,trailing:c}){return n.jsxs("button",{"aria-expanded":t,className:re("flex items-center gap-1.5 rounded-sm border border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3",t&&"bg-muted text-foreground"),"data-capability-trigger":!0,onClick:a,title:l,type:"button",children:[s,n.jsx("span",{children:i}),n.jsx("span",{className:"font-mono text-foreground",children:e}),c]})}function zK(e){return Object.keys(e.mcpServers).length+Object.keys(e.remoteMcpServers).length+Object.keys(e.projectMcpServers).length+Object.keys(e.projectRemoteMcpServers).length}function BK(e,t){const s=e?.skills??[];return{skills:s.filter(i=>i.kind!=="plugin").length,plugins:s.filter(i=>i.kind==="plugin").length,mcps:e?zK(e):0,hooks:t}}function IK(e){let t=0,s=0;for(const i of e)i.state==="needs-auth"?t+=1:i.state==="failed"&&(s+=1);return{checked:e.length,needsAuth:t,failed:s}}function HK(e,t){return t==="claude"?`/${e} `:`@${e} `}function $K(e){return`Use the "${e}" MCP server: `}function FK(e,t,s){const i=[],a=[];for(const f of e?.skills??[])if(f.kind==="plugin"){if(a.push({name:f.name,detail:f.scope,insert:`Use the "${f.name}" plugin: `}),s==="claude")for(const h of[...f.pluginSkills??[],...f.pluginCommands??[]])a.push({name:`${f.name}:${h}`,insert:`/${f.name}:${h} `,sub:!0})}else i.push({name:f.name,detail:f.scope,insert:HK(f.name,s)});const l=[],c=[[e?.mcpServers??{},"user"],[e?.remoteMcpServers??{},"user · remote"],[e?.projectMcpServers??{},"project"],[e?.projectRemoteMcpServers??{},"project · remote"]];for(const[f,h]of c)for(const g of Object.keys(f))l.push({name:g,detail:h,insert:$K(g)});const d=t.map(f=>({name:f.matcher?`${f.event} · ${f.matcher}`:f.event,detail:f.command}));return{skills:i,plugins:a,mcps:l,hooks:d}}function UK(e,t=!0){const s=e==="codex"?"codex":"claude",i=e==="codex"?"codex":"claude-code",[a,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(null),[g,p]=x.useState({});return x.useEffect(()=>{if(!t)return;let b=!1;return l(null),d(null),h(null),p({}),Promise.all([PE().catch(()=>[]),e0().catch(()=>null)]).then(([v,_])=>{if(b)return;const S=v.find(N=>N.agent===s),C=_?.agents[i]?.hooks??[];l(BK(S,C.length)),d(FK(S,C,e))}),OE(i).then(v=>{b||(h(IK(v)),p(Object.fromEntries(v.map(_=>[_.name,_.state]))))}).catch(()=>{b||h({checked:0,needsAuth:0,failed:0})}),()=>{b=!0}},[t,s,i,e]),{counts:a,items:c,auth:f,mcpAuth:g}}const qK=new Set(["c","cpp","cs","go","java","js","jsx","kt","mjs","py","rs","swift","ts","tsx"]),GK=new Set([".env",".gitignore","components.json","dockerfile","package.json","tsconfig.json","vite.config.ts"]),VK=new Set(["conf","config","ini","toml","yaml","yml"]),WK=new Set(["csv","json","sql","xml"]),KK=new Set(["md","mdx","rst","txt"]),YK=new Set(["gif","jpeg","jpg","png","svg","webp"]),XK=new Set(["package-lock.json","pnpm-lock.yaml","yarn.lock"]),ZK=new Set(["css","less","sass","scss"]);function QK(e){const t=e.split("/").pop()?.toLowerCase()??e.toLowerCase(),s=t.includes(".")?t.split(".").pop()??"":"";return XK.has(t)||t.endsWith(".lock")?"lock":JK(t)?"test":GK.has(t)||VK.has(s)?"config":ZK.has(s)?"style":YK.has(s)?"image":KK.has(s)?"document":WK.has(s)?"data":qK.has(s)?"code":"generic"}function JK(e){return e.includes(".test.")||e.includes(".spec.")||e.endsWith("_test.go")}function Y0({path:e,className:t}){const s=QK(e),i=eY[s];return n.jsx(i,{"aria-label":`${s} file`,className:re("size-3.5 shrink-0",tY[s],t)})}const eY={code:fE,config:Zx,data:si,document:qx,generic:gE,image:U6,lock:oD,style:wE,test:b6},tY={code:"text-sky-600",config:"text-zinc-600",data:"text-emerald-700",document:"text-blue-700",generic:"text-muted-foreground",image:"text-fuchsia-700",lock:"text-amber-700",style:"text-rose-700",test:"text-violet-700"};function sY(e){const t=e.lastIndexOf(".");return t>0?e.slice(t):""}function nY({onPick:e,onClose:t}){const[s,i]=x.useState(""),[a,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(!1),g=x.useRef(null),p=J(),b=a?a.parent!==a.path:!1;return x.useEffect(()=>{function v(_){g.current&&!g.current.contains(_.target)&&t()}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[t]),x.useEffect(()=>{let v=!0;return h(!0),d(null),XE(s,{files:!0}).then(_=>v&&l(_)).catch(_=>v&&d(_ instanceof Error?_.message:String(_))).finally(()=>v&&h(!1)),()=>{v=!1}},[s]),n.jsxs("div",{ref:g,className:"absolute bottom-full left-2 z-10 mb-2 w-[22rem] max-w-[calc(100vw-1rem)] overflow-hidden rounded-md border border-border bg-card shadow-lg",children:[n.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[n.jsx(Q,{"aria-label":p("agent.picker.parentFolder"),className:"size-7",disabled:!b,onClick:()=>a&&i(a.parent),size:"icon",type:"button",variant:"ghost",children:n.jsx(qf,{})}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:a?.path,children:a?.path??"…"}),f?n.jsx(Mt,{className:"size-3.5 animate-spin text-muted-foreground"}):null,a?n.jsxs(Q,{className:"h-7 px-2 text-[11px]",onClick:()=>e(a.path),size:"sm",title:p("agent.picker.attachFolder"),type:"button",variant:"outline",children:[n.jsx(ZM,{})," ",p("agent.picker.thisFolder")]}):null,n.jsx(Q,{"aria-label":p("common.close"),className:"size-7",onClick:t,size:"icon",type:"button",variant:"ghost",children:n.jsx(Vt,{})})]}),n.jsx("div",{className:"max-h-64 overflow-auto p-1",children:c?n.jsx(Ze,{variant:"destructive",className:"m-1",children:c}):a&&a.entries.length===0?n.jsx(Ze,{variant:"muted",className:"m-1 text-center",children:p("agent.picker.emptyFolder")}):a?.entries.map(v=>{const _=v.isDir?"":sY(v.name);return n.jsxs("button",{className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[12px] hover:bg-muted",onClick:()=>v.isDir?i(v.path):e(v.path),title:v.path,type:"button",children:[v.isDir?n.jsx(Co,{className:"size-3.5 shrink-0 text-amber-600"}):n.jsx(Y0,{path:v.path}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.name}),_?n.jsx("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] text-muted-foreground",children:_}):null]},v.path)})})]})}const xC="flex h-7 items-center gap-1.5 rounded-sm px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-40";function iY(e,t){const s=t?.trim()||e.split(/\r?\n/).find(i=>i.trim())?.trim()||"Agent task";return s.length>60?`${s.slice(0,57).trimEnd()}…`:s}function rY({capabilities:e,onNavigate:t,onShellMode:s,shellMode:i=!1}){const a=J(),{activeSource:l,clearSource:c,configured:d,createShellTask:f,createTask:h,creating:g,draft:p,focusNonce:b,insertPath:v,insertPrompt:_,onboarding:S,provider:C,providers:N,selectProvider:A,setDraft:j,setOnboarding:E}=Ot(),[T,L]=x.useState(!1),[H,P]=x.useState(""),F=x.useRef(null);x.useEffect(()=>{const D=requestAnimationFrame(()=>{const q=F.current;if(!q)return;q.focus();const W=q.value.length;q.setSelectionRange(W,W)});return()=>cancelAnimationFrame(D)},[b]),x.useLayoutEffect(()=>{F.current&&(F.current.style.height="auto",F.current.style.height=`${F.current.scrollHeight}px`)},[p]);const M=!!g||(i?!1:!p.trim()||d!==!0);async function z(D=p,q){if(g)return;if(i){if(!await f(D))return;j(""),c(),P("");return}!D.trim()||d!==!0||!await h({prompt:D,label:iY(D,q??l?.label),source:l??void 0})||(j(""),c(),E(!1),P(""))}function G(D){D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),z())}return n.jsx("div",{className:"flex h-full items-center justify-center overflow-auto p-6",children:n.jsxs("div",{className:"w-full max-w-3xl",children:[!i&&d===null?n.jsx("div",{className:"mb-3 border-l-2 border-border pl-3 text-xs text-muted-foreground",children:a("dock.checkingAvailability",{name:C?.label??"agent"})}):null,!i&&d===!1?n.jsxs("div",{className:"mb-3 border-l-2 border-amber-500/70 pl-3 text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-medium text-foreground",children:a("dock.notInstalled",{name:C?.label??"Agent"})})," ",C?.installHint]}):null,l?n.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"font-mono uppercase tracking-wide",children:a("dock.sourceLabel")}),n.jsx("span",{className:"rounded-sm bg-muted px-1.5 py-0.5 text-foreground",children:l.label}),n.jsx("button",{"aria-label":a("dock.clearSourceAria"),onClick:c,type:"button",children:n.jsx(Vt,{className:"size-3"})})]}):null,n.jsxs("div",{className:"border border-border bg-card shadow-sm",children:[S&&!i?n.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx(J6,{className:"size-4 text-muted-foreground"}),n.jsx("input",{"aria-label":a("dock.repoUrlAria"),className:"min-w-0 flex-1 bg-transparent text-sm outline-none",disabled:d!==!0,onChange:D=>P(D.target.value),placeholder:"https://github.com/owner/repository",value:H}),n.jsx(Q,{disabled:d!==!0||!H.trim()||!!g,onClick:()=>{z(HF(H),`Onboard ${H}`)},size:"sm",children:a("dock.onboard")})]}):null,n.jsx("textarea",{"aria-label":a(i?"dock.shellCommandAria":"dock.promptAria"),className:re("block max-h-40 min-h-20 w-full resize-none bg-transparent px-3 py-3 text-sm leading-relaxed outline-none placeholder:text-muted-foreground",i&&"font-mono"),disabled:!i&&d!==!0,onChange:D=>j(D.target.value),onKeyDown:G,placeholder:a(i?"dock.shellPlaceholder":"dock.promptPlaceholder"),ref:F,rows:2,value:p}),n.jsxs("div",{className:"flex h-10 items-center gap-1 border-t border-border px-2",children:[n.jsxs("fieldset",{"aria-label":a("dock.providerAria"),className:"flex shrink-0 items-center gap-0.5",children:[N.map(D=>{const q=D.id==="codex"?Oa:Ir,W=!i&&(C?.id??"claude")===D.id;return n.jsxs("button",{"aria-label":D.label,"aria-pressed":W,className:re(xC,W&&"bg-muted text-foreground"),disabled:!D.configured,onClick:()=>{s?.(!1),A(D.id)},title:D.configured?D.label:`${D.label}${a("dock.notInstalledSuffix")} — ${D.installHint}`,type:"button",children:[n.jsx(q,{className:"size-3.5"}),W?n.jsx("span",{children:D.label}):null]},D.id)}),n.jsxs("button",{"aria-label":a("dock.shell"),"aria-pressed":i,className:re(xC,i&&"bg-muted text-foreground"),onClick:()=>s?.(!0),title:a("dock.shellTitle"),type:"button",children:[n.jsx(Br,{className:"size-3.5"}),i?n.jsx("span",{children:a("dock.shell")}):null]})]}),n.jsx("button",{"aria-label":a("dock.attachAria"),className:"grid size-7 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>L(D=>!D),type:"button",children:n.jsx(BD,{className:"size-3.5"})}),i?null:n.jsx("button",{className:"px-2 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>E(!S),type:"button",children:a("dock.repoUrlToggle")}),n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"hidden text-[10px] text-muted-foreground sm:inline",children:a(i?"dock.shellEnterHint":"dock.shiftEnterHint")}),n.jsx(Q,{"aria-label":a(i?"dock.openShellAria":"dock.runAria"),className:"size-7",disabled:M,onClick:()=>{z()},size:"icon",children:n.jsx($f,{})})]})]}),e?n.jsx(OK,{capabilities:e,onInsert:_,onNavigate:t,providerLabel:C?.label}):null,T?n.jsx("div",{className:"relative mt-2",children:n.jsx(nY,{onClose:()=>L(!1),onPick:D=>{v(D),L(!1)}})}):null]})})}const Qi="new";function aY(e){return e==="running"?"fill-emerald-500 text-emerald-500":e==="error"?"fill-destructive text-destructive":"fill-muted-foreground/50 text-muted-foreground/50"}function oY({tasks:e,activeTaskId:t,composing:s,onActivate:i,onClose:a,onSplit:l,pendingTaskIds:c,splitTaskId:d}){const f=J();return n.jsxs("div",{"aria-label":f("dock.tasksAria"),className:"flex min-w-0 flex-1 items-stretch gap-px overflow-x-auto",role:"tablist",children:[e.map(h=>{const g=h.kind==="shell",p=h.label||(g?f("dock.shellFallback"):f("dock.taskFallback",{provider:h.provider==="codex"?"Codex":"Claude"})),b=h.id===t,v=h.id===d,_=g?Br:h.provider==="codex"?Oa:Ir;return n.jsxs("div",{className:re("group/tab flex h-9 shrink-0 items-center border-x border-transparent",(b||v)&&"border-border bg-background"),"data-split":v||void 0,children:[n.jsxs("button",{"aria-controls":`agent-panel-${h.id}`,"aria-label":f("dock.openTaskAria",{label:p}),"aria-selected":b,className:"flex h-full max-w-56 items-center gap-2 px-3 text-xs",id:`agent-tab-${h.id}`,onClick:()=>i(h.id),role:"tab",type:"button",children:[n.jsx(_,{className:re("size-3 shrink-0",b||v?"text-foreground":"text-muted-foreground")}),n.jsx(Cl,{"aria-hidden":!0,className:re("size-2",aY(h.state))}),n.jsx("span",{className:re("truncate font-mono text-[11px]",b||v?"text-foreground":"text-muted-foreground"),children:p})]}),l&&!b?n.jsx("button",{"aria-label":f(v?"dock.unsplitTaskAria":"dock.splitTaskAria",{label:p}),"aria-pressed":v,className:re("grid size-6 place-items-center rounded-sm text-muted-foreground opacity-50 hover:bg-muted hover:text-foreground group-hover/tab:opacity-100",v&&"text-foreground opacity-100"),onClick:()=>l(h.id),type:"button",children:n.jsx(GM,{className:"size-3"})}):null,n.jsx("button",{"aria-label":f("dock.closeTaskAria",{label:p}),className:"mr-1 grid size-6 place-items-center rounded-sm text-muted-foreground opacity-50 hover:bg-muted hover:text-foreground group-hover/tab:opacity-100 disabled:pointer-events-none disabled:opacity-25",disabled:c?.has(h.id),onClick:()=>a(h.id),type:"button",children:n.jsx(Vt,{className:"size-3"})})]},h.id)}),s?n.jsx("div",{className:"flex h-9 shrink-0 items-center border-x border-border bg-background",children:n.jsxs("button",{"aria-controls":`agent-panel-${Qi}`,"aria-selected":!0,className:"flex h-full items-center gap-2 px-3 text-xs",id:`agent-tab-${Qi}`,onClick:()=>i(Qi),role:"tab",type:"button",children:[n.jsx(ms,{"aria-hidden":!0,className:"size-3 shrink-0 text-foreground"}),n.jsx("span",{className:"truncate font-mono text-[11px] text-foreground",children:f("dock.newTaskTab")})]})}):null]})}const lY=5,kx=new Map,Sb=new Map,Cx=[];let Nx=0;function yC(){for(;Nx<lY&&Cx.length>0;){const e=Cx.shift();e&&(Nx++,e())}}function cY(e){return kx.get(e)}function wA(e){const t=kx.get(e);if(t)return Promise.resolve(t);const s=Sb.get(e);if(s)return s;const i=new Promise((a,l)=>{Cx.push(()=>{K7(e).then(c=>{c.state!=="pending"&&kx.set(e,c),a(c)}).catch(l).finally(()=>{Nx--,Sb.delete(e),yC()})})});return Sb.set(e,i),yC(),i}function uY(e,t){const{claude:s,codex:i}=e??{},a=i?{fiveHour:i.primary,weekly:i.secondary,contextPercent:i.contextWindow&&i.contextWindow>0?Math.min(100,i.lastTotalTokens/i.contextWindow*100):null,costUSD:null}:null,l=s?{fiveHour:s.fiveHour,weekly:s.weekly,contextPercent:null,costUSD:s.costUSD}:null;return t==="codex"&&a?a:l??a??null}function dY(e){const t=e?.selectedRepository?.name??null,s=e?.status?.branch??null,i=e?.status?.ahead??0,[a,l]=x.useState(null),[c,d]=x.useState(null);return x.useEffect(()=>{if(!t){l(null);return}let f=!0;return $E(1).then(h=>{f&&l(h[0]?.hash??null)}).catch(()=>{f&&l(null)}),()=>{f=!1}},[t,s,i]),x.useEffect(()=>{if(!a){d(null);return}let f=!0;const h=()=>wA(a).then(p=>{f&&d(p)}).catch(()=>{f&&d(null)});h();const g=window.setInterval(h,3e4);return()=>{f=!1,window.clearInterval(g)}},[a]),c}function hY(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-emerald-500"}function fY(e){switch(e){case"success":return"bg-emerald-500";case"pending":return"bg-amber-400 animate-pulse";case"failure":return"bg-red-500";case"error":return"bg-orange-500";default:return"bg-zinc-400"}}function mY(e,t,s){const i=e("dock.status.limitTitle",{label:t,pct:s.usedPercent.toFixed(0)});if(!s.resetsAtUnix)return i;const a=new Date(s.resetsAtUnix*1e3).toLocaleString();return`${i}${e("dock.status.resetsSuffix",{time:a})}`}function _C({label:e,window:t,className:s}){const i=J(),a=Math.min(100,Math.max(0,t.usedPercent));return n.jsxs("span",{className:re("flex items-center gap-1 font-mono text-[10px] text-muted-foreground",s),title:mY(i,e,t),children:[n.jsx("span",{children:e}),n.jsx("span",{className:"h-1.5 w-7 overflow-hidden rounded-full bg-muted",children:n.jsx("span",{className:re("block h-full",hY(a)),style:{width:`${a.toFixed(0)}%`}})}),n.jsxs("span",{className:"tabular-nums text-foreground",children:[a.toFixed(0),"%"]})]})}function Th({title:e,className:t,children:s}){return n.jsx("span",{className:re("flex items-center gap-1 font-mono text-[10px] text-muted-foreground",t),title:e,children:s})}function wC(){return n.jsx("span",{"aria-hidden":!0,className:"h-3 w-px shrink-0 bg-border"})}function SC({git:e,provider:t,variant:s="strip"}){const i=J(),{usage:a}=f5(15e3),l=dY(e),c=uY(a,t),d=e?.status??null,f=d?.upstream??i("dock.status.noUpstream"),h=l&&l.state!=="unknown"&&l.totalCount>0,g=s==="strip"&&!!d?.branch,p=s==="strip"&&(c?.contextPercent!=null||c?.costUSD!=null),b=[];return g&&d&&b.push(n.jsxs(Th,{className:"hidden max-w-[9rem] md:flex",title:i("dock.status.branchTitle",{branch:d.branch,upstream:f}),children:[n.jsx(_n,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate text-foreground",children:d.branch}),d.ahead>0?n.jsxs("span",{className:"text-emerald-600",children:["↑",d.ahead]}):null,d.behind>0?n.jsxs("span",{className:"text-amber-600",children:["↓",d.behind]}):null]},"branch")),h&&l&&b.push(n.jsxs(Th,{className:"hidden sm:flex",title:i("dock.status.ciTitle",{state:l.state,count:l.totalCount}),children:[n.jsx("span",{className:re("size-2 shrink-0 rounded-full",fY(l.state))}),n.jsx("span",{children:i("dock.status.ci")})]},"ci")),c?.fiveHour&&b.push(n.jsx(_C,{label:i("dock.status.fiveHour"),window:c.fiveHour},"5h")),c?.weekly&&b.push(n.jsx(_C,{className:"hidden sm:flex",label:i("dock.status.weekly"),window:c.weekly},"wk")),p&&c&&(c.contextPercent!=null?b.push(n.jsxs(Th,{className:"hidden lg:flex",title:i("dock.status.contextTitle",{pct:c.contextPercent.toFixed(0)}),children:[n.jsx("span",{children:i("dock.status.context")}),n.jsxs("span",{className:"tabular-nums text-foreground",children:[c.contextPercent.toFixed(0),"%"]})]},"ctx")):c.costUSD!=null&&b.push(n.jsx(Th,{className:"hidden lg:flex",title:i("dock.status.costTitle",{cost:c.costUSD.toFixed(4)}),children:n.jsxs("span",{className:"tabular-nums text-emerald-700 dark:text-emerald-500",children:["$",c.costUSD.toFixed(2)]})},"cost"))),b.length===0?null:n.jsxs("span",{className:re("flex shrink-0 items-center gap-2",s==="dock"&&"hidden border-l border-border px-2 lg:flex"),children:[s==="strip"?n.jsx(wC,{}):null,b.map((v,_)=>n.jsxs("span",{className:"flex items-center gap-2",children:[_>0?n.jsx(wC,{}):null,v]},_))]})}function bm({className:e}){return n.jsx("svg",{className:re("size-3.5",e),viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:n.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}const SA="nomoreide-theme-choice",pY="nomoreide:ui-preferences";function gY(){if(typeof window>"u")return"system";try{const e=window.localStorage.getItem(pY),t=e?JSON.parse(e):null;if(t?.version===1&&(t.theme==="light"||t.theme==="dark"||t.theme==="system"))return t.theme}catch{}try{const e=window.localStorage.getItem(SA);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function X0(e){return e!=="system"?e:typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ex(e){if(typeof document>"u")return;const t=document.documentElement;t.classList.toggle("dark",e==="dark"),t.style.colorScheme=e}let So=gY(),po=X0(So);const sf=new Set;let yo=null;function kA(){for(const e of sf)e()}function Mf(){if(yo?.(),yo=null,po=X0(So),Ex(po),So!=="system"||typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=s=>{po=s.matches?"dark":"light",Ex(po),kA()};e.addEventListener("change",t),yo=()=>e.removeEventListener("change",t)}Mf();function bY(){return So}function vY(){return po}function jx(e){if(!(e!==So)){e==="system"&&!yo?Mf():(po=X0(e),Ex(po));return}So=e,Mf();try{window.localStorage.setItem(SA,e)}catch{}kA()}function CA(e){return sf.add(e),So==="system"&&!yo&&Mf(),()=>{sf.delete(e),sf.size===0&&(yo?.(),yo=null)}}function NA(){return[x.useSyncExternalStore(CA,bY,()=>"system"),jx]}function xY(){return x.useSyncExternalStore(CA,vY,()=>"dark")}const EA="nomoreide:ui-preferences";function yY(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function jA(){return{version:1,theme:"system",language:"en",density:"comfortable",codeFontSize:12,reducedMotion:yY(),sidebarDocked:!1,projectScope:"all"}}function _Y(){if(typeof window>"u")return{};const e=bl("nomoreide-theme-choice"),t=bl("nomoreide-language")??bl("nomoreide-language-choice"),s=bl("nomoreide:sidebar-docked"),i=bl("nomoreide:project-scope");return{...e==="light"||e==="dark"||e==="system"?{theme:e}:{},...t==="en"||t==="zh"?{language:t}:{},...s==="true"||s==="false"?{sidebarDocked:s==="true"}:{},...i==="all"||i==="project"?{projectScope:i}:{}}}function bl(e){try{return window.localStorage.getItem(e)}catch{return null}}function vm(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return t.version!==1||!["light","dark","system"].includes(String(t.theme))||!["en","zh"].includes(String(t.language))||!["comfortable","compact"].includes(String(t.density))||typeof t.codeFontSize!="number"||!Number.isInteger(t.codeFontSize)||t.codeFontSize<10||t.codeFontSize>18||typeof t.reducedMotion!="boolean"||typeof t.sidebarDocked!="boolean"||!["all","project"].includes(String(t.projectScope))?null:t}function wY(e,t){return vm({...e,...t})}function mu(e){const t=vm(e);if(!t)return!1;try{return window.localStorage.setItem(EA,JSON.stringify(t)),!0}catch{return!1}}function SY(){let e=null;try{const s=bl(EA);e=s?vm(JSON.parse(s)):null}catch{e=null}const t=e??{...jA(),..._Y()};return mu(t),t}function kY(){const e=jA();return mu(e),e}function kC(e){if(typeof document>"u")return;const t=document.documentElement;t.dataset.density=e.density,t.dataset.reducedMotion=String(e.reducedMotion),t.style.setProperty("--code-font-size",`${e.codeFontSize}px`)}const CC={version:1,terminal:{fontSize:13,cursorStyle:"block",scrollback:5e3,copyOnSelect:!1,confirmTerminate:!0}},Rh={logs:{showTimestamps:!0,wrapLines:!0},database:{confirmWrites:!0,resultLimit:100}},AA=x.createContext(null);function _a(e){return e instanceof Error?e.message:String(e)}function CY(e,t){return{...e,terminal:{...e.terminal,...t.terminal}}}function NY(e,t){return{...e,logs:{...e.logs,...t.logs},database:{...e.database,...t.database}}}function EY({children:e}){const[t,s]=x.useState(CC),[i,a]=x.useState(CC),[l,c]=x.useState(Rh),[d,f]=x.useState(Rh),[h,g]=x.useState(()=>SY()),[p,b]=x.useState(!0),[v,_]=x.useState(null),[S,C]=x.useState(!1),[N,A]=x.useState(null),[j,E]=x.useState(null),[T,L]=x.useState("idle"),[H,P]=x.useState(null),[F]=NA(),[M]=a5(),z=x.useRef(!0),G=x.useRef(!1),D=x.useRef(0),q=x.useRef(0),W=x.useRef(0),I=x.useRef(0),Y=x.useRef(Promise.resolve()),$=x.useRef(Promise.resolve()),me=x.useRef(t),ee=x.useRef(l),V=x.useRef(null),K=x.useRef(null),xe=x.useRef(h),ie=x.useRef(i),Z=x.useRef(d),ge=x.useRef(null),ne=x.useRef(0),we=x.useRef(null),Ne=x.useRef(null),Ue=x.useRef(!1),Pe=x.useRef(null),Me=x.useRef(h.language),pe=x.useCallback(()=>{ge.current!==null&&(window.clearTimeout(ge.current),ge.current=null)},[]),Je=x.useCallback(()=>{pe(),L("saved"),ge.current=window.setTimeout(()=>{z.current&&L("idle")},1500)},[pe]),jt=x.useCallback(()=>{pe(),ne.current===0&&(we.current=null,P(null)),ne.current+=1,L("saving")},[pe]),dt=x.useCallback(st=>{if(st&&!we.current&&(we.current=st),ne.current=Math.max(0,ne.current-1),ne.current>0){L("saving"),we.current&&P(we.current);return}if(we.current){P(we.current),L("error");return}Je()},[Je]),Fs=x.useCallback(st=>{if(V.current===st)return K.current??Promise.resolve();const nt=++q.current;if(++I.current,V.current=st,_(st),E(null),ee.current=structuredClone(Rh),Z.current=structuredClone(Rh),c(ee.current),f(Z.current),st===null)return C(!1),K.current=null,Promise.resolve();C(!0);const k=$.current.then(()=>$g(st)).then(se=>{!z.current||nt!==q.current||V.current!==st||(ee.current=se.project,Z.current=se.project,c(se.project),f(se.project))}).catch(se=>{z.current&&nt===q.current&&V.current===st&&E(`Could not load project settings: ${_a(se)}`)}).finally(()=>{z.current&&nt===q.current&&V.current===st&&(C(!1),K.current=null)});return K.current=k,k},[]),Nn=x.useCallback(async()=>{const st=V.current;if(!st)return;const nt=++q.current;++I.current;const At=$.current;C(!0),E(null);const k=At.then(()=>$g(st)).then(se=>{!z.current||nt!==q.current||V.current!==st||(ee.current=se.project,Z.current=se.project,c(se.project),f(se.project))}).catch(se=>{z.current&&nt===q.current&&V.current===st&&E(`Could not load project settings: ${_a(se)}`)}).finally(()=>{z.current&&nt===q.current&&V.current===st&&(C(!1),K.current=null)});return K.current=k,k},[]),gs=x.useCallback(async()=>{const st=++D.current,nt=V.current,At=nt?++q.current:q.current,k=W.current,se=I.current,ve=Y.current,ke=$.current;b(!0),nt&&C(!0),A(null),nt&&E(null);try{await Promise.all([ve,ke]);const le=await $g(nt??void 0);if(!z.current||st!==D.current)return;k===W.current&&(me.current=le.global,ie.current=le.global,s(le.global),a(le.global)),se===I.current&&nt===V.current&&At===q.current&&(ee.current=le.project,Z.current=le.project,c(le.project),f(le.project))}catch(le){const Le=nt===null||nt===V.current&&At===q.current;z.current&&st===D.current&&Le&&(nt?E(`Could not load project settings: ${_a(le)}`):A(_a(le)))}finally{z.current&&st===D.current&&(b(!1),nt===V.current&&C(!1))}},[]);x.useEffect(()=>(z.current=!0,G.current||(G.current=!0,gs()),Ne.current=window.setTimeout(()=>{Ue.current=!0},0),()=>{z.current=!1,pe(),Ne.current!==null&&(window.clearTimeout(Ne.current),Ne.current=null)}),[pe,gs]);const Us=x.useCallback(st=>{const nt=vm(st);return nt?(mu(nt),xe.current=nt,kC(nt),g(nt),Pe.current=nt.theme,jx(nt.theme),Me.current=nt.language,Iv(nt.language),!0):!1},[]);x.useEffect(()=>{kC(h),Pe.current=h.theme,jx(h.theme),Me.current=h.language,Iv(h.language)},[]),x.useEffect(()=>{if(Ue.current&&Pe.current!==null&&F!==Pe.current){const st={...h,theme:F};xe.current=st,mu(st),g(st),Pe.current=F}},[F,h]),x.useEffect(()=>{if(Ue.current&&M!==Me.current){const st={...h,language:M};xe.current=st,mu(st),g(st),Me.current=M}},[M,h]);const fn=x.useCallback(st=>{const nt=wY(xe.current,st);return nt?Us(nt):!1},[Us]),ni=x.useCallback(()=>{Us(kY())},[Us]),Hn=x.useCallback(async st=>{const nt=++W.current,At=CY(me.current,st);me.current=At,s(At),jt();const k=Y.current.then(()=>C9(st));Y.current=k.then(()=>{},()=>{});try{const se=await k;if(!z.current)return;ie.current=se,a(se),nt===W.current&&(me.current=se,s(se)),dt()}catch(se){if(!z.current)return;nt===W.current&&(me.current=ie.current,s(ie.current)),dt(`Could not save global settings: ${_a(se)}`)}},[jt,dt]),Pt=x.useCallback(async st=>{const nt=V.current;if(!nt){P("Select a project before changing project settings."),L("error");return}const At=++I.current,k=NY(ee.current,st);ee.current=k,c(k),jt();const se=$.current.then(()=>N9(nt,st));$.current=se.then(()=>{},()=>{});try{const ve=await se;if(!z.current)return;nt===V.current&&(Z.current=ve,f(ve),At===I.current&&(ee.current=ve,c(ve))),dt()}catch(ve){if(!z.current)return;nt===V.current&&At===I.current&&(ee.current=Z.current,c(Z.current)),dt(`Could not save project settings: ${_a(ve)}`)}},[jt,dt]),bs=x.useCallback(async()=>{const st=++W.current;jt();const nt=Y.current.then(E9);Y.current=nt.then(()=>{},()=>{});try{const At=await nt;if(!z.current)return;ie.current=At,a(At),st===W.current&&(me.current=At,s(At)),dt()}catch(At){if(!z.current)return;dt(`Could not reset global settings: ${_a(At)}`)}},[jt,dt]),rs=x.useCallback(async()=>{const st=V.current;if(!st){P("Select a project before resetting project settings."),L("error");return}const nt=++I.current;jt();const At=$.current.then(()=>j9(st));$.current=At.then(()=>{},()=>{});try{const k=await At;if(!z.current)return;st===V.current&&(Z.current=k,f(k),nt===I.current&&(ee.current=k,c(k))),dt()}catch(k){if(!z.current)return;dt(`Could not reset project settings: ${_a(k)}`)}},[jt,dt]);return n.jsx(AA.Provider,{value:{loading:p,loadError:N,retry:gs,activeProjectPath:v,projectLoading:S,projectLoadError:j,selectProject:Fs,retryProject:Nn,saveState:T,saveError:H,global:t,confirmedGlobal:i,project:l,confirmedProject:d,ui:h,updateGlobal:Hn,updateProject:Pt,updateUi:fn,resetGlobal:bs,resetProject:rs,resetUi:ni},children:e})}function xm(){const e=ym();if(!e)throw new Error("useSettings must be used within SettingsProvider");return e}function ym(){return x.useContext(AA)}const jY=[{page:"services",labelKey:"nav.services",icon:n.jsx(Zf,{})},{page:"docker",labelKey:"nav.docker",icon:n.jsx(Fx,{})},{page:"git",labelKey:"nav.git",icon:n.jsx(_n,{})},{page:"github",labelKey:"nav.github",icon:n.jsx(bm,{})},{page:"workflows",labelKey:"nav.workflows",icon:n.jsx(of,{})},{page:"errors",labelKey:"nav.errors",icon:n.jsx(Au,{})},{page:"database",labelKey:"nav.database",icon:n.jsx(si,{})},{page:"terminal",labelKey:"nav.terminal",icon:n.jsx(Br,{})},{page:"agent",labelKey:"nav.agent",icon:n.jsx(Ff,{})},{page:"agent-env",labelKey:"nav.agentEnv",icon:n.jsx(Tu,{})}];function AY(e,t){const s=Math.max(0,t-48),i=Math.min(180,s);return Math.max(i,Math.min(s,e))}function TY(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function RY({currentPage:e="services",git:t,onGitRefresh:s,onNavigate:i}){const a=J(),l=ym(),{activeTaskId:c,claimInitialInput:d,closeTask:f,draft:h,focusNonce:g,insertPrompt:p,onboarding:b,open:v,pendingTaskIds:_,provider:S,setActiveTaskId:C,setOpen:N,stopTask:A,tasks:j,terminalError:E,updateTaskStatus:T}=Ot(),[L,H]=x.useState(null),[P,F]=x.useState(!1),[M,z]=x.useState(!1),[G,D]=x.useState(null),[q,W]=x.useState(!1),I=x.useRef(null),Y=x.useRef(new Map),$=x.useRef(g),me=x.useRef(b),ee=j.find(pe=>pe.id===c)??null;x.useEffect(()=>{(h||b)&&C(Qi)},[]),x.useEffect(()=>{g!==$.current&&C(Qi),$.current=g},[g,C]),x.useEffect(()=>{b&&!me.current&&C(Qi),me.current=b},[b,C]),x.useEffect(()=>()=>I.current?.(),[]),x.useEffect(()=>{if(!M)return;const pe=Je=>{Je.key==="Escape"&&z(!1)};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[M]),x.useEffect(()=>{v||z(!1)},[v]);const V=()=>{z(!1),N(!1)},K=pe=>{i?.(pe),V()};function xe(pe){pe.preventDefault(),pe.currentTarget.setPointerCapture?.(pe.pointerId),F(!0);const Je=Fs=>H(AY(window.innerHeight-Fs.clientY,window.innerHeight)),jt=()=>{window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",dt),I.current=null},dt=()=>{F(!1),jt()};I.current?.(),I.current=jt,window.addEventListener("pointermove",Je),window.addEventListener("pointerup",dt)}const ie=ee?.provider??S?.id,Z=ee?.kind==="shell",ge=Z?Br:ie==="codex"?Oa:Ir,ne=Z?a("dock.shell"):ee?ee.provider==="codex"?"Codex":"Claude Code":S?.label??"Agent",we=c===Qi||j.length===0,Ne=we?!q:!Z,Ue=G&&G!==c&&j.some(pe=>pe.id===G)?G:null,Pe=UK(((we?S?.id:ee?.provider??S?.id)??"claude")==="codex"?"codex":"claude",v),Me=pe=>{if(!we&&ee?.state==="running"){const Je=Y.current.get(ee.id);if(Je){Je.input(pe),Je.focus();return}}p(pe)};return n.jsxs(n.Fragment,{children:[v?null:n.jsxs("button",{"aria-label":a("dock.openAria"),className:"fixed inset-x-0 bottom-0 z-50 flex h-9 w-full items-center gap-2 border-t border-border bg-card/95 px-3 text-left shadow-[0_-4px_18px_-14px_rgba(0,0,0,.45)] backdrop-blur",onClick:()=>N(!0),type:"button",children:[n.jsx(ge,{className:"size-3.5 text-primary"}),n.jsx("span",{className:"text-xs font-medium",children:ne}),n.jsx("span",{className:"h-3 w-px bg-border"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",children:ee?.label??a("dock.newTask")}),n.jsx(SC,{git:t,provider:ie,variant:"strip"}),ee?n.jsxs("span",{className:re("font-mono text-[10px] text-muted-foreground",ee.state==="running"&&"text-emerald-600",ee.state==="error"&&"text-destructive"),children:[n.jsx("span",{className:"sr-only",children:a("dock.activeStatusSr")}),TY(ee.state)]}):null,j.length>1?n.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:j.length}):null,n.jsx(qf,{className:"size-3.5 text-muted-foreground"})]}),n.jsxs("div",{"aria-hidden":!v||void 0,className:re("fixed inset-x-0 bottom-0 z-50 flex flex-col overflow-hidden border-t border-border bg-card shadow-[0_-12px_30px_-20px_rgba(0,0,0,.5)]",!M&&(P||"transition-[height] duration-150"),!v&&"invisible pointer-events-none border-transparent shadow-none"),inert:!v||void 0,style:M?{height:"auto",top:Ls()?32:0}:{height:v?L??"50vh":0},children:[M?n.jsx("nav",{"aria-label":a("dock.fullscreenNavAria"),className:"flex h-11 shrink-0 items-center gap-1 overflow-x-auto border-b border-border bg-background px-2",children:jY.map(pe=>n.jsxs("button",{"aria-current":e===pe.page?"page":void 0,"aria-label":a(pe.labelKey),className:re("flex h-8 shrink-0 items-center gap-2 rounded-md px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4",e===pe.page&&"bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground"),onClick:()=>K(pe.page),type:"button",children:[pe.icon,n.jsx("span",{children:a(pe.labelKey)})]},pe.page))}):null,n.jsx("div",{"aria-hidden":!0,className:re("absolute inset-x-0 -top-1 z-20 h-2 cursor-ns-resize",M&&"hidden"),"data-agent-resize-grip":!0,onDoubleClick:()=>H(null),onPointerDown:xe}),n.jsxs("div",{className:"flex h-9 shrink-0 items-stretch border-b border-border bg-muted/25",children:[n.jsx(oY,{activeTaskId:c,composing:we,onActivate:C,onClose:pe=>{f(pe)},onSplit:pe=>D(Je=>Je===pe?null:pe),pendingTaskIds:_,splitTaskId:Ue,tasks:j}),Ne?n.jsx(PK,{capabilities:Pe,onInsert:Me,onNavigate:i?K:void 0,providerLabel:ne}):n.jsx("span",{className:"flex-1"}),n.jsx(SC,{git:t,provider:ie,variant:"dock"}),n.jsxs("div",{className:"flex shrink-0 items-center border-l border-border px-1",children:[n.jsx("button",{"aria-label":a("dock.newTask"),className:"grid size-7 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>C(Qi),type:"button",children:n.jsx(ms,{className:"size-3.5"})}),ee?.state==="running"?n.jsx("button",{"aria-label":a("dock.stopTaskAria",{label:ee.label??a("dock.newTask")}),className:"grid size-7 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-35",disabled:_.has(ee.id),onClick:()=>{A(ee.id)},type:"button",children:n.jsx(Ta,{className:"size-3"})}):null,n.jsx("button",{"aria-label":a(M?"dock.restoreDock":"dock.enterFullScreen"),className:"grid size-7 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>z(pe=>!pe),type:"button",children:M?n.jsx(Yx,{className:"size-3.5"}):n.jsx(Kx,{className:"size-3.5"})}),n.jsx("button",{"aria-label":a("dock.collapseAria"),className:"grid size-7 place-items-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",onClick:V,type:"button",children:n.jsx(hn,{className:"size-3.5"})})]})]}),E?n.jsx("div",{role:"alert",className:"border-b border-destructive/30 bg-destructive/5 px-3 py-1 font-mono text-[11px] text-destructive",children:E}):null,t&&we?n.jsx("div",{className:"shrink-0 px-3 pt-2",children:n.jsx(uG,{git:t,onRefresh:s})}):null,n.jsxs("div",{className:"relative min-h-0 flex-1 bg-[#101214]",children:[j.map(pe=>{const Je=v&&(pe.id===c||pe.id===Ue),jt=Ue?pe.id===Ue?"left-1/2 right-0 border-l border-border":"left-0 right-1/2":"inset-x-0";return n.jsx("div",{"aria-labelledby":`agent-tab-${pe.id}`,className:re("absolute inset-y-0",jt,!Je&&"invisible pointer-events-none"),id:`agent-panel-${pe.id}`,role:"tabpanel",children:n.jsx(vA,{active:Je,claimInitialInput:()=>d(pe.id),displaySettings:l?.confirmedGlobal.terminal,onStatusChange:dt=>T(pe.id,{state:dt.state==="connecting"?"idle":dt.state,cwd:dt.cwd,error:dt.state==="error"?dt.detail:void 0}),ref:dt=>{dt?Y.current.set(pe.id,dt):Y.current.delete(pe.id)},sessionId:pe.id})},pe.id)}),v&&we?n.jsx("div",{"aria-labelledby":`agent-tab-${Qi}`,className:re("absolute inset-y-0 bg-background",Ue?"left-0 right-1/2":"inset-x-0"),id:`agent-panel-${Qi}`,role:"tabpanel",children:n.jsx(rY,{capabilities:q?void 0:Pe,onNavigate:i?K:void 0,onShellMode:W,shellMode:q})}):null]})]})]})}function wl(e,t){const s=`nomoreide:${e}`,[i,a]=x.useState(()=>{try{const c=window.localStorage.getItem(s);return c===null?t:JSON.parse(c)}catch{return t}}),l=x.useCallback(c=>{a(c);try{window.localStorage.setItem(s,JSON.stringify(c))}catch{}},[s]);return[i,l]}function _m(e,t){if(!e)return!1;const s=t.endsWith("/")?t.slice(0,-1):t;return e===s||e.startsWith(`${s}/`)}function MY(e,t){return!t||!e?!0:_m(e,t)}function DY(e,t){const s=e.config.services.filter(d=>_m(d.cwd,t.path)),i=new Set(s.map(d=>d.name)),a=e.config.bundles.map(d=>({...d,services:d.services.filter(f=>i.has(f))})).filter(d=>d.services.length>0),l=Object.fromEntries(Object.entries(e.runtime.services).filter(([d])=>i.has(d))),c=Object.fromEntries(Object.entries(e.health).filter(([d])=>i.has(d)));return{...e,config:{...e.config,services:s,bundles:a},runtime:{services:l},health:c,ports:e.ports.filter(d=>d.services.some(f=>i.has(f))),logs:e.logs.filter(d=>i.has(d.service)),timeline:e.timeline.filter(d=>!d.service||i.has(d.service))}}const kb={host:"",port:"",user:"",password:"",database:"",ssl:!1},LY="localhost";function Ax(e,t,{includePassword:s=!0}={}){const i=e==="mysql"?"mysql":"postgres",a=t.host.trim()||LY,l=t.port.trim(),c=t.database.trim().replace(/^\//,""),d=t.user.trim(),f=s&&t.password,h=d?`${encodeURIComponent(d)}${f?`:${encodeURIComponent(t.password)}`:""}@`:"",g=l?`:${l}`:"",p=e==="postgres"&&t.ssl?"?sslmode=require":"";return`${i}://${h}${a}${g}/${c}${p}`}function Tx(e){if(!e.trim())return null;let t;try{t=new URL(e.trim())}catch{return null}return{host:t.hostname,port:t.port,user:NC(t.username),password:NC(t.password),database:t.pathname.replace(/^\//,""),ssl:t.searchParams.get("sslmode")==="require"||t.searchParams.has("ssl")}}function OY(e){const t=/^([a-z0-9+]+):\/\//i.exec(e.trim());if(!t)return null;const s=t[1].toLowerCase();return s.startsWith("postgres")?"postgres":s.startsWith("mysql")?"mysql":s.startsWith("sqlite")||s==="file"?"sqlite":null}function NC(e){try{return decodeURIComponent(e)}catch{return e}}const PY=[{value:"postgres",label:"Postgres"},{value:"mysql",label:"MySQL"},{value:"sqlite",label:"SQLite"}];function zY({onClose:e,onSaved:t,initial:s,projects:i=[]}){const a=J(),{isPending:l,runOperation:c}=In(),{error:d,success:f}=cs(),h=!!s,g=x.useMemo(()=>BY(s),[s]),[p,b]=x.useState(g.engine),[v,_]=x.useState(g.name),[S,C]=x.useState(g.url),[N,A]=x.useState(g.fields),[j,E]=x.useState([]),[T,L]=x.useState(s?.projectPath??""),[H,P]=x.useState({status:"idle"}),[F,M]=x.useState(!1),z=`database:${s?.name??"new"}:save`,G=l(z);x.useEffect(()=>{h||t7().then(E).catch(()=>E([]))},[h]);const D=p==="sqlite",q=D?S.trim():Ax(p,N),W=D?!!S.trim():!!(N.host.trim()&&N.database.trim());function I(){P({status:"idle"})}function Y(Z,ge){return Ax(Z,ge,{includePassword:!1})}function $(Z){b(Z),I(),Z!=="sqlite"&&C(Y(Z,N))}function me(Z){const ge={...N,...Z};A(ge),C(Y(p,ge)),I()}function ee(Z){I();const ge=OY(Z),ne=ge??p;ge&&ge!==p&&b(ge);const we=ge==="sqlite"?null:Tx(Z);if(!we){C(Z);return}we.password?(A(we),C(Y(ne,we))):(A({...we,password:N.password}),C(Z))}function V(Z){b(Z.engine);const ge=Z.engine==="sqlite"?null:Tx(Z.url);ge?(A(ge),C(Y(Z.engine,ge))):C(Z.url),I(),v.trim()||_(IY(Z));const ne=Z.cwd?i.find(we=>_m(Z.cwd,we.path)):void 0;ne&&L(ne.path)}function K(){return v.trim()?D?S.trim()?null:a("database.dialog.errFilePathRequired"):N.host.trim()?N.database.trim()?null:a("database.dialog.errDatabaseRequired"):a("database.dialog.errHostRequired"):a("database.dialog.errNameRequired")}async function xe(){if(W){M(!0),I();try{const Z=await n7({engine:p,url:q});P(Z.ok?{status:"ok",message:a("database.dialog.connected")}:{status:"fail",message:Z.error??a("database.dialog.connectionFailed")})}catch(Z){P({status:"fail",message:Z instanceof Error?Z.message:String(Z)})}finally{M(!1)}}}async function ie(){const Z=K();if(Z){d(Z);return}try{await c({key:z,label:a("database.dialog.savingConnection",{name:v.trim()})},()=>s7({name:v.trim(),engine:p,url:q,projectPath:T})),f(a("database.dialog.savedToast",{name:v.trim()})),t(),e()}catch(ge){d(ge instanceof Error?ge.message:String(ge))}}return n.jsx(zn,{icon:n.jsx(si,{}),onClose:e,title:a(h?"database.dialog.editTitle":"database.dialog.addTitle"),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[j.length>0?n.jsxs("section",{children:[n.jsxs("p",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[n.jsx(T8,{className:"size-3.5"}),a("database.dialog.foundInServices")]}),n.jsx("div",{className:"flex flex-wrap gap-1.5",children:j.map(Z=>n.jsxs("button",{type:"button",onClick:()=>V(Z),className:"group flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-left text-xs transition-colors hover:border-primary hover:bg-muted",title:Z.maskedUrl,children:[n.jsx(We,{variant:"outline",size:"small",children:Z.engine}),n.jsx("span",{className:"font-mono",children:Z.service}),n.jsxs("span",{className:"font-mono text-muted-foreground",children:["·",Z.key]})]},`${Z.service}:${Z.key}`))})]}):null,n.jsxs("section",{children:[n.jsx("p",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:a("database.dialog.engine")}),n.jsx("div",{className:"flex gap-1.5",children:PY.map(Z=>n.jsx(Q,{size:"sm",variant:p===Z.value?"default":"outline",onClick:()=>$(Z.value),disabled:h,type:"button",children:Z.label},Z.value))})]}),n.jsxs("label",{className:"flex flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.name")}),n.jsx(pt,{value:v,onChange:Z=>_(Z.target.value),placeholder:a("database.dialog.namePlaceholder"),disabled:h}),h?n.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("database.dialog.nameLocked")}):null]}),i.length>0?n.jsxs("label",{className:"flex flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Project"}),n.jsxs("select",{className:"h-9 rounded-md border border-border bg-background px-2 text-sm",onChange:Z=>L(Z.target.value),value:T,children:[n.jsx("option",{value:"",children:"No project (shared)"}),T&&!i.some(Z=>Z.path===T)?n.jsx("option",{value:T,children:T}):null,i.map(Z=>n.jsx("option",{value:Z.path,children:Z.name},Z.path))]}),n.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Classifies the connection under a project; shared connections show in every project scope."})]}):null,D?null:n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex gap-3",children:[n.jsxs("label",{className:"flex flex-1 flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.host")}),n.jsx(pt,{value:N.host,onChange:Z=>me({host:Z.target.value}),placeholder:"localhost",className:"font-mono text-xs"})]}),n.jsxs("label",{className:"flex w-24 flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.port")}),n.jsx(pt,{value:N.port,onChange:Z=>me({port:Z.target.value}),placeholder:p==="mysql"?"3306":"5432",className:"font-mono text-xs"})]})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsxs("label",{className:"flex flex-1 flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.user")}),n.jsx(pt,{value:N.user,onChange:Z=>me({user:Z.target.value}),placeholder:"postgres",className:"font-mono text-xs"})]}),n.jsxs("label",{className:"flex flex-1 flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.password")}),n.jsx(pt,{type:"password",value:N.password,onChange:Z=>me({password:Z.target.value}),placeholder:h?a("database.dialog.passwordKeep"):"••••••••",className:"font-mono text-xs"})]})]}),n.jsxs("label",{className:"flex flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a("database.dialog.database")}),n.jsx(pt,{value:N.database,onChange:Z=>me({database:Z.target.value}),placeholder:"app",className:"font-mono text-xs"})]}),p==="postgres"?n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("input",{type:"checkbox",checked:N.ssl,onChange:Z=>me({ssl:Z.target.checked}),className:"size-3.5 accent-primary"}),a("database.dialog.requireSslPre")," ",n.jsx("span",{className:"font-mono",children:"?sslmode=require"}),a("database.dialog.requireSslPost")]}):null]}),n.jsxs("label",{className:"flex flex-col gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:a(D?"database.dialog.filePath":"database.dialog.connectionUrl")}),n.jsx(pt,{value:S,onChange:Z=>ee(Z.target.value),placeholder:D?"/abs/path/to/app.db":p==="mysql"?"mysql://user:pass@host:3306/db":"postgres://user:pass@host:5432/db",className:"font-mono text-xs"}),n.jsx("span",{className:"text-[11px] text-muted-foreground",children:a(D?"database.dialog.sqliteHint":"database.dialog.urlHint")})]}),H.status!=="idle"?n.jsxs("div",{className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs ${H.status==="ok"?"border-emerald-500/40 text-emerald-600 dark:text-emerald-400":"border-destructive/40 text-destructive"}`,children:[H.status==="ok"?n.jsx(Ys,{className:"size-3.5"}):n.jsx(Vt,{className:"size-3.5"}),n.jsx("span",{className:"break-all font-mono",children:H.message})]}):null,n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border pt-3",children:[n.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>{xe()},disabled:F||!W,type:"button",children:[F?n.jsx(Mt,{className:"animate-spin"}):null,a("database.dialog.testConnection")]}),n.jsx(Q,{size:"sm",onClick:()=>{ie()},loading:G,loadingLabel:a("common.saving"),type:"button",children:a(h?"database.dialog.saveChanges":"common.save")})]})]})})}function BY(e){if(!e)return{engine:"postgres",name:"",fields:kb,url:""};if(e.engine==="sqlite")return{engine:"sqlite",name:e.name,fields:kb,url:e.url};const t=Tx(e.url),s=t?{...t,password:""}:kb;return{engine:e.engine,name:e.name,fields:s,url:Ax(e.engine,s,{includePassword:!1})}}function IY(e){try{const s=new URL(e.url).pathname.replace(/^\//,"");if(s)return`${e.service}-${s}`}catch{}return`${e.service}-${e.engine}`}function HY({connections:e,projectLabel:t,selected:s,onSelect:i,onAdd:a,onEdit:l,onRemove:c}){const d=J(),[f,h]=x.useState(!1),g=x.useRef(null),p=e.find(b=>b.name===s);return x.useEffect(()=>{if(!f)return;function b(v){g.current&&v.target instanceof Node&&!g.current.contains(v.target)&&h(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[f]),n.jsxs("div",{className:"relative z-50 flex items-center gap-2",ref:g,children:[n.jsxs(Q,{className:"max-w-[240px] justify-start gap-2 rounded-md border-border bg-card",onClick:()=>h(b=>!b),size:"sm",type:"button",variant:"outline",children:[n.jsx(si,{className:"text-muted-foreground"}),n.jsx("span",{className:"truncate",children:p?.name??d("database.selectConnection")}),p?n.jsx(We,{variant:"outline",size:"small",children:p.engine}):null,n.jsx(hn,{className:re("ml-auto transition-transform",f&&"rotate-180")})]}),f?n.jsxs("div",{className:"absolute right-0 top-10 z-50 w-[min(420px,calc(100vw-2rem))] overflow-hidden rounded-lg border border-border bg-card shadow-lg",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx(si,{className:"size-3.5 text-muted-foreground"}),n.jsx("div",{className:"text-xs font-semibold",children:d("database.connections")}),n.jsx(We,{className:"ml-auto",variant:"outline",size:"small",children:e.length})]}),n.jsx("div",{className:"max-h-72 overflow-auto",children:e.length?n.jsx("div",{className:"divide-y divide-border",children:e.map(b=>{const v=b.name===s;return n.jsxs("div",{className:re("group grid w-full grid-cols-[1fr_auto_auto_auto] items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-muted",v&&"bg-muted/70"),children:[n.jsxs("button",{className:"min-w-0 text-left",onClick:()=>{i(b.name),h(!1)},type:"button",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-sm font-medium leading-tight",children:b.name}),t?n.jsx(We,{className:"shrink-0",size:"small",variant:"outline",children:t(b)??"unassigned"}):null]}),n.jsx("span",{className:"block truncate font-mono text-[10px] leading-tight text-muted-foreground",children:b.url})]}),v?n.jsx(Ys,{className:"size-3.5"}):n.jsx("span",{className:"size-3.5"}),n.jsx(Q,{"aria-label":d("database.editConn",{name:b.name}),className:"size-6 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>{l(b),h(!1)},size:"icon",title:d("database.editConn",{name:b.name}),type:"button",variant:"ghost",children:n.jsx(Nl,{className:"size-3.5"})}),n.jsx(Q,{"aria-label":d("database.removeConn",{name:b.name}),className:"size-6 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>c(b.name),size:"icon",title:d("database.removeConn",{name:b.name}),type:"button",variant:"ghost",children:n.jsx(Ii,{className:"size-3.5 text-destructive"})})]},b.name)})}):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:d("database.noSavedConnections")})}),n.jsx("div",{className:"border-t border-border bg-muted/20 p-2",children:n.jsxs(Q,{className:"w-full",onClick:()=>{a(),h(!1)},size:"sm",type:"button",children:[n.jsx(ms,{className:"size-3"}),d("database.addConnection")]})})]}):null]})}function $Y({onAddManual:e,onAddWithAi:t}){const s=J(),[i,a]=x.useState(!1),l=x.useRef(null);x.useEffect(()=>{if(!i)return;function d(f){l.current&&f.target instanceof Node&&!l.current.contains(f.target)&&a(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[i]);function c(d){a(!1),d()}return n.jsxs("div",{className:"relative",ref:l,children:[n.jsxs(Q,{"aria-label":s("database.addMenuAria"),onClick:()=>a(d=>!d),size:"sm",type:"button",children:[n.jsx(ms,{className:"size-3.5"}),s("common.add")]}),i?n.jsxs("div",{className:"absolute right-0 top-9 z-50 w-56 overflow-hidden rounded-lg border border-border bg-card shadow-lg",children:[n.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",onClick:()=>c(e),type:"button",children:[n.jsx(si,{className:"size-3.5 text-muted-foreground"}),s("database.addConnection")]}),n.jsxs("button",{className:"flex w-full items-center gap-2 border-t border-border px-3 py-2 text-left text-sm transition-colors hover:bg-muted",onClick:()=>c(t),type:"button",children:[n.jsx(Bn,{className:"size-3.5 text-muted-foreground"}),s("database.addWithAi")]})]}):null]})}function FY(){const[e,t]=x.useState([]),[s,i]=x.useState(!0),[a,l]=x.useState(null),c=x.useCallback(async()=>{i(!0),l(null);try{t(await zE())}catch(d){l(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);return x.useEffect(()=>{c()},[c]),{connections:e,loading:s,error:a,refresh:c}}const UY=[50,100,500,1e3];function TA(e){return[...new Set([...UY,e])].sort((t,s)=>t-s)}function qY(e){const[t,s]=x.useState(null),[i,a]=x.useState(null),[l,c]=x.useState(!1);x.useEffect(()=>{s(null),a(null)},[e]);const d=x.useCallback(async(h,g)=>{if(!(!e||!h.trim())){c(!0),a(null);try{s(await r7(e,h,g))}catch(p){s(null),a(p instanceof Error?p.message:String(p))}finally{c(!1)}}},[e]),f=x.useCallback(()=>{s(null),a(null)},[]);return{result:t,error:i,running:l,run:d,reset:f}}const GY=["select","show","explain","pragma","describe","desc"];function VY(e){const t=/^\s*([a-z]+)/i.exec(e)?.[1]?.toLowerCase()??"";return GY.includes(t)}function WY(e){const[t,s]=x.useState(null),[i,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState(!1),[h,g]=x.useState(!1);x.useEffect(()=>{s(null),a(null),c(null)},[e]);const p=x.useCallback(async S=>{if(!(!e||!S.trim())){f(!0),c(null),a(null);try{const C=await hS(e,S,"preview");s({sql:S,preview:C})}catch(C){c(C instanceof Error?C.message:String(C))}finally{f(!1)}}},[e]),b=x.useCallback(async S=>{const C=S??t?.sql;if(!e||!C)return null;g(!0),c(null);try{const N=await hS(e,C,"commit");return a(N),s(null),N}catch(N){return s(null),c(N instanceof Error?N.message:String(N)),null}finally{g(!1)}},[e,t]),v=x.useCallback(()=>s(null),[]),_=x.useCallback(()=>{s(null),a(null),c(null)},[]);return{pending:t,committed:i,error:l,previewing:d,committing:h,preview:p,commit:b,cancel:v,reset:_}}function KY(e,t){const[s,i]=x.useState(!1),a=x.useCallback(async l=>{if(e){i(!0);try{await a7(e,l),t()}finally{i(!1)}}},[e,t]);return{updating:s,setUnlocked:a}}function YY(e,t=100){const[s,i]=x.useState([]),[a,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState(!1),[_,S]=x.useState(!1),[C,N]=x.useState(()=>t),A=x.useRef(!1),[j,E]=x.useState(0);x.useEffect(()=>{A.current||N(t)},[t]),x.useEffect(()=>{E(0)},[e,a]),x.useEffect(()=>{if(i([]),l(null),d(null),h(null),p(null),!e)return;let M=!1;return v(!0),BE(e).then(z=>{M||(i(z),l(z[0]?.qualifiedName??null))}).catch(z=>{M||h(z instanceof Error?z.message:String(z))}).finally(()=>{M||v(!1)}),()=>{M=!0}},[e]),x.useEffect(()=>{if(d(null),p(null),!e||!a)return;let M=!1;return S(!0),o7(e,a,C,j).then(z=>{M||d(z)}).catch(z=>{M||p(z instanceof Error?z.message:String(z))}).finally(()=>{M||S(!1)}),()=>{M=!0}},[e,a,C,j]);const T=j>0,L=c?c.rowCount===C:!1;function H(M){A.current=!0,N(M),E(0)}function P(){L&&E(M=>M+C)}function F(){E(M=>Math.max(0,M-C))}return{tables:s,selectedTable:a,setSelectedTable:l,sample:c,tablesError:f,rowsError:g,loadingTables:b,loadingRows:_,limit:C,offset:j,canPrev:T,canNext:L,changePageSize:H,nextPage:P,prevPage:F}}function XY(e,t,s,i){const a=J(),{provider:l}=Ot(),[c,d]=x.useState(!1),[f,h]=x.useState(null),g=x.useRef(null),p=x.useRef(!0);return x.useEffect(()=>(p.current=!0,()=>{p.current=!1,g.current?.abort()}),[]),{generate:x.useCallback(async v=>{if(!e||!v.trim()||c)return;d(!0),h(null);const _=new AbortController;g.current=_;try{let S=[];try{S=await BE(e)}catch{S=[]}if(!p.current||_.signal.aborted)return;const C=await B0({prompt:UF(e,v,{engine:t,tables:S,unlocked:s}),provider:l?.id,signal:_.signal});if(!p.current)return;const N=ZY(C);N?i(N):h(a("database.sql.noSqlBlock"))}catch(S){p.current&&!_.signal.aborted&&h(S instanceof Error?S.message:String(S))}finally{g.current===_&&(g.current=null),p.current&&d(!1)}},[e,t,s,c,i,l?.id,a]),generating:c,error:f}}function ZY(e){if(!e)return null;const s=/```(?:sql)?\s*\n?([\s\S]*?)```/i.exec(e)?.[1]?.trim();return s||null}function QY({connection:e,sample:t}){const s=J(),{sendToAgent:i}=Ot(),{success:a,error:l}=cs(),c=t.columns.map(p=>p.name);function d(p){i({prompt:FF(e,t.engine,t.table,t.columns,p),source:{type:"database-row",label:s("database.grid.rowSource",{table:t.table.name})},mode:"draft"})}async function f(p,b){try{await navigator.clipboard.writeText(p),a(s("database.grid.copiedWhat",{what:b}))}catch(v){l(v instanceof Error?v.message:String(v))}}function h(p){const b=v=>{const _=pu(v);return/[",\n]/.test(_)?`"${_.replace(/"/g,'""')}"`:_};return`${c.join(",")}
|
|
118
|
-
${c.map(v=>b(p[v])).join(",")}`}function g(p){const b=_=>_==null?"NULL":typeof _=="number"||typeof _=="boolean"?String(_):`'${(typeof _=="object"?JSON.stringify(_):String(_)).replace(/'/g,"''")}'`,v=c.map(_=>b(p[_])).join(", ");return`INSERT INTO ${t.table} (${c.join(", ")}) VALUES (${v});`}return t.columns.length===0?n.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:s("database.grid.noColumnsTable")}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"code-font-size w-max min-w-full border-collapse text-left font-mono",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-card",children:n.jsxs("tr",{className:"border-b border-border",children:[t.columns.map(p=>n.jsxs("th",{className:"whitespace-nowrap px-3 py-2 font-semibold text-foreground",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[p.primaryKey?n.jsx(xE,{className:"size-3 text-amber-500"}):null,p.name]}),n.jsx("span",{className:"block font-normal text-muted-foreground",children:p.dataType})]},p.name)),n.jsx("th",{className:"sticky right-0 z-20 w-16 border-l border-border bg-card px-2 py-2"})]})}),n.jsxs("tbody",{children:[t.rows.map((p,b)=>n.jsxs("tr",{className:"group border-b border-border/60 hover:bg-muted/40",children:[t.columns.map(v=>n.jsx("td",{className:"max-w-[320px] truncate px-3 py-1 align-top text-muted-foreground",title:pu(p[v.name]),children:pu(p[v.name])},v.name)),n.jsx("td",{className:"sticky right-0 z-[1] border-l border-border/60 bg-card px-2 py-1 align-top before:pointer-events-none before:absolute before:inset-0 before:bg-muted/40 before:opacity-0 group-hover:before:opacity-100",children:n.jsxs("div",{className:"relative z-[1] flex items-center justify-end gap-0.5",children:[n.jsx(rr,{label:s("database.grid.askAiRow"),onAsk:()=>d(p)}),n.jsx(Ll,{label:s("database.grid.rowActions"),items:[{label:s("database.grid.copyJson"),icon:n.jsx(xM,{className:"size-3.5"}),onSelect:()=>{f(JSON.stringify(p,null,2),s("database.grid.rowAsJson"))}},{label:s("database.grid.copyCsv"),icon:n.jsx(f6,{className:"size-3.5"}),onSelect:()=>{f(h(p),s("database.grid.rowAsCsv"))}},{label:s("database.grid.copySqlInsert"),icon:n.jsx(si,{className:"size-3.5"}),onSelect:()=>{f(g(p),s("database.grid.insertStatement"))}}]})]})})]},b)),t.rows.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:t.columns.length+1,className:"px-3 py-6 text-center text-muted-foreground",children:s("database.grid.noRows")})}):null]})]})})}function pu(e){return e==null?"NULL":typeof e=="object"?JSON.stringify(e):String(e)}function JY({connection:e,busy:t,onConfirm:s,onClose:i}){const a=J();return n.jsx(zn,{icon:n.jsx(o8,{className:"text-amber-500"}),onClose:i,title:a("database.write.unlockTitle",{connection:e}),children:n.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[n.jsx("p",{className:"text-muted-foreground",children:a("database.write.unlockBody1")}),n.jsx("p",{className:"text-muted-foreground",children:a("database.write.unlockBody2")}),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border pt-3",children:[n.jsx(Q,{variant:"outline",size:"sm",onClick:i,type:"button",children:a("common.cancel")}),n.jsxs(Q,{size:"sm",onClick:s,disabled:t,type:"button",children:[t?n.jsx(Mt,{className:"animate-spin"}):n.jsx(yE,{}),a("database.write.unlockWrites")]})]})]})})}function eX({sql:e,preview:t,busy:s,onConfirm:i,onClose:a}){const l=J();return n.jsx(zn,{icon:n.jsx(zr,{className:"text-amber-500"}),onClose:a,title:l("database.write.confirmTitle"),children:n.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[n.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap",children:e}),t.previewUnavailable?n.jsx("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[13px] text-amber-700 dark:text-amber-300",children:l("database.write.previewUnavailable")}):n.jsxs("p",{className:"text-muted-foreground",children:[l("database.write.willAffectPre")," ",n.jsx("strong",{className:"text-foreground tabular-nums",children:t.affectedRows??0})," ",l("database.write.willAffectPost")]}),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border pt-3",children:[n.jsx(Q,{variant:"outline",size:"sm",onClick:a,type:"button",children:l("common.cancel")}),n.jsxs(Q,{size:"sm",className:"bg-amber-600 text-white hover:bg-amber-600/90",onClick:i,disabled:s,type:"button",children:[s?n.jsx(Mt,{className:"animate-spin"}):null,l("database.write.runCommit")]})]})]})})}function tX({connection:e,engine:t,unlocked:s,seed:i,onWriteAccessChange:a,preferences:l={confirmWrites:!0,resultLimit:100}}){const c=J(),{isPending:d,runOperation:f}=In(),{success:h}=cs(),{sendToAgent:g}=Ot(),p=qY(e),b=WY(e),v=KY(e,a),[_,S]=x.useState(i?.sql??""),[C,N]=x.useState(()=>l.resultLimit),A=x.useRef(!1);x.useEffect(()=>{A.current||N(l.resultLimit)},[l.resultLimit]);const j=i?.nonce;x.useEffect(()=>{i&&S(i.sql)},[j]);const[E,T]=x.useState(!1),L=XY(e,t,s,S),H=_.trim().length>0&&!VY(_),P=s&&H,F=H&&!s,M=p.running||b.previewing||b.committing,z=`database:${e}:write`,G=d(z);function D(){if(_.trim()){if(F){T(!0);return}P?(p.reset(),l.confirmWrites?b.preview(_):I(_)):(b.reset(),p.run(_,C))}}function q(Y){(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"&&(Y.preventDefault(),D())}function W(Y){g({prompt:qF(e,t,_,Y),source:{type:"database-sql-debug",label:"Debug SQL"},label:c("database.sql.debugLabel")})}async function I(Y){const $=await f({key:z,label:c("database.sql.committingWrite",{connection:e})},()=>b.commit(Y));if($?.committed){const me=$.affectedRows??0;h(c("database.sql.committed",{count:me}))}}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b border-border p-2",children:[n.jsx(sX,{generate:L}),n.jsx("textarea",{value:_,onChange:Y=>S(Y.target.value),onKeyDown:q,spellCheck:!1,placeholder:c(s?"database.sql.placeholderUnlocked":"database.sql.placeholderLocked"),className:"code-font-size h-24 w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono outline-none focus:border-ring"}),n.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[n.jsx(nX,{unlocked:s,updating:v.updating,onUnlock:()=>T(!0),onLock:()=>{v.setUnlocked(!1)}}),n.jsxs("div",{className:"flex items-center gap-2",children:[P?null:n.jsx("select",{"aria-label":c("database.sql.maxRows"),className:"rounded-md border border-border bg-background px-1.5 py-1 text-[11px]",value:C,onChange:Y=>{A.current=!0,N(Number(Y.target.value))},children:TA(l.resultLimit).map(Y=>n.jsx("option",{value:Y,children:c("database.sql.rowsOption",{size:Y})},Y))}),n.jsxs(Q,{size:"sm",className:re("h-7 px-3",P&&"bg-amber-600 text-white hover:bg-amber-600/90"),onClick:D,disabled:M||!_.trim(),loading:P&&G,loadingLabel:c("database.sql.runWrite"),type:"button",children:[M?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(or,{className:"size-3.5"}),P?l.confirmWrites?c("database.sql.previewWrite"):c("database.sql.runWrite"):c("database.sql.run")]})]})]})]}),n.jsx(iX,{read:p,write:b,onDebug:W}),E?n.jsx(JY,{connection:e,busy:v.updating,onConfirm:async()=>{await v.setUnlocked(!0),T(!1)},onClose:()=>T(!1)}):null,b.pending?n.jsx(eX,{sql:b.pending.sql,preview:b.pending.preview,busy:b.committing,onConfirm:()=>{I()},onClose:b.cancel}):null]})}function sX({generate:e}){const t=J(),[s,i]=x.useState("");function a(){const c=s.trim();!c||e.generating||e.generate(c)}function l(c){c.key==="Enter"&&(c.preventDefault(),a())}return n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(Xt,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2"}),n.jsx("input",{value:s,onChange:c=>i(c.target.value),onKeyDown:l,disabled:e.generating,placeholder:t("database.sql.generatePlaceholder"),className:"h-8 w-full rounded-md border border-border bg-background pl-7 pr-2 text-[12px] outline-none focus:border-ring disabled:opacity-60"})]}),n.jsxs(Q,{size:"sm",variant:"outline",className:"h-8 px-3",onClick:a,disabled:e.generating||!s.trim(),type:"button",children:[e.generating?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Xt,{className:"size-3.5"}),e.generating?t("database.sql.generating"):t("database.sql.askAi")]})]}),e.error?n.jsx("p",{className:"mt-1 text-[11px] text-amber-600 dark:text-amber-400",children:e.error}):null]})}function nX({unlocked:e,updating:t,onUnlock:s,onLock:i}){const a=J();return n.jsxs("button",{type:"button",onClick:e?i:s,disabled:t,className:re("flex items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] font-medium transition-colors",e?"border-amber-500/50 text-amber-600 hover:bg-amber-500/10 dark:text-amber-400":"border-border text-muted-foreground hover:text-foreground"),title:a(e?"database.sql.writesUnlockedTitle":"database.sql.readOnlyTitle"),children:[t?n.jsx(Mt,{className:"size-3.5 animate-spin"}):e?n.jsx(yE,{className:"size-3.5"}):n.jsx(uD,{className:"size-3.5"}),a(e?"database.sql.writesUnlocked":"database.sql.readOnly")]})}function iX({read:e,write:t,onDebug:s}){const i=J(),a=t.error??e.error;return n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:a?n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsx("p",{className:"code-font-size whitespace-pre-wrap font-mono text-destructive",children:a}),n.jsxs(Q,{size:"sm",variant:"outline",className:"h-7 px-3",onClick:()=>s(a),type:"button",children:[n.jsx(Xt,{className:"size-3.5"}),i("database.sql.debugWithAi")]})]}):t.committed?n.jsx(rX,{outcome:t.committed}):e.result?n.jsx(RA,{columns:e.result.columns,rows:e.result.rows,truncated:e.result.truncated}):n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:i("database.sql.emptyResult")})})}function rX({outcome:e}){const t=J();if(!e)return null;const s=e.affectedRows??0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-b border-border bg-emerald-500/10 px-3 py-1.5 text-[12px] text-emerald-700 dark:text-emerald-400",children:[n.jsx(Ys,{className:"size-3.5"}),t("database.sql.committed",{count:s})]}),e.rows&&e.rows.length>0&&e.columns?n.jsx(RA,{columns:e.columns,rows:e.rows}):null]})}function RA({columns:e,rows:t,truncated:s=!1}){const i=J();return e.length===0?n.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:i("database.sql.noColumns")}):n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s?n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-b border-border bg-amber-500/10 px-3 py-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[n.jsx(zr,{className:"size-3.5"}),i("database.sql.truncated",{count:t.length})]}):null,n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"code-font-size w-max min-w-full border-collapse text-left font-mono",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-card",children:n.jsx("tr",{className:"border-b border-border",children:e.map(a=>n.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-semibold text-foreground",children:a.name},a.name))})}),n.jsxs("tbody",{children:[t.map((a,l)=>n.jsx("tr",{className:"border-b border-border/60 hover:bg-muted/40",children:e.map(c=>n.jsx("td",{className:"max-w-[320px] truncate px-3 py-1 align-top text-muted-foreground",title:pu(a[c.name]),children:pu(a[c.name])},c.name))},l)),t.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:e.length,className:"px-3 py-6 text-center text-muted-foreground",children:i("database.grid.noRows")})}):null]})]})})]})}function aX({staged:e,onStageConsumed:t,projects:s=[],scopePath:i=null}={}){const a=J(),c=ym()?.confirmedProject.database??{confirmWrites:!0,resultLimit:100},{connections:d,loading:f,error:h,refresh:g}=FY(),p=x.useMemo(()=>d.filter(z=>MY(z.projectPath,i)),[d,i]),b=z=>z.projectPath?s.find(D=>_m(z.projectPath,D.path))?.name??z.projectPath.split("/").pop()??null:null;Eo(g);const{error:v,success:_}=cs(),{sendToAgent:S}=Ot(),[C,N]=wl("database:selected",null),[A,j]=wl("database:mode","browse"),[E,T]=x.useState(null),[L,H]=x.useState(null);x.useEffect(()=>{e&&(e.connection&&N(e.connection),j("query"),H({sql:e.sql,nonce:e.nonce}),t?.())},[e?.nonce]);function P(){S({prompt:IF,source:{type:"database-setup",label:"Add a database"},label:"Help me connect a database, one step at a time."})}x.useEffect(()=>{if(p.length===0){C!==null&&N(null);return}(!C||!p.some(z=>z.name===C))&&N(p[0].name)},[p,C,N]);async function F(z){try{await i7(z),_(a("database.toast.removed",{name:z})),await g()}catch(G){v(G instanceof Error?G.message:String(G))}}function M(z){T({mode:"edit",target:z})}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("header",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(si,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:a("database.title")}),f&&p.length===0?n.jsx(Mt,{className:"size-3.5 animate-spin text-muted-foreground"}):null]}),n.jsxs("div",{className:"flex items-center gap-2",children:[C?n.jsx(oX,{mode:A,onChange:j}):null,n.jsx(HY,{connections:p,projectLabel:b,selected:C,onSelect:N,onAdd:()=>T({mode:"add"}),onEdit:M,onRemove:z=>{F(z)}}),n.jsx($Y,{onAddManual:()=>T({mode:"add"}),onAddWithAi:P})]})]}),n.jsx("div",{className:"min-h-0 flex-1",children:h?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:h})}):C?A==="query"?n.jsx(tX,{connection:C,engine:p.find(z=>z.name===C)?.engine,unlocked:p.find(z=>z.name===C)?.writeUnlocked??!1,seed:L,onWriteAccessChange:g,preferences:c},C):n.jsx(lX,{connection:C,resultLimit:c.resultLimit}):n.jsx(cX,{onAdd:()=>T({mode:"add"}),onAddWithAi:P})}),E?n.jsx(zY,{initial:E.mode==="edit"?E.target:void 0,projects:s,onClose:()=>T(null),onSaved:g}):null]})}function oX({mode:e,onChange:t}){const s=J(),i=[{value:"browse",label:s("database.browse"),icon:jE},{value:"query",label:s("database.sql"),icon:Tl}];return n.jsx("div",{className:"flex items-center rounded-md border border-border p-0.5",children:i.map(a=>{const l=a.icon;return n.jsxs("button",{type:"button",onClick:()=>t(a.value),className:re("flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition-colors",e===a.value?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(l,{className:"size-3.5"}),a.label]},a.value)})})}function lX({connection:e,resultLimit:t}){const s=J(),{sendToAgent:i}=Ot(),{tables:a,selectedTable:l,setSelectedTable:c,sample:d,tablesError:f,rowsError:h,loadingTables:g,loadingRows:p,limit:b,offset:v,canPrev:_,canNext:S,changePageSize:C,nextPage:N,prevPage:A}=YY(e,t);function j(T){i({prompt:t2(e,T.table,{engine:T.engine,columns:T.columns}),source:{type:"database-table",label:`${T.table.name} table`},mode:"draft"})}function E(T){i({prompt:t2(e,T),source:{type:"database-table",label:`${T.name} table`},mode:"draft"})}return n.jsxs("div",{className:"flex h-full min-h-0",children:[n.jsxs("div",{className:"flex w-56 shrink-0 flex-col border-r border-border",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx(jE,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:s("database.tables")}),n.jsx(We,{variant:"outline",size:"small",children:a.length}),g?n.jsx(Mt,{className:"size-3.5 animate-spin"}):null]}),f?n.jsx("div",{className:"p-3",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:f})}):n.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto",children:[a.map(T=>n.jsxs("li",{className:re("group flex items-center gap-1 pr-1 transition-colors hover:bg-muted/50",T.qualifiedName===l&&"bg-muted/70"),children:[n.jsx("button",{type:"button",onClick:()=>c(T.qualifiedName),className:re("min-w-0 flex-1 truncate px-3 py-1.5 text-left font-mono text-[11px]",T.qualifiedName===l&&"font-semibold"),children:T.qualifiedName}),n.jsx(rr,{label:s("database.askAiAbout",{name:T.qualifiedName}),onAsk:()=>E(T)})]},T.qualifiedName)),!g&&a.length===0?n.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:s("database.noTables")}):null]})]}),n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"group flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-2",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[n.jsx("span",{className:"truncate font-mono text-xs font-semibold",children:l??s("database.selectTable")}),d?n.jsx(rr,{label:s("database.askAiAbout",{name:d.table.qualifiedName}),onAsk:()=>j(d)}):null]}),d?n.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"tabular-nums",children:d.rowCount===0?s("database.noRows"):s("database.rowsRange",{from:v+1,to:v+d.rowCount})}),n.jsx("select",{"aria-label":s("database.rowsPerPage"),className:"rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px]",value:b,onChange:T=>C(Number(T.target.value)),children:TA(t).map(T=>n.jsx("option",{value:T,children:s("database.perPage",{size:T})},T))}),n.jsx(Q,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:A,disabled:!_,type:"button",children:s("database.prev")}),n.jsx(Q,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:N,disabled:!S,type:"button",children:s("database.next")})]}):null]}),h?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:h})}):p?n.jsxs("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"mr-2 size-4 animate-spin"}),s("database.loadingRows")]}):d?n.jsx(QY,{connection:e,sample:d}):n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:s("database.pickTable")})]})]})}function cX({onAdd:e,onAddWithAi:t}){const s=J();return n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"max-w-sm",children:[n.jsx(si,{className:"mx-auto size-8 text-muted-foreground/50"}),n.jsx("p",{className:"mt-3 text-sm font-medium",children:s("database.emptyTitle")}),n.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[s("database.emptyBody1")," ",n.jsx("code",{children:".env"})," ",s("database.emptyBody2")]}),n.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2",children:[n.jsxs(Q,{size:"sm",onClick:e,type:"button",children:[n.jsx(ms,{}),s("database.addConnection")]}),n.jsxs(Q,{size:"sm",variant:"outline",onClick:t,type:"button",children:[n.jsx(Bn,{}),s("database.addWithAi")]})]})]})})}const Ji=[{id:"general",label:"General",description:"Language, navigation, and startup context.",icon:Y6,scope:"global",keywords:["language","sidebar","project scope"]},{id:"appearance",label:"Appearance",description:"Theme, density, type size, and motion.",icon:wE,scope:"global",keywords:["theme","dark","light","font","motion"]},{id:"terminal",label:"Terminal",description:"Terminal rendering and process safeguards.",icon:Br,scope:"global",keywords:["shell","cursor","scrollback","copy","terminate"]},{id:"services-logs",label:"Services & Logs",description:"How this project presents runtime output.",icon:Zf,scope:"project",keywords:["timestamps","wrap","runtime","services"]},{id:"git-github",label:"Git & GitHub",description:"Source-control preferences and connection status.",icon:_n,scope:"mixed",keywords:["git","github","co-author","repository"]},{id:"agents-mcp",label:"Agents & MCP",description:"Agent environments and MCP management.",icon:Ff,scope:"mixed",keywords:["agent","model","mcp","claude","codex"]},{id:"database-safety",label:"Database & Safety",description:"Project query limits and write safeguards.",icon:si,scope:"project",keywords:["database","sql","danger confirmation","writes","limit"]},{id:"notifications",label:"Notifications",description:"Browser notification capability and permission.",icon:hM,scope:"global",keywords:["alerts","desktop","permission"]},{id:"data-privacy",label:"Data & Privacy",description:"Local storage, export, reset, and privacy.",icon:CE,scope:"mixed",keywords:["data","privacy","export","reset","storage"]},{id:"about",label:"About",description:"Version, runtime, documentation, and support.",icon:V6,scope:"global",keywords:["version","docs","runtime","issues"]}],MA={language:{category:"general",label:"Language",description:"Choose the language preference for this console."},"sidebar-docked":{category:"general",label:"Dock sidebar",description:"Keep the navigation expanded while you work."},"project-scope":{category:"general",label:"Default project scope",description:"Choose whether Run pages open across every project or the selected project."},theme:{category:"appearance",label:"Theme",description:"Follow your system or choose an explicit dashboard theme."},density:{category:"appearance",label:"Interface density",description:"Adjust spacing throughout the control surface."},"code-font":{category:"appearance",label:"Code font size",description:"Size used by code and log surfaces."},"reduced-motion":{category:"appearance",label:"Reduced motion",description:"Reduce non-essential movement and animated transitions."},"terminal-font":{category:"terminal",label:"Terminal font size",description:"Text size for terminal sessions."},cursor:{category:"terminal",label:"Cursor style",description:"Shape of the active terminal cursor."},scrollback:{category:"terminal",label:"Scrollback limit",description:"Number of previous terminal lines kept in memory."},"copy-on-select":{category:"terminal",label:"Copy on select",description:"Copy selected terminal text to the clipboard."},"confirm-terminate":{category:"terminal",label:"Confirm before terminating",description:"Ask before closing, stopping, or restarting a running process. Danger confirmation."},"log-timestamps":{category:"services-logs",label:"Show timestamps",description:"Show the time gutter beside each log entry."},"wrap-lines":{category:"services-logs",label:"Wrap log lines",description:"Wrap long output instead of scrolling horizontally."},"github-connection":{category:"git-github",label:"GitHub connection",description:"Review the current GitHub connection without exposing credentials here."},"repository-defaults":{category:"git-github",label:"Repository defaults",description:"Repository-specific Git preferences will appear when their behavior is available."},"agent-environments":{category:"agents-mcp",label:"Agent environments",description:"Manage installed agents, MCP servers, skills, and profiles."},"project-agent-context":{category:"agents-mcp",label:"Project agent context",description:"Project-specific agent configuration remains in Agent Environments."},"confirm-writes":{category:"database-safety",label:"Confirm before writes",description:"Show a danger confirmation before write statements are submitted."},"result-limit":{category:"database-safety",label:"Default result limit",description:"Maximum rows requested for a default browse or query."},connections:{category:"database-safety",label:"Connections",description:"Manage connections and write access in the Database workbench."},"desktop-notifications":{category:"notifications",label:"Desktop notifications",description:"Shows whether desktop notifications are supported in this environment. Permission controls arrive with notification events."},"local-storage":{category:"data-privacy",label:"Local settings storage",description:"UI preferences stay in local browser storage; operational settings live in your NoMoreIDE config directory."},"export-reset":{category:"data-privacy",label:"Export and reset",description:"Export and reset controls are coming in a later delivery."},version:{category:"about",label:"Version",description:"Application version."},console:{category:"about",label:"Console",description:"Local runtime address."},documentation:{category:"about",label:"Documentation",description:"NoMoreIDE documentation and support."}};function uX(e){const t=MA[e];if(!t)throw new Error(`Missing settings copy for "${e}".`);return t}function DA(e){return`settingsHub.item.${e}.label`}function LA(e){return`settingsHub.item.${e}.desc`}function gu(e){return`settingsHub.cat.${e}.label`}function dX(e){return`settingsHub.cat.${e}.desc`}const hX=Object.keys(MA);function fX(e,t,s){const i=OA(e),a=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return hX.filter(l=>{const c=uX(l);if(c.category!==e)return!1;const d=s?` ${s(gu(e))} ${s(DA(l))} ${s(LA(l))}`:"",f=`${i.label} ${i.description} ${i.keywords.join(" ")} ${c.label} ${c.description}${d}`.toLowerCase();return a.every(h=>f.includes(h))})}function OA(e){return Ji.find(t=>t.id===e)??Ji[0]}function mX({scope:e}){const t=J();return n.jsx("span",{className:re("rounded-full border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide",e==="project"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border bg-muted/60 text-muted-foreground"),children:t(e==="project"?"settingsHub.currentProject":"settingsHub.global")})}function pX({state:e,error:t}){const s=J();return e==="idle"?null:n.jsxs("div",{"aria-live":"polite",className:re("flex items-center gap-1.5 text-xs",e==="error"?"text-destructive":"text-muted-foreground"),children:[e==="saving"?n.jsx(Mt,{className:"size-3.5 animate-spin"}):null,e==="saved"?n.jsx(Ys,{className:"size-3.5 text-emerald-600"}):null,e==="error"?n.jsx(Gf,{className:"size-3.5"}):null,n.jsx("span",{children:e==="saving"?s("settingsHub.saving"):e==="saved"?s("settingsHub.saved"):t})]})}function Z0({id:e,label:t,description:s,children:i,disabled:a=!1}){return n.jsxs("div",{className:re("settings-row grid gap-3 border-b border-border/50 px-4 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",a&&"opacity-55"),children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("label",{className:"text-sm font-medium",htmlFor:e,children:t}),n.jsx("p",{className:"mt-0.5 max-w-xl text-xs leading-5 text-muted-foreground",id:`${e}-description`,children:s})]}),n.jsx("div",{className:"min-w-0 sm:justify-self-end",children:i})]})}function io({id:e,label:t,description:s,checked:i,onChange:a,disabled:l=!1}){return n.jsx(Z0,{description:s,disabled:l,id:e,label:t,children:n.jsx("input",{"aria-describedby":`${e}-description`,checked:i,className:"size-4 accent-foreground",disabled:l,id:e,onChange:c=>a(c.target.checked),type:"checkbox"})})}function Uc({id:e,label:t,description:s,value:i,options:a,onChange:l,disabled:c=!1}){return n.jsx(Z0,{description:s,disabled:c,id:e,label:t,children:n.jsx("select",{"aria-describedby":`${e}-description`,className:"h-8 min-w-36 rounded-md border border-input bg-background px-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:c,id:e,onChange:d=>l(d.target.value),value:i,children:a.map(d=>n.jsx("option",{disabled:d.disabled,value:d.value,children:d.label},d.value))})})}function Mh({id:e,label:t,description:s,value:i,min:a,max:l,onSave:c,disabled:d=!1,scopeKey:f}){const h=J(),{isPending:g,runOperation:p}=In(),[b,v]=x.useState(String(i)),[_,S]=x.useState(null),C=`settings:${f??"global"}:${e}:save`,N=g(C);x.useEffect(()=>{v(String(i)),S(null)},[f,i]);async function A(){const j=Number(b);if(!Number.isInteger(j)||j<a||j>l){S(h("settingsHub.numberRange",{min:a,max:l}));return}S(null);try{await p({key:C,label:h("settingsHub.savingSetting",{label:t})},async()=>c(j))}catch(E){S(E instanceof Error?E.message:String(E))}}return n.jsx(Z0,{description:s,disabled:d,id:e,label:t,children:n.jsxs("div",{className:"flex flex-col items-start gap-1 sm:items-end",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(pt,{"aria-describedby":`${e}-description${_?` ${e}-error`:""}`,"aria-invalid":!!_,className:"h-8 w-24 font-mono text-xs",disabled:d,id:e,max:l,min:a,onChange:j=>v(j.target.value),type:"number",value:b}),n.jsx(Q,{"aria-label":h("settingsHub.saveAria",{label:t}),disabled:d,loading:N,loadingLabel:h("settingsHub.saving"),onClick:()=>{A()},size:"sm",type:"button",variant:"outline",children:h("settingsHub.save")})]}),_?n.jsx("span",{className:"text-[11px] text-destructive",id:`${e}-error`,role:"alert",children:_}):null]})})}function wa({title:e,description:t,action:s}){return n.jsxs("div",{className:"settings-row flex flex-col items-stretch justify-between gap-3 border-b border-border/50 px-4 last:border-b-0 sm:flex-row sm:items-center sm:gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-medium",children:e}),n.jsx("p",{className:"mt-0.5 break-words text-xs leading-5 text-muted-foreground",children:t})]}),s?n.jsx("div",{className:"w-full shrink-0 [&_button]:w-full sm:w-auto sm:[&_button]:w-auto",children:s}):null]})}function gX({children:e}){return n.jsx("div",{className:"border border-dashed border-border bg-muted/30 px-4 py-3 text-xs leading-5 text-muted-foreground",children:e})}function bX({selected:e,onSelect:t,search:s,onSearch:i,saveState:a,saveError:l,children:c}){const d=J(),f=x.useRef([]),h=OA(e),g=h.icon;function p(b,v){let _=null;if(b.key==="ArrowDown"&&(_=(v+1)%Ji.length),b.key==="ArrowUp"&&(_=(v-1+Ji.length)%Ji.length),b.key==="Home"&&(_=0),b.key==="End"&&(_=Ji.length-1),_===null)return;b.preventDefault();const S=Ji[_];t(S.id),f.current[_]?.focus()}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2.5",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(kE,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:d("settingsHub.title")})]}),n.jsxs("div",{className:"relative ml-auto w-full sm:w-64",children:[n.jsx(Xx,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx("input",{"aria-label":d("settingsHub.searchAria"),className:"h-8 w-full rounded-md border border-input bg-background pl-8 pr-8 text-xs outline-none focus:ring-2 focus:ring-ring",onChange:b=>i(b.target.value),placeholder:d("settingsHub.searchPlaceholder"),type:"search",value:s}),s?n.jsx("button",{"aria-label":d("settingsHub.clearSearch"),className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>i(""),type:"button",children:n.jsx(Vt,{className:"size-3"})}):null]}),n.jsx(pX,{error:l,state:a})]}),n.jsxs("div",{className:"border-b border-border px-3 py-2 md:hidden",children:[n.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",htmlFor:"settings-category-select",children:d("settingsHub.category")}),n.jsx("select",{className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",id:"settings-category-select",onChange:b=>t(b.target.value),value:e,children:Ji.map(b=>n.jsx("option",{value:b.id,children:d(gu(b.id))},b.id))})]}),n.jsxs("div",{className:"flex min-h-0 flex-1",children:[n.jsx("aside",{className:"hidden w-56 shrink-0 border-r border-border bg-muted/20 p-2 md:block",children:n.jsx("nav",{"aria-label":d("settingsHub.categoriesAria"),className:"space-y-0.5",children:Ji.map((b,v)=>{const _=b.icon,S=e===b.id;return n.jsxs("button",{"aria-current":S?"page":void 0,className:re("flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",S?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>t(b.id),onKeyDown:C=>p(C,v),ref:C=>{f.current[v]=C},tabIndex:S?0:-1,type:"button",children:[n.jsx(_,{className:"size-3.5"}),n.jsx("span",{children:d(gu(b.id))})]},b.id)})})}),n.jsx("main",{className:"min-w-0 flex-1 overflow-y-auto",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-3 py-4 sm:px-6 sm:py-6",children:[s?null:n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(g,{className:"size-4 text-muted-foreground"}),n.jsx("h2",{className:"text-base font-semibold",children:d(gu(h.id))})]}),n.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:d(dX(h.id))})]}),c]})})]})]})}function Qn({scope:e,title:t,children:s}){const i=J();return n.jsxs("section",{className:"mb-4 overflow-hidden rounded-lg border border-border bg-background/70",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-muted/25 px-4 py-2.5",children:[n.jsx("h3",{className:"text-xs font-semibold",children:t??i(e==="global"?"settingsHub.global":"settingsHub.currentProject")}),n.jsx(mX,{scope:e})]}),s]})}function qc({project:e,ready:t,loadError:s,onRetry:i}){const a=J();return e&&s?n.jsxs("div",{className:"border-b border-destructive/30 bg-destructive/5 px-4 py-3",role:"alert",children:[n.jsx("p",{className:"text-xs text-destructive",children:s}),n.jsx(Q,{"aria-label":a("settingsHub.retryProject"),className:"mt-2",onClick:i,size:"sm",type:"button",variant:"outline",children:a("settingsHub.retryProject")})]}):e&&!t?n.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-2 text-xs text-muted-foreground",children:a("settingsHub.loadingProject",{name:e.name})}):e?n.jsxs("div",{className:"border-b border-border/50 bg-amber-500/5 px-4 py-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"font-medium text-foreground",children:e.name})," · ",a("settingsHub.projectWritesPre"),n.jsx("code",{children:"nomoreide.config.json"}),a("settingsHub.projectWritesPost")]}):n.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-2 text-xs text-muted-foreground",children:a("settingsHub.selectProject")})}function vX({activeProject:e=null,onNavigate:t}={}){const s=J(),i=xm(),a=!!(e?.path&&e.path===i.activeProjectPath&&!i.projectLoading&&!i.projectLoadError),[l,c]=x.useState("general"),[d,f]=x.useState(""),h=d.trim().toLowerCase(),g=x.useMemo(()=>h?Ji.map(b=>({id:b.id,settingIds:fX(b.id,h,s)})).filter(b=>b.settingIds.length>0):[],[h,s]);let p;return i.loading?p=n.jsx("div",{"aria-label":s("settingsHub.loadingAria"),className:"space-y-3",role:"status",children:[0,1,2].map(b=>n.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-border bg-muted/40"},b))}):i.loadError?p=n.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",role:"alert",children:[n.jsx("p",{className:"text-sm font-medium",children:s("settingsHub.loadFailed")}),n.jsx("p",{className:"mt-1 text-xs text-destructive",children:i.loadError}),n.jsx(Q,{className:"mt-3",onClick:()=>{i.retry()},size:"sm",type:"button",variant:"outline",children:s("settingsHub.retry")})]}):h?p=n.jsxs("div",{children:[n.jsx("h2",{className:"mb-4 text-base font-semibold",children:s("settingsHub.searchResults")}),g.length?g.map(({id:b,settingIds:v})=>n.jsxs("div",{className:"mb-5",children:[n.jsx("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:s(gu(b))}),n.jsx(EC,{activeProject:e,category:b,onNavigate:t,projectReady:a,settings:i,visibleSettingIds:new Set(v)})]},b)):n.jsx(gX,{children:s("settingsHub.noMatches",{query:d.trim()})})]}):p=n.jsx(EC,{activeProject:e,category:l,onNavigate:t,projectReady:a,settings:i}),n.jsx(bX,{onSearch:f,onSelect:c,saveError:i.saveError,saveState:i.saveState,search:d,selected:l,children:p})}function EC({category:e,activeProject:t,projectReady:s,onNavigate:i,settings:a,visibleSettingIds:l}){const c=J(),d=!s,f=p=>!l||l.has(p),h=p=>p.some(f),g=p=>({label:c(DA(p)),description:c(LA(p))});switch(e){case"general":return n.jsxs(Qn,{scope:"global",children:[f("language")?n.jsx(Uc,{...g("language"),id:"setting-language",onChange:p=>a.updateUi({language:p}),options:Q$.map(p=>({value:p.value,label:p.nativeLabel,disabled:!p.available})),value:a.ui.language}):null,f("sidebar-docked")?n.jsx(io,{...g("sidebar-docked"),checked:a.ui.sidebarDocked,id:"setting-sidebar-docked",onChange:p=>a.updateUi({sidebarDocked:p})}):null,f("project-scope")?n.jsx(Uc,{...g("project-scope"),id:"setting-project-scope",onChange:p=>a.updateUi({projectScope:p}),options:[{value:"all",label:c("settingsHub.opt.allProjects")},{value:"project",label:c("settingsHub.currentProject")}],value:a.ui.projectScope}):null]});case"appearance":return n.jsxs(Qn,{scope:"global",children:[f("theme")?n.jsx(Uc,{...g("theme"),id:"setting-theme",onChange:p=>a.updateUi({theme:p}),options:[{value:"system",label:c("settingsHub.opt.system")},{value:"light",label:c("settingsHub.opt.light")},{value:"dark",label:c("settingsHub.opt.dark")}],value:a.ui.theme}):null,f("density")?n.jsx(Uc,{...g("density"),id:"setting-density",onChange:p=>a.updateUi({density:p}),options:[{value:"comfortable",label:c("settingsHub.opt.comfortable")},{value:"compact",label:c("settingsHub.opt.compact")}],value:a.ui.density}):null,f("code-font")?n.jsx(Mh,{...g("code-font"),id:"setting-code-font",max:18,min:10,onSave:p=>{a.updateUi({codeFontSize:p})},value:a.ui.codeFontSize}):null,f("reduced-motion")?n.jsx(io,{...g("reduced-motion"),checked:a.ui.reducedMotion,id:"setting-reduced-motion",onChange:p=>a.updateUi({reducedMotion:p})}):null]});case"terminal":return n.jsxs(Qn,{scope:"global",children:[f("terminal-font")?n.jsx(Mh,{...g("terminal-font"),id:"setting-terminal-font",max:24,min:10,onSave:p=>a.updateGlobal({terminal:{fontSize:p}}),value:a.global.terminal.fontSize}):null,f("cursor")?n.jsx(Uc,{...g("cursor"),id:"setting-cursor",onChange:p=>{a.updateGlobal({terminal:{cursorStyle:p}})},options:[{value:"block",label:c("settingsHub.opt.block")},{value:"underline",label:c("settingsHub.opt.underline")},{value:"bar",label:c("settingsHub.opt.bar")}],value:a.global.terminal.cursorStyle}):null,f("scrollback")?n.jsx(Mh,{...g("scrollback"),id:"setting-scrollback",max:1e5,min:500,onSave:p=>a.updateGlobal({terminal:{scrollback:p}}),value:a.global.terminal.scrollback}):null,f("copy-on-select")?n.jsx(io,{...g("copy-on-select"),checked:a.global.terminal.copyOnSelect,id:"setting-copy-on-select",onChange:p=>{a.updateGlobal({terminal:{copyOnSelect:p}})}}):null,f("confirm-terminate")?n.jsx(io,{...g("confirm-terminate"),checked:a.global.terminal.confirmTerminate,id:"setting-confirm-terminate",onChange:p=>{a.updateGlobal({terminal:{confirmTerminate:p}})}}):null]});case"services-logs":return n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),f("log-timestamps")?n.jsx(io,{...g("log-timestamps"),checked:a.project.logs.showTimestamps,disabled:d,id:"setting-log-timestamps",onChange:p=>{a.updateProject({logs:{showTimestamps:p}})}}):null,f("wrap-lines")?n.jsx(io,{...g("wrap-lines"),checked:a.project.logs.wrapLines,disabled:d,id:"setting-wrap-lines",onChange:p=>{a.updateProject({logs:{wrapLines:p}})}}):null]});case"git-github":return n.jsxs(n.Fragment,{children:[h(["github-connection"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{action:n.jsx(Q,{onClick:()=>i?.("github"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.manageGitHub")}),description:g("github-connection").description,title:g("github-connection").label})}):null,h(["repository-defaults"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("repository-defaults").description,title:g("repository-defaults").label})]}):null]});case"agents-mcp":return n.jsxs(n.Fragment,{children:[h(["agent-environments"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{action:n.jsx(Q,{onClick:()=>i?.("agent-env"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.openAgentEnv")}),description:g("agent-environments").description,title:g("agent-environments").label})}):null,h(["project-agent-context"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("project-agent-context").description,title:g("project-agent-context").label})]}):null]});case"database-safety":return n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),f("confirm-writes")?n.jsx(io,{...g("confirm-writes"),checked:a.project.database.confirmWrites,disabled:d,id:"setting-confirm-writes",onChange:p=>{a.updateProject({database:{confirmWrites:p}})}}):null,f("result-limit")?n.jsx(Mh,{...g("result-limit"),disabled:d,id:"setting-result-limit",max:5e3,min:10,onSave:p=>a.updateProject({database:{resultLimit:p}}),scopeKey:a.activeProjectPath,value:a.project.database.resultLimit}):null,f("connections")?n.jsx(wa,{action:n.jsx(Q,{disabled:d,onClick:()=>i?.("database"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.openDatabase")}),description:g("connections").description,title:g("connections").label}):null]});case"notifications":{const p=typeof Notification>"u"?c("settingsHub.notifUnavailable"):c("settingsHub.notifPermission",{value:Notification.permission});return n.jsx(Qn,{scope:"global",children:f("desktop-notifications")?n.jsx(wa,{action:n.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:p}),description:g("desktop-notifications").description,title:g("desktop-notifications").label}):null})}case"data-privacy":return n.jsxs(n.Fragment,{children:[h(["local-storage"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{description:g("local-storage").description,title:g("local-storage").label})}):null,h(["export-reset"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("export-reset").description,title:g("export-reset").label})]}):null]});case"about":return n.jsx(Qn,{scope:"global",children:n.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-5 gap-y-2 px-4 py-4 text-xs",children:[f("version")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("version").label}),n.jsxs("code",{children:["v","0.1.87"]})]}):null,f("console")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("console").label}),n.jsx("code",{children:"127.0.0.1:4317"})]}):null,f("documentation")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("documentation").label}),n.jsxs("a",{className:"inline-flex items-center gap-1 text-primary hover:underline",href:"https://www.nomoreide.com/docs",rel:"noreferrer",target:"_blank",children:[n.jsx(oE,{className:"size-3"}),"nomoreide.com/docs",n.jsx(Pr,{className:"size-3"})]})]}):null]})})}}function xX(e,t){const s=t.trim().toLocaleLowerCase();return s?[e.service,e.title,e.file??"",...e.logExcerpt].some(i=>i.toLocaleLowerCase().includes(s)):!0}function yX(e,t,s){const i=new Set(s.levels),a=new Set(s.services);return e.filter(l=>xX(l,t)&&(i.size===0||i.has(l.level))&&(a.size===0||a.has(l.service)))}function _X(e){return{levels:[...new Set(e.map(({level:t})=>t))].sort(),services:[...new Set(e.map(({service:t})=>t))].sort()}}function wX(e){return e.levels.length+e.services.length}function SX({detailId:e,incident:t,onReviewChanges:s}){const i=J(),{sendToAgent:a}=Ot(),{isPending:l,runOperation:c}=In(),d=`error:${t.id}:fix`,f=l(d),[h,g]=x.useState(null);async function p(){await c({errorMessage:b=>b instanceof Error?b.message:String(b),key:d,label:i("errors.incident.fixingOperation",{service:t.service})},async()=>{const{prompt:b,sessionId:v}=await p7(t.id);a({prompt:b,source:{type:"error",label:`${t.service} — ${t.level}`},label:i("errors.incident.fixLabel",{level:t.level,service:t.service,title:t.title})}),g(v)})}return n.jsxs("div",{className:"min-w-0 rounded-lg border border-border bg-background","data-incident-detail":"true",id:e,children:[n.jsxs("div",{className:"px-4 py-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(We,{variant:t.level==="error"?"danger":"secondary",appearance:"subtle",size:"small",children:i(t.level==="error"?"errors.level.error":"errors.level.warning")}),n.jsx("span",{className:"truncate font-mono text-xs font-semibold",children:t.service}),t.count>1?n.jsxs(We,{variant:"outline",size:"small",children:["×",t.count]}):null]}),n.jsxs(Q,{loading:f,loadingLabel:i("errors.incident.starting"),onClick:()=>{p().catch(()=>{})},size:"sm",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"}),i("errors.incident.fixWithAi")]})]}),n.jsx("p",{className:"mt-1.5 break-words font-mono text-xs text-foreground",children:t.title}),t.file?n.jsxs("p",{className:"mt-1 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground",children:[n.jsx(pE,{className:"size-3.5"}),t.file,t.line?`:${t.line}`:""]}):null,n.jsx("p",{className:"mt-1 font-mono text-[10px] text-muted-foreground/80",children:i("errors.incident.firstLast",{first:new Date(t.firstSeen).toLocaleString(),last:new Date(t.lastSeen).toLocaleTimeString()})})]}),n.jsxs("div",{className:"border-t border-border p-4",children:[h?n.jsx(Ze,{variant:"muted",className:"mb-3",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs",children:i("errors.incident.working")}),s?n.jsxs(Q,{onClick:()=>s(h),size:"sm",variant:"outline",children:[n.jsx(mE,{className:"size-3.5"}),i("errors.incident.reviewChanges")]}):null]})}):null,n.jsx("p",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:i("errors.incident.logExcerpt")}),n.jsx("pre",{className:"overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-[11px] leading-relaxed",children:t.logExcerpt.join(`
|
|
118
|
+
${c.map(v=>b(p[v])).join(",")}`}function g(p){const b=_=>_==null?"NULL":typeof _=="number"||typeof _=="boolean"?String(_):`'${(typeof _=="object"?JSON.stringify(_):String(_)).replace(/'/g,"''")}'`,v=c.map(_=>b(p[_])).join(", ");return`INSERT INTO ${t.table} (${c.join(", ")}) VALUES (${v});`}return t.columns.length===0?n.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:s("database.grid.noColumnsTable")}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"code-font-size w-max min-w-full border-collapse text-left font-mono",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-card",children:n.jsxs("tr",{className:"border-b border-border",children:[t.columns.map(p=>n.jsxs("th",{className:"whitespace-nowrap px-3 py-2 font-semibold text-foreground",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[p.primaryKey?n.jsx(xE,{className:"size-3 text-amber-500"}):null,p.name]}),n.jsx("span",{className:"block font-normal text-muted-foreground",children:p.dataType})]},p.name)),n.jsx("th",{className:"sticky right-0 z-20 w-16 border-l border-border bg-card px-2 py-2"})]})}),n.jsxs("tbody",{children:[t.rows.map((p,b)=>n.jsxs("tr",{className:"group border-b border-border/60 hover:bg-muted/40",children:[t.columns.map(v=>n.jsx("td",{className:"max-w-[320px] truncate px-3 py-1 align-top text-muted-foreground",title:pu(p[v.name]),children:pu(p[v.name])},v.name)),n.jsx("td",{className:"sticky right-0 z-[1] border-l border-border/60 bg-card px-2 py-1 align-top before:pointer-events-none before:absolute before:inset-0 before:bg-muted/40 before:opacity-0 group-hover:before:opacity-100",children:n.jsxs("div",{className:"relative z-[1] flex items-center justify-end gap-0.5",children:[n.jsx(rr,{label:s("database.grid.askAiRow"),onAsk:()=>d(p)}),n.jsx(Ll,{label:s("database.grid.rowActions"),items:[{label:s("database.grid.copyJson"),icon:n.jsx(xM,{className:"size-3.5"}),onSelect:()=>{f(JSON.stringify(p,null,2),s("database.grid.rowAsJson"))}},{label:s("database.grid.copyCsv"),icon:n.jsx(f6,{className:"size-3.5"}),onSelect:()=>{f(h(p),s("database.grid.rowAsCsv"))}},{label:s("database.grid.copySqlInsert"),icon:n.jsx(si,{className:"size-3.5"}),onSelect:()=>{f(g(p),s("database.grid.insertStatement"))}}]})]})})]},b)),t.rows.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:t.columns.length+1,className:"px-3 py-6 text-center text-muted-foreground",children:s("database.grid.noRows")})}):null]})]})})}function pu(e){return e==null?"NULL":typeof e=="object"?JSON.stringify(e):String(e)}function JY({connection:e,busy:t,onConfirm:s,onClose:i}){const a=J();return n.jsx(zn,{icon:n.jsx(o8,{className:"text-amber-500"}),onClose:i,title:a("database.write.unlockTitle",{connection:e}),children:n.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[n.jsx("p",{className:"text-muted-foreground",children:a("database.write.unlockBody1")}),n.jsx("p",{className:"text-muted-foreground",children:a("database.write.unlockBody2")}),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border pt-3",children:[n.jsx(Q,{variant:"outline",size:"sm",onClick:i,type:"button",children:a("common.cancel")}),n.jsxs(Q,{size:"sm",onClick:s,disabled:t,type:"button",children:[t?n.jsx(Mt,{className:"animate-spin"}):n.jsx(yE,{}),a("database.write.unlockWrites")]})]})]})})}function eX({sql:e,preview:t,busy:s,onConfirm:i,onClose:a}){const l=J();return n.jsx(zn,{icon:n.jsx(zr,{className:"text-amber-500"}),onClose:a,title:l("database.write.confirmTitle"),children:n.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[n.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap",children:e}),t.previewUnavailable?n.jsx("p",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[13px] text-amber-700 dark:text-amber-300",children:l("database.write.previewUnavailable")}):n.jsxs("p",{className:"text-muted-foreground",children:[l("database.write.willAffectPre")," ",n.jsx("strong",{className:"text-foreground tabular-nums",children:t.affectedRows??0})," ",l("database.write.willAffectPost")]}),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border pt-3",children:[n.jsx(Q,{variant:"outline",size:"sm",onClick:a,type:"button",children:l("common.cancel")}),n.jsxs(Q,{size:"sm",className:"bg-amber-600 text-white hover:bg-amber-600/90",onClick:i,disabled:s,type:"button",children:[s?n.jsx(Mt,{className:"animate-spin"}):null,l("database.write.runCommit")]})]})]})})}function tX({connection:e,engine:t,unlocked:s,seed:i,onWriteAccessChange:a,preferences:l={confirmWrites:!0,resultLimit:100}}){const c=J(),{isPending:d,runOperation:f}=In(),{success:h}=cs(),{sendToAgent:g}=Ot(),p=qY(e),b=WY(e),v=KY(e,a),[_,S]=x.useState(i?.sql??""),[C,N]=x.useState(()=>l.resultLimit),A=x.useRef(!1);x.useEffect(()=>{A.current||N(l.resultLimit)},[l.resultLimit]);const j=i?.nonce;x.useEffect(()=>{i&&S(i.sql)},[j]);const[E,T]=x.useState(!1),L=XY(e,t,s,S),H=_.trim().length>0&&!VY(_),P=s&&H,F=H&&!s,M=p.running||b.previewing||b.committing,z=`database:${e}:write`,G=d(z);function D(){if(_.trim()){if(F){T(!0);return}P?(p.reset(),l.confirmWrites?b.preview(_):I(_)):(b.reset(),p.run(_,C))}}function q(Y){(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"&&(Y.preventDefault(),D())}function W(Y){g({prompt:qF(e,t,_,Y),source:{type:"database-sql-debug",label:"Debug SQL"},label:c("database.sql.debugLabel")})}async function I(Y){const $=await f({key:z,label:c("database.sql.committingWrite",{connection:e})},()=>b.commit(Y));if($?.committed){const me=$.affectedRows??0;h(c("database.sql.committed",{count:me}))}}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b border-border p-2",children:[n.jsx(sX,{generate:L}),n.jsx("textarea",{value:_,onChange:Y=>S(Y.target.value),onKeyDown:q,spellCheck:!1,placeholder:c(s?"database.sql.placeholderUnlocked":"database.sql.placeholderLocked"),className:"code-font-size h-24 w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono outline-none focus:border-ring"}),n.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[n.jsx(nX,{unlocked:s,updating:v.updating,onUnlock:()=>T(!0),onLock:()=>{v.setUnlocked(!1)}}),n.jsxs("div",{className:"flex items-center gap-2",children:[P?null:n.jsx("select",{"aria-label":c("database.sql.maxRows"),className:"rounded-md border border-border bg-background px-1.5 py-1 text-[11px]",value:C,onChange:Y=>{A.current=!0,N(Number(Y.target.value))},children:TA(l.resultLimit).map(Y=>n.jsx("option",{value:Y,children:c("database.sql.rowsOption",{size:Y})},Y))}),n.jsxs(Q,{size:"sm",className:re("h-7 px-3",P&&"bg-amber-600 text-white hover:bg-amber-600/90"),onClick:D,disabled:M||!_.trim(),loading:P&&G,loadingLabel:c("database.sql.runWrite"),type:"button",children:[M?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(or,{className:"size-3.5"}),P?l.confirmWrites?c("database.sql.previewWrite"):c("database.sql.runWrite"):c("database.sql.run")]})]})]})]}),n.jsx(iX,{read:p,write:b,onDebug:W}),E?n.jsx(JY,{connection:e,busy:v.updating,onConfirm:async()=>{await v.setUnlocked(!0),T(!1)},onClose:()=>T(!1)}):null,b.pending?n.jsx(eX,{sql:b.pending.sql,preview:b.pending.preview,busy:b.committing,onConfirm:()=>{I()},onClose:b.cancel}):null]})}function sX({generate:e}){const t=J(),[s,i]=x.useState("");function a(){const c=s.trim();!c||e.generating||e.generate(c)}function l(c){c.key==="Enter"&&(c.preventDefault(),a())}return n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(Xt,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2"}),n.jsx("input",{value:s,onChange:c=>i(c.target.value),onKeyDown:l,disabled:e.generating,placeholder:t("database.sql.generatePlaceholder"),className:"h-8 w-full rounded-md border border-border bg-background pl-7 pr-2 text-[12px] outline-none focus:border-ring disabled:opacity-60"})]}),n.jsxs(Q,{size:"sm",variant:"outline",className:"h-8 px-3",onClick:a,disabled:e.generating||!s.trim(),type:"button",children:[e.generating?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Xt,{className:"size-3.5"}),e.generating?t("database.sql.generating"):t("database.sql.askAi")]})]}),e.error?n.jsx("p",{className:"mt-1 text-[11px] text-amber-600 dark:text-amber-400",children:e.error}):null]})}function nX({unlocked:e,updating:t,onUnlock:s,onLock:i}){const a=J();return n.jsxs("button",{type:"button",onClick:e?i:s,disabled:t,className:re("flex items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] font-medium transition-colors",e?"border-amber-500/50 text-amber-600 hover:bg-amber-500/10 dark:text-amber-400":"border-border text-muted-foreground hover:text-foreground"),title:a(e?"database.sql.writesUnlockedTitle":"database.sql.readOnlyTitle"),children:[t?n.jsx(Mt,{className:"size-3.5 animate-spin"}):e?n.jsx(yE,{className:"size-3.5"}):n.jsx(uD,{className:"size-3.5"}),a(e?"database.sql.writesUnlocked":"database.sql.readOnly")]})}function iX({read:e,write:t,onDebug:s}){const i=J(),a=t.error??e.error;return n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:a?n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsx("p",{className:"code-font-size whitespace-pre-wrap font-mono text-destructive",children:a}),n.jsxs(Q,{size:"sm",variant:"outline",className:"h-7 px-3",onClick:()=>s(a),type:"button",children:[n.jsx(Xt,{className:"size-3.5"}),i("database.sql.debugWithAi")]})]}):t.committed?n.jsx(rX,{outcome:t.committed}):e.result?n.jsx(RA,{columns:e.result.columns,rows:e.result.rows,truncated:e.result.truncated}):n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:i("database.sql.emptyResult")})})}function rX({outcome:e}){const t=J();if(!e)return null;const s=e.affectedRows??0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-b border-border bg-emerald-500/10 px-3 py-1.5 text-[12px] text-emerald-700 dark:text-emerald-400",children:[n.jsx(Ys,{className:"size-3.5"}),t("database.sql.committed",{count:s})]}),e.rows&&e.rows.length>0&&e.columns?n.jsx(RA,{columns:e.columns,rows:e.rows}):null]})}function RA({columns:e,rows:t,truncated:s=!1}){const i=J();return e.length===0?n.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:i("database.sql.noColumns")}):n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s?n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 border-b border-border bg-amber-500/10 px-3 py-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[n.jsx(zr,{className:"size-3.5"}),i("database.sql.truncated",{count:t.length})]}):null,n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"code-font-size w-max min-w-full border-collapse text-left font-mono",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-card",children:n.jsx("tr",{className:"border-b border-border",children:e.map(a=>n.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-semibold text-foreground",children:a.name},a.name))})}),n.jsxs("tbody",{children:[t.map((a,l)=>n.jsx("tr",{className:"border-b border-border/60 hover:bg-muted/40",children:e.map(c=>n.jsx("td",{className:"max-w-[320px] truncate px-3 py-1 align-top text-muted-foreground",title:pu(a[c.name]),children:pu(a[c.name])},c.name))},l)),t.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:e.length,className:"px-3 py-6 text-center text-muted-foreground",children:i("database.grid.noRows")})}):null]})]})})]})}function aX({staged:e,onStageConsumed:t,projects:s=[],scopePath:i=null}={}){const a=J(),c=ym()?.confirmedProject.database??{confirmWrites:!0,resultLimit:100},{connections:d,loading:f,error:h,refresh:g}=FY(),p=x.useMemo(()=>d.filter(z=>MY(z.projectPath,i)),[d,i]),b=z=>z.projectPath?s.find(D=>_m(z.projectPath,D.path))?.name??z.projectPath.split("/").pop()??null:null;Eo(g);const{error:v,success:_}=cs(),{sendToAgent:S}=Ot(),[C,N]=wl("database:selected",null),[A,j]=wl("database:mode","browse"),[E,T]=x.useState(null),[L,H]=x.useState(null);x.useEffect(()=>{e&&(e.connection&&N(e.connection),j("query"),H({sql:e.sql,nonce:e.nonce}),t?.())},[e?.nonce]);function P(){S({prompt:IF,source:{type:"database-setup",label:"Add a database"},label:"Help me connect a database, one step at a time."})}x.useEffect(()=>{if(p.length===0){C!==null&&N(null);return}(!C||!p.some(z=>z.name===C))&&N(p[0].name)},[p,C,N]);async function F(z){try{await i7(z),_(a("database.toast.removed",{name:z})),await g()}catch(G){v(G instanceof Error?G.message:String(G))}}function M(z){T({mode:"edit",target:z})}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("header",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(si,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:a("database.title")}),f&&p.length===0?n.jsx(Mt,{className:"size-3.5 animate-spin text-muted-foreground"}):null]}),n.jsxs("div",{className:"flex items-center gap-2",children:[C?n.jsx(oX,{mode:A,onChange:j}):null,n.jsx(HY,{connections:p,projectLabel:b,selected:C,onSelect:N,onAdd:()=>T({mode:"add"}),onEdit:M,onRemove:z=>{F(z)}}),n.jsx($Y,{onAddManual:()=>T({mode:"add"}),onAddWithAi:P})]})]}),n.jsx("div",{className:"min-h-0 flex-1",children:h?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:h})}):C?A==="query"?n.jsx(tX,{connection:C,engine:p.find(z=>z.name===C)?.engine,unlocked:p.find(z=>z.name===C)?.writeUnlocked??!1,seed:L,onWriteAccessChange:g,preferences:c},C):n.jsx(lX,{connection:C,resultLimit:c.resultLimit}):n.jsx(cX,{onAdd:()=>T({mode:"add"}),onAddWithAi:P})}),E?n.jsx(zY,{initial:E.mode==="edit"?E.target:void 0,projects:s,onClose:()=>T(null),onSaved:g}):null]})}function oX({mode:e,onChange:t}){const s=J(),i=[{value:"browse",label:s("database.browse"),icon:jE},{value:"query",label:s("database.sql"),icon:Tl}];return n.jsx("div",{className:"flex items-center rounded-md border border-border p-0.5",children:i.map(a=>{const l=a.icon;return n.jsxs("button",{type:"button",onClick:()=>t(a.value),className:re("flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition-colors",e===a.value?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(l,{className:"size-3.5"}),a.label]},a.value)})})}function lX({connection:e,resultLimit:t}){const s=J(),{sendToAgent:i}=Ot(),{tables:a,selectedTable:l,setSelectedTable:c,sample:d,tablesError:f,rowsError:h,loadingTables:g,loadingRows:p,limit:b,offset:v,canPrev:_,canNext:S,changePageSize:C,nextPage:N,prevPage:A}=YY(e,t);function j(T){i({prompt:t2(e,T.table,{engine:T.engine,columns:T.columns}),source:{type:"database-table",label:`${T.table.name} table`},mode:"draft"})}function E(T){i({prompt:t2(e,T),source:{type:"database-table",label:`${T.name} table`},mode:"draft"})}return n.jsxs("div",{className:"flex h-full min-h-0",children:[n.jsxs("div",{className:"flex w-56 shrink-0 flex-col border-r border-border",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx(jE,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:s("database.tables")}),n.jsx(We,{variant:"outline",size:"small",children:a.length}),g?n.jsx(Mt,{className:"size-3.5 animate-spin"}):null]}),f?n.jsx("div",{className:"p-3",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:f})}):n.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto",children:[a.map(T=>n.jsxs("li",{className:re("group flex items-center gap-1 pr-1 transition-colors hover:bg-muted/50",T.qualifiedName===l&&"bg-muted/70"),children:[n.jsx("button",{type:"button",onClick:()=>c(T.qualifiedName),className:re("min-w-0 flex-1 truncate px-3 py-1.5 text-left font-mono text-[11px]",T.qualifiedName===l&&"font-semibold"),children:T.qualifiedName}),n.jsx(rr,{label:s("database.askAiAbout",{name:T.qualifiedName}),onAsk:()=>E(T)})]},T.qualifiedName)),!g&&a.length===0?n.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:s("database.noTables")}):null]})]}),n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"group flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-2",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[n.jsx("span",{className:"truncate font-mono text-xs font-semibold",children:l??s("database.selectTable")}),d?n.jsx(rr,{label:s("database.askAiAbout",{name:d.table.qualifiedName}),onAsk:()=>j(d)}):null]}),d?n.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"tabular-nums",children:d.rowCount===0?s("database.noRows"):s("database.rowsRange",{from:v+1,to:v+d.rowCount})}),n.jsx("select",{"aria-label":s("database.rowsPerPage"),className:"rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px]",value:b,onChange:T=>C(Number(T.target.value)),children:TA(t).map(T=>n.jsx("option",{value:T,children:s("database.perPage",{size:T})},T))}),n.jsx(Q,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:A,disabled:!_,type:"button",children:s("database.prev")}),n.jsx(Q,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:N,disabled:!S,type:"button",children:s("database.next")})]}):null]}),h?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-destructive/40 text-destructive",children:h})}):p?n.jsxs("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"mr-2 size-4 animate-spin"}),s("database.loadingRows")]}):d?n.jsx(QY,{connection:e,sample:d}):n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:s("database.pickTable")})]})]})}function cX({onAdd:e,onAddWithAi:t}){const s=J();return n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"max-w-sm",children:[n.jsx(si,{className:"mx-auto size-8 text-muted-foreground/50"}),n.jsx("p",{className:"mt-3 text-sm font-medium",children:s("database.emptyTitle")}),n.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[s("database.emptyBody1")," ",n.jsx("code",{children:".env"})," ",s("database.emptyBody2")]}),n.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2",children:[n.jsxs(Q,{size:"sm",onClick:e,type:"button",children:[n.jsx(ms,{}),s("database.addConnection")]}),n.jsxs(Q,{size:"sm",variant:"outline",onClick:t,type:"button",children:[n.jsx(Bn,{}),s("database.addWithAi")]})]})]})})}const Ji=[{id:"general",label:"General",description:"Language, navigation, and startup context.",icon:Y6,scope:"global",keywords:["language","sidebar","project scope"]},{id:"appearance",label:"Appearance",description:"Theme, density, type size, and motion.",icon:wE,scope:"global",keywords:["theme","dark","light","font","motion"]},{id:"terminal",label:"Terminal",description:"Terminal rendering and process safeguards.",icon:Br,scope:"global",keywords:["shell","cursor","scrollback","copy","terminate"]},{id:"services-logs",label:"Services & Logs",description:"How this project presents runtime output.",icon:Zf,scope:"project",keywords:["timestamps","wrap","runtime","services"]},{id:"git-github",label:"Git & GitHub",description:"Source-control preferences and connection status.",icon:_n,scope:"mixed",keywords:["git","github","co-author","repository"]},{id:"agents-mcp",label:"Agents & MCP",description:"Agent environments and MCP management.",icon:Ff,scope:"mixed",keywords:["agent","model","mcp","claude","codex"]},{id:"database-safety",label:"Database & Safety",description:"Project query limits and write safeguards.",icon:si,scope:"project",keywords:["database","sql","danger confirmation","writes","limit"]},{id:"notifications",label:"Notifications",description:"Browser notification capability and permission.",icon:hM,scope:"global",keywords:["alerts","desktop","permission"]},{id:"data-privacy",label:"Data & Privacy",description:"Local storage, export, reset, and privacy.",icon:CE,scope:"mixed",keywords:["data","privacy","export","reset","storage"]},{id:"about",label:"About",description:"Version, runtime, documentation, and support.",icon:V6,scope:"global",keywords:["version","docs","runtime","issues"]}],MA={language:{category:"general",label:"Language",description:"Choose the language preference for this console."},"sidebar-docked":{category:"general",label:"Dock sidebar",description:"Keep the navigation expanded while you work."},"project-scope":{category:"general",label:"Default project scope",description:"Choose whether Run pages open across every project or the selected project."},theme:{category:"appearance",label:"Theme",description:"Follow your system or choose an explicit dashboard theme."},density:{category:"appearance",label:"Interface density",description:"Adjust spacing throughout the control surface."},"code-font":{category:"appearance",label:"Code font size",description:"Size used by code and log surfaces."},"reduced-motion":{category:"appearance",label:"Reduced motion",description:"Reduce non-essential movement and animated transitions."},"terminal-font":{category:"terminal",label:"Terminal font size",description:"Text size for terminal sessions."},cursor:{category:"terminal",label:"Cursor style",description:"Shape of the active terminal cursor."},scrollback:{category:"terminal",label:"Scrollback limit",description:"Number of previous terminal lines kept in memory."},"copy-on-select":{category:"terminal",label:"Copy on select",description:"Copy selected terminal text to the clipboard."},"confirm-terminate":{category:"terminal",label:"Confirm before terminating",description:"Ask before closing, stopping, or restarting a running process. Danger confirmation."},"log-timestamps":{category:"services-logs",label:"Show timestamps",description:"Show the time gutter beside each log entry."},"wrap-lines":{category:"services-logs",label:"Wrap log lines",description:"Wrap long output instead of scrolling horizontally."},"github-connection":{category:"git-github",label:"GitHub connection",description:"Review the current GitHub connection without exposing credentials here."},"repository-defaults":{category:"git-github",label:"Repository defaults",description:"Repository-specific Git preferences will appear when their behavior is available."},"agent-environments":{category:"agents-mcp",label:"Agent environments",description:"Manage installed agents, MCP servers, skills, and profiles."},"project-agent-context":{category:"agents-mcp",label:"Project agent context",description:"Project-specific agent configuration remains in Agent Environments."},"confirm-writes":{category:"database-safety",label:"Confirm before writes",description:"Show a danger confirmation before write statements are submitted."},"result-limit":{category:"database-safety",label:"Default result limit",description:"Maximum rows requested for a default browse or query."},connections:{category:"database-safety",label:"Connections",description:"Manage connections and write access in the Database workbench."},"desktop-notifications":{category:"notifications",label:"Desktop notifications",description:"Shows whether desktop notifications are supported in this environment. Permission controls arrive with notification events."},"local-storage":{category:"data-privacy",label:"Local settings storage",description:"UI preferences stay in local browser storage; operational settings live in your NoMoreIDE config directory."},"export-reset":{category:"data-privacy",label:"Export and reset",description:"Export and reset controls are coming in a later delivery."},version:{category:"about",label:"Version",description:"Application version."},console:{category:"about",label:"Console",description:"Local runtime address."},documentation:{category:"about",label:"Documentation",description:"NoMoreIDE documentation and support."}};function uX(e){const t=MA[e];if(!t)throw new Error(`Missing settings copy for "${e}".`);return t}function DA(e){return`settingsHub.item.${e}.label`}function LA(e){return`settingsHub.item.${e}.desc`}function gu(e){return`settingsHub.cat.${e}.label`}function dX(e){return`settingsHub.cat.${e}.desc`}const hX=Object.keys(MA);function fX(e,t,s){const i=OA(e),a=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return hX.filter(l=>{const c=uX(l);if(c.category!==e)return!1;const d=s?` ${s(gu(e))} ${s(DA(l))} ${s(LA(l))}`:"",f=`${i.label} ${i.description} ${i.keywords.join(" ")} ${c.label} ${c.description}${d}`.toLowerCase();return a.every(h=>f.includes(h))})}function OA(e){return Ji.find(t=>t.id===e)??Ji[0]}function mX({scope:e}){const t=J();return n.jsx("span",{className:re("rounded-full border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide",e==="project"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border bg-muted/60 text-muted-foreground"),children:t(e==="project"?"settingsHub.currentProject":"settingsHub.global")})}function pX({state:e,error:t}){const s=J();return e==="idle"?null:n.jsxs("div",{"aria-live":"polite",className:re("flex items-center gap-1.5 text-xs",e==="error"?"text-destructive":"text-muted-foreground"),children:[e==="saving"?n.jsx(Mt,{className:"size-3.5 animate-spin"}):null,e==="saved"?n.jsx(Ys,{className:"size-3.5 text-emerald-600"}):null,e==="error"?n.jsx(Gf,{className:"size-3.5"}):null,n.jsx("span",{children:e==="saving"?s("settingsHub.saving"):e==="saved"?s("settingsHub.saved"):t})]})}function Z0({id:e,label:t,description:s,children:i,disabled:a=!1}){return n.jsxs("div",{className:re("settings-row grid gap-3 border-b border-border/50 px-4 last:border-b-0 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",a&&"opacity-55"),children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("label",{className:"text-sm font-medium",htmlFor:e,children:t}),n.jsx("p",{className:"mt-0.5 max-w-xl text-xs leading-5 text-muted-foreground",id:`${e}-description`,children:s})]}),n.jsx("div",{className:"min-w-0 sm:justify-self-end",children:i})]})}function io({id:e,label:t,description:s,checked:i,onChange:a,disabled:l=!1}){return n.jsx(Z0,{description:s,disabled:l,id:e,label:t,children:n.jsx("input",{"aria-describedby":`${e}-description`,checked:i,className:"size-4 accent-foreground",disabled:l,id:e,onChange:c=>a(c.target.checked),type:"checkbox"})})}function Uc({id:e,label:t,description:s,value:i,options:a,onChange:l,disabled:c=!1}){return n.jsx(Z0,{description:s,disabled:c,id:e,label:t,children:n.jsx("select",{"aria-describedby":`${e}-description`,className:"h-8 min-w-36 rounded-md border border-input bg-background px-2 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:c,id:e,onChange:d=>l(d.target.value),value:i,children:a.map(d=>n.jsx("option",{disabled:d.disabled,value:d.value,children:d.label},d.value))})})}function Mh({id:e,label:t,description:s,value:i,min:a,max:l,onSave:c,disabled:d=!1,scopeKey:f}){const h=J(),{isPending:g,runOperation:p}=In(),[b,v]=x.useState(String(i)),[_,S]=x.useState(null),C=`settings:${f??"global"}:${e}:save`,N=g(C);x.useEffect(()=>{v(String(i)),S(null)},[f,i]);async function A(){const j=Number(b);if(!Number.isInteger(j)||j<a||j>l){S(h("settingsHub.numberRange",{min:a,max:l}));return}S(null);try{await p({key:C,label:h("settingsHub.savingSetting",{label:t})},async()=>c(j))}catch(E){S(E instanceof Error?E.message:String(E))}}return n.jsx(Z0,{description:s,disabled:d,id:e,label:t,children:n.jsxs("div",{className:"flex flex-col items-start gap-1 sm:items-end",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(pt,{"aria-describedby":`${e}-description${_?` ${e}-error`:""}`,"aria-invalid":!!_,className:"h-8 w-24 font-mono text-xs",disabled:d,id:e,max:l,min:a,onChange:j=>v(j.target.value),type:"number",value:b}),n.jsx(Q,{"aria-label":h("settingsHub.saveAria",{label:t}),disabled:d,loading:N,loadingLabel:h("settingsHub.saving"),onClick:()=>{A()},size:"sm",type:"button",variant:"outline",children:h("settingsHub.save")})]}),_?n.jsx("span",{className:"text-[11px] text-destructive",id:`${e}-error`,role:"alert",children:_}):null]})})}function wa({title:e,description:t,action:s}){return n.jsxs("div",{className:"settings-row flex flex-col items-stretch justify-between gap-3 border-b border-border/50 px-4 last:border-b-0 sm:flex-row sm:items-center sm:gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-medium",children:e}),n.jsx("p",{className:"mt-0.5 break-words text-xs leading-5 text-muted-foreground",children:t})]}),s?n.jsx("div",{className:"w-full shrink-0 [&_button]:w-full sm:w-auto sm:[&_button]:w-auto",children:s}):null]})}function gX({children:e}){return n.jsx("div",{className:"border border-dashed border-border bg-muted/30 px-4 py-3 text-xs leading-5 text-muted-foreground",children:e})}function bX({selected:e,onSelect:t,search:s,onSearch:i,saveState:a,saveError:l,children:c}){const d=J(),f=x.useRef([]),h=OA(e),g=h.icon;function p(b,v){let _=null;if(b.key==="ArrowDown"&&(_=(v+1)%Ji.length),b.key==="ArrowUp"&&(_=(v-1+Ji.length)%Ji.length),b.key==="Home"&&(_=0),b.key==="End"&&(_=Ji.length-1),_===null)return;b.preventDefault();const S=Ji[_];t(S.id),f.current[_]?.focus()}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2.5",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(kE,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm font-semibold",children:d("settingsHub.title")})]}),n.jsxs("div",{className:"relative ml-auto w-full sm:w-64",children:[n.jsx(Xx,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx("input",{"aria-label":d("settingsHub.searchAria"),className:"h-8 w-full rounded-md border border-input bg-background pl-8 pr-8 text-xs outline-none focus:ring-2 focus:ring-ring",onChange:b=>i(b.target.value),placeholder:d("settingsHub.searchPlaceholder"),type:"search",value:s}),s?n.jsx("button",{"aria-label":d("settingsHub.clearSearch"),className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>i(""),type:"button",children:n.jsx(Vt,{className:"size-3"})}):null]}),n.jsx(pX,{error:l,state:a})]}),n.jsxs("div",{className:"border-b border-border px-3 py-2 md:hidden",children:[n.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",htmlFor:"settings-category-select",children:d("settingsHub.category")}),n.jsx("select",{className:"h-9 w-full rounded-md border border-input bg-background px-2 text-sm",id:"settings-category-select",onChange:b=>t(b.target.value),value:e,children:Ji.map(b=>n.jsx("option",{value:b.id,children:d(gu(b.id))},b.id))})]}),n.jsxs("div",{className:"flex min-h-0 flex-1",children:[n.jsx("aside",{className:"hidden w-56 shrink-0 border-r border-border bg-muted/20 p-2 md:block",children:n.jsx("nav",{"aria-label":d("settingsHub.categoriesAria"),className:"space-y-0.5",children:Ji.map((b,v)=>{const _=b.icon,S=e===b.id;return n.jsxs("button",{"aria-current":S?"page":void 0,className:re("flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",S?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>t(b.id),onKeyDown:C=>p(C,v),ref:C=>{f.current[v]=C},tabIndex:S?0:-1,type:"button",children:[n.jsx(_,{className:"size-3.5"}),n.jsx("span",{children:d(gu(b.id))})]},b.id)})})}),n.jsx("main",{className:"min-w-0 flex-1 overflow-y-auto",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-3 py-4 sm:px-6 sm:py-6",children:[s?null:n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(g,{className:"size-4 text-muted-foreground"}),n.jsx("h2",{className:"text-base font-semibold",children:d(gu(h.id))})]}),n.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:d(dX(h.id))})]}),c]})})]})]})}function Qn({scope:e,title:t,children:s}){const i=J();return n.jsxs("section",{className:"mb-4 overflow-hidden rounded-lg border border-border bg-background/70",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-muted/25 px-4 py-2.5",children:[n.jsx("h3",{className:"text-xs font-semibold",children:t??i(e==="global"?"settingsHub.global":"settingsHub.currentProject")}),n.jsx(mX,{scope:e})]}),s]})}function qc({project:e,ready:t,loadError:s,onRetry:i}){const a=J();return e&&s?n.jsxs("div",{className:"border-b border-destructive/30 bg-destructive/5 px-4 py-3",role:"alert",children:[n.jsx("p",{className:"text-xs text-destructive",children:s}),n.jsx(Q,{"aria-label":a("settingsHub.retryProject"),className:"mt-2",onClick:i,size:"sm",type:"button",variant:"outline",children:a("settingsHub.retryProject")})]}):e&&!t?n.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-2 text-xs text-muted-foreground",children:a("settingsHub.loadingProject",{name:e.name})}):e?n.jsxs("div",{className:"border-b border-border/50 bg-amber-500/5 px-4 py-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"font-medium text-foreground",children:e.name})," · ",a("settingsHub.projectWritesPre"),n.jsx("code",{children:"nomoreide.config.json"}),a("settingsHub.projectWritesPost")]}):n.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-2 text-xs text-muted-foreground",children:a("settingsHub.selectProject")})}function vX({activeProject:e=null,onNavigate:t}={}){const s=J(),i=xm(),a=!!(e?.path&&e.path===i.activeProjectPath&&!i.projectLoading&&!i.projectLoadError),[l,c]=x.useState("general"),[d,f]=x.useState(""),h=d.trim().toLowerCase(),g=x.useMemo(()=>h?Ji.map(b=>({id:b.id,settingIds:fX(b.id,h,s)})).filter(b=>b.settingIds.length>0):[],[h,s]);let p;return i.loading?p=n.jsx("div",{"aria-label":s("settingsHub.loadingAria"),className:"space-y-3",role:"status",children:[0,1,2].map(b=>n.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-border bg-muted/40"},b))}):i.loadError?p=n.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",role:"alert",children:[n.jsx("p",{className:"text-sm font-medium",children:s("settingsHub.loadFailed")}),n.jsx("p",{className:"mt-1 text-xs text-destructive",children:i.loadError}),n.jsx(Q,{className:"mt-3",onClick:()=>{i.retry()},size:"sm",type:"button",variant:"outline",children:s("settingsHub.retry")})]}):h?p=n.jsxs("div",{children:[n.jsx("h2",{className:"mb-4 text-base font-semibold",children:s("settingsHub.searchResults")}),g.length?g.map(({id:b,settingIds:v})=>n.jsxs("div",{className:"mb-5",children:[n.jsx("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:s(gu(b))}),n.jsx(EC,{activeProject:e,category:b,onNavigate:t,projectReady:a,settings:i,visibleSettingIds:new Set(v)})]},b)):n.jsx(gX,{children:s("settingsHub.noMatches",{query:d.trim()})})]}):p=n.jsx(EC,{activeProject:e,category:l,onNavigate:t,projectReady:a,settings:i}),n.jsx(bX,{onSearch:f,onSelect:c,saveError:i.saveError,saveState:i.saveState,search:d,selected:l,children:p})}function EC({category:e,activeProject:t,projectReady:s,onNavigate:i,settings:a,visibleSettingIds:l}){const c=J(),d=!s,f=p=>!l||l.has(p),h=p=>p.some(f),g=p=>({label:c(DA(p)),description:c(LA(p))});switch(e){case"general":return n.jsxs(Qn,{scope:"global",children:[f("language")?n.jsx(Uc,{...g("language"),id:"setting-language",onChange:p=>a.updateUi({language:p}),options:Q$.map(p=>({value:p.value,label:p.nativeLabel,disabled:!p.available})),value:a.ui.language}):null,f("sidebar-docked")?n.jsx(io,{...g("sidebar-docked"),checked:a.ui.sidebarDocked,id:"setting-sidebar-docked",onChange:p=>a.updateUi({sidebarDocked:p})}):null,f("project-scope")?n.jsx(Uc,{...g("project-scope"),id:"setting-project-scope",onChange:p=>a.updateUi({projectScope:p}),options:[{value:"all",label:c("settingsHub.opt.allProjects")},{value:"project",label:c("settingsHub.currentProject")}],value:a.ui.projectScope}):null]});case"appearance":return n.jsxs(Qn,{scope:"global",children:[f("theme")?n.jsx(Uc,{...g("theme"),id:"setting-theme",onChange:p=>a.updateUi({theme:p}),options:[{value:"system",label:c("settingsHub.opt.system")},{value:"light",label:c("settingsHub.opt.light")},{value:"dark",label:c("settingsHub.opt.dark")}],value:a.ui.theme}):null,f("density")?n.jsx(Uc,{...g("density"),id:"setting-density",onChange:p=>a.updateUi({density:p}),options:[{value:"comfortable",label:c("settingsHub.opt.comfortable")},{value:"compact",label:c("settingsHub.opt.compact")}],value:a.ui.density}):null,f("code-font")?n.jsx(Mh,{...g("code-font"),id:"setting-code-font",max:18,min:10,onSave:p=>{a.updateUi({codeFontSize:p})},value:a.ui.codeFontSize}):null,f("reduced-motion")?n.jsx(io,{...g("reduced-motion"),checked:a.ui.reducedMotion,id:"setting-reduced-motion",onChange:p=>a.updateUi({reducedMotion:p})}):null]});case"terminal":return n.jsxs(Qn,{scope:"global",children:[f("terminal-font")?n.jsx(Mh,{...g("terminal-font"),id:"setting-terminal-font",max:24,min:10,onSave:p=>a.updateGlobal({terminal:{fontSize:p}}),value:a.global.terminal.fontSize}):null,f("cursor")?n.jsx(Uc,{...g("cursor"),id:"setting-cursor",onChange:p=>{a.updateGlobal({terminal:{cursorStyle:p}})},options:[{value:"block",label:c("settingsHub.opt.block")},{value:"underline",label:c("settingsHub.opt.underline")},{value:"bar",label:c("settingsHub.opt.bar")}],value:a.global.terminal.cursorStyle}):null,f("scrollback")?n.jsx(Mh,{...g("scrollback"),id:"setting-scrollback",max:1e5,min:500,onSave:p=>a.updateGlobal({terminal:{scrollback:p}}),value:a.global.terminal.scrollback}):null,f("copy-on-select")?n.jsx(io,{...g("copy-on-select"),checked:a.global.terminal.copyOnSelect,id:"setting-copy-on-select",onChange:p=>{a.updateGlobal({terminal:{copyOnSelect:p}})}}):null,f("confirm-terminate")?n.jsx(io,{...g("confirm-terminate"),checked:a.global.terminal.confirmTerminate,id:"setting-confirm-terminate",onChange:p=>{a.updateGlobal({terminal:{confirmTerminate:p}})}}):null]});case"services-logs":return n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),f("log-timestamps")?n.jsx(io,{...g("log-timestamps"),checked:a.project.logs.showTimestamps,disabled:d,id:"setting-log-timestamps",onChange:p=>{a.updateProject({logs:{showTimestamps:p}})}}):null,f("wrap-lines")?n.jsx(io,{...g("wrap-lines"),checked:a.project.logs.wrapLines,disabled:d,id:"setting-wrap-lines",onChange:p=>{a.updateProject({logs:{wrapLines:p}})}}):null]});case"git-github":return n.jsxs(n.Fragment,{children:[h(["github-connection"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{action:n.jsx(Q,{onClick:()=>i?.("github"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.manageGitHub")}),description:g("github-connection").description,title:g("github-connection").label})}):null,h(["repository-defaults"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("repository-defaults").description,title:g("repository-defaults").label})]}):null]});case"agents-mcp":return n.jsxs(n.Fragment,{children:[h(["agent-environments"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{action:n.jsx(Q,{onClick:()=>i?.("agent-env"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.openAgentEnv")}),description:g("agent-environments").description,title:g("agent-environments").label})}):null,h(["project-agent-context"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("project-agent-context").description,title:g("project-agent-context").label})]}):null]});case"database-safety":return n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),f("confirm-writes")?n.jsx(io,{...g("confirm-writes"),checked:a.project.database.confirmWrites,disabled:d,id:"setting-confirm-writes",onChange:p=>{a.updateProject({database:{confirmWrites:p}})}}):null,f("result-limit")?n.jsx(Mh,{...g("result-limit"),disabled:d,id:"setting-result-limit",max:5e3,min:10,onSave:p=>a.updateProject({database:{resultLimit:p}}),scopeKey:a.activeProjectPath,value:a.project.database.resultLimit}):null,f("connections")?n.jsx(wa,{action:n.jsx(Q,{disabled:d,onClick:()=>i?.("database"),size:"sm",type:"button",variant:"outline",children:c("settingsHub.openDatabase")}),description:g("connections").description,title:g("connections").label}):null]});case"notifications":{const p=typeof Notification>"u"?c("settingsHub.notifUnavailable"):c("settingsHub.notifPermission",{value:Notification.permission});return n.jsx(Qn,{scope:"global",children:f("desktop-notifications")?n.jsx(wa,{action:n.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:p}),description:g("desktop-notifications").description,title:g("desktop-notifications").label}):null})}case"data-privacy":return n.jsxs(n.Fragment,{children:[h(["local-storage"])?n.jsx(Qn,{scope:"global",children:n.jsx(wa,{description:g("local-storage").description,title:g("local-storage").label})}):null,h(["export-reset"])?n.jsxs(Qn,{scope:"project",children:[n.jsx(qc,{loadError:a.projectLoadError,onRetry:()=>{a.retryProject()},project:t,ready:s}),n.jsx(wa,{description:g("export-reset").description,title:g("export-reset").label})]}):null]});case"about":return n.jsx(Qn,{scope:"global",children:n.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-5 gap-y-2 px-4 py-4 text-xs",children:[f("version")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("version").label}),n.jsxs("code",{children:["v","0.1.88"]})]}):null,f("console")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("console").label}),n.jsx("code",{children:"127.0.0.1:4317"})]}):null,f("documentation")?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground",children:g("documentation").label}),n.jsxs("a",{className:"inline-flex items-center gap-1 text-primary hover:underline",href:"https://www.nomoreide.com/docs",rel:"noreferrer",target:"_blank",children:[n.jsx(oE,{className:"size-3"}),"nomoreide.com/docs",n.jsx(Pr,{className:"size-3"})]})]}):null]})})}}function xX(e,t){const s=t.trim().toLocaleLowerCase();return s?[e.service,e.title,e.file??"",...e.logExcerpt].some(i=>i.toLocaleLowerCase().includes(s)):!0}function yX(e,t,s){const i=new Set(s.levels),a=new Set(s.services);return e.filter(l=>xX(l,t)&&(i.size===0||i.has(l.level))&&(a.size===0||a.has(l.service)))}function _X(e){return{levels:[...new Set(e.map(({level:t})=>t))].sort(),services:[...new Set(e.map(({service:t})=>t))].sort()}}function wX(e){return e.levels.length+e.services.length}function SX({detailId:e,incident:t,onReviewChanges:s}){const i=J(),{sendToAgent:a}=Ot(),{isPending:l,runOperation:c}=In(),d=`error:${t.id}:fix`,f=l(d),[h,g]=x.useState(null);async function p(){await c({errorMessage:b=>b instanceof Error?b.message:String(b),key:d,label:i("errors.incident.fixingOperation",{service:t.service})},async()=>{const{prompt:b,sessionId:v}=await p7(t.id);a({prompt:b,source:{type:"error",label:`${t.service} — ${t.level}`},label:i("errors.incident.fixLabel",{level:t.level,service:t.service,title:t.title})}),g(v)})}return n.jsxs("div",{className:"min-w-0 rounded-lg border border-border bg-background","data-incident-detail":"true",id:e,children:[n.jsxs("div",{className:"px-4 py-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(We,{variant:t.level==="error"?"danger":"secondary",appearance:"subtle",size:"small",children:i(t.level==="error"?"errors.level.error":"errors.level.warning")}),n.jsx("span",{className:"truncate font-mono text-xs font-semibold",children:t.service}),t.count>1?n.jsxs(We,{variant:"outline",size:"small",children:["×",t.count]}):null]}),n.jsxs(Q,{loading:f,loadingLabel:i("errors.incident.starting"),onClick:()=>{p().catch(()=>{})},size:"sm",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"}),i("errors.incident.fixWithAi")]})]}),n.jsx("p",{className:"mt-1.5 break-words font-mono text-xs text-foreground",children:t.title}),t.file?n.jsxs("p",{className:"mt-1 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground",children:[n.jsx(pE,{className:"size-3.5"}),t.file,t.line?`:${t.line}`:""]}):null,n.jsx("p",{className:"mt-1 font-mono text-[10px] text-muted-foreground/80",children:i("errors.incident.firstLast",{first:new Date(t.firstSeen).toLocaleString(),last:new Date(t.lastSeen).toLocaleTimeString()})})]}),n.jsxs("div",{className:"border-t border-border p-4",children:[h?n.jsx(Ze,{variant:"muted",className:"mb-3",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs",children:i("errors.incident.working")}),s?n.jsxs(Q,{onClick:()=>s(h),size:"sm",variant:"outline",children:[n.jsx(mE,{className:"size-3.5"}),i("errors.incident.reviewChanges")]}):null]})}):null,n.jsx("p",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:i("errors.incident.logExcerpt")}),n.jsx("pre",{className:"overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-[11px] leading-relaxed",children:t.logExcerpt.join(`
|
|
119
119
|
`)}),n.jsx("p",{className:"mt-3 text-[11px] text-muted-foreground",children:i("errors.incident.explain")})]})]})}function kX({activeCount:e,levels:t,onClear:s,onToggleLevel:i,onToggleService:a,open:l,query:c,reduceMotion:d,selectedLevels:f,selectedServices:h,services:g}){const p=J(),b=d?{duration:0}:{duration:.16};return n.jsx($H,{initial:!1,children:l?n.jsxs(du.div,{animate:{height:"auto",opacity:1},className:"mt-3 grid gap-4 overflow-hidden rounded-lg border border-border bg-background p-3 md:grid-cols-2 lg:w-[280px] lg:grid-cols-1",exit:{height:0,opacity:0},initial:{height:0,opacity:0},transition:b,children:[n.jsx(jC,{format:v=>p(v==="error"?"errors.level.error":"errors.level.warning"),label:p("errors.filterSeverity"),onToggle:i,options:t,selected:f}),n.jsx(jC,{format:v=>v,label:p("errors.filterService"),onToggle:a,options:g,selected:h}),n.jsx(Q,{disabled:e===0&&!c,onClick:s,size:"sm",type:"button",variant:"ghost",children:p("errors.clearFilters")})]}):null})}function jC({format:e,label:t,onToggle:s,options:i,selected:a}){return n.jsxs("fieldset",{children:[n.jsx("legend",{className:"mb-2 text-xs font-semibold",children:t}),n.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(l=>{const c=a.includes(l);return n.jsx(Q,{"aria-pressed":c,onClick:()=>s(l),size:"sm",type:"button",variant:c?"secondary":"outline",children:e(l)},l)})})]})}function AC(e,t){return e.includes(t)?e.filter(s=>s!==t):[...e,t]}function CX({connected:e,error:t,incidents:s,onReviewChanges:i}){const[a,l]=x.useState(""),[c,d]=x.useState(()=>({levels:[],services:[]})),[f,h]=x.useState(!1),[g,p]=x.useState(null),b=Y$(),v=J(),_=x.useMemo(()=>_X(s),[s]),S=x.useMemo(()=>yX(s,a,c),[c,s,a]),C=wX(c),N=()=>{l(""),d({levels:[],services:[]})},A=b?{duration:0}:{duration:.16};return n.jsxs("section",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("header",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Au,{className:"size-4 text-muted-foreground"}),n.jsx("h2",{className:"text-sm font-semibold",children:v("errors.incidents")}),n.jsx(We,{appearance:"outline",size:"small",variant:"outline",children:v("errors.summary",{count:s.length})})]}),n.jsx(We,{appearance:"outline",icon:n.jsx("span",{className:re("inline-block size-1.5 rounded-full",e?"animate-pulse bg-emerald-500":"bg-muted-foreground/60")}),size:"small",variant:"outline",children:v(e?"errors.live":"errors.reconnecting")})]}),n.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-3",children:[n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx(Xx,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(pt,{"aria-label":v("errors.searchAria"),className:"pl-9",onChange:j=>l(j.target.value),placeholder:v("errors.searchPlaceholder"),type:"search",value:a})]}),n.jsxs(Q,{"aria-expanded":f,"aria-label":v(f?"errors.hideFilters":"errors.showFilters"),onClick:()=>h(j=>!j),size:"sm",type:"button",variant:"outline",children:[n.jsx(h8,{}),v("errors.filters"),C>0?n.jsx(We,{appearance:"solid",size:"small",variant:"primary",children:C}):null]})]}),n.jsx(kX,{activeCount:C,levels:_.levels,onClear:N,onToggleLevel:j=>d(E=>({...E,levels:AC(E.levels,j)})),onToggleService:j=>d(E=>({...E,services:AC(E.services,j)})),open:f,query:a,reduceMotion:b,selectedLevels:c.levels,selectedServices:c.services,services:_.services}),n.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:v("errors.resultCount",{shown:S.length,total:s.length})})]}),t?n.jsx("div",{className:"shrink-0 px-4 pt-3",children:n.jsx(Ze,{className:"border-destructive/40 text-destructive",variant:"muted",children:v("errors.loadFailed",{error:t})})}):null,n.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2 sm:p-4",children:s.length===0?n.jsx(TC,{body:v("errors.emptyBody"),title:v("errors.emptyTitle")}):S.length===0?n.jsx(TC,{body:v("errors.noMatchesBody"),title:v("errors.noMatchesTitle"),children:n.jsx(Q,{onClick:N,size:"sm",type:"button",variant:"outline",children:v("errors.clearFilters")})}):n.jsxs("table",{"aria-label":v("errors.tableAria"),className:"w-full table-fixed border-collapse",children:[n.jsx("thead",{className:"hidden border-b border-border text-left text-[10px] font-semibold uppercase tracking-wide text-muted-foreground md:table-header-group",children:n.jsxs("tr",{children:[n.jsx("th",{className:"w-24 px-3 py-2",scope:"col",children:v("errors.columnSeverity")}),n.jsx("th",{className:"w-36 px-3 py-2",scope:"col",children:v("errors.columnLatest")}),n.jsx("th",{className:"w-28 px-3 py-2",scope:"col",children:v("errors.columnService")}),n.jsx("th",{className:"px-3 py-2",scope:"col",children:v("errors.columnIncident")}),n.jsx("th",{className:"w-20 px-3 py-2",scope:"col",children:v("errors.columnCount")}),n.jsx("th",{className:"w-48 px-3 py-2",scope:"col",children:v("errors.columnSource")}),n.jsx("th",{className:"w-10 px-2 py-2",scope:"col",children:n.jsx("span",{className:"sr-only",children:v("errors.columnActions")})})]})}),n.jsx("tbody",{className:"divide-y divide-border",children:S.map(j=>{const E=j.id===g,T=`incident-detail-${j.id}`;return n.jsxs(x.Fragment,{children:[n.jsxs("tr",{className:"transition-colors hover:bg-muted/40 motion-reduce:transition-none","data-incident-id":j.id,children:[n.jsx("td",{className:"w-24 px-2 py-3 align-middle md:px-3",children:n.jsx(We,{appearance:"subtle",size:"small",variant:j.level==="error"?"danger":"warning",children:v(j.level==="error"?"errors.level.error":"errors.level.warning")})}),n.jsx("td",{className:"hidden px-3 py-3 align-middle font-mono text-[11px] text-muted-foreground md:table-cell",children:new Date(j.lastSeen).toLocaleString()}),n.jsx("td",{className:"hidden truncate px-3 py-3 align-middle font-mono text-xs font-semibold md:table-cell",children:j.service}),n.jsxs("td",{className:"min-w-0 px-2 py-3 align-middle md:px-3",children:[n.jsx("p",{className:"truncate text-xs font-medium",children:j.title}),n.jsxs("p",{className:"mt-0.5 truncate font-mono text-[10px] text-muted-foreground md:hidden",children:[j.service," · ",new Date(j.lastSeen).toLocaleString()]})]}),n.jsxs("td",{className:"hidden px-3 py-3 align-middle font-mono text-xs text-muted-foreground md:table-cell",children:["×",j.count]}),n.jsx("td",{className:"hidden truncate px-3 py-3 align-middle font-mono text-[11px] text-muted-foreground md:table-cell",children:j.file?`${j.file}${j.line?`:${j.line}`:""}`:v("common.none")}),n.jsx("td",{className:"w-10 px-2 py-3 align-middle",children:n.jsx(Q,{"aria-controls":T,"aria-expanded":E,"aria-label":v(E?"errors.collapseIncident":"errors.expandIncident",{title:j.title}),onClick:()=>p(E?null:j.id),size:"icon-sm",type:"button",variant:"ghost",children:n.jsx(hn,{className:re("transition-transform motion-reduce:transition-none",E&&"rotate-180")})})})]}),E?n.jsx("tr",{children:n.jsx("td",{className:"px-2 pb-3 md:px-3",colSpan:7,children:n.jsx(du.div,{animate:{opacity:1,y:0},initial:{opacity:0,y:b?0:-4},transition:A,children:n.jsx(SX,{detailId:T,incident:j,onReviewChanges:i})})})}):null]},j.id)})})]})})]})}function TC({body:e,children:t,title:s}){return n.jsx("div",{className:"flex min-h-64 items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"max-w-sm",children:[n.jsx(Au,{className:"mx-auto size-8 text-muted-foreground/50"}),n.jsx("p",{className:"mt-3 text-sm font-medium",children:s}),n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e}),t?n.jsx("div",{className:"mt-4",children:t}):null]})})}function RC(e){return[...e].sort((t,s)=>t.lastSeen<s.lastSeen?1:t.lastSeen>s.lastSeen?-1:s.id-t.id)}function NX(){const[e,t]=x.useState([]),[s,i]=x.useState(!1),[a,l]=x.useState(null),c=x.useCallback(d=>{t(f=>RC([...f.filter(h=>h.id!==d.id),d]))},[]);return x.useEffect(()=>{let d=!0;HE().then(h=>{d&&t(RC(h))}).catch(h=>{d&&l(h instanceof Error?h.message:String(h))});const f=new EventSource("/api/errors/stream");return f.addEventListener("open",()=>i(!0)),f.addEventListener("error",()=>i(!1)),f.addEventListener("incident",h=>{try{const g=JSON.parse(h.data);c(g)}catch{}}),()=>{d=!1,f.close()}},[c]),{incidents:e,connected:s,error:a}}function EX({inScope:e,onReviewChanges:t}={}){const{incidents:s,connected:i,error:a}=NX(),l=x.useMemo(()=>e?s.filter(c=>e(c.service)):s,[s,e]);return n.jsx(CX,{connected:i,error:a,incidents:l,onReviewChanges:t})}function Eu({label:e}){return n.jsx(Ze,{variant:"muted",className:"m-4 text-center",children:e})}const jX=900*1e3,su=12,Cb=200;function AX({events:e}){const t=J(),[s,i]=x.useState(null),[a,l]=x.useState(null),{rows:c,windowStart:d,windowEnd:f}=x.useMemo(()=>TX(e),[e]),h=s?c.find(g=>g.service===s)??null:null;return n.jsxs(n.Fragment,{children:[n.jsxs(wi,{className:"rounded-none border-0 border-b border-border bg-transparent",children:[n.jsxs(Si,{className:"border-b border-border px-3 py-2",children:[n.jsxs(ki,{className:"flex items-center gap-2",children:[n.jsx(go,{className:"size-3.5"}),t("services.timeline.title")]}),n.jsx(lr,{className:"text-xs",children:e.length===0?t("services.timeline.noEvents"):t("services.timeline.events",{count:e.length})})]}),n.jsx(Ci,{className:"p-0",children:c.length===0?n.jsx(Eu,{label:t("services.timeline.empty")}):n.jsxs("div",{className:"divide-y divide-border",children:[c.map(g=>n.jsx(MX,{onClick:()=>i(g.service),row:g,windowEnd:f,windowStart:d},g.service)),n.jsxs("div",{className:"flex justify-between px-3 py-1.5 font-mono text-[10px] text-muted-foreground",children:[n.jsx("span",{children:Df(d)}),n.jsx("span",{children:t("services.timeline.now")})]})]})})]}),h?n.jsx(zn,{icon:n.jsx(go,{}),onClose:()=>i(null),title:h.service,children:n.jsx(LX,{onSelect:l,row:h})}):null,a?n.jsx(zn,{icon:n.jsx(go,{}),onClose:()=>l(null),title:a.title,children:n.jsx(OX,{event:a})}):null]})}function TX(e){const t=Date.now(),s=t,i=t-jX;let a=e.filter(f=>{if(f.kind==="service.http")return!1;const h=new Date(f.timestamp).getTime();return!Number.isNaN(h)&&h>=i});a.length===0&&e.length>0?a=e.slice(-Cb):a.length>Cb&&(a=a.slice(-Cb));const l=new Map;for(const f of a){const h=f.service||"·system",g=l.get(h)??[];g.push(f),l.set(h,g)}const c=Math.max(s-i,1);return{rows:Array.from(l.entries()).map(([f,h])=>{const g=[...h].sort((A,j)=>A.timestamp.localeCompare(j.timestamp)),p=new Array(su).fill(0),b=new Array(su).fill(null);for(const A of g){const j=new Date(A.timestamp).getTime(),E=Math.max(i,Math.min(s,j)),T=Math.min(su-1,Math.floor((E-i)/c*su));p[T]+=1;const L=b[T];b[T]=RX(L,A.severity)}const v=g.filter(A=>A.severity==="error").length,_=g.filter(A=>A.severity==="warning").length,S=g.length-v-_,C=[...g].reverse().find(A=>A.severity!=="info")??null,N=v>0?"error":_>0?"warning":"info";return{service:f,events:g,errors:v,warnings:_,infos:S,buckets:p,bucketSeverity:b,lastNotable:C,worstSeverity:N}}).sort((f,h)=>{const g=b=>b.errors*1e3+b.warnings,p=g(h)-g(f);return p!==0?p:f.service.localeCompare(h.service)}),windowStart:i,windowEnd:s}}function RX(e,t){return e==="error"||t==="error"?"error":e==="warning"||t==="warning"?"warning":"info"}function MX({onClick:e,row:t,windowEnd:s,windowStart:i}){const a=J(),l=Math.max(1,...t.buckets);return n.jsxs("button",{className:"timeline-service-row block w-full px-3 py-2 text-left transition-colors hover:bg-muted/40 focus:outline-none focus-visible:bg-muted/40","data-testid":"timeline-service-row",onClick:e,type:"button",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:re("size-2 shrink-0 rounded-full",PA(t.worstSeverity))}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",dir:"rtl",children:n.jsx("bdi",{children:t.service})}),t.errors>0?n.jsxs("span",{className:"rounded bg-red-500/15 px-1 font-mono text-[10px] text-red-500",children:[t.errors,"E"]}):null,t.warnings>0?n.jsxs("span",{className:"rounded bg-amber-500/15 px-1 font-mono text-[10px] text-amber-500",children:[t.warnings,"W"]}):null,n.jsx(wn,{className:"size-3 text-muted-foreground"})]}),n.jsx("div",{className:"timeline-density mt-1.5 grid h-3 gap-px","data-testid":"timeline-density",style:{gridTemplateColumns:`repeat(${su}, minmax(0, 1fr))`},children:t.buckets.map((c,d)=>n.jsx(DX,{count:c,max:l,severity:t.bucketSeverity[d]},d))}),t.lastNotable?n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground",children:t.lastNotable.detail??t.lastNotable.title}):n.jsx("div",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:a("services.timeline.infoEvents",{count:t.infos})}),n.jsxs("div",{className:"mt-0.5 flex justify-between font-mono text-[9px] text-muted-foreground/60",children:[n.jsx("span",{children:Df(i)}),n.jsx("span",{children:Df(s)})]})]})}function DX({count:e,max:t,severity:s}){const i=J();if(e===0)return n.jsx("span",{className:"rounded-sm bg-border/60"});const a=Math.min(1,.35+e/t*.65);return n.jsx("span",{className:re("rounded-sm",PX(s)),style:{opacity:a},title:i("services.timeline.eventsCount",{count:e})})}function LX({onSelect:e,row:t}){const s=J(),i=[...t.events].sort((a,l)=>l.timestamp.localeCompare(a.timestamp));return n.jsxs("div",{className:"flex max-h-[480px] flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:s("services.timeline.eventsCount",{count:t.events.length})}),n.jsx("span",{children:"·"}),n.jsx("span",{children:s("services.timeline.errorsCount",{count:t.errors})}),n.jsx("span",{children:"·"}),n.jsx("span",{children:s("services.timeline.warningsCount",{count:t.warnings})})]}),n.jsx("ul",{className:"min-h-0 divide-y divide-border overflow-auto",children:i.map(a=>n.jsx("li",{children:n.jsxs("button",{className:"block w-full px-4 py-2 text-left hover:bg-muted/40 focus:outline-none focus-visible:bg-muted/40",onClick:()=>e(a),type:"button",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:re("size-2 shrink-0 rounded-full",PA(a.severity))}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:a.title}),n.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:Df(a.timestamp)})]}),a.detail?n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground",children:a.detail}):null]})},a.id))})]})}function OX({event:e}){const t=J(),s=new Date(e.timestamp);return n.jsxs("div",{className:"space-y-3 p-4 text-sm",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:re("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase text-white",zX(e.severity)),children:e.severity}),n.jsx("span",{className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:e.kind}),e.service?n.jsx("span",{className:"rounded border border-border bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground",children:e.service}):null]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:t("services.timeline.when")}),n.jsx("div",{className:"font-mono text-xs",children:Number.isNaN(s.getTime())?e.timestamp:s.toLocaleString()})]}),e.detail?n.jsxs("div",{children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:t("services.timeline.detail")}),n.jsx("pre",{className:"mt-1 max-h-72 overflow-auto whitespace-pre-wrap rounded border border-border bg-background p-3 font-mono text-xs",children:e.detail})]}):null]})}function PA(e){return e==="error"?"bg-red-500":e==="warning"?"bg-amber-500":"bg-zinc-400"}function PX(e){return e==="error"?"bg-red-500":e==="warning"?"bg-amber-500":"bg-zinc-500"}function zX(e){return e==="error"?"bg-red-600":e==="warning"?"bg-amber-600":"bg-zinc-700"}function Df(e){const t=typeof e=="number"?new Date(e):new Date(e);return Number.isNaN(t.getTime())?"--:--:--":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const Rx=150,Sl=40,MC=200,DC=64,Dh=20;function BX({statuses:e,health:t,hasDependencies:s,onSelectService:i}){const a=J(),[l,c]=x.useState(null),[d,f]=x.useState(null);x.useEffect(()=>{let p=!0;return c9().then(b=>{p&&c(b)}).catch(b=>{p&&f(b instanceof Error?b.message:String(b))}),()=>{p=!1}},[]);const h=x.useMemo(()=>l?IX(l.nodes):null,[l]);if(d)return n.jsx(Ze,{variant:"destructive",children:a("services.graph.loadError",{error:d})});if(!l||!h)return n.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"size-4 animate-spin"}),a("services.graph.loading")]});if(!s)return n.jsx("div",{className:"grid gap-3",children:n.jsxs(Ze,{variant:"muted",children:[n.jsx("div",{className:"font-medium",children:a("services.graph.noDeps")}),n.jsxs("div",{className:"mt-1 text-xs",children:[a("services.graph.noDepsHint1")," ",n.jsx("span",{className:"font-medium",children:a("services.graph.dependencies")}),a("services.graph.noDepsHint2")]})]})});const g=l.nodes.filter(p=>p.missing.length>0);return n.jsxs("div",{className:"grid gap-3",children:[l.cycles.length>0?n.jsxs(Ze,{variant:"destructive",children:[n.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[n.jsx(zr,{className:"size-4"}),a("services.graph.cycleDetected")]}),n.jsxs("div",{className:"mt-1 text-xs",children:[l.cycles.map(p=>p.join(" → ")).join("; "),". ",a("services.graph.cycleHint")]})]}):null,g.length>0?n.jsx(Ze,{variant:"muted",children:n.jsx("div",{className:"text-xs",children:g.map(p=>n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:p.name})," ",a(p.missing.length>1?"services.graph.dependsUnknownMany":"services.graph.dependsUnknownOne",{list:p.missing.join(", ")})]},p.name))})}):null,n.jsx("div",{className:"overflow-auto rounded-md border border-border bg-muted/20 p-2",children:n.jsxs("svg",{"aria-label":a("services.graph.aria"),height:h.height,role:"img",width:h.width,children:[h.edges.map(p=>n.jsx("path",{className:"fill-none stroke-border",d:p.path,strokeWidth:1.5},`${p.from}->${p.to}`)),h.nodes.map(p=>{const b=e[p.name],v=HX(b?.state,t[p.name]?.status);return n.jsxs("g",{"aria-label":a("services.graph.selectAria",{name:p.name}),className:"cursor-pointer",onClick:()=>i(p.name),transform:`translate(${p.x}, ${p.y})`,children:[n.jsx("rect",{className:re("stroke-2",v.fill,v.stroke),height:Sl,rx:6,width:Rx}),n.jsx("circle",{className:v.dot,cx:14,cy:Sl/2,r:4}),n.jsx("text",{className:"fill-foreground text-[11px] font-medium",dominantBaseline:"middle",x:26,y:Sl/2,children:$X(p.name)})]},p.name)})]})}),l.order.length>0?n.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"font-medium uppercase tracking-wide",children:a("services.graph.startOrder")})," ",l.order.join(" → ")]}):null]})}function IX(e){const t=new Map(e.map(p=>[p.name,p.dependsOn])),s=new Map,i=new Set,a=p=>{const b=s.get(p);if(b!==void 0)return b;if(i.has(p))return 0;i.add(p);const v=t.get(p)??[],_=v.length===0?0:Math.max(...v.map(S=>a(S)+1));return i.delete(p),s.set(p,_),_};for(const p of e)a(p.name);const l=new Map,c=e.map(p=>{const b=s.get(p.name)??0,v=l.get(b)??0;return l.set(b,v+1),{...p,x:Dh+b*MC,y:Dh+v*DC}}),d=new Map(c.map(p=>[p.name,p])),f=c.flatMap(p=>p.dependsOn.flatMap(b=>{const v=d.get(b);if(!v)return[];const _=v.x+Rx,S=v.y+Sl/2,C=p.x,N=p.y+Sl/2,A=(_+C)/2;return[{from:b,to:p.name,path:`M ${_} ${S} C ${A} ${S}, ${A} ${N}, ${C} ${N}`}]})),h=Math.max(0,...c.map(p=>s.get(p.name)??0)),g=Math.max(1,...l.values());return{nodes:c,edges:f,width:Dh*2+h*MC+Rx,height:Dh*2+(g-1)*DC+Sl}}function HX(e,t){return e==="running"?t==="warning"?{fill:"fill-amber-500/10",stroke:"stroke-amber-500/60",dot:"fill-amber-500"}:t==="unhealthy"?{fill:"fill-red-500/10",stroke:"stroke-red-500/60",dot:"fill-red-500"}:{fill:"fill-emerald-500/10",stroke:"stroke-emerald-500/60",dot:"fill-emerald-500"}:e==="starting"?{fill:"fill-amber-500/10",stroke:"stroke-amber-500/60",dot:"fill-amber-500"}:e==="exited"?{fill:"fill-red-500/10",stroke:"stroke-red-500/60",dot:"fill-red-500"}:{fill:"fill-card",stroke:"stroke-border",dot:"fill-muted-foreground"}}function $X(e,t=18){return e.length>t?`${e.slice(0,t-1)}…`:e}function FX({onOnboardRepo:e,onOnboardWithAi:t,onCreateService:s,onCreateWithAi:i}){const a=J();return n.jsx("div",{className:"flex h-full min-h-0 items-center justify-center overflow-auto bg-card/85 p-6",children:n.jsxs("div",{className:"w-full max-w-xl space-y-6",children:[n.jsxs("div",{className:"space-y-2 text-center",children:[n.jsx("h2",{className:"text-xl font-semibold",children:a("services.firstRun.title")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("services.firstRun.desc")})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(LC,{icon:n.jsx(_n,{className:"size-5"}),title:a("services.addFromGithub"),description:a("services.firstRun.githubDesc"),onClick:e,onAi:t,aiTitle:a("services.onboardWithAiHint")}),n.jsx(LC,{icon:n.jsx(ms,{className:"size-5"}),title:a("services.firstRun.createTitle"),description:a("services.firstRun.createDesc"),onClick:s,onAi:i,aiTitle:a("services.firstRun.createAiHint")})]})]})})}function LC({icon:e,title:t,description:s,onClick:i,onAi:a,aiTitle:l}){return n.jsxs("div",{className:"group flex items-stretch overflow-hidden rounded-lg border border-border bg-card shadow-sm transition-colors hover:border-foreground/20",children:[n.jsxs("button",{className:"flex flex-1 items-start gap-3 px-4 py-4 text-left hover:bg-muted/60",onClick:i,type:"button",children:[n.jsx("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:e}),n.jsxs("span",{className:"min-w-0 space-y-1",children:[n.jsx("span",{className:"block text-sm font-semibold",children:t}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:s})]})]}),n.jsxs("button",{className:"flex shrink-0 items-center gap-1.5 border-l border-border px-4 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",onClick:a,title:l,type:"button",children:[n.jsx(Xt,{className:"size-4 shrink-0"}),"AI"]})]})}function UX({health:e}){const t=J();if(!e)return null;const s=e.processTree,i=e.status==="healthy"||e.status==="unknown"?void 0:WX(e.summary);return n.jsxs("div",{className:"mt-1.5 grid min-w-0 gap-2 text-[11px] text-muted-foreground sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs("span",{className:re("inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-medium",qX(e.status)),children:[n.jsx("span",{className:"inline-flex shrink-0",children:n.jsx(go,{className:"size-3"})}),n.jsx("span",{className:"whitespace-nowrap",children:e.status})]}),i?n.jsx("span",{className:"min-w-0 truncate",children:i}):null]}),s?n.jsxs("div",{className:"health-metrics flex min-w-max items-center gap-2 font-mono sm:justify-end",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 font-mono",children:[n.jsx(JM,{className:"size-3"}),s.processCount," ",s.processCount===1?t("services.process"):t("services.processes")]}),n.jsxs("span",{children:[VX(s.cpuPercent)," CPU"]}),n.jsxs("span",{className:"inline-flex items-center gap-1 font-mono",children:[n.jsx(bD,{className:"size-3"}),GX(s.rssMb)," RAM"]})]}):null]})}function qX(e){return e==="healthy"?"bg-emerald-600 text-white":e==="warning"?"bg-amber-600 text-white":e==="unhealthy"?"bg-red-600 text-white":"bg-zinc-700 text-white"}function GX(e){return Number.isInteger(e)?`${e} MB`:`${e.toFixed(1)} MB`}function VX(e){return`${e.toFixed(1)}%`}function WX(e){return e.replace(/^Recent error log:\s*/i,"Recent stderr: ").replace(/:\s*\d+(?:\.\d+)? MB RSS\.?$/i,"").replace(/\s+RSS\.?$/i,"")}function KX({ports:e}){const t=J(),s=e.filter(a=>a.state==="occupied").length,i=e.filter(a=>a.state==="managed").length;return n.jsxs(wi,{className:"rounded-none border-0 border-b border-border bg-transparent",children:[n.jsxs(Si,{className:"border-b border-border px-3 py-2",children:[n.jsxs(ki,{className:"flex items-center gap-2",children:[n.jsx(ED,{className:"size-3.5"}),t("services.ports")]}),n.jsx(lr,{className:"text-xs",children:t("services.portsSummary",{managed:i,occupied:s})})]}),n.jsx(Ci,{className:"p-0",children:e.length?n.jsx("div",{className:"divide-y divide-border",children:e.map(a=>n.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-2 px-3 py-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"font-mono text-xs",children:[":",a.port]}),n.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:a.services.join(", ")||t("services.unassigned")}),a.urls[0]?n.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:a.urls[0]}):null]}),n.jsx(YX,{port:a})]},a.port))}):n.jsx(Eu,{label:t("services.noPorts")})})]})}function YX({compact:e,port:t}){const s=J(),i=t.state==="managed"?s("services.portManaged"):t.state==="occupied"?s("services.portOccupied"):s("services.portAvailable"),a=t.state==="managed"?"success":t.state==="occupied"?"warning":"outline";return n.jsx(We,{className:re(e&&"max-w-36 truncate"),variant:a,children:i})}function XX({onChange:e,value:t}){const s=J();return n.jsxs("div",{className:"relative block",children:[n.jsx(Xx,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(pt,{"aria-label":s("services.log.search"),className:"h-8 w-44 pl-7 text-xs",onChange:i=>e(i.target.value),placeholder:s("services.log.search"),value:t})]})}function ZX({className:e,containerRef:t,emptyText:s,logs:i,query:a,showTimestamps:l=!0,wrapLines:c=!0}){return n.jsx("div",{className:re("code-font-size h-full max-w-full overflow-auto bg-background font-mono leading-5 dark:bg-zinc-950",e),ref:t,role:"log",children:i.length?i.map((d,f)=>n.jsxs("div",{className:re("grid min-w-max gap-2 border-b border-border/45 px-3 py-0.5 dark:border-zinc-800/80",l?"grid-cols-[88px_minmax(420px,1fr)]":"grid-cols-[minmax(420px,1fr)]",d.stream==="stderr"?"bg-red-50/70 text-red-800 dark:bg-red-950/35 dark:text-red-100":"bg-emerald-50/35 text-zinc-800 dark:bg-zinc-950 dark:text-zinc-200 dark:odd:bg-zinc-900/45"),children:[l?n.jsx("span",{className:"text-muted-foreground dark:text-zinc-500",title:d.timestamp,children:QX(d.timestamp)}):null,n.jsxs("span",{className:c?"whitespace-pre-wrap break-words":"whitespace-pre",children:[d.stream==="stderr"?n.jsx("span",{className:"mr-2 rounded bg-red-100 px-1 font-semibold uppercase text-red-700 dark:bg-red-500/15 dark:text-red-300 dark:ring-1 dark:ring-red-400/20",children:"stderr"}):null,tZ(d.text,a)]})]},eZ(d,f))):n.jsx("div",{className:"p-3 text-muted-foreground",children:s})})}function QX(e){const t=/T(\d{2}:\d{2}:\d{2})(?:\.(\d{1,3}))?/.exec(e);return t?t[2]?`${t[1]}.${t[2]}`:t[1]:e}function JX(e){return`${e.timestamp} ${e.stream} ${e.text}`}function eZ(e,t){return e.cursor??`${e.service}-${e.timestamp}-${e.stream}-${t}`}function tZ(e,t){const s=t.trim();if(!s)return e;const i=e.toLowerCase(),a=s.toLowerCase(),l=[];let c=0,d=i.indexOf(a);for(;d!==-1;){d>c&&l.push(e.slice(c,d));const f=d+s.length;l.push(n.jsx("mark",{className:"rounded bg-amber-200 px-0.5 text-amber-950 dark:bg-amber-400/20 dark:text-amber-200",children:e.slice(d,f)},`${d}-${f}`)),c=f,d=i.indexOf(a,c)}return c<e.length&&l.push(e.slice(c)),l}function OC(e){return`${e.kind}:${e.name}`}function sZ(e,t=!1,s={}){const[i,a]=x.useState(),[l,c]=x.useState(),[d,f]=x.useState(e.kind==="source"),h=JSON.stringify(s);return x.useEffect(()=>{a(void 0),c(void 0);let g=!1;const p=async()=>{try{if(e.kind==="service"){const v=await YE(e.name,s);g||(a(v.logs),f(v.queryable),c(void 0))}else{const v=await VE(e.name,s);g||(a(v),f(!0),c(void 0))}}catch(v){g||c(v instanceof Error?v.message:String(v))}};p();const b=window.setInterval(p,t?1e3:2e3);return()=>{g=!0,window.clearInterval(b)}},[e.kind,e.name,t,h]),{logs:i,error:l,queryable:d}}const nZ=[{labelKey:"services.log.range.live",value:""},{labelKey:"services.log.range.15min",value:"15 min ago"},{labelKey:"services.log.range.hour",value:"1 hour ago"},{labelKey:"services.log.range.today",value:"today"},{labelKey:"services.log.range.24h",value:"1 day ago"},{labelKey:"services.log.range.7days",value:"7 days ago"}];function zA({target:e,query:t,setQuery:s,streaming:i,setStreaming:a,hideStdout:l,setHideStdout:c,fill:d=!1,leading:f,trailing:h}){const g=J(),b=ym()?.confirmedProject.logs??{showTimestamps:!0,wrapLines:!0},v=e.kind==="source",[_,S]=x.useState(""),[C,N]=x.useState(""),[A,j]=x.useState(t);x.useEffect(()=>{const K=window.setTimeout(()=>j(t),300);return()=>window.clearTimeout(K)},[t]);const E=x.useMemo(()=>{const K={};_&&(K.since=_),C&&(K.level=C);const xe=A.trim();return xe&&(K.grep=xe),K},[_,C,A]),{logs:T,error:L,queryable:H}=sZ(e,i,E),P=v||H,F=x.useRef(null),M=x.useRef(!0),[z,G]=x.useState([]),[D,q]=x.useState(!1),W=JSON.stringify(E);x.useEffect(()=>{G([])},[W,e.kind,e.name]);const I=x.useMemo(()=>{const K=T??[];if(z.length===0)return K;const xe=new Set(z.map(ie=>ie.cursor).filter(Boolean));return[...z,...K.filter(ie=>!ie.cursor||!xe.has(ie.cursor))]},[T,z]),Y=(z[0]??(T??[])[0])?.cursor;async function $(){if(!(!P||!Y||D)){q(!0),M.current=!1;try{const K={...E,before:Y,lines:200},xe=e.kind==="source"?await VE(e.name,K):(await YE(e.name,K)).logs;xe.length&&G(ie=>{const Z=new Set(ie.map(ne=>ne.cursor).filter(Boolean));return[...xe.filter(ne=>!ne.cursor||!Z.has(ne.cursor)),...ie]})}finally{q(!1)}}}const me=t.trim().toLowerCase(),ee=x.useMemo(()=>{let K=I;return l&&(K=K.filter(xe=>xe.stream==="stderr")),me&&(K=K.filter(xe=>JX(xe).toLowerCase().includes(me))),K},[I,l,me]);x.useEffect(()=>{const K=F.current;if(!K)return;const xe=()=>{const ie=K.scrollHeight-K.scrollTop-K.clientHeight;M.current=ie<40};return xe(),K.addEventListener("scroll",xe,{passive:!0}),()=>K.removeEventListener("scroll",xe)},[]),x.useEffect(()=>{if(!i||!M.current||ee.length===0)return;const K=F.current;K&&(K.scrollTop=K.scrollHeight)},[i,ee]);const V=T?me?g("services.log.noMatch",{query:t.trim()}):g(l?"services.log.noStderr":"services.log.noEntries"):g("common.loading");return n.jsxs("div",{className:d?"flex h-full min-h-0 flex-col gap-2":"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,n.jsx(XX,{onChange:s,value:t}),P?n.jsxs(n.Fragment,{children:[n.jsx("select",{"aria-label":g("services.log.timeRange"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs",onChange:K=>S(K.target.value),value:_,children:nZ.map(K=>n.jsx("option",{value:K.value,children:g(K.labelKey)},K.labelKey))}),n.jsxs("select",{"aria-label":g("services.log.level"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs",onChange:K=>N(K.target.value),value:C,children:[n.jsx("option",{value:"",children:g("services.log.allLevels")}),n.jsx("option",{value:"warn",children:g("services.log.warningsPlus")}),n.jsx("option",{value:"error",children:g("services.log.errors")})]})]}):n.jsxs(PC,{active:l,activeClassName:"border-amber-600 bg-amber-50 text-amber-700 dark:border-amber-400/40 dark:bg-amber-500/15 dark:text-amber-300",onClick:()=>c(!l),children:[n.jsx(S6,{}),g("services.log.errorsOnly")]}),n.jsxs(PC,{active:i,activeClassName:"border-emerald-600 bg-emerald-50 text-emerald-700 dark:border-emerald-400/40 dark:bg-emerald-500/15 dark:text-emerald-300",onClick:()=>a(!i),children:[n.jsx(WD,{}),g(i?"services.log.streaming":"services.log.stream")]}),P&&Y?n.jsxs(Q,{disabled:D,onClick:()=>{$()},size:"sm",type:"button",variant:"outline",children:[n.jsx(qf,{}),g(D?"common.loading":"services.log.loadOlder")]}):null,h?n.jsx("div",{className:"ml-auto flex items-center gap-2",children:h}):null]}),L?n.jsx("div",{className:"text-red-600",children:L}):null,n.jsx(ZX,{className:re("rounded border border-border/60",d?"min-h-0 flex-1":"max-h-80"),containerRef:F,emptyText:V,logs:ee,query:t,showTimestamps:b.showTimestamps,wrapLines:b.wrapLines})]})}function PC({active:e,activeClassName:t,children:s,onClick:i}){return n.jsx(Q,{"aria-pressed":e,className:e?t:void 0,onClick:i,size:"sm",type:"button",variant:"outline",children:s})}function iZ(e,t){return e.kind===t.kind&&e.name===t.name}function rZ({options:e,target:t,onChange:s,className:i}){const a=J(),l=e.findIndex(d=>iZ(d.target,t)),c=[...new Set(e.map(d=>d.group))];return n.jsx("select",{"aria-label":a("services.logSource"),className:i??"h-8 max-w-44 rounded-md border border-border bg-background px-2 text-xs",onChange:d=>s(e[Number(d.target.value)].target),value:String(l),children:c.map(d=>n.jsx("optgroup",{label:d,children:e.map((f,h)=>f.group===d?n.jsx("option",{value:String(h),children:f.label},`${f.group}:${f.label}`):null)},d))})}function aZ({serviceName:e}){const t=J(),[s,i]=x.useState(""),[a,l]=x.useState(!1),[c,d]=x.useState(!1),[f,h]=x.useState(!1),g=n.jsx(zA,{fill:!0,hideStdout:c,query:s,setHideStdout:d,setQuery:i,setStreaming:l,streaming:a,target:{kind:"service",name:e},trailing:n.jsx(Q,{"aria-label":t(f?"services.logsView.exitFs":"services.logsView.expand"),className:"text-muted-foreground hover:text-foreground",onClick:()=>h(p=>!p),size:"icon-sm",title:t(f?"services.fsExit":"services.fsExpand"),type:"button",variant:"ghost",children:f?n.jsx(Yx,{}):n.jsx(Kx,{})})});return f?n.jsx(Q0,{onClose:()=>h(!1),title:t("services.logsTitle",{name:e}),children:g}):n.jsx("div",{className:"h-[60vh] min-h-[24rem]",children:g})}function Q0({title:e,onClose:t,children:s,maxWidthClass:i="max-w-6xl"}){const a=J();return x.useEffect(()=>{function l(c){c.key==="Escape"&&t()}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t]),Hi.createPortal(n.jsx("div",{className:"fixed inset-0 z-[1000] bg-black/40 p-4 sm:p-8",onMouseDown:t,children:n.jsxs("div",{"aria-modal":"true",className:`mx-auto flex h-full ${i} flex-col overflow-hidden rounded-lg border border-border bg-card text-xs shadow-xl`,onMouseDown:l=>l.stopPropagation(),role:"dialog",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-2",children:[n.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:e}),n.jsx(Q,{"aria-label":a("services.closeLogs"),onClick:t,size:"icon",type:"button",variant:"ghost",children:n.jsx(Vt,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 p-3",children:s})]})}),document.body)}const oZ={journald:"services.log.hint.journald",docker:"services.log.hint.docker",ssh:"services.log.hint.ssh",file:"services.log.hint.file",command:"services.log.hint.command"};function lZ({onClose:e,onAdded:t}){const s=J(),[i,a]=x.useState(""),[l,c]=x.useState("journald"),[d,f]=x.useState(""),[h,g]=x.useState(""),[p,b]=x.useState(""),[v,_]=x.useState(""),[S,C]=x.useState(""),[N,A]=x.useState(""),[j,E]=x.useState(),[T,L]=x.useState(!1);async function H(){L(!0),E(void 0);try{const P={name:i.trim(),kind:"command"};l==="file"?(P.kind="file",P.path=h.trim()):l==="ssh"?(P.kind="ssh",P.host=d.trim(),P.path=h.trim()):l==="command"?(P.kind="command",P.command=p.trim(),v.trim()&&(P.cwd=v.trim())):l==="journald"?(P.driver="journald",P.unit=S.trim(),d.trim()&&(P.host=d.trim())):l==="docker"&&(P.driver="docker",P.container=N.trim(),d.trim()&&(P.host=d.trim()));const F=await J7(P);t(F,P.name),e()}catch(P){E(P instanceof Error?P.message:String(P))}finally{L(!1)}}return n.jsx(zn,{icon:n.jsx(Xf,{}),onClose:e,size:"md",title:s("services.log.addSourceTitle"),children:n.jsxs("form",{className:"flex flex-col gap-3 p-4 text-xs",onSubmit:P=>{P.preventDefault(),H()},children:[n.jsx(Rr,{label:s("services.log.name"),children:n.jsx(pt,{autoFocus:!0,onChange:P=>a(P.target.value),placeholder:"PROD",value:i})}),n.jsxs(Rr,{label:s("services.log.type"),children:[n.jsxs("select",{className:"h-9 w-full rounded-md border border-border bg-background px-2 text-xs",onChange:P=>c(P.target.value),value:l,children:[n.jsx("option",{value:"journald",children:s("services.log.typeJournald")}),n.jsx("option",{value:"docker",children:s("services.log.typeDocker")}),n.jsx("option",{value:"ssh",children:s("services.log.typeSsh")}),n.jsx("option",{value:"file",children:s("services.log.typeFile")}),n.jsx("option",{value:"command",children:s("services.log.typeCommand")})]}),n.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:s(oZ[l])})]}),l==="journald"||l==="docker"?n.jsx(Rr,{label:s("services.log.hostOptional"),children:n.jsx(pt,{onChange:P=>f(P.target.value),placeholder:"jobjourney-prod (an alias from ~/.ssh/config)",value:d})}):null,l==="journald"?n.jsx(Rr,{label:s("services.log.unit"),children:n.jsx(pt,{onChange:P=>C(P.target.value),placeholder:"jobjourney",value:S})}):null,l==="docker"?n.jsx(Rr,{label:s("services.log.container"),children:n.jsx(pt,{onChange:P=>A(P.target.value),placeholder:"brainctl-api",value:N})}):null,l==="ssh"?n.jsx(Rr,{label:s("services.log.host"),children:n.jsx(pt,{onChange:P=>f(P.target.value),placeholder:"prod (an alias from ~/.ssh/config)",value:d})}):null,l==="file"||l==="ssh"?n.jsx(Rr,{label:s(l==="ssh"?"services.log.remotePath":"services.log.filePath"),children:n.jsx(pt,{onChange:P=>g(P.target.value),placeholder:"/var/log/app/out.log",value:h})}):null,l==="command"?n.jsxs(n.Fragment,{children:[n.jsx(Rr,{label:s("services.log.command"),children:n.jsx(pt,{onChange:P=>b(P.target.value),placeholder:"kubectl logs -l app=myapp --tail 500",value:p})}),n.jsx(Rr,{label:s("services.log.cwdOptional"),children:n.jsx(pt,{onChange:P=>_(P.target.value),placeholder:"/srv/app",value:v})})]}):null,j?n.jsx("div",{className:"text-red-600",children:j}):null,n.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[n.jsx(Q,{onClick:e,size:"sm",type:"button",variant:"outline",children:s("common.cancel")}),n.jsx(Q,{disabled:T||!i.trim(),size:"sm",type:"submit",children:s(T?"common.saving":"services.log.addSource")})]})]})})}function Rr({label:e,children:t}){return n.jsxs("label",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"font-medium text-muted-foreground",children:e}),t]})}const zC=4;function cZ({services:e,initialService:t,onClose:s}){const i=J(),[a,l]=x.useState([]),[c,d]=x.useState(!1),[f,h]=x.useState(()=>[0]),[g,p]=x.useState(()=>{const E=t?{kind:"service",name:t}:e[0]?{kind:"service",name:e[0]}:void 0;return E?{0:E}:{}}),b=x.useRef(1);x.useEffect(()=>{let E=!1;return Q7().then(T=>{E||l(T)}),()=>{E=!0}},[]);const v=[...e.map(E=>({target:{kind:"service",name:E},label:E,group:i("services.title")})),...a.map(E=>({target:{kind:"source",name:E.name},label:E.name,group:i("services.log.sourcesGroup")}))],_=v.map(E=>E.target);function S(){if(f.length>=zC||_.length===0)return;const E=b.current++,T=new Set(Object.values(g).map(OC)),L=_.find(H=>!T.has(OC(H)))??_[0];h(H=>[...H,E]),p(H=>({...H,[E]:L}))}function C(E){h(T=>T.filter(L=>L!==E)),p(T=>{const L={...T};return delete L[E],L})}function N(E,T){p(L=>({...L,[E]:T}))}function A(E,T){l(E);const L=f[0];L!==void 0&&N(L,{kind:"source",name:T})}const j=n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{children:i("services.logs")}),n.jsxs(Q,{onClick:()=>d(!0),size:"sm",type:"button",variant:"outline",children:[n.jsx(ms,{}),i("services.log.addSource")]}),n.jsxs(Q,{disabled:f.length>=zC||_.length===0,onClick:S,size:"sm",type:"button",variant:"outline",children:[n.jsx(ms,{}),i("services.log.addPane")]})]});return n.jsxs(n.Fragment,{children:[n.jsx(Q0,{maxWidthClass:"max-w-[1500px]",onClose:s,title:j,children:_.length===0?n.jsx("div",{className:"grid h-full place-items-center text-center text-muted-foreground",children:n.jsxs("div",{children:[n.jsx("p",{children:i("services.log.noneYet")}),n.jsxs(Q,{className:"mt-2",onClick:()=>d(!0),size:"sm",type:"button",children:[n.jsx(ms,{}),i("services.log.addLogSource")]})]})}):n.jsx("div",{className:re("grid h-full min-h-0 gap-3",f.length>1?"lg:grid-cols-2":"grid-cols-1",f.length>2?"lg:grid-rows-2":"grid-rows-1"),children:f.map(E=>n.jsx(uZ,{onChangeTarget:T=>N(E,T),onRemove:f.length>1?()=>C(E):void 0,options:v,target:g[E]??_[0]},E))})}),c?n.jsx(lZ,{onAdded:A,onClose:()=>d(!1)}):null]})}function uZ({options:e,target:t,onChangeTarget:s,onRemove:i}){const a=J(),[l,c]=x.useState(""),[d,f]=x.useState(!0),[h,g]=x.useState(!1);return n.jsx("div",{className:"flex min-h-0 min-w-0 flex-col rounded-lg border border-border bg-background/60 p-2",children:n.jsx(zA,{fill:!0,hideStdout:h,leading:n.jsx(rZ,{onChange:s,options:e,target:t}),query:l,setHideStdout:g,setQuery:c,setStreaming:f,streaming:d,target:t,trailing:i?n.jsx(Q,{"aria-label":a("services.log.removePane"),onClick:i,size:"icon",type:"button",variant:"ghost",children:n.jsx(Vt,{})}):void 0})})}function dZ({runtime:e,reloading:t,onReload:s}){const i=J();if(!e?.stale)return null;const a=e.staleFiles,l=a.length===1?i("services.env.staleOne",{file:a[0].relativePath}):i("services.env.staleMany",{count:a.length});return n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-amber-700 dark:text-amber-400",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(zr,{className:"size-4 shrink-0"}),n.jsx("span",{children:i("services.env.staleBanner",{summary:l})})]}),n.jsxs(Q,{disabled:t,onClick:s,size:"sm",type:"button",variant:"outline",children:[n.jsx(ZD,{})," ",i(t?"services.env.reloading":"services.env.reloadService")]})]})}function hZ({rows:e,revealAll:t,onAdd:s,onRemove:i,onUpdate:a}){const l=J();return e.length===0?n.jsxs("div",{className:"text-muted-foreground",children:[l("services.env.noVars")," ",n.jsx("button",{className:"underline",onClick:s,type:"button",children:l("services.env.addOne")}),"."]}):n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full font-mono text-[11px]",children:[n.jsx("thead",{className:"text-left text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"py-1 pr-3",children:l("services.env.key")}),n.jsx("th",{className:"py-1 pr-3",children:l("services.env.value")}),n.jsx("th",{className:"py-1 w-8"})]})}),n.jsx("tbody",{children:e.map((c,d)=>{const f=!c.reveal&&!t;return n.jsxs("tr",{className:"border-t border-border/40",children:[n.jsx("td",{className:"py-1 pr-3 align-top",children:n.jsx("input",{className:"w-full rounded border border-border/60 bg-background px-1.5 py-0.5 font-mono",onChange:h=>a(d,{key:h.target.value}),placeholder:"KEY",spellCheck:!1,value:c.key})}),n.jsx("td",{className:"py-1 pr-3 align-top",children:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("input",{className:"w-full rounded border border-border/60 bg-background px-1.5 py-0.5 font-mono",onChange:h=>a(d,{value:h.target.value}),spellCheck:!1,type:f?"password":"text",value:c.value}),n.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>a(d,{reveal:!c.reveal}),title:c.reveal||t?l("services.env.hide"):l("services.env.reveal"),type:"button",children:c.reveal||t?n.jsx(Ux,{size:14}):n.jsx(Wf,{size:14})})]})}),n.jsx("td",{className:"py-1 align-top",children:n.jsx("button",{className:"text-muted-foreground hover:text-red-600",onClick:()=>i(d),type:"button",children:n.jsx(Ii,{size:14})})})]},d)})})]})})}function fZ({serviceName:e,onClose:t,onPick:s}){const i=J(),[a,l]=x.useState(),[c,d]=x.useState(),[f,h]=x.useState(!0),[g,p]=x.useState();x.useEffect(()=>{let _=!1;return h(!0),d(void 0),(async()=>{try{const S=await f9(e,g);_||l(S)}catch(S){_||d(S instanceof Error?S.message:String(S))}finally{_||h(!1)}})(),()=>{_=!0}},[e,g]);function b(_){if(_.kind==="directory"){p(_.relativePath);return}_.supported&&s(_.relativePath)}function v(){if(!a||a.isRoot)return;const _=a.relativePath,S=_.includes("/")?_.slice(0,_.lastIndexOf("/")):"";p(S||void 0)}return n.jsx(zn,{icon:n.jsx(Kf,{}),onClose:t,size:"lg",title:i("services.fileBrowser.title"),children:n.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.jsxs(Q,{disabled:!a||a.isRoot,onClick:v,size:"sm",type:"button",variant:"outline",children:[n.jsx(qf,{})," ",i("services.fileBrowser.up")]}),n.jsx("code",{className:"truncate rounded bg-muted px-2 py-1 font-mono",children:a?.relativePath||"./"})]}),c?n.jsx("div",{className:"text-red-600",children:c}):f?n.jsx("div",{className:"text-muted-foreground",children:i("common.loading")}):!a||a.entries.length===0?n.jsx("div",{className:"text-muted-foreground",children:i("services.fileBrowser.empty")}):n.jsx("div",{className:"max-h-[50vh] overflow-auto rounded border border-border/60",children:n.jsx("ul",{className:"divide-y divide-border/40",children:a.entries.map(_=>{const S=_.kind==="directory",C=S||_.supported;return n.jsx("li",{children:n.jsxs("button",{className:re("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs",C?"hover:bg-muted":"cursor-not-allowed text-muted-foreground"),disabled:!C,onClick:()=>b(_),type:"button",children:[S?n.jsx(Co,{size:14}):n.jsx(gE,{size:14}),n.jsx("span",{className:"flex-1 truncate font-mono",children:_.name}),!S&&_.format?n.jsx(We,{size:"small",variant:"secondary",children:_.format}):null]})},_.relativePath)})})}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[i("services.fileBrowser.hintPre")," ",n.jsx("code",{children:".env*"}),", ",n.jsx("code",{children:"appsettings*.json"})," ",i("services.fileBrowser.hintAnd")," ",n.jsx("code",{children:"application*.yml"}),i("services.fileBrowser.hintTail")]})]})})}function mZ(e){const{error:t,success:s}=cs(),[i,a]=x.useState(),[l,c]=x.useState(!1),d=x.useCallback(async()=>{try{a(await b9(e))}catch{a(void 0)}},[e]);x.useEffect(()=>{d()},[d]);const f=x.useCallback(async()=>{c(!0);try{await KE(e),s(`Reloaded ${e} with the latest configuration.`),await d()}catch(h){t(h instanceof Error?h.message:String(h))}finally{c(!1)}},[e,d,t,s]);return{runtime:i,reloading:l,refresh:d,reload:f}}function BA(e){if(!e.trim())return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function pZ(e){const{error:t,success:s}=cs(),[i,a]=x.useState([]),[l,c]=x.useState(),[d,f]=x.useState(),[h,g]=x.useState(!0),[p,b]=x.useState(!1),[v,_]=x.useState(!1),[S,C]=x.useState(!1),[N,A]=x.useState();x.useEffect(()=>{let M=!1;return g(!0),A(void 0),(async()=>{try{const z=await m9(e);if(M)return;a(z.files),z.files.length>0?c(G=>G??z.files[0].path):(c(void 0),f(void 0))}catch(z){M||A(z instanceof Error?z.message:String(z))}finally{M||g(!1)}})(),()=>{M=!0}},[e]);const j=x.useCallback(async M=>{b(!0),A(void 0);try{const z=await yS(e,M),G={path:z.path,relativePath:z.relativePath,format:z.format};z.format==="env"?f({info:G,exists:z.exists,rows:z.entries.map(D=>({...D,reveal:!1}))}):f({info:G,exists:z.exists,text:z.format==="json"?BA(z.content):z.content}),C(!1)}catch(z){A(z instanceof Error?z.message:String(z))}finally{b(!1)}},[e]);x.useEffect(()=>{l&&j(l)},[l,j]);function E(M,z){f(G=>{if(!G?.rows)return G;const D=G.rows.map((q,W)=>W===M?{...q,...z}:q);return{...G,rows:D}}),C(!0)}function T(){f(M=>M?.rows?{...M,rows:[...M.rows,{key:"",value:"",secret:!1,reveal:!0}]}:M),C(!0)}function L(M){f(z=>z?.rows?{...z,rows:z.rows.filter((G,D)=>D!==M)}:z),C(!0)}function H(M){f(z=>z&&{...z,text:M}),C(!0)}async function P(){if(d){_(!0);try{if(d.info.format==="env"&&d.rows){const M=await p9(e,d.info.path,d.rows.map(z=>({key:z.key.trim(),value:z.value})));f({info:{path:M.path,relativePath:M.relativePath,format:M.format},exists:M.exists,rows:M.entries.map(z=>({...z,reveal:!1}))}),s(`Saved ${M.entries.length} entries to ${M.relativePath}.`)}else if(d.text!==void 0){const M=await g9(e,d.info.path,d.text);f({info:{path:M.path,relativePath:M.relativePath,format:M.format},exists:M.exists,text:M.content}),s(`Saved ${M.relativePath}.`)}C(!1)}catch(M){t(M instanceof Error?M.message:String(M))}finally{_(!1)}}}async function F(M){try{const z=await yS(e,M),G={path:z.path,relativePath:z.relativePath,format:z.format};return a(D=>D.some(q=>q.path===G.path)?D:[...D,G]),c(G.path),s(`Loaded ${G.relativePath}.`),!0}catch(z){return t(z instanceof Error?z.message:String(z)),!1}}return{files:i,selectedPath:l,setSelectedPath:c,loaded:d,loadingList:h,loadingFile:p,saving:v,dirty:S,error:N,addRow:T,removeRow:L,updateRow:E,updateText:H,save:P,pickFile:F}}function gZ({serviceName:e}){const t=J(),{files:s,selectedPath:i,setSelectedPath:a,loaded:l,loadingList:c,loadingFile:d,saving:f,dirty:h,error:g,addRow:p,removeRow:b,updateRow:v,updateText:_,save:S,pickFile:C}=pZ(e),N=mZ(e),[A,j]=x.useState(!1),[E,T]=x.useState(!1);async function L(){await S(),await N.refresh()}return c?n.jsx("div",{className:"text-muted-foreground",children:t("common.loading")}):g&&!l?n.jsx("div",{className:"text-red-600",children:g}):n.jsxs("div",{className:"space-y-2",children:[n.jsx(dZ,{onReload:()=>{N.reload()},reloading:N.reloading,runtime:N.runtime}),n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:t("services.env.file")}),s.length>0?n.jsx("select",{className:"rounded border border-border/60 bg-background px-1.5 py-0.5 font-mono text-xs",onChange:H=>a(H.target.value),value:i??"",children:s.map(H=>n.jsxs("option",{value:H.path,children:[H.relativePath," [",H.format,"]"]},H.path))}):n.jsx("span",{className:"text-muted-foreground",children:t("services.env.noneDetected")}),n.jsxs(Q,{onClick:()=>T(!0),size:"sm",type:"button",variant:"outline",children:[n.jsx(Kf,{})," ",t("services.env.browseFiles")]}),l?n.jsx("code",{className:"rounded bg-background px-1.5 py-0.5 font-mono text-muted-foreground",children:l.info.path}):null]}),n.jsxs("div",{className:"flex items-center gap-1",children:[l?.info.format==="env"?n.jsxs(n.Fragment,{children:[n.jsxs(Q,{onClick:()=>j(H=>!H),size:"sm",type:"button",variant:"outline",children:[A?n.jsx(Ux,{}):n.jsx(Wf,{}),t(A?"services.env.hideSecrets":"services.env.revealSecrets")]}),n.jsxs(Q,{onClick:p,size:"sm",type:"button",variant:"outline",children:[n.jsx(ms,{})," ",t("common.add")]})]}):null,n.jsxs(Q,{disabled:!h||f||!l,onClick:()=>{L()},size:"sm",type:"button",children:[n.jsx(SE,{})," ",t(f?"common.saving":"common.save")]})]})]}),g&&!l?n.jsx("div",{className:"text-red-600",children:g}):l?.info.format==="env"&&l.rows?n.jsx("div",{className:re(d&&"opacity-60 transition-opacity"),children:n.jsx(hZ,{revealAll:A,rows:l.rows,onAdd:p,onRemove:b,onUpdate:v})}):l?.text!==void 0?n.jsxs("div",{className:re("space-y-1",d&&"opacity-60 transition-opacity"),children:[l.info.format==="json"?n.jsx("div",{className:"flex justify-end",children:n.jsx(Q,{onClick:()=>_(BA(l.text??"")),size:"sm",type:"button",variant:"outline",children:t("services.env.formatJson")})}):null,n.jsx("textarea",{className:"min-h-[300px] w-full rounded border border-border/60 bg-background p-2 font-mono text-[11px] leading-relaxed",onChange:H=>_(H.target.value),spellCheck:!1,value:l.text})]}):d?n.jsx("div",{className:"text-muted-foreground",children:t("services.env.loadingFile")}):null,l?n.jsxs("p",{className:"text-muted-foreground",children:[l.info.format==="env"?t("services.env.preservedEnv"):l.info.format==="json"?t("services.env.validatedJson"):t("services.env.rawYaml")," ",t("services.env.restartHint")]}):null,E?n.jsx(fZ,{onClose:()=>T(!1),onPick:H=>{C(H).then(P=>{P&&T(!1)})},serviceName:e}):null]})}function bZ({serviceName:e,status:t,timeline:s,onRefresh:i}){const a=J(),{error:l,success:c}=cs(),[d,f]=x.useState(!1),h=t?.inspector,g=t?.state==="running",p=x.useMemo(()=>s.filter(_=>_.kind==="service.http"&&_.service===e).map(_=>{const S=_.data??{};return{id:S.id??_.id,startedAt:_.timestamp,method:S.method??"?",path:S.path??"?",status:S.status??0,durationMs:S.durationMs??0,reqBytes:S.reqBytes??0,resBytes:S.resBytes??0}}).slice(-500).reverse(),[s,e]);async function b(_){f(!0);try{await zi(`/api/services/${encodeURIComponent(e)}/inspector`,{enabled:_?"true":"false"}),await i(),c(_?a("services.http.started",{name:e}):a("services.http.stopped",{name:e}))}catch(S){l(S instanceof Error?S.message:String(S))}finally{f(!1)}}if(!g)return n.jsx("div",{className:"text-muted-foreground",children:a("services.http.notRunning")});if(!h?.enabled)return n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-muted-foreground",children:a("services.http.intro")}),n.jsxs(Q,{disabled:d,onClick:()=>b(!0),size:"sm",type:"button",children:[n.jsx(or,{})," ",a("services.http.start")]})]});const v=h.port?`http://127.0.0.1:${h.port}`:void 0;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:a("services.http.inspectUrl")}),v?n.jsxs(n.Fragment,{children:[n.jsx("code",{className:"rounded bg-background px-1.5 py-0.5 font-mono",children:v}),n.jsxs(Q,{onClick:()=>{navigator.clipboard.writeText(v),c(a("services.http.copiedUrl"))},size:"sm",type:"button",variant:"outline",children:[n.jsx(nf,{})," ",a("common.copy")]}),n.jsx(Q,{onClick:()=>{em(v)},size:"sm",type:"button",variant:"outline",children:a("common.open")})]}):n.jsx("span",{className:"text-muted-foreground",children:a("services.startingEllipsis")}),n.jsx("span",{className:"text-muted-foreground",children:a("services.http.upstream",{port:h.upstreamPort??"?"})}),n.jsxs(Q,{disabled:d,onClick:()=>b(!1),size:"sm",type:"button",variant:"outline",children:[n.jsx(Ta,{})," ",a("common.stop")]})]}),p.length===0?n.jsx("div",{className:"text-muted-foreground",children:a("services.http.noRequests")}):n.jsx("div",{className:"max-h-80 overflow-auto",children:n.jsxs("table",{className:"w-full font-mono text-[11px]",children:[n.jsx("thead",{className:"sticky top-0 bg-muted/60 text-left text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"py-1 pr-3",children:a("services.http.time")}),n.jsx("th",{className:"py-1 pr-3",children:a("services.http.method")}),n.jsx("th",{className:"py-1 pr-3",children:a("services.http.path")}),n.jsx("th",{className:"py-1 pr-3 text-right",children:a("services.http.status")}),n.jsx("th",{className:"py-1 pr-3 text-right",children:a("services.http.size")}),n.jsx("th",{className:"py-1 pr-3 text-right",children:"ms"})]})}),n.jsx("tbody",{children:p.map(_=>n.jsxs("tr",{className:"border-t border-border/40",children:[n.jsx("td",{className:"py-1 pr-3 text-muted-foreground",children:new Date(_.startedAt).toLocaleTimeString()}),n.jsx("td",{className:"py-1 pr-3",children:_.method}),n.jsx("td",{className:"py-1 pr-3 truncate max-w-[40ch]",children:_.path}),n.jsx("td",{className:re("py-1 pr-3 text-right",vZ(_.status)),children:_.status}),n.jsx("td",{className:"py-1 pr-3 text-right text-muted-foreground",children:xZ(_.resBytes)}),n.jsx("td",{className:"py-1 pr-3 text-right",children:_.durationMs.toFixed(1)})]},_.id))})]})})]})}function vZ(e){return e>=500?"text-red-600 dark:text-red-400":e>=400?"text-amber-600 dark:text-amber-400":e>=300?"text-zinc-500":e>=200?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}function xZ(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yZ({serviceName:e}){const t=J(),[s,i]=x.useState(null),[a,l]=x.useState(null),[c,d]=x.useState(()=>Date.now());return x.useEffect(()=>{let f=!1;async function h(){try{const p=await v9(e);f||(i(p),d(Date.now()),l(null))}catch(p){f||l(p instanceof Error?p.message:String(p))}}h();const g=setInterval(()=>{h()},3e3);return()=>{f=!0,clearInterval(g)}},[e]),a?n.jsx("p",{className:"text-destructive",children:t("services.metrics.loadError",{error:a})}):s?s.samples.length===0?n.jsx("p",{className:"text-muted-foreground",children:t("services.metrics.noSamples")}):n.jsx(_Z,{series:s,now:c}):n.jsx("p",{className:"text-muted-foreground",children:t("services.metrics.loading")})}function _Z({series:e,now:t}){const s=J(),{samples:i}=e,a=x.useMemo(()=>BC(i,h=>h.cpu),[i]),l=x.useMemo(()=>BC(i,h=>h.rss),[i]),c=e.startedAt?new Date(e.startedAt):null,d=c?t-c.getTime():null,f=i.length>1?i[i.length-1].t-i[0].t:0;return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[n.jsx(Lh,{accent:"#22c55e",label:"CPU",value:`${a.last.toFixed(1)}%`,sub:s("services.metrics.peakAvg",{peak:`${a.max.toFixed(1)}%`,avg:`${a.avg.toFixed(1)}%`})}),n.jsx(Lh,{accent:"#3b82f6",label:s("services.metrics.memory"),value:Nb(l.last),sub:s("services.metrics.peakAvg",{peak:Nb(l.max),avg:Nb(l.avg)})}),n.jsx(Lh,{accent:"#a855f7",label:s("services.metrics.uptime"),value:d!=null?$C(d):"—",sub:c?s("services.metrics.since",{time:c.toLocaleTimeString()}):s("services.metrics.notRunning")}),n.jsx(Lh,{accent:"#f59e0b",label:s("services.metrics.samples"),value:String(i.length),sub:f?s("services.metrics.over",{dur:$C(f)}):s("services.metrics.collecting")})]}),n.jsx(HC,{label:"CPU",samples:i,pick:h=>h.cpu,summary:a,color:"#22c55e",suffix:"%",unit:"percent"}),n.jsx(HC,{label:s("services.metrics.memoryRss"),samples:i,pick:h=>h.rss,summary:l,color:"#3b82f6",suffix:" MB",unit:"mb"})]})}function BC(e,t){const s=e.map(t),i=s.reduce((a,l)=>a+l,0);return{last:s[s.length-1],max:Math.max(...s),min:Math.min(...s),avg:i/s.length}}function Lh({accent:e,label:t,value:s,sub:i}){return n.jsxs("div",{className:"rounded-lg border border-border bg-card px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:e}}),n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:t})]}),n.jsx("div",{className:"mt-1 font-mono text-lg leading-none tabular-nums",children:s}),n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground",children:i})]})}const ml=160,IC=44,wZ=20;function HC({label:e,samples:t,pick:s,summary:i,color:a,suffix:l,unit:c}){const d=J(),f=x.useMemo(()=>`metric-grad-${c}-${Math.random().toString(36).slice(2,8)}`,[c]),h=t.map(s),g=Math.max(...h,c==="percent"?10:1),p=SZ(g),b=0,v=p-b||1,_=t[0].t,S=t[t.length-1].t,C=Math.max(1,S-_),N=z=>(z-_)/C*1e3,A=z=>(1-(z-b)/v)*1e3,j=t.map(z=>`${N(z.t).toFixed(1)},${A(s(z)).toFixed(1)}`),E=`M0,1000 L${j.join(" L")} L1000,1000 Z`,T=`M${j.join(" L")}`,L=N(S),H=A(i.last),P=A(i.avg),F=[1,.75,.5,.25,0],M=5;return n.jsxs("figure",{className:"space-y-1",children:[n.jsxs("figcaption",{className:"flex items-baseline justify-between",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e}),n.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:[d("services.metrics.wNow")," ",n.jsxs("span",{className:"text-foreground",children:[i.last.toFixed(1),l]}),n.jsx("span",{className:"mx-1.5",children:"·"}),d("services.metrics.wPeak")," ",i.max.toFixed(1),l,n.jsx("span",{className:"mx-1.5",children:"·"}),d("services.metrics.wAvg")," ",i.avg.toFixed(1),l]})]}),n.jsxs("div",{className:"rounded-lg border border-border bg-card p-2",children:[n.jsxs("div",{className:"flex",children:[n.jsx("div",{className:"relative flex shrink-0 flex-col justify-between text-right font-mono text-[10px] text-muted-foreground",style:{width:IC,height:ml},children:F.map(z=>n.jsx("span",{className:"pr-1 leading-none",children:kZ(b+z*v,c)},z))}),n.jsxs("div",{className:"relative min-w-0 flex-1",style:{height:ml},children:[F.map((z,G)=>n.jsx("div",{className:"pointer-events-none absolute inset-x-0 border-t border-border/40",style:{top:`${z===1?0:z===0?ml-1:(1-z)*ml}px`,borderStyle:G===F.length-1?"solid":"dashed"}},z)),n.jsx("div",{className:"pointer-events-none absolute inset-x-0 border-t border-dashed",style:{top:`${P/1e3*ml}px`,borderColor:a,opacity:.4}}),n.jsxs("svg",{"aria-label":e,className:"absolute inset-0 h-full w-full",preserveAspectRatio:"none",role:"img",viewBox:"0 0 1000 1000",children:[n.jsx("defs",{children:n.jsxs("linearGradient",{id:f,x1:"0",x2:"0",y1:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:.35}),n.jsx("stop",{offset:"100%",stopColor:a,stopOpacity:.02})]})}),n.jsx("path",{d:E,fill:`url(#${f})`}),n.jsx("path",{d:T,fill:"none",stroke:a,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round",strokeLinecap:"round"})]}),n.jsx("span",{className:"pointer-events-none absolute z-10 block h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full ring-2 ring-card",style:{left:`${L/1e3*100}%`,top:`${H/1e3*ml}px`,backgroundColor:a,boxShadow:`0 0 0 4px ${a}33`}})]})]}),n.jsx("div",{className:"flex font-mono text-[10px] text-muted-foreground",style:{height:wZ,paddingLeft:IC},children:n.jsx("div",{className:"relative flex-1",children:Array.from({length:M+1},(z,G)=>{const D=G/M,q=_+D*C;return n.jsx("span",{className:"absolute top-1 whitespace-nowrap",style:{left:`${D*100}%`,transform:G===0?"translateX(0)":G===M?"translateX(-100%)":"translateX(-50%)"},children:CZ(q-S)},G)})})})]})]})}function SZ(e){if(e<=1)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),s=e/t;return(s<=1?1:s<=2?2:s<=5?5:10)*t}function kZ(e,t){return t==="percent"?`${e.toFixed(0)}%`:e>=1024?`${(e/1024).toFixed(1)}G`:`${e.toFixed(0)}M`}function Nb(e){return e>=1024?`${(e/1024).toFixed(2)} GB`:`${e.toFixed(0)} MB`}function $C(e){const t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;const s=Math.floor(t/60);if(s<60)return`${s}m ${t%60}s`;const i=Math.floor(s/60);return i<24?`${i}h ${s%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function CZ(e){const t=Math.round(e/1e3);if(t===0)return"now";if(Math.abs(t)<60)return`${t}s`;const i=Math.round(t/60);return Math.abs(i)<60?`${i}m`:`${Math.round(i/60)}h`}function NZ({rows:e,running:t}){const s=J();if(e.length===0)return n.jsx("div",{className:"text-muted-foreground",children:s(t?"services.proc.emptyRunning":"services.proc.emptyStopped")});const i=[...e].sort((l,c)=>c.cpuPercent-l.cpuPercent),a=new Set(e.map(l=>l.pid));return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full font-mono text-[11px]",children:[n.jsx("thead",{className:"text-left text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"py-1 pr-3",children:"PID"}),n.jsx("th",{className:"py-1 pr-3",children:"PPID"}),n.jsx("th",{className:"py-1 pr-3 text-right",children:"CPU%"}),n.jsx("th",{className:"py-1 pr-3 text-right",children:"RSS MB"}),n.jsx("th",{className:"py-1",children:s("services.proc.command")})]})}),n.jsx("tbody",{children:i.map(l=>{const c=a.has(l.ppid);return n.jsxs("tr",{className:"border-t border-border/40",children:[n.jsx("td",{className:"py-1 pr-3",children:l.pid}),n.jsx("td",{className:"py-1 pr-3 text-muted-foreground",children:l.ppid}),n.jsx("td",{className:"py-1 pr-3 text-right",children:l.cpuPercent.toFixed(1)}),n.jsx("td",{className:"py-1 pr-3 text-right",children:l.rssMb.toFixed(1)}),n.jsx("td",{className:re("py-1 truncate max-w-[60ch]",c&&"pl-4"),children:l.command})]},l.pid)})})]})})}const FC={connecting:"bg-amber-500",running:"bg-emerald-500",exited:"bg-muted-foreground/40",error:"bg-red-500"},EZ={state:"connecting",cwd:"Local workspace",detail:"Opening shell"};function IA({sessionId:e,active:t,toolbarExtra:s}){const i=J(),{confirmedGlobal:a}=xm(),l=x.useRef(null),[c,d]=x.useState(EZ),[f,h]=x.useState(null),g=x.useCallback(v=>d(v),[]),p=x.useCallback(v=>{l.current?.[v]()},[]),b=x.useCallback(v=>{if(a.terminal.confirmTerminate){h(v);return}p(v)},[a.terminal.confirmTerminate,p]);return n.jsxs("section",{className:re("flex h-full min-h-0 flex-col bg-[#090909] text-white",!t&&"hidden"),children:[n.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-white/10 bg-[#111111] px-4 py-2",children:[n.jsx("div",{className:"min-w-0",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"relative flex size-2.5 shrink-0 items-center justify-center",title:c.state,children:[c.state==="connecting"&&n.jsx("span",{className:re("absolute inline-flex size-full animate-ping rounded-full opacity-60",FC[c.state])}),n.jsx("span",{className:re("relative inline-flex size-2 rounded-full",FC[c.state])})]}),n.jsxs("span",{className:"truncate font-mono text-[11px] text-white/55",children:[c.cwd," · ",c.detail]})]})}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Q,{"aria-label":i("terminal.restart"),className:"text-white/60 hover:bg-white/10 hover:text-white",size:"icon-sm",variant:"ghost",onClick:()=>b("restart"),title:i("terminal.restart"),type:"button",children:n.jsx(Ru,{})}),n.jsx(Q,{"aria-label":i("terminal.stop"),className:"text-white/60 hover:bg-white/10 hover:text-white",size:"icon-sm",variant:"ghost",onClick:()=>b("stop"),title:i("terminal.stop"),type:"button",children:n.jsx(Ta,{})}),s]})]}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(vA,{active:t,displaySettings:a.terminal,onStatusChange:g,ref:l,sessionId:e})}),f?n.jsx(Ol,{confirmLabel:i(f==="restart"?"terminal.restart":"terminal.stop"),message:i(f==="restart"?"terminal.confirmRestartBody":"terminal.confirmStopBody"),onCancel:()=>h(null),onConfirm:()=>{p(f),h(null)},title:i(f==="restart"?"terminal.confirmRestartTitle":"terminal.confirmStopTitle"),tone:"danger"}):null]})}function jZ({serviceName:e,active:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState(!1),h=x.useRef(!1),g=x.useRef(!0);x.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]),x.useEffect(()=>{!t||h.current||(h.current=!0,(async()=>{try{const v=await au({serviceName:e});g.current&&a(v.id)}catch(v){g.current&&(c(v instanceof Error?v.message:String(v)),h.current=!1)}})())},[t,e]);const p=n.jsx(Q,{"aria-label":s(d?"services.term.exitFs":"services.term.expand"),className:"text-white/60 hover:bg-white/10 hover:text-white",onClick:()=>f(v=>!v),size:"icon-sm",title:s(d?"services.fsExit":"services.fsExpand"),type:"button",variant:"ghost",children:d?n.jsx(Yx,{}):n.jsx(Kx,{})}),b=l?n.jsx("div",{className:"p-3 font-mono text-[11px] text-destructive",children:s("services.term.openError",{error:l})}):i?n.jsx(IA,{active:t,sessionId:i,toolbarExtra:p}):n.jsx("div",{className:"p-3 font-mono text-[11px] text-muted-foreground",children:s("services.term.opening")});return d&&t?n.jsx(Q0,{onClose:()=>f(!1),title:s("services.termTitle",{name:e}),children:b}):n.jsx("div",{className:re("h-[60vh] min-h-[24rem] overflow-hidden rounded-md border border-border",!t&&"hidden"),children:b})}const AZ=500;function TZ(e){const[t,s]=x.useState(),[i,a]=x.useState([]),[l,c]=x.useState(),[d,f]=x.useState(!1),h=x.useRef(void 0);x.useEffect(()=>{h.current=void 0,s(void 0),a([]);const p=new EventSource(`/api/services/${encodeURIComponent(e)}/test/stream`),b=v=>{try{const _=JSON.parse(v.data);_.run.id!==h.current&&(h.current=_.run.id,a([])),s(_.run),_.line&&a(S=>[...S,_.line].slice(-AZ))}catch{}};return p.addEventListener("status",b),p.addEventListener("output",b),()=>p.close()},[e]);const g=x.useCallback(async p=>{f(!0),c(void 0);try{await y9(e,p)}catch(b){c(b instanceof Error?b.message:String(b))}finally{f(!1)}},[e]);return{run:t,lines:i,error:l,starting:d,start:g}}const RZ={running:"secondary",passed:"success",failed:"error",error:"error"},MZ={running:"services.tests.statusRunning",passed:"services.tests.statusPassed",failed:"services.tests.statusFailed",error:"services.tests.statusError"};function DZ({serviceName:e}){const t=J(),{run:s,lines:i,error:a,starting:l,start:c}=TZ(e),[d,f]=x.useState(""),h=s?.status==="running"||l,g=s?.status==="failed"||s?.status==="error";return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("form",{className:"flex items-center gap-2",onSubmit:p=>{p.preventDefault(),h||c(d.trim()||void 0)},children:[n.jsx(pt,{className:"h-7 flex-1 text-[11px]",disabled:h,onChange:p=>f(p.target.value),placeholder:t("services.tests.patternPlaceholder"),value:d}),n.jsx(Q,{disabled:h,size:"sm",type:"submit",children:t(h?"services.tests.running":"services.tests.runTests")})]}),a?n.jsx("div",{className:"text-red-600",children:a}):null,s?n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[n.jsx(We,{size:"small",variant:RZ[s.status],children:t(MZ[s.status])}),n.jsx("code",{className:"font-mono text-[11px]",children:s.command}),s.failingCount>0?n.jsxs("span",{children:["· ",t("services.tests.failing",{count:s.failingCount})]}):null,s.exitCode!=null?n.jsxs("span",{children:["· ",t("services.tests.exit",{code:s.exitCode})]}):null]}):n.jsx("div",{className:"text-muted-foreground",children:t("services.tests.noRuns")}),i.length>0?n.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-all rounded bg-background p-2 font-mono text-[11px]",children:i.map((p,b)=>n.jsx("div",{className:re(p.stream==="stderr"&&"text-red-500"),children:p.text},b))}):null,g?n.jsxs("div",{className:"rounded border border-border bg-muted/40 p-2",children:[t("services.tests.failuresPre")," ",n.jsx("a",{className:"font-medium underline",href:"/errors",children:t("services.tests.errorInbox")})," ",t("services.tests.failuresPost")]}):null]})}function LZ({serviceName:e,status:t,health:s,timeline:i,onRefresh:a}){const l=J(),[c,d]=wl("service-detail:tab","metrics"),f=s?.processTree?.processes??[];return n.jsxs("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs",children:[n.jsxs("div",{className:"mb-2 flex gap-1",children:[n.jsx(ro,{active:c==="logs",onClick:()=>d("logs"),children:l("services.logs")}),n.jsxs(ro,{active:c==="processes",onClick:()=>d("processes"),children:[l("services.tab.processes")," ",f.length?n.jsx(We,{variant:"secondary",size:"small",children:f.length}):null]}),n.jsx(ro,{active:c==="metrics",onClick:()=>d("metrics"),children:l("services.tab.metrics")}),n.jsxs(ro,{active:c==="http",onClick:()=>d("http"),children:["HTTP",t?.inspector?.enabled?n.jsx(We,{variant:"success",size:"small",children:l("services.tab.on")}):null]}),n.jsx(ro,{active:c==="env",onClick:()=>d("env"),children:l("services.tab.env")}),n.jsx(ro,{active:c==="tests",onClick:()=>d("tests"),children:l("services.tab.tests")}),n.jsx(ro,{active:c==="terminal",onClick:()=>d("terminal"),children:l("nav.terminal")})]}),c==="processes"?n.jsx(NZ,{rows:f,running:t?.state==="running"}):null,c==="metrics"?n.jsx(yZ,{serviceName:e}):null,c==="http"?n.jsx(bZ,{serviceName:e,status:t,timeline:i,onRefresh:a}):null,c==="env"?n.jsx(gZ,{serviceName:e}):null,c==="tests"?n.jsx(DZ,{serviceName:e}):null,c==="logs"?n.jsx(aZ,{serviceName:e}):null,n.jsx(jZ,{active:c==="terminal",serviceName:e},e)]})}function ro({active:e,onClick:t,children:s}){return n.jsx("button",{className:re("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:t,type:"button",children:s})}const OZ={high:"success",medium:"warning",low:"secondary"};function PZ({onClose:e,onRefresh:t}){const s=J(),i=cs(),{sendToAgent:a}=Ot(),[l,c]=x.useState("url"),[d,f]=x.useState(""),[h,g]=x.useState(!1),[p,b]=x.useState(null),[v,_]=x.useState(null),[S,C]=x.useState([]),[N,A]=x.useState([]),[j,E]=x.useState(null),T=j?.kind==="docker-compose"?N.find(F=>F.composeService===j.composeService):void 0;async function L(){if(d.trim()){g(!0),b(null);try{const F=await i9(d.trim());_(F.profile),C(F.proposals),A(F.databases),E(F.proposals[0]??null),F.proposals.length===0&&b(s("onboard.scanNoDetect")),c("review")}catch(F){b(F instanceof Error?F.message:String(F))}finally{g(!1)}}}function H(){a({prompt:`Onboard this repository and register it as a NoMoreIDE service: ${d.trim()}
|
|
120
120
|
Use nomoreide_onboard_repo to inspect it, pick the best run command, then register and start it.`,source:{type:"repo-onboard",label:"Onboard repo"},label:s("onboard.refineLabel",{url:d.trim()})}),e()}async function P(F){if(j){g(!0),b(null);try{await r9(j,F,T),await t();const M=(T?s("onboard.extraDb"):"")+(F?s("onboard.extraStart"):"");i.success(s("onboard.registeredToast",{name:j.name,extras:M})),e()}catch(M){b(M instanceof Error?M.message:String(M))}finally{g(!1)}}}return n.jsxs(zn,{icon:n.jsx(_n,{}),onClose:e,size:"lg",title:s("onboard.title"),children:[l==="url"?n.jsx(zZ,{url:d,busy:h,error:p,onChange:f,onScan:L,onRefine:H}):null,l==="review"&&v?n.jsx(BZ,{profile:v,proposals:S,selected:j,database:T,error:p,onSelect:E,onEdit:E,onBack:()=>c("url"),onRefine:H,onContinue:()=>c("install")}):null,l==="install"&&j?n.jsx(HZ,{proposal:j,busy:h,error:p,onBack:()=>c("review"),onRegister:P}):null]})}function zZ({url:e,busy:t,error:s,onChange:i,onScan:a,onRefine:l}){const c=J();return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:c("onboard.urlIntro")}),n.jsx(pt,{autoFocus:!0,placeholder:"https://github.com/owner/repo",value:e,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!t&&a()}}),s?n.jsx("p",{className:"text-sm text-destructive",children:s}):null,n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs(Q,{variant:"ghost",size:"sm",onClick:l,disabled:!e.trim(),children:[n.jsx(Bn,{className:"size-3.5"}),c("onboard.refineWithAi")]}),n.jsxs(Q,{onClick:a,disabled:t||!e.trim(),children:[t?n.jsx(Mt,{className:"size-4 animate-spin"}):n.jsx(_n,{className:"size-4"}),c(t?"onboard.cloning":"onboard.cloneDetect")]})]})]})}function BZ({profile:e,proposals:t,selected:s,database:i,error:a,onSelect:l,onEdit:c,onBack:d,onRefine:f,onContinue:h}){const g=J();return n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-medium",children:e.name}),e.languages.map(p=>n.jsx(We,{variant:"outline",size:"small",label:p},p))]}),a?n.jsx("p",{className:"text-sm text-destructive",children:a}):null,t.length>0?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:g("onboard.detectedServices")}),t.map(p=>{const b=s?.name===p.name;return n.jsxs("button",{type:"button",onClick:()=>l(p),className:`rounded-md border px-3 py-2 text-left text-sm transition-colors ${b?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-medium",children:p.name}),n.jsx(We,{variant:OZ[p.confidence],size:"small",label:p.confidence})]}),n.jsx("div",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:p.kind==="docker-compose"?`compose · ${p.composeService}`:p.command}),n.jsx("div",{className:"text-[11px] text-muted-foreground",children:p.reason})]},p.name)})]}):null,s?n.jsx(IZ,{proposal:s,onChange:c}):null,i?n.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-border bg-muted/30 px-2.5 py-1.5 text-xs text-muted-foreground",children:[n.jsx(si,{className:"size-3.5"}),n.jsxs("span",{children:[g("onboard.alsoRegistersPre")," ",n.jsx("span",{className:"font-medium",children:i.name})," (",i.engine,")"," ",g("onboard.alsoRegistersPost")]})]}):null,e.envKeys.length>0?n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-medium",children:g("onboard.envFrom")})," ",e.envKeys.join(", ")]}):null,e.readmeExcerpt?n.jsxs("details",{className:"rounded-md border border-border bg-muted/30 p-2 text-xs",children:[n.jsx("summary",{className:"cursor-pointer font-medium",children:g("onboard.readmeExcerpt")}),n.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap font-mono",children:e.readmeExcerpt})]}):null,n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs(Q,{variant:"ghost",size:"sm",onClick:d,children:[n.jsx(ju,{className:"size-3.5"}),g("common.back")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(Q,{variant:"outline",size:"sm",onClick:f,children:[n.jsx(Bn,{className:"size-3.5"}),g("onboard.refineWithAi")]}),n.jsx(Q,{onClick:h,disabled:!s,children:g("onboard.continue")})]})]})]})}function IZ({proposal:e,onChange:t}){const s=J();return n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(nu,{label:s("onboard.serviceName"),children:n.jsx(pt,{value:e.name,onChange:i=>t({...e,name:i.target.value})})}),n.jsx(nu,{label:s("onboard.portOptional"),children:n.jsx(pt,{value:e.port?.toString()??"",placeholder:"auto",onChange:i=>t({...e,port:i.target.value?Number(i.target.value):void 0})})}),e.kind==="docker-compose"?n.jsx(nu,{label:s("onboard.composeService"),className:"col-span-2",children:n.jsx(pt,{value:e.composeService??"",onChange:i=>t({...e,composeService:i.target.value})})}):n.jsx(nu,{label:s("onboard.runCommand"),className:"col-span-2",children:n.jsx(pt,{value:e.command??"",onChange:i=>t({...e,command:i.target.value})})})]})}function HZ({proposal:e,busy:t,error:s,onBack:i,onRegister:a}){const l=J(),[c,d]=x.useState(e.installCommand??""),[f,h]=x.useState([]),[g,p]=x.useState(!1),[b,v]=x.useState(!1),_=x.useRef(null);function S(N){h(A=>[...A,N]),queueMicrotask(()=>{const A=_.current;A&&(A.scrollTop=A.scrollHeight)})}async function C(){c.trim()&&(p(!0),v(!1),h([]),await a9({clonePath:e.cwd,command:c.trim()},{onLine:N=>S(N.text),onDone:N=>{S(N===0?l("onboard.installComplete"):l("onboard.installExited",{code:N??"?"})),p(!1),v(N===0)},onError:N=>{S(`✗ ${N}`),p(!1)}}))}return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsx(nu,{label:l("onboard.installCommand"),className:"flex-1",children:n.jsx(pt,{value:c,placeholder:"e.g. npm install",onChange:N=>d(N.target.value)})}),n.jsxs(Q,{variant:"outline",onClick:C,disabled:g||!c.trim(),children:[g?n.jsx(Mt,{className:"size-4 animate-spin"}):n.jsx(vu,{className:"size-4"}),l("onboard.install")]})]}),f.length>0?n.jsx("pre",{ref:_,className:"max-h-48 overflow-auto rounded-md border border-border bg-black/80 p-2 font-mono text-[11px] text-green-200",children:f.join(`
|
|
121
121
|
`)}):null,s?n.jsx("p",{className:"text-sm text-destructive",children:s}):null,n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs(Q,{variant:"ghost",size:"sm",onClick:i,children:[n.jsx(ju,{className:"size-3.5"}),l("common.back")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Q,{variant:"outline",onClick:()=>a(!1),disabled:t,children:l("onboard.registerOnly")}),n.jsxs(Q,{onClick:()=>a(!0),disabled:t,children:[t?n.jsx(Mt,{className:"size-4 animate-spin"}):n.jsx(or,{className:"size-4"}),b||!c.trim()?l("onboard.registerStart"):l("onboard.skipInstallStart")]})]})]})]})}function nu({label:e,className:t,children:s}){return n.jsxs("label",{className:`flex flex-col gap-1 text-xs ${t??""}`,children:[n.jsx("span",{className:"font-medium text-muted-foreground",children:e}),s]})}function $Z({data:e,onRefresh:t,focusService:s,onServiceFocused:i,scopeName:a}){const l=J(),c=e.config.services[0]?.name??"",[d,f]=x.useState(c),[h,g]=x.useState(null),[p,b]=x.useState(!1),{sendToAgent:v,startOnboard:_}=Ot(),[S,C]=x.useState(!1),[N,A]=x.useState(!1),[j,E]=x.useState(!1),[T,L]=x.useState(!1),[H,P]=x.useState(!1),F=x.useRef({}),{error:M,message:z,success:G}=cs(),D=x.useMemo(()=>new Set(e.config.bundles.flatMap(ne=>ne.services)),[e.config.bundles]),q=x.useMemo(()=>{const ne=new Map;for(const we of e.config.bundles)for(const Ne of we.services)ne.has(Ne)||ne.set(Ne,we.name);return ne},[e.config.bundles]),W=x.useMemo(()=>e.config.services.filter(ne=>!D.has(ne.name)),[e.config.services,D]),I=x.useMemo(()=>e.config.services.map(ne=>ne.name),[e.config.services]),Y=x.useMemo(()=>e.config.services.some(ne=>(ne.dependsOn?.length??0)>0),[e.config.services]),$=e.health??{},me=e.config.bundles.length>0||W.length>0;x.useEffect(()=>{!e.config.services.some(we=>we.name===d)&&c&&f(c)},[e.config.services,c,d]),x.useEffect(()=>{s&&e.config.services.some(ne=>ne.name===s)&&(f(s),i?.())},[s,e.config.services,i]);const ee=x.useMemo(()=>e.config.services.find(ne=>ne.name===d),[e.config.services,d]),V=d?e.runtime.services[d]:void 0,K=d?$[d]:void 0;async function xe(ne,we){if(!ne.services.includes(we))try{await _9(ne.name,ne.services,we),G(l("services.toast.addedToGroup",{service:we,group:ne.name})),await t()}catch(Ne){M(Ne instanceof Error?Ne.message:String(Ne))}}async function ie(){if(ee){if(hu(V?.state)){M(l("services.toast.stopBeforeDelete",{name:ee.name}));return}if(window.confirm(l("services.confirmDelete",{name:ee.name})))try{await h9(ee.name),G(l("services.toast.deleted",{name:ee.name})),await t()}catch(ne){M(ne instanceof Error?ne.message:String(ne))}}}async function Z(ne){const we=e.config.bundles.filter(Ne=>Ne.services.includes(ne));if(we.length!==0)try{for(const Ne of we)await S9(Ne.name,Ne.services,ne);z({text:l("services.toast.removedFromGroups",{service:ne,groups:we.map(Ne=>Ne.name).join(", ")})}),await t()}catch(Ne){M(Ne instanceof Error?Ne.message:String(Ne))}}x.useEffect(()=>{const ne=Object.fromEntries(e.config.services.map(Ne=>[Ne.name,e.runtime.services[Ne.name]?.state??"stopped"])),we=F.current;if(Object.keys(we).length){const Ne=new Map,Ue=new Map;for(const Pe of e.config.services){const Me=ne[Pe.name],pe=we[Pe.name];if(!pe||pe===Me)continue;const Je=e.runtime.services[Pe.name],jt=q.get(Pe.name);if(jt){const dt=Ne.get(jt)??new Map;if(dt.set(Me,(dt.get(Me)??0)+1),Ne.set(jt,dt),Me==="exited"){const Fs=Ue.get(jt)??[];Fs.push(Je?.exitCode),Ue.set(jt,Fs)}continue}Me==="running"?G(l("services.toast.running",{name:Pe.name})):Me==="stopped"?z({text:l("services.toast.stopped",{name:Pe.name})}):Me==="starting"?z({text:l("services.toast.starting",{name:Pe.name})}):Me==="exited"&&M(Je?.exitCode===void 0||Je.exitCode===null?l("services.toast.exited",{name:Pe.name}):l("services.toast.exitedWithCode",{name:Pe.name,code:Je.exitCode}))}for(const[Pe,Me]of Ne)UZ({exitCodes:Ue.get(Pe)??[],groupName:Pe,showErrorToast:M,showMessageToast:z,showSuccessToast:G,transitions:Me,t:l})}F.current=ne},[e.config.services,e.runtime.services,q,M,z,G]);const ge=e.config.services.length>0;return n.jsxs(n.Fragment,{children:[!ge&&a?n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"max-w-sm text-sm text-muted-foreground",children:[n.jsxs("p",{className:"font-medium text-foreground",children:["No services in ",a]}),n.jsx("p",{className:"mt-1 text-xs",children:"Services whose working directory lives under this project appear here. Switch to All projects in the sidebar to see everything."})]})}):ge?n.jsxs("div",{className:re("grid h-full min-h-0 overflow-hidden bg-card/85",j?"lg:grid-cols-[320px_minmax(0,1fr)]":"lg:grid-cols-[320px_minmax(0,1fr)_340px]"),children:[n.jsx("div",{className:"min-h-0 min-w-0 overflow-auto border-r border-border",children:n.jsxs(wi,{className:"min-w-0 rounded-none border-0 border-b border-border bg-transparent",children:[n.jsx(Si,{className:"border-b border-border px-3 py-2",children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(ki,{className:"text-sm",children:l("services.title")}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsxs(Q,{"aria-haspopup":"dialog",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>A(!0),size:"sm",type:"button",variant:"outline",children:[n.jsx(of,{className:"size-3.5"}),l("services.graph")]}),n.jsxs(Q,{"aria-haspopup":"dialog",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>C(!0),size:"sm",type:"button",variant:"outline",children:[n.jsx(Xf,{className:"size-3.5"}),l("services.logs")]}),n.jsx(FZ,{onCreateGroup:()=>g("group"),onCreateService:()=>g("service"),onOnboardRepo:()=>b(!0),onOnboardWithAi:_,canGroupWithAi:W.length>1,onCreateWithAi:()=>v({prompt:e2,source:{type:"service-setup",label:"Add a service"},label:"Help me add a new service, one step at a time."}),onGroupWithAi:()=>v({prompt:ZF(W),source:{type:"group-services",label:"Group services"},label:"Propose how to group my ungrouped services."})})]})]})}),n.jsx(Ci,{className:"p-0",children:me?n.jsxs("div",{className:"divide-y divide-border",children:[e.config.bundles.map(ne=>n.jsx(Bq,{group:ne,onRefresh:t,ports:e.ports,allServices:e.config.services,health:$,services:e.config.services.filter(we=>ne.services.includes(we.name)),statuses:e.runtime.services,timeline:e.timeline,selectedService:d,onSelectService:f,onDropService:we=>{xe(ne,we)}},ne.name)),W.length?n.jsxs("div",{className:re("transition-colors",H&&"bg-primary/5 outline-dashed outline-2 -outline-offset-2 outline-primary/60"),onDragOver:ne=>{ne.dataTransfer.types.includes(Su)&&(ne.preventDefault(),ne.dataTransfer.dropEffect="move",P(!0))},onDragLeave:()=>P(!1),onDrop:ne=>{ne.preventDefault(),P(!1);const we=ne.dataTransfer.getData(Su);we&&Z(we)},children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 bg-muted/55 px-3 py-1 text-[10px] font-semibold uppercase text-muted-foreground",children:[n.jsx("span",{children:l("services.ungrouped")}),n.jsx("span",{className:"text-muted-foreground/80",children:W.length})]}),n.jsx("div",{className:"divide-y divide-border",children:W.map(ne=>n.jsx(S5,{service:ne,status:e.runtime.services[ne.name],health:$[ne.name],ports:e.ports,onRefresh:t,timeline:e.timeline,selected:d===ne.name,onSelect:()=>f(ne.name)},ne.name))})]}):null]}):n.jsx(Eu,{label:l("services.empty")})})]})}),n.jsx("div",{className:"min-h-0 min-w-0 overflow-auto",children:ee?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"shrink-0 space-y-2 border-b border-border bg-background/60 px-4 py-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("h2",{className:"min-w-0 truncate text-base font-semibold",children:ee.name}),n.jsx(k5,{state:V?.state??"stopped"}),n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[(()=>{const ne=V?.url??(ee.port?Hq(ee.port):void 0);return ne?n.jsx(ja,{label:l("services.openUrl",{url:ne}),children:n.jsx(Q,{"aria-label":l("services.openInBrowser"),className:"size-7",onClick:()=>{em(ne)},size:"icon",type:"button",variant:"outline",children:n.jsx(Pr,{})})}):null})(),K?.agentContext&&ee?n.jsx(ja,{label:l("services.debugWithAi"),children:n.jsx(Q,{"aria-label":l("services.debugWithAi"),className:"size-7",onClick:()=>v({prompt:sU({service:ee.name,context:K.agentContext}),source:{type:"service-debug",label:ee.name},label:`Debug \`${ee.name}\` with its current context.`}),size:"icon",type:"button",variant:"outline",children:n.jsx(Xt,{className:"size-3.5"})})}):null,n.jsx(z0,{active:hu(V?.state),baseUrl:`/api/services/${encodeURIComponent(ee.name)}`,compact:!0,resourceKind:"service",resourceName:ee.name,targetLabel:ee.name,onRefresh:t}),n.jsx(Ll,{className:"size-7 border border-border bg-background opacity-100 hover:border-foreground/30",items:[{icon:n.jsx(Nl,{className:"size-3.5"}),label:l("services.editService"),onSelect:()=>L(!0)},...hu(V?.state)?[]:[{icon:n.jsx(Ii,{className:"size-3.5 text-destructive"}),label:l("services.deleteService"),onSelect:()=>{ie()}}]],label:l("services.moreActions",{name:ee.name})}),n.jsx(ja,{label:l(j?"services.showRail":"services.hideRail"),side:"left",children:n.jsx(Q,{"aria-label":l(j?"services.showRail":"services.hideRail"),className:"size-7",onClick:()=>E(ne=>!ne),size:"icon",type:"button",variant:"ghost",children:j?n.jsx(EM,{}):n.jsx(wn,{})})})]})]}),ee.command?n.jsxs("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:ee.command,children:["$ ",ee.command]}):null,ee.cwd?n.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:ee.cwd,children:ee.cwd}):null,n.jsx(UX,{health:K})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(LZ,{serviceName:ee.name,status:V,health:K,timeline:e.timeline??[],onRefresh:t},ee.name)})]}):n.jsx(Eu,{label:l("services.selectPrompt")})}),j?null:n.jsxs("div",{className:"min-h-0 overflow-auto border-l border-border",children:[n.jsx(KX,{ports:e.ports}),n.jsx(AX,{events:e.timeline??[]})]})]}):n.jsx(FX,{onOnboardRepo:()=>b(!0),onOnboardWithAi:_,onCreateService:()=>g("service"),onCreateWithAi:()=>v({prompt:e2,source:{type:"service-setup",label:"Add a service"},label:"Help me add a new service, one step at a time."})}),T&&ee?n.jsx(zn,{icon:n.jsx(Nl,{}),onClose:()=>L(!1),size:"lg",title:l("services.editServiceTitle",{name:ee.name}),children:n.jsx(x2,{cwd:e.cwd,initialService:ee,availableServices:I,onRefresh:t,onSaved:()=>L(!1)})}):null,h?n.jsx(zn,{icon:h==="service"?n.jsx(ms,{}):n.jsx(Uf,{}),onClose:()=>g(null),size:h==="service"?"lg":"md",title:l(h==="service"?"services.addService":"services.createGroup"),children:h==="service"?n.jsx(x2,{cwd:e.cwd,availableServices:I,onRefresh:t,onSaved:()=>g(null)}):n.jsx(w5,{services:W,onRefresh:t,onSaved:()=>g(null)})}):null,p?n.jsx(PZ,{onClose:()=>b(!1),onRefresh:t}):null,S?n.jsx(cZ,{initialService:d||void 0,onClose:()=>C(!1),services:e.config.services.map(ne=>ne.name)}):null,N?n.jsx(zn,{icon:n.jsx(of,{}),onClose:()=>A(!1),size:"lg",title:l("services.depGraphTitle"),children:n.jsx(BX,{statuses:e.runtime.services,health:$,hasDependencies:Y,onSelectService:ne=>{f(ne),A(!1)}})}):null]})}function FZ({onCreateService:e,onCreateGroup:t,onCreateWithAi:s,onGroupWithAi:i,canGroupWithAi:a,onOnboardRepo:l,onOnboardWithAi:c}){const d=J(),[f,h]=x.useState(!1);function g(p){h(!1),p()}return n.jsxs("div",{className:"relative",children:[n.jsx(ja,{label:d("services.add"),side:"bottom",children:n.jsx(Q,{"aria-expanded":f,"aria-haspopup":"menu","aria-label":d("services.addServiceOrGroup"),className:"size-7",onClick:()=>h(p=>!p),size:"icon",type:"button",variant:"ghost",children:n.jsx(ms,{})})}),f?n.jsxs(n.Fragment,{children:[n.jsx("button",{"aria-hidden":!0,className:"fixed inset-0 z-[40] cursor-default",onClick:()=>h(!1),tabIndex:-1,type:"button"}),n.jsxs("div",{className:"absolute right-0 z-[50] mt-1 w-56 overflow-hidden rounded-md border border-border bg-card py-1 shadow-lg",role:"menu",children:[n.jsxs("div",{className:"group flex items-stretch",children:[n.jsxs("button",{className:"flex flex-1 items-center gap-2 whitespace-nowrap px-3 py-2 text-left text-sm hover:bg-muted/60 [&_svg]:size-4",onClick:()=>g(e),role:"menuitem",type:"button",children:[n.jsx(ms,{}),d("services.createService")]}),n.jsxs("button",{className:"flex max-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap border-l border-transparent px-0 text-[11px] font-medium text-muted-foreground opacity-0 transition-all duration-200 ease-out hover:bg-muted/60 hover:text-foreground group-hover:max-w-24 group-hover:border-border group-hover:px-3 group-hover:opacity-100",onClick:()=>g(s),role:"menuitem",title:d("services.setupWithAiHint"),type:"button",children:[n.jsx(Xt,{className:"size-3.5 shrink-0"}),"AI"]})]}),n.jsxs("div",{className:"group flex items-stretch",children:[n.jsxs("button",{className:"flex flex-1 items-center gap-2 whitespace-nowrap px-3 py-2 text-left text-sm hover:bg-muted/60 [&_svg]:size-4",onClick:()=>g(t),role:"menuitem",type:"button",children:[n.jsx(Uf,{}),d("services.createGroup")]}),a?n.jsxs("button",{className:"flex max-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap border-l border-transparent px-0 text-[11px] font-medium text-muted-foreground opacity-0 transition-all duration-200 ease-out hover:bg-muted/60 hover:text-foreground group-hover:max-w-24 group-hover:border-border group-hover:px-3 group-hover:opacity-100",onClick:()=>g(i),role:"menuitem",title:d("services.groupWithAiHint"),type:"button",children:[n.jsx(Xt,{className:"size-3.5 shrink-0"}),"AI"]}):null]}),n.jsxs("div",{className:"group flex items-stretch",children:[n.jsxs("button",{className:"flex flex-1 items-center gap-2 whitespace-nowrap px-3 py-2 text-left text-sm hover:bg-muted/60 [&_svg]:size-4",onClick:()=>g(l),role:"menuitem",type:"button",children:[n.jsx(_n,{}),d("services.addFromGithub")]}),n.jsxs("button",{className:"flex max-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap border-l border-transparent px-0 text-[11px] font-medium text-muted-foreground opacity-0 transition-all duration-200 ease-out hover:bg-muted/60 hover:text-foreground group-hover:max-w-24 group-hover:border-border group-hover:px-3 group-hover:opacity-100",onClick:()=>g(c),role:"menuitem",title:d("services.onboardWithAiHint"),type:"button",children:[n.jsx(Xt,{className:"size-3.5 shrink-0"}),"AI"]})]})]})]}):null]})}function UZ({exitCodes:e,groupName:t,showErrorToast:s,showMessageToast:i,showSuccessToast:a,transitions:l,t:c}){if(l.size===1){const[h]=l.keys();if(h==="running")a(c("services.toast.groupRunning",{name:t}));else if(h==="stopped")i({text:c("services.toast.groupStopped",{name:t})});else if(h==="starting")i({text:c("services.toast.groupStarting",{name:t})});else if(h==="exited"){const g=e.filter(p=>p!=null);s(g.length?c("services.toast.groupExitedWithCode",{name:t,code:g.join(", ")}):c("services.toast.groupExited",{name:t}))}return}const d=[...l.entries()].map(([h,g])=>`${g} ${h}`).join(", "),f=c("services.toast.groupUpdated",{name:t,summary:d});l.has("exited")?s(f):i({text:f})}function qZ({container:e,onClose:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState(!0);async function h(){f(!0),c(null);try{a(await h7(e.id,500))}catch(g){c(g instanceof Error?g.message:String(g))}finally{f(!1)}}return x.useEffect(()=>{h()},[e.id]),n.jsxs(zn,{icon:n.jsx(Xf,{}),onClose:t,size:"lg",title:s("docker.logs.title",{name:e.name}),children:[n.jsx("div",{className:"mb-2 flex justify-end",children:n.jsxs(Q,{disabled:d,loading:d,onClick:()=>{h()},size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{}),s("common.refresh")]})}),l?n.jsx(Ze,{variant:"destructive",children:l}):d&&i===null?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"size-4 animate-spin"}),s("docker.logs.loading")]}):i?n.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap rounded border border-border bg-background p-3 font-mono text-[11px]",children:i}):n.jsx(Ze,{variant:"muted",children:s("docker.logs.empty")})]})}const GZ={running:"success",restarting:"warning",exited:"danger",dead:"danger",paused:"outline",created:"outline"};function VZ({container:e,onRefresh:t}){const s=J(),[i,a]=x.useState(!1),l=e.state==="running"||e.state==="restarting";return n.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2 px-3 py-2 hover:bg-muted/40",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-sm font-medium",title:e.name,children:e.name}),n.jsx(We,{size:"small",variant:GZ[e.state]??"outline",children:e.state})]}),n.jsxs("div",{className:"truncate text-[11px] text-muted-foreground",title:e.image,children:[e.image,e.ports?` · ${e.ports}`:""]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsx(ja,{label:s("docker.actions.logs"),children:n.jsx(Q,{"aria-label":s("docker.actions.logs"),className:"size-7",onClick:()=>a(!0),size:"icon",type:"button",variant:"ghost",children:n.jsx(Xf,{})})}),n.jsx(UC,{action:l?"restart":"start",container:e,icon:l?n.jsx(Ru,{}):n.jsx(or,{}),label:s(l?"common.restart":"common.start"),onRefresh:t}),l?n.jsx(UC,{action:"stop",container:e,icon:n.jsx(Ta,{}),label:s("common.stop"),onRefresh:t}):null]}),i?n.jsx(qZ,{container:e,onClose:()=>a(!1)}):null]})}function UC({action:e,container:t,icon:s,label:i,onRefresh:a}){const l=J(),{error:c,success:d}=cs(),{isPending:f,runOperation:h}=In(),g=`docker:${t.id}:${e}`,p=f(g);return n.jsx(ja,{label:i,children:n.jsx(Q,{"aria-label":i,className:"size-7",loading:p,loadingLabel:i,onClick:()=>{h({key:g,label:i},async()=>{try{await d7(t.id,e),d(l("docker.actions.done",{label:i,name:t.name})),await a()}catch(b){const v=b instanceof Error?b.message:String(b);c(l("docker.actions.failed",{label:i,name:t.name,message:v}))}})},size:"icon",type:"button",variant:"outline",children:s})})}function WZ(){const[e,t]=x.useState(null),[s,i]=x.useState([]),[a,l]=x.useState(!0),[c,d]=x.useState(null),f=x.useCallback(async()=>{l(!0),d(null);try{const h=await c7();t(h),i(h.available?await u7():[])}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}},[]);return x.useEffect(()=>{f()},[f]),{status:e,containers:s,loading:a,error:c,refresh:f}}function KZ(e){const t=new Map,s=[];for(const a of e){if(!a.project){s.push(a);continue}const l=t.get(a.project)??[];l.push(a),t.set(a.project,l)}const i=[...t.entries()].sort(([a],[l])=>a.localeCompare(l)).map(([a,l])=>({project:a,containers:l}));return s.length&&i.push({project:null,containers:s}),i}function YZ(){const e=J(),{status:t,containers:s,loading:i,error:a,refresh:l}=WZ();if(Eo(l),i&&t===null)return n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"size-4 animate-spin"}),e("docker.loading")]});if(a)return n.jsx(Ze,{className:"m-4",variant:"destructive",children:a});if(t&&!t.available)return n.jsx("div",{className:"p-4",children:n.jsxs(Ze,{variant:"muted",children:[n.jsx(Fx,{}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-foreground",children:e("docker.unavailable.title")}),n.jsx("p",{className:"mt-1 text-muted-foreground",children:e("docker.unavailable.body")}),t.error?n.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap rounded border border-border bg-background p-2 font-mono text-[11px] text-muted-foreground",children:t.error}):null,n.jsxs(Q,{className:"mt-3",onClick:()=>{l()},size:"sm",variant:"outline",children:[n.jsx(_i,{}),e("common.refresh")]})]})]})});const c=KZ(s);return n.jsxs("div",{className:"p-4",children:[n.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:e("docker.desc")}),n.jsxs(Q,{onClick:()=>{l()},size:"sm",variant:"outline",children:[n.jsx(_i,{}),e("common.refresh")]})]}),c.length?n.jsx("div",{className:"space-y-4",children:c.map(d=>n.jsxs("section",{className:"overflow-hidden rounded-lg border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/35 px-3 py-1.5 text-xs font-medium",children:d.project??e("docker.otherContainers")}),n.jsx("div",{className:"divide-y divide-border",children:d.containers.map(f=>n.jsx(VZ,{container:f,onRefresh:l},f.id))})]},d.project??"__ungrouped__"))}):n.jsx(Eu,{label:e("docker.empty")})]})}function XZ({data:e,onOpenService:t}){const s=J(),i=x.useMemo(()=>ZZ(e,s("services.startingEllipsis")),[e,s]);return i.length?n.jsxs("div",{className:"flex shrink-0 items-center gap-3 overflow-x-auto border-b border-border bg-card/60 px-4 py-1.5 backdrop-blur",children:[n.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:[n.jsx(go,{className:"size-3"}),s("services.stripeRunning")]}),n.jsx("div",{className:"flex min-w-0 items-center gap-2",children:i.map(a=>n.jsxs("button",{className:"group flex shrink-0 items-center gap-2 rounded-md border border-border/60 bg-background/60 px-2.5 py-1 font-mono text-[11px] transition-colors hover:border-border hover:bg-muted",onClick:()=>t(a.name),title:a.url?`${a.name} — ${a.url}`:a.name,type:"button",children:[n.jsx("span",{className:re("size-2 shrink-0 rounded-full",JZ(a.tone))}),n.jsx("span",{className:"max-w-40 truncate font-medium text-foreground",children:a.name}),a.port?n.jsxs("span",{className:"text-muted-foreground",children:[":",a.port]}):null,a.uptime?n.jsxs("span",{className:"text-muted-foreground/70",children:["↑",a.uptime]}):null]},a.name))})]}):null}function ZZ(e,t){const s=new Map(e.config.services.map(i=>[i.name,i.port]));return Object.values(e.runtime.services).filter(i=>i.state==="running"||i.state==="starting").map(i=>({name:i.name,tone:QZ(i,e.health[i.name]),port:s.get(i.name)??eQ(i.url),uptime:i.state==="running"?tQ(i.startedAt):t,url:i.url})).sort((i,a)=>i.name.localeCompare(a.name))}function QZ(e,t){return e.state==="starting"?"starting":t?.status==="healthy"?"healthy":t?.status==="warning"?"warning":t?.status==="unhealthy"?"unhealthy":"healthy"}function JZ(e){return e==="starting"?"animate-pulse bg-amber-500":e==="warning"?"bg-amber-500":e==="unhealthy"?"bg-red-500":e==="unknown"?"bg-zinc-500":"bg-emerald-500"}function eQ(e){if(e)try{const t=new URL(e).port;return t?Number(t):void 0}catch{return}}function tQ(e){if(!e)return;const t=new Date(e).getTime();if(Number.isNaN(t))return;const s=Math.max(0,Math.floor((Date.now()-t)/1e3));if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const a=Math.floor(i/60),l=i%60;return a<24?`${a}h${l?`${l}m`:""}`:`${Math.floor(a/24)}d${a%24?`${a%24}h`:""}`}function sQ(){const e=J(),{confirmedGlobal:t}=xm(),[s,i]=x.useState([]),[a,l]=x.useState(null),[c,d]=x.useState(!1),[f,h]=x.useState(null);x.useEffect(()=>{let v=!1;return(async()=>{let _=await ZE().catch(()=>[]);if(_.length===0){const S=await au().catch(()=>null);_=S?[S]:[]}v||(i(_),l(_[0]?.id??null))})(),()=>{v=!0}},[]);const g=x.useCallback(async()=>{d(!0);try{const v=await au();i(_=>[..._,v]),l(v.id)}finally{d(!1)}},[]),p=x.useCallback(async v=>{d(!0);try{await fv(v);const _=s.findIndex(C=>C.id===v),S=s.filter(C=>C.id!==v);if(S.length===0){const C=await au();i([C]),l(C.id);return}if(i(S),a===v){const C=S[Math.min(_,S.length-1)];l(C.id)}}finally{d(!1)}},[s,a]),b=x.useCallback((v,_)=>{if(t.terminal.confirmTerminate){h({id:v,name:_});return}p(v)},[p,t.terminal.confirmTerminate]);return n.jsxs("section",{className:"flex h-full min-h-0 flex-col bg-[#090909] text-white",children:[n.jsxs("div",{"aria-label":e("terminal.tabs"),className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b border-white/10 bg-[#111111] px-2 py-1.5",role:"tablist",children:[s.map((v,_)=>{const S=v.label??e("terminal.tabName",{n:_+1});return n.jsxs("div",{className:re("group flex items-center gap-1 rounded-md border border-transparent px-2 py-1 text-xs",v.id===a?"border-white/15 bg-white/10 text-white":"text-white/60 hover:bg-white/5"),children:[n.jsx("button",{"aria-selected":v.id===a,className:"max-w-[160px] truncate font-medium",onClick:()=>l(v.id),role:"tab",type:"button",children:S}),n.jsx("button",{"aria-label":e("terminal.closeTab",{name:S}),className:"rounded p-0.5 text-white/40 opacity-0 transition hover:bg-white/10 hover:text-white group-hover:opacity-100",disabled:c,onClick:()=>b(v.id,S),type:"button",children:n.jsx(Vt,{className:"size-3"})})]},v.id)}),n.jsx("button",{"aria-label":e("terminal.newTerminal"),className:"ml-1 rounded-md p-1 text-white/60 transition hover:bg-white/10 hover:text-white disabled:opacity-40",disabled:c,onClick:()=>{g()},type:"button",children:n.jsx(ms,{className:"size-4"})})]}),n.jsx("div",{className:"relative min-h-0 flex-1",children:s.length===0?n.jsx("div",{className:"flex h-full items-center justify-center font-mono text-[11px] text-white/40",children:e("terminal.starting")}):s.map(v=>n.jsx("div",{className:"absolute inset-0",children:n.jsx(IA,{active:v.id===a,sessionId:v.id})},v.id))}),f?n.jsx(Ol,{confirmLabel:`Close ${f.name}`,loading:c,message:"The running shell process will be terminated and this terminal tab will be closed.",onCancel:()=>h(null),onConfirm:()=>{const v=f.id;h(null),p(v)},title:`Close ${f.name}?`,tone:"danger"}):null]})}function HA({branch:e}){return n.jsx("span",{className:"min-w-0 max-w-40",title:e,children:n.jsx(We,{className:"w-full max-w-full shadow-none",variant:"outline",children:e})})}function $A({branch:e,error:t,files:s,selectedFile:i,onSelectFile:a,root:l,staging:c}){const d=J(),f=x.useMemo(()=>aQ(s).filter(p=>p.files.length),[s]),[h,g]=x.useState({staged:!1,unstaged:!1,untracked:!1});return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/95 px-2.5 py-1.5",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold tracking-tight",children:[n.jsx(_n,{className:"size-3.5"}),n.jsx("span",{className:"truncate",children:d("git.tab.changes")})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[e?n.jsx(HA,{branch:e}):null,n.jsx(We,{variant:"secondary",children:s.length})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto py-1",children:f.length?f.map(p=>n.jsx(nQ,{collapsed:h[p.id],group:p,onSelectFile:a,onToggle:()=>g(b=>({...b,[p.id]:!b[p.id]})),root:l,selectedFile:i,staging:c},p.id)):n.jsx(Ze,{variant:"muted",className:"m-3 text-center",children:t??d("git.noChangedFiles")})})]})}function nQ({collapsed:e,group:t,onSelectFile:s,onToggle:i,root:a,selectedFile:l,staging:c}){const d=J(),f=e?wn:hn,h=t.files.map(p=>p.path),g=c?t.id==="staged"?{label:d("git.stageArea.unstageAll"),run:()=>c.onUnstage(h)}:{label:d("git.stageArea.stageAll"),run:()=>c.onStage(h)}:null;return n.jsxs("section",{className:"border-b border-border last:border-b-0",children:[n.jsxs("div",{className:"flex w-full items-center justify-between gap-2 bg-muted/45 px-2 py-0.5 text-[10px] font-semibold uppercase text-muted-foreground hover:bg-muted",children:[n.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",onClick:i,type:"button",children:[n.jsx(f,{className:"size-3.5"}),n.jsx("span",{className:"truncate",children:d(t.labelKey)})]}),g?n.jsx("button",{className:"shrink-0 rounded px-1 text-[10px] font-medium normal-case text-muted-foreground transition-colors hover:bg-background hover:text-foreground disabled:opacity-50",disabled:c?.busy,onClick:g.run,type:"button",children:g.label}):null,n.jsx(We,{className:"min-w-6 justify-center font-mono shadow-none",size:"small",variant:"outline",children:t.files.length})]}),e?null:n.jsx("div",{children:t.files.map(p=>n.jsx(iQ,{active:l===p.path,file:p,group:t.id,onClick:()=>s(p.path),root:a,staging:c},p.path))})]})}function iQ({active:e,file:t,group:s,onClick:i,root:a,staging:l}){const c=J(),d=t.path.split("/").pop()||t.path,f=t.path.split("/").slice(0,-1).join("/"),h=a?_5(Bu(a,t.path)):{},g=s==="staged";return n.jsxs("div",{className:re("group flex w-full items-center gap-1.5 px-1 py-0.5 text-[12px] hover:bg-muted",e&&"bg-muted font-medium"),children:[n.jsxs("button",{"aria-label":c("git.file.openAria",{path:t.path}),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",onClick:i,type:"button",...h,children:[n.jsx(Y0,{path:t.path}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5 truncate",children:[n.jsx("span",{"data-testid":"changed-file-name",className:"shrink-0 truncate",children:d}),f?n.jsx("span",{"data-testid":"changed-file-dir",className:"min-w-0 truncate text-muted-foreground",children:f}):null]})]}),l?n.jsx("button",{"aria-label":g?c("git.stageArea.unstageFile",{path:t.path}):c("git.stageArea.stageFile",{path:t.path}),className:"shrink-0 rounded p-0.5 text-muted-foreground opacity-0 transition-colors hover:bg-background hover:text-foreground focus:opacity-100 group-hover:opacity-100 disabled:opacity-50",disabled:l.busy,onClick:()=>g?l.onUnstage([t.path]):l.onStage([t.path]),title:c(g?"git.stageArea.unstage":"git.stageArea.stage"),type:"button",children:g?n.jsx(_E,{className:"size-3.5"}):n.jsx(ms,{className:"size-3.5"})}):null,n.jsx("span",{className:re("ml-1 shrink-0 font-mono text-[10px] font-semibold",s==="untracked"&&"text-amber-700 dark:text-amber-400",s==="staged"&&"text-emerald-700 dark:text-emerald-400",s==="unstaged"&&"text-zinc-800 dark:text-zinc-300"),children:rQ(t,s)})]})}function rQ(e,t){return t==="untracked"?"?":t==="staged"?e.index.trim():e.workingTree.trim()}function aQ(e){return[{id:"unstaged",labelKey:"git.group.changes",files:e.filter(t=>!(t.index==="?"&&t.workingTree==="?")&&t.workingTree.trim())},{id:"staged",labelKey:"git.group.staged",files:e.filter(t=>!(t.index==="?"&&t.workingTree==="?")&&t.index.trim()&&!t.workingTree.trim())},{id:"untracked",labelKey:"git.group.untracked",files:e.filter(t=>t.index==="?"&&t.workingTree==="?")}]}function FA({branch:e,files:t,onDone:s,repo:i}){const a=J(),{sendToAgent:l}=Ot(),[c,d]=x.useState(""),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState(null),_=x.useMemo(()=>t.filter(A=>A.index.trim()&&A.index!=="?").map(A=>A.path),[t]),S=_.length>0&&c.trim().length>0&&f===null;async function C(A,j){h(A),p(null),v(null);try{if(await qE(c.trim(),i),j){const E=await tm(i);v(a("git.commit.committedPushed",{branch:E.branch}))}else v(a("git.commit.committed"));d(""),s()}catch(E){p(E instanceof Error?E.message:String(E))}finally{h(null)}}function N(){l({prompt:WF({branch:e,stagedFiles:_}),source:{type:"git-commit",label:a("git.commit.sourceLabel")},mode:"send",label:a("git.commit.suggestLabel")})}return n.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border bg-card/95 p-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-tight text-muted-foreground",children:a("git.commit.title")}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("git.commit.stagedCount",{count:_.length})}),n.jsxs("button",{"aria-label":a("git.commit.suggestAria"),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50",disabled:_.length===0,onClick:N,title:a("git.commit.suggestTitle"),type:"button",children:[n.jsx(Xt,{className:"size-3.5"}),a("git.commit.aiMessage")]})]})]}),n.jsx("textarea",{"aria-label":a("git.commit.messageAria"),className:"min-h-16 w-full resize-y rounded-md border border-border bg-background px-2.5 py-1.5 text-[12px] outline-none transition-colors placeholder:text-muted-foreground focus:border-foreground/40 focus:ring-2 focus:ring-ring",onChange:A=>{d(A.target.value),p(null),v(null)},placeholder:_.length?a("git.commit.messagePlaceholder"):a("git.commit.stagePrompt"),value:c}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs(Q,{disabled:!S,onClick:()=>{C("commit",!1)},size:"sm",type:"button",variant:"outline",children:[f==="commit"?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Ys,{className:"size-3.5"}),a("git.commit.commit")]}),n.jsxs(Q,{disabled:!S,onClick:()=>{C("push",!0)},size:"sm",type:"button",children:[f==="push"?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Qf,{className:"size-3.5"}),a("git.commit.commitPush")]})]}),g?n.jsx(Ze,{className:"px-2.5 py-1.5 text-[11px]",variant:"destructive",children:g}):b?n.jsx(Ze,{className:"px-2.5 py-1.5 text-[11px]",variant:"muted",children:b}):null]})}function oQ(e){const t={name:"",path:"",children:[],isFile:!1},s=new Map;s.set("",t);const i=[...e].sort();for(const l of i){const c=l.split("/");let d="";for(let f=0;f<c.length;f+=1){const h=c[f],g=f===c.length-1,p=d?`${d}/${h}`:h;let b=s.get(p);b||(b={name:h,path:p,children:[],isFile:g},s.set(p,b),s.get(d)?.children.push(b)),d=p}}const a=l=>{l.children.sort((c,d)=>c.isFile!==d.isFile?c.isFile?1:-1:c.name.localeCompare(d.name)),l.children.forEach(a)};return a(t),t}function qC(e,t){const s={"":!0},i=a=>{for(const l of a.children)l.isFile||(s[l.path]=!0,t&&i(l))};return i(e),s}function GC({defaultExpandAll:e=!1,paths:t,status:s,selectedFile:i,onSelectFile:a,branch:l,emptyMessage:c,root:d,title:f}){const h=J(),g=f??h("git.tree.filesDefault"),p=c??h("git.tree.emptyDefault"),b=x.useMemo(()=>oQ(t),[t]),v=x.useMemo(()=>qC(b,e),[e,b]),_=x.useMemo(()=>qC(b,!0),[b]),S=Math.max(0,Object.keys(_).length-1),C=x.useMemo(()=>{const P=new Map;for(const F of s)P.set(F.path,F);return P},[s]),[N,A]=x.useState(v),[j,E]=x.useState(!1);x.useEffect(()=>{j||b.children.length===0||(A(v),E(!0))},[v,j,b.children.length]);function T(P){A(F=>({...F,[P]:!F[P]}))}function L(){A(_)}function H(){A({"":!0})}return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/95 px-2.5 py-1.5",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold tracking-tight",children:[n.jsx(Co,{className:"size-3.5"}),n.jsx("span",{className:"truncate",children:g})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[S>0?n.jsxs("span",{className:"flex items-center gap-0.5",children:[n.jsx("button",{"aria-label":h("git.tree.expandAll"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:L,title:h("git.tree.expandAll"),type:"button",children:n.jsx(nD,{className:"size-3.5"})}),n.jsx("button",{"aria-label":h("git.tree.collapseAll"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:H,title:h("git.tree.collapseAll"),type:"button",children:n.jsx(tD,{className:"size-3.5"})})]}):null,l?n.jsx(HA,{branch:l}):null,n.jsx(We,{variant:"secondary",children:t.length})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto py-1",children:b.children.length===0?n.jsx(Ze,{variant:"muted",className:"m-3 text-center",children:p}):b.children.map(P=>n.jsx(UA,{depth:0,expanded:N,node:P,onSelectFile:a,onToggle:T,root:d,selectedFile:i,statusByPath:C},P.path))})]})}function UA({depth:e,expanded:t,node:s,onSelectFile:i,onToggle:a,root:l,selectedFile:c,statusByPath:d}){const f=t[s.path]??!1,h=6+e*12,g=l?_5(Bu(l,s.path)):{};if(s.isFile){const v=d.get(s.path),_=c===s.path;return n.jsxs("button",{className:re("flex w-full items-center gap-1.5 px-1 py-0.5 text-left text-[12px] hover:bg-muted",_&&"bg-muted font-medium"),onClick:()=>i(s.path),style:{paddingLeft:h},type:"button",...g,children:[n.jsx(Y0,{path:s.path}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.name}),v?n.jsx(lQ,{file:v}):null]})}const p=f?hn:wn,b=f?Kf:Co;return n.jsxs("div",{children:[n.jsxs("button",{className:"flex w-full items-center gap-1 py-0.5 text-left text-[12px] font-medium hover:bg-muted",onClick:()=>a(s.path),style:{paddingLeft:h},type:"button",...g,children:[n.jsx(p,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx(b,{className:"size-3.5 shrink-0 text-amber-600"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.name})]}),f?s.children.map(v=>n.jsx(UA,{depth:e+1,expanded:t,node:v,onSelectFile:i,onToggle:a,root:l,selectedFile:c,statusByPath:d},v.path)):null]})}function lQ({file:e}){const t=e.workingTree.trim()||e.index.trim();if(!t)return null;const s=e.index.trim()&&!e.workingTree.trim()?"text-emerald-700 dark:text-emerald-400":t==="?"?"text-amber-700 dark:text-amber-400":"text-zinc-700 dark:text-zinc-300";return n.jsx("span",{className:re("ml-1 shrink-0 font-mono text-[10px] font-semibold",s),children:t})}var Eb,VC;function cQ(){if(VC)return Eb;VC=1;function e(U){return U instanceof Map?U.clear=U.delete=U.set=function(){throw new Error("map is read-only")}:U instanceof Set&&(U.add=U.clear=U.delete=function(){throw new Error("set is read-only")}),Object.freeze(U),Object.getOwnPropertyNames(U).forEach(ae=>{const _e=U[ae],$e=typeof _e;($e==="object"||$e==="function")&&!Object.isFrozen(_e)&&e(_e)}),U}class t{constructor(ae){ae.data===void 0&&(ae.data={}),this.data=ae.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(U){return U.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(U,...ae){const _e=Object.create(null);for(const $e in U)_e[$e]=U[$e];return ae.forEach(function($e){for(const lt in $e)_e[lt]=$e[lt]}),_e}const a="</span>",l=U=>!!U.scope,c=(U,{prefix:ae})=>{if(U.startsWith("language:"))return U.replace("language:","language-");if(U.includes(".")){const _e=U.split(".");return[`${ae}${_e.shift()}`,..._e.map(($e,lt)=>`${$e}${"_".repeat(lt+1)}`)].join(" ")}return`${ae}${U}`};class d{constructor(ae,_e){this.buffer="",this.classPrefix=_e.classPrefix,ae.walk(this)}addText(ae){this.buffer+=s(ae)}openNode(ae){if(!l(ae))return;const _e=c(ae.scope,{prefix:this.classPrefix});this.span(_e)}closeNode(ae){l(ae)&&(this.buffer+=a)}value(){return this.buffer}span(ae){this.buffer+=`<span class="${ae}">`}}const f=(U={})=>{const ae={children:[]};return Object.assign(ae,U),ae};class h{constructor(){this.rootNode=f(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ae){this.top.children.push(ae)}openNode(ae){const _e=f({scope:ae});this.add(_e),this.stack.push(_e)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ae){return this.constructor._walk(ae,this.rootNode)}static _walk(ae,_e){return typeof _e=="string"?ae.addText(_e):_e.children&&(ae.openNode(_e),_e.children.forEach($e=>this._walk(ae,$e)),ae.closeNode(_e)),ae}static _collapse(ae){typeof ae!="string"&&ae.children&&(ae.children.every(_e=>typeof _e=="string")?ae.children=[ae.children.join("")]:ae.children.forEach(_e=>{h._collapse(_e)}))}}class g extends h{constructor(ae){super(),this.options=ae}addText(ae){ae!==""&&this.add(ae)}startScope(ae){this.openNode(ae)}endScope(){this.closeNode()}__addSublanguage(ae,_e){const $e=ae.root;_e&&($e.scope=`language:${_e}`),this.add($e)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(U){return U?typeof U=="string"?U:U.source:null}function b(U){return S("(?=",U,")")}function v(U){return S("(?:",U,")*")}function _(U){return S("(?:",U,")?")}function S(...U){return U.map(_e=>p(_e)).join("")}function C(U){const ae=U[U.length-1];return typeof ae=="object"&&ae.constructor===Object?(U.splice(U.length-1,1),ae):{}}function N(...U){return"("+(C(U).capture?"":"?:")+U.map($e=>p($e)).join("|")+")"}function A(U){return new RegExp(U.toString()+"|").exec("").length-1}function j(U,ae){const _e=U&&U.exec(ae);return _e&&_e.index===0}const E=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function T(U,{joinWith:ae}){let _e=0;return U.map($e=>{_e+=1;const lt=_e;let Lt=p($e),Ve="";for(;Lt.length>0;){const qe=E.exec(Lt);if(!qe){Ve+=Lt;break}Ve+=Lt.substring(0,qe.index),Lt=Lt.substring(qe.index+qe[0].length),qe[0][0]==="\\"&&qe[1]?Ve+="\\"+String(Number(qe[1])+lt):(Ve+=qe[0],qe[0]==="("&&_e++)}return Ve}).map($e=>`(${$e})`).join(ae)}const L=/\b\B/,H="[a-zA-Z]\\w*",P="[a-zA-Z_]\\w*",F="\\b\\d+(\\.\\d+)?",M="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",G="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",D=(U={})=>{const ae=/^#![ ]*\//;return U.binary&&(U.begin=S(ae,/.*\b/,U.binary,/\b.*/)),i({scope:"meta",begin:ae,end:/$/,relevance:0,"on:begin":(_e,$e)=>{_e.index!==0&&$e.ignoreMatch()}},U)},q={begin:"\\\\[\\s\\S]",relevance:0},W={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[q]},I={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[q]},Y={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},$=function(U,ae,_e={}){const $e=i({scope:"comment",begin:U,end:ae,contains:[]},_e);$e.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const lt=N("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return $e.contains.push({begin:S(/[ ]+/,"(",lt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),$e},me=$("//","$"),ee=$("/\\*","\\*/"),V=$("#","$"),K={scope:"number",begin:F,relevance:0},xe={scope:"number",begin:M,relevance:0},ie={scope:"number",begin:z,relevance:0},Z={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[q,{begin:/\[/,end:/\]/,relevance:0,contains:[q]}]},ge={scope:"title",begin:H,relevance:0},ne={scope:"title",begin:P,relevance:0},we={begin:"\\.\\s*"+P,relevance:0};var Ue=Object.freeze({__proto__:null,APOS_STRING_MODE:W,BACKSLASH_ESCAPE:q,BINARY_NUMBER_MODE:ie,BINARY_NUMBER_RE:z,COMMENT:$,C_BLOCK_COMMENT_MODE:ee,C_LINE_COMMENT_MODE:me,C_NUMBER_MODE:xe,C_NUMBER_RE:M,END_SAME_AS_BEGIN:function(U){return Object.assign(U,{"on:begin":(ae,_e)=>{_e.data._beginMatch=ae[1]},"on:end":(ae,_e)=>{_e.data._beginMatch!==ae[1]&&_e.ignoreMatch()}})},HASH_COMMENT_MODE:V,IDENT_RE:H,MATCH_NOTHING_RE:L,METHOD_GUARD:we,NUMBER_MODE:K,NUMBER_RE:F,PHRASAL_WORDS_MODE:Y,QUOTE_STRING_MODE:I,REGEXP_MODE:Z,RE_STARTERS_RE:G,SHEBANG:D,TITLE_MODE:ge,UNDERSCORE_IDENT_RE:P,UNDERSCORE_TITLE_MODE:ne});function Pe(U,ae){U.input[U.index-1]==="."&&ae.ignoreMatch()}function Me(U,ae){U.className!==void 0&&(U.scope=U.className,delete U.className)}function pe(U,ae){ae&&U.beginKeywords&&(U.begin="\\b("+U.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",U.__beforeBegin=Pe,U.keywords=U.keywords||U.beginKeywords,delete U.beginKeywords,U.relevance===void 0&&(U.relevance=0))}function Je(U,ae){Array.isArray(U.illegal)&&(U.illegal=N(...U.illegal))}function jt(U,ae){if(U.match){if(U.begin||U.end)throw new Error("begin & end are not supported with match");U.begin=U.match,delete U.match}}function dt(U,ae){U.relevance===void 0&&(U.relevance=1)}const Fs=(U,ae)=>{if(!U.beforeMatch)return;if(U.starts)throw new Error("beforeMatch cannot be used with starts");const _e=Object.assign({},U);Object.keys(U).forEach($e=>{delete U[$e]}),U.keywords=_e.keywords,U.begin=S(_e.beforeMatch,b(_e.begin)),U.starts={relevance:0,contains:[Object.assign(_e,{endsParent:!0})]},U.relevance=0,delete _e.beforeMatch},Nn=["of","and","for","in","not","or","if","then","parent","list","value"],gs="keyword";function Us(U,ae,_e=gs){const $e=Object.create(null);return typeof U=="string"?lt(_e,U.split(" ")):Array.isArray(U)?lt(_e,U):Object.keys(U).forEach(function(Lt){Object.assign($e,Us(U[Lt],ae,Lt))}),$e;function lt(Lt,Ve){ae&&(Ve=Ve.map(qe=>qe.toLowerCase())),Ve.forEach(function(qe){const ct=qe.split("|");$e[ct[0]]=[Lt,fn(ct[0],ct[1])]})}}function fn(U,ae){return ae?Number(ae):ni(U)?0:1}function ni(U){return Nn.includes(U.toLowerCase())}const Hn={},Pt=U=>{console.error(U)},bs=(U,...ae)=>{console.log(`WARN: ${U}`,...ae)},rs=(U,ae)=>{Hn[`${U}/${ae}`]||(console.log(`Deprecated as of ${U}. ${ae}`),Hn[`${U}/${ae}`]=!0)},st=new Error;function nt(U,ae,{key:_e}){let $e=0;const lt=U[_e],Lt={},Ve={};for(let qe=1;qe<=ae.length;qe++)Ve[qe+$e]=lt[qe],Lt[qe+$e]=!0,$e+=A(ae[qe-1]);U[_e]=Ve,U[_e]._emit=Lt,U[_e]._multi=!0}function At(U){if(Array.isArray(U.begin)){if(U.skip||U.excludeBegin||U.returnBegin)throw Pt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),st;if(typeof U.beginScope!="object"||U.beginScope===null)throw Pt("beginScope must be object"),st;nt(U,U.begin,{key:"beginScope"}),U.begin=T(U.begin,{joinWith:""})}}function k(U){if(Array.isArray(U.end)){if(U.skip||U.excludeEnd||U.returnEnd)throw Pt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),st;if(typeof U.endScope!="object"||U.endScope===null)throw Pt("endScope must be object"),st;nt(U,U.end,{key:"endScope"}),U.end=T(U.end,{joinWith:""})}}function se(U){U.scope&&typeof U.scope=="object"&&U.scope!==null&&(U.beginScope=U.scope,delete U.scope)}function ve(U){se(U),typeof U.beginScope=="string"&&(U.beginScope={_wrap:U.beginScope}),typeof U.endScope=="string"&&(U.endScope={_wrap:U.endScope}),At(U),k(U)}function ke(U){function ae(Ve,qe){return new RegExp(p(Ve),"m"+(U.case_insensitive?"i":"")+(U.unicodeRegex?"u":"")+(qe?"g":""))}class _e{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(qe,ct){ct.position=this.position++,this.matchIndexes[this.matchAt]=ct,this.regexes.push([ct,qe]),this.matchAt+=A(qe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const qe=this.regexes.map(ct=>ct[1]);this.matcherRe=ae(T(qe,{joinWith:"|"}),!0),this.lastIndex=0}exec(qe){this.matcherRe.lastIndex=this.lastIndex;const ct=this.matcherRe.exec(qe);if(!ct)return null;const vs=ct.findIndex((cr,To)=>To>0&&cr!==void 0),ss=this.matchIndexes[vs];return ct.splice(0,vs),Object.assign(ct,ss)}}class $e{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(qe){if(this.multiRegexes[qe])return this.multiRegexes[qe];const ct=new _e;return this.rules.slice(qe).forEach(([vs,ss])=>ct.addRule(vs,ss)),ct.compile(),this.multiRegexes[qe]=ct,ct}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(qe,ct){this.rules.push([qe,ct]),ct.type==="begin"&&this.count++}exec(qe){const ct=this.getMatcher(this.regexIndex);ct.lastIndex=this.lastIndex;let vs=ct.exec(qe);if(this.resumingScanAtSamePosition()&&!(vs&&vs.index===this.lastIndex)){const ss=this.getMatcher(0);ss.lastIndex=this.lastIndex+1,vs=ss.exec(qe)}return vs&&(this.regexIndex+=vs.position+1,this.regexIndex===this.count&&this.considerAll()),vs}}function lt(Ve){const qe=new $e;return Ve.contains.forEach(ct=>qe.addRule(ct.begin,{rule:ct,type:"begin"})),Ve.terminatorEnd&&qe.addRule(Ve.terminatorEnd,{type:"end"}),Ve.illegal&&qe.addRule(Ve.illegal,{type:"illegal"}),qe}function Lt(Ve,qe){const ct=Ve;if(Ve.isCompiled)return ct;[Me,jt,ve,Fs].forEach(ss=>ss(Ve,qe)),U.compilerExtensions.forEach(ss=>ss(Ve,qe)),Ve.__beforeBegin=null,[pe,Je,dt].forEach(ss=>ss(Ve,qe)),Ve.isCompiled=!0;let vs=null;return typeof Ve.keywords=="object"&&Ve.keywords.$pattern&&(Ve.keywords=Object.assign({},Ve.keywords),vs=Ve.keywords.$pattern,delete Ve.keywords.$pattern),vs=vs||/\w+/,Ve.keywords&&(Ve.keywords=Us(Ve.keywords,U.case_insensitive)),ct.keywordPatternRe=ae(vs,!0),qe&&(Ve.begin||(Ve.begin=/\B|\b/),ct.beginRe=ae(ct.begin),!Ve.end&&!Ve.endsWithParent&&(Ve.end=/\B|\b/),Ve.end&&(ct.endRe=ae(ct.end)),ct.terminatorEnd=p(ct.end)||"",Ve.endsWithParent&&qe.terminatorEnd&&(ct.terminatorEnd+=(Ve.end?"|":"")+qe.terminatorEnd)),Ve.illegal&&(ct.illegalRe=ae(Ve.illegal)),Ve.contains||(Ve.contains=[]),Ve.contains=[].concat(...Ve.contains.map(function(ss){return Le(ss==="self"?Ve:ss)})),Ve.contains.forEach(function(ss){Lt(ss,ct)}),Ve.starts&&Lt(Ve.starts,qe),ct.matcher=lt(ct),ct}if(U.compilerExtensions||(U.compilerExtensions=[]),U.contains&&U.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return U.classNameAliases=i(U.classNameAliases||{}),Lt(U)}function le(U){return U?U.endsWithParent||le(U.starts):!1}function Le(U){return U.variants&&!U.cachedVariants&&(U.cachedVariants=U.variants.map(function(ae){return i(U,{variants:null},ae)})),U.cachedVariants?U.cachedVariants:le(U)?i(U,{starts:U.starts?i(U.starts):null}):Object.isFrozen(U)?i(U):U}var O="11.11.1";class ce extends Error{constructor(ae,_e){super(ae),this.name="HTMLInjectionError",this.html=_e}}const Oe=s,Ce=i,fe=Symbol("nomatch"),De=7,je=function(U){const ae=Object.create(null),_e=Object.create(null),$e=[];let lt=!0;const Lt="Could not find the language '{}', did you forget to load/include a language module?",Ve={disableAutodetect:!0,name:"Plain text",contains:[]};let qe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:g};function ct(ze){return qe.noHighlightRe.test(ze)}function vs(ze){let it=ze.className+" ";it+=ze.parentNode?ze.parentNode.className:"";const yt=qe.languageDetectRe.exec(it);if(yt){const zt=mn(yt[1]);return zt||(bs(Lt.replace("{}",yt[1])),bs("Falling back to no-highlight mode for this block.",ze)),zt?yt[1]:"no-highlight"}return it.split(/\s+/).find(zt=>ct(zt)||mn(zt))}function ss(ze,it,yt){let zt="",ys="";typeof it=="object"?(zt=ze,yt=it.ignoreIllegals,ys=it.language):(rs("10.7.0","highlight(lang, code, ...args) has been deprecated."),rs("10.7.0",`Please use highlight(code, options) instead.
|
|
@@ -216,7 +216,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
216
216
|
`+O.slice(fe,De),fe=De+1),je=He;return U+=`
|
|
217
217
|
`,O.length-fe>ce&&je>fe?U+=O.slice(fe,je)+`
|
|
218
218
|
`+O.slice(je+1):U+=O.slice(fe),U.slice(1)}function rs(O){let ce="",Oe=0;for(let Ce=0;Ce<O.length;Oe>=65536?Ce+=2:Ce++){Oe=pe(O,Ce);const fe=I[Oe];!fe&&we(Oe)?(ce+=O[Ce],Oe>=65536&&(ce+=O[Ce+1])):ce+=fe||ee(Oe)}return ce}function st(O,ce,Oe){let Ce="";const fe=O.tag;for(let De=0,je=Oe.length;De<je;De+=1){let He=Oe[De];O.replacer&&(He=O.replacer.call(Oe,String(De),He)),(ve(O,ce,He,!1,!1)||typeof He>"u"&&ve(O,ce,null,!1,!1))&&(Ce!==""&&(Ce+=","+(O.condenseFlow?"":" ")),Ce+=O.dump)}O.tag=fe,O.dump="["+Ce+"]"}function nt(O,ce,Oe,Ce){let fe="";const De=O.tag;for(let je=0,He=Oe.length;je<He;je+=1){let U=Oe[je];O.replacer&&(U=O.replacer.call(Oe,String(je),U)),(ve(O,ce+1,U,!0,!0,!1,!0)||typeof U>"u"&&ve(O,ce+1,null,!0,!0,!1,!0))&&((!Ce||fe!=="")&&(fe+=Z(O,ce)),O.dump&&h===O.dump.charCodeAt(0)?fe+="-":fe+="- ",fe+=O.dump)}O.tag=De,O.dump=fe||"[]"}function At(O,ce,Oe){let Ce="";const fe=O.tag,De=Object.keys(Oe);for(let je=0,He=De.length;je<He;je+=1){let U="";Ce!==""&&(U+=", "),O.condenseFlow&&(U+='"');const ae=De[je];let _e=Oe[ae];O.replacer&&(_e=O.replacer.call(Oe,ae,_e)),ve(O,ce,ae,!1,!1)&&(O.dump.length>1024&&(U+="? "),U+=O.dump+(O.condenseFlow?'"':"")+":"+(O.condenseFlow?"":" "),ve(O,ce,_e,!1,!1)&&(U+=O.dump,Ce+=U))}O.tag=fe,O.dump="{"+Ce+"}"}function k(O,ce,Oe,Ce){let fe="";const De=O.tag,je=Object.keys(Oe);if(O.sortKeys===!0)je.sort();else if(typeof O.sortKeys=="function")je.sort(O.sortKeys);else if(O.sortKeys)throw new i("sortKeys must be a boolean or a function");for(let He=0,U=je.length;He<U;He+=1){let ae="";(!Ce||fe!=="")&&(ae+=Z(O,ce));const _e=je[He];let $e=Oe[_e];if(O.replacer&&($e=O.replacer.call(Oe,_e,$e)),!ve(O,ce+1,_e,!0,!0,!0))continue;const lt=O.tag!==null&&O.tag!=="?"||O.dump&&O.dump.length>1024;lt&&(O.dump&&h===O.dump.charCodeAt(0)?ae+="?":ae+="? "),ae+=O.dump,lt&&(ae+=Z(O,ce)),ve(O,ce+1,$e,!0,lt)&&(O.dump&&h===O.dump.charCodeAt(0)?ae+=":":ae+=": ",ae+=O.dump,fe+=ae)}O.tag=De,O.dump=fe||"{}"}function se(O,ce,Oe){const Ce=Oe?O.explicitTypes:O.implicitTypes;for(let fe=0,De=Ce.length;fe<De;fe+=1){const je=Ce[fe];if((je.instanceOf||je.predicate)&&(!je.instanceOf||typeof ce=="object"&&ce instanceof je.instanceOf)&&(!je.predicate||je.predicate(ce))){if(Oe?je.multi&&je.representName?O.tag=je.representName(ce):O.tag=je.tag:O.tag="?",je.represent){const He=O.styleMap[je.tag]||je.defaultStyle;let U;if(l.call(je.represent)==="[object Function]")U=je.represent(ce,He);else if(c.call(je.represent,He))U=je.represent[He](ce,He);else throw new i("!<"+je.tag+'> tag resolver accepts not "'+He+'" style');O.dump=U}return!0}}return!1}function ve(O,ce,Oe,Ce,fe,De,je){O.tag=null,O.dump=Oe,se(O,Oe,!1)||se(O,Oe,!0);const He=l.call(O.dump),U=Ce;Ce&&(Ce=O.flowLevel<0||O.flowLevel>ce);const ae=He==="[object Object]"||He==="[object Array]";let _e,$e;if(ae&&(_e=O.duplicates.indexOf(Oe),$e=_e!==-1),(O.tag!==null&&O.tag!=="?"||$e||O.indent!==2&&ce>0)&&(fe=!1),$e&&O.usedDuplicates[_e])O.dump="*ref_"+_e;else{if(ae&&$e&&!O.usedDuplicates[_e]&&(O.usedDuplicates[_e]=!0),He==="[object Object]")Ce&&Object.keys(O.dump).length!==0?(k(O,ce,O.dump,fe),$e&&(O.dump="&ref_"+_e+O.dump)):(At(O,ce,O.dump),$e&&(O.dump="&ref_"+_e+" "+O.dump));else if(He==="[object Array]")Ce&&O.dump.length!==0?(O.noArrayIndent&&!je&&ce>0?nt(O,ce-1,O.dump,fe):nt(O,ce,O.dump,fe),$e&&(O.dump="&ref_"+_e+O.dump)):(st(O,ce,O.dump),$e&&(O.dump="&ref_"+_e+" "+O.dump));else if(He==="[object String]")O.tag!=="?"&&fn(O,O.dump,ce,De,U);else{if(He==="[object Undefined]")return!1;if(O.skipInvalid)return!1;throw new i("unacceptable kind of an object to dump "+He)}if(O.tag!==null&&O.tag!=="?"){let lt=encodeURI(O.tag[0]==="!"?O.tag.slice(1):O.tag).replace(/!/g,"%21");O.tag[0]==="!"?lt="!"+lt:lt.slice(0,18)==="tag:yaml.org,2002:"?lt="!!"+lt.slice(18):lt="!<"+lt+">",O.dump=lt+" "+O.dump}}return!0}function ke(O,ce){const Oe=[],Ce=[];le(O,Oe,Ce);const fe=Ce.length;for(let De=0;De<fe;De+=1)ce.duplicates.push(Oe[Ce[De]]);ce.usedDuplicates=new Array(fe)}function le(O,ce,Oe){if(O!==null&&typeof O=="object"){const Ce=ce.indexOf(O);if(Ce!==-1)Oe.indexOf(Ce)===-1&&Oe.push(Ce);else if(ce.push(O),Array.isArray(O))for(let fe=0,De=O.length;fe<De;fe+=1)le(O[fe],ce,Oe);else{const fe=Object.keys(O);for(let De=0,je=fe.length;De<je;De+=1)le(O[fe[De]],ce,Oe)}}}function Le(O,ce){ce=ce||{};const Oe=new xe(ce);Oe.noRefs||ke(O,Oe);let Ce=O;return Oe.replacer&&(Ce=Oe.replacer.call({"":Ce},"",Ce)),ve(Oe,0,Ce,!0,!0)?Oe.dump+`
|
|
219
|
-
`:""}t.exports.dump=Le})),vT=FJ(ts(((e,t)=>{var s=qJ(),i=GJ();function a(l,c){return function(){throw new Error("Function yaml."+l+" is removed in js-yaml 4. Use yaml."+c+" instead, which is now safe by default.")}}t.exports.Type=Cn(),t.exports.Schema=tT(),t.exports.FAILSAFE_SCHEMA=rT(),t.exports.JSON_SCHEMA=uT(),t.exports.CORE_SCHEMA=dT(),t.exports.DEFAULT_SCHEMA=c1(),t.exports.load=s.load,t.exports.loadAll=s.loadAll,t.exports.dump=i.dump,t.exports.YAMLException=Gu(),t.exports.types={binary:mT(),float:cT(),map:iT(),null:aT(),pairs:gT(),set:bT(),timestamp:hT(),bool:oT(),int:lT(),merge:fT(),omap:pT(),seq:nT(),str:sT()},t.exports.safeLoad=a("safeLoad","load"),t.exports.safeLoadAll=a("safeLoadAll","loadAll"),t.exports.safeDump=a("safeDump","dump")}))()),{Type:pse,Schema:gse,FAILSAFE_SCHEMA:bse,JSON_SCHEMA:vse,CORE_SCHEMA:xse,DEFAULT_SCHEMA:yse,load:_se,loadAll:wse,dump:Sse,YAMLException:kse,types:Cse,safeLoad:Nse,safeLoadAll:Ese,safeDump:jse}=vT.default,VJ=vT.default;function xT(e){return e!==null&&typeof e=="object"}function yT(e){return typeof e=="string"?"text-rose-700 dark:text-rose-300":typeof e=="number"?"text-emerald-700 dark:text-emerald-300":typeof e=="boolean"?"text-blue-700 dark:text-blue-400":e==null?"text-muted-foreground italic":"text-foreground"}function _T(e){return e==null?"null":typeof e=="string"?e===""?'""':e:String(e)}function wT({label:e,value:t,depth:s,defaultOpen:i}){const[a,l]=x.useState(i),c={paddingLeft:`${s*1.1}rem`};if(!xT(t))return n.jsxs("div",{className:"flex items-baseline gap-2 py-[1px]",style:c,children:[n.jsxs("span",{className:"text-muted-foreground",children:[e,":"]}),n.jsx("span",{className:re("whitespace-pre-wrap break-words",yT(t)),children:_T(t)})]});const d=Array.isArray(t)?t.map((h,g)=>[String(g),h]):Object.entries(t),f=Array.isArray(t)?`[${d.length}]`:`{${d.length}}`;return n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"flex w-full items-center gap-1 py-[1px] text-left hover:bg-muted",style:c,children:[a?n.jsx(hn,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(wn,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"font-medium text-foreground",children:e}),n.jsx("span",{className:"text-muted-foreground",children:f})]}),a?d.map(([h,g])=>n.jsx(wT,{label:h,value:g,depth:s+1,defaultOpen:s<1},h)):null]})}function WJ({content:e}){const t=J(),s=x.useMemo(()=>{try{const a=VJ.loadAll(e);return{value:a.length<=1?a[0]:a,error:null}}catch(a){return{value:null,error:a instanceof Error?a.message:String(a)}}},[e]);if(s.error)return n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:t("git.yaml.parseError",{error:s.error})})});if(!xT(s.value))return n.jsx("div",{className:"p-4 font-mono text-[12px]",children:n.jsx("span",{className:yT(s.value),children:_T(s.value)})});const i=Array.isArray(s.value)?s.value.map((a,l)=>[String(l),a]):Object.entries(s.value);return n.jsx("div",{className:"min-w-max px-4 py-3 font-mono text-[12px] leading-[1.6]",children:i.map(([a,l])=>n.jsx(wT,{label:a,value:l,depth:0,defaultOpen:!0},a))})}const KJ=x.lazy(()=>Mu(()=>import("./code-editor-
|
|
219
|
+
`:""}t.exports.dump=Le})),vT=FJ(ts(((e,t)=>{var s=qJ(),i=GJ();function a(l,c){return function(){throw new Error("Function yaml."+l+" is removed in js-yaml 4. Use yaml."+c+" instead, which is now safe by default.")}}t.exports.Type=Cn(),t.exports.Schema=tT(),t.exports.FAILSAFE_SCHEMA=rT(),t.exports.JSON_SCHEMA=uT(),t.exports.CORE_SCHEMA=dT(),t.exports.DEFAULT_SCHEMA=c1(),t.exports.load=s.load,t.exports.loadAll=s.loadAll,t.exports.dump=i.dump,t.exports.YAMLException=Gu(),t.exports.types={binary:mT(),float:cT(),map:iT(),null:aT(),pairs:gT(),set:bT(),timestamp:hT(),bool:oT(),int:lT(),merge:fT(),omap:pT(),seq:nT(),str:sT()},t.exports.safeLoad=a("safeLoad","load"),t.exports.safeLoadAll=a("safeLoadAll","loadAll"),t.exports.safeDump=a("safeDump","dump")}))()),{Type:pse,Schema:gse,FAILSAFE_SCHEMA:bse,JSON_SCHEMA:vse,CORE_SCHEMA:xse,DEFAULT_SCHEMA:yse,load:_se,loadAll:wse,dump:Sse,YAMLException:kse,types:Cse,safeLoad:Nse,safeLoadAll:Ese,safeDump:jse}=vT.default,VJ=vT.default;function xT(e){return e!==null&&typeof e=="object"}function yT(e){return typeof e=="string"?"text-rose-700 dark:text-rose-300":typeof e=="number"?"text-emerald-700 dark:text-emerald-300":typeof e=="boolean"?"text-blue-700 dark:text-blue-400":e==null?"text-muted-foreground italic":"text-foreground"}function _T(e){return e==null?"null":typeof e=="string"?e===""?'""':e:String(e)}function wT({label:e,value:t,depth:s,defaultOpen:i}){const[a,l]=x.useState(i),c={paddingLeft:`${s*1.1}rem`};if(!xT(t))return n.jsxs("div",{className:"flex items-baseline gap-2 py-[1px]",style:c,children:[n.jsxs("span",{className:"text-muted-foreground",children:[e,":"]}),n.jsx("span",{className:re("whitespace-pre-wrap break-words",yT(t)),children:_T(t)})]});const d=Array.isArray(t)?t.map((h,g)=>[String(g),h]):Object.entries(t),f=Array.isArray(t)?`[${d.length}]`:`{${d.length}}`;return n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"flex w-full items-center gap-1 py-[1px] text-left hover:bg-muted",style:c,children:[a?n.jsx(hn,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(wn,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"font-medium text-foreground",children:e}),n.jsx("span",{className:"text-muted-foreground",children:f})]}),a?d.map(([h,g])=>n.jsx(wT,{label:h,value:g,depth:s+1,defaultOpen:s<1},h)):null]})}function WJ({content:e}){const t=J(),s=x.useMemo(()=>{try{const a=VJ.loadAll(e);return{value:a.length<=1?a[0]:a,error:null}}catch(a){return{value:null,error:a instanceof Error?a.message:String(a)}}},[e]);if(s.error)return n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:t("git.yaml.parseError",{error:s.error})})});if(!xT(s.value))return n.jsx("div",{className:"p-4 font-mono text-[12px]",children:n.jsx("span",{className:yT(s.value),children:_T(s.value)})});const i=Array.isArray(s.value)?s.value.map((a,l)=>[String(l),a]):Object.entries(s.value);return n.jsx("div",{className:"min-w-max px-4 py-3 font-mono text-[12px] leading-[1.6]",children:i.map(([a,l])=>n.jsx(wT,{label:a,value:l,depth:0,defaultOpen:!0},a))})}const KJ=x.lazy(()=>Mu(()=>import("./code-editor-Cql1PV_g.js"),[]).then(e=>({default:e.CodeEditor})));function YJ(e){const t=e.split("/").pop()?.toLowerCase().split(".").pop()??"";return t==="md"||t==="mdx"||t==="markdown"?"markdown":t==="yml"||t==="yaml"?"yaml":null}function XJ(e){const t=e.split("/").pop()?.toLowerCase()??"",s=t.includes(".")?t.split(".").pop()??"":"",i={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",sh:"bash",bash:"bash",zsh:"bash",json:"json",yaml:"yaml",yml:"yaml",toml:"ini",ini:"ini",md:"markdown",mdx:"markdown",css:"css",scss:"scss",less:"less",html:"xml",xml:"xml",sql:"sql",dockerfile:"dockerfile"};return i[s]?i[s]:t==="dockerfile"?"dockerfile":null}function ZJ(e,t){const s=e.endsWith(`
|
|
220
220
|
`)?e.slice(0,-1):e;return!t||!Mx.getLanguage(t)?s.split(`
|
|
221
221
|
`).map(zN):s.split(`
|
|
222
222
|
`).map(i=>{if(!i)return"";try{return Mx.highlight(i,{language:t,ignoreIllegals:!0}).value}catch{return zN(i)}})}function zN(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function QJ({content:e,path:t}){const s=x.useMemo(()=>XJ(t),[t]),i=x.useMemo(()=>ZJ(e,s),[e,s]),a=`${Math.max(2,String(i.length).length)}ch`;return n.jsx("div",{className:"min-w-max font-mono text-[12px] leading-[1.5]",children:i.map((l,c)=>n.jsxs("div",{className:"flex",children:[n.jsx("span",{className:"shrink-0 select-none border-r border-zinc-200 bg-zinc-100 px-2 text-right text-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-500",style:{minWidth:`calc(${a} + 1rem)`},children:c+1}),n.jsx("span",{className:"hljs whitespace-pre px-3 text-zinc-800 dark:text-zinc-100",dangerouslySetInnerHTML:{__html:l||" "}})]},c))})}function JJ({path:e,isModified:t,onViewDiff:s,onFileSaved:i,onSendToAi:a}){const[l,c]=x.useState(null),[d,f]=x.useState(""),[h,g]=x.useState(!1),[p,b]=x.useState(null),[v,_]=x.useState(!1),[S,C]=x.useState(!1),{success:N,error:A}=cs(),j=J(),E=x.useMemo(()=>YJ(e),[e]),[T,L]=x.useState("preview"),H=!!(l&&!l.binary&&!l.truncated),P=l?d!==l.content:!1;x.useEffect(()=>{L(E?"preview":"source"),g(!1)},[E]),x.useEffect(()=>{if(!e){c(null);return}let z=!0;return _(!0),b(null),g(!1),S7(e).then(G=>{z&&(c(G),f(G.content),_(!1))}).catch(G=>{z&&(b(G instanceof Error?G.message:String(G)),_(!1))}),()=>{z=!1}},[e]);async function F(){if(!(!e||!l||!P||S)){C(!0);try{await k7(e,d);const z={...l,content:d,size:new TextEncoder().encode(d).length};c(z),g(!1),N(j("git.fileViewer.savedToast",{path:e})),i?.(e)}catch(z){A(z instanceof Error?z.message:String(z))}finally{C(!1)}}}function M(){f(l?.content??""),g(!1)}return e?n.jsxs("section",{className:"flex min-h-0 min-w-0 flex-col border-l border-border bg-card",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-[13px] font-semibold tracking-tight",children:e}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground",children:[n.jsx("span",{children:j("git.fileViewer.readOnly")}),l?.truncated?n.jsx("span",{className:"text-amber-700",children:j("git.fileViewer.truncated")}):null,l?.binary?n.jsx("span",{className:"text-amber-700",children:j("git.fileViewer.binary")}):null]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[E&&!l?.binary?n.jsxs("div",{className:"flex items-center rounded-md border border-border p-0.5",children:[n.jsxs("button",{type:"button",onClick:()=>L("preview"),"aria-pressed":T==="preview",className:re("flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition-colors",T==="preview"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:[n.jsx(Wf,{className:"size-3.5"}),j("git.fileViewer.preview")]}),n.jsxs("button",{type:"button",onClick:()=>L("source"),"aria-pressed":T==="source",className:re("flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition-colors",T==="source"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:[n.jsx(dE,{className:"size-3.5"}),j("git.fileViewer.source")]})]}):null,t?n.jsx(Q,{onClick:s,size:"sm",type:"button",variant:"outline",children:j("git.fileViewer.viewDiff")}):null,a?n.jsx(Q,{"aria-label":j("git.fileViewer.sendToAi"),className:"size-8",disabled:!e,onClick:a,size:"icon",title:j("git.fileViewer.sendPathToAi"),type:"button",variant:"outline",children:n.jsx(Xt,{className:"size-4"})}):null,h?n.jsxs(n.Fragment,{children:[n.jsxs(Q,{disabled:!P||S,onClick:()=>{F()},size:"sm",type:"button",children:[n.jsx(SE,{}),j("git.fileViewer.apply")]}),n.jsxs(Q,{disabled:S,onClick:M,size:"sm",type:"button",variant:"outline",children:[n.jsx(Vt,{}),j("common.cancel")]})]}):H?n.jsxs(Q,{onClick:()=>{L("source"),g(!0)},size:"sm",type:"button",variant:"outline",children:[n.jsx(Nl,{}),j("common.edit")]}):null]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-card",children:p?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:p})}):v?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:j("common.loading")}):l?.binary?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:j("git.fileViewer.cannotBinary")}):l?h?n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:j("git.fileViewer.loadingEditor")}),children:n.jsx(KJ,{path:e,value:d,onChange:f})}):E&&T==="preview"?E==="markdown"?n.jsx(l1,{content:l.content}):n.jsx(WJ,{content:l.content}):n.jsx(QJ,{content:l.content,path:e}):null})]}):n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-dashed p-12 text-center",children:j("git.fileViewer.selectFile")})})}function eee({activeHunkIndex:e,filePaths:t,hunkCount:s,pendingNextFilePath:i,selectedFile:a}){if(s>0&&e<s-1)return{kind:"hunk",activeHunkIndex:e+1};const l=t.indexOf(a),c=t[l+1];return c?i===c?{kind:"file",filePath:c}:{kind:"confirm-next-file",filePath:c}:{kind:"none"}}function BN(e){const t={name:"",fullPath:"",children:new Map};for(const s of e){const i=s.name.split("/");let a=t;i.forEach((l,c)=>{let d=a.children.get(l);d||(d={name:l,fullPath:i.slice(0,c+1).join("/"),children:new Map},a.children.set(l,d)),a=d}),a.branch=s}return t}function IN({label:e,tree:t,onSelect:s,defaultOpen:i,forceOpen:a}){const[l,c]=x.useState(i??!1),d=a||l,f=t.children.size===0;return n.jsxs("div",{className:"mb-1",children:[n.jsxs("button",{type:"button",onClick:()=>c(h=>!h),className:"flex w-full items-center gap-1 px-2 py-0.5 text-left text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:text-foreground",children:[d?n.jsx(hn,{size:12}):n.jsx(wn,{size:12}),e,f?null:n.jsxs("span",{className:"ml-1 text-[10px] font-normal",children:["(",t.children.size,")"]})]}),d&&!f?n.jsx("ul",{children:Array.from(t.children.values()).map(h=>n.jsx(ST,{node:h,depth:1,onSelect:s,forceOpen:a},h.fullPath))}):null]})}function ST({node:e,depth:t,onSelect:s,forceOpen:i}){const[a,l]=x.useState(!0),c=i||a,d=e.children.size>0,f=e.branch,h={paddingLeft:`${t*10}px`};return!d&&f?n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>s(f),style:h,title:f.name,className:`flex w-full items-center gap-1.5 py-0.5 pr-2 text-left text-[12px] hover:bg-muted/60 ${f.current?"font-semibold text-emerald-700":""}`,children:[n.jsx(_n,{size:11,className:"shrink-0 opacity-70"}),n.jsx("span",{className:"truncate",children:e.name}),f.current?n.jsx("span",{className:"text-[10px]",children:"●"}):null]})}):n.jsxs("li",{children:[n.jsxs("button",{type:"button",onClick:()=>{f?s(f):l(g=>!g)},style:h,className:"flex w-full items-center gap-1 py-0.5 pr-2 text-left text-[12px] hover:bg-muted/60",children:[d?c?n.jsx(hn,{size:11}):n.jsx(wn,{size:11}):n.jsx("span",{className:"inline-block w-[11px]"}),n.jsx("span",{className:"truncate",children:e.name})]}),c&&d?n.jsx("ul",{children:Array.from(e.children.values()).map(g=>n.jsx(ST,{node:g,depth:t+1,onSelect:s,forceOpen:i},g.fullPath))}):null]})}function tee({selectedCommit:e,selectedFile:t,diff:s,diffLoading:i,diffError:a}){const l=J();return n.jsxs("section",{className:"flex min-h-0 min-w-0 flex-col bg-card border-b border-border",children:[n.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-1.5",children:n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-[13px] font-semibold tracking-tight",children:t??(e?e.subject:l("git.graph.commitFallback"))}),e?n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:e.hash.slice(0,12)}),n.jsxs("span",{children:[e.author," <",e.email,">"]}),n.jsx("span",{children:new Date(e.timestamp*1e3).toLocaleString()})]}):null]})}),n.jsx("div",{className:"relative min-h-0 min-w-0 flex-1",children:a?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:a})}):e?i?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("git.diff.loading")}):s?n.jsx(zu,{activeHunkIndex:0,diff:s}):n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-dashed p-6 text-center",children:e.parents.length>1?l("git.graph.mergeNoDiff"):l("git.graph.noTextualChanges")})}):n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-dashed p-12 text-center",children:l("git.graph.selectCommitDiff")})})})]})}function see({files:e,filesError:t,selectedHash:s,selectedFile:i,onSelect:a}){const l=J();return n.jsxs("aside",{className:"flex min-h-0 flex-col overflow-hidden border-r border-border",children:[n.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:n.jsxs("h2",{className:"text-[13px] font-semibold tracking-tight",children:[l("git.tree.filesDefault"),e.length?n.jsx("span",{className:"ml-2 text-[11px] font-normal text-muted-foreground",children:e.length}):null]})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t?n.jsx("div",{className:"p-3",children:n.jsx(Ze,{variant:"destructive",children:t})}):s?e.length===0?n.jsx("div",{className:"p-3 text-[12px] text-muted-foreground",children:l("git.graph.noFileChanges")}):n.jsx("ul",{className:"divide-y divide-border",children:e.map(c=>n.jsx("li",{children:n.jsxs("button",{onClick:()=>a(c.path),type:"button",title:c.path,className:`flex w-full items-center gap-2 px-2 py-1 text-left text-[12px] transition-colors hover:bg-muted/60 ${i===c.path?"bg-muted":""}`,children:[n.jsx("span",{className:nee(c.index),children:c.index.trim()||"·"}),n.jsx("span",{className:"truncate font-mono",children:c.path})]})},c.path))}):n.jsx("div",{className:"p-3 text-[12px] text-muted-foreground",children:l("git.graph.selectCommitFiles")})})]})}function nee(e){const t="inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-[10px] font-bold";switch(e.trim().toUpperCase()){case"A":return`${t} bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`;case"D":return`${t} bg-red-100 text-red-800 dark:bg-red-500/15 dark:text-red-300`;case"M":return`${t} bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300`;case"R":return`${t} bg-blue-100 text-blue-800 dark:bg-blue-500/15 dark:text-blue-300`;case"C":return`${t} bg-indigo-100 text-indigo-800 dark:bg-indigo-500/15 dark:text-indigo-300`;default:return`${t} bg-slate-100 text-slate-700 dark:bg-slate-500/15 dark:text-slate-300`}}const HN=["#3b82f6","#10b981","#f59e0b","#ec4899","#8b5cf6","#14b8a6","#ef4444","#84cc16"];function Vc(e){return HN[e%HN.length]}function iee({lane:e,laneCount:t,edges:s,throughLanes:i,isMerge:a,height:l=28,laneWidth:c=14}){const f=Math.max(e+1,t,1)*c,h=l/2,g=Wc(e,c),p=a?4:3.5;return n.jsxs("svg",{width:f,height:l,viewBox:`0 0 ${f} ${l}`,style:{flex:"0 0 auto",display:"block"},children:[i.map(b=>n.jsx("line",{x1:Wc(b,c),y1:0,x2:Wc(b,c),y2:l,stroke:Vc(b),strokeWidth:1.5},`t-${b}`)),n.jsx("line",{x1:g,y1:0,x2:g,y2:h,stroke:Vc(e),strokeWidth:1.5}),s.map((b,v)=>{const _=Wc(b.fromLane,c),S=Wc(b.toLane,c);if(_===S)return n.jsx("line",{x1:_,y1:h,x2:S,y2:l,stroke:Vc(b.toLane),strokeWidth:1.5},`e-${v}`);const C=h+(l-h)/2;return n.jsx("path",{d:`M ${_} ${h} C ${_} ${C}, ${S} ${C}, ${S} ${l}`,fill:"none",stroke:Vc(b.toLane),strokeWidth:1.5},`e-${v}`)}),n.jsx("circle",{cx:g,cy:h,r:p,fill:Vc(e),stroke:"var(--background, #fff)",strokeWidth:1.5})]})}function Wc(e,t){return e*t+t/2}function ree({sha:e}){const t=J(),[s,i]=x.useState(()=>cY(e)??null),a=x.useRef(null);if(x.useEffect(()=>{if(s)return;const d=a.current;if(!d||typeof IntersectionObserver>"u")return;let f=!0;const h=new IntersectionObserver(g=>{g.some(p=>p.isIntersecting)&&(h.disconnect(),wA(e).then(p=>{f&&i(p)}).catch(()=>{}))},{rootMargin:"200px"});return h.observe(d),()=>{f=!1,h.disconnect()}},[e,s]),!s||s.state==="unknown"||s.totalCount===0)return n.jsx("span",{ref:a,"aria-hidden":!0,className:"inline-block size-2 shrink-0"});const l=aee(s.state),c=t("github.ci.badgeLabel",{state:s.state,count:s.totalCount});return n.jsx("span",{"aria-label":c,className:`shrink-0 size-2 rounded-full ${l}`,title:c})}function aee(e){switch(e){case"success":return"bg-emerald-500";case"pending":return"bg-amber-400 animate-pulse";case"failure":return"bg-red-500";case"error":return"bg-orange-500";default:return"bg-zinc-400"}}const $N=28;function oee({commits:e,loading:t,error:s,selectedHash:i,maxLanes:a,rowRefs:l,onSelect:c,onLoadMore:d}){const f=J(),{sendToAgent:h}=Ot(),[g,p]=x.useState(null);function b(v,_){p(null),h({prompt:VF(v,_),source:{type:"git-commit",label:v.hash.slice(0,7)},label:`${v.hash.slice(0,7)}: ${_}`})}return n.jsxs("aside",{className:"flex min-h-0 flex-col overflow-hidden border-r border-border",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsxs("h2",{className:"text-[13px] font-semibold tracking-tight",children:[f("git.graph.commitTree"),e.length?n.jsx("span",{className:"ml-2 text-[11px] font-normal text-muted-foreground",children:f("git.graph.commitsCount",{count:e.length})}):null]}),n.jsx(Q,{disabled:t,onClick:d,size:"sm",type:"button",variant:"outline",children:f("git.graph.loadMore")})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s?n.jsx("div",{className:"p-3",children:n.jsx(Ze,{variant:"destructive",children:s})}):t&&e.length===0?n.jsx("div",{className:"p-3 text-[12px] text-muted-foreground",children:f("git.graph.loadingCommits")}):e.length===0?n.jsx("div",{className:"p-3 text-[12px] text-muted-foreground",children:f("git.graph.noCommits")}):n.jsx("ul",{className:"divide-y divide-border",children:e.map(v=>n.jsxs("li",{ref:_=>{_?l.current.set(v.hash,_):l.current.delete(v.hash)},className:"group flex flex-col",children:[n.jsxs("div",{className:`flex items-center transition-colors hover:bg-muted/60 ${i===v.hash?"bg-muted":""}`,children:[n.jsxs("button",{onClick:()=>c(v.hash),type:"button",className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-0.5 text-left",style:{minHeight:$N},title:`${v.hash}
|
|
@@ -224,4 +224,4 @@ ${v.author} <${v.email}>
|
|
|
224
224
|
${v.subject}`,children:[n.jsx(iee,{lane:v.lane,laneCount:Math.max(v.laneCount,a),edges:v.edges,throughLanes:v.throughLanes,isMerge:v.parents.length>1,height:$N}),n.jsxs("span",{className:"flex items-center gap-1 font-mono text-[10px] text-muted-foreground",children:[v.hash.slice(0,7),n.jsx(ree,{sha:v.hash})]}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[v.refs.map(_=>n.jsx("span",{className:cee(_.kind),children:_.name},`${_.kind}-${_.name}`)),n.jsx("span",{className:"truncate text-[12px]",children:v.subject})]}),n.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:v.author}),n.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/70",title:new Date(v.timestamp*1e3).toLocaleString(),children:lee(v.timestamp)})]}),n.jsx(rr,{className:`mr-1 shrink-0 ${g===v.hash?"opacity-100":""}`,label:f("git.graph.askCommitLabel",{sha:v.hash.slice(0,7)}),onAsk:()=>p(_=>_===v.hash?null:v.hash)})]}),g===v.hash?n.jsx("div",{className:"px-2 pb-1.5 pt-0.5",children:n.jsx(Hr,{placeholder:f("git.graph.askPlaceholder"),onSubmit:_=>b(v,_),onCancel:()=>p(null)})}):null]},v.hash))})})]})}function lee(e){if(!e)return"";const t=Math.max(0,Math.floor(Date.now()/1e3-e));if(t<60)return`${t}s`;const s=Math.floor(t/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const a=Math.floor(i/24);if(a<30)return`${a}d`;const l=Math.floor(a/30);return l<12?`${l}mo`:`${Math.floor(l/12)}y`}function cee(e){const t="rounded border px-1.5 py-px text-[10px] font-medium";switch(e){case"head":return`${t} border-emerald-200 bg-emerald-100 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-500/15 dark:text-emerald-300`;case"branch":return`${t} border-blue-200 bg-blue-100 text-blue-800 dark:border-blue-400/30 dark:bg-blue-500/15 dark:text-blue-300`;case"remote":return`${t} border-slate-200 bg-slate-100 text-slate-700 dark:border-zinc-700/80 dark:bg-zinc-800/80 dark:text-zinc-300`;case"tag":return`${t} border-amber-200 bg-amber-100 text-amber-800 dark:border-amber-400/30 dark:bg-amber-500/15 dark:text-amber-300`}}const FN=200;function uee(){const[e,t]=x.useState([]),[s,i]=x.useState(FN),[a,l]=x.useState(0),[c,d]=x.useState(!0),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState([]),[_,S]=x.useState(!1),[C,N]=x.useState(null),[A,j]=x.useState(null),[E,T]=x.useState(""),[L,H]=x.useState(!1),[P,F]=x.useState(null),M=x.useCallback(D=>{p(D),v([]),j(null),T("")},[]);x.useEffect(()=>{let D=!0;return d(!0),h(null),$E(s).then(q=>{D&&(t(q),q.length>0&&!q.some(W=>W.hash===g)&&M(q[0].hash))}).catch(q=>{D&&h(q instanceof Error?q.message:String(q))}).finally(()=>{D&&d(!1)}),()=>{D=!1}},[s,a]),x.useEffect(()=>{if(!g){v([]),j(null),S(!1);return}let D=!0;return N(null),S(!0),y7(g).then(q=>{D&&(v(q),j(q[0]?.path??null))}).catch(q=>{D&&N(q instanceof Error?q.message:String(q))}).finally(()=>{D&&S(!1)}),()=>{D=!1}},[g]),x.useEffect(()=>{if(!g||!A){T(""),H(!1);return}let D=!0;return F(null),H(!0),x7(g,A).then(q=>{D&&T(q)}).catch(q=>{D&&F(q instanceof Error?q.message:String(q))}).finally(()=>{D&&H(!1)}),()=>{D=!1}},[g,A]);const z=x.useMemo(()=>e.reduce((D,q)=>Math.max(D,q.laneCount),1),[e]),G=e.find(D=>D.hash===g)??null;return{commits:e,loading:c,error:f,selectedHash:g,setSelectedHash:M,files:b,filesError:C,selectedFile:A,setSelectedFile:j,diff:E,diffLoading:L||_,diffError:P,maxLanes:z,selectedCommit:G,loadMore:()=>i(D=>D+FN),refresh:()=>l(D=>D+1)}}function dee({branches:e=[]}){const{commits:t,loading:s,error:i,selectedHash:a,setSelectedHash:l,files:c,filesError:d,selectedFile:f,setSelectedFile:h,diff:g,diffLoading:p,diffError:b,maxLanes:v,selectedCommit:_,loadMore:S,refresh:C}=uee(),N=J();Eo(C);const[A,j]=x.useState(""),E=x.useMemo(()=>{const M=A.trim().toLowerCase();return M?e.filter(z=>z.name.toLowerCase().includes(M)):e},[e,A]),T=x.useMemo(()=>BN(E.filter(M=>!M.remote)),[E]),L=x.useMemo(()=>BN(E.filter(M=>M.remote)),[E]),H=A.trim().length>0,P=x.useRef(new Map);function F(M){const z=M.remote?"remote":"branch",G=t.find(W=>W.refs.some(I=>I.kind===z&&I.name===M.name));if(!G)return;l(G.hash);const D=P.current.get(G.hash),q=D?.parentElement?.parentElement;!D||!q||q.scrollTo({top:Math.max(D.offsetTop-q.clientHeight/2+D.clientHeight/2,0),behavior:"smooth"})}return n.jsxs("div",{className:"grid h-full min-h-0 overflow-hidden border-0 bg-card/85 grid-cols-[220px_minmax(0,1fr)]",children:[n.jsxs("aside",{className:"flex min-h-0 flex-col overflow-hidden border-r border-border",children:[n.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-b border-border px-3 py-1.5",children:[n.jsx("h2",{className:"text-[13px] font-semibold tracking-tight",children:N("git.graph.branches")}),n.jsx("input",{type:"search",value:A,onChange:M=>j(M.target.value),placeholder:N("git.graph.searchBranches"),className:"w-full rounded border border-border bg-background px-2 py-1 text-[11px] outline-none focus:border-foreground"})]}),n.jsxs("div",{className:"min-h-0 flex-1 overflow-auto py-1",children:[n.jsx(IN,{label:N("git.branch.sectionLocal"),tree:T,onSelect:F,defaultOpen:!0,forceOpen:H}),n.jsx(IN,{label:N("git.branch.sectionRemote"),tree:L,onSelect:F,forceOpen:H})]})]}),n.jsxs("div",{className:"grid min-h-0 min-w-0 grid-rows-[minmax(0,3fr)_minmax(0,2fr)]",children:[n.jsx(tee,{selectedCommit:_,selectedFile:f,diff:g,diffLoading:p,diffError:b}),n.jsxs("div",{className:"grid min-h-0 min-w-0 grid-cols-[minmax(0,1fr)_280px]",children:[n.jsx(oee,{commits:t,loading:s,error:i,selectedHash:a,maxLanes:v,rowRefs:P,onSelect:l,onLoadMore:S}),n.jsx(see,{files:c,filesError:d,selectedHash:a,selectedFile:f,onSelect:h})]})]})]})}function hee({repo:e,file:t,onClose:s}){const i=J(),[a,l]=x.useState(""),[c,d]=x.useState(null),[f,h]=x.useState(!0);x.useEffect(()=>{let p=!0;return h(!0),d(null),FE(t,e).then(b=>{p&&l(b)}).catch(b=>{p&&d(b instanceof Error?b.message:String(b))}).finally(()=>{p&&h(!1)}),()=>{p=!1}},[e,t]),x.useEffect(()=>{function p(b){b.key==="Escape"&&s()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s]);const g=O0(a);return Hi.createPortal(n.jsxs("div",{className:"fixed inset-0 z-[1000] flex justify-end",children:[n.jsx("button",{"aria-label":i("git.diff.closeAria"),className:"absolute inset-0 bg-black/35",onClick:s,type:"button"}),n.jsxs("div",{className:"relative z-10 flex h-full w-[min(900px,calc(100vw-3rem))] flex-col bg-card shadow-xl",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-[13px] font-semibold tracking-tight",children:t}),n.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:e}),g.additions||g.deletions?n.jsxs("span",{className:"flex items-center gap-1 font-mono",children:[n.jsxs("span",{className:"text-emerald-700",children:["+",g.additions]}),n.jsxs("span",{className:"text-red-700",children:["-",g.deletions]})]}):null]})]}),n.jsx(Q,{"aria-label":i("git.diff.closeAria"),onClick:s,size:"icon",variant:"ghost",children:n.jsx(Vt,{})})]}),n.jsx("div",{className:"relative min-h-0 min-w-0 flex-1",children:c?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:c})}):f?n.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:i("git.diff.loading")}):n.jsx(zu,{diff:a||i("git.noUnstagedDiff")})})]})]}),document.body)}function kT(e){return e.split(/[\\/]/).filter(Boolean).pop()??"project"}function fee({initialPath:e,onSelect:t,selectedPath:s}){const i=J(),[a,l]=x.useState(e),[c,d]=x.useState(e),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState(!1),_=mee(f);return x.useEffect(()=>{l(e)},[e]),x.useEffect(()=>{f&&d(f.path)},[f]),x.useEffect(()=>{let S=!0;return v(!0),p(null),XE(a).then(C=>{S&&(h(C),t(C.path))}).catch(C=>{S&&p(C instanceof Error?C.message:String(C))}).finally(()=>{S&&v(!1)}),()=>{S=!1}},[a,t]),n.jsxs("div",{className:"rounded-md border border-border bg-background",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b border-border p-2",children:[_?n.jsx(Q,{"aria-label":i("git.folder.parentAria"),onClick:()=>f&&l(f.parent),size:"icon",type:"button",variant:"ghost",children:n.jsx(hn,{className:"rotate-90"})}):null,n.jsx(pt,{"aria-label":i("git.folder.pathAria"),className:"h-7 min-w-0 flex-1 font-mono text-xs",onChange:S=>d(S.target.value),onKeyDown:S=>{if(S.key==="Enter"){S.preventDefault();const C=c.trim();C&&l(C)}},spellCheck:!1,value:c}),b?n.jsx(Mt,{className:"size-4 shrink-0 animate-spin text-muted-foreground"}):null]}),n.jsxs("div",{className:"max-h-56 overflow-auto p-1",children:[g?n.jsx(Ze,{variant:"destructive",className:"m-1",children:g}):null,!g&&f?.entries.length===0?n.jsx(Ze,{variant:"muted",className:"m-1 text-center",children:i("git.folder.empty")}):null,f?.entries.map(S=>n.jsxs(Q,{className:re("h-8 w-full justify-start rounded-sm px-2 text-left",s===S.path&&"bg-muted"),onClick:()=>l(S.path),title:S.path,type:"button",variant:"ghost",children:[n.jsx(Co,{className:"text-accent"}),n.jsx("span",{className:"truncate",children:S.name})]},S.path))]})]})}function mee(e){return!!(e&&e.parent!==e.path)}function CT({confirmLabel:e,errorMessage:t,initialPath:s,onCancel:i,onSelect:a,onUse:l,selectedPath:c,title:d}){const f=J();return Hi.createPortal(n.jsx("div",{className:"fixed inset-0 z-[1000] grid place-items-center bg-black/35 px-4",children:n.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-border bg-card p-4 shadow-xl",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[n.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg border border-border bg-background",children:n.jsx(Co,{className:"size-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-semibold",children:d??f("git.repo.chooseFolder")}),n.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:c})]}),n.jsx(Q,{"aria-label":f("git.repo.closeFolderPicker"),onClick:i,size:"icon",variant:"ghost",children:n.jsx(Vt,{})})]}),n.jsx(fee,{initialPath:s,onSelect:a,selectedPath:c}),t?n.jsx("div",{className:"mt-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:t}):null,n.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[n.jsx(Q,{onClick:i,type:"button",variant:"outline",children:f("common.cancel")}),n.jsx(Q,{onClick:()=>{l()},type:"button",children:e??f("git.repo.useThisFolder")})]})]})}),document.body)}const Kc=5,pee=240,Px=8,gee=176+Px;function bee({currentRepoPath:e}){const t=J(),[s,i]=x.useState(null),[a,l]=x.useState([]),[c,d]=x.useState(null),[f,h]=x.useState(!0),[g,p]=x.useState(null),b=x.useRef(null),v=x.useRef(null),[_,S]=x.useState(0);x.useEffect(()=>{const q=v.current;if(!q)return;const W=new ResizeObserver(I=>{S(I[0].contentRect.width)});return W.observe(q),()=>W.disconnect()},[s]);const C=x.useCallback(()=>{let q=!0;return h(!0),d(null),zg().then(W=>{q&&(i(W.repos),l(W.board))}).catch(W=>{q&&d(W instanceof Error?W.message:String(W))}).finally(()=>{q&&h(!1)}),()=>{q=!1}},[]);x.useEffect(C,[C]);const N=x.useCallback(()=>{zg().then(q=>{i(q.repos),l(q.board)}).catch(q=>{d(q instanceof Error?q.message:String(q))})},[]),A=x.useCallback(q=>{l(q),mS(q).catch(W=>{d(W instanceof Error?W.message:String(W))})},[]),j=x.useCallback(async q=>{const W=q.trim();if(!W.startsWith("/"))return t("git.board.absolutePathError");try{const I=kT(W);await zi("/api/git/repositories",{name:I,path:W});const Y=await zg();i(Y.repos);const $=(Y.board.includes(I)?Y.board:[...Y.board,I]).slice(0,Kc);return l($),await mS($),null}catch(I){return I instanceof Error?I.message:String(I)}},[t]),E=new Map((s??[]).map(q=>[q.name,q])),T=a.map(q=>E.get(q)).filter(q=>!!q).slice(0,Kc),L=(s??[]).filter(q=>!a.includes(q.name)),H=T.length<Kc,P=Math.max(0,_-(H?gee:0)),F=_===0?Kc:Math.max(1,Math.floor((P+Px)/(pee+Px))),M=Math.min(T.length,F),z=T.slice(0,M),G=T.length-M;function D(q){const W=b.current;if(b.current=null,W===null||W===q)return;const I=[...a],[Y]=I.splice(W,1);I.splice(q,0,Y),A(I)}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/95 px-3 py-1.5",children:[n.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] font-semibold tracking-tight",children:[n.jsx(Gx,{className:"size-3.5"}),t("git.board.repositories"),s?n.jsxs(We,{variant:"secondary",className:"ml-1",children:[T.length,s.length>T.length?` / ${s.length}`:""]}):null,G>0?n.jsx("span",{className:"ml-1 text-[10px] font-normal text-muted-foreground",children:t("git.board.hidden",{count:G})}):null]}),n.jsxs(Q,{"aria-label":t("git.board.refreshAria"),disabled:f,onClick:C,size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{className:f?"animate-spin":void 0}),t("common.refresh")]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:c?n.jsx(Ze,{variant:"destructive",className:"m-3",children:c}):s&&s.length===0?n.jsx(Ze,{variant:"muted",className:"m-3 text-center",children:t("git.board.emptyRegistered")}):n.jsxs("div",{className:"flex h-full min-h-0 gap-2 p-2",ref:v,children:[z.map((q,W)=>n.jsx(vee,{repo:q,isCurrent:!!e&&q.path===e,selectedFile:g?.repo===q.name?g.file:"",onSelectFile:I=>p({repo:q.name,file:I}),onRemove:()=>A(a.filter(I=>I!==q.name)),onMutated:N,onDragStart:()=>{b.current=W},onDropColumn:()=>D(W)},q.name)),H?n.jsx(xee,{unpinned:L,onAdd:q=>A([...a,q].slice(0,Kc)),onRegister:j}):null]})}),g?n.jsx(hee,{repo:g.repo,file:g.file,onClose:()=>p(null)}):null]})}function vee({repo:e,isCurrent:t,selectedFile:s,onSelectFile:i,onRemove:a,onMutated:l,onDragStart:c,onDropColumn:d}){const f=J(),[h,g]=x.useState(!1),[p,b]=x.useState(!1),[v,_]=x.useState(!1),S=x.useCallback(async(j,E)=>{if(E.length){b(!0);try{await j(E,e.name),l()}finally{b(!1)}}},[e.name,l]),C={busy:p,onStage:j=>{S(t0,j)},onUnstage:j=>{S(UE,j)}},N=e.files.filter(j=>j.index.trim()&&j.index!=="?").length,A=v?hn:wn;return n.jsxs("div",{className:re("flex min-w-0 flex-1 flex-col overflow-hidden rounded-md border border-border bg-card",t&&"border-primary/60 ring-1 ring-primary/30",h&&"ring-2 ring-foreground/40"),onDragOver:j=>{j.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:()=>{g(!1),d()},children:[n.jsxs("div",{className:"flex shrink-0 cursor-grab items-center justify-between gap-1 border-b border-border bg-muted/40 px-1.5 py-1.5 active:cursor-grabbing",draggable:!0,onDragStart:c,children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[n.jsx(z6,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),n.jsx("span",{className:"truncate text-[12px] font-semibold",title:e.path,children:e.name}),t?n.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 rounded bg-primary px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-primary-foreground",title:f("git.board.currentTitle"),children:[n.jsx(Ys,{className:"size-2.5"}),f("git.board.current")]}):null]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[n.jsxs("span",{className:"flex items-center gap-1 font-mono text-[10px] text-muted-foreground",children:[e.ahead?n.jsxs("span",{className:"flex items-center",title:f("git.board.aheadTitle",{count:e.ahead}),children:[n.jsx($f,{className:"size-3"}),e.ahead]}):null,e.behind?n.jsxs("span",{className:"flex items-center",title:f("git.board.behindTitle",{count:e.behind}),children:[n.jsx(Hf,{className:"size-3"}),e.behind]}):null]}),n.jsx("button",{"aria-label":f("git.board.removeAria",{name:e.name}),className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-background hover:text-foreground",onClick:a,title:f("git.board.removeTitle"),type:"button",children:n.jsx(Vt,{className:"size-3.5"})})]})]}),n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx($A,{branch:e.branch||void 0,error:e.error,files:e.files,onSelectFile:i,root:e.path,selectedFile:s,staging:C})}),n.jsxs("div",{className:"shrink-0 border-t border-border",children:[n.jsxs("button",{"aria-expanded":v,className:"flex w-full items-center gap-1.5 bg-muted/40 px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-tight text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>_(j=>!j),type:"button",children:[n.jsx(A,{className:"size-3.5 shrink-0"}),n.jsx("span",{className:"flex-1",children:f("git.commit.title")}),N?n.jsx(We,{size:"small",variant:"secondary",children:f("git.commit.stagedCount",{count:N})}):null]}),v?n.jsx(FA,{branch:e.branch||void 0,files:e.files,onDone:l,repo:e.name}):null]})]})}function xee({unpinned:e,onAdd:t,onRegister:s}){const i=J(),[a,l]=x.useState(!1),[c,d]=x.useState(null),[f,h]=x.useState(""),[g,p]=x.useState(null),[b,v]=x.useState(!1),[_,S]=x.useState(!1),[C,N]=x.useState(""),A=x.useRef(null),j=x.useRef(null);function E(){if(a){l(!1);return}d(A.current?.getBoundingClientRect()??null),p(null),l(!0)}x.useEffect(()=>{if(!a)return;function H(P){const F=P.target;F instanceof Node&&(j.current?.contains(F)||A.current?.contains(F)||l(!1))}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[a]);async function T(H){v(!0),p(null);const P=await s(H);return v(!1),P?(p(P),!1):(h(""),l(!1),!0)}async function L(H){H.preventDefault(),await T(f)}return n.jsxs("div",{className:"w-44 shrink-0",children:[n.jsxs("button",{ref:A,className:"flex h-full w-full flex-col items-center justify-center gap-1.5 rounded-md border border-dashed border-border text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground",onClick:E,type:"button",children:[n.jsx(ms,{className:"size-5"}),n.jsx("span",{className:"text-[12px] font-medium",children:i("git.board.addRepo")})]}),a&&c?Hi.createPortal(n.jsxs("div",{ref:j,className:"fixed z-[1000] w-72 overflow-hidden rounded-lg border border-border bg-card shadow-xl",style:{left:Math.max(8,Math.min(c.left,window.innerWidth-296)),top:Math.min(c.top,window.innerHeight-320)},children:[e.length?n.jsxs("div",{className:"border-b border-border",children:[n.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:i("git.board.pinRegistered")}),n.jsx("div",{className:"max-h-52 overflow-auto pb-1",children:e.map(H=>n.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm hover:bg-muted",onClick:()=>{t(H.name),l(!1)},type:"button",children:[n.jsx(Gx,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",title:H.path,children:H.name}),H.files.length?n.jsx(We,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:H.files.length}):null]},H.name))})]}):null,n.jsxs("div",{className:"p-2.5",children:[n.jsx("div",{className:"pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:i("git.board.addNew")}),n.jsxs("form",{className:"flex gap-1.5",onSubmit:L,children:[n.jsx(pt,{"aria-label":i("git.board.absPathAria"),className:"h-7 flex-1 px-2 font-mono text-[11px]",onChange:H=>{h(H.target.value),p(null)},placeholder:"/absolute/path/to/repo",value:f}),n.jsx(Q,{className:"h-7 px-2 text-[11px]",disabled:b||!f.trim(),size:"sm",type:"submit",children:i("common.add")})]}),n.jsxs(Q,{className:"mt-1.5 h-7 w-full gap-1.5 text-[11px]",disabled:b,onClick:()=>{N(f.trim()||""),S(!0)},size:"sm",type:"button",variant:"outline",children:[n.jsx(Vx,{className:"size-3"}),i("git.board.browseFolders")]}),g?n.jsx("div",{className:"mt-1.5 text-[10px] text-destructive",children:g}):null]})]}),document.body):null,_?n.jsx(CT,{confirmLabel:i("git.board.addRepo"),errorMessage:g,initialPath:C||"/",selectedPath:C,title:i("git.board.addRepoTitle"),onCancel:()=>S(!1),onSelect:N,onUse:async()=>{await T(C)&&S(!1)}}):null]})}const zx=300,yee=600,_ee=new Set(["md","mdx","markdown","txt","rst","adoc","json","jsonc","json5","yaml","yml","toml","xml","ini","cfg","conf","env","properties","csv","tsv","lock","svg","map","snap","png","jpg","jpeg","gif","ico","webp"]);function wee(e){const t=e.toLowerCase();if(t.endsWith(".d.ts")||t.endsWith(".min.js")||t.endsWith(".min.css"))return!1;const s=t.lastIndexOf(".");return s<0?!0:!_ee.has(t.slice(s+1))}function See(e){return e>=yee?"danger":e>=zx?"warn":"ok"}const kee={ok:"bg-emerald-500/60",warn:"bg-amber-500/70",danger:"bg-destructive/70"},Cee={ok:"text-muted-foreground",warn:"text-amber-600 dark:text-amber-400",danger:"text-destructive"};function Nee({onOpenFile:e,root:t}){const s=J(),[i,a]=x.useState([]),[l,c]=x.useState(!0),[d,f]=x.useState(null),[h,g]=x.useState(!0);function p(){c(!0),f(null),w7().then(a).catch(C=>f(C instanceof Error?C.message:String(C))).finally(()=>c(!1))}x.useEffect(()=>{p()},[]);const b=x.useMemo(()=>h?i.filter(C=>wee(C.path)):i,[i,h]),v=i.length-b.length,_=b[0]?.lines??1,S=b.filter(C=>C.lines>=zx).length;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-card/85",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(pE,{className:"size-4"}),n.jsx("span",{className:"font-semibold text-foreground",children:s("git.largest.title")}),!l&&!d?n.jsxs("span",{children:[s("git.largest.summary",{visible:b.length,over:S,warn:zx}),h&&v>0?s("git.largest.hiddenSuffix",{hidden:v}):""]}):null]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsxs(Q,{size:"sm",variant:h?"default":"outline",className:"h-7",onClick:()=>g(C=>!C),title:s("git.largest.codeOnlyTitle"),type:"button",children:[n.jsx(dE,{}),s("git.largest.codeOnly")]}),n.jsxs(Q,{size:"sm",variant:"outline",className:"h-7",onClick:p,disabled:l,type:"button",children:[l?n.jsx(Mt,{className:"animate-spin"}):n.jsx(_i,{}),s("common.refresh")]})]})]}),d?n.jsx(Ze,{variant:"destructive",className:"m-3",children:d}):l&&i.length===0?n.jsxs("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:[n.jsx(Mt,{className:"mr-2 size-4 animate-spin"}),s("git.largest.scanning")]}):b.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:i.length===0?s("git.largest.noTextFiles"):s("git.largest.noCodeFiles")}):n.jsx("ul",{className:"min-h-0 flex-1 divide-y divide-border/60 overflow-auto",children:b.map((C,N)=>{const A=See(C.lines);return n.jsxs("li",{className:"group flex items-center gap-3 px-3 transition-colors hover:bg-muted/50",children:[n.jsx("span",{className:"w-6 shrink-0 text-right font-mono text-[10px] text-muted-foreground",children:N+1}),n.jsx("button",{type:"button",onClick:()=>e(C.path),className:"min-w-0 flex-1 py-1.5 text-left",children:n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"truncate font-mono text-[11px]",children:C.path}),n.jsxs("span",{className:re("shrink-0 font-mono text-[11px] tabular-nums",Cee[A]),children:[C.truncated?"≥":"",s("git.largest.linesCount",{count:C.lines.toLocaleString()})]})]}),n.jsx("div",{className:"mt-1 h-1 w-full overflow-hidden rounded-full bg-muted",children:n.jsx("div",{className:re("h-full rounded-full",kee[A]),style:{width:`${Math.max(2,C.lines/_*100)}%`}})})]})}),n.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-0.5",children:[n.jsx(Eee,{file:C,root:t}),n.jsx(jee,{file:C,root:t})]})]},C.path)})})]})}function Eee({file:e,root:t}){const s=J(),{sendToAgent:i}=Ot(),a=Bu(t,e.path),l=e.path.split("/").pop()??e.path;function c(){i({prompt:GF({absolutePath:a,lines:e.lines,relativePath:e.path}),source:{label:l,type:"large-file"},label:s("git.largest.splitLabel",{path:e.path,count:e.lines.toLocaleString()}),mode:"send"})}function d(){i({prompt:a,source:{label:l,type:"large-file"},mode:"draft"})}return n.jsx(NT,{label:s("git.largest.aiActions",{path:e.path}),trigger:n.jsx(Xt,{className:"size-3.5"}),children:f=>n.jsxs(n.Fragment,{children:[n.jsx(bu,{icon:n.jsx(Xt,{className:"size-3.5"}),onSelect:()=>{f(),c()},children:s("git.largest.askSplit")}),n.jsx(bu,{icon:n.jsx(fE,{className:"size-3.5"}),onSelect:()=>{f(),d()},children:s("git.largest.sendPath")})]})})}function jee({file:e,root:t}){const s=J(),{error:i,success:a}=cs(),l=Bu(t,e.path),c=e.path.split("/").pop()??e.path;async function d(f,h){try{await navigator.clipboard.writeText(f),a(s("git.largest.copiedWhat",{what:h}))}catch(g){i(g instanceof Error?g.message:s("git.largest.couldNotCopy",{what:h}))}}return n.jsx(NT,{label:s("git.largest.copyPathFor",{path:e.path}),trigger:n.jsxs(n.Fragment,{children:[n.jsx(hE,{className:"size-3.5"}),n.jsx("span",{className:"sr-only",children:s("common.moreActions")})]}),children:f=>n.jsxs(n.Fragment,{children:[n.jsx(bu,{icon:n.jsx(qx,{className:"size-3.5"}),onSelect:()=>{f(),d(c,s("git.largest.whatFileName"))},children:s("git.largest.copyFileName")}),n.jsx(bu,{icon:n.jsx(nf,{className:"size-3.5"}),onSelect:()=>{f(),d(e.path,s("git.largest.whatRelPath"))},children:s("git.largest.copyRelPath")}),n.jsx(bu,{icon:n.jsx(nf,{className:"size-3.5"}),onSelect:()=>{f(),d(l,s("git.largest.whatAbsPath"))},children:s("git.largest.copyAbsPath")})]})})}function NT({children:e,label:t,trigger:s}){const[i,a]=x.useState(!1),[l,c]=x.useState({right:0,top:0}),d=x.useRef(null),f=x.useRef(null);function h(){a(!1)}function g(){const p=d.current?.getBoundingClientRect();p&&c({top:p.bottom+6,right:window.innerWidth-p.right}),a(b=>!b)}return x.useEffect(()=>{if(!i)return;function p(v){const _=v.target;d.current?.contains(_)||f.current?.contains(_)||h()}function b(v){v.key==="Escape"&&h()}return document.addEventListener("mousedown",p),document.addEventListener("keydown",b),window.addEventListener("scroll",h,!0),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",b),window.removeEventListener("scroll",h,!0)}},[i]),n.jsxs(n.Fragment,{children:[n.jsx("button",{"aria-label":t,className:re("flex h-7 min-w-7 shrink-0 items-center justify-center gap-1 rounded-md px-1.5 text-muted-foreground opacity-0 transition-all duration-150 hover:bg-muted hover:text-foreground group-hover:opacity-100",i&&"bg-muted text-foreground opacity-100"),onClick:g,ref:d,title:t,type:"button",children:s}),i?Hi.createPortal(n.jsx("div",{className:"fixed z-50 w-56 overflow-hidden rounded-md border border-border bg-card p-1 shadow-md",ref:f,style:{top:l.top,right:l.right},children:e(h)}),document.body):null]})}function bu({children:e,icon:t,onSelect:s}){return n.jsxs("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs text-foreground transition-colors hover:bg-muted",onClick:s,type:"button",children:[n.jsx("span",{className:"text-muted-foreground",children:t}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:e})]})}function Aee({data:e,onRefresh:t}){const s=J(),{insertPath:i}=Ot(),[a,l]=x.useState(!1),[c,d]=x.useState("changes"),[f,h]=x.useState("changes"),[g,p]=x.useState(e.git.status?.files[0]?.path??""),[b,v]=x.useState(""),[_,S]=x.useState([]),[C,N]=x.useState(null),[A,j]=x.useState(""),[E,T]=x.useState(null),[L,H]=x.useState(0),[P,F]=x.useState(null),[M,z]=x.useState(()=>new Set),G=e.git.status?.files??[],D=x.useMemo(()=>{const Me=new Set(G.map(Je=>Je.path)),pe=[...M].filter(Je=>!Me.has(Je)).sort().map(Je=>({path:Je,index:" ",workingTree:"M"}));return[...G,...pe]},[G,M]),q=x.useMemo(()=>D.map(Me=>Me.path),[D]),W=x.useMemo(()=>O0(A),[A]),I=x.useCallback(async(Me,pe)=>{if(pe.length){l(!0);try{await Me(pe),t?.()}finally{l(!1)}}},[t]),Y=t?{busy:a,onStage:Me=>{I(t0,Me)},onUnstage:Me=>{I(UE,Me)}}:void 0;x.useEffect(()=>{const Me=D[0]?.path??"";p(pe=>pe&&D.some(Je=>Je.path===pe)?pe:Me)},[D]),x.useEffect(()=>{if(c!=="all"||_.length>0)return;let Me=!0;return N(null),_7().then(pe=>{Me&&S(pe)}).catch(pe=>{Me&&N(pe instanceof Error?pe.message:String(pe))}),()=>{Me=!1}},[c,_.length]),x.useEffect(()=>{if(!g){j("");return}let Me=!0;return T(null),FE(g).then(pe=>{Me&&(j(pe),H(0),F(null))}).catch(pe=>{Me&&T(pe instanceof Error?pe.message:String(pe))}),()=>{Me=!1}},[g]);function $(Me){H(0),F(null),p(Me)}function me(){const Me=eee({activeHunkIndex:L,filePaths:q,hunkCount:W.hunks,pendingNextFilePath:P,selectedFile:g});Me.kind==="hunk"?(F(null),H(Me.activeHunkIndex)):Me.kind==="confirm-next-file"?F(Me.filePath):Me.kind==="file"?$(Me.filePath):F(null)}function ee(){if(F(null),L>0){H(Je=>Je-1);return}const Me=D.findIndex(Je=>Je.path===g),pe=D[Me-1];pe&&$(pe.path)}const V=D.findIndex(Me=>Me.path===g),K=!!(W.hunks&&L<W.hunks-1||D[V+1]),xe=!!(L>0||D[V-1]),ie=P?s("git.navHintEndOfFile",{path:P}):null,Z=Me=>`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${Me?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,ge=Me=>`flex-1 px-2 py-0.5 text-[11px] font-medium transition-colors ${Me?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,ne=x.useMemo(()=>{const Me=new Set(D.map(pe=>pe.path));for(const pe of M)Me.add(pe);return Me},[D,M]);if(!e.git.selectedRepository)return n.jsx(Tee,{});function we(){b&&(d("changes"),h("changes"),$(b))}function Ne(Me){z(pe=>new Set(pe).add(Me)),v(Me),d("changes"),h("changes"),$(Me)}function Ue(Me){v(Me),d("all")}function Pe(Me){Me&&i(Bu(e.git.cwd,Me))}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-card/85",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card/95 px-3 py-1",children:[n.jsx("button",{type:"button",className:Z(c==="changes"),onClick:()=>d("changes"),children:s("git.tab.changes")}),n.jsx("button",{type:"button","aria-label":s("git.boardAria"),className:Z(c==="board"),onClick:()=>d("board"),children:s("git.tab.board")}),n.jsx("button",{type:"button","aria-label":s("git.allFilesAria"),className:Z(c==="all"),onClick:()=>d("all"),children:s("git.tab.all")}),n.jsx("button",{type:"button",className:Z(c==="graph"),onClick:()=>d("graph"),children:s("git.tab.tree")}),n.jsx("button",{type:"button",className:Z(c==="largest"),onClick:()=>d("largest"),children:s("git.tab.largest")}),n.jsx("button",{type:"button",className:Z(c==="snapshots"),onClick:()=>d("snapshots"),children:s("git.tab.snapshots")})]}),n.jsx("div",{className:"min-h-0 flex-1",children:c==="board"?n.jsx(bee,{currentRepoPath:e.git.cwd}):c==="graph"?n.jsx(dee,{branches:e.git.branches??[]}):c==="largest"?n.jsx(Nee,{onOpenFile:Ue,root:e.git.cwd}):c==="snapshots"?n.jsx(wF,{}):c==="all"?n.jsxs("div",{className:"grid h-full min-h-0 overflow-hidden border-0 bg-card/85 xl:grid-cols-[320px_minmax(0,1fr)]",children:[n.jsx("aside",{className:"flex min-h-0 flex-col overflow-hidden",children:C?n.jsx(Ze,{variant:"destructive",className:"m-3",children:C}):n.jsx(GC,{branch:e.git.status?.branch||void 0,onSelectFile:v,paths:_,root:e.git.cwd,selectedFile:b,status:D})}),n.jsx(JJ,{isModified:ne.has(b),onFileSaved:Ne,onSendToAi:()=>Pe(b),onViewDiff:we,path:b})]}):n.jsxs("div",{className:"grid h-full min-h-0 overflow-hidden border-0 bg-card/85 xl:grid-cols-[320px_minmax(0,1fr)]",children:[n.jsxs("aside",{className:"flex min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 gap-0.5 border-b border-border bg-card/95 p-1",children:[n.jsx("button",{"aria-label":s("git.modeListAria"),className:ge(f==="changes"),onClick:()=>h("changes"),type:"button",children:s("git.tab.changes")}),n.jsx("button",{"aria-label":s("git.modeTreeAria"),className:ge(f==="tree"),onClick:()=>h("tree"),type:"button",children:s("git.tab.tree")})]}),f==="changes"?n.jsx($A,{branch:e.git.status?.branch||void 0,error:e.git.error,files:D,selectedFile:g,onSelectFile:$,root:e.git.cwd,staging:Y}):n.jsx(GC,{branch:e.git.status?.branch||void 0,defaultExpandAll:!0,emptyMessage:e.git.error??s("git.noChangedFiles"),onSelectFile:$,paths:q,root:e.git.cwd,selectedFile:g,status:D,title:s("git.tab.changes")}),t&&e.git.status?n.jsx(FA,{branch:e.git.status.branch||void 0,files:D,onDone:t}):null]}),n.jsxs("section",{className:"flex min-h-0 min-w-0 flex-col border-l border-border bg-card",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-[13px] font-semibold tracking-tight",children:g||s("git.diff")}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground",children:[n.jsx("span",{children:s("git.longRowsWrap")}),W.additions||W.deletions?n.jsxs("span",{className:"flex items-center gap-1 font-mono",children:[n.jsxs("span",{className:"text-emerald-700",children:["+",W.additions]}),n.jsxs("span",{className:"text-red-700",children:["-",W.deletions]})]}):null]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[ie?n.jsx("span",{className:"max-w-72 truncate rounded border border-amber-200 bg-amber-50 px-2 py-1 text-[11px] text-amber-900",children:ie}):null,n.jsxs(Q,{disabled:!g||!xe,onClick:ee,size:"sm",type:"button",variant:"outline",children:[n.jsx($f,{}),s("git.previous")]}),n.jsxs(Q,{disabled:!g||!K,onClick:me,size:"sm",type:"button",variant:"outline",children:[n.jsx(Hf,{}),s("git.next")]}),n.jsx(Q,{"aria-label":s("git.sendToAiAria"),className:"size-8",disabled:!g,onClick:()=>Pe(g),size:"icon",title:s("git.sendToAiTitle"),type:"button",variant:"outline",children:n.jsx(Xt,{className:"size-4"})})]})]}),n.jsx("div",{className:"relative min-h-0 min-w-0 flex-1",children:E?n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"destructive",children:E})}):g?n.jsx(zu,{activeHunkIndex:L,diff:A||s("git.noUnstagedDiff")}):n.jsx("div",{className:"p-4",children:n.jsx(Ze,{variant:"muted",className:"border-dashed p-12 text-center",children:s("git.selectFilePrompt")})})})]})]})})]})}function Tee(){const e=J();return n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"max-w-sm",children:[n.jsx(Gx,{className:"mx-auto size-8 text-muted-foreground/50"}),n.jsx("p",{className:"mt-3 text-sm font-medium",children:e("git.noRepoTitle")}),n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.noRepoBody")})]})})}function UN(e,t,s){const i=e.trim(),a=i.toLowerCase(),l=[],c=/\breview|check|inspect|audit\b/.test(a),d=/\btest|verify|ci\b/.test(a),f=/\bcommit\b/.test(a)||/\bship|push|pr|pull request\b/.test(a),h=/\bpush|ship|pr|pull request\b/.test(a),g=/\bpr\b|pull request/.test(a),p=Mee(a,s);return g&&l.push({kind:"action",id:"assert-pr-branch",title:"Check PR branch",op:"assert-pr-branch"}),c&&(l.push(Ph("gate-review","Approve review","Review the current changes?")),l.push(Yc("review","Review changes","Review the current git changes. Summarize risks, likely bugs, and anything that should change before committing.",zh(p,["skills","mcpServers"])))),d&&l.push(Yc("verify","Run verification","Run the relevant tests or checks for this repository. If something fails, stop and explain the failure.",zh(p,["skills","mcpServers","plugins"]))),f&&(l.push(Yc("commit-message","Generate commit message","Stage the appropriate changed files, inspect the staged diff briefly, and draft one conventional commit message. Do not commit.",zh(p,["skills"]))),l.push(Ph("gate-commit","Approve commit","Commit with this generated message?")),l.push({kind:"action",id:"commit",title:"Commit with approved message",op:"commit"})),h&&(l.push(Ph("gate-push","Approve push",g?"Push and continue toward a PR?":"Push this branch?")),l.push({kind:"action",id:"push",title:"Push branch",op:"push"})),g&&(l.push(Yc("open-pr","Open PR","Open a pull request for the current branch. Use the latest commit subject as the title and summarize the commit list in the body.",zh(p,["mcpServers","plugins"]))),l.push({kind:"action",id:"checkout-default-and-pull",title:"Return to default branch",op:"checkout-default-and-pull"})),l.length||(l.push(Ph("gate-start","Approve start","Run this workflow?")),l.push(Yc("ai-step","AI step",i||"Complete this workflow step.",p))),{id:Lee(ET(qN(a))||"custom-workflow",t),name:qN(a),description:i||"Custom AI-authored workflow.",builtin:!1,steps:Dee(l)}}function Ree(e){return["Create a NoMoreIDE workflow from this user intent:","",e.trim()||"(no intent provided)","","Return a workflow JSON object only. Use this shape:","{",' "id": "short-kebab-id",',' "name": "Human name",',' "description": "One sentence",',' "steps": [',' { kind: "gate", id: "gate-id", title: "Approve thing", message: "Question for the user?" },',' { kind: "agent", id: "ai-id", title: "AI task", prompt: "Clear instruction", capabilities: { skills: [], mcpServers: [], plugins: [], hooks: [] }, verify: "committed" },',' { kind: "action", id: "push", title: "Push", op: "push" },',' { kind: "action", id: "checkout-default-and-pull", title: "Return to default branch", op: "checkout-default-and-pull" }'," ]","}","","Use gates before mutating git or GitHub state. Prefer intent-level AI steps over direct MCP tool calls."].join(`
|
|
225
225
|
`)}function qN(e){const t=/\breview|check|inspect|audit\b/.test(e),s=/\bcommit\b|\bship|push|pr|pull request\b/.test(e),i=/\bpr\b|pull request/.test(e),a=/\btest|verify|ci\b/.test(e);return t&&s&&i?"Review, Commit & PR":a&&s&&i?"Verify, Commit & PR":t&&s?"Review & Commit":s&&i?"Commit & PR":s?"Commit workflow":t?"Review workflow":"Custom workflow"}function Ph(e,t,s){return{kind:"gate",id:e,title:t,message:s}}function Yc(e,t,s,i,a){return{kind:"agent",id:e,title:t,prompt:s,capabilities:u1(i),verify:a}}function Mee(e,t){return u1({skills:t.skills.filter(s=>e.includes(s.toLowerCase())),mcpServers:t.mcpServers.filter(s=>e.includes(s.toLowerCase())),plugins:t.plugins.filter(s=>e.includes(s.toLowerCase())),hooks:t.hooks.filter(s=>e.includes(s.toLowerCase()))})??{}}function zh(e,t){const s={};for(const i of t){const a=e[i];a?.length&&(s[i]=a)}return u1(s)}function u1(e){if(!e)return;const t={};for(const s of["skills","mcpServers","plugins","hooks"]){const i=Array.from(new Set((e[s]??[]).filter(Boolean)));i.length&&(t[s]=i)}return Object.keys(t).length?t:void 0}function Dee(e){const t=new Map;return e.map(s=>{const i=ET(s.id)||s.kind,a=t.get(i)??0;return t.set(i,a+1),a===0?{...s,id:i}:{...s,id:`${i}-${a+1}`}})}function Lee(e,t){const s=new Set(t.map(l=>l.id));let i=e||"workflow",a=2;for(;s.has(i);)i=`${e}-${a}`,a++;return i}function ET(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const zf={"error-incident":"workflows.triggers.eventErrorIncident","service-crash":"workflows.triggers.eventServiceCrash","ci-failure":"workflows.triggers.eventCiFailure"};function Oee({workflows:e}){const t=J(),{triggers:s,pending:i,error:a,saveTrigger:l,removeTrigger:c,runPending:d,dismissPending:f}=cG(),[h,g]=x.useState(!1),p=b=>e.find(v=>v.id===b)?.name??b;return n.jsxs("section",{className:"border-t border-border px-4 py-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{children:[n.jsxs("h3",{className:"flex items-center gap-1.5 text-[12px] font-semibold",children:[n.jsx(AE,{className:"size-3.5 text-amber-500"})," ",t("workflows.triggers.title")]}),n.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:t("workflows.triggers.subtitle")})]}),n.jsxs(Q,{onClick:()=>g(b=>!b),size:"sm",type:"button",variant:"outline",children:[n.jsx(ms,{className:"size-3.5"})," ",t("workflows.triggers.add")]})]}),a?n.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:a}):null,i.length>0?n.jsx("div",{className:"mt-3 space-y-1.5",children:i.map(b=>n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-amber-500/40 bg-amber-500/5 px-2.5 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"truncate text-[11px] font-medium",children:[p(b.workflowId),n.jsxs("span",{className:"ml-1.5 text-muted-foreground",children:["· ",t(zf[b.event])]})]}),n.jsx("div",{className:"truncate text-[10px] text-muted-foreground",children:b.summary})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsxs(Q,{onClick:()=>d(b),size:"sm",type:"button",variant:"outline",children:[n.jsx(or,{className:"size-3"})," ",t("workflows.run")]}),n.jsx(Q,{onClick:()=>{f(b.id)},size:"icon",type:"button",variant:"ghost","aria-label":t("workflows.triggers.dismiss"),children:n.jsx(Vt,{className:"size-3.5"})})]})]},b.id))}):null,h?n.jsx(Pee,{workflows:e,onCancel:()=>g(!1),onSave:async b=>{await l(b),g(!1)}}):null,n.jsxs("div",{className:"mt-3 space-y-1.5",children:[s.length===0&&!h?n.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:t("workflows.triggers.empty")}):null,s.map(b=>n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-1.5",children:[n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("input",{checked:b.enabled,className:"size-3.5 accent-primary",onChange:v=>{l({...b,enabled:v.target.checked})},type:"checkbox"}),n.jsxs("span",{className:"min-w-0 truncate text-[11px]",children:[n.jsx("span",{className:"font-medium",children:t(zf[b.event])}),b.filter?n.jsxs("span",{className:"text-muted-foreground",children:[" · “",b.filter,"”"]}):null,n.jsxs("span",{className:"text-muted-foreground",children:[" → ",p(b.workflowId)]}),b.autoRun?n.jsx("span",{className:"ml-1.5 rounded bg-amber-500/15 px-1 py-px text-[9px] font-semibold uppercase text-amber-600",children:t("workflows.triggers.autoBadge")}):null]})]}),n.jsx(Q,{onClick:()=>{c(b.id)},size:"icon",type:"button",variant:"ghost","aria-label":t("workflows.triggers.deleteAria"),children:n.jsx(Ii,{className:"size-3.5"})})]},b.id))]})]})}function Pee({workflows:e,onCancel:t,onSave:s}){const i=J(),[a,l]=x.useState("error-incident"),[c,d]=x.useState(e[0]?.id??""),[f,h]=x.useState(""),[g,p]=x.useState(!1),b="rounded border border-border bg-background px-2 py-1 text-[11px] outline-none focus:border-primary";return n.jsxs("div",{className:"mt-3 space-y-2 rounded-md border border-border bg-background p-3",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsxs("label",{className:"flex flex-col gap-1 text-[10px] font-medium text-muted-foreground",children:[i("workflows.triggers.when"),n.jsx("select",{className:b,value:a,onChange:v=>l(v.target.value),children:Object.keys(zf).map(v=>n.jsx("option",{value:v,children:i(zf[v])},v))})]}),n.jsxs("label",{className:"flex flex-col gap-1 text-[10px] font-medium text-muted-foreground",children:[i("workflows.triggers.runWorkflow"),n.jsx("select",{className:b,value:c,onChange:v=>d(v.target.value),children:e.map(v=>n.jsx("option",{value:v.id,children:v.name},v.id))})]})]}),n.jsxs("label",{className:"flex flex-col gap-1 text-[10px] font-medium text-muted-foreground",children:[i("workflows.triggers.filterLabel"),n.jsx("input",{className:b,value:f,onChange:v=>h(v.target.value),placeholder:"e.g. api",type:"text"})]}),n.jsxs("label",{className:"flex w-fit items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx("input",{checked:g,className:"size-3.5 accent-primary",onChange:v=>p(v.target.checked),type:"checkbox"}),i("workflows.triggers.autoRunLabel")]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[n.jsx(Q,{onClick:t,size:"sm",type:"button",variant:"ghost",children:i("common.cancel")}),n.jsx(Q,{disabled:!c,onClick:()=>{s({id:`trigger-${Date.now().toString(36)}`,event:a,workflowId:c,filter:f.trim()||void 0,enabled:!0,autoRun:g})},size:"sm",type:"button",children:i("common.add")})]})]})}function zee(){const e=J(),{run:t,start:s,resume:i,approve:a,skip:l,stop:c,dismiss:d}=N5(),[f,h]=x.useState([]),[g,p]=x.useState(null),[b,v]=x.useState(null),[_,S]=x.useState(null),[C,N]=x.useState(!0),[A,j]=x.useState(!1),[E,T]=x.useState(!0);x.useEffect(()=>{let M=!0;return N(!0),Promise.all([QE(),e0().catch(()=>null)]).then(([z,G])=>{M&&(h(z),p(G))}).catch(z=>{M&&S(z instanceof Error?z.message:String(z))}).finally(()=>{M&&N(!1)}),()=>{M=!1}},[]);function L(M){j(!0),s(M,E)}async function H(M){S(null);try{const z=await Y9(M);h(z),v(null)}catch(z){S(z instanceof Error?z.message:String(z))}}async function P(M){if(!M.builtin&&window.confirm(e("workflows.deleteConfirm",{name:M.name}))){S(null);try{h(await X9(M.id))}catch(z){S(z instanceof Error?z.message:String(z))}}}function F(M){v({...M,id:d1(`${M.id}-copy`,f),name:`${M.name} copy`,builtin:!1,steps:M.steps.map((z,G)=>({...z,id:`${z.id}-${G+1}`}))})}return t&&A?n.jsx(Wee,{run:t,onApprove:a,onSkip:l,onStop:c,onBack:()=>j(!1),onResume:()=>{j(!0),i(E)},onRestart:()=>{j(!0),s(t.workflow,E)}}):b?n.jsx(Hee,{agent:g?Xee(g):null,existing:f,initial:b,onCancel:()=>v(null),onSave:M=>{H(M)}}):n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-card/85",children:[n.jsxs("div",{className:"border-b border-border px-4 py-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsxs("h2",{className:"flex items-center gap-1.5 text-[13px] font-semibold",children:[n.jsx(Xt,{className:"size-4"})," ",e("workflows.title")]}),n.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e("workflows.subtitle")})]}),n.jsxs(Q,{onClick:()=>v(Qee(f)),size:"sm",type:"button",variant:"outline",children:[n.jsx(ms,{className:"size-3.5"})," ",e("workflows.new")]})]}),n.jsxs("label",{className:"mt-2 flex w-fit items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx("input",{checked:E,className:"size-3.5 accent-primary",onChange:M=>T(M.target.checked),type:"checkbox"}),e("workflows.autoApprove"),n.jsx("span",{className:"text-muted-foreground/60",children:e("workflows.autoApproveHint")})]})]}),_?n.jsx(Ze,{variant:"destructive",className:"m-4",children:_}):C?n.jsxs("div",{className:"flex flex-1 items-center justify-center text-[12px] text-muted-foreground",children:[n.jsx(Mt,{className:"mr-2 size-4 animate-spin"})," ",e("workflows.loading")]}):n.jsxs(n.Fragment,{children:[t?n.jsx(Bee,{onClear:d,onView:()=>j(!0),run:t}):null,n.jsx("div",{className:"grid gap-3 p-4 sm:grid-cols-2 xl:grid-cols-3",children:f.map(M=>n.jsx(Iee,{lastRun:t?.workflow.id===M.id?t:null,workflow:M,onDelete:()=>{P(M)},onDuplicate:()=>F(M),onEdit:()=>v(M),onRun:()=>L(M)},M.id))}),n.jsx(Oee,{workflows:f})]})]})}function Bee({onClear:e,onView:t,run:s}){const i=J(),a=s.outcome==="running";return n.jsx("section",{className:"mx-4 mt-4 rounded-md border border-border bg-background p-3 shadow-sm",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:i(a?"workflows.banner.running":"workflows.banner.last")}),n.jsx(RT,{outcome:s.outcome})]}),n.jsx("p",{className:"mt-1 truncate text-[13px] font-medium",children:s.workflow.name}),n.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:a?i("workflows.banner.startedAt",{time:Bx(s.startedAt)}):i("workflows.banner.ranAt",{time:Bx(s.startedAt)})})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{onClick:t,size:"sm",type:"button",children:[n.jsx(Tl,{className:"size-3.5"})," ",i("workflows.viewRun")]}),a?null:n.jsxs(Q,{onClick:e,size:"sm",type:"button",variant:"outline",children:[n.jsx(Vt,{className:"size-3.5"})," ",i("workflows.clear")]})]})]})})}function Iee({lastRun:e,workflow:t,onDelete:s,onDuplicate:i,onEdit:a,onRun:l}){const c=J(),[d,f]=x.useState(!1),h=t.steps.length;return n.jsxs("div",{className:"flex flex-col rounded-lg border border-border bg-background p-3.5 shadow-sm",children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsx("h3",{className:"text-[13px] font-semibold",children:t.name}),t.builtin?n.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[9px] uppercase tracking-wide text-muted-foreground",children:c("workflows.template")}):null]}),t.description?n.jsx("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:t.description}):null,e?n.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx(Tl,{className:"size-3"}),e.outcome==="running"?c("workflows.runningNow"):c("workflows.lastRun",{time:Bx(e.startedAt)})]}):null,n.jsxs("button",{"aria-expanded":d,className:"mt-2.5 flex w-full items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",onClick:()=>f(g=>!g),type:"button",children:[n.jsx(wn,{className:re("size-3 shrink-0 transition-transform",d?"rotate-90":""),"aria-hidden":!0}),n.jsx("span",{children:c(h===1?"workflows.stepOne":"workflows.stepMany",{count:h})})]}),d?n.jsx("ol",{className:"mt-1.5 space-y-1",children:t.steps.map(g=>n.jsxs("li",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx(tte,{kind:g.kind}),n.jsx("span",{className:"truncate",children:Bf(g)})]},g.id))}):null,n.jsxs(Q,{className:"mt-3 w-full",onClick:l,size:"sm",type:"button",children:[n.jsx(or,{className:"size-3.5"})," ",c("workflows.run")]}),n.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-1.5",children:[n.jsxs(Q,{onClick:a,size:"sm",type:"button",variant:"outline",children:[n.jsx(HD,{className:"size-3.5"})," ",c("common.edit")]}),n.jsxs(Q,{onClick:i,size:"sm",type:"button",variant:"outline",children:[n.jsx(nf,{className:"size-3.5"})," ",c("common.copy")]}),n.jsxs(Q,{disabled:t.builtin,onClick:s,size:"sm",title:t.builtin?c("workflows.deleteBuiltinHint"):c("workflows.deleteTitle"),type:"button",variant:"outline",children:[n.jsx(Ii,{className:"size-3.5"})," ",c("common.delete")]})]})]})}function Hee({agent:e,existing:t,initial:s,onCancel:i,onSave:a}){const l=J(),[c,d]=x.useState(()=>structuredClone(s)),[f,h]=x.useState(s.description??""),[g,p]=x.useState(!1),b=Zee(e),{sendToAgent:v}=Ot(),_=!c.id.trim()||!c.name.trim()||c.steps.length===0;function S(H,P){d(F=>({...F,steps:F.steps.map((M,z)=>z===H?P(M):M)}))}function C(H,P){d(F=>{const M=H+P;if(M<0||M>=F.steps.length)return F;const z=[...F.steps],[G]=z.splice(H,1);return z.splice(M,0,G),{...F,steps:z}})}function N(H){d(P=>({...P,steps:P.steps.filter((F,M)=>M!==H)}))}function A(H,P){d(F=>{const M=[...F.steps];return M.splice(H,0,Fee(P,F.steps)),{...F,steps:M}})}function j(H=f){const P=UN(H,t,b);d(P)}function E(H){const P=UN(H,[],b);d(F=>({...F,steps:[...F.steps,...P.steps]}))}function T(){v({prompt:Ree(f||c.description||c.name),source:{type:"workflow",label:l("workflows.builder.composerSource")},mode:"draft"})}function L(){const H=kl(c.id)||d1(kl(c.name)||"workflow",t);a({...c,id:H,name:c.name.trim(),description:(f||c.description)?.trim()||void 0,builtin:!1,steps:c.steps.map(Jee)})}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-card/85",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Xt,{className:"size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("input",{"aria-label":l("workflows.builder.nameAria"),className:"w-full bg-transparent text-[14px] font-semibold outline-none",onChange:H=>d(P=>({...P,name:H.target.value,id:kl(H.target.value)||P.id})),placeholder:l("workflows.builder.namePlaceholder"),value:c.name}),n.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id})]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>p(H=>!H),size:"sm",type:"button",variant:g?"default":"outline",children:[n.jsx(Bn,{className:"size-3.5"})," ",l("workflows.builder.aiCompose")]}),n.jsxs(Q,{onClick:i,size:"sm",type:"button",variant:"outline",children:[n.jsx(ju,{className:"size-3.5"})," ",l("common.back")]}),n.jsxs(Q,{disabled:_,onClick:L,size:"sm",type:"button",children:[n.jsx(Ys,{className:"size-3.5"})," ",l("common.save")]})]})]}),g?n.jsx("section",{className:"shrink-0 border-b border-border bg-muted/20 p-4",children:n.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[n.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 shadow-sm",children:[n.jsx(Or,{children:l("workflows.builder.describe")}),n.jsx("textarea",{className:"min-h-16 w-full resize-none bg-transparent text-[13px] leading-relaxed outline-none placeholder:text-muted-foreground",onChange:H=>h(H.target.value),placeholder:l("workflows.builder.describePlaceholder"),value:f}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>j(),size:"sm",type:"button",children:[n.jsx(Bn,{className:"size-3.5"})," ",l("workflows.builder.draftTimeline")]}),n.jsxs(Q,{onClick:T,size:"sm",type:"button",variant:"outline",children:[n.jsx(xD,{className:"size-3.5"})," ",l("workflows.builder.askAi")]}),["Commit safely","Review then push","Fix CI then PR","File issue from changes"].map(H=>n.jsx("button",{className:"rounded-md border border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>{h(H),j(H)},type:"button",children:H},H))]})]}),n.jsxs("div",{className:"grid gap-3",children:[n.jsx(Uee,{onAdd:E}),n.jsx(qee,{capabilities:b})]})]})}):null,n.jsx("main",{className:"min-h-0 flex-1 overflow-auto p-4",children:n.jsxs("div",{className:"mx-auto max-w-3xl",children:[n.jsx(GN,{onInsert:H=>A(0,H)}),c.steps.length?c.steps.map((H,P)=>n.jsxs(x.Fragment,{children:[n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("div",{className:"relative flex w-9 shrink-0 justify-center pt-2",children:[n.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border"}),n.jsx($ee,{index:P,kind:H.kind})]}),n.jsx("div",{className:"min-w-0 flex-1 pb-1",children:n.jsx(Gee,{capabilities:b,index:P,isFirst:P===0,isLast:P===c.steps.length-1,onMove:C,onRemove:N,onUpdate:S,step:H})})]}),n.jsx(GN,{onInsert:F=>A(P+1,F)})]},`${H.kind}:${H.id}`)):n.jsx("div",{className:"ml-[3.25rem] flex h-24 items-center justify-center rounded-lg border border-dashed border-border text-[12px] text-muted-foreground",children:l("workflows.builder.emptyCanvas")})]})})]})}function GN({defaultOpen:e=!1,onInsert:t}){const s=J(),[i,a]=x.useState(e),l=["gate","agent","action"];return n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("div",{className:"relative flex w-9 shrink-0 justify-center",children:[n.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border"}),n.jsx("button",{"aria-label":s(i?"workflows.builder.cancelAddStep":"workflows.builder.addStepHere"),className:re("relative z-10 my-1.5 flex size-5 items-center justify-center rounded-full border bg-card text-muted-foreground transition-colors",i?"border-primary/50 text-primary":"border-border hover:border-primary/50 hover:text-primary"),onClick:()=>a(c=>!c),type:"button",children:i?n.jsx(Vt,{className:"size-3"}):n.jsx(ms,{className:"size-3"})})]}),n.jsx("div",{className:"flex-1 py-1",children:i?n.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:l.map(c=>n.jsxs("button",{className:"flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground",onClick:()=>{t(c),a(!1)},type:"button",children:[n.jsx(MT,{kind:c})," ",s(jT[c])]},c))}):null})]})}function $ee({index:e,kind:t}){return n.jsxs("div",{className:"relative z-10 flex size-9 items-center justify-center rounded-full border border-border bg-card shadow-sm",children:[n.jsx("span",{className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full border border-border bg-background font-mono text-[9px] text-muted-foreground",children:e+1}),n.jsx(MT,{kind:t})]})}function Fee(e,t){const s=new Set(t.map(a=>a.id)),i=a=>{let l=a,c=2;for(;s.has(l);)l=`${a}-${c++}`;return l};return e==="gate"?{kind:"gate",id:i("gate"),title:"Approve step",message:"Continue?"}:e==="action"?{kind:"action",id:i("action"),title:"Commit with approved message",op:"commit"}:{kind:"agent",id:i("step"),title:"AI step",prompt:""}}function Uee({onAdd:e}){const t=J(),[s,i]=x.useState("");return n.jsxs("form",{className:"rounded-lg border border-dashed border-border bg-background/70 p-3",onSubmit:a=>{a.preventDefault();const l=s.trim();l&&(e(l),i(""))},children:[n.jsx(Or,{children:t("workflows.builder.addStepLabel")}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{className:"min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground",onChange:a=>i(a.target.value),placeholder:t("workflows.builder.addStepPlaceholder"),value:s}),n.jsxs(Q,{size:"sm",type:"submit",variant:"outline",children:[n.jsx(ms,{className:"size-3.5"})," ",t("common.add")]})]})]})}function qee({capabilities:e}){const t=J(),s=[...e.skills.map(i=>`@skill:${i}`),...e.mcpServers.map(i=>`@mcp:${i}`),...e.plugins.map(i=>`@plugin:${i}`)].slice(0,18);return s.length?n.jsxs("div",{className:"rounded-lg border border-border bg-background p-3",children:[n.jsx(Or,{children:t("workflows.builder.detectedCapabilities")}),n.jsx("div",{className:"flex max-h-20 flex-wrap gap-1.5 overflow-hidden",children:s.map(i=>n.jsx("span",{className:"rounded-md border border-border bg-muted/30 px-2 py-1 font-mono text-[11px] text-muted-foreground",children:i},i))})]}):null}function Gee({capabilities:e,index:t,isFirst:s,isLast:i,onMove:a,onRemove:l,onUpdate:c,step:d}){const f=J();return n.jsx("section",{className:"group rounded-lg border border-border bg-background p-3 shadow-sm",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ix,{kind:d.kind}),n.jsx("input",{className:"min-w-0 flex-1 bg-transparent text-[13px] font-semibold outline-none",onChange:h=>c(t,g=>({...g,title:h.target.value})),value:d.title})]}),d.kind==="gate"?n.jsx("textarea",{className:"mt-2 min-h-12 w-full resize-none bg-transparent text-[12px] leading-relaxed text-muted-foreground outline-none focus:text-foreground",onChange:h=>c(t,g=>g.kind==="gate"?{...g,message:h.target.value}:g),placeholder:f("workflows.builder.gatePlaceholder"),value:d.message}):d.kind==="action"?n.jsxs("div",{className:"mt-2 space-y-1.5",children:[n.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-[12px] outline-none",onChange:h=>{const g=h.target.value;c(t,p=>p.kind==="action"?{...p,op:g}:p)},value:d.op,children:[n.jsx("option",{value:"commit",children:f("workflows.op.commit")}),n.jsx("option",{value:"push",children:f("workflows.op.push")}),n.jsx("option",{value:"assert-pr-branch",children:f("workflows.op.assertPrBranch")}),n.jsx("option",{value:"checkout-default-and-pull",children:f("workflows.op.checkoutDefault")})]}),n.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:f(AT[d.op])})]}):n.jsxs(n.Fragment,{children:[n.jsx("textarea",{className:"mt-2 min-h-16 w-full resize-none bg-transparent text-[12px] leading-relaxed text-muted-foreground outline-none focus:text-foreground",onChange:h=>c(t,g=>g.kind==="agent"?{...g,prompt:h.target.value}:g),placeholder:f("workflows.builder.agentPromptPlaceholder"),value:d.prompt}),n.jsx(Vee,{capabilities:e,selected:d.capabilities,onToggle:(h,g)=>c(t,p=>p.kind==="agent"?{...p,capabilities:ete(p.capabilities,h,g)}:p)})]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-70 transition-opacity group-hover:opacity-100",children:[n.jsx(Q,{disabled:s,onClick:()=>a(t,-1),size:"sm",type:"button",variant:"ghost",children:"↑"}),n.jsx(Q,{disabled:i,onClick:()=>a(t,1),size:"sm",type:"button",variant:"ghost",children:"↓"}),n.jsx(Q,{onClick:()=>l(t),size:"sm",type:"button",variant:"ghost",children:n.jsx(Ii,{className:"size-3.5"})})]})]})})}function Vee({capabilities:e,onToggle:t,selected:s}){const i=J(),a=[{key:"skills",label:"Skills",values:e.skills},{key:"mcpServers",label:"MCP",values:e.mcpServers},{key:"plugins",label:"Plugins",values:e.plugins},{key:"hooks",label:"Hooks",values:e.hooks}];return n.jsxs("div",{className:"space-y-2",children:[n.jsx(Or,{children:i("workflows.builder.capabilities")}),a.map(l=>n.jsxs("div",{children:[n.jsx("div",{className:"mb-1 text-[10px] text-muted-foreground",children:l.label}),l.values.length?n.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.values.map(c=>{const d=s?.[l.key]?.includes(c)??!1;return n.jsx("button",{className:re("rounded-md border px-2 py-1 text-[11px] transition-colors",d?"border-primary/50 bg-primary/10 text-primary":"border-border bg-muted/30 text-muted-foreground hover:bg-muted"),onClick:()=>t(l.key,c),type:"button",children:c},c)})}):n.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:i("workflows.builder.noneDetected")})]},l.key))]})}function Wee({run:e,onApprove:t,onSkip:s,onStop:i,onBack:a,onResume:l,onRestart:c}){const d=J(),{sendToAgent:f}=Ot(),h=e.outcome!=="running",[g,p]=x.useState(e.index);x.useEffect(()=>{p(e.index)},[e.index]);const b=e.workflow.steps[g]??e.workflow.steps[e.index],v=e.statuses[g]??"pending",_=e.outputs[g],S=e.outputs[g-1],C=b?.kind==="gate"&&v==="waiting",N=v==="failed"||v==="blocked",A=v==="blocked"&&b?.kind==="action"&&b.op==="assert-pr-branch";return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-card/85",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("h2",{className:"flex items-center gap-1.5 text-[13px] font-semibold",children:[n.jsx(Xt,{className:"size-4"})," ",e.workflow.name]}),n.jsxs("p",{className:"mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground",children:[n.jsx(Tl,{className:"size-3"})," ",d("workflows.run.watchDock")]})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(RT,{outcome:e.outcome}),n.jsxs(Q,{onClick:a,size:"sm",type:"button",variant:"outline",children:[n.jsx(ju,{className:"size-3.5"})," ",d("workflows.run.workflows")]}),h?null:n.jsxs(Q,{onClick:i,size:"sm",type:"button",variant:"outline",children:[n.jsx(Ta,{className:"size-3.5"})," ",d("common.stop")]})]})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden lg:grid-cols-[minmax(240px,320px)_minmax(0,1fr)]",children:[n.jsx("aside",{className:"min-h-0 overflow-auto border-b border-border bg-background/55 p-3 lg:border-b-0 lg:border-r",children:n.jsx("ol",{className:"space-y-1",children:e.workflow.steps.map((j,E)=>{const T=e.statuses[E],L=T==="running"||T==="waiting",H=E===g;return n.jsx("li",{children:n.jsxs("button",{className:re("flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left transition-colors",H?"border-primary/45 bg-primary/[0.06]":L?"border-primary/30 bg-primary/[0.03]":"border-transparent hover:border-border hover:bg-muted/40"),onClick:()=>p(E),type:"button",children:[n.jsx("span",{className:re("flex size-7 shrink-0 items-center justify-center rounded-full border bg-card",T==="failed"?"border-destructive/50":T==="blocked"?"border-amber-500/50":L?"border-primary/50":T==="done"?"border-emerald-500/50":"border-border"),children:n.jsx(WN,{status:T,kind:j.kind})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[12px] font-medium",children:Bf(j)}),n.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5",children:[n.jsx(Ix,{kind:j.kind}),n.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:d(VN[T])})]})]}),n.jsx(wn,{className:re("size-3.5 shrink-0 text-muted-foreground/50 transition-transform",H?"translate-x-0.5 text-primary":"")})]})},j.id)})})}),n.jsx("main",{className:"min-h-0 overflow-auto p-4",children:b?n.jsxs("section",{className:re("min-h-full rounded-lg border bg-background p-4 shadow-sm",v==="failed"?"border-destructive/40 bg-destructive/[0.03]":v==="blocked"?"border-amber-500/40 bg-amber-500/[0.04]":v==="running"||v==="waiting"?"border-primary/40 bg-primary/[0.03]":"border-border"),children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(WN,{status:v,kind:b.kind}),n.jsx("h3",{className:"truncate text-[13px] font-semibold",children:Bf(b)})]}),n.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[n.jsx(Ix,{kind:b.kind}),n.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:d(VN[v])})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h&&N&&g===e.index&&!A?n.jsxs(Q,{"aria-label":d("workflows.run.resumeAria"),onClick:l,size:"sm",type:"button",children:[n.jsx(or,{className:"size-3.5"})," ",d("workflows.run.resume")]}):null,N?n.jsxs(Q,{"aria-label":d("workflows.run.debugAria"),onClick:()=>f({prompt:Gq({workflowName:e.workflow.name,step:b,status:v,error:e.error,previousOutput:S,output:_}),source:{type:"workflow-debug",label:b.title},mode:"send",label:d("workflows.run.debugLabel",{title:b.title}),background:!0}),size:"sm",type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"})," ",d("workflows.run.debugWithAi")]}):null,h?null:n.jsxs(Q,{"aria-label":d("workflows.run.stopAria"),onClick:i,size:"sm",type:"button",variant:"outline",children:[n.jsx(Ta,{className:"size-3.5"})," ",d("workflows.run.stopAfter")]})]})]}),n.jsxs("div",{className:"py-3 text-[11px] leading-relaxed",children:[n.jsx(Yee,{output:_,previousOutput:S,status:v,step:b}),C?n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{onClick:t,size:"sm",type:"button",children:[n.jsx(Ys,{className:"size-3.5"})," ",d("workflows.run.approve")]}),n.jsxs(Q,{onClick:s,size:"sm",type:"button",variant:"outline",children:[n.jsx(EE,{className:"size-3.5"})," ",d("workflows.run.skip")]}),n.jsxs(Q,{onClick:i,size:"sm",type:"button",variant:"outline",children:[n.jsx(Vt,{className:"size-3.5"})," ",d("common.stop")]})]}):null,v==="failed"&&e.error?n.jsx("p",{className:"mt-3 text-destructive",children:e.error}):null,A?n.jsx(Kee,{error:e.error,onRestart:c,workflowName:e.workflow.name}):null,v==="blocked"&&e.error?n.jsx("p",{className:"mt-3 text-amber-700 dark:text-amber-400",children:e.error}):null]})]}):null})]})]})}function Kee({error:e,onRestart:t,workflowName:s}){const i=J(),{provider:a}=Ot(),[l,c]=x.useState(""),[d,f]=x.useState(!1),[h,g]=x.useState(!1),[p,b]=x.useState(null),[v,_]=x.useState(null),S=x.useRef(null),C=Jq(l);x.useEffect(()=>()=>S.current?.abort(),[]);async function N(j){S.current?.abort();const E=new AbortController;S.current=E,_(null),b(null),c(""),f(!0);try{const T=await B0({prompt:[Vq({workflowName:s,error:e}),j?.trim()?j.trim():""].filter(Boolean).join(`
|
|
226
226
|
|
|
227
|
-
`),provider:a?.id,signal:E.signal});E.signal.aborted||c(T)}catch(T){E.signal.aborted||_(T instanceof Error?T.message:String(T))}finally{S.current===E&&(S.current=null,f(!1))}}async function A(){if(C){g(!0),_(null);try{await N7(C),b(C)}catch(j){_(j instanceof Error?j.message:String(j))}finally{g(!1)}}}return n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-muted/35 p-3",children:[n.jsx(Or,{children:i("workflows.recover.title")}),n.jsx("p",{className:"mb-2 text-[11px] text-muted-foreground",children:i("workflows.recover.desc")}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>{N()},size:"sm",type:"button",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.recommend")]}),p?n.jsxs(Q,{onClick:t,size:"sm",type:"button",variant:"outline",children:[n.jsx(or,{className:"size-3.5"})," ",i("workflows.recover.runAgain")]}):null]}),d?n.jsxs("p",{className:"mt-2 flex items-center gap-1 text-[11px] text-muted-foreground",children:[n.jsx(Mt,{className:"size-3 animate-spin"})," ",i("workflows.recover.choosing")]}):null,C?n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-background p-2.5",children:[n.jsx(Or,{children:i("workflows.recover.recommendedBranch")}),n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("code",{className:"min-w-0 rounded bg-muted px-2 py-1 font-mono text-[12px] text-foreground",children:C}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{disabled:h||p===C,onClick:()=>{A()},size:"sm",type:"button",children:[h?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Ys,{className:"size-3.5"}),i("workflows.recover.createBranch")]}),n.jsxs(Q,{disabled:h,onClick:()=>{N("Recommend a different concise branch name. Keep the same output contract with `BRANCH_NAME: <branch-name>`.")},size:"sm",type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.askAnother")]})]})]})]}):l&&!d?n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-background p-2.5",children:[n.jsx("p",{className:"text-[11px] text-muted-foreground",children:i("workflows.recover.noBranch")}),n.jsxs(Q,{className:"mt-2",onClick:()=>{N("Return only a concise branch suggestion using this exact line: `BRANCH_NAME: <branch-name>`.")},size:"sm",type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.askAnother")]})]}):null,p?n.jsxs("p",{className:"mt-2 text-[11px] text-emerald-700 dark:text-emerald-400",children:[i("workflows.recover.createdPre"),n.jsx("code",{className:"font-mono",children:p}),i("workflows.recover.createdPost")]}):null,v?n.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:v}):null]})}const VN={running:"workflows.status.running",waiting:"workflows.status.waiting",done:"workflows.status.done",blocked:"workflows.status.needsYou",failed:"workflows.status.failed",skipped:"workflows.status.skipped",pending:"workflows.status.queued"},jT={gate:"workflows.kind.gate",agent:"workflows.kind.agent",action:"workflows.kind.action"};function Yee({output:e,previousOutput:t,status:s,step:i}){const a=J();if(i.kind==="gate"){const c=i.id==="gate-commit"?t?.trim():"";return n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:i.message}),c?n.jsxs("div",{className:"mt-3",children:[n.jsx(Or,{children:a("workflows.step.generatedCommitMessage")}),n.jsx("div",{className:"whitespace-pre-wrap break-words rounded-md border border-border bg-muted/50 px-2.5 py-2 font-mono text-[11px] text-foreground",children:c})]}):null]})}if(i.kind==="action")return n.jsx("p",{className:"text-muted-foreground",children:a(AT[i.op])});const l=s==="done"||s==="failed"||s==="skipped";return e?n.jsxs("div",{children:[n.jsx(Or,{children:a("workflows.step.result")}),n.jsx("div",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/50 px-2.5 py-2 font-mono text-[11px] text-foreground",children:e})]}):n.jsxs("div",{children:[n.jsx(Or,{children:a(l?"workflows.step.result":"workflows.step.task")}),l?n.jsx("p",{className:"italic text-muted-foreground",children:a("workflows.step.noReply")}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground",children:i.prompt}),s==="running"?n.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-muted-foreground/80",children:[n.jsx(Mt,{className:"size-3 animate-spin"})," ",a("workflows.step.working")]}):null]})]})}function Xee(e){return e.detected.name==="codex"?e.agents.codex:e.agents["claude-code"]??e}function Zee(e){return e?{skills:ru(e.skills.map(t=>t.name)),mcpServers:ru(e.mcpServers.map(t=>t.name)),plugins:ru(e.plugins.map(t=>t.name)),hooks:ru(e.hooks.map(t=>t.matcher?`${t.event}: ${t.matcher}`:t.event))}:{skills:[],mcpServers:[],plugins:[],hooks:[]}}function Qee(e){return{id:d1("custom-workflow",e),name:"Custom workflow",description:"A user-built workflow.",builtin:!1,steps:[{kind:"gate",id:"gate-start",title:"Approve start",message:"Run this workflow?"}]}}function Jee(e){const t=kl(e.id)||e.kind,s=e.title.trim()||Bf(e);if(e.kind==="gate")return{...e,id:t,title:s,message:e.message.trim()||"Continue?"};if(e.kind==="action")return{...e,id:t,title:s};const i=TT(e.capabilities);return{...e,id:t,title:s,prompt:e.prompt.trim()||"Complete this workflow step.",capabilities:i}}const AT={"assert-pr-branch":"workflows.opDesc.assertPrBranch","checkout-default-and-pull":"workflows.opDesc.checkoutDefault",push:"workflows.opDesc.push",commit:"workflows.opDesc.commit"};function TT(e){if(!e)return;const t={};for(const s of["skills","mcpServers","plugins","hooks"]){const i=ru((e[s]??[]).map(a=>a.trim()).filter(Boolean));i.length&&(t[s]=i)}return Object.keys(t).length?t:void 0}function ete(e,t,s){const i=e?.[t]??[],a=i.includes(s)?i.filter(l=>l!==s):[...i,s];return TT({...e??{},[t]:a})}function d1(e,t){const s=new Set(t.map(l=>l.id));let i=kl(e)||"workflow",a=2;for(;s.has(i);)i=`${kl(e)||"workflow"}-${a}`,a++;return i}function kl(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ru(e){return Array.from(new Set(e.filter(Boolean)))}function Or({children:e}){return n.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:e})}function Bx(e){return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(new Date(e))}function RT({outcome:e}){const t=J(),s={running:{labelKey:"workflows.status.running",className:"border-primary/40 text-primary"},done:{labelKey:"workflows.status.done",className:"border-emerald-500/40 text-emerald-600 dark:text-emerald-400"},stopped:{labelKey:"workflows.status.stopped",className:"border-border text-muted-foreground"},failed:{labelKey:"workflows.status.failed",className:"border-destructive/40 text-destructive"},blocked:{labelKey:"workflows.status.needsYou",className:"border-amber-500/40 text-amber-700 dark:text-amber-400"}},{labelKey:i,className:a}=s[e];return n.jsx("span",{className:re("rounded-full border px-2 py-0.5 text-[10px] font-medium",a),children:t(i)})}function MT({kind:e}){return e==="gate"?n.jsx(NE,{className:"size-4 text-amber-600 dark:text-amber-400"}):e==="agent"?n.jsx(Bn,{className:"size-4 text-primary"}):n.jsx(or,{className:"size-4 text-muted-foreground"})}function WN({status:e,kind:t}){return e==="running"?n.jsx(Mt,{className:"size-4 shrink-0 animate-spin text-primary"}):e==="waiting"?n.jsx(NE,{className:"size-4 shrink-0 text-primary"}):e==="done"?n.jsx(Ys,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}):e==="blocked"?n.jsx(Gf,{className:"size-4 shrink-0 text-amber-600 dark:text-amber-400"}):e==="failed"?n.jsx(zr,{className:"size-4 shrink-0 text-destructive"}):e==="skipped"?n.jsx(EE,{className:"size-4 shrink-0 text-muted-foreground/60"}):t==="agent"?n.jsx(Bn,{className:"size-4 shrink-0 text-muted-foreground/50"}):n.jsx(DM,{className:"size-4 shrink-0 text-muted-foreground/50"})}function tte(e){return n.jsx(wn,{className:"size-3 shrink-0 text-muted-foreground/40","aria-hidden":!0})}function Ix({kind:e}){const t=J(),s=e==="agent"?"border-primary/30 text-primary":e==="gate"?"border-amber-500/40 text-amber-600 dark:text-amber-400":"border-border text-muted-foreground";return n.jsx("span",{className:re("shrink-0 rounded-full border px-1.5 py-px text-[9px] uppercase tracking-wide",s),children:t(jT[e])})}function Bf(e){return e.title}function ste(){const[e,t]=x.useState(!1),[s,i]=x.useState(!1),[a,l]=x.useState(!0),[c,d]=x.useState("checking"),[f,h]=x.useState(null),[g,p]=x.useState(null);function b(){l(!0),d("checking"),h(null),D7().then(v=>{t(v.configured),i(v.deviceFlowAvailable),d(v.status),h(v.error??null),p(v)}).catch(v=>{t(!1),i(!1),d("connection_error"),h(v instanceof Error?v.message:String(v)),p(null)}).finally(()=>l(!1))}return x.useEffect(()=>{b()},[]),{configured:e,deviceFlowAvailable:s,loading:a,status:c,error:f,info:g,isConnected:c==="connected",needsLogin:c==="not_configured"||c==="auth_error",refresh:b}}const dv=30;function nte(e="open"){const[t,s]=x.useState([]),[i,a]=x.useState(!0),[l,c]=x.useState(!1),[d,f]=x.useState(!1),[h,g]=x.useState(1),[p,b]=x.useState(null),[v,_]=x.useState(null),[S,C]=x.useState(null),[N,A]=x.useState(""),[j,E]=x.useState(!1),[T,L]=x.useState(null);x.useEffect(()=>{let F=!0;return a(!0),b(null),g(1),Bg(e,1).then(M=>{F&&(s(M),f(M.length===dv),M.length>0&&!M.some(z=>z.number===v)&&_(M[0]?.number??null))}).catch(M=>{F&&b(M instanceof Error?M.message:String(M))}).finally(()=>{F&&a(!1)}),()=>{F=!1}},[e]),x.useEffect(()=>{if(!v){C(null);return}let F=!0;return I7(v).then(M=>{F&&C(M)}).catch(()=>{}),()=>{F=!1}},[v]),x.useEffect(()=>{if(!v){A("");return}let F=!0;return E(!0),L(null),H7(v).then(M=>{F&&A(M)}).catch(M=>{F&&L(M instanceof Error?M.message:String(M))}).finally(()=>{F&&E(!1)}),()=>{F=!1}},[v]);function H(){if(l||!d)return;const F=h+1;c(!0),Bg(e,F).then(M=>{s(z=>{const G=new Set(z.map(D=>D.number));return[...z,...M.filter(D=>!G.has(D.number))]}),f(M.length===dv),g(F)}).catch(M=>b(M instanceof Error?M.message:String(M))).finally(()=>c(!1))}function P(){let F=!0;return a(!0),b(null),g(1),Bg(e,1).then(M=>{F&&(s(M),f(M.length===dv))}).catch(M=>{F&&b(M instanceof Error?M.message:String(M))}).finally(()=>{F&&a(!1)}),()=>{F=!1}}return{prs:t,loading:i,loadingMore:l,hasMore:d,error:p,selectedNumber:v,setSelectedNumber:_,selectedPR:S,diff:N,diffLoading:j,diffError:T,loadMore:H,refresh:P}}const hv=30;function ite(e="open"){const[t,s]=x.useState([]),[i,a]=x.useState(!0),[l,c]=x.useState(!1),[d,f]=x.useState(!1),[h,g]=x.useState(1),[p,b]=x.useState(null),[v,_]=x.useState(null),[S,C]=x.useState(null),[N,A]=x.useState([]),[j,E]=x.useState(!1),[T,L]=x.useState(null),[H,P]=x.useState(!1);x.useEffect(()=>{let G=!0;return a(!0),b(null),g(1),Ig(e,1).then(D=>{G&&(s(D),f(D.length===hv),D.length>0&&!D.some(q=>q.number===v)&&_(D[0]?.number??null))}).catch(D=>{G&&b(D instanceof Error?D.message:String(D))}).finally(()=>{G&&a(!1)}),()=>{G=!1}},[e]),x.useEffect(()=>{if(!v){C(null),A([]);return}let G=!0;return E(!0),Promise.all([G7(v),V7(v)]).then(([D,q])=>{G&&(C(D),A(q))}).catch(()=>{}).finally(()=>{G&&E(!1)}),()=>{G=!1}},[v]);async function F(G){if(v){P(!0),L(null);try{const D=await W7(v,G);A(q=>[...q,D])}catch(D){L(D instanceof Error?D.message:String(D))}finally{P(!1)}}}function M(){if(l||!d)return;const G=h+1;c(!0),Ig(e,G).then(D=>{s(q=>{const W=new Set(q.map(I=>I.number));return[...q,...D.filter(I=>!W.has(I.number))]}),f(D.length===hv),g(G)}).catch(D=>b(D instanceof Error?D.message:String(D))).finally(()=>c(!1))}function z(){let G=!0;return a(!0),g(1),Ig(e,1).then(D=>{G&&(s(D),f(D.length===hv))}).catch(()=>{}).finally(()=>{G&&a(!1)}),()=>{G=!1}}return{issues:t,loading:i,loadingMore:l,hasMore:d,error:p,selectedNumber:v,setSelectedNumber:_,selectedIssue:S,comments:N,commentsLoading:j,commentError:T,submitting:H,addComment:F,loadMore:M,refresh:z}}function DT({deviceFlowAvailable:e,initialMode:t,onSaved:s}){const i=J(),[a,l]=x.useState(()=>t==="device-pending"&&!e?"pat":t??(e?"choose":"pat"));return a==="device-pending"?n.jsx(rte,{onSuccess:s,onCancel:()=>l("choose")}):a==="pat"?n.jsx(ate,{onSaved:s,onBack:e?()=>l("choose"):void 0}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-muted",children:n.jsx(tS,{className:"size-6 text-muted-foreground"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:i("github.setup.connectTitle")}),n.jsx("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:i("github.setup.connectDesc")})]})]}),n.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-2",children:[n.jsxs(Q,{className:"w-full",onClick:()=>l("device-pending"),type:"button",children:[n.jsx(tS,{className:"mr-2 size-4"}),i("github.setup.authorizeWith")]}),n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>l("pat"),type:"button",children:i("github.setup.usePat")})]})]})}function rte({onSuccess:e,onCancel:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState(!0),[h,g]=x.useState(!1),p=x.useRef(null),b=x.useRef(5),v=x.useRef(!1);x.useEffect(()=>{let N=!0;return L7().then(A=>{if(!N)return;a(A),b.current=A.interval,f(!1);const j=A.verification_uri_complete||A.verification_uri;j&&em(j),_(A.device_code,A.interval),setTimeout(()=>{v.current=!0},A.expires_in*1e3)}).catch(A=>{N&&(c(A instanceof Error?A.message:String(A)),f(!1))}),()=>{N=!1,p.current&&clearTimeout(p.current)}},[]);function _(N,A){p.current=setTimeout(()=>{S(N,A)},A*1e3)}async function S(N,A){if(v.current){c(s("github.setup.expired"));return}try{const j=await O7(N);if(j.done){e();return}const E=j.slowDown?A+5:A;b.current=E,_(N,E)}catch{_(N,b.current)}}function C(){i&&navigator.clipboard.writeText(i.user_code).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)})}return d?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx(sS,{className:"size-6 animate-spin text-muted-foreground"}),n.jsx("p",{className:"text-[13px] text-muted-foreground",children:s("github.setup.requesting")})]})}):l?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8",children:[n.jsx(Ze,{variant:"destructive",children:l}),n.jsx(Q,{onClick:t,variant:"outline",children:s("github.setup.goBack")})]}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-emerald-100 dark:bg-emerald-500/15",children:n.jsx(Vf,{className:"size-6 text-emerald-600 dark:text-emerald-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:s("github.setup.authorizeOnTitle")}),n.jsxs("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:[s("github.setup.enterCodePre"),n.jsx("strong",{children:s("github.setup.authorizeWord")}),s("github.setup.enterCodePost")]})]})]}),n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsx("div",{className:"flex cursor-pointer select-all items-center gap-3 rounded-xl border-2 border-border bg-muted px-6 py-4 font-mono text-2xl font-bold tracking-[0.3em] transition-colors hover:border-ring",onClick:C,title:s("github.setup.clickToCopy"),children:i?.user_code}),n.jsx("button",{className:"text-[11px] text-muted-foreground transition-colors hover:text-foreground",onClick:C,type:"button",children:s(h?"common.copied":"github.setup.clickCodeCopy")})]}),n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[n.jsx(sS,{className:"size-3.5 animate-spin"}),s("github.setup.waiting")]}),n.jsx("a",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",href:i?.verification_uri_complete||i?.verification_uri,rel:"noopener noreferrer",target:"_blank",children:s("github.setup.openAgain")}),n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:t,type:"button",children:s("common.cancel")})]})]})}function ate({onSaved:e,onBack:t}){const s=J(),[i,a]=x.useState(""),[l,c]=x.useState(!1),[d,f]=x.useState(null);async function h(g){g.preventDefault();const p=i.trim();if(p){c(!0),f(null);try{await P7("github.com",p),e()}catch(b){f(b instanceof Error?b.message:String(b))}finally{c(!1)}}}return n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-muted",children:n.jsx(xE,{className:"size-6 text-muted-foreground"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:s("github.setup.patTitle")}),n.jsxs("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:[s("github.setup.patDescPre"),n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"https://github.com/settings/tokens/new?scopes=repo,workflow",rel:"noopener noreferrer",target:"_blank",children:"github.com/settings/tokens"}),s("github.setup.patDescMid"),n.jsx("code",{className:"rounded bg-muted px-1 py-px text-[11px]",children:"repo"}),s("github.setup.patDescAnd"),n.jsx("code",{className:"rounded bg-muted px-1 py-px text-[11px]",children:"workflow"}),s("github.setup.patDescPost")]})]})]}),n.jsxs("form",{className:"flex w-full max-w-sm flex-col gap-3",onSubmit:g=>{h(g)},children:[n.jsx("input",{autoComplete:"off",className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-[13px] placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring",onChange:g=>a(g.target.value),placeholder:"ghp_...",spellCheck:!1,type:"password",value:i}),d?n.jsx(Ze,{variant:"destructive",children:d}):null,n.jsx(Q,{disabled:!i.trim()||l,type:"submit",children:s(l?"common.saving":"github.setup.saveToken")}),t?n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:t,type:"button",children:s("github.setup.back")}):null]})]})}function h1({hasMore:e,loading:t,onLoadMore:s}){const i=J();return e?n.jsx("div",{className:"p-2",children:n.jsxs("button",{className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-border py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-60",disabled:t,onClick:s,type:"button",children:[t?n.jsx(Mt,{className:"size-3 animate-spin"}):null,i(t?"common.loading":"github.loadMore")]})}):null}function ote({prs:e,loading:t,loadingMore:s,hasMore:i,error:a,selectedNumber:l,onSelect:c,onLoadMore:d}){const f=J();return t&&e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.prs.loading")}):a?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:a}):e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.prs.empty")}):n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"divide-y divide-border",children:e.map(h=>n.jsx("li",{children:n.jsxs("button",{className:`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted/60 ${l===h.number?"bg-muted":""}`,onClick:()=>c(h.number),type:"button",children:[n.jsx("span",{className:"mt-0.5 shrink-0",children:n.jsx(lte,{pr:h})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:h.title}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",h.number," · ",h.base.ref," ← ",h.head.ref," · ",h.user.login]})]}),h.draft?n.jsx("span",{className:"shrink-0 rounded border border-border px-1.5 py-px text-[10px] text-muted-foreground",children:f("github.prs.draft")}):null]})},h.number))}),n.jsx(h1,{hasMore:i,loading:s,onLoadMore:d})]})}function lte({pr:e}){return e.state==="merged"?n.jsx(af,{className:"size-4 text-purple-500"}):e.state==="closed"?n.jsx(R6,{className:"size-4 text-red-500"}):n.jsx(vE,{className:"size-4 text-emerald-500"})}function LT({body:e,title:t}){const s=J(),i=t??s("github.md.description"),[a,l]=x.useState("rendered"),c=d=>re("rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors",d?"bg-foreground text-background":"text-muted-foreground hover:text-foreground");return n.jsxs("section",{className:"overflow-hidden rounded-md border border-border bg-muted/25",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:i}),n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-background/60 p-0.5",children:[n.jsx("button",{className:c(a==="rendered"),onClick:()=>l("rendered"),type:"button",children:s("github.md.rendered")}),n.jsx("button",{className:c(a==="raw"),onClick:()=>l("raw"),type:"button",children:s("github.md.raw")})]})]}),a==="rendered"?n.jsx(l1,{content:e}):n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-3 py-3 font-mono text-[12px]",children:e})]})}function cte({pr:e,diff:t,diffLoading:s,diffError:i,onMerged:a}){const l=J(),[c,d]=x.useState("cockpit"),[f,h]=x.useState(null),[g,p]=x.useState(!1),[b,v]=x.useState(null),[_,S]=x.useState(null),[C,N]=x.useState(!1),[A,j]=x.useState(null),[E,T]=x.useState(!1),{sendToAgent:L}=Ot(),{isPending:H,runOperation:P}=In(),F=e?`github:pr:${e.number}:merge`:"",M=F?H(F):!1,z=x.useMemo(()=>bF(t),[t]);x.useEffect(()=>{j($=>$&&z.some(me=>me.path===$)?$:z[0]?.path??null)},[z]);const G=z.find($=>$.path===A)??z[0]??null;function D($){j($),d("diff")}function q($,me){e&&(T(!1),L({prompt:me?JF(e,me,$):QF(e,$),source:{type:"github-pr",label:`PR #${e.number}${me?` · ${If(me)}`:""}`},label:`PR #${e.number}${me?` (${If(me)})`:""}: ${$}`}))}if(x.useEffect(()=>{if(T(!1),!e){h(null);return}let $=!0;return p(!0),v(null),$7(e.number).then(me=>{$&&h(me)}).catch(me=>{$&&v(me instanceof Error?me.message:String(me))}).finally(()=>{$&&p(!1)}),()=>{$=!1}},[e]),!e)return n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:l("github.pr.selectPrompt")});const W=e.state==="open"&&!e.draft;async function I(){if(!(!e||M)){S(null);try{await P({errorMessage:$=>$ instanceof Error?$.message:String($),key:F,label:l("github.pr.mergingOperation",{number:e.number})},()=>q7(e.number,{method:"squash"})),N(!1),a?.()}catch($){S($ instanceof Error?$.message:String($)),N(!1)}}}const Y=$=>`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${$?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"group flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-semibold",children:e.title}),n.jsx(rr,{className:re("shrink-0",E&&"opacity-100"),label:l("github.pr.askLabel",{number:e.number}),onAsk:()=>T($=>!$)}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsx("button",{className:Y(c==="cockpit"),onClick:()=>d("cockpit"),type:"button",children:l("github.pr.tabReview")}),n.jsx("button",{className:Y(c==="diff"),onClick:()=>d("diff"),type:"button",children:l("github.pr.tabDiff")})]}),W?n.jsxs(Q,{className:"shrink-0",loading:M,loadingLabel:l("github.pr.merging"),onClick:()=>N(!0),size:"sm",title:l("github.pr.squashTitle"),type:"button",variant:"success",children:[n.jsx(af,{}),l("github.pr.squashMerge")]}):null,n.jsx("a",{"aria-label":l("github.openOnGithub"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.openOnGithub"),children:n.jsx(Pr,{className:"size-3.5"})})]}),_?n.jsx("div",{className:"shrink-0 border-b border-border bg-red-500/10 px-3 py-1.5 text-[11px] text-red-500",children:_}):null,E?n.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:n.jsx(Hr,{placeholder:l("github.pr.askPlaceholder"),onSubmit:$=>q($),onCancel:()=>T(!1)})}):null,c==="cockpit"?n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(ute,{cockpit:f,error:b,loading:g,onOpenFile:D,pr:e})}):s?n.jsx(im,{className:"flex-1",label:l("git.diff.loading")}):i?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:i}):z.length?n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[n.jsx(dte,{files:z,onAsk:($,me)=>q(me,$),onSelect:j,selected:G?.path??null}),n.jsx("div",{className:"relative min-h-0 min-w-0 flex-1",children:G?n.jsx(zu,{diff:G.diff}):null})]}):n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.pr.noDiff")}),C?n.jsx(Ol,{confirmLabel:M?n.jsxs(n.Fragment,{children:[n.jsx(nm,{size:"sm"})," ",l("github.pr.merging")]}):l("github.pr.squashMerge"),icon:n.jsx(af,{}),loading:M,message:n.jsxs(n.Fragment,{children:[l("github.pr.confirmPre"),n.jsxs("span",{className:"font-mono",children:["#",e.number]})," ",n.jsx("span",{className:"font-medium text-foreground",children:e.title}),l("github.pr.confirmInto"),n.jsx("span",{className:"font-mono",children:e.base.ref}),l("github.pr.confirmQ")]}),onCancel:()=>N(!1),onConfirm:()=>{I()},title:l("github.pr.squashMerge"),tone:"success"}):null]})}function ute({pr:e,cockpit:t,loading:s,error:i,onOpenFile:a}){const l=J(),[c,d]=x.useState(!1),f=t?.pr??e,h=t?.files??[],g=t?.reviews??[],p=t?.comments??[],b=t?.checks??null,v=b?.runs.filter(_=>_.conclusion==="failure"||_.conclusion==="timed_out"||_.conclusion==="cancelled")??[];return n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-[12px]",children:[n.jsx(mte,{pr:f}),n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border bg-muted/40 px-2 py-1 font-mono text-[11px]",children:[n.jsx(_n,{className:"size-3 shrink-0 text-muted-foreground"}),f.base.ref,n.jsx(ju,{className:"size-3 shrink-0 text-muted-foreground"}),f.head.ref]}),n.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[n.jsx(j8,{className:"size-3 shrink-0"}),f.user.login]}),n.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[n.jsx(wM,{className:"size-3 shrink-0"}),new Date(f.created_at).toLocaleDateString()]})]}),i?n.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2 text-[12px] text-red-500",children:i}):null,s?n.jsx(im,{className:"justify-start",label:l("github.pr.loadingCockpit")}):null,n.jsxs("div",{className:"grid gap-2 md:grid-cols-4",children:[n.jsx(Bh,{title:l("github.pr.mergeReadiness"),value:l(OT(f,b)),tone:hte(f,b)}),n.jsx(Bh,{title:l("github.pr.reviewStateTitle"),value:l(PT(g)),tone:fte(g)}),n.jsx(Bh,{title:l("github.pr.checks"),value:b?l("github.pr.checksValue",{state:b.state,count:b.totalCount}):l("github.pr.unknown"),tone:b?.state==="success"?"success":b?.state==="failure"||b?.state==="error"?"danger":"muted"}),n.jsx(Bh,{title:l("github.pr.changedFiles"),value:String(h.length),tone:"muted"})]}),v.length>0?n.jsxs("section",{className:"rounded-md border border-red-500/25 bg-red-500/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 text-[11px] font-medium text-red-500",children:l("github.pr.failingChecks")}),n.jsx("div",{className:"flex flex-wrap gap-2",children:v.slice(0,4).map(_=>n.jsxs("a",{className:"inline-flex items-center gap-1 text-[11px] text-red-500 underline-offset-2 hover:underline",href:_.html_url,rel:"noopener noreferrer",target:"_blank",children:[n.jsx($x,{className:"size-3"}),l("github.pr.openFailingCheck",{name:_.name})]},_.id))})]}):null,n.jsxs("section",{className:"rounded-md border border-border bg-muted/25 p-3",children:[n.jsxs("button",{className:"flex w-full items-center gap-2 text-[12px] font-medium",onClick:()=>d(_=>!_),type:"button",children:[c?n.jsx(hn,{className:"size-3.5 text-muted-foreground"}):n.jsx(wn,{className:"size-3.5 text-muted-foreground"}),n.jsx(qx,{className:"size-3.5 text-muted-foreground"}),l("github.pr.changedFiles"),h.length?n.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:["(",h.length,")"]}):null]}),c?h.length?n.jsx("ul",{className:"mt-2 divide-y divide-border",children:h.slice(0,12).map(_=>n.jsx("li",{children:n.jsxs("button",{className:"flex w-full items-center gap-2 py-1.5 text-left text-[12px] transition-colors hover:text-foreground",onClick:()=>a(_.path),title:l("github.pr.viewDiffTitle",{path:_.path}),type:"button",children:[n.jsx("span",{className:"w-16 shrink-0 font-mono text-[10px] uppercase text-muted-foreground",children:_.status}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:_.path}),n.jsxs("span",{className:"shrink-0 font-mono text-[11px] text-emerald-600",children:["+",_.additions]}),n.jsxs("span",{className:"shrink-0 font-mono text-[11px] text-red-500",children:["-",_.deletions]})]})},_.path))}):n.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground",children:l("github.pr.noFileMeta")}):null]}),n.jsxs("section",{className:"rounded-md border border-border bg-muted/25 p-3",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[12px] font-medium",children:[n.jsx(_D,{className:"size-3.5 text-muted-foreground"}),l("github.pr.reviewStateTitle")]}),g.length||p.length?n.jsxs("div",{className:"space-y-2",children:[g.slice(-4).map(_=>n.jsx(KN,{href:_.html_url,meta:`${_.user.login} - ${_.state.toLowerCase()}`,text:_.body||l("github.pr.noReviewSummary")},`review:${_.id}`)),p.slice(-4).map(_=>n.jsx(KN,{href:_.html_url,meta:l("github.pr.reviewMetaComment",{login:_.user.login}),text:_.body},`comment:${_.id}`))]}):n.jsx("p",{className:"text-[12px] text-muted-foreground",children:l("github.pr.noReviews")})]}),f.body?n.jsx(LT,{body:f.body}):n.jsx("p",{className:"text-[12px] italic text-muted-foreground",children:l("github.noDescription")})]})}function dte({files:e,selected:t,onSelect:s,onAsk:i}){const a=J(),[l,c]=x.useState(null);return n.jsx("div",{className:"w-44 shrink-0 overflow-y-auto border-r border-border bg-card/60",children:n.jsx("ul",{className:"py-1",children:e.map(d=>n.jsxs("li",{className:"group flex flex-col",children:[n.jsxs("div",{className:re("flex items-center transition-colors",d.path===t?"bg-muted":"hover:bg-muted/60"),children:[n.jsxs("button",{className:re("flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px]",d.path===t?"text-foreground":"text-muted-foreground group-hover:text-foreground"),onClick:()=>s(d.path),title:d.path,type:"button",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:If(d.path)}),n.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-emerald-600",children:["+",d.additions]}),n.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-red-500",children:["-",d.deletions]})]}),n.jsx(rr,{className:re("mr-1 shrink-0",l===d.path&&"opacity-100"),label:a("github.pr.askFileLabel",{name:If(d.path)}),onAsk:()=>c(f=>f===d.path?null:d.path)})]}),l===d.path?n.jsx("div",{className:"px-2 pb-1.5 pt-0.5",children:n.jsx(Hr,{placeholder:a("github.pr.askFilePlaceholder"),onSubmit:f=>{c(null),i(d.path,f)},onCancel:()=>c(null)})}):null]},d.path))})})}function If(e){const t=e.split("/");return t[t.length-1]||e}function Bh({title:e,value:t,tone:s}){const i=s==="success"?"bg-emerald-500":s==="warning"?"bg-amber-500":s==="danger"?"bg-red-500":"bg-muted-foreground";return n.jsxs("div",{className:"rounded-md border border-border bg-card px-3 py-2",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:e}),n.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[12px] font-medium",children:[n.jsx("span",{className:`size-1.5 rounded-full ${i}`}),t]})]})}function KN({meta:e,text:t,href:s}){return n.jsxs("a",{className:"block rounded border border-border bg-card px-2.5 py-2 text-[12px] transition-colors hover:bg-muted/60",href:s,rel:"noopener noreferrer",target:"_blank",children:[n.jsxs("span",{className:"mb-1 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx(Pr,{className:"size-3"}),e]}),n.jsx("span",{className:"line-clamp-2 whitespace-pre-wrap",children:t})]})}function OT(e,t){return e.state==="merged"?"github.pr.readiness.merged":e.state==="closed"?"github.pr.readiness.closed":e.draft?"github.pr.readiness.draft":e.mergeable===!1?"github.pr.readiness.blocked":t?.state==="failure"||t?.state==="error"?"github.pr.readiness.checksFailing":t?.state==="pending"?"github.pr.readiness.checksPending":e.mergeable===!0?"github.pr.readiness.ready":"github.pr.unknown"}function hte(e,t){const s=OT(e,t);return s==="github.pr.readiness.ready"?"success":s==="github.pr.readiness.blocked"||s==="github.pr.readiness.checksFailing"?"danger":s==="github.pr.readiness.draft"||s==="github.pr.readiness.checksPending"?"warning":"muted"}function PT(e){return e.some(t=>t.state==="CHANGES_REQUESTED")?"github.pr.review.changesRequested":e.some(t=>t.state==="APPROVED")?"github.pr.review.approved":e.some(t=>t.state==="COMMENTED")?"github.pr.review.commented":"github.pr.review.none"}function fte(e){const t=PT(e);return t==="github.pr.review.approved"?"success":t==="github.pr.review.changesRequested"?"danger":t==="github.pr.review.commented"?"warning":"muted"}function mte({pr:e}){const t=J(),{labelKey:s,dot:i,kind:a}=e.state==="merged"?{labelKey:"github.prState.merged",dot:"bg-violet-500",kind:"merged"}:e.state==="closed"?{labelKey:"github.prState.closed",dot:"bg-red-500",kind:"other"}:e.draft?{labelKey:"github.prState.draft",dot:"bg-muted-foreground",kind:"other"}:{labelKey:"github.prState.open",dot:"bg-emerald-500",kind:"open"};return n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${i}`}),a==="merged"?n.jsx(af,{className:"size-3"}):a==="open"?n.jsx(Vf,{className:"size-3"}):n.jsx(Cl,{className:"size-3"}),t(s)]})}function zT({label:e}){return n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",title:e.name,children:[n.jsx("span",{className:"size-2 shrink-0 rounded-sm",style:{backgroundColor:`#${e.color}`}}),n.jsx("span",{className:"truncate",children:e.name})]})}function pte({issues:e,loading:t,loadingMore:s,hasMore:i,error:a,selectedNumber:l,onSelect:c,onLoadMore:d}){const f=J();return t&&e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.issues.loading")}):a?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:a}):e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.issues.empty")}):n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"divide-y divide-border",children:e.map(h=>n.jsx("li",{children:n.jsxs("button",{className:`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted/60 ${l===h.number?"bg-muted":""}`,onClick:()=>c(h.number),type:"button",children:[n.jsx(OM,{className:`mt-0.5 size-4 shrink-0 ${h.state==="open"?"text-emerald-500":"text-red-500"}`}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:h.title}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",h.number," · ",h.user.login," · ",f("github.issues.commentsCount",{count:h.comments})]})]}),h.labels.length>0?n.jsx("span",{className:"flex max-w-40 shrink-0 flex-wrap justify-end gap-x-2 gap-y-0.5",children:h.labels.slice(0,3).map(g=>n.jsx(zT,{label:g},g.name))}):null]})},h.number))}),n.jsx(h1,{hasMore:i,loading:s,onLoadMore:d})]})}const Ih=6,gte=6,bte=8;function vte(e,t,s,i){const a=Math.max(0,Math.min(gte,e/2,t/2)),l=Math.max(0,Math.min(bte,s-a,i-a));return[`M ${a} 0`,`H ${e-a}`,`A ${a} ${a} 0 0 1 ${e} ${a}`,`V ${t-i-a}`,`A ${a} ${a} 0 0 1 ${e-a} ${t-i}`,`H ${e-s+l}`,`A ${l} ${l} 0 0 0 ${e-s} ${t-i+l}`,`V ${t-a}`,`A ${a} ${a} 0 0 1 ${e-s-a} ${t}`,`H ${a}`,`A ${a} ${a} 0 0 1 0 ${t-a}`,`V ${a}`,`A ${a} ${a} 0 0 1 ${a} 0`,"Z"].join(" ")}function xte({value:e,onChange:t,placeholder:s,rows:i=3,action:a}){const l=J(),c=x.useRef(null),d=x.useRef(null),[f,h]=x.useState(null),[g,p]=x.useState({w:0,h:0});x.useLayoutEffect(()=>{const v=c.current,_=d.current;if(!v||!_)return;const S=()=>{h({w:v.clientWidth,h:v.clientHeight}),p({w:_.offsetWidth+Ih*2,h:_.offsetHeight+Ih*2})};S();const C=new ResizeObserver(S);return C.observe(v),C.observe(_),()=>C.disconnect()},[]);const b=f&&g.w&&g.h?vte(f.w,f.h,g.w,g.h):null;return n.jsxs("div",{className:"relative",ref:c,children:[n.jsx("textarea",{className:"peer block w-full resize-none bg-background px-3 pt-2 font-mono text-[12px] placeholder:text-muted-foreground focus:outline-none",onChange:v=>t(v.target.value),placeholder:s,rows:i,style:{clipPath:b?`path('${b}')`:void 0,paddingBottom:g.h||44},value:e}),f&&b?n.jsxs("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-visible text-border transition-colors peer-focus:text-foreground/40",fill:"none",height:f.h,viewBox:`0 0 ${f.w} ${f.h}`,width:f.w,children:[n.jsx("title",{children:l("github.commentBorderTitle")}),n.jsx("path",{d:b,stroke:"currentColor",strokeWidth:1})]}):null,n.jsx("div",{className:"absolute",ref:d,style:{bottom:Ih,right:Ih},children:a})]})}function yte({issue:e,comments:t,commentsLoading:s,commentError:i,submitting:a,onAddComment:l}){const c=J(),[d,f]=x.useState(""),[h,g]=x.useState(!1),{sendToAgent:p}=Ot(),{isPending:b,runOperation:v}=In(),_=e?`github:issue:${e.number}:comment`:"",S=a||(_?b(_):!1);x.useEffect(()=>{g(!1)},[e?.number]);function C(A){e&&(g(!1),p({prompt:eU(e,A),source:{type:"github-issue",label:`Issue #${e.number}`},label:`Issue #${e.number}: ${A}`}))}if(!e)return n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:c("github.issue.selectPrompt")});async function N(A){A.preventDefault();const j=d.trim();j&&(await v({key:_,label:c("github.issue.postingOperation",{number:e.number})},()=>l(j)),f(""))}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"group flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-semibold",children:e.title}),n.jsx(rr,{className:re("shrink-0",h&&"opacity-100"),label:c("github.issue.askLabel",{number:e.number}),onAsk:()=>g(A=>!A)}),n.jsx("a",{"aria-label":c("github.openOnGithub"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",children:n.jsx(Pr,{className:"size-3.5"})})]}),h?n.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:n.jsx(Hr,{placeholder:c("github.issue.askPlaceholder"),onSubmit:C,onCancel:()=>g(!1)})}):null,n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px]",children:[n.jsxs("span",{className:"text-[11px]",children:[n.jsx("span",{className:"text-muted-foreground",children:c("github.issue.author")}),n.jsx("span",{className:"font-medium",children:e.user.login})]}),n.jsxs("span",{className:"text-[11px]",children:[n.jsx("span",{className:"text-muted-foreground",children:c("github.issue.opened")}),n.jsx("span",{className:"font-medium",children:new Date(e.created_at).toLocaleDateString()})]}),e.labels.map(A=>n.jsx(zT,{label:A},A.name))]}),e.body?n.jsx(LT,{body:e.body}):n.jsx("p",{className:"text-[12px] text-muted-foreground italic",children:c("github.noDescription")}),s?n.jsx(im,{className:"justify-start",label:c("github.issue.loadingComments")}):n.jsx("div",{className:"space-y-2",children:t.map(A=>n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 p-3",children:[n.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[n.jsx("span",{className:"text-[11px] font-semibold",children:A.user.login}),n.jsx("span",{className:"text-[10px] text-muted-foreground",children:new Date(A.created_at).toLocaleDateString()})]}),n.jsx(l1,{content:A.body})]},A.id))})]})}),n.jsx("div",{className:"shrink-0 border-t border-border p-3",children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:A=>{N(A)},children:[n.jsx(xte,{action:n.jsx(Q,{disabled:!d.trim(),loading:S,loadingLabel:c("github.issue.posting"),size:"sm",type:"submit",children:c("github.issue.comment")}),onChange:f,placeholder:c("github.issue.addComment"),value:d}),i?n.jsx(Ze,{variant:"destructive",children:i}):null]})})]})}const YN=30,_te=4e3;function wte(e){return e.status==="in_progress"||e.status==="queued"}function XN(e){return e.map(t=>`${t.id}:${t.status}:${t.conclusion}`).join("|")}function ZN(e){return e.map(t=>`${t.id}:${t.status}:${t.conclusion}:`+t.steps.map(s=>`${s.number}:${s.status}:${s.conclusion}`).join(",")).join("|")}function Ste(e,t){if(e.length===0)return t;const s=new Map(t.map(c=>[c.id,c])),i=new Set(e.map(c=>c.id)),a=t.filter(c=>!i.has(c.id)),l=e.map(c=>s.get(c.id)??c);return[...a,...l]}function kte(e){const[t,s]=x.useState([]),[i,a]=x.useState(null),[l,c]=x.useState([]),[d,f]=x.useState(!0),[h,g]=x.useState(!1),[p,b]=x.useState(!1),[v,_]=x.useState(1),[S,C]=x.useState(!1),[N,A]=x.useState(null),[j,E]=x.useState(null);function T(){let F=!0;return f(!0),A(null),_(1),Hh(e,1).then(M=>{F&&(s(M),b(M.length===YN))}).catch(M=>{F&&A(M instanceof Error?M.message:String(M))}).finally(()=>{F&&f(!1)}),()=>{F=!1}}function L(){if(h||!p)return;const F=v+1;g(!0),Hh(e,F).then(M=>{s(z=>{const G=new Set(z.map(D=>D.id));return[...z,...M.filter(D=>!G.has(D.id))]}),b(M.length===YN),_(F)}).catch(M=>A(M instanceof Error?M.message:String(M))).finally(()=>g(!1))}const H=x.useCallback(()=>{Hh(e,1).then(F=>s(M=>{const z=Ste(M,F);return XN(M)===XN(z)?M:z})).catch(()=>{}),i&&bS(i).then(F=>c(M=>ZN(M)===ZN(F)?M:F)).catch(()=>{})},[e,i]);x.useEffect(T,[e]),x.useEffect(()=>{a(F=>F&&t.some(M=>M.id===F)?F:t[0]?.id??null)},[t]),x.useEffect(()=>{if(!i){c([]);return}let F=!0;return C(!0),E(null),bS(i).then(M=>{F&&c(M)}).catch(M=>{F&&E(M instanceof Error?M.message:String(M))}).finally(()=>{F&&C(!1)}),()=>{F=!1}},[i]);const P=t.some(wte);return x.useEffect(()=>{if(!P)return;const F=window.setInterval(()=>{document.visibilityState==="visible"&&H()},_te);return()=>window.clearInterval(F)},[P,H]),{runs:t,selectedRunId:i,jobs:l,loading:d,loadingMore:h,hasMore:p,jobsLoading:S,error:N,jobsError:j,loadMore:L,refresh:T,syncLatest:H,setSelectedRunId:a}}function BT(e){return e.conclusion==="failure"||e.conclusion==="timed_out"||e.conclusion==="cancelled"}function Cte({branch:e,onClearBranch:t}){const{runs:s,selectedRunId:i,jobs:a,loading:l,loadingMore:c,hasMore:d,jobsLoading:f,error:h,jobsError:g,loadMore:p,refresh:b,syncLatest:v,setSelectedRunId:_}=kte(e),S=J();Eo(v);const C=s.find(T=>T.id===i)??null,{sendToAgent:N}=Ot(),[A,j]=x.useState(null);function E(T,L){j(null),N({prompt:tU(T,L),source:{type:"github-run",label:S("github.actions.runLabel",{number:T.run_number})},label:S("github.actions.runInputLabel",{number:T.run_number,input:L??S("github.actions.fixDefault")})})}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[13px] font-semibold",children:S("github.actions.title")}),e?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"shrink-0",children:S("github.actions.filteredTo")}),n.jsx("span",{className:"min-w-0 truncate font-mono",children:e}),t?n.jsx("button",{"aria-label":S("github.actions.clearFilter"),className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:t,title:S("github.actions.clearFilter"),type:"button",children:n.jsx(Vt,{className:"size-3"})}):null]}):null]}),n.jsxs(Q,{disabled:l,onClick:()=>{b()},size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{className:`mr-1 size-3.5 ${l?"animate-spin":""}`}),S("common.refresh")]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:h?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:h}):l&&s.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:S("github.actions.loadingRuns")}):s.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:S("github.actions.noRuns")}):n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(280px,380px)_minmax(0,1fr)] divide-x divide-border",children:[n.jsxs("div",{className:"min-h-0 overflow-auto",children:[n.jsx("ul",{className:"divide-y divide-border",children:s.map(T=>n.jsxs("li",{className:"group flex flex-col",children:[n.jsxs("div",{className:`flex items-center transition-colors hover:bg-muted/60 ${T.id===i?"bg-muted/70":""}`,children:[n.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-3 px-3 py-2.5 text-left",onClick:()=>_(T.id),type:"button",children:[n.jsx(Nte,{run:T}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:T.name}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",T.run_number," · ",T.head_branch," · ",T.event," ·"," ",n.jsx("span",{title:new Date(T.created_at).toLocaleString(),children:pj(T.created_at)})]})]}),n.jsx(Ete,{run:T})]}),BT(T)?n.jsx(rr,{className:`mr-2 shrink-0 ${A===T.id?"opacity-100":""}`,label:S("github.actions.fixRunAi",{number:T.run_number}),onAsk:()=>j(L=>L===T.id?null:T.id)}):null]}),A===T.id?n.jsx("div",{className:"px-3 pb-2 pt-0.5",children:n.jsx(Hr,{onCancel:()=>j(null),onSubmit:L=>E(T,L),placeholder:S("github.actions.askPlaceholder")})}):null]},T.id))}),n.jsx(h1,{hasMore:d,loading:c,onLoadMore:p})]}),n.jsx(jte,{error:g,jobs:a,loading:f,onFix:T=>E(T),run:C})]})})]})}function Nte({run:e}){return e.status==="in_progress"||e.status==="queued"?n.jsx(Cl,{className:"size-4 shrink-0 animate-pulse text-amber-400"}):e.conclusion==="success"?n.jsx(Vf,{className:"size-4 shrink-0 text-emerald-500"}):e.conclusion==="failure"||e.conclusion==="timed_out"?n.jsx($x,{className:"size-4 shrink-0 text-red-500"}):n.jsx(Cl,{className:"size-4 shrink-0 text-zinc-400"})}function Ete({run:e}){const t=e.status==="completed"?e.conclusion??"completed":e.status,s=t==="success"?"bg-emerald-500":t==="failure"||t==="timed_out"?"bg-red-500":t==="in_progress"||t==="queued"?"bg-amber-500":"bg-muted-foreground";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),t]})}function jte({run:e,jobs:t,loading:s,error:i,onFix:a}){const l=J();return e?n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-semibold",children:e.name}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["Run #",e.run_number," · ",e.head_branch," · ",e.head_sha.slice(0,7)]})]}),BT(e)?n.jsxs(Q,{className:"shrink-0 gap-1",onClick:()=>a(e),size:"sm",title:l("github.actions.fixTitle"),type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"}),l("github.actions.fixWithAi")]}):null,n.jsx("a",{"aria-label":l("github.actions.openRun"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.actions.openRun"),children:n.jsx(Pr,{className:"size-3.5"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:i?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:i}):s?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.actions.loadingJobs")}):t.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.actions.noJobs")}):n.jsx("ul",{className:"divide-y divide-border",children:t.map(c=>n.jsxs("li",{className:"px-3 py-3",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[n.jsx(QN,{item:c}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium",children:c.name}),n.jsx("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:JN(c.started_at,c.completed_at)}),n.jsx("a",{"aria-label":l("github.actions.openJobAria",{name:c.name}),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:c.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.actions.openJob"),children:n.jsx(Pr,{className:"size-3.5"})})]}),c.steps.length?n.jsx("ol",{className:"space-y-1.5 pl-6",children:c.steps.map(d=>n.jsxs("li",{className:"flex items-center gap-2 text-[12px]",children:[n.jsx(QN,{item:d}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.name}),n.jsx("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:JN(d.started_at,d.completed_at)})]},`${c.id}:${d.number}`))}):n.jsx("p",{className:"pl-6 text-[12px] text-muted-foreground",children:l("github.actions.noSteps")})]},c.id))})})]}):n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:l("github.actions.selectRun")})}function QN({item:e}){return e.status==="in_progress"||e.status==="queued"?n.jsx(Cl,{className:"size-3.5 shrink-0 animate-pulse text-amber-400"}):e.conclusion==="success"||e.conclusion==="skipped"?n.jsx(Vf,{className:"size-3.5 shrink-0 text-emerald-500"}):e.conclusion==="failure"||e.conclusion==="timed_out"||e.conclusion==="cancelled"?n.jsx($x,{className:"size-3.5 shrink-0 text-red-500"}):n.jsx(Cl,{className:"size-3.5 shrink-0 text-zinc-400"})}function JN(e,t){if(!e)return"-";const s=Date.parse(e),i=t?Date.parse(t):Date.now();if(!Number.isFinite(s)||!Number.isFinite(i)||i<s)return"-";const a=Math.max(0,Math.round((i-s)/1e3));if(a<60)return`${a}s`;const l=Math.floor(a/60),c=a%60;return c?`${l}m ${c}s`:`${l}m`}function Ate({onCreatePR:e,onViewRuns:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(!0),[d,f]=x.useState(null);function h(){let p=!0;return c(!0),f(null),B7().then(b=>{p&&a(b)}).catch(b=>{p&&f(b instanceof Error?b.message:String(b))}).finally(()=>{p&&c(!1)}),()=>{p=!1}}x.useEffect(h,[]),Eo(()=>{h()});const g=x.useMemo(()=>[...i?.branches??[]].sort((b,v)=>{const _=tE(b,i),S=tE(v,i);return _-S||b.name.localeCompare(v.name)}),[i]);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[13px] font-semibold",children:s("github.tab.branches")}),n.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:i?.repository.full_name??s("github.selectedRepo")})]}),n.jsxs(Q,{disabled:l,onClick:()=>{h()},size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{className:`mr-1 size-3.5 ${l?"animate-spin":""}`}),s("common.refresh")]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:d}):l&&!i?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:s("github.branches.loading")}):g.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:s("github.branches.empty")}):n.jsx("ul",{className:"divide-y divide-border",children:g.map(p=>n.jsx(Tte,{branch:p,currentBranch:i?.currentBranch??null,defaultBranch:i?.defaultBranch??null,onCreatePR:e,onViewRuns:t},p.name))})})]})}function Tte({branch:e,defaultBranch:t,currentBranch:s,onCreatePR:i,onViewRuns:a}){const l=J(),c=e.name===t,d=e.name===s,f=!c;return n.jsxs("li",{className:"flex flex-wrap items-center gap-3 px-3 py-2.5",children:[n.jsx(_n,{className:"size-4 shrink-0 text-muted-foreground"}),n.jsxs("div",{className:"min-w-48 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[13px] font-medium",children:e.name}),c?n.jsx(eE,{label:l("github.branches.default"),tone:"success"}):null,d?n.jsx(eE,{label:l("github.branches.current"),tone:"warning"}):null,e.protected?n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx(CE,{className:"size-3"}),l("github.branches.protected")]}):null]}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:e.commit.sha.slice(0,7)})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>a(e.name),size:"sm",title:l("github.branches.viewRunsTitle",{name:e.name}),type:"button",variant:"outline",children:[n.jsx(zM,{className:"size-3.5"}),l("github.branches.viewRuns")]}),n.jsxs(Q,{disabled:!f,onClick:()=>i(e.name),size:"sm",title:f?l("github.branches.openPrTitle",{name:e.name}):l("github.branches.defaultNoPr"),type:"button",variant:"outline",children:[n.jsx(vE,{className:"size-3.5"}),l("github.branches.openPr")]})]})]})}function eE({label:e,tone:t}){const s=t==="success"?"bg-emerald-500":"bg-amber-500";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),e]})}function tE(e,t){return e.name===t?.currentBranch?0:e.name===t?.defaultBranch?1:e.protected?2:3}function Rte(){const e=J(),t=ste();let s;return t.loading||t.status==="checking"?s=n.jsx(im,{fill:!0,label:e("common.loading")}):t.status==="not_configured"?s=n.jsx(DT,{deviceFlowAvailable:t.deviceFlowAvailable,onSaved:t.refresh}):t.status==="auth_error"||t.status==="connection_error"?s=n.jsx(Mte,{token:t}):s=n.jsx(Dte,{token:t}),n.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-card/85",children:s})}function Mte({token:e}){const t=J(),[s,i]=x.useState(null);if(s)return n.jsx(DT,{deviceFlowAvailable:e.deviceFlowAvailable,initialMode:s,onSaved:e.refresh});const a=e.status==="auth_error";return n.jsx("div",{className:"flex h-full items-center justify-center p-8",children:n.jsxs("div",{className:"w-full max-w-lg space-y-4 rounded-md border border-border bg-card p-5",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(bm,{className:"size-5"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("h2",{className:"text-sm font-semibold",children:t("github.connFailed")}),n.jsx("p",{className:"text-[12px] text-muted-foreground",children:t(a?"github.tokenRejected":"github.cantValidate")})]}),n.jsx(IT,{label:t(a?"github.needsRelogin":"github.connProblem"),tone:a?"danger":"warning"})]}),e.error?n.jsx(Ze,{variant:"destructive",children:e.error}):null,n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(Q,{onClick:e.refresh,type:"button",variant:a?"outline":"default",children:[n.jsx(_i,{}),t("common.refresh")]}),n.jsx(Q,{onClick:()=>i(e.deviceFlowAvailable?"device-pending":"pat"),type:"button",variant:a?"default":"outline",children:t("github.reconnectGithub")}),n.jsx(Q,{onClick:()=>i("pat"),type:"button",variant:"outline",children:t("github.useToken")})]})]})})}function Dte({token:e}){const t=J(),[s,i]=wl("github:tab","prs"),[a,l]=wl("github:pr-state","open"),[c,d]=wl("github:issue-state","open"),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState(null),{isPending:_,runOperation:S}=In(),C=_("github:disconnect"),N=nte(a),A=ite(c);Eo(()=>{s==="prs"?N.refresh():s==="issues"&&A.refresh()});const j=L=>`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${L?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,E=L=>`rounded px-2 py-0.5 text-[10px] font-medium transition-colors ${L?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`;async function T(){v(null);try{await S({errorMessage:L=>L instanceof Error?L.message:String(L),key:"github:disconnect",label:t("github.disconnecting")},async()=>{await z7("github.com"),e.refresh()})}catch(L){v(L instanceof Error?L.message:String(L))}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card/95 px-3 py-1",children:[n.jsx("button",{className:j(s==="prs"),onClick:()=>i("prs"),type:"button",children:t("github.tab.prs")}),n.jsx("button",{className:j(s==="issues"),onClick:()=>i("issues"),type:"button",children:t("github.tab.issues")}),n.jsx("button",{className:j(s==="branches"),onClick:()=>i("branches"),type:"button",children:t("github.tab.branches")}),n.jsx("button",{className:j(s==="actions"),onClick:()=>i("actions"),type:"button",children:t("github.tab.actions")}),n.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[n.jsx(Lte,{token:e}),n.jsxs(Q,{onClick:e.refresh,size:"sm",title:t("github.recheckTitle"),type:"button",variant:"outline",children:[n.jsx(_i,{}),t("github.reconnect")]}),n.jsx(Q,{loading:C,loadingLabel:t("github.disconnecting"),onClick:()=>{T()},size:"sm",type:"button",variant:"outline",children:t("github.disconnect")})]}),s==="prs"?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:[n.jsx("button",{className:E(a==="open"),onClick:()=>l("open"),type:"button",children:t("github.open")}),n.jsx("button",{className:E(a==="closed"),onClick:()=>l("closed"),type:"button",children:t("github.closed")})]}),n.jsx(Q,{onClick:()=>h(""),size:"sm",type:"button",variant:"outline",children:t("github.newPr")})]}):s==="issues"?n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:[n.jsx("button",{className:E(c==="open"),onClick:()=>d("open"),type:"button",children:t("github.open")}),n.jsx("button",{className:E(c==="closed"),onClick:()=>d("closed"),type:"button",children:t("github.closed")})]}):null]}),b?n.jsx(Ze,{variant:"destructive",className:"m-3",children:b}):null,f!==null?n.jsx(Ote,{initialHead:f,onCreated:L=>{h(null),i("prs"),N.setSelectedNumber(L.number),N.refresh()},onCancel:()=>h(null)}):n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s==="prs"?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(0,1fr)_minmax(0,2fr)] divide-x divide-border",children:[n.jsx("div",{className:"min-h-0 overflow-auto",children:n.jsx(ote,{error:N.error,hasMore:N.hasMore,loading:N.loading,loadingMore:N.loadingMore,onLoadMore:N.loadMore,onSelect:N.setSelectedNumber,prs:N.prs,selectedNumber:N.selectedNumber})}),n.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:n.jsx(cte,{diff:N.diff,diffError:N.diffError,diffLoading:N.diffLoading,onMerged:()=>N.refresh(),pr:N.selectedPR})})]}):s==="issues"?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(0,1fr)_minmax(0,2fr)] divide-x divide-border",children:[n.jsx("div",{className:"min-h-0 overflow-auto",children:n.jsx(pte,{error:A.error,hasMore:A.hasMore,issues:A.issues,loading:A.loading,loadingMore:A.loadingMore,onLoadMore:A.loadMore,onSelect:A.setSelectedNumber,selectedNumber:A.selectedNumber})}),n.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:n.jsx(yte,{commentError:A.commentError,comments:A.comments,commentsLoading:A.commentsLoading,issue:A.selectedIssue,onAddComment:A.addComment,submitting:A.submitting})})]}):s==="branches"?n.jsx(Ate,{onCreatePR:L=>h(L),onViewRuns:L=>{p(L),i("actions")}}):n.jsx(Cte,{branch:g??void 0,onClearBranch:()=>p(null)})})]})}function Lte({token:e}){const t=J(),s=e.info?.repository?.full_name??(e.info?.user?`@${e.info.user.login}`:"GitHub");return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-r border-border pr-2",children:[n.jsx(bm,{className:"size-4 shrink-0 text-foreground"}),n.jsx(IT,{label:t("github.connected"),tone:"success"}),n.jsx("span",{className:"max-w-48 truncate font-mono text-[10px] text-muted-foreground",children:s})]})}function IT({label:e,tone:t}){const s=t==="success"?"bg-emerald-500":t==="danger"?"bg-red-500":"bg-amber-500";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),e]})}function Ote({initialHead:e,onCreated:t,onCancel:s}){const i=J(),[a,l]=x.useState(""),[c,d]=x.useState(""),[f,h]=x.useState(""),[g,p]=x.useState("main"),[b,v]=x.useState(!1),[_,S]=x.useState(null),[C,N]=x.useState(!0),[A,j]=x.useState(!1),[E,T]=x.useState(null);x.useEffect(()=>{let F=!0;return N(!0),T(null),F7().then(M=>{F&&(S(M),l(M.title),d(M.body),h(e||M.head),p(M.base||M.suggestedBase||"main"),v(M.draft))}).catch(M=>{F&&T(M instanceof Error?M.message:String(M))}).finally(()=>{F&&N(!1)}),()=>{F=!1}},[e]);async function L(F){if(F.preventDefault(),!(!a.trim()||!f.trim()||!g.trim())){j(!0),T(null);try{const M=await U7({title:a.trim(),body:c.trim()||void 0,head:f.trim(),base:g.trim(),draft:b});t(M)}catch(M){T(M instanceof Error?M.message:String(M))}finally{j(!1)}}}const H="w-full rounded-md border border-border bg-background px-3 py-2 text-[13px] placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring",P=_?.warnings??[];return n.jsxs("form",{className:"flex min-h-0 flex-col gap-3 overflow-auto bg-muted/20 p-4",onSubmit:F=>{L(F)},children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{className:"text-[13px] font-semibold",children:i("github.branchToPr")}),n.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[_?.repository?.full_name??i("github.selectedRepo"),_?.currentBranch?` - ${_.currentBranch}`:""]})]}),n.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:i(C?"github.detectingBranch":"github.editableDraft")})]}),n.jsx(Pte,{template:_,loading:C}),P.length>0?n.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[12px] text-amber-700 dark:text-amber-300",children:P[0]}):null,n.jsx("input",{className:H,disabled:C,onChange:F=>l(F.target.value),placeholder:i("github.fieldTitle"),required:!0,value:a}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("label",{className:"space-y-1",children:[n.jsx("span",{className:"text-[10px] uppercase text-muted-foreground",children:i("github.head")}),n.jsx("input",{className:H,disabled:C,onChange:F=>h(F.target.value),placeholder:i("github.headBranch"),required:!0,value:f})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("span",{className:"text-[10px] uppercase text-muted-foreground",children:i("github.base")}),n.jsx("input",{className:H,disabled:C,onChange:F=>p(F.target.value),placeholder:i("github.baseBranch"),required:!0,value:g})]})]}),n.jsx("textarea",{className:`${H} resize-none`,disabled:C,onChange:F=>d(F.target.value),placeholder:i("github.descriptionOptional"),rows:7,value:c}),n.jsxs("label",{className:"flex items-center gap-2 text-[12px]",children:[n.jsx("input",{checked:b,className:"size-3.5",disabled:C,onChange:F=>v(F.target.checked),type:"checkbox"}),i("github.createAsDraft")]}),E?n.jsx(Ze,{variant:"destructive",children:E}):null,n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Q,{disabled:C||A||!a.trim()||!f.trim()||!g.trim(),type:"submit",children:i(A?"github.creating":"github.createPr")}),n.jsx(Q,{onClick:s,type:"button",variant:"outline",children:i("common.cancel")})]})]})}function Pte({template:e,loading:t}){const s=J(),i=e?.compare,a=i?.ciStatus,l=[{label:s("github.compare.base"),value:i?.base||e?.base||"main"},{label:s("github.compare.head"),value:i?.head||e?.head||"manual"},{label:s("github.compare.ahead"),value:t?"...":String(i?.aheadBy??0)},{label:s("github.compare.changed"),value:t?"...":String(i?.files.length??0)},{label:s("github.compare.ci"),value:a?`${a.state} (${a.totalCount})`:s("github.compare.unavailable")}];return n.jsxs("div",{className:"rounded-md border border-border bg-card px-3 py-2",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-[11px] font-medium text-foreground",children:s("github.compareSummary")}),i?.headSha?n.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:i.headSha.slice(0,7)}):null]}),n.jsx("div",{className:"grid grid-cols-5 gap-2",children:l.map(c=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate text-[10px] uppercase text-muted-foreground",children:c.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:c.value})]},c.label))}),i?.files.length?n.jsx("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:i.files.slice(0,4).map(c=>n.jsxs("span",{className:"max-w-52 truncate",children:[c.status," ",c.path]},`${c.status}:${c.path}`))}):null]})}function zte({data:e,docked:t,scopeAll:s,onScopeChange:i,onRefresh:a,onClose:l,onManage:c}){const d=J(),{error:f,success:h}=cs(),g=e.git.selectedRepository;async function p(S){l();try{await GE(S),i(!1),await a(),h(d("git.repo.switchedToast",{name:S}))}catch(C){f(C instanceof Error?C.message:String(C))}}function b(){l(),i(!0),h(d("app.showingAllProjects"))}const v=S=>re("grid h-8 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left transition-[background-color,width] duration-150 hover:bg-muted",t?"w-full":"w-12 group-hover/sidebar:w-full",S&&"bg-muted/60"),_=re("flex min-w-0 items-center gap-2 overflow-hidden whitespace-pre pr-2 text-xs transition duration-150",t?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100");return n.jsxs("div",{className:"mt-1 grid gap-0.5",children:[n.jsxs("button",{className:v(s),onClick:b,title:d("app.allProjects"),type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(rf,{className:"size-4 text-muted-foreground"})}),n.jsxs("span",{className:_,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:d("app.allProjects")}),s?n.jsx(Ys,{className:"size-3.5 shrink-0"}):null]})]}),e.config.gitRepositories.map(S=>{const C=!s&&S.name===g?.name;return n.jsxs("button",{className:v(C),onClick:()=>{p(S.name)},title:S.path,type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(Uf,{className:"size-4 text-muted-foreground"})}),n.jsxs("span",{className:_,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:S.name}),C?n.jsx(Ys,{className:"size-3.5 shrink-0"}):null]})]},S.name)}),n.jsxs("button",{className:re("grid h-8 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left text-muted-foreground transition-[background-color,color,width] duration-150 hover:bg-muted hover:text-foreground",t?"w-full":"w-12 group-hover/sidebar:w-full"),onClick:()=>{l(),c()},title:d("app.addManageProjects"),type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(Vx,{className:"size-4"})}),n.jsx("span",{className:_,children:n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[d("app.addManageProjects"),"…"]})})]})]})}function Bte({data:e,docked:t,scopeAll:s,onScopeChange:i,onRefresh:a}){const l=J(),[c,d]=x.useState(!1),[f,h]=x.useState(!1),g=e.git.selectedRepository,p=s?l("app.allProjects"):g?.name??l("app.pickProject"),b=e.config.gitRepositories.length,v=s?l(b===1?"app.projectCountOne":"app.projectCountMany",{count:b}):g?e.git.status?.branch??g.path:l("app.setContext");return n.jsxs(n.Fragment,{children:[n.jsxs("button",{"aria-label":l("app.projectScope",{label:p}),className:re("relative grid h-11 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left transition-[background-color,width] duration-150 hover:bg-muted",t?"w-full":"w-12 group-hover/sidebar:w-full"),"aria-expanded":c,onClick:()=>d(_=>!_),title:l("app.projectScope",{label:p}),type:"button",children:[n.jsx("span",{className:"flex h-11 w-12 items-center justify-center",children:n.jsx("span",{className:"flex size-8 items-center justify-center rounded-lg border border-border bg-background text-[13px] font-semibold text-foreground",children:s?n.jsx(rf,{className:"size-4 text-muted-foreground"}):g?p.charAt(0).toUpperCase():n.jsx(Uf,{className:"size-4 text-muted-foreground"})})}),n.jsxs("span",{className:re("min-w-0 overflow-hidden whitespace-pre pr-8 transition duration-150",t?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100"),children:[n.jsx("span",{className:"block truncate text-[13px] font-semibold leading-tight",children:p}),n.jsx("span",{className:"block truncate text-[10px] leading-tight text-muted-foreground",children:v})]}),n.jsx(hn,{className:re("absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground transition-[opacity,transform] duration-150",t?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100",c&&"rotate-180")})]}),c?n.jsx(zte,{data:e,docked:t,onClose:()=>d(!1),onManage:()=>h(!0),onRefresh:a,onScopeChange:i,scopeAll:s}):null,f?n.jsx(Ite,{data:e,onClose:()=>h(!1),onRefresh:a,onScopeChange:i,scopeAll:s}):null]})}function Ite({data:e,onClose:t,onRefresh:s,onScopeChange:i,scopeAll:a}){const l=J(),[c,d]=x.useState("path"),[f,h]=x.useState(e.git.cwd),[g,p]=x.useState(""),[b,v]=x.useState(!1),[_,S]=x.useState(null),[C,N]=x.useState(!1),[A,j]=x.useState(e.git.cwd),E=e.git.selectedRepository,{error:T,success:L}=cs();async function H(D){try{await GE(D),i(!1),t(),await s(),L(l("git.repo.switchedToast",{name:D}))}catch(q){T(q instanceof Error?q.message:String(q))}}function P(){i(!0),t(),L(l("app.showingAllProjects"))}async function F(D){const q=D.trim();if(!q.startsWith("/")){const W=l("git.repo.absPathError");return S(W),T(W),!1}try{const W=kT(q);return await j7(W,q),S(null),await s(),L(l("git.repo.addedToast",{name:W})),!0}catch(W){const I=W instanceof Error?W.message:String(W);return S(I),T(I),!1}}async function M(D){try{await E7(D),await s(),L(l("git.repo.removedToast",{name:D}))}catch(q){T(q instanceof Error?q.message:String(q))}}async function z(D){D.preventDefault(),await F(f)&&t()}async function G(D){D.preventDefault();const q=g.trim();if(q){v(!0),S(null);try{const{name:W}=await A7(q);p(""),await s(),L(l("git.repo.clonedToast",{name:W})),t()}catch(W){const I=W instanceof Error?W.message:String(W);S(I),T(I)}finally{v(!1)}}}return Hi.createPortal(n.jsxs("div",{className:"fixed inset-0 z-[1000] grid place-items-center bg-black/35 px-4",onMouseDown:D=>{D.target===D.currentTarget&&t()},children:[n.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-xl",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-3",children:[n.jsx(rf,{className:"size-4 text-muted-foreground"}),n.jsx("div",{className:"text-sm font-semibold",children:l("git.repo.projectsShort")}),n.jsx(We,{className:"h-5 px-1.5 text-[10px]",variant:"outline",children:e.config.gitRepositories.length}),n.jsx(Q,{"aria-label":l("git.repo.closeSwitcher"),className:"ml-auto size-7",onClick:t,size:"icon",variant:"ghost",children:n.jsx(Vt,{className:"size-4"})})]}),n.jsxs("div",{className:"max-h-80 overflow-auto",children:[n.jsxs("button",{className:re("grid w-full grid-cols-[1fr_auto] items-center gap-2 border-b border-border px-4 py-2.5 text-left transition-colors hover:bg-muted",a&&"bg-muted/70"),onClick:P,type:"button",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(rf,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-medium leading-tight",children:l("app.allProjects")}),n.jsx("span",{className:"block truncate text-[10px] leading-tight text-muted-foreground",children:l("app.allProjectsHint")})]})]}),a?n.jsx(Ys,{className:"size-3.5"}):n.jsx("span",{className:"size-3.5"})]}),e.config.gitRepositories.length?n.jsx("div",{className:"divide-y divide-border",children:e.config.gitRepositories.map(D=>{const q=!a&&D.name===E?.name;return n.jsxs("div",{className:re("group grid w-full grid-cols-[1fr_auto_auto] items-center gap-2 px-4 py-2 text-left transition-colors hover:bg-muted",q&&"bg-muted/70"),children:[n.jsxs("button",{className:"min-w-0 text-left",onClick:()=>{H(D.name)},type:"button",children:[n.jsx("span",{className:"block truncate text-sm font-medium leading-tight",children:D.name}),n.jsx("span",{className:"block truncate font-mono text-[10px] leading-tight text-muted-foreground",children:D.path})]}),q?n.jsx(Ys,{className:"size-3.5"}):n.jsx("span",{className:"size-3.5"}),n.jsx(Q,{"aria-label":l("git.repo.removeName",{name:D.name}),className:"size-6 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>{M(D.name)},size:"icon",title:l("git.repo.removeName",{name:D.name}),type:"button",variant:"ghost",children:n.jsx(Ii,{className:"size-3.5 text-destructive"})})]},D.name)})}):n.jsx("div",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:l("git.repo.noProjects")})]}),n.jsxs("div",{className:"border-t border-border bg-muted/20 p-3",children:[n.jsxs("div",{className:"mb-1.5 flex gap-1 text-[11px]",children:[n.jsxs("button",{className:re("flex items-center gap-1 rounded px-2 py-0.5 transition-colors",c==="path"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{d("path"),S(null)},type:"button",children:[n.jsx(Co,{className:"size-3"}),l("git.repo.localPath")]}),n.jsxs("button",{className:re("flex items-center gap-1 rounded px-2 py-0.5 transition-colors",c==="url"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{d("url"),S(null)},type:"button",children:[n.jsx(vu,{className:"size-3"}),l("git.repo.cloneUrl")]})]}),c==="path"?n.jsxs("form",{className:"flex gap-1.5",onSubmit:z,children:[n.jsx(pt,{"aria-label":l("git.repo.pasteAbsPath"),className:"h-7 flex-1 px-2 font-mono text-[11px]",onChange:D=>{h(D.target.value),S(null)},placeholder:"/absolute/path",value:f}),n.jsxs(Q,{className:"h-7 px-2 text-[11px]",size:"sm",type:"submit",children:[n.jsx(ms,{className:"size-3"}),l("common.add")]}),n.jsx(Q,{"aria-label":l("git.repo.browseAdd"),className:"h-7 px-2",onClick:()=>{S(null),j(e.git.cwd),N(!0)},size:"sm",type:"button",variant:"outline",children:n.jsx(Vx,{className:"size-3"})})]}):n.jsxs("form",{className:"flex gap-1.5",onSubmit:G,children:[n.jsx(pt,{"aria-label":l("git.repo.remoteUrl"),className:"h-7 flex-1 px-2 font-mono text-[11px]",onChange:D=>{p(D.target.value),S(null)},placeholder:"https://… or git@host:owner/repo.git",value:g}),n.jsxs(Q,{className:"h-7 px-2 text-[11px]",disabled:b||!g.trim(),size:"sm",type:"submit",children:[n.jsx(vu,{className:"size-3"}),l(b?"git.repo.cloning":"git.repo.clone")]})]}),_?n.jsx("div",{className:"mt-1.5 truncate text-[10px] text-destructive",children:_}):null,c==="url"?n.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:l("git.repo.cloneHint")}):null]})]}),C?n.jsx(CT,{confirmLabel:l("git.repo.addProject"),errorMessage:_,initialPath:e.git.cwd,selectedPath:A,title:l("git.repo.addProjectTitle"),onCancel:()=>N(!1),onSelect:j,onUse:async()=>{await F(A)&&(N(!1),t())}}):null]}),document.body)}function Hte({ahead:e=0,behind:t=0,branches:s,currentBranch:i,disabled:a,onRefresh:l,upstream:c}){const d=J(),[f,h]=x.useState(!1),[g,p]=x.useState(""),[b,v]=x.useState(null),[_,S]=x.useState(null),[C,N]=x.useState(null),A=s.filter(M=>!M.remote),j=s.filter(M=>M.remote);async function E(M,z){v(M),N(null),S(null);try{await z(),await l()}catch(G){N(G instanceof Error?G.message:String(G))}finally{v(null)}}async function T(M){await E(`switch:${M}`,async()=>{await zi("/api/git/branches/switch",{name:M}),h(!1)})}async function L(){await E("fetch",async()=>{await zi("/api/git/fetch",{}),S(d("git.branch.fetched"))})}async function H(){await E("push",async()=>{const M=await tm();S(M.setUpstream?d("git.branch.pushedSetUpstream",{branch:M.branch}):d("git.branch.pushed",{branch:M.branch}))})}const P=!!i&&(e>0||!c&&t===0);async function F(M){M.preventDefault();const z=g.trim();if(!z){N(d("git.branch.nameRequired"));return}await E("create",async()=>{await zi("/api/git/branches",{name:z}),p(""),h(!1)})}return n.jsxs("div",{className:"fixed bottom-12 right-4 z-50 flex items-end",children:[f?n.jsxs("div",{"aria-label":d("git.branch.switchAria"),className:"mb-11 w-[min(460px,calc(100vw-2rem))] rounded-lg border border-border bg-card shadow-xl",role:"dialog",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border p-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_n,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:i||d("git.branch.branches")})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[P?n.jsxs(Q,{"aria-label":d("git.branch.pushAria"),className:"gap-1.5 px-2 text-xs",disabled:a||b!==null,onClick:()=>{H()},size:"sm",title:c?d("git.branch.pushCountTo",{ahead:e,upstream:c}):d("git.branch.pushSetUpstream"),type:"button",variant:"default",children:[n.jsx(Qf,{className:re("size-3.5",b==="push"&&"animate-pulse")}),d("git.branch.push"),e>0?` ${e}`:""]}):null,n.jsx(Q,{"aria-label":d("git.branch.fetchAria"),disabled:a||b!==null,onClick:()=>{L()},size:"icon",title:d("git.branch.fetchAria"),type:"button",variant:"ghost",children:n.jsx(_i,{className:re(b==="fetch"&&"animate-spin")})}),n.jsx(Q,{"aria-label":d("git.branch.closeAria"),onClick:()=>h(!1),size:"icon",type:"button",variant:"ghost",children:n.jsx(Vt,{})})]})]}),n.jsx("div",{className:"max-h-72 overflow-auto",children:s.length?n.jsxs(n.Fragment,{children:[n.jsx(sE,{branches:A,busy:b!==null,disabled:a,empty:d("git.branch.noLocal"),label:d("git.branch.sectionLocal"),onSwitch:T}),n.jsx(sE,{branches:j,busy:b!==null,disabled:a,empty:d("git.branch.noRemote"),label:d("git.branch.sectionRemote"),onSwitch:T})]}):n.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:d("git.branch.noneFound")})}),n.jsxs("div",{className:"border-t border-border p-3",children:[n.jsxs("form",{className:"grid gap-2 sm:grid-cols-[1fr_auto]",onSubmit:F,children:[n.jsx(pt,{"aria-label":d("git.branch.newNameAria"),disabled:a||b!==null,onChange:M=>{p(M.target.value),N(null),S(null)},placeholder:"feature/new-work",value:g}),n.jsxs(Q,{disabled:a||b!==null,type:"submit",children:[n.jsx(D6,{}),d("git.branch.create")]})]}),C||_?n.jsx(Ze,{className:"mt-3 px-3 py-2 text-xs",variant:C?"destructive":"muted",children:C??_}):null]})]}):null,n.jsxs(Q,{className:"h-8 max-w-[260px] gap-2 rounded-md shadow-lg",disabled:a,onClick:()=>h(M=>!M),size:"sm",title:d("git.branch.switchAria"),type:"button",variant:"default",children:[n.jsx(_n,{className:"size-4"}),n.jsx("span",{className:"truncate font-mono text-xs",children:i||d("git.branch.noBranch")}),i&&(e>0||t>0)?n.jsxs("span",{className:"flex items-center gap-1 font-mono text-[11px] tabular-nums",title:c?d("git.branch.aheadBehindUpstream",{ahead:e,behind:t,upstream:c}):d("git.branch.aheadBehind",{ahead:e,behind:t}),children:[t>0?n.jsxs("span",{className:"flex items-center",children:[n.jsx(Hf,{className:"size-3"}),t]}):null,e>0?n.jsxs("span",{className:"flex items-center",children:[n.jsx($f,{className:"size-3"}),e]}):null]}):null,n.jsx(hn,{className:re("size-4 transition-transform",f&&"rotate-180")})]})]})}function sE({branches:e,busy:t,disabled:s,empty:i,label:a,onSwitch:l}){const c=J();return n.jsxs("section",{children:[n.jsx("div",{className:"border-b border-border bg-muted/60 px-3 py-1.5 text-[11px] font-semibold uppercase text-muted-foreground",children:a}),e.length?e.map(d=>n.jsxs("button",{className:re("grid w-full grid-cols-[1fr_auto] items-center gap-2 border-b border-border px-3 py-2 text-left text-sm last:border-b-0 hover:bg-muted",d.current&&"bg-muted/70"),disabled:s||t||d.current,onClick:()=>{l(d.name)},type:"button",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate font-medium",children:d.name}),d.upstream?n.jsx("span",{className:"block truncate font-mono text-[11px] text-muted-foreground",children:c("git.branch.tracks",{upstream:d.upstream})}):null]}),n.jsx(We,{variant:d.current?"success":d.remote?"outline":"secondary",children:d.current?c("git.branch.tagCurrent"):d.remote?c("git.branch.tagRemote"):c("git.branch.tagLocal")})]},`${d.remote?"remote":"local"}:${d.name}`)):n.jsx("div",{className:"border-b border-border px-3 py-3 text-sm text-muted-foreground",children:i})]})}function $te(){const e=J(),[,t]=NA(),s=xY(),i=x.useRef(null),a=x.useCallback(()=>{const l=s==="dark"?"light":"dark",c=i.current,d=document;if(!c||!d.startViewTransition||window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(l);return}const f=c.getBoundingClientRect(),h=f.left+f.width/2,g=f.top+f.height/2,p=Math.hypot(Math.max(h,window.innerWidth-h),Math.max(g,window.innerHeight-g));d.startViewTransition(()=>{t(l)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${g}px)`,`circle(${p}px at ${h}px ${g}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},[s,t]);return n.jsxs("button",{ref:i,type:"button",onClick:a,title:e(s==="dark"?"action.toLight":"action.toDark"),"aria-label":e("action.theme"),className:xf(),children:[n.jsx("span",{className:yf(),children:s==="dark"?n.jsx(_8,{}):n.jsx(CD,{})}),n.jsx("span",{className:_f(),children:e("action.theme")})]})}function Fte(){const e=J();return Ls()?n.jsxs("div",{className:"flex items-center justify-between h-8 bg-background border-b border-border select-none",style:{WebkitAppRegion:"drag"},onMouseDown:()=>H8(),children:[n.jsx("span",{className:"px-3 text-xs font-medium text-muted-foreground",children:"NoMoreIDE"}),n.jsxs("div",{className:"flex items-center",style:{WebkitAppRegion:"no-drag"},children:[n.jsx("button",{type:"button",onClick:z8,className:"h-8 w-10 flex items-center justify-center hover:bg-muted transition-colors","aria-label":e("common.minimize"),children:n.jsx(_E,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:B8,className:"h-8 w-10 flex items-center justify-center hover:bg-muted transition-colors","aria-label":e("common.maximize"),children:n.jsx(Ta,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:I8,className:"h-8 w-10 flex items-center justify-center hover:bg-destructive hover:text-destructive-foreground transition-colors","aria-label":e("common.close"),children:n.jsx(Vt,{className:"h-3 w-3"})})]})]}):null}const Ute=300;function qte(){const{operations:e}=In(),[t,s]=x.useState(!1),[i,a]=x.useState(!1),l=x.useId(),c=J();if(x.useEffect(()=>{if(e.length===0){s(!1),a(!1);return}const h=Math.min(...e.map(({startedAt:b})=>b)),g=Math.max(0,Ute-(Date.now()-h));if(g===0){s(!0);return}s(!1);const p=window.setTimeout(()=>s(!0),g);return()=>window.clearTimeout(p)},[e]),!t||e.length===0)return null;const d=e.length>1,f=d?c("operation.multiple",{count:e.length}):e[0].label;return n.jsxs("aside",{"aria-live":"polite",className:"rounded-lg border border-border bg-card px-3 py-2 text-card-foreground shadow-sm transition-all motion-reduce:transition-none",role:"status",children:[n.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[n.jsx(nm,{size:"sm"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:f}),d?n.jsx(Q,{"aria-controls":l,"aria-expanded":i,"aria-label":c(i?"operation.hideDetails":"operation.showDetails"),onClick:()=>a(h=>!h),size:"icon-sm",type:"button",variant:"ghost",children:n.jsx(hn,{className:re("transition-transform motion-reduce:transition-none",i&&"rotate-180")})}):null]}),d&&i?n.jsx("ul",{className:"mt-2 space-y-1 border-t border-border pt-2",id:l,children:e.map(h=>n.jsxs("li",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-primary"}),n.jsx("span",{className:"truncate",children:h.label})]},h.id))}):null]})}const HT={services:"/",docker:"/docker",git:"/git",github:"/github",workflows:"/workflows",errors:"/errors",database:"/database",terminal:"/terminal",agent:"/agent","agent-env":"/agent-env",settings:"/settings"},Gte={services:"nav.services",docker:"nav.docker",git:"nav.git",github:"nav.github",workflows:"nav.workflows",errors:"nav.errors",database:"nav.database",terminal:"nav.terminal",agent:"pageTitle.agent","agent-env":"pageTitle.agentEnv",settings:"nav.settings"},Vte=Object.entries(HT).filter(([,e])=>e!=="/").sort(([,e],[,t])=>t.length-e.length);function Wte(e){for(const[t,s]of Vte)if(e.startsWith(s))return t;return"services"}const Kte=[{labelKey:"nav.section.run",items:[{page:"services",labelKey:"nav.services",icon:n.jsx(Zf,{})},{page:"docker",labelKey:"nav.docker",icon:n.jsx(Fx,{})},{page:"errors",labelKey:"nav.errors",icon:n.jsx(Au,{})},{page:"terminal",labelKey:"nav.terminal",icon:n.jsx(Br,{})}]},{labelKey:"nav.section.code",items:[{page:"git",labelKey:"nav.git",icon:n.jsx(_n,{})},{page:"github",labelKey:"nav.github",icon:n.jsx(bm,{})},{page:"workflows",labelKey:"nav.workflows",icon:n.jsx(of,{})}]},{labelKey:"nav.section.data",items:[{page:"database",labelKey:"nav.database",icon:n.jsx(si,{})}]},{labelKey:"nav.section.agent",items:[{page:"agent",labelKey:"nav.agentConsole",icon:n.jsx(Ff,{})},{page:"agent-env",labelKey:"nav.agentEnv",icon:n.jsx(Tu,{})}]}];function Yte(e=!1){return re("group/sidebar hidden h-full shrink-0 overflow-x-hidden overflow-y-auto border-r border-border bg-card/85 py-4 backdrop-blur transition-[width,padding] duration-200 md:flex md:flex-col",e?"w-64 px-4":"w-16 px-2 hover:w-64 hover:px-4")}function Xte(e,t=!1){return re("relative grid h-10 grid-cols-[48px_minmax(0,1fr)] items-center justify-start gap-0 overflow-hidden rounded-md px-0 text-sm font-medium transition-[background-color,color,width] duration-150",t?"w-full":"w-12 group-hover/sidebar:w-full",e?"bg-primary text-primary-foreground hover:bg-primary/90":"hover:bg-muted")}function Zte(e=!1,t=!1){return re("min-w-0 overflow-hidden text-left text-current transition duration-150 whitespace-pre",e?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100",t?"pr-10":"pr-3")}function Qte(e=!1){return re("flex h-10 w-12 items-center justify-center text-current transition-transform duration-150 [&_svg]:size-5",e?"translate-x-0":"-translate-x-px group-hover/sidebar:translate-x-0")}function Jte({docked:e,onToggleDock:t}){return n.jsxs("div",{className:re("mt-auto flex h-10 min-w-0 items-center overflow-hidden border-t border-border/60 text-[11px] text-muted-foreground transition-[height,opacity,width] duration-150",e?"w-full justify-start opacity-100":"w-12 justify-center group-hover/sidebar:w-full group-hover/sidebar:justify-start group-hover/sidebar:opacity-100"),children:[n.jsxs("span",{className:re("flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-pre transition-[opacity,width] duration-150",e?"flex-1 opacity-100":"w-0 flex-none opacity-0 group-hover/sidebar:w-auto group-hover/sidebar:flex-1 group-hover/sidebar:opacity-100"),children:[n.jsx("span",{children:"Made with"}),n.jsx(I6,{"aria-label":"love",className:"size-3 shrink-0 fill-red-500 text-red-500"}),n.jsx("span",{children:"by Robert Wang"}),n.jsx("a",{"aria-label":"Robert Wang on LinkedIn",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-[#0A66C2]",href:"https://www.linkedin.com/in/robert-wang-cs/",rel:"noopener noreferrer",target:"_blank",title:"LinkedIn",children:n.jsxs("svg",{className:"size-3 fill-current",role:"img",viewBox:"0 0 24 24",children:[n.jsx("title",{children:"LinkedIn"}),n.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.063 2.063 0 1 1 0-4.126 2.063 2.063 0 0 1 0 4.126zM7.119 20.452H3.554V9h3.565v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.225 0z"})]})})]}),n.jsx("button",{"aria-label":e?"Undock sidebar":"Dock sidebar","aria-pressed":e,className:re("flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4",e?"ml-auto bg-muted text-foreground":"group-hover/sidebar:ml-auto"),onClick:t,title:e?"Undock sidebar":"Dock sidebar",type:"button",children:e?n.jsx(MD,{}):n.jsx(LD,{})})]})}function ese({className:e}){return n.jsxs("div",{className:re("min-w-0",e),children:[n.jsxs("div",{className:"flex items-baseline gap-1.5",children:[n.jsx("div",{className:"text-sm font-semibold",children:"NoMoreIDE"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:["v","0.1.87"]})]}),n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"127.0.0.1 console"})]})}function tse({syncLocation:e=!0}={}){return n.jsx(EY,{children:n.jsx(pF,{children:n.jsx(nse,{syncLocation:e})})})}function sse({projectPath:e,selectProject:t}){return x.useEffect(()=>{t(e)},[e,t]),null}function nse({syncLocation:e}){const t=J(),[s,i]=x.useState(()=>e?Wte(window.location.pathname):"services"),[a,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(null),[g,p]=x.useState(0),[b,v]=x.useState(null),[_,S]=x.useState(!0),{error:C,message:N,success:A}=cs(),{ui:j,updateUi:E,selectProject:T}=xm(),L=j.sidebarDocked,H=j.projectScope==="all",P=x.useCallback($=>E({projectScope:$?"all":"project"}),[E]),F=GU(),M=x.useCallback(async($={})=>{$.silent||S(!0),v(null);try{l(await l9()),$.notify&&A(t("app.dashboardRefreshed"))}catch(me){const ee=me instanceof Error?me.message:String(me);v(ee),C(ee)}finally{S(!1)}},[C,A,t]),z=x.useCallback(()=>{M({notify:!0}),F.runActive()},[M,F]);x.useEffect(()=>{M()},[M]),x.useEffect(()=>{function $(){document.visibilityState==="visible"&&(M({silent:!0}),F.runActive())}const me=window.setInterval($,5e3);return window.addEventListener("focus",$),document.addEventListener("visibilitychange",$),()=>{window.clearInterval(me),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[s,M,F.runActive]),x.useEffect(()=>{if(!e)return;const $=HT[s];window.location.pathname!==$&&window.history.pushState(null,"",$)},[s,e]);const G=!H&&a?.git.selectedRepository||null,D=x.useMemo(()=>a&&G?DY(a,G):a,[a,G]),q=x.useMemo(()=>G&&D?new Set(D.config.services.map($=>$.name)):null,[G,D]),W=x.useMemo(()=>D?Object.values(D.runtime.services).filter($=>$.state==="running").length:0,[D]),I=a?.git.selectedRepository?.name??a?.git.cwd??"no-git-repository",Y=a?.git.selectedRepository?.path??null;return n.jsxs(RF,{children:[n.jsx(sse,{projectPath:Y,selectProject:T}),n.jsx(VU,{value:F,children:n.jsx(oG,{onRefresh:()=>{M({silent:!0})},children:n.jsx(lG,{children:n.jsxs("div",{className:"flex flex-col h-screen overflow-hidden",children:[n.jsx(Fte,{}),n.jsxs("div",{className:"flex-1 overflow-hidden pb-9",children:[n.jsxs("div",{className:"mx-auto flex h-full max-w-[1500px]",children:[n.jsxs("aside",{className:Yte(L),children:[n.jsxs("div",{className:re("grid h-12 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden transition-[width] duration-150",L?"w-full":"w-12 group-hover/sidebar:w-full"),children:[n.jsx("div",{className:"flex size-12 items-center justify-center",children:n.jsx("div",{className:"flex size-9 items-center justify-center overflow-hidden rounded-md bg-primary text-primary-foreground",children:n.jsxs("svg",{"aria-label":"NoMoreIDE",className:"size-6",fill:"none",role:"img",viewBox:"0 0 64 64",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M5 17C5 13.69 7.69 11 11 11H25L31 17H53C56.31 17 59 19.69 59 23V53C59 56.31 56.31 59 53 59H11C7.69 59 5 56.31 5 53V17Z",fill:"currentColor"}),n.jsx("path",{d:"M22 31L30 39L22 47",stroke:"hsl(var(--primary))",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"4.5"}),n.jsx("path",{d:"M36 47H48",stroke:"hsl(var(--primary))",strokeLinecap:"round",strokeWidth:"4.5"})]})})}),n.jsx(ese,{className:re("min-w-0 translate-x-1 overflow-hidden transition-opacity duration-200",L?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100")})]}),a?n.jsx("div",{className:"mt-3 border-b border-border/60 pb-2",children:n.jsx(Bte,{data:a,docked:L,onRefresh:()=>M({silent:!0}),onScopeChange:P,scopeAll:H})}):null,n.jsx("nav",{className:"mt-2 flex-1 content-start overflow-y-auto overflow-x-hidden",children:Kte.map(($,me)=>n.jsxs("div",{className:re(me>0&&"mt-2 border-t border-border/60 pt-2"),children:[n.jsx(ise,{docked:L,label:t($.labelKey)}),n.jsx("div",{className:"grid gap-0.5",children:$.items.map(ee=>n.jsx(nE,{active:s===ee.page,badge:ee.page==="services"?W:void 0,docked:L,icon:ee.icon,label:t(ee.labelKey),onClick:()=>i(ee.page)},ee.page))})]},$.labelKey))}),n.jsx("div",{className:"mb-1 border-t border-border/60 pt-1",children:n.jsx(nE,{active:s==="settings",docked:L,icon:n.jsx(kE,{}),label:t("nav.settings"),onClick:()=>i("settings")})}),n.jsx(Jte,{docked:L,onToggleDock:()=>E({sidebarDocked:!L})})]}),n.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col px-0 py-0",children:[n.jsxs("header",{className:re("relative z-40 flex shrink-0 flex-wrap items-center justify-between gap-3 border border-border bg-card/90 px-4 py-3 backdrop-blur","border-x-0 border-t-0 border-b"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(PD,{className:"size-4 text-muted-foreground md:hidden"}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:t(Gte[s])}),n.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:s==="git"||s==="github"?a?.git.selectedRepository?.name??a?.git.cwd??t("app.localWorkspace"):G?.name??t("app.allProjects")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[b?n.jsx(We,{variant:"danger",children:b}):null,n.jsxs("div",{"aria-label":"Dashboard quick actions",className:"flex items-center gap-1 rounded-lg border border-border bg-background p-px",role:"toolbar",children:[n.jsxs("button",{"aria-label":t("action.refresh"),className:xf(),onClick:z,title:t("action.refreshTitle"),type:"button",children:[n.jsx("span",{className:yf(),children:n.jsx(_i,{className:re(_&&"animate-spin")})}),n.jsx("span",{className:_f(),children:t("action.refresh")})]}),n.jsx($te,{}),n.jsxs("a",{"aria-label":t("action.docsTitle"),className:xf(),href:"https://www.nomoreide.com/docs",rel:"noreferrer",target:"_blank",title:t("action.docsTitle"),children:[n.jsx("span",{className:yf(),children:n.jsx(oE,{})}),n.jsx("span",{className:_f(),children:t("action.docs")})]}),a?n.jsx(Fq,{data:a}):null]})]})]}),n.jsx("div",{className:"relative z-30 shrink-0 px-4 pt-2",children:n.jsx(qte,{})}),a?n.jsx(XZ,{data:a,onOpenService:$=>{q&&!q.has($)&&(P(!0),N({text:t("app.serviceOutsideScope")})),d($),i("services"),M({silent:!0})}}):null,_&&!a?n.jsx(Ze,{variant:"muted",children:t("app.loading")}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[D&&s==="services"?n.jsx($Z,{data:D,onRefresh:M,focusService:c,onServiceFocused:()=>d(null),scopeName:G?.name??null}):null,s==="docker"?n.jsx(YZ,{}):null,a&&s==="git"?n.jsx(Aee,{data:a,onRefresh:()=>{M({silent:!0})}}):null,s==="github"?n.jsx(Rte,{},I):null,s==="workflows"?n.jsx(zee,{}):null,s==="agent"?n.jsx(qU,{focusChanges:g,onOpenAgentEnv:()=>i("agent-env")}):null,s==="agent-env"?n.jsx(gq,{}):null,s==="errors"?n.jsx(EX,{inScope:q?$=>q.has($):void 0,onReviewChanges:()=>{p($=>$+1),i("agent")}}):null,s==="database"?n.jsx(aX,{projects:a?.config.gitRepositories??[],scopePath:G?.path??null,staged:f,onStageConsumed:()=>h(null)}):null,s==="terminal"?n.jsx(sQ,{}):null,s==="settings"?n.jsx(vX,{activeProject:a?.git.selectedRepository??null,onNavigate:$=>i($)}):null]})]})]}),a&&s==="git"?n.jsx(Hte,{ahead:a.git.status?.ahead??0,behind:a.git.status?.behind??0,branches:a.git.branches,currentBranch:a.git.status?.branch||void 0,disabled:!a.git.status,onRefresh:M,upstream:a.git.status?.upstream}):null,n.jsx(RY,{currentPage:s,git:a?.git,onNavigate:$=>i($),onGitRefresh:()=>{M({silent:!0})}})]})]})})})})]})}function ise({docked:e,label:t}){return n.jsx("div",{className:"flex h-5 items-center overflow-hidden px-3",children:n.jsx("span",{className:re("whitespace-pre text-[10px] font-semibold uppercase tracking-widest text-muted-foreground transition-opacity duration-150",e?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100"),children:t})})}function nE({active:e,badge:t,docked:s,icon:i,label:a,onClick:l}){const c=t!==void 0&&t>0;return n.jsxs(Q,{"aria-label":a,title:a,className:Xte(e,s),variant:"ghost",onClick:l,type:"button",children:[n.jsx("span",{className:Qte(s),children:i}),n.jsx("span",{className:Zte(s,c),children:a}),t!==void 0&&t>0?n.jsx(We,{appearance:t>0?"solid":"outline",className:re("min-w-6 justify-center px-1.5 font-mono shadow-none",e?"border-primary-foreground/40 bg-primary-foreground/15 text-primary-foreground dark:border-primary-foreground/40 dark:bg-primary-foreground/15 dark:text-primary-foreground":t>0?"":"border-border bg-background text-muted-foreground","absolute right-1.5 top-1.5 h-4 min-w-4 rounded-full px-1 text-[10px] leading-none shadow-none group-hover/sidebar:right-2 group-hover/sidebar:top-1/2 group-hover/sidebar:-translate-y-1/2 group-hover/sidebar:text-xs",s&&"right-2 top-1/2 -translate-y-1/2 text-xs"),size:"small",variant:t>0?"success":"outline",children:t}):null]})}rE.createRoot(document.getElementById("root")).render(n.jsx(x.StrictMode,{children:n.jsx(tse,{})}));export{n as j,x as r};
|
|
227
|
+
`),provider:a?.id,signal:E.signal});E.signal.aborted||c(T)}catch(T){E.signal.aborted||_(T instanceof Error?T.message:String(T))}finally{S.current===E&&(S.current=null,f(!1))}}async function A(){if(C){g(!0),_(null);try{await N7(C),b(C)}catch(j){_(j instanceof Error?j.message:String(j))}finally{g(!1)}}}return n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-muted/35 p-3",children:[n.jsx(Or,{children:i("workflows.recover.title")}),n.jsx("p",{className:"mb-2 text-[11px] text-muted-foreground",children:i("workflows.recover.desc")}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>{N()},size:"sm",type:"button",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.recommend")]}),p?n.jsxs(Q,{onClick:t,size:"sm",type:"button",variant:"outline",children:[n.jsx(or,{className:"size-3.5"})," ",i("workflows.recover.runAgain")]}):null]}),d?n.jsxs("p",{className:"mt-2 flex items-center gap-1 text-[11px] text-muted-foreground",children:[n.jsx(Mt,{className:"size-3 animate-spin"})," ",i("workflows.recover.choosing")]}):null,C?n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-background p-2.5",children:[n.jsx(Or,{children:i("workflows.recover.recommendedBranch")}),n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("code",{className:"min-w-0 rounded bg-muted px-2 py-1 font-mono text-[12px] text-foreground",children:C}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Q,{disabled:h||p===C,onClick:()=>{A()},size:"sm",type:"button",children:[h?n.jsx(Mt,{className:"size-3.5 animate-spin"}):n.jsx(Ys,{className:"size-3.5"}),i("workflows.recover.createBranch")]}),n.jsxs(Q,{disabled:h,onClick:()=>{N("Recommend a different concise branch name. Keep the same output contract with `BRANCH_NAME: <branch-name>`.")},size:"sm",type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.askAnother")]})]})]})]}):l&&!d?n.jsxs("div",{className:"mt-3 rounded-md border border-border bg-background p-2.5",children:[n.jsx("p",{className:"text-[11px] text-muted-foreground",children:i("workflows.recover.noBranch")}),n.jsxs(Q,{className:"mt-2",onClick:()=>{N("Return only a concise branch suggestion using this exact line: `BRANCH_NAME: <branch-name>`.")},size:"sm",type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"})," ",i("workflows.recover.askAnother")]})]}):null,p?n.jsxs("p",{className:"mt-2 text-[11px] text-emerald-700 dark:text-emerald-400",children:[i("workflows.recover.createdPre"),n.jsx("code",{className:"font-mono",children:p}),i("workflows.recover.createdPost")]}):null,v?n.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:v}):null]})}const VN={running:"workflows.status.running",waiting:"workflows.status.waiting",done:"workflows.status.done",blocked:"workflows.status.needsYou",failed:"workflows.status.failed",skipped:"workflows.status.skipped",pending:"workflows.status.queued"},jT={gate:"workflows.kind.gate",agent:"workflows.kind.agent",action:"workflows.kind.action"};function Yee({output:e,previousOutput:t,status:s,step:i}){const a=J();if(i.kind==="gate"){const c=i.id==="gate-commit"?t?.trim():"";return n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:i.message}),c?n.jsxs("div",{className:"mt-3",children:[n.jsx(Or,{children:a("workflows.step.generatedCommitMessage")}),n.jsx("div",{className:"whitespace-pre-wrap break-words rounded-md border border-border bg-muted/50 px-2.5 py-2 font-mono text-[11px] text-foreground",children:c})]}):null]})}if(i.kind==="action")return n.jsx("p",{className:"text-muted-foreground",children:a(AT[i.op])});const l=s==="done"||s==="failed"||s==="skipped";return e?n.jsxs("div",{children:[n.jsx(Or,{children:a("workflows.step.result")}),n.jsx("div",{className:"whitespace-pre-wrap break-words rounded-md bg-muted/50 px-2.5 py-2 font-mono text-[11px] text-foreground",children:e})]}):n.jsxs("div",{children:[n.jsx(Or,{children:a(l?"workflows.step.result":"workflows.step.task")}),l?n.jsx("p",{className:"italic text-muted-foreground",children:a("workflows.step.noReply")}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground",children:i.prompt}),s==="running"?n.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-muted-foreground/80",children:[n.jsx(Mt,{className:"size-3 animate-spin"})," ",a("workflows.step.working")]}):null]})]})}function Xee(e){return e.detected.name==="codex"?e.agents.codex:e.agents["claude-code"]??e}function Zee(e){return e?{skills:ru(e.skills.map(t=>t.name)),mcpServers:ru(e.mcpServers.map(t=>t.name)),plugins:ru(e.plugins.map(t=>t.name)),hooks:ru(e.hooks.map(t=>t.matcher?`${t.event}: ${t.matcher}`:t.event))}:{skills:[],mcpServers:[],plugins:[],hooks:[]}}function Qee(e){return{id:d1("custom-workflow",e),name:"Custom workflow",description:"A user-built workflow.",builtin:!1,steps:[{kind:"gate",id:"gate-start",title:"Approve start",message:"Run this workflow?"}]}}function Jee(e){const t=kl(e.id)||e.kind,s=e.title.trim()||Bf(e);if(e.kind==="gate")return{...e,id:t,title:s,message:e.message.trim()||"Continue?"};if(e.kind==="action")return{...e,id:t,title:s};const i=TT(e.capabilities);return{...e,id:t,title:s,prompt:e.prompt.trim()||"Complete this workflow step.",capabilities:i}}const AT={"assert-pr-branch":"workflows.opDesc.assertPrBranch","checkout-default-and-pull":"workflows.opDesc.checkoutDefault",push:"workflows.opDesc.push",commit:"workflows.opDesc.commit"};function TT(e){if(!e)return;const t={};for(const s of["skills","mcpServers","plugins","hooks"]){const i=ru((e[s]??[]).map(a=>a.trim()).filter(Boolean));i.length&&(t[s]=i)}return Object.keys(t).length?t:void 0}function ete(e,t,s){const i=e?.[t]??[],a=i.includes(s)?i.filter(l=>l!==s):[...i,s];return TT({...e??{},[t]:a})}function d1(e,t){const s=new Set(t.map(l=>l.id));let i=kl(e)||"workflow",a=2;for(;s.has(i);)i=`${kl(e)||"workflow"}-${a}`,a++;return i}function kl(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ru(e){return Array.from(new Set(e.filter(Boolean)))}function Or({children:e}){return n.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:e})}function Bx(e){return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(new Date(e))}function RT({outcome:e}){const t=J(),s={running:{labelKey:"workflows.status.running",className:"border-primary/40 text-primary"},done:{labelKey:"workflows.status.done",className:"border-emerald-500/40 text-emerald-600 dark:text-emerald-400"},stopped:{labelKey:"workflows.status.stopped",className:"border-border text-muted-foreground"},failed:{labelKey:"workflows.status.failed",className:"border-destructive/40 text-destructive"},blocked:{labelKey:"workflows.status.needsYou",className:"border-amber-500/40 text-amber-700 dark:text-amber-400"}},{labelKey:i,className:a}=s[e];return n.jsx("span",{className:re("rounded-full border px-2 py-0.5 text-[10px] font-medium",a),children:t(i)})}function MT({kind:e}){return e==="gate"?n.jsx(NE,{className:"size-4 text-amber-600 dark:text-amber-400"}):e==="agent"?n.jsx(Bn,{className:"size-4 text-primary"}):n.jsx(or,{className:"size-4 text-muted-foreground"})}function WN({status:e,kind:t}){return e==="running"?n.jsx(Mt,{className:"size-4 shrink-0 animate-spin text-primary"}):e==="waiting"?n.jsx(NE,{className:"size-4 shrink-0 text-primary"}):e==="done"?n.jsx(Ys,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}):e==="blocked"?n.jsx(Gf,{className:"size-4 shrink-0 text-amber-600 dark:text-amber-400"}):e==="failed"?n.jsx(zr,{className:"size-4 shrink-0 text-destructive"}):e==="skipped"?n.jsx(EE,{className:"size-4 shrink-0 text-muted-foreground/60"}):t==="agent"?n.jsx(Bn,{className:"size-4 shrink-0 text-muted-foreground/50"}):n.jsx(DM,{className:"size-4 shrink-0 text-muted-foreground/50"})}function tte(e){return n.jsx(wn,{className:"size-3 shrink-0 text-muted-foreground/40","aria-hidden":!0})}function Ix({kind:e}){const t=J(),s=e==="agent"?"border-primary/30 text-primary":e==="gate"?"border-amber-500/40 text-amber-600 dark:text-amber-400":"border-border text-muted-foreground";return n.jsx("span",{className:re("shrink-0 rounded-full border px-1.5 py-px text-[9px] uppercase tracking-wide",s),children:t(jT[e])})}function Bf(e){return e.title}function ste(){const[e,t]=x.useState(!1),[s,i]=x.useState(!1),[a,l]=x.useState(!0),[c,d]=x.useState("checking"),[f,h]=x.useState(null),[g,p]=x.useState(null);function b(){l(!0),d("checking"),h(null),D7().then(v=>{t(v.configured),i(v.deviceFlowAvailable),d(v.status),h(v.error??null),p(v)}).catch(v=>{t(!1),i(!1),d("connection_error"),h(v instanceof Error?v.message:String(v)),p(null)}).finally(()=>l(!1))}return x.useEffect(()=>{b()},[]),{configured:e,deviceFlowAvailable:s,loading:a,status:c,error:f,info:g,isConnected:c==="connected",needsLogin:c==="not_configured"||c==="auth_error",refresh:b}}const dv=30;function nte(e="open"){const[t,s]=x.useState([]),[i,a]=x.useState(!0),[l,c]=x.useState(!1),[d,f]=x.useState(!1),[h,g]=x.useState(1),[p,b]=x.useState(null),[v,_]=x.useState(null),[S,C]=x.useState(null),[N,A]=x.useState(""),[j,E]=x.useState(!1),[T,L]=x.useState(null);x.useEffect(()=>{let F=!0;return a(!0),b(null),g(1),Bg(e,1).then(M=>{F&&(s(M),f(M.length===dv),M.length>0&&!M.some(z=>z.number===v)&&_(M[0]?.number??null))}).catch(M=>{F&&b(M instanceof Error?M.message:String(M))}).finally(()=>{F&&a(!1)}),()=>{F=!1}},[e]),x.useEffect(()=>{if(!v){C(null);return}let F=!0;return I7(v).then(M=>{F&&C(M)}).catch(()=>{}),()=>{F=!1}},[v]),x.useEffect(()=>{if(!v){A("");return}let F=!0;return E(!0),L(null),H7(v).then(M=>{F&&A(M)}).catch(M=>{F&&L(M instanceof Error?M.message:String(M))}).finally(()=>{F&&E(!1)}),()=>{F=!1}},[v]);function H(){if(l||!d)return;const F=h+1;c(!0),Bg(e,F).then(M=>{s(z=>{const G=new Set(z.map(D=>D.number));return[...z,...M.filter(D=>!G.has(D.number))]}),f(M.length===dv),g(F)}).catch(M=>b(M instanceof Error?M.message:String(M))).finally(()=>c(!1))}function P(){let F=!0;return a(!0),b(null),g(1),Bg(e,1).then(M=>{F&&(s(M),f(M.length===dv))}).catch(M=>{F&&b(M instanceof Error?M.message:String(M))}).finally(()=>{F&&a(!1)}),()=>{F=!1}}return{prs:t,loading:i,loadingMore:l,hasMore:d,error:p,selectedNumber:v,setSelectedNumber:_,selectedPR:S,diff:N,diffLoading:j,diffError:T,loadMore:H,refresh:P}}const hv=30;function ite(e="open"){const[t,s]=x.useState([]),[i,a]=x.useState(!0),[l,c]=x.useState(!1),[d,f]=x.useState(!1),[h,g]=x.useState(1),[p,b]=x.useState(null),[v,_]=x.useState(null),[S,C]=x.useState(null),[N,A]=x.useState([]),[j,E]=x.useState(!1),[T,L]=x.useState(null),[H,P]=x.useState(!1);x.useEffect(()=>{let G=!0;return a(!0),b(null),g(1),Ig(e,1).then(D=>{G&&(s(D),f(D.length===hv),D.length>0&&!D.some(q=>q.number===v)&&_(D[0]?.number??null))}).catch(D=>{G&&b(D instanceof Error?D.message:String(D))}).finally(()=>{G&&a(!1)}),()=>{G=!1}},[e]),x.useEffect(()=>{if(!v){C(null),A([]);return}let G=!0;return E(!0),Promise.all([G7(v),V7(v)]).then(([D,q])=>{G&&(C(D),A(q))}).catch(()=>{}).finally(()=>{G&&E(!1)}),()=>{G=!1}},[v]);async function F(G){if(v){P(!0),L(null);try{const D=await W7(v,G);A(q=>[...q,D])}catch(D){L(D instanceof Error?D.message:String(D))}finally{P(!1)}}}function M(){if(l||!d)return;const G=h+1;c(!0),Ig(e,G).then(D=>{s(q=>{const W=new Set(q.map(I=>I.number));return[...q,...D.filter(I=>!W.has(I.number))]}),f(D.length===hv),g(G)}).catch(D=>b(D instanceof Error?D.message:String(D))).finally(()=>c(!1))}function z(){let G=!0;return a(!0),g(1),Ig(e,1).then(D=>{G&&(s(D),f(D.length===hv))}).catch(()=>{}).finally(()=>{G&&a(!1)}),()=>{G=!1}}return{issues:t,loading:i,loadingMore:l,hasMore:d,error:p,selectedNumber:v,setSelectedNumber:_,selectedIssue:S,comments:N,commentsLoading:j,commentError:T,submitting:H,addComment:F,loadMore:M,refresh:z}}function DT({deviceFlowAvailable:e,initialMode:t,onSaved:s}){const i=J(),[a,l]=x.useState(()=>t==="device-pending"&&!e?"pat":t??(e?"choose":"pat"));return a==="device-pending"?n.jsx(rte,{onSuccess:s,onCancel:()=>l("choose")}):a==="pat"?n.jsx(ate,{onSaved:s,onBack:e?()=>l("choose"):void 0}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-muted",children:n.jsx(tS,{className:"size-6 text-muted-foreground"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:i("github.setup.connectTitle")}),n.jsx("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:i("github.setup.connectDesc")})]})]}),n.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-2",children:[n.jsxs(Q,{className:"w-full",onClick:()=>l("device-pending"),type:"button",children:[n.jsx(tS,{className:"mr-2 size-4"}),i("github.setup.authorizeWith")]}),n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>l("pat"),type:"button",children:i("github.setup.usePat")})]})]})}function rte({onSuccess:e,onCancel:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState(!0),[h,g]=x.useState(!1),p=x.useRef(null),b=x.useRef(5),v=x.useRef(!1);x.useEffect(()=>{let N=!0;return L7().then(A=>{if(!N)return;a(A),b.current=A.interval,f(!1);const j=A.verification_uri_complete||A.verification_uri;j&&em(j),_(A.device_code,A.interval),setTimeout(()=>{v.current=!0},A.expires_in*1e3)}).catch(A=>{N&&(c(A instanceof Error?A.message:String(A)),f(!1))}),()=>{N=!1,p.current&&clearTimeout(p.current)}},[]);function _(N,A){p.current=setTimeout(()=>{S(N,A)},A*1e3)}async function S(N,A){if(v.current){c(s("github.setup.expired"));return}try{const j=await O7(N);if(j.done){e();return}const E=j.slowDown?A+5:A;b.current=E,_(N,E)}catch{_(N,b.current)}}function C(){i&&navigator.clipboard.writeText(i.user_code).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)})}return d?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx(sS,{className:"size-6 animate-spin text-muted-foreground"}),n.jsx("p",{className:"text-[13px] text-muted-foreground",children:s("github.setup.requesting")})]})}):l?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8",children:[n.jsx(Ze,{variant:"destructive",children:l}),n.jsx(Q,{onClick:t,variant:"outline",children:s("github.setup.goBack")})]}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-emerald-100 dark:bg-emerald-500/15",children:n.jsx(Vf,{className:"size-6 text-emerald-600 dark:text-emerald-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:s("github.setup.authorizeOnTitle")}),n.jsxs("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:[s("github.setup.enterCodePre"),n.jsx("strong",{children:s("github.setup.authorizeWord")}),s("github.setup.enterCodePost")]})]})]}),n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsx("div",{className:"flex cursor-pointer select-all items-center gap-3 rounded-xl border-2 border-border bg-muted px-6 py-4 font-mono text-2xl font-bold tracking-[0.3em] transition-colors hover:border-ring",onClick:C,title:s("github.setup.clickToCopy"),children:i?.user_code}),n.jsx("button",{className:"text-[11px] text-muted-foreground transition-colors hover:text-foreground",onClick:C,type:"button",children:s(h?"common.copied":"github.setup.clickCodeCopy")})]}),n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[n.jsx(sS,{className:"size-3.5 animate-spin"}),s("github.setup.waiting")]}),n.jsx("a",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",href:i?.verification_uri_complete||i?.verification_uri,rel:"noopener noreferrer",target:"_blank",children:s("github.setup.openAgain")}),n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:t,type:"button",children:s("common.cancel")})]})]})}function ate({onSaved:e,onBack:t}){const s=J(),[i,a]=x.useState(""),[l,c]=x.useState(!1),[d,f]=x.useState(null);async function h(g){g.preventDefault();const p=i.trim();if(p){c(!0),f(null);try{await P7("github.com",p),e()}catch(b){f(b instanceof Error?b.message:String(b))}finally{c(!1)}}}return n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl bg-muted",children:n.jsx(xE,{className:"size-6 text-muted-foreground"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:s("github.setup.patTitle")}),n.jsxs("p",{className:"mt-1 max-w-sm text-[13px] text-muted-foreground",children:[s("github.setup.patDescPre"),n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"https://github.com/settings/tokens/new?scopes=repo,workflow",rel:"noopener noreferrer",target:"_blank",children:"github.com/settings/tokens"}),s("github.setup.patDescMid"),n.jsx("code",{className:"rounded bg-muted px-1 py-px text-[11px]",children:"repo"}),s("github.setup.patDescAnd"),n.jsx("code",{className:"rounded bg-muted px-1 py-px text-[11px]",children:"workflow"}),s("github.setup.patDescPost")]})]})]}),n.jsxs("form",{className:"flex w-full max-w-sm flex-col gap-3",onSubmit:g=>{h(g)},children:[n.jsx("input",{autoComplete:"off",className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-[13px] placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring",onChange:g=>a(g.target.value),placeholder:"ghp_...",spellCheck:!1,type:"password",value:i}),d?n.jsx(Ze,{variant:"destructive",children:d}):null,n.jsx(Q,{disabled:!i.trim()||l,type:"submit",children:s(l?"common.saving":"github.setup.saveToken")}),t?n.jsx("button",{className:"text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:t,type:"button",children:s("github.setup.back")}):null]})]})}function h1({hasMore:e,loading:t,onLoadMore:s}){const i=J();return e?n.jsx("div",{className:"p-2",children:n.jsxs("button",{className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-border py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-60",disabled:t,onClick:s,type:"button",children:[t?n.jsx(Mt,{className:"size-3 animate-spin"}):null,i(t?"common.loading":"github.loadMore")]})}):null}function ote({prs:e,loading:t,loadingMore:s,hasMore:i,error:a,selectedNumber:l,onSelect:c,onLoadMore:d}){const f=J();return t&&e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.prs.loading")}):a?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:a}):e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.prs.empty")}):n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"divide-y divide-border",children:e.map(h=>n.jsx("li",{children:n.jsxs("button",{className:`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted/60 ${l===h.number?"bg-muted":""}`,onClick:()=>c(h.number),type:"button",children:[n.jsx("span",{className:"mt-0.5 shrink-0",children:n.jsx(lte,{pr:h})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:h.title}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",h.number," · ",h.base.ref," ← ",h.head.ref," · ",h.user.login]})]}),h.draft?n.jsx("span",{className:"shrink-0 rounded border border-border px-1.5 py-px text-[10px] text-muted-foreground",children:f("github.prs.draft")}):null]})},h.number))}),n.jsx(h1,{hasMore:i,loading:s,onLoadMore:d})]})}function lte({pr:e}){return e.state==="merged"?n.jsx(af,{className:"size-4 text-purple-500"}):e.state==="closed"?n.jsx(R6,{className:"size-4 text-red-500"}):n.jsx(vE,{className:"size-4 text-emerald-500"})}function LT({body:e,title:t}){const s=J(),i=t??s("github.md.description"),[a,l]=x.useState("rendered"),c=d=>re("rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors",d?"bg-foreground text-background":"text-muted-foreground hover:text-foreground");return n.jsxs("section",{className:"overflow-hidden rounded-md border border-border bg-muted/25",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:i}),n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-background/60 p-0.5",children:[n.jsx("button",{className:c(a==="rendered"),onClick:()=>l("rendered"),type:"button",children:s("github.md.rendered")}),n.jsx("button",{className:c(a==="raw"),onClick:()=>l("raw"),type:"button",children:s("github.md.raw")})]})]}),a==="rendered"?n.jsx(l1,{content:e}):n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-3 py-3 font-mono text-[12px]",children:e})]})}function cte({pr:e,diff:t,diffLoading:s,diffError:i,onMerged:a}){const l=J(),[c,d]=x.useState("cockpit"),[f,h]=x.useState(null),[g,p]=x.useState(!1),[b,v]=x.useState(null),[_,S]=x.useState(null),[C,N]=x.useState(!1),[A,j]=x.useState(null),[E,T]=x.useState(!1),{sendToAgent:L}=Ot(),{isPending:H,runOperation:P}=In(),F=e?`github:pr:${e.number}:merge`:"",M=F?H(F):!1,z=x.useMemo(()=>bF(t),[t]);x.useEffect(()=>{j($=>$&&z.some(me=>me.path===$)?$:z[0]?.path??null)},[z]);const G=z.find($=>$.path===A)??z[0]??null;function D($){j($),d("diff")}function q($,me){e&&(T(!1),L({prompt:me?JF(e,me,$):QF(e,$),source:{type:"github-pr",label:`PR #${e.number}${me?` · ${If(me)}`:""}`},label:`PR #${e.number}${me?` (${If(me)})`:""}: ${$}`}))}if(x.useEffect(()=>{if(T(!1),!e){h(null);return}let $=!0;return p(!0),v(null),$7(e.number).then(me=>{$&&h(me)}).catch(me=>{$&&v(me instanceof Error?me.message:String(me))}).finally(()=>{$&&p(!1)}),()=>{$=!1}},[e]),!e)return n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:l("github.pr.selectPrompt")});const W=e.state==="open"&&!e.draft;async function I(){if(!(!e||M)){S(null);try{await P({errorMessage:$=>$ instanceof Error?$.message:String($),key:F,label:l("github.pr.mergingOperation",{number:e.number})},()=>q7(e.number,{method:"squash"})),N(!1),a?.()}catch($){S($ instanceof Error?$.message:String($)),N(!1)}}}const Y=$=>`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${$?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"group flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-semibold",children:e.title}),n.jsx(rr,{className:re("shrink-0",E&&"opacity-100"),label:l("github.pr.askLabel",{number:e.number}),onAsk:()=>T($=>!$)}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsx("button",{className:Y(c==="cockpit"),onClick:()=>d("cockpit"),type:"button",children:l("github.pr.tabReview")}),n.jsx("button",{className:Y(c==="diff"),onClick:()=>d("diff"),type:"button",children:l("github.pr.tabDiff")})]}),W?n.jsxs(Q,{className:"shrink-0",loading:M,loadingLabel:l("github.pr.merging"),onClick:()=>N(!0),size:"sm",title:l("github.pr.squashTitle"),type:"button",variant:"success",children:[n.jsx(af,{}),l("github.pr.squashMerge")]}):null,n.jsx("a",{"aria-label":l("github.openOnGithub"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.openOnGithub"),children:n.jsx(Pr,{className:"size-3.5"})})]}),_?n.jsx("div",{className:"shrink-0 border-b border-border bg-red-500/10 px-3 py-1.5 text-[11px] text-red-500",children:_}):null,E?n.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:n.jsx(Hr,{placeholder:l("github.pr.askPlaceholder"),onSubmit:$=>q($),onCancel:()=>T(!1)})}):null,c==="cockpit"?n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(ute,{cockpit:f,error:b,loading:g,onOpenFile:D,pr:e})}):s?n.jsx(im,{className:"flex-1",label:l("git.diff.loading")}):i?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:i}):z.length?n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[n.jsx(dte,{files:z,onAsk:($,me)=>q(me,$),onSelect:j,selected:G?.path??null}),n.jsx("div",{className:"relative min-h-0 min-w-0 flex-1",children:G?n.jsx(zu,{diff:G.diff}):null})]}):n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.pr.noDiff")}),C?n.jsx(Ol,{confirmLabel:M?n.jsxs(n.Fragment,{children:[n.jsx(nm,{size:"sm"})," ",l("github.pr.merging")]}):l("github.pr.squashMerge"),icon:n.jsx(af,{}),loading:M,message:n.jsxs(n.Fragment,{children:[l("github.pr.confirmPre"),n.jsxs("span",{className:"font-mono",children:["#",e.number]})," ",n.jsx("span",{className:"font-medium text-foreground",children:e.title}),l("github.pr.confirmInto"),n.jsx("span",{className:"font-mono",children:e.base.ref}),l("github.pr.confirmQ")]}),onCancel:()=>N(!1),onConfirm:()=>{I()},title:l("github.pr.squashMerge"),tone:"success"}):null]})}function ute({pr:e,cockpit:t,loading:s,error:i,onOpenFile:a}){const l=J(),[c,d]=x.useState(!1),f=t?.pr??e,h=t?.files??[],g=t?.reviews??[],p=t?.comments??[],b=t?.checks??null,v=b?.runs.filter(_=>_.conclusion==="failure"||_.conclusion==="timed_out"||_.conclusion==="cancelled")??[];return n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-[12px]",children:[n.jsx(mte,{pr:f}),n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border bg-muted/40 px-2 py-1 font-mono text-[11px]",children:[n.jsx(_n,{className:"size-3 shrink-0 text-muted-foreground"}),f.base.ref,n.jsx(ju,{className:"size-3 shrink-0 text-muted-foreground"}),f.head.ref]}),n.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[n.jsx(j8,{className:"size-3 shrink-0"}),f.user.login]}),n.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[n.jsx(wM,{className:"size-3 shrink-0"}),new Date(f.created_at).toLocaleDateString()]})]}),i?n.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2 text-[12px] text-red-500",children:i}):null,s?n.jsx(im,{className:"justify-start",label:l("github.pr.loadingCockpit")}):null,n.jsxs("div",{className:"grid gap-2 md:grid-cols-4",children:[n.jsx(Bh,{title:l("github.pr.mergeReadiness"),value:l(OT(f,b)),tone:hte(f,b)}),n.jsx(Bh,{title:l("github.pr.reviewStateTitle"),value:l(PT(g)),tone:fte(g)}),n.jsx(Bh,{title:l("github.pr.checks"),value:b?l("github.pr.checksValue",{state:b.state,count:b.totalCount}):l("github.pr.unknown"),tone:b?.state==="success"?"success":b?.state==="failure"||b?.state==="error"?"danger":"muted"}),n.jsx(Bh,{title:l("github.pr.changedFiles"),value:String(h.length),tone:"muted"})]}),v.length>0?n.jsxs("section",{className:"rounded-md border border-red-500/25 bg-red-500/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 text-[11px] font-medium text-red-500",children:l("github.pr.failingChecks")}),n.jsx("div",{className:"flex flex-wrap gap-2",children:v.slice(0,4).map(_=>n.jsxs("a",{className:"inline-flex items-center gap-1 text-[11px] text-red-500 underline-offset-2 hover:underline",href:_.html_url,rel:"noopener noreferrer",target:"_blank",children:[n.jsx($x,{className:"size-3"}),l("github.pr.openFailingCheck",{name:_.name})]},_.id))})]}):null,n.jsxs("section",{className:"rounded-md border border-border bg-muted/25 p-3",children:[n.jsxs("button",{className:"flex w-full items-center gap-2 text-[12px] font-medium",onClick:()=>d(_=>!_),type:"button",children:[c?n.jsx(hn,{className:"size-3.5 text-muted-foreground"}):n.jsx(wn,{className:"size-3.5 text-muted-foreground"}),n.jsx(qx,{className:"size-3.5 text-muted-foreground"}),l("github.pr.changedFiles"),h.length?n.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:["(",h.length,")"]}):null]}),c?h.length?n.jsx("ul",{className:"mt-2 divide-y divide-border",children:h.slice(0,12).map(_=>n.jsx("li",{children:n.jsxs("button",{className:"flex w-full items-center gap-2 py-1.5 text-left text-[12px] transition-colors hover:text-foreground",onClick:()=>a(_.path),title:l("github.pr.viewDiffTitle",{path:_.path}),type:"button",children:[n.jsx("span",{className:"w-16 shrink-0 font-mono text-[10px] uppercase text-muted-foreground",children:_.status}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:_.path}),n.jsxs("span",{className:"shrink-0 font-mono text-[11px] text-emerald-600",children:["+",_.additions]}),n.jsxs("span",{className:"shrink-0 font-mono text-[11px] text-red-500",children:["-",_.deletions]})]})},_.path))}):n.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground",children:l("github.pr.noFileMeta")}):null]}),n.jsxs("section",{className:"rounded-md border border-border bg-muted/25 p-3",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[12px] font-medium",children:[n.jsx(_D,{className:"size-3.5 text-muted-foreground"}),l("github.pr.reviewStateTitle")]}),g.length||p.length?n.jsxs("div",{className:"space-y-2",children:[g.slice(-4).map(_=>n.jsx(KN,{href:_.html_url,meta:`${_.user.login} - ${_.state.toLowerCase()}`,text:_.body||l("github.pr.noReviewSummary")},`review:${_.id}`)),p.slice(-4).map(_=>n.jsx(KN,{href:_.html_url,meta:l("github.pr.reviewMetaComment",{login:_.user.login}),text:_.body},`comment:${_.id}`))]}):n.jsx("p",{className:"text-[12px] text-muted-foreground",children:l("github.pr.noReviews")})]}),f.body?n.jsx(LT,{body:f.body}):n.jsx("p",{className:"text-[12px] italic text-muted-foreground",children:l("github.noDescription")})]})}function dte({files:e,selected:t,onSelect:s,onAsk:i}){const a=J(),[l,c]=x.useState(null);return n.jsx("div",{className:"w-44 shrink-0 overflow-y-auto border-r border-border bg-card/60",children:n.jsx("ul",{className:"py-1",children:e.map(d=>n.jsxs("li",{className:"group flex flex-col",children:[n.jsxs("div",{className:re("flex items-center transition-colors",d.path===t?"bg-muted":"hover:bg-muted/60"),children:[n.jsxs("button",{className:re("flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px]",d.path===t?"text-foreground":"text-muted-foreground group-hover:text-foreground"),onClick:()=>s(d.path),title:d.path,type:"button",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:If(d.path)}),n.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-emerald-600",children:["+",d.additions]}),n.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-red-500",children:["-",d.deletions]})]}),n.jsx(rr,{className:re("mr-1 shrink-0",l===d.path&&"opacity-100"),label:a("github.pr.askFileLabel",{name:If(d.path)}),onAsk:()=>c(f=>f===d.path?null:d.path)})]}),l===d.path?n.jsx("div",{className:"px-2 pb-1.5 pt-0.5",children:n.jsx(Hr,{placeholder:a("github.pr.askFilePlaceholder"),onSubmit:f=>{c(null),i(d.path,f)},onCancel:()=>c(null)})}):null]},d.path))})})}function If(e){const t=e.split("/");return t[t.length-1]||e}function Bh({title:e,value:t,tone:s}){const i=s==="success"?"bg-emerald-500":s==="warning"?"bg-amber-500":s==="danger"?"bg-red-500":"bg-muted-foreground";return n.jsxs("div",{className:"rounded-md border border-border bg-card px-3 py-2",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:e}),n.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[12px] font-medium",children:[n.jsx("span",{className:`size-1.5 rounded-full ${i}`}),t]})]})}function KN({meta:e,text:t,href:s}){return n.jsxs("a",{className:"block rounded border border-border bg-card px-2.5 py-2 text-[12px] transition-colors hover:bg-muted/60",href:s,rel:"noopener noreferrer",target:"_blank",children:[n.jsxs("span",{className:"mb-1 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx(Pr,{className:"size-3"}),e]}),n.jsx("span",{className:"line-clamp-2 whitespace-pre-wrap",children:t})]})}function OT(e,t){return e.state==="merged"?"github.pr.readiness.merged":e.state==="closed"?"github.pr.readiness.closed":e.draft?"github.pr.readiness.draft":e.mergeable===!1?"github.pr.readiness.blocked":t?.state==="failure"||t?.state==="error"?"github.pr.readiness.checksFailing":t?.state==="pending"?"github.pr.readiness.checksPending":e.mergeable===!0?"github.pr.readiness.ready":"github.pr.unknown"}function hte(e,t){const s=OT(e,t);return s==="github.pr.readiness.ready"?"success":s==="github.pr.readiness.blocked"||s==="github.pr.readiness.checksFailing"?"danger":s==="github.pr.readiness.draft"||s==="github.pr.readiness.checksPending"?"warning":"muted"}function PT(e){return e.some(t=>t.state==="CHANGES_REQUESTED")?"github.pr.review.changesRequested":e.some(t=>t.state==="APPROVED")?"github.pr.review.approved":e.some(t=>t.state==="COMMENTED")?"github.pr.review.commented":"github.pr.review.none"}function fte(e){const t=PT(e);return t==="github.pr.review.approved"?"success":t==="github.pr.review.changesRequested"?"danger":t==="github.pr.review.commented"?"warning":"muted"}function mte({pr:e}){const t=J(),{labelKey:s,dot:i,kind:a}=e.state==="merged"?{labelKey:"github.prState.merged",dot:"bg-violet-500",kind:"merged"}:e.state==="closed"?{labelKey:"github.prState.closed",dot:"bg-red-500",kind:"other"}:e.draft?{labelKey:"github.prState.draft",dot:"bg-muted-foreground",kind:"other"}:{labelKey:"github.prState.open",dot:"bg-emerald-500",kind:"open"};return n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${i}`}),a==="merged"?n.jsx(af,{className:"size-3"}):a==="open"?n.jsx(Vf,{className:"size-3"}):n.jsx(Cl,{className:"size-3"}),t(s)]})}function zT({label:e}){return n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",title:e.name,children:[n.jsx("span",{className:"size-2 shrink-0 rounded-sm",style:{backgroundColor:`#${e.color}`}}),n.jsx("span",{className:"truncate",children:e.name})]})}function pte({issues:e,loading:t,loadingMore:s,hasMore:i,error:a,selectedNumber:l,onSelect:c,onLoadMore:d}){const f=J();return t&&e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.issues.loading")}):a?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:a}):e.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:f("github.issues.empty")}):n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"divide-y divide-border",children:e.map(h=>n.jsx("li",{children:n.jsxs("button",{className:`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-muted/60 ${l===h.number?"bg-muted":""}`,onClick:()=>c(h.number),type:"button",children:[n.jsx(OM,{className:`mt-0.5 size-4 shrink-0 ${h.state==="open"?"text-emerald-500":"text-red-500"}`}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:h.title}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",h.number," · ",h.user.login," · ",f("github.issues.commentsCount",{count:h.comments})]})]}),h.labels.length>0?n.jsx("span",{className:"flex max-w-40 shrink-0 flex-wrap justify-end gap-x-2 gap-y-0.5",children:h.labels.slice(0,3).map(g=>n.jsx(zT,{label:g},g.name))}):null]})},h.number))}),n.jsx(h1,{hasMore:i,loading:s,onLoadMore:d})]})}const Ih=6,gte=6,bte=8;function vte(e,t,s,i){const a=Math.max(0,Math.min(gte,e/2,t/2)),l=Math.max(0,Math.min(bte,s-a,i-a));return[`M ${a} 0`,`H ${e-a}`,`A ${a} ${a} 0 0 1 ${e} ${a}`,`V ${t-i-a}`,`A ${a} ${a} 0 0 1 ${e-a} ${t-i}`,`H ${e-s+l}`,`A ${l} ${l} 0 0 0 ${e-s} ${t-i+l}`,`V ${t-a}`,`A ${a} ${a} 0 0 1 ${e-s-a} ${t}`,`H ${a}`,`A ${a} ${a} 0 0 1 0 ${t-a}`,`V ${a}`,`A ${a} ${a} 0 0 1 ${a} 0`,"Z"].join(" ")}function xte({value:e,onChange:t,placeholder:s,rows:i=3,action:a}){const l=J(),c=x.useRef(null),d=x.useRef(null),[f,h]=x.useState(null),[g,p]=x.useState({w:0,h:0});x.useLayoutEffect(()=>{const v=c.current,_=d.current;if(!v||!_)return;const S=()=>{h({w:v.clientWidth,h:v.clientHeight}),p({w:_.offsetWidth+Ih*2,h:_.offsetHeight+Ih*2})};S();const C=new ResizeObserver(S);return C.observe(v),C.observe(_),()=>C.disconnect()},[]);const b=f&&g.w&&g.h?vte(f.w,f.h,g.w,g.h):null;return n.jsxs("div",{className:"relative",ref:c,children:[n.jsx("textarea",{className:"peer block w-full resize-none bg-background px-3 pt-2 font-mono text-[12px] placeholder:text-muted-foreground focus:outline-none",onChange:v=>t(v.target.value),placeholder:s,rows:i,style:{clipPath:b?`path('${b}')`:void 0,paddingBottom:g.h||44},value:e}),f&&b?n.jsxs("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-visible text-border transition-colors peer-focus:text-foreground/40",fill:"none",height:f.h,viewBox:`0 0 ${f.w} ${f.h}`,width:f.w,children:[n.jsx("title",{children:l("github.commentBorderTitle")}),n.jsx("path",{d:b,stroke:"currentColor",strokeWidth:1})]}):null,n.jsx("div",{className:"absolute",ref:d,style:{bottom:Ih,right:Ih},children:a})]})}function yte({issue:e,comments:t,commentsLoading:s,commentError:i,submitting:a,onAddComment:l}){const c=J(),[d,f]=x.useState(""),[h,g]=x.useState(!1),{sendToAgent:p}=Ot(),{isPending:b,runOperation:v}=In(),_=e?`github:issue:${e.number}:comment`:"",S=a||(_?b(_):!1);x.useEffect(()=>{g(!1)},[e?.number]);function C(A){e&&(g(!1),p({prompt:eU(e,A),source:{type:"github-issue",label:`Issue #${e.number}`},label:`Issue #${e.number}: ${A}`}))}if(!e)return n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:c("github.issue.selectPrompt")});async function N(A){if(A.preventDefault(),!e)return;const j=d.trim();j&&(await v({key:_,label:c("github.issue.postingOperation",{number:e.number})},()=>l(j)),f(""))}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"group flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-semibold",children:e.title}),n.jsx(rr,{className:re("shrink-0",h&&"opacity-100"),label:c("github.issue.askLabel",{number:e.number}),onAsk:()=>g(A=>!A)}),n.jsx("a",{"aria-label":c("github.openOnGithub"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",children:n.jsx(Pr,{className:"size-3.5"})})]}),h?n.jsx("div",{className:"shrink-0 border-b border-border px-3 py-1.5",children:n.jsx(Hr,{placeholder:c("github.issue.askPlaceholder"),onSubmit:C,onCancel:()=>g(!1)})}):null,n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("div",{className:"space-y-3 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px]",children:[n.jsxs("span",{className:"text-[11px]",children:[n.jsx("span",{className:"text-muted-foreground",children:c("github.issue.author")}),n.jsx("span",{className:"font-medium",children:e.user.login})]}),n.jsxs("span",{className:"text-[11px]",children:[n.jsx("span",{className:"text-muted-foreground",children:c("github.issue.opened")}),n.jsx("span",{className:"font-medium",children:new Date(e.created_at).toLocaleDateString()})]}),e.labels.map(A=>n.jsx(zT,{label:A},A.name))]}),e.body?n.jsx(LT,{body:e.body}):n.jsx("p",{className:"text-[12px] text-muted-foreground italic",children:c("github.noDescription")}),s?n.jsx(im,{className:"justify-start",label:c("github.issue.loadingComments")}):n.jsx("div",{className:"space-y-2",children:t.map(A=>n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 p-3",children:[n.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[n.jsx("span",{className:"text-[11px] font-semibold",children:A.user.login}),n.jsx("span",{className:"text-[10px] text-muted-foreground",children:new Date(A.created_at).toLocaleDateString()})]}),n.jsx(l1,{content:A.body})]},A.id))})]})}),n.jsx("div",{className:"shrink-0 border-t border-border p-3",children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:A=>{N(A)},children:[n.jsx(xte,{action:n.jsx(Q,{disabled:!d.trim(),loading:S,loadingLabel:c("github.issue.posting"),size:"sm",type:"submit",children:c("github.issue.comment")}),onChange:f,placeholder:c("github.issue.addComment"),value:d}),i?n.jsx(Ze,{variant:"destructive",children:i}):null]})})]})}const YN=30,_te=4e3;function wte(e){return e.status==="in_progress"||e.status==="queued"}function XN(e){return e.map(t=>`${t.id}:${t.status}:${t.conclusion}`).join("|")}function ZN(e){return e.map(t=>`${t.id}:${t.status}:${t.conclusion}:`+t.steps.map(s=>`${s.number}:${s.status}:${s.conclusion}`).join(",")).join("|")}function Ste(e,t){if(e.length===0)return t;const s=new Map(t.map(c=>[c.id,c])),i=new Set(e.map(c=>c.id)),a=t.filter(c=>!i.has(c.id)),l=e.map(c=>s.get(c.id)??c);return[...a,...l]}function kte(e){const[t,s]=x.useState([]),[i,a]=x.useState(null),[l,c]=x.useState([]),[d,f]=x.useState(!0),[h,g]=x.useState(!1),[p,b]=x.useState(!1),[v,_]=x.useState(1),[S,C]=x.useState(!1),[N,A]=x.useState(null),[j,E]=x.useState(null);function T(){let F=!0;return f(!0),A(null),_(1),Hh(e,1).then(M=>{F&&(s(M),b(M.length===YN))}).catch(M=>{F&&A(M instanceof Error?M.message:String(M))}).finally(()=>{F&&f(!1)}),()=>{F=!1}}function L(){if(h||!p)return;const F=v+1;g(!0),Hh(e,F).then(M=>{s(z=>{const G=new Set(z.map(D=>D.id));return[...z,...M.filter(D=>!G.has(D.id))]}),b(M.length===YN),_(F)}).catch(M=>A(M instanceof Error?M.message:String(M))).finally(()=>g(!1))}const H=x.useCallback(()=>{Hh(e,1).then(F=>s(M=>{const z=Ste(M,F);return XN(M)===XN(z)?M:z})).catch(()=>{}),i&&bS(i).then(F=>c(M=>ZN(M)===ZN(F)?M:F)).catch(()=>{})},[e,i]);x.useEffect(T,[e]),x.useEffect(()=>{a(F=>F&&t.some(M=>M.id===F)?F:t[0]?.id??null)},[t]),x.useEffect(()=>{if(!i){c([]);return}let F=!0;return C(!0),E(null),bS(i).then(M=>{F&&c(M)}).catch(M=>{F&&E(M instanceof Error?M.message:String(M))}).finally(()=>{F&&C(!1)}),()=>{F=!1}},[i]);const P=t.some(wte);return x.useEffect(()=>{if(!P)return;const F=window.setInterval(()=>{document.visibilityState==="visible"&&H()},_te);return()=>window.clearInterval(F)},[P,H]),{runs:t,selectedRunId:i,jobs:l,loading:d,loadingMore:h,hasMore:p,jobsLoading:S,error:N,jobsError:j,loadMore:L,refresh:T,syncLatest:H,setSelectedRunId:a}}function BT(e){return e.conclusion==="failure"||e.conclusion==="timed_out"||e.conclusion==="cancelled"}function Cte({branch:e,onClearBranch:t}){const{runs:s,selectedRunId:i,jobs:a,loading:l,loadingMore:c,hasMore:d,jobsLoading:f,error:h,jobsError:g,loadMore:p,refresh:b,syncLatest:v,setSelectedRunId:_}=kte(e),S=J();Eo(v);const C=s.find(T=>T.id===i)??null,{sendToAgent:N}=Ot(),[A,j]=x.useState(null);function E(T,L){j(null),N({prompt:tU(T,L),source:{type:"github-run",label:S("github.actions.runLabel",{number:T.run_number})},label:S("github.actions.runInputLabel",{number:T.run_number,input:L??S("github.actions.fixDefault")})})}return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[13px] font-semibold",children:S("github.actions.title")}),e?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"shrink-0",children:S("github.actions.filteredTo")}),n.jsx("span",{className:"min-w-0 truncate font-mono",children:e}),t?n.jsx("button",{"aria-label":S("github.actions.clearFilter"),className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:t,title:S("github.actions.clearFilter"),type:"button",children:n.jsx(Vt,{className:"size-3"})}):null]}):null]}),n.jsxs(Q,{disabled:l,onClick:()=>{b()},size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{className:`mr-1 size-3.5 ${l?"animate-spin":""}`}),S("common.refresh")]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:h?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:h}):l&&s.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:S("github.actions.loadingRuns")}):s.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:S("github.actions.noRuns")}):n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(280px,380px)_minmax(0,1fr)] divide-x divide-border",children:[n.jsxs("div",{className:"min-h-0 overflow-auto",children:[n.jsx("ul",{className:"divide-y divide-border",children:s.map(T=>n.jsxs("li",{className:"group flex flex-col",children:[n.jsxs("div",{className:`flex items-center transition-colors hover:bg-muted/60 ${T.id===i?"bg-muted/70":""}`,children:[n.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-3 px-3 py-2.5 text-left",onClick:()=>_(T.id),type:"button",children:[n.jsx(Nte,{run:T}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-medium",children:T.name}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["#",T.run_number," · ",T.head_branch," · ",T.event," ·"," ",n.jsx("span",{title:new Date(T.created_at).toLocaleString(),children:pj(T.created_at)})]})]}),n.jsx(Ete,{run:T})]}),BT(T)?n.jsx(rr,{className:`mr-2 shrink-0 ${A===T.id?"opacity-100":""}`,label:S("github.actions.fixRunAi",{number:T.run_number}),onAsk:()=>j(L=>L===T.id?null:T.id)}):null]}),A===T.id?n.jsx("div",{className:"px-3 pb-2 pt-0.5",children:n.jsx(Hr,{onCancel:()=>j(null),onSubmit:L=>E(T,L),placeholder:S("github.actions.askPlaceholder")})}):null]},T.id))}),n.jsx(h1,{hasMore:d,loading:c,onLoadMore:p})]}),n.jsx(jte,{error:g,jobs:a,loading:f,onFix:T=>E(T),run:C})]})})]})}function Nte({run:e}){return e.status==="in_progress"||e.status==="queued"?n.jsx(Cl,{className:"size-4 shrink-0 animate-pulse text-amber-400"}):e.conclusion==="success"?n.jsx(Vf,{className:"size-4 shrink-0 text-emerald-500"}):e.conclusion==="failure"||e.conclusion==="timed_out"?n.jsx($x,{className:"size-4 shrink-0 text-red-500"}):n.jsx(Cl,{className:"size-4 shrink-0 text-zinc-400"})}function Ete({run:e}){const t=e.status==="completed"?e.conclusion??"completed":e.status,s=t==="success"?"bg-emerald-500":t==="failure"||t==="timed_out"?"bg-red-500":t==="in_progress"||t==="queued"?"bg-amber-500":"bg-muted-foreground";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),t]})}function jte({run:e,jobs:t,loading:s,error:i,onFix:a}){const l=J();return e?n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-[13px] font-semibold",children:e.name}),n.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:["Run #",e.run_number," · ",e.head_branch," · ",e.head_sha.slice(0,7)]})]}),BT(e)?n.jsxs(Q,{className:"shrink-0 gap-1",onClick:()=>a(e),size:"sm",title:l("github.actions.fixTitle"),type:"button",variant:"outline",children:[n.jsx(Xt,{className:"size-3.5"}),l("github.actions.fixWithAi")]}):null,n.jsx("a",{"aria-label":l("github.actions.openRun"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:e.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.actions.openRun"),children:n.jsx(Pr,{className:"size-3.5"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:i?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:i}):s?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.actions.loadingJobs")}):t.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:l("github.actions.noJobs")}):n.jsx("ul",{className:"divide-y divide-border",children:t.map(c=>n.jsxs("li",{className:"px-3 py-3",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[n.jsx(QN,{item:c}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium",children:c.name}),n.jsx("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:JN(c.started_at,c.completed_at)}),n.jsx("a",{"aria-label":l("github.actions.openJobAria",{name:c.name}),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",href:c.html_url,rel:"noopener noreferrer",target:"_blank",title:l("github.actions.openJob"),children:n.jsx(Pr,{className:"size-3.5"})})]}),c.steps.length?n.jsx("ol",{className:"space-y-1.5 pl-6",children:c.steps.map(d=>n.jsxs("li",{className:"flex items-center gap-2 text-[12px]",children:[n.jsx(QN,{item:d}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.name}),n.jsx("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:JN(d.started_at,d.completed_at)})]},`${c.id}:${d.number}`))}):n.jsx("p",{className:"pl-6 text-[12px] text-muted-foreground",children:l("github.actions.noSteps")})]},c.id))})})]}):n.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:l("github.actions.selectRun")})}function QN({item:e}){return e.status==="in_progress"||e.status==="queued"?n.jsx(Cl,{className:"size-3.5 shrink-0 animate-pulse text-amber-400"}):e.conclusion==="success"||e.conclusion==="skipped"?n.jsx(Vf,{className:"size-3.5 shrink-0 text-emerald-500"}):e.conclusion==="failure"||e.conclusion==="timed_out"||e.conclusion==="cancelled"?n.jsx($x,{className:"size-3.5 shrink-0 text-red-500"}):n.jsx(Cl,{className:"size-3.5 shrink-0 text-zinc-400"})}function JN(e,t){if(!e)return"-";const s=Date.parse(e),i=t?Date.parse(t):Date.now();if(!Number.isFinite(s)||!Number.isFinite(i)||i<s)return"-";const a=Math.max(0,Math.round((i-s)/1e3));if(a<60)return`${a}s`;const l=Math.floor(a/60),c=a%60;return c?`${l}m ${c}s`:`${l}m`}function Ate({onCreatePR:e,onViewRuns:t}){const s=J(),[i,a]=x.useState(null),[l,c]=x.useState(!0),[d,f]=x.useState(null);function h(){let p=!0;return c(!0),f(null),B7().then(b=>{p&&a(b)}).catch(b=>{p&&f(b instanceof Error?b.message:String(b))}).finally(()=>{p&&c(!1)}),()=>{p=!1}}x.useEffect(h,[]),Eo(()=>{h()});const g=x.useMemo(()=>[...i?.branches??[]].sort((b,v)=>{const _=tE(b,i),S=tE(v,i);return _-S||b.name.localeCompare(v.name)}),[i]);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-3 py-1.5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-[13px] font-semibold",children:s("github.tab.branches")}),n.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:i?.repository.full_name??s("github.selectedRepo")})]}),n.jsxs(Q,{disabled:l,onClick:()=>{h()},size:"sm",type:"button",variant:"outline",children:[n.jsx(_i,{className:`mr-1 size-3.5 ${l?"animate-spin":""}`}),s("common.refresh")]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?n.jsx("div",{className:"p-4 text-[12px] text-red-500",children:d}):l&&!i?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:s("github.branches.loading")}):g.length===0?n.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:s("github.branches.empty")}):n.jsx("ul",{className:"divide-y divide-border",children:g.map(p=>n.jsx(Tte,{branch:p,currentBranch:i?.currentBranch??null,defaultBranch:i?.defaultBranch??null,onCreatePR:e,onViewRuns:t},p.name))})})]})}function Tte({branch:e,defaultBranch:t,currentBranch:s,onCreatePR:i,onViewRuns:a}){const l=J(),c=e.name===t,d=e.name===s,f=!c;return n.jsxs("li",{className:"flex flex-wrap items-center gap-3 px-3 py-2.5",children:[n.jsx(_n,{className:"size-4 shrink-0 text-muted-foreground"}),n.jsxs("div",{className:"min-w-48 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[13px] font-medium",children:e.name}),c?n.jsx(eE,{label:l("github.branches.default"),tone:"success"}):null,d?n.jsx(eE,{label:l("github.branches.current"),tone:"warning"}):null,e.protected?n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx(CE,{className:"size-3"}),l("github.branches.protected")]}):null]}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:e.commit.sha.slice(0,7)})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[n.jsxs(Q,{onClick:()=>a(e.name),size:"sm",title:l("github.branches.viewRunsTitle",{name:e.name}),type:"button",variant:"outline",children:[n.jsx(zM,{className:"size-3.5"}),l("github.branches.viewRuns")]}),n.jsxs(Q,{disabled:!f,onClick:()=>i(e.name),size:"sm",title:f?l("github.branches.openPrTitle",{name:e.name}):l("github.branches.defaultNoPr"),type:"button",variant:"outline",children:[n.jsx(vE,{className:"size-3.5"}),l("github.branches.openPr")]})]})]})}function eE({label:e,tone:t}){const s=t==="success"?"bg-emerald-500":"bg-amber-500";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),e]})}function tE(e,t){return e.name===t?.currentBranch?0:e.name===t?.defaultBranch?1:e.protected?2:3}function Rte(){const e=J(),t=ste();let s;return t.loading||t.status==="checking"?s=n.jsx(im,{fill:!0,label:e("common.loading")}):t.status==="not_configured"?s=n.jsx(DT,{deviceFlowAvailable:t.deviceFlowAvailable,onSaved:t.refresh}):t.status==="auth_error"||t.status==="connection_error"?s=n.jsx(Mte,{token:t}):s=n.jsx(Dte,{token:t}),n.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-card/85",children:s})}function Mte({token:e}){const t=J(),[s,i]=x.useState(null);if(s)return n.jsx(DT,{deviceFlowAvailable:e.deviceFlowAvailable,initialMode:s,onSaved:e.refresh});const a=e.status==="auth_error";return n.jsx("div",{className:"flex h-full items-center justify-center p-8",children:n.jsxs("div",{className:"w-full max-w-lg space-y-4 rounded-md border border-border bg-card p-5",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(bm,{className:"size-5"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("h2",{className:"text-sm font-semibold",children:t("github.connFailed")}),n.jsx("p",{className:"text-[12px] text-muted-foreground",children:t(a?"github.tokenRejected":"github.cantValidate")})]}),n.jsx(IT,{label:t(a?"github.needsRelogin":"github.connProblem"),tone:a?"danger":"warning"})]}),e.error?n.jsx(Ze,{variant:"destructive",children:e.error}):null,n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(Q,{onClick:e.refresh,type:"button",variant:a?"outline":"default",children:[n.jsx(_i,{}),t("common.refresh")]}),n.jsx(Q,{onClick:()=>i(e.deviceFlowAvailable?"device-pending":"pat"),type:"button",variant:a?"default":"outline",children:t("github.reconnectGithub")}),n.jsx(Q,{onClick:()=>i("pat"),type:"button",variant:"outline",children:t("github.useToken")})]})]})})}function Dte({token:e}){const t=J(),[s,i]=wl("github:tab","prs"),[a,l]=wl("github:pr-state","open"),[c,d]=wl("github:issue-state","open"),[f,h]=x.useState(null),[g,p]=x.useState(null),[b,v]=x.useState(null),{isPending:_,runOperation:S}=In(),C=_("github:disconnect"),N=nte(a),A=ite(c);Eo(()=>{s==="prs"?N.refresh():s==="issues"&&A.refresh()});const j=L=>`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${L?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,E=L=>`rounded px-2 py-0.5 text-[10px] font-medium transition-colors ${L?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`;async function T(){v(null);try{await S({errorMessage:L=>L instanceof Error?L.message:String(L),key:"github:disconnect",label:t("github.disconnecting")},async()=>{await z7("github.com"),e.refresh()})}catch(L){v(L instanceof Error?L.message:String(L))}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card/95 px-3 py-1",children:[n.jsx("button",{className:j(s==="prs"),onClick:()=>i("prs"),type:"button",children:t("github.tab.prs")}),n.jsx("button",{className:j(s==="issues"),onClick:()=>i("issues"),type:"button",children:t("github.tab.issues")}),n.jsx("button",{className:j(s==="branches"),onClick:()=>i("branches"),type:"button",children:t("github.tab.branches")}),n.jsx("button",{className:j(s==="actions"),onClick:()=>i("actions"),type:"button",children:t("github.tab.actions")}),n.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[n.jsx(Lte,{token:e}),n.jsxs(Q,{onClick:e.refresh,size:"sm",title:t("github.recheckTitle"),type:"button",variant:"outline",children:[n.jsx(_i,{}),t("github.reconnect")]}),n.jsx(Q,{loading:C,loadingLabel:t("github.disconnecting"),onClick:()=>{T()},size:"sm",type:"button",variant:"outline",children:t("github.disconnect")})]}),s==="prs"?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:[n.jsx("button",{className:E(a==="open"),onClick:()=>l("open"),type:"button",children:t("github.open")}),n.jsx("button",{className:E(a==="closed"),onClick:()=>l("closed"),type:"button",children:t("github.closed")})]}),n.jsx(Q,{onClick:()=>h(""),size:"sm",type:"button",variant:"outline",children:t("github.newPr")})]}):s==="issues"?n.jsxs("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:[n.jsx("button",{className:E(c==="open"),onClick:()=>d("open"),type:"button",children:t("github.open")}),n.jsx("button",{className:E(c==="closed"),onClick:()=>d("closed"),type:"button",children:t("github.closed")})]}):null]}),b?n.jsx(Ze,{variant:"destructive",className:"m-3",children:b}):null,f!==null?n.jsx(Ote,{initialHead:f,onCreated:L=>{h(null),i("prs"),N.setSelectedNumber(L.number),N.refresh()},onCancel:()=>h(null)}):n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s==="prs"?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(0,1fr)_minmax(0,2fr)] divide-x divide-border",children:[n.jsx("div",{className:"min-h-0 overflow-auto",children:n.jsx(ote,{error:N.error,hasMore:N.hasMore,loading:N.loading,loadingMore:N.loadingMore,onLoadMore:N.loadMore,onSelect:N.setSelectedNumber,prs:N.prs,selectedNumber:N.selectedNumber})}),n.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:n.jsx(cte,{diff:N.diff,diffError:N.diffError,diffLoading:N.diffLoading,onMerged:()=>N.refresh(),pr:N.selectedPR})})]}):s==="issues"?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(0,1fr)_minmax(0,2fr)] divide-x divide-border",children:[n.jsx("div",{className:"min-h-0 overflow-auto",children:n.jsx(pte,{error:A.error,hasMore:A.hasMore,issues:A.issues,loading:A.loading,loadingMore:A.loadingMore,onLoadMore:A.loadMore,onSelect:A.setSelectedNumber,selectedNumber:A.selectedNumber})}),n.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:n.jsx(yte,{commentError:A.commentError,comments:A.comments,commentsLoading:A.commentsLoading,issue:A.selectedIssue,onAddComment:A.addComment,submitting:A.submitting})})]}):s==="branches"?n.jsx(Ate,{onCreatePR:L=>h(L),onViewRuns:L=>{p(L),i("actions")}}):n.jsx(Cte,{branch:g??void 0,onClearBranch:()=>p(null)})})]})}function Lte({token:e}){const t=J(),s=e.info?.repository?.full_name??(e.info?.user?`@${e.info.user.login}`:"GitHub");return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-r border-border pr-2",children:[n.jsx(bm,{className:"size-4 shrink-0 text-foreground"}),n.jsx(IT,{label:t("github.connected"),tone:"success"}),n.jsx("span",{className:"max-w-48 truncate font-mono text-[10px] text-muted-foreground",children:s})]})}function IT({label:e,tone:t}){const s=t==="success"?"bg-emerald-500":t==="danger"?"bg-red-500":"bg-amber-500";return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[n.jsx("span",{className:`size-1.5 rounded-full ${s}`}),e]})}function Ote({initialHead:e,onCreated:t,onCancel:s}){const i=J(),[a,l]=x.useState(""),[c,d]=x.useState(""),[f,h]=x.useState(""),[g,p]=x.useState("main"),[b,v]=x.useState(!1),[_,S]=x.useState(null),[C,N]=x.useState(!0),[A,j]=x.useState(!1),[E,T]=x.useState(null);x.useEffect(()=>{let F=!0;return N(!0),T(null),F7().then(M=>{F&&(S(M),l(M.title),d(M.body),h(e||M.head),p(M.base||M.suggestedBase||"main"),v(M.draft))}).catch(M=>{F&&T(M instanceof Error?M.message:String(M))}).finally(()=>{F&&N(!1)}),()=>{F=!1}},[e]);async function L(F){if(F.preventDefault(),!(!a.trim()||!f.trim()||!g.trim())){j(!0),T(null);try{const M=await U7({title:a.trim(),body:c.trim()||void 0,head:f.trim(),base:g.trim(),draft:b});t(M)}catch(M){T(M instanceof Error?M.message:String(M))}finally{j(!1)}}}const H="w-full rounded-md border border-border bg-background px-3 py-2 text-[13px] placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring",P=_?.warnings??[];return n.jsxs("form",{className:"flex min-h-0 flex-col gap-3 overflow-auto bg-muted/20 p-4",onSubmit:F=>{L(F)},children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{className:"text-[13px] font-semibold",children:i("github.branchToPr")}),n.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[_?.repository?.full_name??i("github.selectedRepo"),_?.currentBranch?` - ${_.currentBranch}`:""]})]}),n.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:i(C?"github.detectingBranch":"github.editableDraft")})]}),n.jsx(Pte,{template:_,loading:C}),P.length>0?n.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[12px] text-amber-700 dark:text-amber-300",children:P[0]}):null,n.jsx("input",{className:H,disabled:C,onChange:F=>l(F.target.value),placeholder:i("github.fieldTitle"),required:!0,value:a}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("label",{className:"space-y-1",children:[n.jsx("span",{className:"text-[10px] uppercase text-muted-foreground",children:i("github.head")}),n.jsx("input",{className:H,disabled:C,onChange:F=>h(F.target.value),placeholder:i("github.headBranch"),required:!0,value:f})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("span",{className:"text-[10px] uppercase text-muted-foreground",children:i("github.base")}),n.jsx("input",{className:H,disabled:C,onChange:F=>p(F.target.value),placeholder:i("github.baseBranch"),required:!0,value:g})]})]}),n.jsx("textarea",{className:`${H} resize-none`,disabled:C,onChange:F=>d(F.target.value),placeholder:i("github.descriptionOptional"),rows:7,value:c}),n.jsxs("label",{className:"flex items-center gap-2 text-[12px]",children:[n.jsx("input",{checked:b,className:"size-3.5",disabled:C,onChange:F=>v(F.target.checked),type:"checkbox"}),i("github.createAsDraft")]}),E?n.jsx(Ze,{variant:"destructive",children:E}):null,n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Q,{disabled:C||A||!a.trim()||!f.trim()||!g.trim(),type:"submit",children:i(A?"github.creating":"github.createPr")}),n.jsx(Q,{onClick:s,type:"button",variant:"outline",children:i("common.cancel")})]})]})}function Pte({template:e,loading:t}){const s=J(),i=e?.compare,a=i?.ciStatus,l=[{label:s("github.compare.base"),value:i?.base||e?.base||"main"},{label:s("github.compare.head"),value:i?.head||e?.head||"manual"},{label:s("github.compare.ahead"),value:t?"...":String(i?.aheadBy??0)},{label:s("github.compare.changed"),value:t?"...":String(i?.files.length??0)},{label:s("github.compare.ci"),value:a?`${a.state} (${a.totalCount})`:s("github.compare.unavailable")}];return n.jsxs("div",{className:"rounded-md border border-border bg-card px-3 py-2",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-[11px] font-medium text-foreground",children:s("github.compareSummary")}),i?.headSha?n.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:i.headSha.slice(0,7)}):null]}),n.jsx("div",{className:"grid grid-cols-5 gap-2",children:l.map(c=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate text-[10px] uppercase text-muted-foreground",children:c.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:c.value})]},c.label))}),i?.files.length?n.jsx("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:i.files.slice(0,4).map(c=>n.jsxs("span",{className:"max-w-52 truncate",children:[c.status," ",c.path]},`${c.status}:${c.path}`))}):null]})}function zte({data:e,docked:t,scopeAll:s,onScopeChange:i,onRefresh:a,onClose:l,onManage:c}){const d=J(),{error:f,success:h}=cs(),g=e.git.selectedRepository;async function p(S){l();try{await GE(S),i(!1),await a(),h(d("git.repo.switchedToast",{name:S}))}catch(C){f(C instanceof Error?C.message:String(C))}}function b(){l(),i(!0),h(d("app.showingAllProjects"))}const v=S=>re("grid h-8 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left transition-[background-color,width] duration-150 hover:bg-muted",t?"w-full":"w-12 group-hover/sidebar:w-full",S&&"bg-muted/60"),_=re("flex min-w-0 items-center gap-2 overflow-hidden whitespace-pre pr-2 text-xs transition duration-150",t?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100");return n.jsxs("div",{className:"mt-1 grid gap-0.5",children:[n.jsxs("button",{className:v(s),onClick:b,title:d("app.allProjects"),type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(rf,{className:"size-4 text-muted-foreground"})}),n.jsxs("span",{className:_,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:d("app.allProjects")}),s?n.jsx(Ys,{className:"size-3.5 shrink-0"}):null]})]}),e.config.gitRepositories.map(S=>{const C=!s&&S.name===g?.name;return n.jsxs("button",{className:v(C),onClick:()=>{p(S.name)},title:S.path,type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(Uf,{className:"size-4 text-muted-foreground"})}),n.jsxs("span",{className:_,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:S.name}),C?n.jsx(Ys,{className:"size-3.5 shrink-0"}):null]})]},S.name)}),n.jsxs("button",{className:re("grid h-8 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left text-muted-foreground transition-[background-color,color,width] duration-150 hover:bg-muted hover:text-foreground",t?"w-full":"w-12 group-hover/sidebar:w-full"),onClick:()=>{l(),c()},title:d("app.addManageProjects"),type:"button",children:[n.jsx("span",{className:"flex h-8 w-12 items-center justify-center",children:n.jsx(Vx,{className:"size-4"})}),n.jsx("span",{className:_,children:n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[d("app.addManageProjects"),"…"]})})]})]})}function Bte({data:e,docked:t,scopeAll:s,onScopeChange:i,onRefresh:a}){const l=J(),[c,d]=x.useState(!1),[f,h]=x.useState(!1),g=e.git.selectedRepository,p=s?l("app.allProjects"):g?.name??l("app.pickProject"),b=e.config.gitRepositories.length,v=s?l(b===1?"app.projectCountOne":"app.projectCountMany",{count:b}):g?e.git.status?.branch??g.path:l("app.setContext");return n.jsxs(n.Fragment,{children:[n.jsxs("button",{"aria-label":l("app.projectScope",{label:p}),className:re("relative grid h-11 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden rounded-md text-left transition-[background-color,width] duration-150 hover:bg-muted",t?"w-full":"w-12 group-hover/sidebar:w-full"),"aria-expanded":c,onClick:()=>d(_=>!_),title:l("app.projectScope",{label:p}),type:"button",children:[n.jsx("span",{className:"flex h-11 w-12 items-center justify-center",children:n.jsx("span",{className:"flex size-8 items-center justify-center rounded-lg border border-border bg-background text-[13px] font-semibold text-foreground",children:s?n.jsx(rf,{className:"size-4 text-muted-foreground"}):g?p.charAt(0).toUpperCase():n.jsx(Uf,{className:"size-4 text-muted-foreground"})})}),n.jsxs("span",{className:re("min-w-0 overflow-hidden whitespace-pre pr-8 transition duration-150",t?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100"),children:[n.jsx("span",{className:"block truncate text-[13px] font-semibold leading-tight",children:p}),n.jsx("span",{className:"block truncate text-[10px] leading-tight text-muted-foreground",children:v})]}),n.jsx(hn,{className:re("absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground transition-[opacity,transform] duration-150",t?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100",c&&"rotate-180")})]}),c?n.jsx(zte,{data:e,docked:t,onClose:()=>d(!1),onManage:()=>h(!0),onRefresh:a,onScopeChange:i,scopeAll:s}):null,f?n.jsx(Ite,{data:e,onClose:()=>h(!1),onRefresh:a,onScopeChange:i,scopeAll:s}):null]})}function Ite({data:e,onClose:t,onRefresh:s,onScopeChange:i,scopeAll:a}){const l=J(),[c,d]=x.useState("path"),[f,h]=x.useState(e.git.cwd),[g,p]=x.useState(""),[b,v]=x.useState(!1),[_,S]=x.useState(null),[C,N]=x.useState(!1),[A,j]=x.useState(e.git.cwd),E=e.git.selectedRepository,{error:T,success:L}=cs();async function H(D){try{await GE(D),i(!1),t(),await s(),L(l("git.repo.switchedToast",{name:D}))}catch(q){T(q instanceof Error?q.message:String(q))}}function P(){i(!0),t(),L(l("app.showingAllProjects"))}async function F(D){const q=D.trim();if(!q.startsWith("/")){const W=l("git.repo.absPathError");return S(W),T(W),!1}try{const W=kT(q);return await j7(W,q),S(null),await s(),L(l("git.repo.addedToast",{name:W})),!0}catch(W){const I=W instanceof Error?W.message:String(W);return S(I),T(I),!1}}async function M(D){try{await E7(D),await s(),L(l("git.repo.removedToast",{name:D}))}catch(q){T(q instanceof Error?q.message:String(q))}}async function z(D){D.preventDefault(),await F(f)&&t()}async function G(D){D.preventDefault();const q=g.trim();if(q){v(!0),S(null);try{const{name:W}=await A7(q);p(""),await s(),L(l("git.repo.clonedToast",{name:W})),t()}catch(W){const I=W instanceof Error?W.message:String(W);S(I),T(I)}finally{v(!1)}}}return Hi.createPortal(n.jsxs("div",{className:"fixed inset-0 z-[1000] grid place-items-center bg-black/35 px-4",onMouseDown:D=>{D.target===D.currentTarget&&t()},children:[n.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-xl",children:[n.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-3",children:[n.jsx(rf,{className:"size-4 text-muted-foreground"}),n.jsx("div",{className:"text-sm font-semibold",children:l("git.repo.projectsShort")}),n.jsx(We,{className:"h-5 px-1.5 text-[10px]",variant:"outline",children:e.config.gitRepositories.length}),n.jsx(Q,{"aria-label":l("git.repo.closeSwitcher"),className:"ml-auto size-7",onClick:t,size:"icon",variant:"ghost",children:n.jsx(Vt,{className:"size-4"})})]}),n.jsxs("div",{className:"max-h-80 overflow-auto",children:[n.jsxs("button",{className:re("grid w-full grid-cols-[1fr_auto] items-center gap-2 border-b border-border px-4 py-2.5 text-left transition-colors hover:bg-muted",a&&"bg-muted/70"),onClick:P,type:"button",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(rf,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-medium leading-tight",children:l("app.allProjects")}),n.jsx("span",{className:"block truncate text-[10px] leading-tight text-muted-foreground",children:l("app.allProjectsHint")})]})]}),a?n.jsx(Ys,{className:"size-3.5"}):n.jsx("span",{className:"size-3.5"})]}),e.config.gitRepositories.length?n.jsx("div",{className:"divide-y divide-border",children:e.config.gitRepositories.map(D=>{const q=!a&&D.name===E?.name;return n.jsxs("div",{className:re("group grid w-full grid-cols-[1fr_auto_auto] items-center gap-2 px-4 py-2 text-left transition-colors hover:bg-muted",q&&"bg-muted/70"),children:[n.jsxs("button",{className:"min-w-0 text-left",onClick:()=>{H(D.name)},type:"button",children:[n.jsx("span",{className:"block truncate text-sm font-medium leading-tight",children:D.name}),n.jsx("span",{className:"block truncate font-mono text-[10px] leading-tight text-muted-foreground",children:D.path})]}),q?n.jsx(Ys,{className:"size-3.5"}):n.jsx("span",{className:"size-3.5"}),n.jsx(Q,{"aria-label":l("git.repo.removeName",{name:D.name}),className:"size-6 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>{M(D.name)},size:"icon",title:l("git.repo.removeName",{name:D.name}),type:"button",variant:"ghost",children:n.jsx(Ii,{className:"size-3.5 text-destructive"})})]},D.name)})}):n.jsx("div",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:l("git.repo.noProjects")})]}),n.jsxs("div",{className:"border-t border-border bg-muted/20 p-3",children:[n.jsxs("div",{className:"mb-1.5 flex gap-1 text-[11px]",children:[n.jsxs("button",{className:re("flex items-center gap-1 rounded px-2 py-0.5 transition-colors",c==="path"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{d("path"),S(null)},type:"button",children:[n.jsx(Co,{className:"size-3"}),l("git.repo.localPath")]}),n.jsxs("button",{className:re("flex items-center gap-1 rounded px-2 py-0.5 transition-colors",c==="url"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{d("url"),S(null)},type:"button",children:[n.jsx(vu,{className:"size-3"}),l("git.repo.cloneUrl")]})]}),c==="path"?n.jsxs("form",{className:"flex gap-1.5",onSubmit:z,children:[n.jsx(pt,{"aria-label":l("git.repo.pasteAbsPath"),className:"h-7 flex-1 px-2 font-mono text-[11px]",onChange:D=>{h(D.target.value),S(null)},placeholder:"/absolute/path",value:f}),n.jsxs(Q,{className:"h-7 px-2 text-[11px]",size:"sm",type:"submit",children:[n.jsx(ms,{className:"size-3"}),l("common.add")]}),n.jsx(Q,{"aria-label":l("git.repo.browseAdd"),className:"h-7 px-2",onClick:()=>{S(null),j(e.git.cwd),N(!0)},size:"sm",type:"button",variant:"outline",children:n.jsx(Vx,{className:"size-3"})})]}):n.jsxs("form",{className:"flex gap-1.5",onSubmit:G,children:[n.jsx(pt,{"aria-label":l("git.repo.remoteUrl"),className:"h-7 flex-1 px-2 font-mono text-[11px]",onChange:D=>{p(D.target.value),S(null)},placeholder:"https://… or git@host:owner/repo.git",value:g}),n.jsxs(Q,{className:"h-7 px-2 text-[11px]",disabled:b||!g.trim(),size:"sm",type:"submit",children:[n.jsx(vu,{className:"size-3"}),l(b?"git.repo.cloning":"git.repo.clone")]})]}),_?n.jsx("div",{className:"mt-1.5 truncate text-[10px] text-destructive",children:_}):null,c==="url"?n.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:l("git.repo.cloneHint")}):null]})]}),C?n.jsx(CT,{confirmLabel:l("git.repo.addProject"),errorMessage:_,initialPath:e.git.cwd,selectedPath:A,title:l("git.repo.addProjectTitle"),onCancel:()=>N(!1),onSelect:j,onUse:async()=>{await F(A)&&(N(!1),t())}}):null]}),document.body)}function Hte({ahead:e=0,behind:t=0,branches:s,currentBranch:i,disabled:a,onRefresh:l,upstream:c}){const d=J(),[f,h]=x.useState(!1),[g,p]=x.useState(""),[b,v]=x.useState(null),[_,S]=x.useState(null),[C,N]=x.useState(null),A=s.filter(M=>!M.remote),j=s.filter(M=>M.remote);async function E(M,z){v(M),N(null),S(null);try{await z(),await l()}catch(G){N(G instanceof Error?G.message:String(G))}finally{v(null)}}async function T(M){await E(`switch:${M}`,async()=>{await zi("/api/git/branches/switch",{name:M}),h(!1)})}async function L(){await E("fetch",async()=>{await zi("/api/git/fetch",{}),S(d("git.branch.fetched"))})}async function H(){await E("push",async()=>{const M=await tm();S(M.setUpstream?d("git.branch.pushedSetUpstream",{branch:M.branch}):d("git.branch.pushed",{branch:M.branch}))})}const P=!!i&&(e>0||!c&&t===0);async function F(M){M.preventDefault();const z=g.trim();if(!z){N(d("git.branch.nameRequired"));return}await E("create",async()=>{await zi("/api/git/branches",{name:z}),p(""),h(!1)})}return n.jsxs("div",{className:"fixed bottom-12 right-4 z-50 flex items-end",children:[f?n.jsxs("div",{"aria-label":d("git.branch.switchAria"),className:"mb-11 w-[min(460px,calc(100vw-2rem))] rounded-lg border border-border bg-card shadow-xl",role:"dialog",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border p-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_n,{className:"size-4 text-muted-foreground"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:i||d("git.branch.branches")})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[P?n.jsxs(Q,{"aria-label":d("git.branch.pushAria"),className:"gap-1.5 px-2 text-xs",disabled:a||b!==null,onClick:()=>{H()},size:"sm",title:c?d("git.branch.pushCountTo",{ahead:e,upstream:c}):d("git.branch.pushSetUpstream"),type:"button",variant:"default",children:[n.jsx(Qf,{className:re("size-3.5",b==="push"&&"animate-pulse")}),d("git.branch.push"),e>0?` ${e}`:""]}):null,n.jsx(Q,{"aria-label":d("git.branch.fetchAria"),disabled:a||b!==null,onClick:()=>{L()},size:"icon",title:d("git.branch.fetchAria"),type:"button",variant:"ghost",children:n.jsx(_i,{className:re(b==="fetch"&&"animate-spin")})}),n.jsx(Q,{"aria-label":d("git.branch.closeAria"),onClick:()=>h(!1),size:"icon",type:"button",variant:"ghost",children:n.jsx(Vt,{})})]})]}),n.jsx("div",{className:"max-h-72 overflow-auto",children:s.length?n.jsxs(n.Fragment,{children:[n.jsx(sE,{branches:A,busy:b!==null,disabled:a,empty:d("git.branch.noLocal"),label:d("git.branch.sectionLocal"),onSwitch:T}),n.jsx(sE,{branches:j,busy:b!==null,disabled:a,empty:d("git.branch.noRemote"),label:d("git.branch.sectionRemote"),onSwitch:T})]}):n.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:d("git.branch.noneFound")})}),n.jsxs("div",{className:"border-t border-border p-3",children:[n.jsxs("form",{className:"grid gap-2 sm:grid-cols-[1fr_auto]",onSubmit:F,children:[n.jsx(pt,{"aria-label":d("git.branch.newNameAria"),disabled:a||b!==null,onChange:M=>{p(M.target.value),N(null),S(null)},placeholder:"feature/new-work",value:g}),n.jsxs(Q,{disabled:a||b!==null,type:"submit",children:[n.jsx(D6,{}),d("git.branch.create")]})]}),C||_?n.jsx(Ze,{className:"mt-3 px-3 py-2 text-xs",variant:C?"destructive":"muted",children:C??_}):null]})]}):null,n.jsxs(Q,{className:"h-8 max-w-[260px] gap-2 rounded-md shadow-lg",disabled:a,onClick:()=>h(M=>!M),size:"sm",title:d("git.branch.switchAria"),type:"button",variant:"default",children:[n.jsx(_n,{className:"size-4"}),n.jsx("span",{className:"truncate font-mono text-xs",children:i||d("git.branch.noBranch")}),i&&(e>0||t>0)?n.jsxs("span",{className:"flex items-center gap-1 font-mono text-[11px] tabular-nums",title:c?d("git.branch.aheadBehindUpstream",{ahead:e,behind:t,upstream:c}):d("git.branch.aheadBehind",{ahead:e,behind:t}),children:[t>0?n.jsxs("span",{className:"flex items-center",children:[n.jsx(Hf,{className:"size-3"}),t]}):null,e>0?n.jsxs("span",{className:"flex items-center",children:[n.jsx($f,{className:"size-3"}),e]}):null]}):null,n.jsx(hn,{className:re("size-4 transition-transform",f&&"rotate-180")})]})]})}function sE({branches:e,busy:t,disabled:s,empty:i,label:a,onSwitch:l}){const c=J();return n.jsxs("section",{children:[n.jsx("div",{className:"border-b border-border bg-muted/60 px-3 py-1.5 text-[11px] font-semibold uppercase text-muted-foreground",children:a}),e.length?e.map(d=>n.jsxs("button",{className:re("grid w-full grid-cols-[1fr_auto] items-center gap-2 border-b border-border px-3 py-2 text-left text-sm last:border-b-0 hover:bg-muted",d.current&&"bg-muted/70"),disabled:s||t||d.current,onClick:()=>{l(d.name)},type:"button",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate font-medium",children:d.name}),d.upstream?n.jsx("span",{className:"block truncate font-mono text-[11px] text-muted-foreground",children:c("git.branch.tracks",{upstream:d.upstream})}):null]}),n.jsx(We,{variant:d.current?"success":d.remote?"outline":"secondary",children:d.current?c("git.branch.tagCurrent"):d.remote?c("git.branch.tagRemote"):c("git.branch.tagLocal")})]},`${d.remote?"remote":"local"}:${d.name}`)):n.jsx("div",{className:"border-b border-border px-3 py-3 text-sm text-muted-foreground",children:i})]})}function $te(){const e=J(),[,t]=NA(),s=xY(),i=x.useRef(null),a=x.useCallback(()=>{const l=s==="dark"?"light":"dark",c=i.current,d=document;if(!c||!d.startViewTransition||window.matchMedia("(prefers-reduced-motion: reduce)").matches){t(l);return}const f=c.getBoundingClientRect(),h=f.left+f.width/2,g=f.top+f.height/2,p=Math.hypot(Math.max(h,window.innerWidth-h),Math.max(g,window.innerHeight-g));d.startViewTransition(()=>{t(l)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${g}px)`,`circle(${p}px at ${h}px ${g}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},[s,t]);return n.jsxs("button",{ref:i,type:"button",onClick:a,title:e(s==="dark"?"action.toLight":"action.toDark"),"aria-label":e("action.theme"),className:xf(),children:[n.jsx("span",{className:yf(),children:s==="dark"?n.jsx(_8,{}):n.jsx(CD,{})}),n.jsx("span",{className:_f(),children:e("action.theme")})]})}function Fte(){const e=J();return Ls()?n.jsxs("div",{className:"flex items-center justify-between h-8 bg-background border-b border-border select-none",style:{WebkitAppRegion:"drag"},onMouseDown:()=>H8(),children:[n.jsx("span",{className:"px-3 text-xs font-medium text-muted-foreground",children:"NoMoreIDE"}),n.jsxs("div",{className:"flex items-center",style:{WebkitAppRegion:"no-drag"},children:[n.jsx("button",{type:"button",onClick:z8,className:"h-8 w-10 flex items-center justify-center hover:bg-muted transition-colors","aria-label":e("common.minimize"),children:n.jsx(_E,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:B8,className:"h-8 w-10 flex items-center justify-center hover:bg-muted transition-colors","aria-label":e("common.maximize"),children:n.jsx(Ta,{className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:I8,className:"h-8 w-10 flex items-center justify-center hover:bg-destructive hover:text-destructive-foreground transition-colors","aria-label":e("common.close"),children:n.jsx(Vt,{className:"h-3 w-3"})})]})]}):null}const Ute=300;function qte(){const{operations:e}=In(),[t,s]=x.useState(!1),[i,a]=x.useState(!1),l=x.useId(),c=J();if(x.useEffect(()=>{if(e.length===0){s(!1),a(!1);return}const h=Math.min(...e.map(({startedAt:b})=>b)),g=Math.max(0,Ute-(Date.now()-h));if(g===0){s(!0);return}s(!1);const p=window.setTimeout(()=>s(!0),g);return()=>window.clearTimeout(p)},[e]),!t||e.length===0)return null;const d=e.length>1,f=d?c("operation.multiple",{count:e.length}):e[0].label;return n.jsxs("aside",{"aria-live":"polite",className:"rounded-lg border border-border bg-card px-3 py-2 text-card-foreground shadow-sm transition-all motion-reduce:transition-none",role:"status",children:[n.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[n.jsx(nm,{size:"sm"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:f}),d?n.jsx(Q,{"aria-controls":l,"aria-expanded":i,"aria-label":c(i?"operation.hideDetails":"operation.showDetails"),onClick:()=>a(h=>!h),size:"icon-sm",type:"button",variant:"ghost",children:n.jsx(hn,{className:re("transition-transform motion-reduce:transition-none",i&&"rotate-180")})}):null]}),d&&i?n.jsx("ul",{className:"mt-2 space-y-1 border-t border-border pt-2",id:l,children:e.map(h=>n.jsxs("li",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-primary"}),n.jsx("span",{className:"truncate",children:h.label})]},h.id))}):null]})}const HT={services:"/",docker:"/docker",git:"/git",github:"/github",workflows:"/workflows",errors:"/errors",database:"/database",terminal:"/terminal",agent:"/agent","agent-env":"/agent-env",settings:"/settings"},Gte={services:"nav.services",docker:"nav.docker",git:"nav.git",github:"nav.github",workflows:"nav.workflows",errors:"nav.errors",database:"nav.database",terminal:"nav.terminal",agent:"pageTitle.agent","agent-env":"pageTitle.agentEnv",settings:"nav.settings"},Vte=Object.entries(HT).filter(([,e])=>e!=="/").sort(([,e],[,t])=>t.length-e.length);function Wte(e){for(const[t,s]of Vte)if(e.startsWith(s))return t;return"services"}const Kte=[{labelKey:"nav.section.run",items:[{page:"services",labelKey:"nav.services",icon:n.jsx(Zf,{})},{page:"docker",labelKey:"nav.docker",icon:n.jsx(Fx,{})},{page:"errors",labelKey:"nav.errors",icon:n.jsx(Au,{})},{page:"terminal",labelKey:"nav.terminal",icon:n.jsx(Br,{})}]},{labelKey:"nav.section.code",items:[{page:"git",labelKey:"nav.git",icon:n.jsx(_n,{})},{page:"github",labelKey:"nav.github",icon:n.jsx(bm,{})},{page:"workflows",labelKey:"nav.workflows",icon:n.jsx(of,{})}]},{labelKey:"nav.section.data",items:[{page:"database",labelKey:"nav.database",icon:n.jsx(si,{})}]},{labelKey:"nav.section.agent",items:[{page:"agent",labelKey:"nav.agentConsole",icon:n.jsx(Ff,{})},{page:"agent-env",labelKey:"nav.agentEnv",icon:n.jsx(Tu,{})}]}];function Yte(e=!1){return re("group/sidebar hidden h-full shrink-0 overflow-x-hidden overflow-y-auto border-r border-border bg-card/85 py-4 backdrop-blur transition-[width,padding] duration-200 md:flex md:flex-col",e?"w-64 px-4":"w-16 px-2 hover:w-64 hover:px-4")}function Xte(e,t=!1){return re("relative grid h-10 grid-cols-[48px_minmax(0,1fr)] items-center justify-start gap-0 overflow-hidden rounded-md px-0 text-sm font-medium transition-[background-color,color,width] duration-150",t?"w-full":"w-12 group-hover/sidebar:w-full",e?"bg-primary text-primary-foreground hover:bg-primary/90":"hover:bg-muted")}function Zte(e=!1,t=!1){return re("min-w-0 overflow-hidden text-left text-current transition duration-150 whitespace-pre",e?"translate-x-1 opacity-100":"opacity-0 group-hover/sidebar:translate-x-1 group-hover/sidebar:opacity-100",t?"pr-10":"pr-3")}function Qte(e=!1){return re("flex h-10 w-12 items-center justify-center text-current transition-transform duration-150 [&_svg]:size-5",e?"translate-x-0":"-translate-x-px group-hover/sidebar:translate-x-0")}function Jte({docked:e,onToggleDock:t}){return n.jsxs("div",{className:re("mt-auto flex h-10 min-w-0 items-center overflow-hidden border-t border-border/60 text-[11px] text-muted-foreground transition-[height,opacity,width] duration-150",e?"w-full justify-start opacity-100":"w-12 justify-center group-hover/sidebar:w-full group-hover/sidebar:justify-start group-hover/sidebar:opacity-100"),children:[n.jsxs("span",{className:re("flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-pre transition-[opacity,width] duration-150",e?"flex-1 opacity-100":"w-0 flex-none opacity-0 group-hover/sidebar:w-auto group-hover/sidebar:flex-1 group-hover/sidebar:opacity-100"),children:[n.jsx("span",{children:"Made with"}),n.jsx(I6,{"aria-label":"love",className:"size-3 shrink-0 fill-red-500 text-red-500"}),n.jsx("span",{children:"by Robert Wang"}),n.jsx("a",{"aria-label":"Robert Wang on LinkedIn",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-[#0A66C2]",href:"https://www.linkedin.com/in/robert-wang-cs/",rel:"noopener noreferrer",target:"_blank",title:"LinkedIn",children:n.jsxs("svg",{className:"size-3 fill-current",role:"img",viewBox:"0 0 24 24",children:[n.jsx("title",{children:"LinkedIn"}),n.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.063 2.063 0 1 1 0-4.126 2.063 2.063 0 0 1 0 4.126zM7.119 20.452H3.554V9h3.565v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.225 0z"})]})})]}),n.jsx("button",{"aria-label":e?"Undock sidebar":"Dock sidebar","aria-pressed":e,className:re("flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4",e?"ml-auto bg-muted text-foreground":"group-hover/sidebar:ml-auto"),onClick:t,title:e?"Undock sidebar":"Dock sidebar",type:"button",children:e?n.jsx(MD,{}):n.jsx(LD,{})})]})}function ese({className:e}){return n.jsxs("div",{className:re("min-w-0",e),children:[n.jsxs("div",{className:"flex items-baseline gap-1.5",children:[n.jsx("div",{className:"text-sm font-semibold",children:"NoMoreIDE"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:["v","0.1.88"]})]}),n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"127.0.0.1 console"})]})}function tse({syncLocation:e=!0}={}){return n.jsx(EY,{children:n.jsx(pF,{children:n.jsx(nse,{syncLocation:e})})})}function sse({projectPath:e,selectProject:t}){return x.useEffect(()=>{t(e)},[e,t]),null}function nse({syncLocation:e}){const t=J(),[s,i]=x.useState(()=>e?Wte(window.location.pathname):"services"),[a,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(null),[g,p]=x.useState(0),[b,v]=x.useState(null),[_,S]=x.useState(!0),{error:C,message:N,success:A}=cs(),{ui:j,updateUi:E,selectProject:T}=xm(),L=j.sidebarDocked,H=j.projectScope==="all",P=x.useCallback($=>E({projectScope:$?"all":"project"}),[E]),F=GU(),M=x.useCallback(async($={})=>{$.silent||S(!0),v(null);try{l(await l9()),$.notify&&A(t("app.dashboardRefreshed"))}catch(me){const ee=me instanceof Error?me.message:String(me);v(ee),C(ee)}finally{S(!1)}},[C,A,t]),z=x.useCallback(()=>{M({notify:!0}),F.runActive()},[M,F]);x.useEffect(()=>{M()},[M]),x.useEffect(()=>{function $(){document.visibilityState==="visible"&&(M({silent:!0}),F.runActive())}const me=window.setInterval($,5e3);return window.addEventListener("focus",$),document.addEventListener("visibilitychange",$),()=>{window.clearInterval(me),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$)}},[s,M,F.runActive]),x.useEffect(()=>{if(!e)return;const $=HT[s];window.location.pathname!==$&&window.history.pushState(null,"",$)},[s,e]);const G=!H&&a?.git.selectedRepository||null,D=x.useMemo(()=>a&&G?DY(a,G):a,[a,G]),q=x.useMemo(()=>G&&D?new Set(D.config.services.map($=>$.name)):null,[G,D]),W=x.useMemo(()=>D?Object.values(D.runtime.services).filter($=>$.state==="running").length:0,[D]),I=a?.git.selectedRepository?.name??a?.git.cwd??"no-git-repository",Y=a?.git.selectedRepository?.path??null;return n.jsxs(RF,{children:[n.jsx(sse,{projectPath:Y,selectProject:T}),n.jsx(VU,{value:F,children:n.jsx(oG,{onRefresh:()=>{M({silent:!0})},children:n.jsx(lG,{children:n.jsxs("div",{className:"flex flex-col h-screen overflow-hidden",children:[n.jsx(Fte,{}),n.jsxs("div",{className:"flex-1 overflow-hidden pb-9",children:[n.jsxs("div",{className:"mx-auto flex h-full max-w-[1500px]",children:[n.jsxs("aside",{className:Yte(L),children:[n.jsxs("div",{className:re("grid h-12 grid-cols-[48px_minmax(0,1fr)] items-center overflow-hidden transition-[width] duration-150",L?"w-full":"w-12 group-hover/sidebar:w-full"),children:[n.jsx("div",{className:"flex size-12 items-center justify-center",children:n.jsx("div",{className:"flex size-9 items-center justify-center overflow-hidden rounded-md bg-primary text-primary-foreground",children:n.jsxs("svg",{"aria-label":"NoMoreIDE",className:"size-6",fill:"none",role:"img",viewBox:"0 0 64 64",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M5 17C5 13.69 7.69 11 11 11H25L31 17H53C56.31 17 59 19.69 59 23V53C59 56.31 56.31 59 53 59H11C7.69 59 5 56.31 5 53V17Z",fill:"currentColor"}),n.jsx("path",{d:"M22 31L30 39L22 47",stroke:"hsl(var(--primary))",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"4.5"}),n.jsx("path",{d:"M36 47H48",stroke:"hsl(var(--primary))",strokeLinecap:"round",strokeWidth:"4.5"})]})})}),n.jsx(ese,{className:re("min-w-0 translate-x-1 overflow-hidden transition-opacity duration-200",L?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100")})]}),a?n.jsx("div",{className:"mt-3 border-b border-border/60 pb-2",children:n.jsx(Bte,{data:a,docked:L,onRefresh:()=>M({silent:!0}),onScopeChange:P,scopeAll:H})}):null,n.jsx("nav",{className:"mt-2 flex-1 content-start overflow-y-auto overflow-x-hidden",children:Kte.map(($,me)=>n.jsxs("div",{className:re(me>0&&"mt-2 border-t border-border/60 pt-2"),children:[n.jsx(ise,{docked:L,label:t($.labelKey)}),n.jsx("div",{className:"grid gap-0.5",children:$.items.map(ee=>n.jsx(nE,{active:s===ee.page,badge:ee.page==="services"?W:void 0,docked:L,icon:ee.icon,label:t(ee.labelKey),onClick:()=>i(ee.page)},ee.page))})]},$.labelKey))}),n.jsx("div",{className:"mb-1 border-t border-border/60 pt-1",children:n.jsx(nE,{active:s==="settings",docked:L,icon:n.jsx(kE,{}),label:t("nav.settings"),onClick:()=>i("settings")})}),n.jsx(Jte,{docked:L,onToggleDock:()=>E({sidebarDocked:!L})})]}),n.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col px-0 py-0",children:[n.jsxs("header",{className:re("relative z-40 flex shrink-0 flex-wrap items-center justify-between gap-3 border border-border bg-card/90 px-4 py-3 backdrop-blur","border-x-0 border-t-0 border-b"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(PD,{className:"size-4 text-muted-foreground md:hidden"}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:t(Gte[s])}),n.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:s==="git"||s==="github"?a?.git.selectedRepository?.name??a?.git.cwd??t("app.localWorkspace"):G?.name??t("app.allProjects")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[b?n.jsx(We,{variant:"danger",children:b}):null,n.jsxs("div",{"aria-label":"Dashboard quick actions",className:"flex items-center gap-1 rounded-lg border border-border bg-background p-px",role:"toolbar",children:[n.jsxs("button",{"aria-label":t("action.refresh"),className:xf(),onClick:z,title:t("action.refreshTitle"),type:"button",children:[n.jsx("span",{className:yf(),children:n.jsx(_i,{className:re(_&&"animate-spin")})}),n.jsx("span",{className:_f(),children:t("action.refresh")})]}),n.jsx($te,{}),n.jsxs("a",{"aria-label":t("action.docsTitle"),className:xf(),href:"https://www.nomoreide.com/docs",rel:"noreferrer",target:"_blank",title:t("action.docsTitle"),children:[n.jsx("span",{className:yf(),children:n.jsx(oE,{})}),n.jsx("span",{className:_f(),children:t("action.docs")})]}),a?n.jsx(Fq,{data:a}):null]})]})]}),n.jsx("div",{className:"relative z-30 shrink-0 px-4 pt-2",children:n.jsx(qte,{})}),a?n.jsx(XZ,{data:a,onOpenService:$=>{q&&!q.has($)&&(P(!0),N({text:t("app.serviceOutsideScope")})),d($),i("services"),M({silent:!0})}}):null,_&&!a?n.jsx(Ze,{variant:"muted",children:t("app.loading")}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[D&&s==="services"?n.jsx($Z,{data:D,onRefresh:M,focusService:c,onServiceFocused:()=>d(null),scopeName:G?.name??null}):null,s==="docker"?n.jsx(YZ,{}):null,a&&s==="git"?n.jsx(Aee,{data:a,onRefresh:()=>{M({silent:!0})}}):null,s==="github"?n.jsx(Rte,{},I):null,s==="workflows"?n.jsx(zee,{}):null,s==="agent"?n.jsx(qU,{focusChanges:g,onOpenAgentEnv:()=>i("agent-env")}):null,s==="agent-env"?n.jsx(gq,{}):null,s==="errors"?n.jsx(EX,{inScope:q?$=>q.has($):void 0,onReviewChanges:()=>{p($=>$+1),i("agent")}}):null,s==="database"?n.jsx(aX,{projects:a?.config.gitRepositories??[],scopePath:G?.path??null,staged:f,onStageConsumed:()=>h(null)}):null,s==="terminal"?n.jsx(sQ,{}):null,s==="settings"?n.jsx(vX,{activeProject:a?.git.selectedRepository??null,onNavigate:$=>i($)}):null]})]})]}),a&&s==="git"?n.jsx(Hte,{ahead:a.git.status?.ahead??0,behind:a.git.status?.behind??0,branches:a.git.branches,currentBranch:a.git.status?.branch||void 0,disabled:!a.git.status,onRefresh:M,upstream:a.git.status?.upstream}):null,n.jsx(RY,{currentPage:s,git:a?.git,onNavigate:$=>i($),onGitRefresh:()=>{M({silent:!0})}})]})]})})})})]})}function ise({docked:e,label:t}){return n.jsx("div",{className:"flex h-5 items-center overflow-hidden px-3",children:n.jsx("span",{className:re("whitespace-pre text-[10px] font-semibold uppercase tracking-widest text-muted-foreground transition-opacity duration-150",e?"opacity-100":"opacity-0 group-hover/sidebar:opacity-100"),children:t})})}function nE({active:e,badge:t,docked:s,icon:i,label:a,onClick:l}){const c=t!==void 0&&t>0;return n.jsxs(Q,{"aria-label":a,title:a,className:Xte(e,s),variant:"ghost",onClick:l,type:"button",children:[n.jsx("span",{className:Qte(s),children:i}),n.jsx("span",{className:Zte(s,c),children:a}),t!==void 0&&t>0?n.jsx(We,{appearance:t>0?"solid":"outline",className:re("min-w-6 justify-center px-1.5 font-mono shadow-none",e?"border-primary-foreground/40 bg-primary-foreground/15 text-primary-foreground dark:border-primary-foreground/40 dark:bg-primary-foreground/15 dark:text-primary-foreground":t>0?"":"border-border bg-background text-muted-foreground","absolute right-1.5 top-1.5 h-4 min-w-4 rounded-full px-1 text-[10px] leading-none shadow-none group-hover/sidebar:right-2 group-hover/sidebar:top-1/2 group-hover/sidebar:-translate-y-1/2 group-hover/sidebar:text-xs",s&&"right-2 top-1/2 -translate-y-1/2 text-xs"),size:"small",variant:t>0?"success":"outline",children:t}):null]})}rE.createRoot(document.getElementById("root")).render(n.jsx(x.StrictMode,{children:n.jsx(tse,{})}));export{n as j,x as r};
|