@pi-chamber/web 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/bin/cli.js +5 -2
  2. package/bin/cli.test.js +44 -0
  3. package/bin/lib/DOCUMENTATION.md +5 -5
  4. package/bin/lib/cli-args.js +19 -4
  5. package/bin/lib/commands-lifecycle.js +14 -0
  6. package/bin/lib/commands-logs.js +2 -1
  7. package/bin/lib/commands-serve.js +166 -2
  8. package/bin/lib/commands-tunnel.js +21 -0
  9. package/bin/lib/commands-update.js +97 -33
  10. package/bin/lib/commands-update.test.js +96 -1
  11. package/dist/assets/{DiagramEditor-DerMrS6m.js → DiagramEditor-CcbnMl1H.js} +1 -1
  12. package/dist/assets/{DiagramView-DdipXAq8.js → DiagramView-DTW5jwK3.js} +1 -1
  13. package/dist/assets/DiffView-CZyHHAOB.js +18 -0
  14. package/dist/assets/{FilesView-BXp0yc0j.js → FilesView-BJYLFR3H.js} +3 -3
  15. package/dist/assets/GitView-Cg_5UU7E.js +8 -0
  16. package/dist/assets/{JsonTreeView-CxXRXXzk.js → JsonTreeView-GTdKGEdy.js} +1 -1
  17. package/dist/assets/{MarkdownRendererImpl-DNZQgQua.js → MarkdownRendererImpl-WqBwxlso.js} +1 -1
  18. package/dist/assets/{PatchDiff-B_NFEIX7.js → PatchDiff-BRi23N1l.js} +1 -1
  19. package/dist/assets/{SessionSwitcherContent-Q4P2TGBr.js → SessionSwitcherContent-7VAU5pwZ.js} +1 -1
  20. package/dist/assets/{SessionSwitcherDropdown-Cgw2mQIO.js → SessionSwitcherDropdown-BslRtccE.js} +2 -2
  21. package/dist/assets/{SessionUnreadDot-BxtTkvHB.js → SessionUnreadDot-1nV0Z2ZA.js} +1 -1
  22. package/dist/assets/SettingsView-UIaAyjTo.js +2 -0
  23. package/dist/assets/{SettingsWindow-BEjHL1ET.js → SettingsWindow-D4jZHl8X.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-C_7vJLEq.js → ToolOutputDialog-BoeJONiR.js} +1 -1
  25. package/dist/assets/{ToolPartDiffPreview-ClV785zX.js → ToolPartDiffPreview-9FLv2fWD.js} +1 -1
  26. package/dist/assets/{VirtualizedFileDiff-DrxkW2WQ.js → VirtualizedFileDiff-ywmPBXAG.js} +4 -4
  27. package/dist/assets/{collapsible-CR3-hRMy.js → collapsible-6mCYf7Ky.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-D0mQcleY.js → computeVirtualFileMetrics-3H6mg13G.js} +1 -1
  29. package/dist/assets/{contextFileOpenGuard-BRc5Z0g-.js → contextFileOpenGuard-CKyf-TZ7.js} +1 -1
  30. package/dist/assets/gitStatusPredicates-UsytDMy_.js +134 -0
  31. package/dist/assets/index-C8NYcA8-.css +1 -0
  32. package/dist/assets/{index-CMfiVUIr.js → index-D1IaU-Q7.js} +1 -1
  33. package/dist/assets/index-yWgKW2Fx.js +8 -0
  34. package/dist/assets/{isDiffPlainText-MmBA1REG.js → isDiffPlainText-DPCilEx_.js} +1 -1
  35. package/dist/assets/{isFilePlainText-bQAPxqO9.js → isFilePlainText-XdCAgm8R.js} +1 -1
  36. package/dist/assets/main-DcAMXRSi.js +135 -0
  37. package/dist/assets/{main-zZrKd3hZ.js → main-DhvLreEl.js} +2 -2
  38. package/dist/assets/{markdownCore-B9jXCPry.js → markdownCore-BF0Dqwm4.js} +1 -1
  39. package/dist/assets/{miniChat-Di2oVS5o.js → miniChat-DsCx0dsW.js} +2 -2
  40. package/dist/assets/{mobile-VU_G_SgX.js → mobile-C-IN49xX.js} +2 -2
  41. package/dist/assets/{renderElectronMiniChatApp-Bi1927c8.js → renderElectronMiniChatApp-C13HXGZL.js} +2 -2
  42. package/dist/assets/renderMobileApp-xCdVzvyf.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CT3WShpj.js +54 -0
  44. package/dist/assets/{runtimeSurface-CBaS2Ank.js → runtimeSurface-C_3mcJ01.js} +1 -1
  45. package/dist/assets/{useAppFontEffects-8ZU-TTIW.js → useAppFontEffects-BgK55NDM.js} +80 -80
  46. package/dist/assets/{useFilesViewSearch-COow9O9x.js → useFilesViewSearch-CWx24PZg.js} +1 -1
  47. package/dist/assets/{usePushVisibilityBeacon-zYd3ppNh.js → usePushVisibilityBeacon-swMQLm-i.js} +1 -1
  48. package/dist/assets/{useSwitcherItems-DOQqhi-e.js → useSwitcherItems-CrS-F6DY.js} +1 -1
  49. package/dist/assets/{vendor-codemirror-language-data-B_0wrsbo.js → vendor-codemirror-language-data-BzeePAPn.js} +2 -2
  50. package/dist/assets/{vendor-dnd-kit-core-CP8ck10N.js → vendor-dnd-kit-core-C9qcAm_1.js} +1 -1
  51. package/dist/assets/{vendor-dnd-kit-sortable-B-Icjoj4.js → vendor-dnd-kit-sortable-D8ozj8M-.js} +1 -1
  52. package/dist/assets/vendor-xterm-addon-fit-DX4qG4td.js +1 -0
  53. package/dist/assets/vendor-xterm-xterm-CrXqRur4.js +16 -0
  54. package/dist/assets/vendor-xterm-xterm-DDGTF8rc.css +1 -0
  55. package/dist/assets/{web-components-C9ENH49P.js → web-components-DAkBDXRk.js} +3 -3
  56. package/dist/index.html +4 -4
  57. package/dist/mini-chat.html +3 -3
  58. package/dist/mobile.html +3 -3
  59. package/package.json +1 -2
  60. package/server/lib/stt/DOCUMENTATION.md +1 -1
  61. package/server/lib/terminal/DOCUMENTATION.md +2 -2
  62. package/dist/assets/DiffView-Gh9wjthp.js +0 -18
  63. package/dist/assets/GitView-BmNCkkoC.js +0 -8
  64. package/dist/assets/SettingsView-CFzxRzUq.js +0 -2
  65. package/dist/assets/gitStatusPredicates-DBGDfr1K.js +0 -134
  66. package/dist/assets/index-CzO3ooje.css +0 -1
  67. package/dist/assets/index-ivrh3jfy.js +0 -8
  68. package/dist/assets/main-BoVfUG73.js +0 -135
  69. package/dist/assets/renderMobileApp-D9mxhuaM.js +0 -11
  70. package/dist/assets/runtimeEndpointReset-DImT35Ug.js +0 -54
  71. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
@@ -0,0 +1 @@
1
+ .xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;inset:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;inset:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}
@@ -1,4 +1,4 @@
1
- import{y as M,ab as V,aG as Y,aH as j,aI as K,cq as X,cr as J,cs as $,ct as Q,ac as Z}from"./useAppFontEffects-8ZU-TTIW.js";import{a as ee,t as p,z as I,B as ne,h as G,C as te,y as C}from"./computeVirtualFileMetrics-D0mQcleY.js";import{t as ie}from"./vendor-hast-util-to-html-BKBhbTDb.js";function U(e,n,t){if(e===n||e==null||n==null)return e===n;const i=new Set(t),a=Object.keys(e),r=new Set(Object.keys(n));for(const s of a)if(r.delete(s),!i.has(s)&&(!(s in n)||e[s]!==n[s]))return!1;for(const s of Array.from(r))if(!i.has(s))return!1;return!0}function Te(e,n){const t=e?.theme??M,i=n?.theme??M,a=R(e),r=R(n);return ee(t,i)&&U(e,n,["theme","parseDiffOptions"])&&U(a,r)}function R(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function H(e,n){return e?.start===n?.start&&e?.end===n?.end&&e?.side===n?.side&&e?.endSide===n?.endSide}function ae(){return p({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[I({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function re(e,n){return e.lineNumber===n.lineNumber&&e.side===n.side}var Ie=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;activeLineHighlightSide;activeLineNumberOnly=!1;editorAttached=!1;proposedSelectedRange;renderedSelectionRange;selectionAnchor;queuedSelectionRender;pointerSession={mode:"idle"};constructor(e,n){this.mode=e,this.options=n}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:n=!1,enableGutterUtility:t=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),t?this.ensureGutterUtilityNode(n):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectionRange=void 0}setEditorAttached(e){this.editorAttached!==e&&(this.editorAttached=e,this.setSelectionDirty(),this.renderSelection())}isSelectionDirty(){return this.renderedSelectionRange===null}setSelection(e,n){const t=!(e===this.selectedRange||H(e??void 0,this.selectedRange??void 0));!this.isSelectionDirty()&&!t||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.activeLineHighlightSide=n?.activeLineSide,this.activeLineNumberOnly=n?.lineNumberOnly??!1,this.renderSelection(),this.placeUtility(),t&&n?.notify!==!1&&this.notifySelectionCommitted())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:n,onLineClick:t,onLineNumberClick:i,onTokenClick:a,onMergeConflictActionClick:r}=this.options;n==null&&t==null&&i==null&&r==null&&a==null||this.options.onGutterUtilityClick!=null&&E(e.composedPath())||(k(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:n="disabled",onLineEnter:t,onLineLeave:i,onTokenEnter:a,onTokenLeave:r,enableGutterUtility:s=!1}=this.options;n==="disabled"&&!s&&t==null&&i==null&&a==null&&r==null||(k(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:n}=this.options;if(k(n,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){k(n,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:n}){const{__debugPointerEvents:t}=this.options,i=n.composedPath();k(t,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const a=this.resolvePointerTarget(i);k(t,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",a);const{onLineClick:r,onLineNumberClick:s,onLineEnter:l,onLineLeave:o,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const u=T(a)&&this.hoveredLine?.lineElement===a.lineElement;A(a)&&this.hoveredToken?.tokenElement===a.tokenElement||(this.hoveredToken!=null&&(m?.(this.hoveredToken,n),this.clearHoveredToken()),A(a)&&(this.setHoveredToken(this.toTokenEventBaseProps(a)),c?.(this.hoveredToken,n))),u||(this.hoveredLine!=null&&(o?.({...this.hoveredLine,event:n}),this.clearHoveredLine()),T(a)?(this.setHoveredLine(this.toEventBaseProps(a)),this.placeUtility(),l?.({...this.hoveredLine,event:n})):this.placeUtility());break}case"click":{if(a==null)break;if(de(a)&&f!=null){f(a);break}if(se(a)&&h!=null){h(a.hunkIndex,a.all||n.shiftKey?"both":a.direction,a.all||n.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!T(a))break;A(a)&&d!=null&&d(this.toTokenEventBaseProps(a),n);const u=this.toEventBaseProps(a);s!=null&&a.numberColumn?s({...u,event:n}):r?.({...u,event:n});break}}}syncPointerListeners(e){const{__debugPointerEvents:n,lineHoverHighlight:t="disabled",onLineClick:i,onLineNumberClick:a,onLineEnter:r,onLineLeave:s,onTokenClick:l,onTokenEnter:o,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:u}=this.options,v=u!=null,b=t!=="disabled"||i!=null||a!=null||r!=null||s!=null||l!=null||o!=null||d!=null||c!=null||m!=null||h||f||v;b&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,k(n,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const x=[];return(n==="both"||n==="click")&&(i!=null&&x.push("onLineClick"),a!=null&&x.push("onLineNumberClick"),c!=null&&x.push("expandable hunk separators"),m!=null&&x.push("merge conflict actions")),x})()),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!b&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const g=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",y=this.pointerSession.mode==="gutterSelecting";(!f&&g||!v&&y)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:n,enableLineSelection:t=!1}=this.options,i=e!=null,a=n!=null||t;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),a&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!a&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const n=e.composedPath();E(n)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(n),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:n=!1}=this.options;if(!n)return;const t=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(t==null)return;const{pre:i}=this;if(i==null)return;e.preventDefault();const{lineNumber:a,eventSide:r,lineIndex:s}=t;if(e.shiftKey&&this.selectedRange!=null){const l=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(l==null)return;const o=l.start<=l.end?s>=l.start:s<=l.end;this.selectionAnchor={lineNumber:o?this.selectedRange.start:this.selectedRange.end,side:o?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===a&&this.selectedRange?.end===a){const l={lineNumber:a,side:r};this.selectionAnchor=l,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:l,pending:l},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:a,side:r},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;if(t==null)return;const i=this.currentSelectionEnds(),a=i?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=i?.top??a;a==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:a},n&&(this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(a.lineNumber,a.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange())),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{const{enableLineSelection:n=!1}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,n===!0&&this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const i={lineNumber:t.lineNumber,side:t.eventSide};if(re(this.pointerSession.pending,i))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(this.pointerSession.current=i,n&&this.updateSelection(i.lineNumber,i.side)),t?.(this.buildSelectedLineRange(this.pointerSession.anchor,this.pointerSession.current)),this.selectionAnchor=void 0,n&&(this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:n="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,n!=="disabled"&&((n==="both"||n==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(n==="both"||n==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const n=document.createElement("div");n.innerHTML=ie(ae());const t=n.firstElementChild;if(!(t instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const n=this.resolvePointerTarget(e);w(n)&&n.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(n))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const n=this.targetForSelectionPoint(e.bottom);return n==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(n)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const n={lineNumber:e.start,side:e.side},t={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(n),a=this.selectionPointRowIndex(t);if(!(i==null||a==null))return i>a?{top:t,bottom:n}:{top:n,bottom:t}}selectionPointRowIndex(e){const n=this.getLineIndex(e.lineNumber,e.side);if(n!=null)return this.isSplitDiff()?n[1]:n[0]}targetForSelectionPoint(e){if(this.pre==null)return;const n=this.getLineIndex(e.lineNumber,e.side);if(n==null)return;const t=this.mode==="diff"?`${n[0]},${n[1]}`:`${n[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${t}"]`);for(const a of i){if(!(a instanceof HTMLElement))continue;const r=this.resolvePointerTarget(L(a));if(w(r)&&!(this.mode==="diff"&&e.side!=null&&r.side!==e.side))return r}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,n){const t=this.resolvePointerTarget(e);if(w(t)&&!(n&&!t.numberColumn)&&t.splitLineIndex!=null)return{lineIndex:t.splitLineIndex,lineNumber:t.lineNumber,eventSide:this.mode==="diff"?t.side:void 0}}resolveSelectionInfo(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionInfoFromPath(t,n.requireNumberColumn):void 0}selectionPointFromPath(e){const n=this.resolvePointerTarget(e);if(w(n))return{lineNumber:n.lineNumber,side:this.mode==="diff"?n.side:void 0}}resolveSelectionPoint(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionPointFromPath(t):void 0}resolveSelectionPath(e,n){const t=n.excludeUtility!==!1;switch(n.source){case"event-path":return this.pathFromEventPath(e.composedPath(),t);case"coordinates-first":{const i=this.pathFromCoordinates(e,t);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),t)}}}pathFromCoordinates(e,n){const t=this.hitTest(e);if(t!==void 0)return t===null?null:this.pathFromElement(t,n)??null}pathFromEventPath(e,n){if(!(n&&E(e))){for(const t of e)if(t instanceof Element)return this.pathFromElement(t,n)}}pathFromElement(e,n){const t=L(e);if(n&&E(t))return;const i=fe(e);return i!=null?L(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const n=ue(ce(e));if(n==null)return;const t=this.targetForSelectionPoint(n);return t!=null?L(t.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const n=this.pre?.getRootNode(),t=z(n)?n:z(document)?document:void 0;if(t!=null)return t.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,n){const{getLineIndex:t}=this.options;return t!=null?t(e,n):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,n,t=!0){const i=this.getCurrentSelectionRange();let a;if(e==null)a=null;else{const r=this.selectionAnchor?.side??n,s=this.selectionAnchor?.lineNumber??e;a=this.buildSelectionRange(s,e,r,n)}H(i??void 0,a??void 0)||(this.activeLineHighlightSide=void 0,this.activeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=a:(this.selectedRange=a,this.queuedSelectionRender??=requestAnimationFrame(this.renderSelection)),this.placeUtility(),t&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,n){if(this.pre==null)return;const t=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return t!=null&&i!=null?{start:n?t[1]:t[0],end:n?i[1]:i[0]}:void 0}highlightLineNumberOnly(){return this.activeLineHighlightSide!=null?this.activeLineNumberOnly:this.activeLineNumberOnly||this.editorAttached}renderSelection=()=>{if(this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;const e=this.pre.querySelectorAll("[data-selected-line]");for(const o of e)o.removeAttribute("data-selected-line");if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;const{children:n}=this.pre;if(n.length===0)return;if(n.length>2)throw console.error(n),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const t=this.pre.getAttribute("data-diff-type")==="split",i=this.getIndexesFromSelection(this.selectedRange,t);if(i==null)throw console.error({rowRange:i,selectedRange:this.selectedRange}),new Error("InteractionManager.renderSelection: No valid rowRange");const a=i.start===i.end,r=Math.min(i.start,i.end),s=Math.max(i.start,i.end),l=this.highlightLineNumberOnly();for(const o of n){const d=this.activeLineHighlightSide;if(d!=null&&(d==="additions"&&o.hasAttribute("data-deletions")||d==="deletions"&&o.hasAttribute("data-additions")))continue;const[c,m]=o.children,h=m.children.length;if(h!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");for(let f=0;f<h;f++){const u=m.children[f],v=c.children[f];if(!(u instanceof HTMLElement)||!(v instanceof HTMLElement))continue;const b=this.parseLineIndex(u,t);if((b??0)>s)break;if(b==null||b<r)continue;let g=a?"single":b===r?"first":b===s?"last":"";v.setAttribute("data-selected-line",g),!l&&(u.setAttribute("data-selected-line",g),v.nextSibling instanceof HTMLElement&&u.nextSibling instanceof HTMLElement&&(u.nextSibling.hasAttribute("data-line-annotation")||u.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(a?(g="last",u.setAttribute("data-selected-line","first")):b===r?g="":b===s&&u.setAttribute("data-selected-line",""),u.nextSibling.setAttribute("data-selected-line",g),v.nextSibling.setAttribute("data-selected-line",g)))}}};notifySelectionCommitted(){this.options.onLineSelected?.(this.getCurrentSelectionRange()??null)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,tokenElement:a,tokenText:r}:{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}}buildSelectedLineRange(e,n){return this.buildSelectionRange(e.lineNumber,n.lineNumber,e.side,n.side)}buildSelectionRange(e,n,t,i){return{start:e,end:n,...t!=null?{side:t}:{},...t!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let n=!1,t,i,a,r,s,l,o,d,c,m;for(const f of e){if(!(f instanceof HTMLElement))continue;if(m==null&&f.hasAttribute("data-merge-conflict-action")){const g=f.getAttribute("data-merge-conflict-action")??void 0,y=f.getAttribute("data-merge-conflict-conflict-index")??void 0,x=y!=null?Number.parseInt(y,10):NaN;le(g)&&Number.isFinite(x)&&(m={kind:"merge-conflict-action",resolution:g,conflictIndex:x})}if(l==null&&f.hasAttribute("data-char")){l=f;const g=f.getAttribute("data-char");if(g!=null){const y=Number.parseInt(g,10);if(!Number.isNaN(y)){const x=f.textContent??"",N=y+x.length;(x.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(o={tokenElement:l,lineCharStart:y,lineCharEnd:N,tokenText:x});continue}}}const u=s==null?f.getAttribute("data-column-number")??void 0:void 0;if(u!=null){s=f,c=Number.parseInt(u,10),n=!0,t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}const v=a==null?f.getAttribute("data-line")??void 0:void 0;if(v!=null){a=f,c=Number.parseInt(v,10),t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const b=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&b!=null){const g=Number.parseInt(b,10);Number.isNaN(g)||(d.hunkIndex=g);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(a??=r!=null?D(i,`[data-line][data-line-index="${r}"]`):void 0,s??=r!=null?D(i,`[data-column-number][data-line-index="${r}"]`):void 0,i==null||a==null||s==null||t==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(a,this.isSplitDiff());return o!=null?this.mode==="file"?{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h,...o}:{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h,...o}:this.mode==="file"?{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h}:{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,n){const t=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(n&&t.length===2)return t[1];if(!n)return t[0]}};function Me({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:n,lineHoverHighlight:t,onGutterUtilityClick:i,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y},x,N,W){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:oe({enableGutterUtility:n,renderGutterUtility:m,onGutterUtilityClick:i}),usesCustomGutterUtility:m!=null,lineHoverHighlight:t,onGutterUtilityClick:i,onHunkExpand:x,onMergeConflictActionClick:W,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y,getLineIndex:N}}function oe({enableGutterUtility:e,renderGutterUtility:n,onGutterUtilityClick:t}){if(t!=null&&n!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function w(e){return e!=null&&"kind"in e&&e.kind==="line"}function A(e){return e!=null&&"kind"in e&&e.kind==="token"}function T(e){return w(e)||A(e)}function se(e){return"type"in e&&e.type==="line-info"}function de(e){return"kind"in e&&e.kind==="merge-conflict-action"}function le(e){return e==="current"||e==="incoming"||e==="both"}function D(e,n){const t=e?.querySelector(n);return t instanceof HTMLElement?t:void 0}function L(e){const n=[];let t=e;for(;t!=null;)n.push(t),t=t.parentNode;return n}function fe(e){const n=e.closest("[data-line], [data-column-number]");if(n instanceof HTMLElement)return n;const t=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(t instanceof HTMLElement))return;const i=t.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function ce(e){const n=e.closest('[slot^="annotation-"]');if(n instanceof HTMLElement)return n.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const t=e.getAttribute("name")??void 0;return t!=null&&t.startsWith("annotation-")?t:void 0}}function ue(e){if(e==null)return;const n=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(n==null)return;const t=Number.parseInt(n[2],10);if(!(!Number.isFinite(t)||t<=0))return{lineNumber:t,side:n[1]}}function z(e){return e!=null&&typeof e.elementFromPoint=="function"}function F(e,n){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return n.hasAttribute("data-deletions")?"deletions":"additions"}}function O(e){const n=e.getAttribute("data-line-type");if(n!=null)switch(n){case"change-deletion":case"change-addition":case"context":case"context-expanded":return n;default:return}}function E(e){for(const n of e)if(n instanceof HTMLElement&&(n.hasAttribute("data-utility-button")||n.hasAttribute("data-gutter-utility-slot")||n.getAttribute("slot")==="gutter-utility-slot"||n.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}function k(e="none",n,...t){switch(e){case"none":return;case"both":break;case"click":if(n!=="click")return;break;case"move":if(n!=="move")return;break}console.log(...t)}var Ue=class S{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const n=S.resizeObserver??new ResizeObserver(S.handleSharedResizeEntries);return S.resizeObserver=n,n}static handleSharedResizeEntries(n){const t=new Map;for(const i of n){const a=S.managersByElement.get(i.target);if(a==null)continue;const r=t.get(a);r==null?t.set(a,[i]):r.push(i)}for(const[i,a]of t)i.handleResizeEntries(a)}observedNodes=new Map;setup(n,t){const i=new Set;let a=0;const r=new Map(this.observedNodes);this.observedNodes.clear();for(const s of n.children){if(a===2)break;const l=(()=>{if(s instanceof HTMLElement&&s.tagName==="CODE")return s})();if(l==null)continue;a++;let o=r.get(l);if(o!=null&&o.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let d=l.firstElementChild;d instanceof HTMLElement||(d=null),o!=null?(this.observedNodes.set(l,o),r.delete(l),o.numberElement!==d?(o.numberElement!=null&&(this.unobserve(o.numberElement),r.delete(o.numberElement)),d!=null&&(this.observe(d),r.delete(d),this.observedNodes.set(d,o)),o.numberElement=d,o.numberWidth=0):o.numberElement!=null?(r.delete(o.numberElement),this.observedNodes.set(o.numberElement,o)):o.numberWidth=0):(o={type:"code",codeElement:l,numberElement:d,codeWidth:"auto",numberWidth:0},this.observedNodes.set(l,o),this.observe(l),d!=null&&(this.observedNodes.set(d,o),this.observe(d)))}if(a>1&&!t){const s=n.querySelectorAll('[data-line-annotation*=","]'),l=new Map;for(const o of s){if(!(o instanceof HTMLElement))continue;const d=o.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(d)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:d,element:o});continue}let c=l.get(d);c==null&&(c=[],l.set(d,c)),c.push(o)}for(const[o,d]of l){if(d.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",o,d);continue}const[c,m]=d,h=c.firstElementChild,f=m.firstElementChild;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement)||!(h instanceof HTMLElement)||!(f instanceof HTMLElement))continue;let u=r.get(h);if(u!=null){this.observedNodes.set(h,u),this.observedNodes.set(f,u),r.delete(h),r.delete(f);continue}const v=h.getBoundingClientRect().height,b=f.getBoundingClientRect().height;u={type:"annotations",column1:{container:c,child:h,childHeight:v},column2:{container:m,child:f,childHeight:b},currentHeight:"auto"},i.add({child1:h,child2:f,item:u,newHeight:Math.max(v,b)})}for(const o of i)this.applyNewHeight(o.item,o.newHeight),this.observedNodes.set(o.child1,o.item),this.observedNodes.set(o.child2,o.item),this.observe(o.child1),this.observe(o.child2);i.clear()}for(const[s,l]of r)this.unobserve(s),l.type==="code"?ge(l):pe(l);r.clear()}cleanUp(){for(const n of this.observedNodes.keys())this.unobserve(n);this.observedNodes.clear()}observe(n){const{managersByElement:t}=S,i=t.get(n);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");t.set(n,this),S.getResizeObserver().observe(n)}}unobserve(n){const{managersByElement:t,resizeObserver:i}=S,a=t.get(n);if(a!=null){if(a!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");t.delete(n),i?.unobserve(n),i!=null&&t.size===0&&(i.disconnect(),S.resizeObserver=void 0)}}handleResizeEntries(n){const t=new Map,i=new Set;for(const a of n){const{target:r,borderBoxSize:s,contentBoxSize:l}=a;if(!(r instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",a);continue}const o=this.observedNodes.get(r);if(o==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",a);continue}if(o.type==="annotations"){const d=(()=>{if(r===o.column1.child)return o.column1;if(r===o.column2.child)return o.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:o,target:r});continue}d.childHeight=s[0].blockSize,i.add(o)}else if(o.type==="code"){const d=t.get(o)??{},c=l[0].inlineSize;r===o.codeElement?d.codeInlineSize=c:r===o.numberElement&&(d.numberInlineSize=c),t.set(o,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(n){for(const t of n)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=n=>{for(const[t,i]of n){const a=i.codeInlineSize!=null?he(i.codeInlineSize):t.codeWidth,r=i.numberInlineSize!=null?me(i.numberInlineSize):t.numberWidth,s=a!==t.codeWidth,l=r!==t.numberWidth;if(!(!s&&!l)&&(t.codeWidth=a,t.numberWidth=r,s&&t.codeElement.style.setProperty("--diffs-column-width",`${typeof a=="number"?`${a}px`:"auto"}`),l&&t.codeElement.style.setProperty("--diffs-column-number-width",`${r===0?"auto":`${r}px`}`),s||l&&a!=="auto")){const o=typeof a=="number"?Math.max(a-r,0):0;t.codeElement.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}};applyNewHeight(n,t){t!==n.currentHeight&&(n.currentHeight=Math.max(t,0),n.column1.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`),n.column2.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`))}};function he(e){const n=Math.max(Math.floor(e),0);return n===0?"auto":n}function me(e){return Math.max(Math.ceil(e),0)}function ge(e){e.codeElement.isConnected&&(e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width"))}function pe(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function Re(e){for(const n of Array.isArray(e)?e:[e])if(!(n==="text"||n==="ansi")&&!ne.has(n))return!1;return!0}function He(e){for(const n of G(e))if(!te.has(n))return!1;return!0}function De(e,n){return e==null||n==null?e===n:e.startingLine===n.startingLine&&e.totalLines===n.totalLines&&e.bufferBefore===n.bufferBefore&&e.bufferAfter===n.bufferAfter}function ze(e){return p({tagName:"div",children:[p({tagName:"div",children:e.annotations?.map(n=>p({tagName:"slot",properties:{name:n}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function be(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function Fe({fileOrDiff:e,mode:n,stickyHeader:t}){const i="type"in e?e:void 0,a={"data-diffs-header":n,"data-change-type":i?.type,"data-sticky":t?"":void 0};return p({tagName:"div",children:[n==="custom"?p({tagName:"slot",properties:{name:V}}):ve({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...n==="custom"?[]:[xe(i)]],properties:a})}function ve({name:e,prevName:n,iconType:t}){const i=[p({tagName:"slot",properties:{name:Y}}),I({name:be(t),properties:{"data-change-icon":t}})];return n!=null&&(i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(n)]})],properties:{"data-prev-name":""}})),i.push(I({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(e)]})],properties:{"data-title":""}})),i.push(p({tagName:"slot",properties:{name:j}})),p({tagName:"div",children:i,properties:{"data-header-content":""}})}function xe(e){const n=[];if(e!=null){let t=0,i=0;for(const a of e.hunks)t+=a.additionLines,i+=a.deletionLines;(i>0||t===0)&&n.push(p({tagName:"span",children:[C(`-${i}`)],properties:{"data-deletions-count":""}})),(t>0||i===0)&&n.push(p({tagName:"span",children:[C(`+${t}`)],properties:{"data-additions-count":""}}))}return n.push(p({tagName:"slot",properties:{name:K}})),p({tagName:"div",children:n,properties:{"data-metadata":""}})}function Oe(e){return p({tagName:"pre",properties:ye(e)})}function ye({diffIndicators:e,disableBackground:n,disableLineNumbers:t,overflow:i,split:a,totalLines:r,type:s,customProperties:l}){return{...l,"data-diff":s==="diff"?"":void 0,"data-file":s==="file"?"":void 0,"data-diff-type":s==="diff"?a?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":t?"":void 0,"data-background":n?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,tabIndex:0,style:`--diffs-min-number-column-width-default:${`${r}`.length}ch;`}}function Be(e,{theme:n,preferredHighlighter:t="shiki-js"}){return{langs:[e??"text"],themes:G(n),preferredHighlighter:t}}function $e(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}const Ge="-1,-1";function _e(e){return e?.some(n=>n.lineNumber===0)??!1}function qe(e){const n=e[0];return n!=null&&n.length>0?n:void 0}function We(e){return e.startingLine===0&&e.totalLines>0}function Ve(e,n){return p({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${n}`}})}function Ye(e){return e.useTokenTransformer===!0||e.onTokenClick!=null||e.onTokenEnter!=null||e.onTokenLeave!=null}const je=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
1
+ import{y as M,ab as V,aI as Y,aJ as K,aK as j,cq as X,cr as J,cs as $,ct as Q,ac as Z}from"./useAppFontEffects-BgK55NDM.js";import{a as ee,t as p,z as I,B as ne,h as G,C as te,y as C}from"./computeVirtualFileMetrics-3H6mg13G.js";import{t as ie}from"./vendor-hast-util-to-html-BKBhbTDb.js";function U(e,n,t){if(e===n||e==null||n==null)return e===n;const i=new Set(t),a=Object.keys(e),r=new Set(Object.keys(n));for(const s of a)if(r.delete(s),!i.has(s)&&(!(s in n)||e[s]!==n[s]))return!1;for(const s of Array.from(r))if(!i.has(s))return!1;return!0}function Te(e,n){const t=e?.theme??M,i=n?.theme??M,a=R(e),r=R(n);return ee(t,i)&&U(e,n,["theme","parseDiffOptions"])&&U(a,r)}function R(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function H(e,n){return e?.start===n?.start&&e?.end===n?.end&&e?.side===n?.side&&e?.endSide===n?.endSide}function ae(){return p({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[I({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function re(e,n){return e.lineNumber===n.lineNumber&&e.side===n.side}var Ie=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;activeLineHighlightSide;activeLineNumberOnly=!1;editorAttached=!1;proposedSelectedRange;renderedSelectionRange;selectionAnchor;queuedSelectionRender;pointerSession={mode:"idle"};constructor(e,n){this.mode=e,this.options=n}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:n=!1,enableGutterUtility:t=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),t?this.ensureGutterUtilityNode(n):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectionRange=void 0}setEditorAttached(e){this.editorAttached!==e&&(this.editorAttached=e,this.setSelectionDirty(),this.renderSelection())}isSelectionDirty(){return this.renderedSelectionRange===null}setSelection(e,n){const t=!(e===this.selectedRange||H(e??void 0,this.selectedRange??void 0));!this.isSelectionDirty()&&!t||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.activeLineHighlightSide=n?.activeLineSide,this.activeLineNumberOnly=n?.lineNumberOnly??!1,this.renderSelection(),this.placeUtility(),t&&n?.notify!==!1&&this.notifySelectionCommitted())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:n,onLineClick:t,onLineNumberClick:i,onTokenClick:a,onMergeConflictActionClick:r}=this.options;n==null&&t==null&&i==null&&r==null&&a==null||this.options.onGutterUtilityClick!=null&&E(e.composedPath())||(k(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:n="disabled",onLineEnter:t,onLineLeave:i,onTokenEnter:a,onTokenLeave:r,enableGutterUtility:s=!1}=this.options;n==="disabled"&&!s&&t==null&&i==null&&a==null&&r==null||(k(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:n}=this.options;if(k(n,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){k(n,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:n}){const{__debugPointerEvents:t}=this.options,i=n.composedPath();k(t,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const a=this.resolvePointerTarget(i);k(t,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",a);const{onLineClick:r,onLineNumberClick:s,onLineEnter:l,onLineLeave:o,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const u=T(a)&&this.hoveredLine?.lineElement===a.lineElement;A(a)&&this.hoveredToken?.tokenElement===a.tokenElement||(this.hoveredToken!=null&&(m?.(this.hoveredToken,n),this.clearHoveredToken()),A(a)&&(this.setHoveredToken(this.toTokenEventBaseProps(a)),c?.(this.hoveredToken,n))),u||(this.hoveredLine!=null&&(o?.({...this.hoveredLine,event:n}),this.clearHoveredLine()),T(a)?(this.setHoveredLine(this.toEventBaseProps(a)),this.placeUtility(),l?.({...this.hoveredLine,event:n})):this.placeUtility());break}case"click":{if(a==null)break;if(de(a)&&f!=null){f(a);break}if(se(a)&&h!=null){h(a.hunkIndex,a.all||n.shiftKey?"both":a.direction,a.all||n.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!T(a))break;A(a)&&d!=null&&d(this.toTokenEventBaseProps(a),n);const u=this.toEventBaseProps(a);s!=null&&a.numberColumn?s({...u,event:n}):r?.({...u,event:n});break}}}syncPointerListeners(e){const{__debugPointerEvents:n,lineHoverHighlight:t="disabled",onLineClick:i,onLineNumberClick:a,onLineEnter:r,onLineLeave:s,onTokenClick:l,onTokenEnter:o,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:u}=this.options,v=u!=null,b=t!=="disabled"||i!=null||a!=null||r!=null||s!=null||l!=null||o!=null||d!=null||c!=null||m!=null||h||f||v;b&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,k(n,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const x=[];return(n==="both"||n==="click")&&(i!=null&&x.push("onLineClick"),a!=null&&x.push("onLineNumberClick"),c!=null&&x.push("expandable hunk separators"),m!=null&&x.push("merge conflict actions")),x})()),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!b&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const g=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",y=this.pointerSession.mode==="gutterSelecting";(!f&&g||!v&&y)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:n,enableLineSelection:t=!1}=this.options,i=e!=null,a=n!=null||t;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),a&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!a&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const n=e.composedPath();E(n)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(n),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:n=!1}=this.options;if(!n)return;const t=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(t==null)return;const{pre:i}=this;if(i==null)return;e.preventDefault();const{lineNumber:a,eventSide:r,lineIndex:s}=t;if(e.shiftKey&&this.selectedRange!=null){const l=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(l==null)return;const o=l.start<=l.end?s>=l.start:s<=l.end;this.selectionAnchor={lineNumber:o?this.selectedRange.start:this.selectedRange.end,side:o?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===a&&this.selectedRange?.end===a){const l={lineNumber:a,side:r};this.selectionAnchor=l,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:l,pending:l},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:a,side:r},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;if(t==null)return;const i=this.currentSelectionEnds(),a=i?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=i?.top??a;a==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:a},n&&(this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(a.lineNumber,a.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange())),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{const{enableLineSelection:n=!1}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,n===!0&&this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const i={lineNumber:t.lineNumber,side:t.eventSide};if(re(this.pointerSession.pending,i))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(this.pointerSession.current=i,n&&this.updateSelection(i.lineNumber,i.side)),t?.(this.buildSelectedLineRange(this.pointerSession.anchor,this.pointerSession.current)),this.selectionAnchor=void 0,n&&(this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:n="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,n!=="disabled"&&((n==="both"||n==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(n==="both"||n==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const n=document.createElement("div");n.innerHTML=ie(ae());const t=n.firstElementChild;if(!(t instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const n=this.resolvePointerTarget(e);w(n)&&n.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(n))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const n=this.targetForSelectionPoint(e.bottom);return n==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(n)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const n={lineNumber:e.start,side:e.side},t={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(n),a=this.selectionPointRowIndex(t);if(!(i==null||a==null))return i>a?{top:t,bottom:n}:{top:n,bottom:t}}selectionPointRowIndex(e){const n=this.getLineIndex(e.lineNumber,e.side);if(n!=null)return this.isSplitDiff()?n[1]:n[0]}targetForSelectionPoint(e){if(this.pre==null)return;const n=this.getLineIndex(e.lineNumber,e.side);if(n==null)return;const t=this.mode==="diff"?`${n[0]},${n[1]}`:`${n[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${t}"]`);for(const a of i){if(!(a instanceof HTMLElement))continue;const r=this.resolvePointerTarget(L(a));if(w(r)&&!(this.mode==="diff"&&e.side!=null&&r.side!==e.side))return r}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,n){const t=this.resolvePointerTarget(e);if(w(t)&&!(n&&!t.numberColumn)&&t.splitLineIndex!=null)return{lineIndex:t.splitLineIndex,lineNumber:t.lineNumber,eventSide:this.mode==="diff"?t.side:void 0}}resolveSelectionInfo(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionInfoFromPath(t,n.requireNumberColumn):void 0}selectionPointFromPath(e){const n=this.resolvePointerTarget(e);if(w(n))return{lineNumber:n.lineNumber,side:this.mode==="diff"?n.side:void 0}}resolveSelectionPoint(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionPointFromPath(t):void 0}resolveSelectionPath(e,n){const t=n.excludeUtility!==!1;switch(n.source){case"event-path":return this.pathFromEventPath(e.composedPath(),t);case"coordinates-first":{const i=this.pathFromCoordinates(e,t);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),t)}}}pathFromCoordinates(e,n){const t=this.hitTest(e);if(t!==void 0)return t===null?null:this.pathFromElement(t,n)??null}pathFromEventPath(e,n){if(!(n&&E(e))){for(const t of e)if(t instanceof Element)return this.pathFromElement(t,n)}}pathFromElement(e,n){const t=L(e);if(n&&E(t))return;const i=fe(e);return i!=null?L(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const n=ue(ce(e));if(n==null)return;const t=this.targetForSelectionPoint(n);return t!=null?L(t.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const n=this.pre?.getRootNode(),t=z(n)?n:z(document)?document:void 0;if(t!=null)return t.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,n){const{getLineIndex:t}=this.options;return t!=null?t(e,n):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,n,t=!0){const i=this.getCurrentSelectionRange();let a;if(e==null)a=null;else{const r=this.selectionAnchor?.side??n,s=this.selectionAnchor?.lineNumber??e;a=this.buildSelectionRange(s,e,r,n)}H(i??void 0,a??void 0)||(this.activeLineHighlightSide=void 0,this.activeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=a:(this.selectedRange=a,this.queuedSelectionRender??=requestAnimationFrame(this.renderSelection)),this.placeUtility(),t&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,n){if(this.pre==null)return;const t=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return t!=null&&i!=null?{start:n?t[1]:t[0],end:n?i[1]:i[0]}:void 0}highlightLineNumberOnly(){return this.activeLineHighlightSide!=null?this.activeLineNumberOnly:this.activeLineNumberOnly||this.editorAttached}renderSelection=()=>{if(this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;const e=this.pre.querySelectorAll("[data-selected-line]");for(const o of e)o.removeAttribute("data-selected-line");if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;const{children:n}=this.pre;if(n.length===0)return;if(n.length>2)throw console.error(n),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const t=this.pre.getAttribute("data-diff-type")==="split",i=this.getIndexesFromSelection(this.selectedRange,t);if(i==null)throw console.error({rowRange:i,selectedRange:this.selectedRange}),new Error("InteractionManager.renderSelection: No valid rowRange");const a=i.start===i.end,r=Math.min(i.start,i.end),s=Math.max(i.start,i.end),l=this.highlightLineNumberOnly();for(const o of n){const d=this.activeLineHighlightSide;if(d!=null&&(d==="additions"&&o.hasAttribute("data-deletions")||d==="deletions"&&o.hasAttribute("data-additions")))continue;const[c,m]=o.children,h=m.children.length;if(h!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");for(let f=0;f<h;f++){const u=m.children[f],v=c.children[f];if(!(u instanceof HTMLElement)||!(v instanceof HTMLElement))continue;const b=this.parseLineIndex(u,t);if((b??0)>s)break;if(b==null||b<r)continue;let g=a?"single":b===r?"first":b===s?"last":"";v.setAttribute("data-selected-line",g),!l&&(u.setAttribute("data-selected-line",g),v.nextSibling instanceof HTMLElement&&u.nextSibling instanceof HTMLElement&&(u.nextSibling.hasAttribute("data-line-annotation")||u.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(a?(g="last",u.setAttribute("data-selected-line","first")):b===r?g="":b===s&&u.setAttribute("data-selected-line",""),u.nextSibling.setAttribute("data-selected-line",g),v.nextSibling.setAttribute("data-selected-line",g)))}}};notifySelectionCommitted(){this.options.onLineSelected?.(this.getCurrentSelectionRange()??null)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,tokenElement:a,tokenText:r}:{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}}buildSelectedLineRange(e,n){return this.buildSelectionRange(e.lineNumber,n.lineNumber,e.side,n.side)}buildSelectionRange(e,n,t,i){return{start:e,end:n,...t!=null?{side:t}:{},...t!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let n=!1,t,i,a,r,s,l,o,d,c,m;for(const f of e){if(!(f instanceof HTMLElement))continue;if(m==null&&f.hasAttribute("data-merge-conflict-action")){const g=f.getAttribute("data-merge-conflict-action")??void 0,y=f.getAttribute("data-merge-conflict-conflict-index")??void 0,x=y!=null?Number.parseInt(y,10):NaN;le(g)&&Number.isFinite(x)&&(m={kind:"merge-conflict-action",resolution:g,conflictIndex:x})}if(l==null&&f.hasAttribute("data-char")){l=f;const g=f.getAttribute("data-char");if(g!=null){const y=Number.parseInt(g,10);if(!Number.isNaN(y)){const x=f.textContent??"",N=y+x.length;(x.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(o={tokenElement:l,lineCharStart:y,lineCharEnd:N,tokenText:x});continue}}}const u=s==null?f.getAttribute("data-column-number")??void 0:void 0;if(u!=null){s=f,c=Number.parseInt(u,10),n=!0,t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}const v=a==null?f.getAttribute("data-line")??void 0:void 0;if(v!=null){a=f,c=Number.parseInt(v,10),t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const b=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&b!=null){const g=Number.parseInt(b,10);Number.isNaN(g)||(d.hunkIndex=g);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(a??=r!=null?D(i,`[data-line][data-line-index="${r}"]`):void 0,s??=r!=null?D(i,`[data-column-number][data-line-index="${r}"]`):void 0,i==null||a==null||s==null||t==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(a,this.isSplitDiff());return o!=null?this.mode==="file"?{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h,...o}:{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h,...o}:this.mode==="file"?{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h}:{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,n){const t=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(n&&t.length===2)return t[1];if(!n)return t[0]}};function Me({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:n,lineHoverHighlight:t,onGutterUtilityClick:i,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y},x,N,W){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:oe({enableGutterUtility:n,renderGutterUtility:m,onGutterUtilityClick:i}),usesCustomGutterUtility:m!=null,lineHoverHighlight:t,onGutterUtilityClick:i,onHunkExpand:x,onMergeConflictActionClick:W,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y,getLineIndex:N}}function oe({enableGutterUtility:e,renderGutterUtility:n,onGutterUtilityClick:t}){if(t!=null&&n!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function w(e){return e!=null&&"kind"in e&&e.kind==="line"}function A(e){return e!=null&&"kind"in e&&e.kind==="token"}function T(e){return w(e)||A(e)}function se(e){return"type"in e&&e.type==="line-info"}function de(e){return"kind"in e&&e.kind==="merge-conflict-action"}function le(e){return e==="current"||e==="incoming"||e==="both"}function D(e,n){const t=e?.querySelector(n);return t instanceof HTMLElement?t:void 0}function L(e){const n=[];let t=e;for(;t!=null;)n.push(t),t=t.parentNode;return n}function fe(e){const n=e.closest("[data-line], [data-column-number]");if(n instanceof HTMLElement)return n;const t=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(t instanceof HTMLElement))return;const i=t.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function ce(e){const n=e.closest('[slot^="annotation-"]');if(n instanceof HTMLElement)return n.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const t=e.getAttribute("name")??void 0;return t!=null&&t.startsWith("annotation-")?t:void 0}}function ue(e){if(e==null)return;const n=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(n==null)return;const t=Number.parseInt(n[2],10);if(!(!Number.isFinite(t)||t<=0))return{lineNumber:t,side:n[1]}}function z(e){return e!=null&&typeof e.elementFromPoint=="function"}function F(e,n){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return n.hasAttribute("data-deletions")?"deletions":"additions"}}function O(e){const n=e.getAttribute("data-line-type");if(n!=null)switch(n){case"change-deletion":case"change-addition":case"context":case"context-expanded":return n;default:return}}function E(e){for(const n of e)if(n instanceof HTMLElement&&(n.hasAttribute("data-utility-button")||n.hasAttribute("data-gutter-utility-slot")||n.getAttribute("slot")==="gutter-utility-slot"||n.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}function k(e="none",n,...t){switch(e){case"none":return;case"both":break;case"click":if(n!=="click")return;break;case"move":if(n!=="move")return;break}console.log(...t)}var Ue=class S{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const n=S.resizeObserver??new ResizeObserver(S.handleSharedResizeEntries);return S.resizeObserver=n,n}static handleSharedResizeEntries(n){const t=new Map;for(const i of n){const a=S.managersByElement.get(i.target);if(a==null)continue;const r=t.get(a);r==null?t.set(a,[i]):r.push(i)}for(const[i,a]of t)i.handleResizeEntries(a)}observedNodes=new Map;setup(n,t){const i=new Set;let a=0;const r=new Map(this.observedNodes);this.observedNodes.clear();for(const s of n.children){if(a===2)break;const l=(()=>{if(s instanceof HTMLElement&&s.tagName==="CODE")return s})();if(l==null)continue;a++;let o=r.get(l);if(o!=null&&o.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let d=l.firstElementChild;d instanceof HTMLElement||(d=null),o!=null?(this.observedNodes.set(l,o),r.delete(l),o.numberElement!==d?(o.numberElement!=null&&(this.unobserve(o.numberElement),r.delete(o.numberElement)),d!=null&&(this.observe(d),r.delete(d),this.observedNodes.set(d,o)),o.numberElement=d,o.numberWidth=0):o.numberElement!=null?(r.delete(o.numberElement),this.observedNodes.set(o.numberElement,o)):o.numberWidth=0):(o={type:"code",codeElement:l,numberElement:d,codeWidth:"auto",numberWidth:0},this.observedNodes.set(l,o),this.observe(l),d!=null&&(this.observedNodes.set(d,o),this.observe(d)))}if(a>1&&!t){const s=n.querySelectorAll('[data-line-annotation*=","]'),l=new Map;for(const o of s){if(!(o instanceof HTMLElement))continue;const d=o.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(d)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:d,element:o});continue}let c=l.get(d);c==null&&(c=[],l.set(d,c)),c.push(o)}for(const[o,d]of l){if(d.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",o,d);continue}const[c,m]=d,h=c.firstElementChild,f=m.firstElementChild;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement)||!(h instanceof HTMLElement)||!(f instanceof HTMLElement))continue;let u=r.get(h);if(u!=null){this.observedNodes.set(h,u),this.observedNodes.set(f,u),r.delete(h),r.delete(f);continue}const v=h.getBoundingClientRect().height,b=f.getBoundingClientRect().height;u={type:"annotations",column1:{container:c,child:h,childHeight:v},column2:{container:m,child:f,childHeight:b},currentHeight:"auto"},i.add({child1:h,child2:f,item:u,newHeight:Math.max(v,b)})}for(const o of i)this.applyNewHeight(o.item,o.newHeight),this.observedNodes.set(o.child1,o.item),this.observedNodes.set(o.child2,o.item),this.observe(o.child1),this.observe(o.child2);i.clear()}for(const[s,l]of r)this.unobserve(s),l.type==="code"?ge(l):pe(l);r.clear()}cleanUp(){for(const n of this.observedNodes.keys())this.unobserve(n);this.observedNodes.clear()}observe(n){const{managersByElement:t}=S,i=t.get(n);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");t.set(n,this),S.getResizeObserver().observe(n)}}unobserve(n){const{managersByElement:t,resizeObserver:i}=S,a=t.get(n);if(a!=null){if(a!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");t.delete(n),i?.unobserve(n),i!=null&&t.size===0&&(i.disconnect(),S.resizeObserver=void 0)}}handleResizeEntries(n){const t=new Map,i=new Set;for(const a of n){const{target:r,borderBoxSize:s,contentBoxSize:l}=a;if(!(r instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",a);continue}const o=this.observedNodes.get(r);if(o==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",a);continue}if(o.type==="annotations"){const d=(()=>{if(r===o.column1.child)return o.column1;if(r===o.column2.child)return o.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:o,target:r});continue}d.childHeight=s[0].blockSize,i.add(o)}else if(o.type==="code"){const d=t.get(o)??{},c=l[0].inlineSize;r===o.codeElement?d.codeInlineSize=c:r===o.numberElement&&(d.numberInlineSize=c),t.set(o,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(n){for(const t of n)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=n=>{for(const[t,i]of n){const a=i.codeInlineSize!=null?he(i.codeInlineSize):t.codeWidth,r=i.numberInlineSize!=null?me(i.numberInlineSize):t.numberWidth,s=a!==t.codeWidth,l=r!==t.numberWidth;if(!(!s&&!l)&&(t.codeWidth=a,t.numberWidth=r,s&&t.codeElement.style.setProperty("--diffs-column-width",`${typeof a=="number"?`${a}px`:"auto"}`),l&&t.codeElement.style.setProperty("--diffs-column-number-width",`${r===0?"auto":`${r}px`}`),s||l&&a!=="auto")){const o=typeof a=="number"?Math.max(a-r,0):0;t.codeElement.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}};applyNewHeight(n,t){t!==n.currentHeight&&(n.currentHeight=Math.max(t,0),n.column1.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`),n.column2.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`))}};function he(e){const n=Math.max(Math.floor(e),0);return n===0?"auto":n}function me(e){return Math.max(Math.ceil(e),0)}function ge(e){e.codeElement.isConnected&&(e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width"))}function pe(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function Re(e){for(const n of Array.isArray(e)?e:[e])if(!(n==="text"||n==="ansi")&&!ne.has(n))return!1;return!0}function He(e){for(const n of G(e))if(!te.has(n))return!1;return!0}function De(e,n){return e==null||n==null?e===n:e.startingLine===n.startingLine&&e.totalLines===n.totalLines&&e.bufferBefore===n.bufferBefore&&e.bufferAfter===n.bufferAfter}function ze(e){return p({tagName:"div",children:[p({tagName:"div",children:e.annotations?.map(n=>p({tagName:"slot",properties:{name:n}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function be(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function Fe({fileOrDiff:e,mode:n,stickyHeader:t}){const i="type"in e?e:void 0,a={"data-diffs-header":n,"data-change-type":i?.type,"data-sticky":t?"":void 0};return p({tagName:"div",children:[n==="custom"?p({tagName:"slot",properties:{name:V}}):ve({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...n==="custom"?[]:[xe(i)]],properties:a})}function ve({name:e,prevName:n,iconType:t}){const i=[p({tagName:"slot",properties:{name:Y}}),I({name:be(t),properties:{"data-change-icon":t}})];return n!=null&&(i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(n)]})],properties:{"data-prev-name":""}})),i.push(I({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(e)]})],properties:{"data-title":""}})),i.push(p({tagName:"slot",properties:{name:K}})),p({tagName:"div",children:i,properties:{"data-header-content":""}})}function xe(e){const n=[];if(e!=null){let t=0,i=0;for(const a of e.hunks)t+=a.additionLines,i+=a.deletionLines;(i>0||t===0)&&n.push(p({tagName:"span",children:[C(`-${i}`)],properties:{"data-deletions-count":""}})),(t>0||i===0)&&n.push(p({tagName:"span",children:[C(`+${t}`)],properties:{"data-additions-count":""}}))}return n.push(p({tagName:"slot",properties:{name:j}})),p({tagName:"div",children:n,properties:{"data-metadata":""}})}function Oe(e){return p({tagName:"pre",properties:ye(e)})}function ye({diffIndicators:e,disableBackground:n,disableLineNumbers:t,overflow:i,split:a,totalLines:r,type:s,customProperties:l}){return{...l,"data-diff":s==="diff"?"":void 0,"data-file":s==="file"?"":void 0,"data-diff-type":s==="diff"?a?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":t?"":void 0,"data-background":n?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,tabIndex:0,style:`--diffs-min-number-column-width-default:${`${r}`.length}ch;`}}function Be(e,{theme:n,preferredHighlighter:t="shiki-js"}){return{langs:[e??"text"],themes:G(n),preferredHighlighter:t}}function $e(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}const Ge="-1,-1";function _e(e){return e?.some(n=>n.lineNumber===0)??!1}function qe(e){const n=e[0];return n!=null&&n.length>0?n:void 0}function We(e){return e.startingLine===0&&e.totalLines>0}function Ve(e,n){return p({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${n}`}})}function Ye(e){return e.useTokenTransformer===!0||e.onTokenClick!=null||e.onTokenEnter!=null||e.onTokenLeave!=null}const Ke=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
2
2
  <symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
3
3
  <path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
4
4
  </symbol>
@@ -50,7 +50,7 @@ import{y as M,ab as V,aG as Y,aH as j,aI as K,cq as X,cr as J,cs as $,ct as Q,ac
50
50
  <symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
51
51
  <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
52
52
  </symbol>
53
- </svg>`;function Ke(e,n){return e==null||n==null?e===n:ke(e.customProperties,n.customProperties)&&e.type===n.type&&e.diffIndicators===n.diffIndicators&&e.disableBackground===n.disableBackground&&e.disableLineNumbers===n.disableLineNumbers&&e.overflow===n.overflow&&e.split===n.split&&e.totalLines===n.totalLines}const B={};function ke(e=B,n=B){if(e===n)return!0;const t=Object.keys(e),i=Object.keys(n);if(t.length!==i.length)return!1;for(const a of t)if(e[a]!==n[a])return!1;return!0}function Xe(e){const n=document.createElement("div");return n.dataset.annotationSlot="",n.slot=e,n.style.whiteSpace="normal",n}function Je(){const e=document.createElement("div");return e.slot="gutter-utility-slot",e.style.position="absolute",e.style.top="0",e.style.bottom="0",e.style.textAlign="center",e.style.whiteSpace="normal",e.style.touchAction="none",e}function Qe(){const e=document.createElement("style");return e.setAttribute(X,""),e}var Se=`@layer base {
53
+ </svg>`;function je(e,n){return e==null||n==null?e===n:ke(e.customProperties,n.customProperties)&&e.type===n.type&&e.diffIndicators===n.diffIndicators&&e.disableBackground===n.disableBackground&&e.disableLineNumbers===n.disableLineNumbers&&e.overflow===n.overflow&&e.split===n.split&&e.totalLines===n.totalLines}const B={};function ke(e=B,n=B){if(e===n)return!0;const t=Object.keys(e),i=Object.keys(n);if(t.length!==i.length)return!1;for(const a of t)if(e[a]!==n[a])return!1;return!0}function Xe(e){const n=document.createElement("div");return n.dataset.annotationSlot="",n.slot=e,n.style.whiteSpace="normal",n}function Je(){const e=document.createElement("div");return e.slot="gutter-utility-slot",e.style.position="absolute",e.style.top="0",e.style.bottom="0",e.style.textAlign="center",e.style.whiteSpace="normal",e.style.touchAction="none",e}function Qe(){const e=document.createElement("style");return e.setAttribute(X,""),e}var Se=`@layer base {
54
54
  :host {
55
55
  --diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
56
56
  "Courier New", monospace;
@@ -1387,4 +1387,4 @@ import{y as M,ab as V,aG as Y,aH as j,aI as K,cq as X,cr as J,cs as $,ct as Q,ac
1387
1387
  ${_(t)}
1388
1388
  ${e}
1389
1389
  }
1390
- }`}function nn(e,n){const t=_(n);return e.replace(Le,t)}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn({code:e,pre:n,columnType:t,rowSpan:i,containerSize:a=!1}={}){return e==null&&(e=document.createElement("code"),e.setAttribute("data-code",""),t!=null&&e.setAttribute(`data-${t}`,""),n?.appendChild(e)),i!=null?e.style.setProperty("grid-row",`span ${i}`):e.style.removeProperty("grid-row"),a?e.setAttribute("data-container-size",""):e.removeAttribute("data-container-size"),e}function an(e,n){if(n==null)return;const t=e.shadowRoot??e.attachShadow({mode:"open"});t.innerHTML===""&&(t.innerHTML=n)}function rn(e,{type:n,diffIndicators:t,disableBackground:i,disableLineNumbers:a,overflow:r,split:s,totalLines:l,customProperties:o}){if(o!=null)for(const d in o){const c=o[d];c!=null&&e.setAttribute(d,`${c}`)}switch(n==="diff"?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),t){case"bars":case"classic":e.setAttribute("data-indicators",t);break;case"none":e.removeAttribute("data-indicators");break}return a?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),i?e.removeAttribute("data-background"):e.setAttribute("data-background",""),n==="diff"?e.setAttribute("data-diff-type",s?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",r),e.tabIndex=0,e.style.setProperty("--diffs-min-number-column-width-default",`${`${l}`.length}ch`),e}function on(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;const n=e.tagName??e.nodeName;return typeof n=="string"&&n.toLowerCase()==="style"}function sn({shadowRoot:e,currentNode:n,themeCSS:t}){if(t.trim()===""){n?.remove();return}return n??=Pe(),n.textContent=t,n.parentNode!==e&&e.appendChild(n),n}function Pe(){const e=document.createElement("style");return e.setAttribute(Q,""),e}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class n extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const i=this.attachShadow({mode:"open"});e==null&&(e=new CSSStyleSheet,e.replaceSync(Se)),i.adoptedStyleSheets=[e]}connectedCallback(){we(this.shadowRoot??this.attachShadow({mode:"open"}))}}customElements.define(Z,n)}export{rn as A,U as B,_e as C,Ge as F,Ie as I,Ue as R,je as S,Te as a,He as b,De as c,Re as d,We as e,qe as f,$e as g,ze as h,Fe as i,Ve as j,Be as k,Oe as l,an as m,Xe as n,Je as o,Me as p,Qe as q,we as r,Ye as s,en as t,sn as u,nn as v,Ze as w,tn as x,on as y,Ke as z};
1390
+ }`}function nn(e,n){const t=_(n);return e.replace(Le,t)}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn({code:e,pre:n,columnType:t,rowSpan:i,containerSize:a=!1}={}){return e==null&&(e=document.createElement("code"),e.setAttribute("data-code",""),t!=null&&e.setAttribute(`data-${t}`,""),n?.appendChild(e)),i!=null?e.style.setProperty("grid-row",`span ${i}`):e.style.removeProperty("grid-row"),a?e.setAttribute("data-container-size",""):e.removeAttribute("data-container-size"),e}function an(e,n){if(n==null)return;const t=e.shadowRoot??e.attachShadow({mode:"open"});t.innerHTML===""&&(t.innerHTML=n)}function rn(e,{type:n,diffIndicators:t,disableBackground:i,disableLineNumbers:a,overflow:r,split:s,totalLines:l,customProperties:o}){if(o!=null)for(const d in o){const c=o[d];c!=null&&e.setAttribute(d,`${c}`)}switch(n==="diff"?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),t){case"bars":case"classic":e.setAttribute("data-indicators",t);break;case"none":e.removeAttribute("data-indicators");break}return a?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),i?e.removeAttribute("data-background"):e.setAttribute("data-background",""),n==="diff"?e.setAttribute("data-diff-type",s?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",r),e.tabIndex=0,e.style.setProperty("--diffs-min-number-column-width-default",`${`${l}`.length}ch`),e}function on(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;const n=e.tagName??e.nodeName;return typeof n=="string"&&n.toLowerCase()==="style"}function sn({shadowRoot:e,currentNode:n,themeCSS:t}){if(t.trim()===""){n?.remove();return}return n??=Pe(),n.textContent=t,n.parentNode!==e&&e.appendChild(n),n}function Pe(){const e=document.createElement("style");return e.setAttribute(Q,""),e}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class n extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const i=this.attachShadow({mode:"open"});e==null&&(e=new CSSStyleSheet,e.replaceSync(Se)),i.adoptedStyleSheets=[e]}connectedCallback(){we(this.shadowRoot??this.attachShadow({mode:"open"}))}}customElements.define(Z,n)}export{rn as A,U as B,_e as C,Ge as F,Ie as I,Ue as R,Ke as S,Te as a,He as b,De as c,Re as d,We as e,qe as f,$e as g,ze as h,Fe as i,Ve as j,Be as k,Oe as l,an as m,Xe as n,Je as o,Me as p,Qe as q,we as r,Ye as s,en as t,sn as u,nn as v,Ze as w,tn as x,on as y,je as z};
package/dist/index.html CHANGED
@@ -540,7 +540,7 @@
540
540
  }
541
541
  }
542
542
  </style>
543
- <script type="module" crossorigin src="/assets/main-zZrKd3hZ.js"></script>
543
+ <script type="module" crossorigin src="/assets/main-DhvLreEl.js"></script>
544
544
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
545
545
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
546
546
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-B5Z1Mdn3.js">
@@ -548,10 +548,10 @@
548
548
  <link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
549
549
  <link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
550
550
  <link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
551
- <link rel="modulepreload" crossorigin href="/assets/index-ivrh3jfy.js">
552
- <link rel="modulepreload" crossorigin href="/assets/runtimeSurface-CBaS2Ank.js">
551
+ <link rel="modulepreload" crossorigin href="/assets/index-yWgKW2Fx.js">
552
+ <link rel="modulepreload" crossorigin href="/assets/runtimeSurface-C_3mcJ01.js">
553
553
  <link rel="modulepreload" crossorigin href="/assets/vendor-katex-CNckGUMB.js">
554
- <link rel="stylesheet" crossorigin href="/assets/index-CzO3ooje.css">
554
+ <link rel="stylesheet" crossorigin href="/assets/index-C8NYcA8-.css">
555
555
  <link rel="stylesheet" crossorigin href="/assets/vendor-katex-Cp579UoJ.css">
556
556
  </head>
557
557
  <body class="h-full bg-background text-foreground">
@@ -89,7 +89,7 @@
89
89
  }
90
90
  </style>
91
91
 
92
- <script type="module" crossorigin src="/assets/miniChat-Di2oVS5o.js"></script>
92
+ <script type="module" crossorigin src="/assets/miniChat-DsCx0dsW.js"></script>
93
93
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
94
94
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-B5Z1Mdn3.js">
@@ -97,9 +97,9 @@
97
97
  <link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
98
98
  <link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
100
- <link rel="modulepreload" crossorigin href="/assets/index-ivrh3jfy.js">
100
+ <link rel="modulepreload" crossorigin href="/assets/index-yWgKW2Fx.js">
101
101
  <link rel="modulepreload" crossorigin href="/assets/vendor-katex-CNckGUMB.js">
102
- <link rel="stylesheet" crossorigin href="/assets/index-CzO3ooje.css">
102
+ <link rel="stylesheet" crossorigin href="/assets/index-C8NYcA8-.css">
103
103
  <link rel="stylesheet" crossorigin href="/assets/vendor-katex-Cp579UoJ.css">
104
104
  </head>
105
105
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-VU_G_SgX.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-C-IN49xX.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-B5Z1Mdn3.js">
@@ -71,9 +71,9 @@
71
71
  <link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
73
73
  <link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
74
- <link rel="modulepreload" crossorigin href="/assets/index-ivrh3jfy.js">
74
+ <link rel="modulepreload" crossorigin href="/assets/index-yWgKW2Fx.js">
75
75
  <link rel="modulepreload" crossorigin href="/assets/vendor-katex-CNckGUMB.js">
76
- <link rel="stylesheet" crossorigin href="/assets/index-CzO3ooje.css">
76
+ <link rel="stylesheet" crossorigin href="/assets/index-C8NYcA8-.css">
77
77
  <link rel="stylesheet" crossorigin href="/assets/vendor-katex-Cp579UoJ.css">
78
78
  </head>
79
79
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-chamber/web",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -81,7 +81,6 @@
81
81
  "eslint": "^9.33.0",
82
82
  "eslint-plugin-react-hooks": "^5.2.0",
83
83
  "eslint-plugin-react-refresh": "^0.5.0",
84
- "ghostty-web": "0.4.0",
85
84
  "globals": "^16.3.0",
86
85
  "next-themes": "^0.4.6",
87
86
  "nodemon": "^3.1.7",
@@ -19,7 +19,7 @@ This module owns final-only composer dictation for web, Electron, hosted mobile,
19
19
  - `DELETE /api/stt/models/:modelId`
20
20
  - `WS /api/stt/ws`
21
21
 
22
- All routes use the existing `/api` authentication middleware. The WebSocket path is in both the URL-token and private-relay allowlists. Shared UI opens it through `openRuntimeWebSocket` after minting URL auth.
22
+ All routes use the existing `/api` authentication middleware. The WebSocket path is in both the URL-token and private-relay allowlists. Shared UI opens it through `openRuntimeWebSocket` with the token returned by that connection's URL-auth mint. A failed older connection cannot clear a newer shared token.
23
23
 
24
24
  Remote URL and API-key values live in `<PiChamber data>/stt/config.json` with owner-only permissions where the platform supports them. Status responses redact API keys. WebSocket start frames carry only a stored provider configuration ID. They never accept a URL or credential.
25
25
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  - `attach` registers a connection for one terminal. One socket may attach to many terminals.
12
12
  - Every attach and reconnect begins with an authoritative `snapshot` containing bounded history and the current sequence.
13
- - A current socket that closes or errors before its initial `open` invalidates its URL-scoped auth token before retrying, so retries mint a fresh token instead of backing off against a rejected upgrade. Hidden or offline clients wait 60 seconds and wake promptly on visibility/online recovery.
13
+ - A current socket that closes or errors before its initial `open` invalidates only the URL-scoped auth token used for that connection before retrying. A stale failure cannot clear a newer shared token minted for terminal, dictation, or events. Hidden or offline clients wait 60 seconds and wake promptly on visibility/online recovery.
14
14
  - `output`, `exit`, and `restarted` carry monotonically increasing per-terminal sequences. Output carries raw live bytes plus replay-safe bytes with terminal query exchanges removed.
15
15
  - Attach registers before capturing the snapshot, buffers concurrent events, drops events represented by the snapshot sequence, then enters live delivery.
16
16
  - `write` always includes the terminal ID; sockets never have mutable single-terminal binding state.
@@ -24,7 +24,7 @@ HTTP remains the authenticated command plane for create, resize, appearance upda
24
24
  - IDs are client-provided or generated with `randomUUID()`.
25
25
  - Concurrent creates for one ID are single-flight only when working directory and shell preference match. Existing IDs cannot be reused for another working directory.
26
26
  - Dimensions are bounded to 1-1000 columns and 1-500 rows; input is capped at 64 KiB.
27
- - A client may create before its renderer has mounted. It derives an initial size from the container and font metrics (falling back to 80x24 when unavailable), then sends a resize once Ghostty reports its final dimensions. This allows shell startup and renderer initialization to overlap.
27
+ - A client may create before its renderer has mounted. It derives an initial size from the container and font metrics (falling back to 80x24 when unavailable), then sends a resize once the renderer reports its final dimensions. This allows shell startup and renderer initialization to overlap.
28
28
  - PTY children explicitly clear `NODE_CHANNEL_FD`; daemon IPC descriptors are host-private and invalid after PTY descriptor cleanup.
29
29
  - PTY children also strip AppImage `ARGV0` (and other host-private shell vars such as `ELECTRON_RUN_AS_NODE`, `BASH_ENV`, `ENV`, `BASH_XTRACEFD`). An exported `ARGV0` makes zsh rewrite argv[0] for every external command, which breaks Python venv detection and other argv[0]/$0 consumers while leaving `/proc/self/exe` correct. On Linux, PTY spawn is wrapped with `env -u ARGV0` because `bun-pty` merges the native OS environ and would otherwise reintroduce `ARGV0` after a JS-only delete.
30
30
  - `GET /api/terminal/shells` reports shell IDs available on the active server using the same augmented PATH provided to spawned PTYs, plus whether each executable has a supported login-mode argument. `auto` preserves environment/platform fallback order; an explicit unavailable shell fails creation instead of silently running a different shell. Login mode is opt-in and uses only built-in arguments for known shells. Preference changes affect new sessions and explicit restarts, not running PTYs.
@@ -1,18 +0,0 @@
1
- import{R as i,j as e}from"./vendor-react-B5Z1Mdn3.js";import{c as J,u as Q,w as Qe,n as Be}from"./index-ivrh3jfy.js";import{b3 as Ft,D as Nt,a as vt,I as U,b as Ct,b4 as Lt,b5 as Ne,a$ as Dt,aa as kt,ao as Ye,b6 as Je,aP as Rt,p as ve,U as Ce,j as Ze,Q as ne,t as et,aS as tt,aA as Et,b7 as At,b8 as Tt,aB as Mt,b9 as It,ba as $t,bb as Pt,bc as _t,k as Bt,bd as Wt,be as Ot,E as zt,F as Gt,G as Ht}from"./useAppFontEffects-8ZU-TTIW.js";import{d as nt,P as Ut,i as We,a as Oe,b as Vt}from"./gitStatusPredicates-DBGDfr1K.js";import{p as Kt}from"./VirtualizedFileDiff-DrxkW2WQ.js";import{v as qt,g as Xt}from"./contextFileOpenGuard-BRc5Z0g-.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-vkqQ2P9o.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-CBaS2Ank.js";import"./vendor-dnd-kit-core-CP8ck10N.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-B-Icjoj4.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B_0wrsbo.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DYppkHEk.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./web-components-C9ENH49P.js";import"./computeVirtualFileMetrics-D0mQcleY.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./runtimeEndpointReset-DImT35Ug.js";import"./SessionUnreadDot-BxtTkvHB.js";import"./permissionStore-iKN1K2_x.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";import"./isDiffPlainText-MmBA1REG.js";import"./vendor-diff-C3JhlQdm.js";function Qt(s,n=10){const t=[];let r;for(const l of s.split(`
2
- `)){const p=l.match(Ft);if(p!=null){r!=null&&(r.hunkLines.length>0&&(De(r,n,"trailing"),Ae(r,t)),r=void 0);const d=parseInt(p[3]),x=parseInt(p[1]),h=parseInt(p[4]??"1"),c=parseInt(p[2]??"1");isNaN(d)||isNaN(x)||isNaN(h)||isNaN(c)?t.push(l):r={additionStart:d,deletionStart:x,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(r==null){t.push(l);continue}if(l.startsWith(" "))r.contextLines.push(l);else if(l!==""){if(r.hunkLines.length>0&&r.contextLines.length>n*2){const d=r.contextLines.length-n*2,x=r.contextLines.slice(-n);De(r,n,"trailing");const{additionCount:h,deletionCount:c}=r;Ae(r,t),r={additionStart:r.additionStart+h+d,deletionStart:r.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:x,hunkLines:[]}}De(r,n,r.hunkLines.length===0?"leading":"before-change"),r.hunkLines.push(l),l.startsWith("+")?r.additionCount+=1:l.startsWith("-")&&(r.deletionCount+=1)}}r!=null&&r.hunkLines.length>0&&(De(r,n,"trailing"),Ae(r,t));const a=t.join(`
3
- `);return s.endsWith(`
4
- `)?`${a}
5
- `:a}function De(s,n,t){if(t==="leading"&&s.contextLines.length>n){const r=s.contextLines.length-n;s.contextLines.splice(0,r),s.additionStart+=r,s.deletionStart+=r}return t==="trailing"&&s.contextLines.length>n&&(s.contextLines.length=n),s.contextLines.length>0&&(s.hunkLines.push(...s.contextLines),s.additionCount+=s.contextLines.length,s.deletionCount+=s.contextLines.length,s.contextLines.length=0),s}function Ae(s,n){n.push(`@@ -${ze(s.deletionStart,s.deletionCount)} +${ze(s.additionStart,s.additionCount)} @@`),n.push(...s.hunkLines)}function ze(s,n){return n===1?`${s}`:`${s},${n}`}const Yt=i.memo(function({scope:n,isGitRepo:t,branchAvailable:r,allCount:a,workingCount:l,stagedCount:p,turnCount:d,branchCount:x,onScopeChange:h}){const[c,f]=i.useState(!1),b=n==="all"?a:n==="staged"?p:n==="turn"?d:n==="branch"?x:l,L=n==="staged"?"Staged":n==="turn"?"Last turn":n==="branch"?"Branch":n==="all"?"All":"Changed";return e.jsxs(Nt,{open:c,onOpenChange:f,children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Select change mode",children:[e.jsxs("span",{className:"whitespace-nowrap",children:[L,e.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",b]})]}),e.jsx(U,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"})]})}),e.jsx(Ct,{align:"start",className:"w-40",children:e.jsxs(Lt,{value:n,onValueChange:u=>{(u==="all"||u==="working"||u==="staged"||u==="turn"||u==="branch")&&(h?.(u),f(!1))},children:[t!==!1?e.jsx(Ne,{value:"all",children:e.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[e.jsx("span",{children:"All"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:a})]})}):null,t!==!1?e.jsx(Ne,{value:"working",children:e.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[e.jsx("span",{children:"Changed"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:l})]})}):null,t!==!1?e.jsx(Ne,{value:"staged",children:e.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[e.jsx("span",{children:"Staged"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:p})]})}):null,e.jsx(Ne,{value:"turn",children:e.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[e.jsx("span",{children:"Last turn"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:d})]})}),r?e.jsx(Ne,{value:"branch",children:e.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[e.jsx("span",{children:"Branch"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:x})]})}):null]})})]})}),Jt=64,Zt=3,ae=new Map,en=(s,n,t=Zt)=>{const r=`${s}\0${t}\0${n}`,a=ae.get(r);if(a)return ae.delete(r),ae.set(r,a),a;const l=nn(n),p=l?Dt(Qt(n,t),{oldFile:{name:s,contents:l.before},newFile:{name:s,contents:l.after}})??He(s):kt(tn(s,n))[0]?.files[0]??He(s);for(ae.set(r,p);ae.size>Jt;){const d=ae.keys().next().value;if(!d)break;ae.delete(d)}return p},tn=(s,n)=>!n.trim()||n.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(n)?n:`Index: ${s}
6
- ===================================================================
7
- --- ${s}
8
- +++ ${s}
9
- ${n}`,nn=s=>{if(!s.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(s))return;const n=[...s.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(n.length!==1)return;const t=n[0],r=Number.parseInt(t[1]??"",10),a=Number.parseInt(t[2]??"",10);if(r>1||a>1||!Number.isFinite(r)||!Number.isFinite(a))return;const l=(t.index??0)+t[0].length,p=s.slice(l),d=[],x=[];let h;for(const c of p.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(h==="-"||h===" "){const f=d.at(-1);f&&(f.newline=!1)}if(h==="+"||h===" "){const f=x.at(-1);f&&(f.newline=!1)}continue}if(c.startsWith("-")){d.push({text:c.slice(1),newline:!0}),h="-";continue}if(c.startsWith("+")){x.push({text:c.slice(1),newline:!0}),h="+";continue}c.startsWith(" ")&&(d.push({text:c.slice(1),newline:!0}),x.push({text:c.slice(1),newline:!0}),h=" ")}return{before:Ge(d),after:Ge(x)}},Ge=s=>s.map(n=>n.text+(n.newline?`
10
- `:"")).join(""),He=s=>Kt({name:s,contents:""},{name:s,contents:""}),sn=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),Me=(s,n,t)=>sn(n)?{original:"",modified:"",isBinary:!0,patch:n,contextMode:t}:{original:"",modified:"",patch:n,fileDiff:en(s,n),contextMode:t},st=(s,n,t)=>{const r=s??0,a=n??0;return!r&&!a?null:e.jsxs("span",{className:J("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",t?.className),children:[r?e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",r]}):null,a?e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},rn=i.memo(function({changedFiles:n,selectedFile:t,onSelectFile:r}){return n.length===0?null:e.jsx(Ye,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:e.jsx("ul",{className:"flex flex-col gap-1",children:n.map(a=>{const l=nt(a),p=t===a.path;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(a.path),className:J("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[e.jsx(Je,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:l.color},title:l.description,"aria-label":l.description,children:l.code}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),st(a.insertions,a.deletions)]})},a.path)})})})}),on=i.memo(function(){return e.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),an=i.memo(function({filePath:n,diff:t,renderSideBySide:r}){const a=t.original.length>0,l=t.modified.length>0,p=r?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",d=r?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return e.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:e.jsxs("div",{className:p,children:[a&&e.jsxs("div",{className:d,children:[e.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),e.jsx("img",{src:t.original,alt:`Original: ${n}`,className:r?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&e.jsxs("div",{className:d,children:[e.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:a?"Modified":"New"}),e.jsx("img",{src:t.modified,alt:`Modified: ${n}`,className:r?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),ln=i.memo(function({filePath:n,diff:t,renderSideBySide:r,wrapLines:a}){const l=i.useMemo(()=>Rt(n)||"text",[n]);return t.isBinary?e.jsx(on,{}):ve(n)?e.jsx(an,{filePath:n,diff:t,renderSideBySide:r}):e.jsx("div",{className:"w-full",style:{contain:"layout"},children:e.jsx(Ut,{original:t.original,modified:t.modified,fileDiff:t.fileDiff,language:l,fileName:n,renderSideBySide:r,wrapLines:a,layout:"inline"})})}),Te=({label:s,icon:n,loading:t,disabled:r,tone:a,onClick:l})=>e.jsx(Ce,{variant:"ghost",size:"sm",className:J("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:r,title:s,"aria-label":s,onClick:p=>{p.stopPropagation(),l()},children:t?e.jsx(U,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(U,{name:n,className:n==="add"?"size-4":"size-3.5"})}),cn=i.memo(function({filePath:n,staged:t,busyAction:r,disabled:a,onAction:l}){return e.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:t?e.jsx(Te,{label:`Unstage ${n}`,icon:"arrow-go-back",loading:r==="unstage",disabled:a,onClick:()=>l("unstage")}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{label:`Revert changes in ${n}`,icon:"arrow-go-back",loading:r==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),e.jsx(Te,{label:`Stage ${n}`,icon:"add",loading:r==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),rt=3,un=1e6,dn=15e3,Ue=500,fn=i.memo(function({directory:n,file:t,layout:r,wrapLines:a,isSelected:l,isExpanded:p,isMounted:d,onSelect:x,onExpandedChange:h,registerSectionRef:c,showOpenInEditorAction:f=!1,isOpeningInEditor:b=!1,onOpenInEditor:L,staged:u=!1,showFileActions:C=!0,loadFullFiles:g=!1,initialDiffData:R=null}){const{git:I}=Ze(),k=ne(i.useCallback(m=>m.directories.get(n)?.diffCache.get(t.path)??null,[n,t.path])),V=ne(m=>m.setDiff),E=ne(m=>m.fetchStatus),y=Q(m=>m.setDiffFileLayout),[w,j]=i.useState(0),[A,F]=i.useState(null),[q,N]=i.useState(!1),[_,B]=i.useState(null),[Z,se]=i.useState(!1),[P,le]=i.useState(null),[T,ee]=i.useState(null),W=i.useRef(null),ce=i.useRef(null),O=i.useMemo(()=>nt(t),[t]),re=r==="side-by-side",Y=g?"full":"patch",te=`${t.index}:${t.working_dir}:${t.insertions}:${t.deletions}`,z=i.useMemo(()=>R||(u?T:P||(k?{original:k.original,modified:k.modified,isBinary:k.isBinary,contextMode:"full"}:null)),[k,R,P,u,T]),ue=z?.contextMode===Y,ye=i.useCallback(m=>{ce.current=m,c(t.path,m)},[t.path,c]),de=i.useCallback(m=>{h(t.path,m)},[t.path,h]),fe=i.useCallback(()=>{x(t.path)},[t.path,x]);i.useEffect(()=>{u?ee(null):le(null),F(null),W.current=null},[te,u]),i.useEffect(()=>{if(!p||!d)return;if(!n||R||z&&ue){W.current=null,N(!1);return}const m=`${n}::${t.path}::${u?"staged":"unstaged"}::${te}::${Y}::${w}`;if(W.current===m)return;W.current=m,F(null),N(!0);let D=!1;const $=Qe(),je=g?un:rt,me=ve(t.path)?I.getGitFileDiff(n,{path:t.path,staged:u}):I.getGitDiff(n,{path:t.path,staged:u,contextLines:je}),ie=dn,ke=new Promise((K,G)=>{setTimeout(()=>G(new Error(`Timed out after ${ie}ms`)),ie)});return Promise.race([me,ke]).then(K=>{if(!D){if("diff"in K){const G=Me(t.path,K.diff,Y);u?ee(G):le(G)}else{const G={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary,contextMode:"full"};u?ee(G):V(n,t.path,G,$)}N(!1)}}).catch(K=>{if(D)return;const G=K instanceof Error?K.message:String(K);F(G),N(!1)}),()=>{D=!0,W.current===m&&(W.current=null)}},[Y,z,ue,w,n,t.path,te,I,R,p,d,g,V,u]);const pe=i.useCallback(()=>{de(!p),fe()},[de,fe,p]),we=i.useCallback(async m=>{if(!(!n||_!==null)){B(m);try{m==="stage"?await I.stageGitFile(n,t.path):m==="unstage"?await I.unstageGitFile(n,t.path):await I.revertGitFile(n,t.path,{scope:"working"}),j(D=>D+1),await E(n,I)}catch(D){const $=m==="unstage"?"Failed to unstage changes":m==="stage"?"Failed to stage changes":"Failed to revert changes";et.error(D instanceof Error?D.message:$)}finally{B(D=>D===m?null:D)}}},[n,E,t.path,_,I]);return e.jsxs("div",{ref:ye,className:J("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[e.jsx("div",{className:J("z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80","sticky top-0"),children:e.jsxs("div",{role:"button",tabIndex:0,onClick:pe,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),pe())},className:J("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",l?"bg-[var(--interactive-selection)]/35":null),children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),e.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:p?e.jsx(U,{name:"arrow-down-s",className:"size-4"}):e.jsx(U,{name:"arrow-right-s",className:"size-4"})}),e.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:O.color},title:O.description,"aria-label":O.description,children:O.code}),e.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:t.path,children:e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Je,{filePath:t.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const m=t.path.lastIndexOf("/");if(m===-1)return e.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:t.path});const D=t.path.slice(0,m),$=t.path.slice(m+1);return e.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[e.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:D}),e.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-foreground",children:$})]})]})})()]})})]}),e.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[st(t.insertions,t.deletions),f&&L?e.jsx(Ce,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"Open this file in editor at change",onClick:m=>{m.stopPropagation(),L(t.path,z)},disabled:b,children:b?e.jsx(U,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(U,{name:"edit",className:"size-3.5"})}):null,e.jsx(tt,{mode:re?"side-by-side":"unified",onModeChange:m=>{const D=m==="side-by-side"?"side-by-side":"inline";y(t.path,D)},className:"opacity-70"})]})]})}),p&&e.jsxs("div",{className:"relative overflow-hidden bg-background",children:[!d&&!A?e.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),e.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A}),e.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>j(m=>m+1),children:"Retry"})]}):null,d&&q&&!z&&!A?e.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[e.jsx(U,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&z&&!Z&&t.insertions+t.deletions>Ue?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${t.insertions+t.deletions} changed lines)`}),e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),e.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>se(!0),children:"Render anyway"})]}):null,d&&z&&(Z||t.insertions+t.deletions<=Ue)?e.jsxs(e.Fragment,{children:[e.jsx(ln,{filePath:t.path,diff:z,renderSideBySide:re,wrapLines:a}),C?e.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:e.jsx("div",{className:"pointer-events-auto",children:e.jsx(cn,{filePath:t.path,staged:u,busyAction:_,disabled:_!==null,onAction:we})})}):null]}):null]})]})}),pn=1100,Ve=300,mn=s=>s<=6?s:s<=12?6:s<=25?4:2,hn=(s,n)=>Et(s,n),Ke=(s,n)=>{const t=s.split(`
11
- `),r=n.split(`
12
- `),a=Math.min(t.length,r.length);for(let l=0;l<a;l+=1)if(t[l]!==r[l])return l+1;return r.length>t.length?t.length+1:t.length>r.length?Math.max(1,r.length):1},gn=s=>Array.isArray(s)?s.filter(n=>!n||typeof n!="object"?!1:typeof n.file=="string"):[],xn=s=>s.split(/^diff --git /m).slice(1).flatMap(t=>{const[r=""]=t.split(`
13
- `,1),a=r.lastIndexOf(" b/");if(a<=2)return[];const l=r.slice(2,a),p=r.slice(a+3).trim(),d=`diff --git ${t}`,x=d.includes(`
14
- new file mode `)?"added":d.includes(`
15
- deleted file mode `)?"deleted":d.includes(`
16
- rename from `)?"renamed":"modified";let h=0,c=0;for(const f of d.split(`
17
- `))f.startsWith("+")&&!f.startsWith("+++")&&(h+=1),f.startsWith("-")&&!f.startsWith("---")&&(c+=1);return[{file:x==="deleted"?l:p,status:x,additions:h,deletions:c,patch:d}]}),bn=s=>s==="added"?"A":s==="deleted"?"D":"M";function yn({activeDiffScope:s,effectiveDirectory:n,branchBase:t,branchHead:r,git:a,sessionMessageRecords:l}){const[p,d]=i.useState([]),[x,h]=i.useState(null),[c,f]=i.useState(!1),b=i.useMemo(()=>{const C=At(l,{showTextJustificationActivity:!1,showTurnChangedFiles:!0,mergeHiddenUserTurns:!0});for(let g=C.turns.length-1;g>=0;g-=1){const R=C.turns[g];if(!R)continue;const I=R.activityParts.map(E=>E.part).filter(E=>E.type==="tool"),k=Tt(I);if(k.length>0)return k.map(E=>({file:E.path,status:"modified",additions:E.additions,deletions:E.deletions,patch:E.patch}));const V=gn(R.userMessage.info?.summary?.diffs);if(V.length>0)return V}return[]},[l]);i.useEffect(()=>{if(s!=="branch"||!n||!t||!r||!a.getGitRangeDiff){d([]),h(null),f(!1);return}let C=!1;return f(!0),h(null),a.getGitRangeDiff(n,{base:t,head:r,contextLines:rt}).then(g=>{C||(d(xn(g.diff??"")),f(!1))}).catch(g=>{C||(d([]),f(!1),h(g instanceof Error?g.message:String(g)))}),()=>{C=!0}},[s,t,r,n,a]);const L=i.useMemo(()=>{const C=new Map;for(const g of b)if(g.file){if(typeof g.patch=="string"){C.set(g.file,Me(g.file,g.patch,"patch"));continue}C.set(g.file,{original:g.before??"",modified:g.after??"",contextMode:"full"})}return C},[b]),u=i.useMemo(()=>{const C=new Map;for(const g of p)!g.file||typeof g.patch!="string"||C.set(g.file,Me(g.file,g.patch,"patch"));return C},[p]);return{branchDiffs:p,branchDiffError:x,branchDiffLoading:c,lastTurnDiffs:b,lastTurnDiffData:L,branchDiffData:u}}const qe=(s,n)=>{if(n.length===0)return null;let t=null,r=null;for(const l of n)l.top<=s?(!t||l.top>t.top)&&(t=l):(!r||l.top<r.top)&&(r=l);const a=t??r;return a?{path:a.path,topOffset:a.top-s}:null},wn=(s,n,t,r)=>Math.min(Math.max(0,r),Math.max(0,s+t-n));function jn({pinSelectedFileHeaderToTopOnNavigate:s,scrollRequestNonce:n,changedFiles:t,expandedFiles:r,setMountedStackedFiles:a,fileDiffRefreshNonce:l}){const p=i.useRef(null),d=i.useRef(new Map),[x,h]=i.useState(null),c=i.useRef(null),f=i.useRef(null),b=i.useRef(!1),L=i.useRef(null),u=i.useRef(null),C=i.useRef(null),g=i.useCallback(()=>{const y=p.current;if(!y)return null;const w=y.getBoundingClientRect().top,j=[];for(const[A,F]of d.current)F&&j.push({path:A,top:F.getBoundingClientRect().top});return qe(w,j)},[]),R=i.useCallback(()=>{c.current=null,b.current=!1,h(null),f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null)},[]),I=i.useCallback(()=>{L.current=null;const y=p.current;if(!y)return;const w=y.getBoundingClientRect(),j=w.top-Ve,A=w.bottom+Ve,F={},q=[];for(const[N,_]of d.current){if(!_)continue;const B=_.getBoundingClientRect();q.push({path:N,top:B.top}),r.has(N)&&(B.bottom<j||B.top>A||(F[N]=!0))}u.current=qe(w.top,q),a(N=>{let _=!1;const B=new Set(N);for(const Z of Object.keys(F))B.has(Z)||(B.add(Z),_=!0);return _?B:N})},[r,a]),k=i.useCallback(()=>{typeof window>"u"||L.current===null&&(L.current=window.requestAnimationFrame(I))},[I]);i.useEffect(()=>{const y=p.current;if(y)return k(),y.addEventListener("scroll",k,{passive:!0}),window.addEventListener("resize",k),()=>{y.removeEventListener("scroll",k),window.removeEventListener("resize",k),L.current!==null&&(window.cancelAnimationFrame(L.current),L.current=null)}},[t,r,k]),i.useLayoutEffect(()=>{const y=C.current;if(!y)return;C.current=null;const w=p.current,j=d.current.get(y.path);if(!w||!j)return;const A=w.getBoundingClientRect().top,F=j.getBoundingClientRect().top-A;w.scrollTop=wn(w.scrollTop,y.topOffset,F,w.scrollHeight-w.clientHeight),u.current=y},[l]);const V=i.useCallback((y,w)=>{const j=d.current;w?j.set(y,w):j.delete(y),k()},[k]),E=i.useCallback(y=>{const w=d.current.get(y),j=p.current;if(!w||!j)return!1;const A=w.getBoundingClientRect().top-j.getBoundingClientRect().top;return j.scrollTo({top:j.scrollTop+A,behavior:"auto"}),!0},[]);return i.useEffect(()=>{if(!c.current)return;let w=0;const j=20;let A=!1;const F=(N=!0)=>{A||(A=!0,c.current=null,b.current=!1,N&&h(null),f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null))},q=()=>{if(A){f.current=null;return}const N=c.current;if(!N){F(),f.current=null;return}if(!E(N)){w+=1,w<j?f.current=window.requestAnimationFrame(q):(F(),f.current=null);return}if(s&&b.current){h(N),F(!1);return}F()};return f.current=window.requestAnimationFrame(q),()=>{A=!0,f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null)}},[s,n,E]),{diffScrollRef:p,fileSectionRefs:d,pinnedStackedTarget:x,pendingScrollTargetRef:c,shouldPinAfterAlignRef:b,pendingScrollAnchorRestoreRef:C,lastScrollAnchorRef:u,captureScrollAnchor:g,cancelPendingScrollAlignment:R,queueVisibleStackedFilesSync:k,registerSectionRef:V,scrollToFile:E}}const Xe=s=>{if(!s)return null;const n=s.split(`
18
- `);let t=null;for(const r of n){const a=r.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[1]??"",10);t=Number.isFinite(l)&&l>=1?l:null;continue}if(t!==null){if(r.startsWith(" ")){t+=1;continue}if(r.startsWith("+"))return t;if(r.startsWith("-"))return Math.max(1,t)}}return null};function Sn({effectiveDirectory:s,activeDiffStaged:n,git:t,files:r,setDiff:a,openContextFileAtLine:l}){const[p,d]=i.useState(null),x=i.useCallback(async(h,c)=>{if(!s||!h)return;d(h);const f=Qe();try{let b=null;if(c?.patch&&!c.isBinary&&!ve(h)?b=Xe(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!ve(h)&&(b=Ke(c.original,c.modified)),b===null)try{const R=await t.getGitDiff(s,{path:h,staged:n,contextLines:3});b=Xe(R.diff)}catch{b=null}let L=c;if(b===null||!L){const R=await t.getGitFileDiff(s,{path:h,staged:n});L={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary},n||a(s,h,L,f??void 0)}const u=b??(L.isBinary||ve(h)?1:Ke(L.original,L.modified)),C=hn(s,h),g=await qt(r,C,{directory:s});if(!g.ok){et.error(Xt(g.reason));return}l(s,C,u,1)}finally{d(b=>b===h?null:b)}},[n,s,r,t,l,a]);return{openingEditorFilePath:p,openFileInEditorAtChange:x}}function Fn(s){const{hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:t=!1,pinSelectedFileHeaderToTopOnNavigate:r=!1,diffScope:a="all",branchBase:l=null,branchHead:p=null,targetFilePath:d=null}=s,{git:x,files:h}=Ze(),c=Mt(),{screenWidth:f,isMobile:b}=It(),L=$t(c??null),u=Pt(c??null),C=_t(c??null),g=ne(o=>o.setActiveDirectory),R=ne(o=>o.ensureStatus),I=ne(o=>o.fetchStatus),k=ne(o=>o.clearDiffCache),V=ne(o=>o.setDiff),[E,y]=i.useState(null),[w,j]=i.useState(!1),[A,F]=i.useState(()=>new Set),[q,N]=i.useState(()=>new Set),[_,B]=i.useState(!1),[Z,se]=i.useState(0),[P,le]=i.useState(()=>new Map),[T,ee]=i.useState(a);i.useEffect(()=>{ee(a)},[a]);const W=Q(o=>o.pendingDiffFile),ce=Q(o=>o.pendingDiffStaged),O=Q(o=>o.pendingDiffScope),re=Q(o=>o.setPendingDiffFile),Y=Q(o=>o.diffLayoutPreference),te=Q(o=>o.diffFileLayout),z=Q(o=>o.setDiffFileLayout),ue=Q(o=>o.diffWrapLines),ye=Q(o=>o.setDiffWrapLines),de=Q(o=>o.openContextFileAtLine),fe=Bt(o=>o.currentSessionId),pe=Wt(fe??""),we=ue,m=T==="staged"?!0:T==="working"?!1:null,D=m??w,$=b||f<=768,je=!n&&!$&&f>=1024,me=i.useRef(null),{branchDiffs:ie,branchDiffError:ke,branchDiffLoading:K,lastTurnDiffs:G,lastTurnDiffData:it,branchDiffData:ot}=yn({activeDiffScope:T,effectiveDirectory:c,branchBase:l,branchHead:p,git:x,sessionMessageRecords:pe}),H=i.useMemo(()=>{if(T==="turn"||T==="branch")return(T==="branch"?ie:G).map(M=>({path:M.file??"",index:"",working_dir:bn(M.status),insertions:M.additions??0,deletions:M.deletions??0,isNew:M.status==="added"})).filter(M=>M.path).sort((M,X)=>M.path.localeCompare(X.path));if(!u?.files)return[];const o=u.diffStats??{},v=T==="staged"?We:T==="working"?Oe:()=>!0;return u.files.filter(v).map(S=>({...S,insertions:o[S.path]?.insertions??0,deletions:o[S.path]?.deletions??0,isNew:Vt(S)})).sort((S,M)=>S.path.localeCompare(M.path))},[T,ie,G,u]),at=i.useMemo(()=>u?.files?u.files.filter(Oe).length:0,[u]),lt=i.useMemo(()=>u?.files?u.files.filter(We).length:0,[u]),ct=G.length,ut=u?.files?.length??0,dt=ie.length,{diffScrollRef:ft,pinnedStackedTarget:pt,pendingScrollTargetRef:he,shouldPinAfterAlignRef:ge,pendingScrollAnchorRestoreRef:Ie,lastScrollAnchorRef:$e,captureScrollAnchor:Pe,cancelPendingScrollAlignment:xe,queueVisibleStackedFilesSync:Le,registerSectionRef:mt,scrollToFile:_e}=jn({pinSelectedFileHeaderToTopOnNavigate:r,scrollRequestNonce:Z,changedFiles:H,expandedFiles:A,setMountedStackedFiles:N,fileDiffRefreshNonce:P}),be=i.useCallback(o=>{F(v=>{if(v.has(o))return v;const S=new Set(v);return S.add(o),S})},[]),Re=i.useMemo(()=>H.map(o=>o.path).join("\0"),[H]);i.useEffect(()=>{const o=Re?Re.split("\0"):[],v=new Set(o),S=`${c??""}:${T}:${t?"collapsed":"default"}`,M=me.current!==S;me.current=S,F(X=>{if(M){const oe=t?0:mn(o.length);return new Set(o.slice(0,oe))}let Se=!1;const Fe=new Set;for(const oe of X){if(!v.has(oe)){Se=!0;continue}Fe.add(oe)}return Se?Fe:X}),N(X=>{if(M)return new Set;let Se=!1;const Fe=new Set;for(const oe of X){if(!v.has(oe)){Se=!0;continue}Fe.add(oe)}return Se?Fe:X})},[T,Re,c,N,t]);const Ee=i.useCallback(o=>{const v=te[o.path];if(v)return v;if(Y==="inline")return"inline";if(Y==="side-by-side")return"side-by-side";const S=f<pn;return o.isNew||S?"inline":"side-by-side"},[te,Y,f]),ht=i.useMemo(()=>H.length===0?null:H.every(o=>Ee(o)==="side-by-side")?"side-by-side":"inline",[H,Ee]);i.useEffect(()=>{c&&(g(c),R(c,x))},[c,g,R,x]),i.useEffect(()=>{if(c)return Ot.onGitRefreshHint(o=>{Be(o.directory)===Be(c)&&(o.paths?.length&&(Ie.current=Pe()??$e.current,k(c,o.paths),le(v=>{const S=new Map(v);for(const M of o.paths??[])S.set(M,(S.get(M)??0)+1);return S})),I(c,x,{silent:!0}))})},[Pe,k,c,I,x,$e,Ie]),i.useEffect(()=>{T!=="all"&&!O||W&&(O&&ee(O),y(W),j(O==="staged"||!O&&ce),re(null),ge.current=!0,he.current=W,be(W),se(o=>o+1))},[T,be,W,O,ce,he,re,ge]),i.useEffect(()=>{if(T==="all")return;const o=d?.trim();o&&(y(o),j(T==="staged"),ge.current=!0,he.current=o,be(o),se(v=>v+1))},[T,be,he,ge,d]),i.useEffect(()=>{if(!E)return;H.some(v=>v.path===E)||(y(null),j(!1))},[H,E]);const gt=i.useCallback((o,v)=>{xe(),F(S=>{const M=S.has(o);if(v===M)return S;const X=new Set(S);return v?X.add(o):X.delete(o),X}),v||N(S=>{if(!S.has(o))return S;const M=new Set(S);return M.delete(o),M}),Le()},[xe,Le,N]),xt=i.useCallback(()=>{xe(),F(o=>o.size>0?new Set:new Set(H.map(v=>v.path))),N(new Set),Le()},[xe,H,Le,N]),bt=i.useCallback(o=>{},[]),yt=i.useCallback(o=>{xe(),y(o),j(!1),ge.current=!0,he.current=o,be(o),se(v=>v+1),_e(o)},[xe,be,he,_e,ge]),wt=i.useCallback(o=>{const v=o==="side-by-side"?"side-by-side":"inline";H.forEach(S=>{z(S.path,v)})},[H,z]),{openingEditorFilePath:jt,openFileInEditorAtChange:St}=Sn({effectiveDirectory:c,activeDiffStaged:D,git:x,files:h,setDiff:V,openContextFileAtLine:de});return{git:x,files:h,effectiveDirectory:c,screenWidth:f,isMobile:b,isGitRepo:L,status:u,isLoadingStatus:C,activeDiffScope:T,setActiveDiffScope:ee,branchDiffs:ie,branchDiffError:ke,branchDiffLoading:K,diffWrapLines:we,setDiffWrapLines:ye,forcedStaged:m,displayFileStaged:w,displayFile:E,pinnedStackedTarget:pt,expandedFiles:A,mountedStackedFiles:q,loadFullFiles:_,setLoadFullFiles:B,fileDiffRefreshNonce:P,showFileSidebar:je,diffScrollRef:ft,lastTurnDiffData:it,branchDiffData:ot,changedFiles:H,workingFileCount:at,stagedFileCount:lt,turnFileCount:ct,allFileCount:ut,branchFileCount:dt,currentLayoutForAllFiles:ht,openingEditorFilePath:jt,registerSectionRef:mt,handleStackedEntryExpandedChange:gt,handleExpandOrCollapseAll:xt,handleSelectFile:bt,handleSelectFileAndScroll:yt,handleHeaderLayoutChange:wt,openFileInEditorAtChange:St,getLayoutForFile:Ee}}const Er=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:n=!1,pinSelectedFileHeaderToTopOnNavigate:t=!1,showOpenInEditorAction:r=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:p=null,branchHead:d=null,targetFilePath:x=null,flushContent:h=!1})=>{const{effectiveDirectory:c,isGitRepo:f,status:b,isLoadingStatus:L,activeDiffScope:u,setActiveDiffScope:C,branchDiffError:g,branchDiffLoading:R,diffWrapLines:I,setDiffWrapLines:k,forcedStaged:V,displayFileStaged:E,displayFile:y,pinnedStackedTarget:w,expandedFiles:j,mountedStackedFiles:A,loadFullFiles:F,setLoadFullFiles:q,fileDiffRefreshNonce:N,showFileSidebar:_,diffScrollRef:B,lastTurnDiffData:Z,branchDiffData:se,changedFiles:P,workingFileCount:le,stagedFileCount:T,turnFileCount:ee,allFileCount:W,branchFileCount:ce,currentLayoutForAllFiles:O,openingEditorFilePath:re,registerSectionRef:Y,handleStackedEntryExpandedChange:te,handleExpandOrCollapseAll:z,handleSelectFile:ue,handleSelectFileAndScroll:ye,handleHeaderLayoutChange:de,openFileInEditorAtChange:fe,getLayoutForFile:pe}=Fn({hideStackedFileSidebar:s,stackedDefaultCollapsedAll:n,pinSelectedFileHeaderToTopOnNavigate:t,diffScope:a,branchBase:p,branchHead:d,targetFilePath:x}),we=()=>{if(!c)return null;const D=$=>V!==null?V:E&&$===y;return e.jsxs("div",{className:J("flex min-w-0 flex-1 min-h-0 h-full",h?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[_&&e.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[e.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:P.length})]}),e.jsx(rn,{changedFiles:P,selectedFile:null,onSelectFile:ye})]}),e.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:e.jsx(Ye,{ref:B,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:e.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:P.map($=>e.jsx(fn,{directory:c,file:$,layout:pe($),wrapLines:I,isSelected:!1,isExpanded:j.has($.path),isMounted:A.has($.path)||$.path===w,onSelect:ue,onExpandedChange:te,registerSectionRef:Y,showOpenInEditorAction:r&&u!=="turn"&&u!=="branch",isOpeningInEditor:re===$.path,onOpenInEditor:(je,me)=>{fe(je,me)},staged:D($.path),showFileActions:u!=="turn"&&u!=="branch",loadFullFiles:F,initialDiffData:u==="turn"?Z.get($.path)??null:u==="branch"?se.get($.path)??null:null},`${$.path}:${N.get($.path)??0}`))})})})]})},m=()=>c?u!=="turn"&&L&&!b?e.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(U,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):u!=="turn"&&u!=="branch"&&f===!1?e.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Not a git repository. Use the Git tab to initialize or change directories."}):u==="branch"&&R?e.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(U,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):u==="branch"&&g?e.jsx("div",{className:"flex flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground",children:`Failed to load branch changes: ${g}`}):P.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):we():e.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"});return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[e.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(f!==!1||u==="turn")&&(u==="all"||u==="working"||u==="staged"||u==="turn"||u==="branch")?e.jsx(Yt,{scope:u,isGitRepo:f,branchAvailable:!!(p&&d),allCount:W,workingCount:le,stagedCount:T,turnCount:ee,branchCount:ce,onScopeChange:D=>{C(D),l?.(D)}}):e.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:e.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:L&&!b?"Loading changes...":P.length===1?`${P.length} file changed`:`${P.length} files changed`})}),P.length>0&&e.jsxs(Ce,{variant:"ghost",size:"sm",onClick:z,className:J("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:j.size>0?"Collapse all":"Expand all",children:[e.jsx(U,{name:"expand-up-down",className:"size-4"}),e.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:j.size>0?"Collapse all":"Expand all"})]}),P.length>0&&u!=="turn"&&u!=="branch"&&e.jsxs(zt,{children:[e.jsx(Gt,{asChild:!0,children:e.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>q(D=>!D),"aria-pressed":F,"aria-label":F?"Unload full files":"Load full files",className:J("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",F&&"bg-interactive-selection text-interactive-selection-foreground"),children:e.jsx(U,{name:"file-download",className:"size-4"})})}),e.jsx(Ht,{children:e.jsx("p",{children:F?"Unload full files":"Load full files"})})]}),P.length>0&&e.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>k(!I),className:J("h-5 w-5 p-0 transition-opacity",I?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:I?"Disable line wrap":"Enable line wrap",children:e.jsx(U,{name:"text-wrap",className:"size-4"})}),O&&e.jsx(tt,{mode:O==="side-by-side"?"side-by-side":"unified",onModeChange:de})]}),m()]})};export{Er as DiffView};