@surething/cockpit 1.0.177 → 1.0.179

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 (131) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +16 -16
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next-prod/server/app/_global-error.html +2 -2
  7. package/.next-prod/server/app/_global-error.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next-prod/server/app/_not-found.html +2 -2
  16. package/.next-prod/server/app/_not-found.rsc +1 -1
  17. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +1 -1
  20. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next-prod/server/app/api/bash/route_client-reference-manifest.js +1 -1
  24. package/.next-prod/server/app/api/chat/route_client-reference-manifest.js +1 -1
  25. package/.next-prod/server/app/api/claude-stats/route_client-reference-manifest.js +1 -1
  26. package/.next-prod/server/app/api/commands/route_client-reference-manifest.js +1 -1
  27. package/.next-prod/server/app/api/comments/route_client-reference-manifest.js +1 -1
  28. package/.next-prod/server/app/api/db/columns/route_client-reference-manifest.js +1 -1
  29. package/.next-prod/server/app/api/db/connect/route_client-reference-manifest.js +1 -1
  30. package/.next-prod/server/app/api/db/disconnect/route_client-reference-manifest.js +1 -1
  31. package/.next-prod/server/app/api/db/export/route_client-reference-manifest.js +1 -1
  32. package/.next-prod/server/app/api/db/query/route_client-reference-manifest.js +1 -1
  33. package/.next-prod/server/app/api/db/schemas/route_client-reference-manifest.js +1 -1
  34. package/.next-prod/server/app/api/extension/version/route_client-reference-manifest.js +1 -1
  35. package/.next-prod/server/app/api/file/route_client-reference-manifest.js +1 -1
  36. package/.next-prod/server/app/api/files/blame/route_client-reference-manifest.js +1 -1
  37. package/.next-prod/server/app/api/files/clipboard/route_client-reference-manifest.js +1 -1
  38. package/.next-prod/server/app/api/files/copy/route_client-reference-manifest.js +1 -1
  39. package/.next-prod/server/app/api/files/delete/route_client-reference-manifest.js +1 -1
  40. package/.next-prod/server/app/api/files/expanded/route_client-reference-manifest.js +1 -1
  41. package/.next-prod/server/app/api/files/index/route_client-reference-manifest.js +1 -1
  42. package/.next-prod/server/app/api/files/init/route_client-reference-manifest.js +1 -1
  43. package/.next-prod/server/app/api/files/paste/route_client-reference-manifest.js +1 -1
  44. package/.next-prod/server/app/api/files/read/route_client-reference-manifest.js +1 -1
  45. package/.next-prod/server/app/api/files/readdir/route_client-reference-manifest.js +1 -1
  46. package/.next-prod/server/app/api/files/recent/route_client-reference-manifest.js +1 -1
  47. package/.next-prod/server/app/api/files/save/route_client-reference-manifest.js +1 -1
  48. package/.next-prod/server/app/api/files/search/route_client-reference-manifest.js +1 -1
  49. package/.next-prod/server/app/api/git/branch-diff/route_client-reference-manifest.js +1 -1
  50. package/.next-prod/server/app/api/git/branches/route_client-reference-manifest.js +1 -1
  51. package/.next-prod/server/app/api/git/commit-diff/route_client-reference-manifest.js +1 -1
  52. package/.next-prod/server/app/api/git/commits/route_client-reference-manifest.js +1 -1
  53. package/.next-prod/server/app/api/git/diff/route_client-reference-manifest.js +1 -1
  54. package/.next-prod/server/app/api/git/discard/route_client-reference-manifest.js +1 -1
  55. package/.next-prod/server/app/api/git/stage/route_client-reference-manifest.js +1 -1
  56. package/.next-prod/server/app/api/git/status/route_client-reference-manifest.js +1 -1
  57. package/.next-prod/server/app/api/git/unstage/route_client-reference-manifest.js +1 -1
  58. package/.next-prod/server/app/api/git/worktree/route_client-reference-manifest.js +1 -1
  59. package/.next-prod/server/app/api/global-state/route_client-reference-manifest.js +1 -1
  60. package/.next-prod/server/app/api/jupyter/load/route_client-reference-manifest.js +1 -1
  61. package/.next-prod/server/app/api/jupyter/save/route_client-reference-manifest.js +1 -1
  62. package/.next-prod/server/app/api/jupyter/shutdown/route_client-reference-manifest.js +1 -1
  63. package/.next-prod/server/app/api/lsp/definition/route_client-reference-manifest.js +1 -1
  64. package/.next-prod/server/app/api/lsp/hover/route_client-reference-manifest.js +1 -1
  65. package/.next-prod/server/app/api/lsp/references/route_client-reference-manifest.js +1 -1
  66. package/.next-prod/server/app/api/lsp/status/route_client-reference-manifest.js +1 -1
  67. package/.next-prod/server/app/api/lsp/warmup/route_client-reference-manifest.js +1 -1
  68. package/.next-prod/server/app/api/mysql/columns/route_client-reference-manifest.js +1 -1
  69. package/.next-prod/server/app/api/mysql/connect/route_client-reference-manifest.js +1 -1
  70. package/.next-prod/server/app/api/mysql/disconnect/route_client-reference-manifest.js +1 -1
  71. package/.next-prod/server/app/api/mysql/export/route_client-reference-manifest.js +1 -1
  72. package/.next-prod/server/app/api/mysql/query/route_client-reference-manifest.js +1 -1
  73. package/.next-prod/server/app/api/mysql/schemas/route_client-reference-manifest.js +1 -1
  74. package/.next-prod/server/app/api/note/route_client-reference-manifest.js +1 -1
  75. package/.next-prod/server/app/api/open-cursor/route_client-reference-manifest.js +1 -1
  76. package/.next-prod/server/app/api/open-vscode/route_client-reference-manifest.js +1 -1
  77. package/.next-prod/server/app/api/pick-folder/route_client-reference-manifest.js +1 -1
  78. package/.next-prod/server/app/api/pinned-sessions/route_client-reference-manifest.js +1 -1
  79. package/.next-prod/server/app/api/project-settings/route_client-reference-manifest.js +1 -1
  80. package/.next-prod/server/app/api/project-state/route_client-reference-manifest.js +1 -1
  81. package/.next-prod/server/app/api/projects/route_client-reference-manifest.js +1 -1
  82. package/.next-prod/server/app/api/redis/command/route_client-reference-manifest.js +1 -1
  83. package/.next-prod/server/app/api/redis/connect/route_client-reference-manifest.js +1 -1
  84. package/.next-prod/server/app/api/redis/delete/route_client-reference-manifest.js +1 -1
  85. package/.next-prod/server/app/api/redis/disconnect/route_client-reference-manifest.js +1 -1
  86. package/.next-prod/server/app/api/redis/get/route_client-reference-manifest.js +1 -1
  87. package/.next-prod/server/app/api/redis/keys/route_client-reference-manifest.js +1 -1
  88. package/.next-prod/server/app/api/redis/set/route_client-reference-manifest.js +1 -1
  89. package/.next-prod/server/app/api/review/[id]/comments/route_client-reference-manifest.js +1 -1
  90. package/.next-prod/server/app/api/review/[id]/replies/route_client-reference-manifest.js +1 -1
  91. package/.next-prod/server/app/api/review/[id]/route_client-reference-manifest.js +1 -1
  92. package/.next-prod/server/app/api/review/identify/route_client-reference-manifest.js +1 -1
  93. package/.next-prod/server/app/api/review/order/route_client-reference-manifest.js +1 -1
  94. package/.next-prod/server/app/api/review/route_client-reference-manifest.js +1 -1
  95. package/.next-prod/server/app/api/review/share-info/route_client-reference-manifest.js +1 -1
  96. package/.next-prod/server/app/api/review/users/route_client-reference-manifest.js +1 -1
  97. package/.next-prod/server/app/api/scheduled-tasks/route_client-reference-manifest.js +1 -1
  98. package/.next-prod/server/app/api/services/config/route_client-reference-manifest.js +1 -1
  99. package/.next-prod/server/app/api/services/scripts/route_client-reference-manifest.js +1 -1
  100. package/.next-prod/server/app/api/session/[sessionId]/fork/route_client-reference-manifest.js +1 -1
  101. package/.next-prod/server/app/api/session/[sessionId]/history/route_client-reference-manifest.js +1 -1
  102. package/.next-prod/server/app/api/session-by-path/route_client-reference-manifest.js +1 -1
  103. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route_client-reference-manifest.js +1 -1
  104. package/.next-prod/server/app/api/sessions/projects/route_client-reference-manifest.js +1 -1
  105. package/.next-prod/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  106. package/.next-prod/server/app/api/settings/route_client-reference-manifest.js +1 -1
  107. package/.next-prod/server/app/api/terminal/aliases/route_client-reference-manifest.js +1 -1
  108. package/.next-prod/server/app/api/terminal/autocomplete/route_client-reference-manifest.js +1 -1
  109. package/.next-prod/server/app/api/terminal/bubble-order/route_client-reference-manifest.js +1 -1
  110. package/.next-prod/server/app/api/terminal/env/route_client-reference-manifest.js +1 -1
  111. package/.next-prod/server/app/api/terminal/history/route_client-reference-manifest.js +1 -1
  112. package/.next-prod/server/app/api/version/route_client-reference-manifest.js +1 -1
  113. package/.next-prod/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  114. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  115. package/.next-prod/server/app/project/page.js +1 -1
  116. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  117. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  118. package/.next-prod/server/app-paths-manifest.json +16 -16
  119. package/.next-prod/server/pages/404.html +2 -2
  120. package/.next-prod/server/pages/500.html +2 -2
  121. package/.next-prod/server/server-reference-manifest.json +1 -1
  122. package/.next-prod/static/chunks/app/project/{page-fb1ff1d5d382977d.js → page-5f44bd5f9edf4fdc.js} +1 -1
  123. package/.next-prod/trace +12 -12
  124. package/.next-prod/trace-build +1 -1
  125. package/README.md +11 -1
  126. package/README.zh.md +11 -1
  127. package/bin/cock.mjs +71 -15
  128. package/package.json +1 -1
  129. package/server.mjs +3 -1
  130. /package/.next-prod/static/{GxqgcsR_qHg08TC1-Wj7V → DScwtrD9gEIvZsD0OBtGE}/_buildManifest.js +0 -0
  131. /package/.next-prod/static/{GxqgcsR_qHg08TC1-Wj7V → DScwtrD9gEIvZsD0OBtGE}/_ssgManifest.js +0 -0
@@ -26,4 +26,4 @@ Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[e,x,l,v,c,a,M,O,
26
26
  font-size: .6rem;
27
27
  font-weight: bold;
28
28
  color: hsl(${Math.max(0,Math.min(120-120*d,120))}deg 100% 31%);`,null==c?void 0:c.key)}return(null==c?void 0:c.onChange)&&!(f&&c.skipInitialOnChange)&&c.onChange(d),f=!1,d}return g.updateDeps=a=>{e=a},g}function g(a,b){if(void 0!==a)return a;throw Error(`Unexpected undefined${b?`: ${b}`:""}`)}let h=a=>{let{offsetWidth:b,offsetHeight:c}=a;return{width:b,height:c}},i=a=>a,j=a=>{let b=Math.max(a.startIndex-a.overscan,0),c=Math.min(a.endIndex+a.overscan,a.count-1),d=[];for(let a=b;a<=c;a++)d.push(a);return d},k=(a,b)=>{let c=a.scrollElement;if(!c)return;let d=a.targetWindow;if(!d)return;let e=a=>{let{width:c,height:d}=a;b({width:Math.round(c),height:Math.round(d)})};if(e(h(c)),!d.ResizeObserver)return()=>{};let f=new d.ResizeObserver(b=>{let d=()=>{let a=b[0];if(null==a?void 0:a.borderBoxSize){let b=a.borderBoxSize[0];if(b)return void e({width:b.inlineSize,height:b.blockSize})}e(h(c))};a.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(d):d()});return f.observe(c,{box:"border-box"}),()=>{f.unobserve(c)}},l={passive:!0},m="u"<typeof window||"onscrollend"in window,n=(a,b)=>{var c,d;let e,f=a.scrollElement;if(!f)return;let g=a.targetWindow;if(!g)return;let h=0,i=a.options.useScrollendEvent&&m?()=>void 0:(c=()=>{b(h,!1)},d=a.options.isScrollingResetDelay,function(...a){g.clearTimeout(e),e=g.setTimeout(()=>c.apply(this,a),d)}),j=c=>()=>{let{horizontal:d,isRtl:e}=a.options;h=d?f.scrollLeft*(e&&-1||1):f.scrollTop,i(),b(h,c)},k=j(!0),n=j(!1);f.addEventListener("scroll",k,l);let o=a.options.useScrollendEvent&&m;return o&&f.addEventListener("scrollend",n,l),()=>{f.removeEventListener("scroll",k),o&&f.removeEventListener("scrollend",n)}},o=(a,b,c)=>{if(null==b?void 0:b.borderBoxSize){let a=b.borderBoxSize[0];if(a)return Math.round(a[c.options.horizontal?"inlineSize":"blockSize"])}return a[c.options.horizontal?"offsetWidth":"offsetHeight"]},p=(a,{adjustments:b=0,behavior:c},d)=>{var e,f;null==(f=null==(e=d.scrollElement)?void 0:e.scrollTo)||f.call(e,{[d.options.horizontal?"left":"top"]:a+b,behavior:c})};class q{constructor(a){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let a=null,b=()=>a||(this.targetWindow&&this.targetWindow.ResizeObserver?a=new this.targetWindow.ResizeObserver(a=>{a.forEach(a=>{let b=()=>{this._measureElement(a.target,a)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(b):b()})}):null);return{disconnect:()=>{var c;null==(c=b())||c.disconnect(),a=null},observe:a=>{var c;return null==(c=b())?void 0:c.observe(a,{box:"border-box"})},unobserve:a=>{var c;return null==(c=b())?void 0:c.unobserve(a)}}})(),this.range=null,this.setOptions=a=>{Object.entries(a).forEach(([b,c])=>{void 0===c&&delete a[b]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:i,rangeExtractor:j,onChange:()=>{},measureElement:o,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...a}},this.notify=a=>{var b,c;null==(c=(b=this.options).onChange)||c.call(b,this,a)},this.maybeNotify=f(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),a=>{this.notify(a)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(a=>a()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var a;let b=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==b){if(this.cleanup(),!b)return void this.maybeNotify();this.scrollElement=b,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(a=this.scrollElement)?void 0:a.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,b)=>{this.scrollAdjustments=0,this.scrollDirection=b?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=b,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(a,b)=>{let c=new Map,d=new Map;for(let e=b-1;e>=0;e--){let b=a[e];if(c.has(b.lane))continue;let f=d.get(b.lane);if(null==f||b.end>f.end?d.set(b.lane,b):b.end<f.end&&c.set(b.lane,!0),c.size===this.options.lanes)break}return d.size===this.options.lanes?Array.from(d.values()).sort((a,b)=>a.end===b.end?a.index-b.index:a.end-b.end)[0]:void 0},this.getMeasurementOptions=f(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(a,b,c,d,e,f)=>(void 0!==this.prevLanes&&this.prevLanes!==f&&(this.lanesChangedFlag=!0),this.prevLanes=f,this.pendingMeasuredCacheIndexes=[],{count:a,paddingStart:b,scrollMargin:c,getItemKey:d,enabled:e,lanes:f}),{key:!1}),this.getMeasurements=f(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:a,paddingStart:b,scrollMargin:c,getItemKey:d,enabled:e,lanes:f},g)=>{if(!e)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>a)for(let b of this.laneAssignments.keys())b>=a&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(a=>{this.itemSizeCache.set(a.key,a.size)}));let h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===a&&(this.lanesSettling=!1);let i=this.measurementsCache.slice(0,h),j=Array(f).fill(void 0);for(let a=0;a<h;a++){let b=i[a];b&&(j[b.lane]=a)}for(let e=h;e<a;e++){let a,f,h=d(e),k=this.laneAssignments.get(e);if(void 0!==k&&this.options.lanes>1){let d=j[a=k],e=void 0!==d?i[d]:void 0;f=e?e.end+this.options.gap:b+c}else{let d=1===this.options.lanes?i[e-1]:this.getFurthestMeasurement(i,e);f=d?d.end+this.options.gap:b+c,a=d?d.lane:e%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(e,a)}let l=g.get(h),m="number"==typeof l?l:this.options.estimateSize(e),n=f+m;i[e]={index:e,start:f,size:m,end:n,key:h,lane:a},j[a]=e}return this.measurementsCache=i,i},{key:!1,debug:()=>this.options.debug}),this.calculateRange=f(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(a,b,c,d)=>this.range=a.length>0&&b>0?function({measurements:a,outerSize:b,scrollOffset:c,lanes:d}){let e=a.length-1;if(a.length<=d)return{startIndex:0,endIndex:e};let f=r(0,e,b=>a[b].start,c),g=f;if(1===d)for(;g<e&&a[g].end<c+b;)g++;else if(d>1){let h=Array(d).fill(0);for(;g<e&&h.some(a=>a<c+b);){let b=a[g];h[b.lane]=b.end,g++}let i=Array(d).fill(c+b);for(;f>=0&&i.some(a=>a>=c);){let b=a[f];i[b.lane]=b.start,f--}f=Math.max(0,f-f%d),g=Math.min(e,g+(d-1-g%d))}return{startIndex:f,endIndex:g}}({measurements:a,outerSize:b,scrollOffset:c,lanes:d}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=f(()=>{let a=null,b=null,c=this.calculateRange();return c&&(a=c.startIndex,b=c.endIndex),this.maybeNotify.updateDeps([this.isScrolling,a,b]),[this.options.rangeExtractor,this.options.overscan,this.options.count,a,b]},(a,b,c,d,e)=>null===d||null===e?[]:a({startIndex:d,endIndex:e,overscan:b,count:c}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=a=>{let b=this.options.indexAttribute,c=a.getAttribute(b);return c?parseInt(c,10):(console.warn(`Missing attribute name '${b}={index}' on measured element.`),-1)},this._measureElement=(a,b)=>{let c=this.indexFromElement(a),d=this.measurementsCache[c];if(!d)return;let e=d.key,f=this.elementsCache.get(e);f!==a&&(f&&this.observer.unobserve(f),this.observer.observe(a),this.elementsCache.set(e,a)),a.isConnected&&this.resizeItem(c,this.options.measureElement(a,b,this))},this.resizeItem=(a,b)=>{let c=this.measurementsCache[a];if(!c)return;let d=b-(this.itemSizeCache.get(c.key)??c.size);0!==d&&((void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(c,d,this):c.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=d,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(c.index),this.itemSizeCache=new Map(this.itemSizeCache.set(c.key,b)),this.notify(!1))},this.measureElement=a=>{a?this._measureElement(a,void 0):this.elementsCache.forEach((a,b)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(b))})},this.getVirtualItems=f(()=>[this.getVirtualIndexes(),this.getMeasurements()],(a,b)=>{let c=[];for(let d=0,e=a.length;d<e;d++){let e=b[a[d]];c.push(e)}return c},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=a=>{let b=this.getMeasurements();if(0!==b.length)return g(b[r(0,b.length-1,a=>g(b[a]).start,a)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let a=this.scrollElement.document.documentElement;return this.options.horizontal?a.scrollWidth-this.scrollElement.innerWidth:a.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(a,b,c=0)=>{if(!this.scrollElement)return 0;let d=this.getSize(),e=this.getScrollOffset();return"auto"===b&&(b=a>=e+d?"end":"start"),"center"===b?a+=(c-d)/2:"end"===b&&(a-=d),Math.max(Math.min(this.getMaxScrollOffset(),a),0)},this.getOffsetForIndex=(a,b="auto")=>{a=Math.max(0,Math.min(a,this.options.count-1));let c=this.measurementsCache[a];if(!c)return;let d=this.getSize(),e=this.getScrollOffset();if("auto"===b)if(c.end>=e+d-this.options.scrollPaddingEnd)b="end";else{if(!(c.start<=e+this.options.scrollPaddingStart))return[e,b];b="start"}if("end"===b&&a===this.options.count-1)return[this.getMaxScrollOffset(),b];let f="end"===b?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(f,b,c.size),b]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(a,{align:b="start",behavior:c}={})=>{"smooth"===c&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(a,b),{adjustments:void 0,behavior:c})},this.scrollToIndex=(a,{align:b="auto",behavior:c}={})=>{"smooth"===c&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),a=Math.max(0,Math.min(a,this.options.count-1)),this.currentScrollToIndex=a;let d=0,e=b=>{if(!this.targetWindow)return;let d=this.getOffsetForIndex(a,b);if(!d)return void console.warn("Failed to get offset for index:",a);let[e,g]=d;this._scrollToOffset(e,{adjustments:void 0,behavior:c}),this.targetWindow.requestAnimationFrame(()=>{let b=()=>{if(this.currentScrollToIndex!==a)return;let b=this.getScrollOffset(),c=this.getOffsetForIndex(a,g);c?1.01>Math.abs(c[0]-b)||f(g):console.warn("Failed to get offset for index:",a)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(b):b()})},f=b=>{this.targetWindow&&this.currentScrollToIndex===a&&(++d<10?this.targetWindow.requestAnimationFrame(()=>e(b)):console.warn(`Failed to scroll to index ${a} after 10 attempts.`))};e(b)},this.scrollBy=(a,{behavior:b}={})=>{"smooth"===b&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+a,{adjustments:void 0,behavior:b})},this.getTotalSize=()=>{var a;let b,c=this.getMeasurements();if(0===c.length)b=this.options.paddingStart;else if(1===this.options.lanes)b=(null==(a=c[c.length-1])?void 0:a.end)??0;else{let a=Array(this.options.lanes).fill(null),d=c.length-1;for(;d>=0&&a.some(a=>null===a);){let b=c[d];null===a[b.lane]&&(a[b.lane]=b.end),d--}b=Math.max(...a.filter(a=>null!==a))}return Math.max(b-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(a,{adjustments:b,behavior:c})=>{this.options.scrollToFn(a,{behavior:c,adjustments:b},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(a)}}let r=(a,b,c,d)=>{for(;a<=b;){let e=(a+b)/2|0,f=c(e);if(f<d)a=e+1;else{if(!(f>d))return e;b=e-1}}return a>0?a-1:0},s="u">typeof document?d.useLayoutEffect:d.useEffect;function t(a){return function({useFlushSync:a=!0,...b}){let c=d.useReducer(()=>({}),{})[1],f={...b,onChange:(d,f)=>{var g;a&&f?(0,e.flushSync)(c):c(),null==(g=b.onChange)||g.call(b,d,f)}},[g]=d.useState(()=>new q(f));return g.setOptions(f),s(()=>g._didMount(),[]),s(()=>g._willUpdate()),g}({observeElementRect:k,observeElementOffset:n,scrollToFn:p,...a})}},36645:(a,b,c)=>{"use strict";c.d(b,{_:()=>i,o:()=>h});var d=c(67484),e=c.n(d),f=c(41564);let g="json-search-highlight-style";function h(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[h,i]=(0,d.useState)(!1),[j,k]=(0,d.useState)(0),[l,m]=(0,d.useState)(0),n=(0,d.useRef)(null),o=(0,d.useRef)([]);(0,d.useCallback)(()=>{let b;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),o.current=[];let c=a.current;if(!c||!e){k(0),m(0);return}!function(){if(document.getElementById(g))return;let a=document.createElement("style");a.id=g,a.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(a)}();let d=c.textContent||"",f=h?e:e.toLowerCase(),i=h?d:d.toLowerCase(),j=[],l=0;for(;l<i.length;){let a=i.indexOf(f,l);if(-1===a)break;j.push([a,a+f.length]),l=a+1}if(0===j.length){k(0),m(0);return}let n=document.createTreeWalker(c,NodeFilter.SHOW_TEXT),p=0,q=0,r=[],s=null,t=0;for(;(b=n.nextNode())&&q<j.length;){let a=b.textContent?.length||0,c=p,d=p+a;for(;q<j.length;){let[a,e]=j[q];if(a>=d)break;if(!s)if(a>=c)(s=document.createRange()).setStart(b,a-c),t=e;else break;if(t<=d)s.setEnd(b,t-c),r.push(s),s=null,q++;else break}p=d}o.current=r,k(r.length),m(a=>r.length>0?Math.min(a,r.length-1):0),CSS.highlights&&r.length>0&&CSS.highlights.set("json-search",new Highlight(...r))},[a,e,h]);let p=(0,d.useCallback)((a,b)=>{let c=a.getBoundingClientRect();(b.top<c.top||b.bottom>c.bottom)&&(a.scrollTop+=b.top-c.top-c.height/2+b.height/2)},[]);(0,d.useCallback)(b=>{CSS.highlights?.delete("json-search-current");let c=o.current[b];if(!c||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(c));let d=c.getBoundingClientRect(),e=a.current?.parentElement;e&&p(e,d)},[a,p]);let q=(0,d.useCallback)(()=>{0!==j&&m(a=>(a+1)%j)},[j]),r=(0,d.useCallback)(()=>{0!==j&&m(a=>(a-1+j)%j)},[j]),s=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>n.current?.focus(),0)},[]),t=(0,d.useCallback)(()=>{c(!1),f(""),m(0)},[]),u=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?r():q()),"Escape"===a.key&&(a.preventDefault(),t())},[q,r,t]);return{isVisible:b,query:e,setQuery:f,caseSensitive:h,setCaseSensitive:i,matchCount:j,currentIndex:l,searchInputRef:n,open:s,close:t,goToNext:q,goToPrev:r,handleKeyDown:u}}function i({search:a}){return a.isVisible?e().createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},e().createElement("input",{ref:a.searchInputRef,type:"text",value:a.query,onChange:b=>a.setQuery(b.target.value),onKeyDown:a.handleKeyDown,placeholder:f.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e().createElement("button",{onClick:()=>a.setCaseSensitive(a=>!a),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${a.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:f.A.t("codeViewer.caseSensitive")},"Aa"),e().createElement("span",{className:"text-xs text-muted-foreground"},a.matchCount>0?`${a.currentIndex+1}/${a.matchCount}`:f.A.t("common.noMatch")),e().createElement("button",{onClick:a.goToPrev,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.previous")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),e().createElement("button",{onClick:a.goToNext,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.next")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),e().createElement("button",{onClick:a.close,className:"p-1 rounded hover:bg-accent",title:f.A.t("common.close")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},37957:(a,b,c)=>{Promise.resolve().then(c.bind(c,38476))},38476:(a,b,c)=>{"use strict";c.d(b,{TabManager:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManager() from the server but TabManager is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/project/TabManager.tsx","TabManager")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},42911:(a,b,c)=>{"use strict";c.d(b,{i:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(41564),h=c(23434),i=c(31172),j=c(81749);function k(a){if(0===a.length)return"";let b=[g.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===h.Un),d=a.filter(a=>a.filePath!==h.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{b.push(`[${c+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(g.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function l({isOpen:a,onClose:b,cwd:c,onNavigateToComment:g}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1);(0,e.useCallback)(async()=>{if(c){p(!0);try{let a=await fetch(`/api/comments?cwd=${encodeURIComponent(c)}&all=true`);if(a.ok){let b=await a.json();n(b.comments||[])}}catch(a){console.error("Failed to load comments:",a)}finally{p(!1)}}},[c]);let u=async a=>{try{(await fetch(`/api/comments?cwd=${encodeURIComponent(c)}&id=${encodeURIComponent(a)}`,{method:"DELETE"})).ok&&(n(b=>b.filter(b=>b.id!==a)),(0,h.Cm)())}catch(a){console.error("Failed to delete comment:",a)}},v=async a=>{r(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await fetch(`/api/files/read?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(a.filePath)}`);if(!d.ok)throw Error("Failed to read file");b=((await d.json()).content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=k([d]);await navigator.clipboard.writeText(e),(0,j.oR)(l("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{r(null)}},w=async()=>{if(0!==m.length){t(!0);try{let a=await (0,h.$3)(c),b=k(a);await navigator.clipboard.writeText(b),(0,j.oR)(l("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{t(!1)}}},x=m.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let y=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:l("comments.allComments")}),m.length>0&&(0,d.jsx)("button",{onClick:w,disabled:s,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:l("comments.copyAllComments"),children:s?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:o?(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:l("common.loading")}):0===m.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsx)("span",{children:l("comments.noComments")})]}):(0,d.jsx)("div",{className:"space-y-4",children:Object.entries(x).map(([a,b])=>(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-secondary border-b border-border",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===h.Un?l("comments.aiReply"):a}),(0,d.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",l("comments.nComments",{count:b.length}),")"]})]}),(0,d.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,d.jsx)("div",{className:"px-3 py-2 hover:bg-accent/50 cursor-pointer group",onClick:()=>g?.(a),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-brand font-mono",children:[l("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",l("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,d.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,d.jsx)("span",{className:"text-muted-foreground italic",children:l("comments.noContent")})})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a)},disabled:q===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50",title:l("common.copy"),children:q===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),u(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground hover:text-red-9 transition-opacity",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})},a.id)})})]},a))})}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border bg-secondary flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:l("comments.totalComments",{count:m.length})}),(0,d.jsx)("button",{onClick:async()=>{0===m.length||await (0,h.RP)(c)&&n([])},disabled:0===m.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:l("comments.clearAll")})]})]})});return(0,d.jsx)(i.Z,{children:y})}},43501:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>C.default,__next_app__:()=>K,handler:()=>M,routeModule:()=>L});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(89125),A=c(86439),B=c(77068),C=c(81227),D=c(61287),E=c(81494),F=c(70722),G=c(70753),H=c(43954),I={};for(let a in D)0>["default","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>D[a]);c.d(b,I);let J={children:["",{children:["project",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,8472)),"/home/runner/work/cockpit/cockpit/src/app/project/page.tsx"]}]},{metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]}.children,K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/project/page",pathname:"/project",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next-prod",relativeProjectDir:""});async function M(a,b,d){var I;L.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let N=!!(0,h.getRequestMeta)(a,"minimalMode"),O="/project/page";"/index"===O&&(O="/");let P=await L.prepare(a,b,{srcPage:O,multiZoneDraftMode:!1});if(!P)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Q,query:R,params:S,pageIsDynamic:T,buildManifest:U,nextFontManifest:V,reactLoadableManifest:W,serverActionsManifest:X,clientReferenceManifest:Y,subresourceIntegrityManifest:Z,prerenderManifest:$,isDraftMode:_,resolvedPathname:aa,revalidateOnlyGenerated:ab,routerServerContext:ac,nextConfig:ad,parsedUrl:ae,interceptionRoutePatterns:af,deploymentId:ag}=P,ah=(0,q.normalizeAppPath)(O),{isOnDemandRevalidate:ai}=P,aj=ad.experimental.ppr&&!ad.cacheComponents&&(0,H.isInterceptionRouteAppPath)(aa)?null:L.match(aa,$),ak=!!$.routes[aa],al=a.headers["user-agent"]||"",am=(0,t.getBotType)(al),an=(0,p.isHtmlBotRequest)(a),ao=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ap=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],aq=(0,r.getIsPossibleServerAction)(a),ar=(0,m.checkIsAppPPREnabled)(ad.experimental.ppr);if(!(0,h.getRequestMeta)(a,"postponed")&&ar&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let b=[];for await(let c of a)b.push(c);let c=Buffer.concat(b).toString("utf8");(0,h.addRequestMeta)(a,"postponed",c)}let as=ar&&(null==(I=$.routes[ah]??$.dynamicRoutes[ah])?void 0:I.renderingMode)==="PARTIALLY_STATIC",at=!1,au=!1,av=as?(0,h.getRequestMeta)(a,"postponed"):void 0,aw=as&&ap&&!ao;N&&(aw=aw&&!!av);let ax=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ay=(!an||!as)&&(!al||(0,p.shouldServeStreamingMetadata)(al,ad.htmlLimitedBots)),az=!!((aj||ak||$.routes[ah])&&!(an&&as)),aA=as&&!0===ad.cacheComponents,aB=!0===L.isDev||!az||"string"==typeof av||(aA&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aw&&!N:aw),aC=an&&as,aD=null;_||!az||aB||aq||av||aw||(aD=aa);let aE=aD;!aE&&L.isDev&&(aE=aa),L.isDev||_||!az||!ap||aw||(0,k.d)(a.headers);let aF={...D,tree:J,GlobalError:C.default,handler:M,routeModule:L,__next_app__:K};X&&Y&&(0,o.setManifestsSingleton)({page:O,clientReferenceManifest:Y,serverActionsManifest:X});let aG=a.method||"GET",aH=(0,g.getTracer)(),aI=aH.getActiveScopeSpan(),aJ=async()=>((null==ac?void 0:ac.render404)?await ac.render404(a,b,ae,!1):b.end("This page could not be found"),null);try{let f=L.getVaryHeader(aa,af);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aH.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aG} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aG} ${O}`)})},m=(0,h.getRequestMeta)(a,"incrementalCache"),o=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let l={query:R,params:S,page:ah,sharedContext:{buildId:Q},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aF,Component:(0,j.T)(aF),params:S,routeModule:L,page:O,postponed:f,shouldWaitOnAllReady:aC,serveStreamingMetadata:ay,supportsDynamicResponse:"string"==typeof f||aB,buildManifest:U,nextFontManifest:V,reactLoadableManifest:W,subresourceIntegrityManifest:Z,setCacheStatus:null==ac?void 0:ac.setCacheStatus,setIsrStatus:null==ac?void 0:ac.setIsrStatus,setReactDebugChannel:null==ac?void 0:ac.setReactDebugChannel,sendErrorsToBrowser:null==ac?void 0:ac.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),L.relativeProjectDir),isDraftMode:_,botType:am,isOnDemandRevalidate:ai,isPossibleServerAction:aq,assetPrefix:ad.assetPrefix,nextConfigOutput:ad.output,crossOrigin:ad.crossOrigin,trailingSlash:ad.trailingSlash,images:ad.images,previewProps:$.preview,deploymentId:ag,enableTainting:ad.experimental.taint,htmlLimitedBots:ad.htmlLimitedBots,reactMaxHeadersLength:ad.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:m,cacheLifeProfiles:ad.cacheLife,basePath:ad.basePath,serverActions:ad.experimental.serverActions,...at||au?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:at}:{},cacheComponents:!!ad.cacheComponents,experimental:{isRoutePPREnabled:as,expireTime:ad.expireTime,staleTimes:ad.experimental.staleTimes,dynamicOnHover:!!ad.experimental.dynamicOnHover,inlineCss:!!ad.experimental.inlineCss,authInterrupts:!!ad.experimental.authInterrupts,clientTraceMetadata:ad.experimental.clientTraceMetadata||[],clientParamParsingOrigins:ad.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,B.parseMaxPostponedStateSize)(ad.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>L.onRequestError(a,b,d,e,ac),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}};at&&(l.renderOpts.nextExport=!0,l.renderOpts.supportsDynamicResponse=!1,l.renderOpts.isDebugDynamicAccesses=at),i&&(l.renderOpts.supportsDynamicResponse=!1);let n=await k(e,l),{metadata:o}=n,{cacheControl:p,headers:q={},fetchTags:r,fetchMetrics:s}=o;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,az&&(null==p?void 0:p.revalidate)===0&&!L.isDev&&!as){let a=o.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${aa}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
29
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ai&&ab&&!f&&!N)return(null==ac?void 0:ac.render404)?await ac.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(k=(0,v.parseFallbackField)(aj.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(al)&&(!as||an)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!N&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aE&&!q&&!_&&T&&(l||!ak)){if((l||aj)&&k===v.FallbackMode.NOT_FOUND){if(ad.experimental.adapterPath)return await aJ();throw new A.NoFallbackError}if(as&&(ad.cacheComponents?!aw:!ap)){let b=l&&"string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:ah,c=l&&(null==aj?void 0:aj.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ad,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:$,isRoutePPREnabled:as,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:N});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ai||g||!av?void 0:av;if(aA&&!N&&m&&aw&&!j){let b=await m.get(aa,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(aa,m,as,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(at&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==aj?void 0:aj.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aD,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ad,prerenderManifest:$,waitUntil:d.waitUntil,isMinimalMode:N});if(_&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aD)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;az&&!aw&&(!n||ao)&&(N||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(av)l={revalidate:0,expire:void 0};else if(aw)l={revalidate:0,expire:void 0};else if(!L.isDev)if(_)l={revalidate:0,expire:void 0};else if(az){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ad.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];N&&az&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=aA?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(N&&az||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(N&&az&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ap&&as||(b.statusCode=q.status),!N&&q.status&&E.RedirectStatusCode[q.status]&&ap&&(b.statusCode=200),n&&!aw&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ap&&!_){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ad.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||N||ap)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:m.cacheControl});if(at)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aI)return await aH.withPropagatedContext(a.headers,()=>aH.trace(i.BaseServerSpan.handleRequest,{spanName:`${aG} ${O}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aG,"http.target":a.url}},q));await q(aI)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:O,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:az,isOnDemandRevalidate:ai})},!1,ac),b}}},43609:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(67484),e=c(94882);function f({cwd:a}){let[b,c]=(0,d.useState)([]),[f,g]=(0,d.useState)(null),[h,i]=(0,d.useState)(new Set),[j,k]=(0,d.useState)([]),[l,m]=(0,d.useState)(null),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)(new Set),[r,s]=(0,d.useState)(null),[t,u]=(0,d.useState)(""),[v,w]=(0,d.useState)(!1),[x,y]=(0,d.useState)(null),[z,A]=(0,d.useState)(!1),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(null),F=(0,d.useRef)(null),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(null),[K,L]=(0,d.useState)("center"),[M,N]=(0,d.useState)(null),[O,P]=(0,d.useState)(null),[Q,R]=(0,d.useState)(!1),[S,T]=(0,d.useState)([]),[U,V]=(0,d.useState)(!1),[W,X]=(0,d.useState)(null),[Y,Z]=(0,d.useState)(null),[$,_]=(0,d.useState)(!1),[aa,ab]=(0,d.useState)(!1),ac=(0,d.useMemo)(()=>j.map(a=>a.path).filter(Boolean),[j]),ad=(0,d.useMemo)(()=>(0,e.v3)(ac),[ac]),ae=(0,d.useMemo)(()=>new Set((0,e.tW)(ad)),[ad]),af=(0,d.useMemo)(()=>t?f?(0,e.KH)(f,t,v):(0,e.q3)(b,t,v):null,[b,f,t,v]),ag=r??p,ah=(0,d.useRef)(null),ai=(0,d.useCallback)(b=>{ah.current&&clearTimeout(ah.current),ah.current=setTimeout(async()=>{try{await fetch("/api/files/expanded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,paths:Array.from(b)})})}catch(a){console.error("Error saving expanded paths:",a)}},500)},[a]),aj=(0,d.useCallback)(async()=>{A(!0),E(null);try{let b=await fetch(`/api/files/init?cwd=${encodeURIComponent(a)}`),d=await b.json();d.error?E(d.error):(c(d.files||[]),d.expandedPaths&&Array.isArray(d.expandedPaths)&&q(new Set(d.expandedPaths)))}catch(a){console.error("Error loading files:",a),E("Failed to load files")}finally{A(!1)}},[a]),ak=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/index?cwd=${encodeURIComponent(a)}`),c=await b.json();c.paths&&g(c.paths)}catch(a){console.error("Error loading file index:",a)}},[a]),al=(0,d.useCallback)(async b=>{i(a=>new Set([...a,b]));try{let d=await fetch(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),f=await d.json();f.children&&c(a=>{if(!b){let b=new Map(a.map(a=>[a.path,a]));return f.children.map(a=>{let c=b.get(a.path);return c?.children&&a.isDirectory?{...a,children:c.children}:a})}let c=structuredClone(a),d=(0,e.MB)(c,b);return d&&(d.children=f.children),c})}catch(a){console.error("Error loading directory:",a)}finally{i(a=>{let c=new Set(a);return c.delete(b),c})}},[a]);(0,d.useRef)(h).current=h;let am=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/recent?cwd=${encodeURIComponent(a)}`),c=await b.json();k(c.files||[])}catch(a){console.error("Error loading recent files:",a)}},[a]),an=(0,d.useCallback)(async b=>{k(a=>{let c=a.filter(a=>a.path!==b);return[{path:b},...c].slice(0,15)});try{await fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b})})}catch(a){console.error("Error adding to recent files:",a)}},[a]),ao=(0,d.useCallback)((b,c,d,e)=>{k(a=>a.map(a=>a.path===b?{...a,scrollLine:c,cursorLine:d,cursorCol:e}:a)),fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b,scrollLine:c,cursorLine:d,cursorCol:e})}).catch(()=>{})},[a]),ap=(0,d.useCallback)(a=>j.find(b=>b.path===a),[j]),aq=(0,d.useCallback)(async b=>{let c=b||l;if(c){V(!0),X(null);try{let b=await fetch(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(c)}`),d=await b.json();d.error?X(d.error):T(d.blame||[])}catch(a){console.error("Error loading blame:",a),X("Failed to load blame info")}finally{V(!1)}}},[a,l]),ar=(0,d.useCallback)(async b=>{C(!0),o(null),R(!1),T([]),X(null),Z(null);try{let c=await fetch(`/api/files/read?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),d=await c.json();o(d),an(b),aq(b)}catch(a){console.error("Error loading file content:",a),o({type:"error",message:"Failed to load file"})}finally{C(!1)}},[a,an,aq]),as=(0,d.useCallback)(()=>{Q?R(!1):(R(!0),0===S.length&&aq())},[Q,S.length,aq]),at=(0,d.useCallback)((a,b)=>{if(!a)return;if(m(a),J(b??null),null==b){let b=j.find(b=>b.path===a);b?.scrollLine?(J(b.scrollLine),L("start"),N(b.cursorLine??null),P(b.cursorCol??null)):(L("center"),N(null),P(null))}else L("center"),N(null),P(null);ar(a);let c=a.split("/");if(c.length>1){let a=[];for(let b=1;b<c.length;b++)a.push(c.slice(0,b).join("/"));q(b=>{let c=new Set(b),d=!1;for(let b of a)c.has(b)||(c.add(b),d=!0);return d&&ai(c),d?c:b})}},[ar,ai,j]),au=(0,d.useCallback)(a=>{if(r)s(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c});else{let c=!p.has(a);if(q(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),ai(c),c}),c){let c=(0,e.MB)(b,a);c&&c.isDirectory&&!c.children&&al(a)}}},[r,ai,p,b,al]);return{files:b,setFiles:c,fileIndex:f,setFileIndex:g,loadingDirs:h,expandedPaths:p,setExpandedPaths:q,searchTreeExpandedPaths:r,setSearchTreeExpandedPaths:s,effectiveExpandedPaths:ag,searchQuery:t,setSearchQuery:u,searchExactMatch:v,setSearchDirExact:w,matchedPaths:af,creatingItem:x,setCreatingItem:y,isLoadingFiles:z,fileError:D,searchInputRef:F,shouldScrollToSelected:G,setShouldScrollToSelected:H,targetLineNumber:I,setTargetLineNumber:J,targetScrollAlign:K,setTargetScrollAlign:L,initialCursorLine:M,initialCursorCol:O,setInitialCursorLine:N,setInitialCursorCol:P,selectedPath:l,setSelectedPath:m,fileContent:n,setFileContent:o,isLoadingContent:B,recentFiles:j,recentFilePaths:ac,setRecentFiles:k,recentFilesTree:ad,recentTreeDirPaths:ae,showBlame:Q,setShowBlame:R,blameLines:S,isLoadingBlame:U,blameError:W,blameSelectedCommit:Y,setBlameSelectedCommit:Z,showMarkdownPreview:$,setShowMarkdownPreview:_,showEditor:aa,setShowEditor:ab,saveExpandedPaths:ai,loadFiles:aj,loadFileIndex:ak,loadDirectory:al,loadRecentFiles:am,addToRecentFiles:an,updateRecentFilePosition:ao,getRecentFilePosition:ap,loadFileContent:ar,loadBlame:aq,handleToggleBlame:as,handleSelectFile:at,handleToggle:au}}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},44218:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},45050:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},45214:(a,b,c)=>{"use strict";c.d(b,{G:()=>h,t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,range:c,codeContent:g,container:h,onSubmit:i,onClose:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=g?.split("\n").slice(0,5).join("\n"),u=!!g&&g.split("\n").length>5;return(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:[(0,d.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-amber-11",children:k("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:k("comments.lineRange",{start:c.start,end:c.end})})]})}),g&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[t,u&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:q,value:l,onChange:a=>m(a.target.value),placeholder:k("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:n,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!n&&l.trim()&&(o(!0),i(l.trim()))),"Escape"!==a.key||n||j()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:k(n?"comments.submitting":"comments.enterSubmit")})]})]})}function h({x:a,y:b,range:c,filePath:g,codeContent:h,container:i,onSubmit:j,onClose:k,isChatLoading:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=h?.split("\n").slice(0,5).join("\n"),u=!!h&&h.split("\n").length>5;return(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-brand",children:m("comments.askAI")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:m("comments.lineRange",{start:c.start,end:c.end})})]}),g&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:g})]}),h&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[t,u&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:q,value:n,onChange:a=>o(a.target.value),placeholder:m("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:l,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!l&&n.trim()&&(j(n.trim()),k())),"Escape"===a.key&&k()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:m(l?"comments.aiGenerating":"comments.enterSend")})]})]})}},45832:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(5811),j=a([i]);function k({results:a,loading:b,totalMatches:c,onSelect:d,onClose:i}){let{t:j}=(0,g.Bd)(),k=function(a){let[b,c]=(0,f.useState)(new Map),[d,e]=(0,f.useState)(!1);return(0,f.useRef)(0),b}(0);return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("searchResults.title")," ",!b&&j("searchResults.nMatches",{count:c})]}),(0,e.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.noResults")}):a.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a.path}),a.matches.map((b,c)=>{let f=`${a.path}:${b.lineNumber}`,g=k.get(f);return(0,e.jsxs)("button",{onClick:()=>d(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),g?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:g}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},46674:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},47033:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});var d=c(67484);function e({cwd:a,filePath:b}){let[c,e]=(0,d.useState)([]),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),j=(0,d.useCallback)(async()=>{if(a&&b){g(!0),i(null);try{let c=await fetch(`/api/comments?cwd=${encodeURIComponent(a)}&filePath=${encodeURIComponent(b)}`);if(c.ok){let a=await c.json();e(a.comments||[])}else i("Failed to load comments")}catch(a){i(a instanceof Error?a.message:"Unknown error")}finally{g(!1)}}},[a,b]),k=(0,d.useCallback)(async(c,d,f,g)=>{try{let h=await fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,startLine:c,endLine:d,content:f,...g?{selectedText:g}:{}})});if(h.ok){let a=await h.json();return e(b=>[...b,a.comment]),a.comment}}catch(a){console.error("Failed to add comment:",a)}return null},[a,b]),l=(0,d.useCallback)(async(b,c)=>{try{let d=await fetch("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})});if(d.ok){let a=await d.json();return e(c=>c.map(c=>c.id===b?a.comment:c)),!0}}catch(a){console.error("Failed to update comment:",a)}return!1},[a]),m=(0,d.useCallback)(async b=>{try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"})).ok)return e(a=>a.filter(a=>a.id!==b)),!0}catch(a){console.error("Failed to delete comment:",a)}return!1},[a]),n=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:f,error:h,addComment:k,updateComment:l,deleteComment:m,refresh:j,getCommentsForLine:n}}c(23434)},47237:(a,b,c)=>{"use strict";c.d(b,{Q:()=>e});var d=c(67484);function e(){let a=(0,d.useRef)([]),b=(0,d.useRef)([]),c=(0,d.useCallback)(c=>{a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),b.current=[]},[]),e=(0,d.useCallback)(c=>{if(0===a.current.length)return null;let d=a.current.pop();return b.current.push(c),b.current.length>50&&(b.current=b.current.slice(-50)),d},[]),f=(0,d.useCallback)(c=>{if(0===b.current.length)return null;let d=b.current.pop();return a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),d},[]);return{push:c,goBack:e,goForward:f,canGoBack:(0,d.useCallback)(()=>a.current.length>0,[]),canGoForward:(0,d.useCallback)(()=>b.current.length>0,[])}}},47408:(a,b,c)=>{"use strict";c.d(b,{A:()=>i});var d=c(67484);let e=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),f=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let h=(0,d.forwardRef)(({color:a="currentColor",size:b=24,strokeWidth:c=2,absoluteStrokeWidth:f,className:h="",children:i,iconNode:j,...k},l)=>(0,d.createElement)("svg",{ref:l,...g,width:b,height:b,stroke:a,strokeWidth:f?24*Number(c)/Number(b):c,className:e("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,b])=>(0,d.createElement)(a,b)),...Array.isArray(i)?i:[i]])),i=(a,b)=>{let c=(0,d.forwardRef)(({className:c,...g},i)=>(0,d.createElement)(h,{ref:i,iconNode:b,className:e(`lucide-${f(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,c),...g}));return c.displayName=f(a),c}},48464:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249);c(67484);var e=c(69005),f=c(44384);function g({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function h({tabs:a,activeTabId:b,unreadTabs:c,dragTabIndex:h,dragOverTabIndex:i,isPinned:j,onTogglePin:k,onSwitchTab:l,onCloseTab:m,onNewTab:n,onDragStart:o,onDragOver:p,onDrop:q,onDragEnd:r}){let{t:s}=(0,f.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[a.map((f,n)=>(0,d.jsx)(e.m,{content:f.title,delay:200,children:(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>o(n),onDragOver:a=>p(a,n),onDrop:()=>q(n),onDragEnd:r,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${f.id===b?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${h===n?"opacity-50":""} ${i===n?"border-l-2 border-brand":""}`,onClick:()=>l(f.id),children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(g,{number:n+1,isActive:f.id===b}),f.isLoading&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!f.isLoading&&c.has(f.id)&&f.id!==b&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),k&&j?.(f.id)&&!f.isLoading&&!(c.has(f.id)&&f.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k(f.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:s("tabBar.unpin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),k&&!j?.(f.id)&&!f.isLoading&&!(c.has(f.id)&&f.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k(f.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:s("tabBar.pin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,d.jsx)("span",{className:"max-w-32 truncate",children:f.title}),a.length>1&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m(f.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:s("tabBar.closeTab"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},f.id)),(0,d.jsx)("button",{onClick:n,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:s("tabBar.newTab"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})})}},49681:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},52620:(a,b,c)=>{"use strict";c.d(b,{JL:()=>h,Sn:()=>e,Xm:()=>f,po:()=>g});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);try{let c=await fetch("/api/lsp/definition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})});return(await c.json()).definitions||[]}catch(a){return console.error("[useLSP] definition error:",a),[]}finally{c(!1)}},[a]),loading:b}}function f(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),f=(0,d.useRef)(null),g=(0,d.useRef)(0),h=(0,d.useRef)(!1),i=(0,d.useRef)(null),j=(0,d.useRef)({x:0,y:0}),k=(0,d.useRef)(!1),l=(0,d.useRef)(null),m=(0,d.useCallback)(()=>{let a=i.current;a&&k.current&&(a.style.pointerEvents="none"),k.current=!1,l.current&&(i.current?.removeEventListener("mouseleave",l.current),l.current=null)},[]),n=(0,d.useCallback)(()=>{let a=i.current;if(!a||k.current)return;k.current=!0,h.current=!0,a.style.pointerEvents="auto";let b=()=>{h.current=!1,m(),g.current++,c(null)};l.current=b,a.addEventListener("mouseleave",b)},[m]),o=(0,d.useCallback)((b,d,h,i)=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current);let j=++g.current;e.current=setTimeout(async()=>{try{let e=await fetch("/api/lsp/hover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:h})}),f=await e.json();if(j!==g.current)return;f.hover&&f.hover.displayString&&c({...f.hover,x:i.x,y:i.y,filePath:b,line:d,column:h})}catch{}},300)},[a]),p=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current++,f.current=setTimeout(function(){if(h.current)return;let a=i.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=j.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void n()}c(null)},150)},[n]),q=(0,d.useCallback)(()=>{h.current=!0,f.current&&clearTimeout(f.current)},[]);return{hoverInfo:b,onTokenMouseEnter:o,onTokenMouseLeave:p,onCardMouseEnter:q,onCardMouseLeave:(0,d.useCallback)(()=>{h.current=!1,g.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current),h.current=!1,m(),g.current++,c(null)},[m]),tooltipElRef:i}}function g(a){let[b,c]=(0,d.useState)([]),[e,f]=(0,d.useState)(!1),[g,h]=(0,d.useState)(!1);return{references:b,loading:e,visible:g,findReferences:(0,d.useCallback)(async(b,d,e)=>{f(!0),h(!0);try{let f=await fetch("/api/lsp/references",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})}),g=await f.json();c(g.references||[])}catch(a){console.error("[useLSP] references error:",a),c([])}finally{f(!1)}},[a]),closeReferences:(0,d.useCallback)(()=>{h(!1),c([])},[])}}function h(a,b){(0,d.useRef)(null)}c(62862)},54017:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>J});var e=c(48249),f=c(67484),g=c(74429),h=c(2868),i=c(86402),j=c(81749),k=c(66254),l=c(95836),m=c(26068),n=c(79029),o=c(56929),p=c(94882),q=c(10164),r=c(66185),s=c(13928),t=c(6440),u=c(99470),v=c(43609),w=c(96666),x=c(86753),y=c(34371),z=c(52620),A=c(47237),B=c(44384),C=c(36645),D=c(62862),E=c(24463),F=c(1906),G=c(45832),H=c(92154),I=a([h,i,n,F,G]);function J({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:I,searchQueryTrigger:J}){let{t:K}=(0,B.Bd)(),{activeView:L}=(0,H.R8)(),[M,N]=(0,f.useState)(c),O=(0,f.useRef)(null),P=(0,f.useRef)(!1),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)(null),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)(1),Z=(0,f.useRef)(null),[$,_]=(0,f.useState)(null),aa=(0,f.useRef)(null),[ab,ac]=(0,f.useState)({isDirty:!1,isSaving:!1}),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(null),aj=(0,f.useRef)(null),ak=(0,C.o)(aj),al=(0,f.useRef)(null),am=(0,C.o)(al),an=(0,z.Sn)(b),ao=(0,z.Xm)(b),ap=(0,z.po)(b),aq=(0,A.Q)(),ar=(0,t.F)(),as=(0,v.W)({cwd:b});(0,z.JL)(b,as.selectedPath);let at=(0,w.p)({cwd:b,onSearchComplete:()=>ae(!0)}),au=(0,x.e)({cwd:b,addToRecentFiles:as.addToRecentFiles}),av=(0,y.y)({cwd:b,addToRecentFiles:as.addToRecentFiles}),aw=(0,f.useCallback)(a=>{as.setFileContent(b=>b?.type==="text"?{...b,content:a}:b)},[as]),ax=(0,f.useCallback)(a=>{as.setShowEditor(!0)},[as]),ay=(0,f.useCallback)(async()=>{if(as.fileContent&&"text"===as.fileContent.type&&as.fileContent.content)try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:as.selectedPath,content:as.fileContent.content})});if(!a.ok)throw Error("Failed to save file");let c=await a.json();c.mtime&&as.setFileContent(a=>a?.type==="text"?{...a,mtime:c.mtime}:a),(0,j.oR)(K("toast.savedSuccess"),"success")}catch{(0,j.oR)(K("toast.saveFailed"),"error")}},[b,as]),az=(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a=Y.current,b=Z.current;a>0&&as.updateRecentFilePosition(as.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[as]),aA=(0,f.useCallback)((a,b)=>{a!==as.selectedPath&&az(),as.handleSelectFile(a,b)},[as,az]),aB=(0,f.useMemo)(()=>{let a=at.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,p.v3)(c),e=new Set((0,p.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[at.contentSearchResults]),[aC,aD]=(0,f.useState)(new Set),aE=(0,f.useCallback)(a=>{aD(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aF=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aB.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aB.matchMap]),aG=ad&&at.contentSearchResults.length>0,aH=!!as.selectedPath&&null!==(0,D.c)(as.selectedPath),aI=(0,f.useCallback)(async(a,c)=>{if(!as.selectedPath||!aH)return;let d=await an.goToDefinition(as.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;aq.push({filePath:as.selectedPath,lineNumber:Y.current}),g===as.selectedPath?as.setTargetLineNumber(e.line):aA(g,e.line)},[as,b,aH,an,aq]),aJ=(0,f.useCallback)((a,b,c)=>{as.selectedPath&&aH&&ao.onTokenMouseEnter(as.selectedPath,a,b,c)},[as.selectedPath,aH,ao]),aK=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;as.selectedPath&&aq.push({filePath:as.selectedPath,lineNumber:Y.current}),d===as.selectedPath?as.setTargetLineNumber(a.line):aA(d,a.line)},[as,b,aq]),aL=(0,f.useMemo)(()=>{if(!au.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of au.status.staged)a.set(c.path,b(c.status));for(let c of au.status.unstaged)a.set(c.path,b(c.status));return a},[au.status]),aM=(0,f.useCallback)(a=>{N(a),as.setBlameSelectedCommit(null),"history"===a&&av.selectedBranch&&av.loadCommits(av.selectedBranch)},[as,av.selectedBranch,av.loadCommits]);(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a={filePath:as.selectedPath,lineNumber:Y.current},b=aq.goBack(a);b&&(b.filePath===as.selectedPath?as.setTargetLineNumber(b.lineNumber):aA(b.filePath,b.lineNumber))},[as,aq]),(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a={filePath:as.selectedPath,lineNumber:Y.current},b=aq.goForward(a);b&&(b.filePath===as.selectedPath?as.setTargetLineNumber(b.lineNumber):aA(b.filePath,b.lineNumber))},[as,aq]);let aN=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a;try{await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})}),(0,j.oR)(K("toast.copiedName",{name:c}),"success")}catch{(0,j.oR)(K("toast.copyFailed"),"error")}},[b]),aO=(0,f.useCallback)(async a=>{try{let c=await fetch("/api/files/clipboard"),d=await c.json();if(!d.path)return void(0,j.oR)(K("toast.noFileToPaste"),"info");let e=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,targetDir:a,sourceAbsPath:d.path})}),f=await e.json();e.ok?((0,j.oR)(K("toast.pastedFile",{name:f.newName}),"success"),as.loadDirectory(a),as.loadFileIndex()):(0,j.oR)(f.error||K("toast.pasteFailed"),"error")}catch{(0,j.oR)(K("toast.pasteFailed"),"error")}},[b,as]);(0,f.useRef)(0),(0,f.useRef)(ar),(0,f.useRef)(M);let aP=(0,f.useRef)(av.selectedBranch);aP.current=av.selectedBranch;let aQ=(0,f.useRef)(as.selectedPath);aQ.current=as.selectedPath;let aR=(0,f.useRef)(as.fileContent?.type);aR.current=as.fileContent?.type;let aS=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(fetch(`/api/files/init?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.error||as.setFiles(a.files||[])})),f.push(fetch(`/api/files/index?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.paths&&as.setFileIndex(a.paths)})),f.push(fetch(`/api/files/recent?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{as.setRecentFiles(a.files||[])}))),d||e){f.push(fetch(`/api/git/status?cwd=${encodeURIComponent(b)}`).then(a=>{if(a.ok)return a.json().then(a=>{au.setStatus(a);let b=(0,l.Do)(a.staged),c=(0,l.Do)(a.unstaged);au.setStagedTree(b),au.setUnstagedTree(c);let d=new Set([...(0,l.Sz)(b),...(0,l.Sz)(c)]);au.setStatusExpandedPaths(a=>new Set([...a,...d]))})})),au.refreshDiff(),d&&av.loadBranches();let a=aP.current;a&&f.push(fetch(`/api/git/commits?cwd=${encodeURIComponent(b)}&branch=${encodeURIComponent(a)}&limit=${p.B_}`).then(a=>a.json()).then(a=>{let b=a.commits||[];av.setCommits(b),av.setHasMoreCommits(b.length>=p.B_)}))}let g=aQ.current,h=aR.current;g&&"text"===h&&f.push(fetch(`/api/files/read?cwd=${encodeURIComponent(b)}&path=${encodeURIComponent(g)}`).then(a=>a.json()).then(a=>{"text"===a.type&&as.setFileContent(a)})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:aS,enabled:ar});let aT=(0,f.useCallback)(a=>{let b=a.split("/");if(b.length>1){let a=[];for(let c=1;c<b.length;c++)a.push(b.slice(0,c).join("/"));as.setExpandedPaths(b=>{let c=new Set(b);for(let b of a)c.add(b);return as.saveExpandedPaths(c),c})}as.setSelectedPath(a),as.setShouldScrollToSelected(!0),N("tree")},[as]);return(0,e.jsxs)(m.SU,{container:Q,children:[(0,e.jsxs)("div",{ref:O,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>aM("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>aM("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>aM("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>aM("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>aM("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.historyTab")})]}),"tree"===M&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:as.searchInputRef,type:"text",value:as.searchQuery,onChange:a=>as.setSearchQuery(a.target.value),placeholder:K("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),as.searchQuery&&(0,e.jsx)("button",{onClick:()=>as.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:K("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>as.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${as.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:as.searchExactMatch?K("fileBrowser.exactMatchOn"):K("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>as.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>as.searchTreeExpandedPaths?as.setSearchTreeExpandedPaths(new Set):as.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===M&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:at.contentSearchInputRef,type:"text",value:at.contentSearchQuery,onChange:a=>at.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&at.performContentSearch(at.contentSearchQuery)},placeholder:K("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),at.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>at.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:K("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>at.performContentSearch(at.contentSearchQuery),disabled:at.isSearching||!at.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:at.isSearching?"...":K("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.caseSensitive,onChange:a=>at.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.wholeWord,onChange:a=>at.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.regex,onChange:a=>at.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:at.searchOptions.fileType,onChange:a=>at.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:K("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===M&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(u.e,{branches:av.branches,selectedBranch:av.selectedBranch,onSelect:a=>{av.setSelectedBranch(a),av.compareMode&&av.loadCompareFiles(a)},isLoading:av.isLoadingBranches})}),(0,e.jsx)("button",{onClick:()=>av.toggleCompareMode(!av.compareMode),className:`flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors ${av.compareMode?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent border border-border"}`,title:av.compareMode?K("fileBrowser.compareModeOff"):K("fileBrowser.compareModeOn"),children:K("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===M?"":"hidden"}`,children:[as.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:as.creatingItem.parentPath?K("fileBrowser.createFileIn",{path:as.creatingItem.parentPath}):K("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:K("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{P.current=!0},onCompositionEnd:()=>{P.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(P.current)return;let c=a.target.value.trim();if(!c)return;let d=as.creatingItem.parentPath,e=d?`${d}/${c}`:c;try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:e,content:""})});if(a.ok)(0,j.oR)(K("toast.createdFile",{name:c}),"success"),as.setCreatingItem(null),as.loadDirectory(d),as.loadFileIndex(),d&&as.setExpandedPaths(a=>new Set([...a,d])),aA(e);else{let b=await a.json();(0,j.oR)(b.error||K("toast.createFailed"),"error")}}catch(a){(0,j.oR)(K("toast.createFailed"),"error")}}else"Escape"===a.key&&as.setCreatingItem(null)},onBlur:()=>as.setCreatingItem(null)})]}),as.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("common.loading")}):as.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:as.fileError}):(0,e.jsx)(k.h,{files:as.files,selectedPath:as.selectedPath,expandedPaths:as.effectiveExpandedPaths,matchedPaths:as.matchedPaths,gitStatusMap:aL,loadingDirs:as.loadingDirs,onSelect:a=>{as.setShouldScrollToSelected(!1),aA(a)},onToggle:as.handleToggle,cwd:b,shouldScrollToSelected:as.shouldScrollToSelected,onScrolledToSelected:()=>as.setShouldScrollToSelected(!1),onCreateFile:a=>as.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>T({path:a,isDirectory:b,name:c}),onRefresh:()=>as.loadFiles(),onCopyFile:aN,onPaste:aO})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===M?"":"hidden"}`,children:at.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):at.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:at.searchError}):0===at.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:at.contentSearchQuery?K("fileBrowser.noContentSearchResults"):K("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[at.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[K("fileBrowser.nFilesNMatches",{files:at.searchStats.totalFiles,matches:at.searchStats.totalMatches}),at.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",K("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(k.h,{files:aB.files,selectedPath:as.selectedPath,expandedPaths:aC,onSelect:a=>{let b=aB.matchMap.get(a);aA(a,b?.matches[0]?.lineNumber),ad||ae(!0)},onToggle:aE,cwd:b,renderActions:aF,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===M?"":"hidden"}`,children:0===as.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noRecentFiles")}):(0,e.jsx)(k.h,{files:as.recentFilesTree,selectedPath:as.selectedPath,expandedPaths:as.recentTreeDirPaths,onSelect:aA,onToggle:p.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===M?"":"hidden"}`,children:au.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):au.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:au.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:K("fileBrowser.stagingArea",{count:au.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>au.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(au.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:au.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:K("fileBrowser.unstageAll")})]}),(0,e.jsx)(l.VO,{files:au.stagedTree,selectedPath:au.statusSelectedFile?.type==="staged"?au.statusSelectedFile.file.path:null,expandedPaths:au.statusExpandedPaths,onSelect:a=>a.file&&au.handleStatusFileSelect(a.file,"staged"),onToggle:au.handleStatusToggle,cwd:b,emptyMessage:K("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,l.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:K("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:K("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:K("fileBrowser.workspace",{count:au.status?.unstaged.length||0})}),(au.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:au.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:K("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:au.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:K("fileBrowser.stageAll")})]})]}),(0,e.jsx)(l.VO,{files:au.unstagedTree,selectedPath:au.statusSelectedFile?.type==="unstaged"?au.statusSelectedFile.file.path:null,expandedPaths:au.statusExpandedPaths,onSelect:a=>a.file&&au.handleStatusFileSelect(a.file,"unstaged"),onToggle:au.handleStatusToggle,cwd:b,emptyMessage:K("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,l.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:K("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:K("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:K("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:K("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===M?"":"hidden"}`,children:av.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:av.historyError})]})}):av.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:av.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.loadingDiff")}):0===av.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:K("fileBrowser.nFilesChanged",{count:av.compareFiles.length,branch:av.selectedBranch})})}),(0,e.jsx)(l.VO,{files:av.compareFileTree,expandedPaths:av.compareExpandedPaths,onToggle:av.handleCompareToggle,selectedPath:av.compareSelectedFile?.path||null,onSelect:a=>{a.file&&av.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:av.commitListRef,className:"flex-1 overflow-y-auto",onScroll:av.handleCommitListScroll,children:av.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.loadingCommits")}):0===av.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[av.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>av.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${av.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,p.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),av.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!av.hasMoreCommits&&av.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:K("fileBrowser.allLoaded",{count:av.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===M||"search"===M||"recent"===M)&&(as.blameSelectedCommit?(0,e.jsx)(h.n,{isOpen:!0,onClose:()=>as.setBlameSelectedCommit(null),commit:as.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:as.selectedPath||void 0,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):as.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:as.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${as.selectedPath}`),(0,j.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aT(as.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:as.showEditor?(0,e.jsxs)(e.Fragment,{children:[ab.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:K("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aa.current?.save(),disabled:!ab.isDirty||ab.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ab.isDirty&&!ab.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:ab.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):K("common.save")}),(0,e.jsx)("button",{onClick:()=>aa.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.closeEdit"),children:K("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[as.fileContent?.type==="text"&&as.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(as.fileContent.content),(0,j.oR)(K("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.copyFileContent"),children:K("common.copy")}),as.selectedPath?.endsWith(".json")&&as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ag(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${af?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:K("fileBrowser.toggleJsonReadable"),children:K("common.readable")}),as.fileContent?.type==="text"&&(0,o.e$)(as.selectedPath)&&(0,e.jsx)("button",{onClick:()=>as.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.previewMarkdown"),children:K("common.preview")}),as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:as.handleToggleBlame,disabled:as.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${as.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:K("fileBrowser.viewBlame"),children:as.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>as.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.editFile"),children:K("common.edit")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:as.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):as.fileContent?"text"===as.fileContent.type&&"string"==typeof as.fileContent.content?as.showBlame&&as.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:as.blameError}),(0,e.jsx)("button",{onClick:()=>as.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:K("fileBrowser.backToPreview")})]})}):as.showBlame&&0===as.blameLines.length&&as.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):af&&as.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(C._,{search:ak}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:aj,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,o.xb)(as.fileContent.content)})})]}):(0,e.jsx)(n.Cv,{ref:aa,content:as.fileContent.content,filePath:as.selectedPath,cwd:b,enableComments:!0,scrollToLine:$??as.targetLineNumber,scrollToLineAlign:null!=$?"start":as.targetScrollAlign,onScrollToLineComplete:()=>{_(null),as.setTargetLineNumber(null)},highlightKeyword:"search"===M?at.contentSearchQuery:null,visibleLineRef:Y,viStateRef:Z,initialCursorLine:as.initialCursorLine,initialCursorCol:as.initialCursorCol,onInitialCursorSet:()=>{as.setInitialCursorLine(null),as.setInitialCursorCol(null)},onCmdClick:aH?aI:void 0,onTokenHover:aH?aJ:void 0,onTokenHoverLeave:aH?ao.onTokenMouseLeave:void 0,onTokenHoverCancel:aH?ao.clearHover:void 0,blameLines:as.showBlame&&as.blameLines.length>0?as.blameLines:void 0,inlineBlameLines:as.blameLines.length>0?as.blameLines:void 0,onSelectCommit:as.setBlameSelectedCommit,editable:as.showEditor,initialMtime:as.fileContent.mtime,onEditorClose:a=>{as.setShowEditor(!1),_(a)},onSaved:()=>{let a=Y.current??1;as.loadFileContent(as.selectedPath),as.setShowEditor(!1),_(a)},onEditorStateChange:ac,viMode:!0,onContentMutate:aw,onEnterInsertMode:ax,onViSave:ay,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):"image"===as.fileContent.type&&as.fileContent.content?(0,e.jsx)("div",{className:"h-full flex items-center justify-center p-4 bg-secondary",children:(0,e.jsx)("img",{src:as.fileContent.content,alt:as.selectedPath,className:"max-w-full max-h-full object-contain"})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:as.fileContent.message||K("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:K("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:K("fileBrowser.selectFileToPreview")})]})})),"status"===M&&(au.statusSelectedFile&&au.statusDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:au.statusSelectedFile.file.path}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${au.statusSelectedFile.file.path}`),(0,j.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aT(au.statusSelectedFile.file.path)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===au.statusSelectedFile.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===au.statusSelectedFile.type?K("fileBrowser.staged"):K("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,p.u)(au.statusSelectedFile.file.path)?(0,e.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,e.jsx)("img",{src:`/api/files/read?cwd=${encodeURIComponent(b)}&path=${encodeURIComponent(au.statusSelectedFile.file.path)}&raw=1`,alt:au.statusSelectedFile.file.path,className:"max-w-full max-h-[60vh] object-contain"})}):(0,e.jsx)(i.xZ,{oldContent:au.statusDiff.oldContent,newContent:au.statusDiff.newContent,filePath:au.statusDiff.filePath,isNew:au.statusDiff.isNew,isDeleted:au.statusDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!au.statusDiff.isDeleted&&(0,o.e$)(au.statusSelectedFile.file.path)?()=>au.setShowStatusDiffPreview(!0):!au.statusDiff.isDeleted&&au.statusSelectedFile.file.path.endsWith(".json")?()=>ai({content:au.statusDiff.newContent,filePath:au.statusDiff.filePath}):void 0,previewLabel:au.statusSelectedFile.file.path.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}})}),au.showStatusDiffPreview&&au.statusDiff&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>au.setShowStatusDiffPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.M,{content:au.statusDiff.newContent,filePath:au.statusDiff.filePath,cwd:b,onClose:()=>au.setShowStatusDiffPreview(!1)})})}),ah&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ai(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:ah.filePath}),(0,e.jsx)("button",{onClick:()=>ai(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(C._,{search:am}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:al,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,o.xb)(ah.content)})})]})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:K("fileBrowser.selectFileToViewDiff")})})),"history"===M&&!av.historyError&&(av.compareMode?av.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:K("fileBrowser.loadingDiffContent")}):av.compareFileDiff?(0,e.jsx)(i.xZ,{oldContent:av.compareFileDiff.oldContent,newContent:av.compareFileDiff.newContent,filePath:av.compareFileDiff.filePath,isNew:av.compareFileDiff.isNew,isDeleted:av.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!av.compareFileDiff.isDeleted&&av.compareFileDiff.filePath.endsWith(".json")?()=>ai({content:av.compareFileDiff.newContent,filePath:av.compareFileDiff.filePath}):void 0,previewLabel:K("common.readable"),onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:av.compareFiles.length>0?K("fileBrowser.selectFileToViewDiff"):K("fileBrowser.clickCompareToLoad")})}):av.selectedCommit?(0,e.jsx)(h.n,{isOpen:!0,onClose:()=>av.setSelectedCommit(null),commit:av.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:K("fileBrowser.selectCommitToView")})}))]})]}),as.showMarkdownPreview&&as.fileContent?.type==="text"&&as.selectedPath&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>as.setShowMarkdownPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.M,{content:as.fileContent.content||"",filePath:as.selectedPath,cwd:b,onClose:()=>as.setShowMarkdownPreview(!1)})})}),U&&(0,e.jsx)(r.c,{files:as.files,fileIndex:as.fileIndex,recentFiles:as.recentFilePaths,onSelectFile:a=>{aA(a),as.setShouldScrollToSelected(!0),N("tree")},onClose:()=>V(!1)}),(aG||ap.visible)&&(0,e.jsxs)("div",{className:`flex ${ap.visible&&aG?"":"flex-col"}`,children:[aG&&(0,e.jsx)("div",{className:ap.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(G.D,{results:at.contentSearchResults,loading:at.isSearching,totalMatches:at.searchStats?.totalMatches??0,onSelect:(a,b)=>{as.selectedPath&&aq.push({filePath:as.selectedPath,lineNumber:Y.current}),aA(a,b)},onClose:()=>ae(!1)})}),ap.visible&&(0,e.jsx)("div",{className:aG?"flex-1 min-w-0":"",children:(0,e.jsx)(F.D,{references:ap.references,loading:ap.loading,onSelect:aK,onClose:ap.closeReferences})})]})]}),W&&(0,g.createPortal)((0,e.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:W.x+12,top:W.y+16},children:W.text}),document.body),S&&(0,g.createPortal)((0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>T(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:K("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:K("fileBrowser.confirmDeleteMessage",{name:S.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>T(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:K("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=S;T(null);try{let d=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})});if(d.ok){(0,j.oR)(K("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";as.loadDirectory(b),as.loadFileIndex(),as.selectedPath===a&&aA("")}else{let a=await d.json();(0,j.oR)(a.error||K("toast.deleteFailed"),"error")}}catch{(0,j.oR)(K("toast.deleteFailed"),"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:K("common.delete")})]})]})}),document.body),ao.hoverInfo&&Q&&(0,g.createPortal)((0,e.jsx)(E.s,{ref:a=>{ao.tooltipElRef.current=a},displayString:ao.hoverInfo.displayString,documentation:ao.hoverInfo.documentation,x:ao.hoverInfo.x,y:ao.hoverInfo.y,container:Q,onMouseEnter:ao.onCardMouseEnter,onMouseLeave:ao.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=ao.hoverInfo;ao.clearHover(),ap.findReferences(a,b,c)},onSearch:a=>{ao.clearHover(),N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}),Q)]})}[h,i,n,F,G]=I.then?(await I)():I,d()}catch(a){d(a)}})},54338:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(4667),i=c(54017),j=c(26130),k=c(27805),l=c(94924),m=c(77033),n=c(92154),o=c(93053),p=c(81190),q=c(48464),r=c(92050),s=c(13928),t=c(132),u=c(21108),v=a([i,r]);function w({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,v]=(0,f.useState)("agent"),{tabs:w,activeTabId:x,activeTab:y,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,closeTab:C,switchTab:D,handleSelectSession:E,handleNewTab:F,handleOpenSession:G,updateTabState:H,handleTabDragStart:I,handleTabDragOver:J,handleTabDrop:K,handleTabDragEnd:L}=(0,o.i)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:M,pinSession:N,unpinSession:O}=(0,t.P)(),{createTask:P}=(0,u.n)(),Q=(0,f.useCallback)(a=>{let b=w.find(b=>b.id===a);return!!b?.sessionId&&M(b.sessionId)},[w,M]),R=(0,f.useCallback)(b=>{let c=w.find(a=>a.id===b);c?.sessionId&&(M(c.sessionId)?O(c.sessionId):N(c.sessionId,c.cwd||a||"",c.title))},[w,M,N,O,a]),[S,T]=(0,f.useState)(!1),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(!1),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(!1),[aa,ab]=(0,f.useState)("tree"),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(null),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(!1);(0,f.useRef)(null);let ak=(0,f.useCallback)(b=>{v(b),a&&(fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,settings:{activeView:b}})}).catch(()=>{}),window.parent.postMessage({type:"VIEW_CHANGE",cwd:a,view:b},"*"))},[a]),al=(0,f.useCallback)(async()=>{if(a)try{let b=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(a)}`);if(b.ok){let c=await b.json();if(_(c.isGitRepo),c.isGitRepo&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&Z(b.branch)}}}catch(a){console.error("Failed to load git info:",a)}},[a]),am=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&al()},[al]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:am,enabled:!!a});let an=(0,f.useCallback)(()=>{ab("status"),ad(a=>a+1),ak("explorer")},[ak]),ao=(0,f.useCallback)(a=>{af(a),ah(a=>a+1),ak("explorer")},[ak]),ap=(0,f.useCallback)(()=>{a&&window.parent.postMessage({type:"OPEN_NOTE",cwd:a},"*")},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(n.fY,{activeView:d,onViewChange:ak,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(p.B,{initialCwd:a,activeTab:y,isGitRepo:$,currentBranch:Y,onOpenWorktree:()=>V(!0),onOpenProjectSessions:()=>T(!0),onOpenAliasManager:()=>X(!0),onBranchSwitched:al}),ai&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),c("console.screenshotting")]}),a?(0,e.jsxs)(n.c0,{children:[(0,e.jsxs)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(q.V,{tabs:w,activeTabId:x,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,isPinned:Q,onTogglePin:R,onSwitchTab:D,onCloseTab:C,onNewTab:F,onDragStart:I,onDragOver:J,onDrop:K,onDragEnd:L}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:w.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===x?"block":"hidden"}`,children:(0,e.jsx)(r.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,isActive:a.id===x&&"agent"===d,onStateChange:H,onShowGitStatus:an,onContentSearch:ao,onOpenNote:ap,onCreateScheduledTask:P,onOpenSession:G})},a.id))})]}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(i.g,{onClose:()=>ak("agent"),cwd:a,initialTab:aa,tabSwitchTrigger:ac,initialSearchQuery:ae,searchQueryTrigger:ag})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:ap})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(q.V,{tabs:w,activeTabId:x,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,isPinned:Q,onTogglePin:R,onSwitchTab:D,onCloseTab:C,onNewTab:F,onDragStart:I,onDragOver:J,onDrop:K,onDragEnd:L}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:w.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===x?"block":"hidden"}`,children:(0,e.jsx)(r.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,isActive:a.id===x,onStateChange:H,onCreateScheduledTask:P,onOpenSession:G})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:S,onClose:()=>T(!1),cwd:a,onSelectSession:E}),a&&$&&(0,e.jsx)(j.x,{isOpen:U,onClose:()=>V(!1),cwd:a}),W&&(0,e.jsx)(l.Y,{onClose:()=>X(!1),onSave:()=>X(!1)})]})})})}[i,r]=v.then?(await v)():v,d()}catch(a){d(a)}})},55313:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},55511:a=>{"use strict";a.exports=require("crypto")},56111:(a,b,c)=>{"use strict";c.d(b,{e:()=>f});var d=c(67484),e=c(41564);function f(a,b,{sessionId:c,cwd:f,onSessionId:g,onFetchTitle:h}){let[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useRef)(null),n=(0,d.useRef)(c);n.current=c;let o=(0,d.useRef)(null),p=(0,d.useRef)(null),q=(0,d.useCallback)(()=>{let a=o.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a)),o.current={messageId:c,text:""}}p.current=null},[b]),r=(0,d.useCallback)(()=>{m.current&&(m.current.abort(),m.current=null)},[]),s=(0,d.useCallback)((a,c)=>{let d=a.type;if("system"===d&&"init"===a.subtype){let b=a.session_id;g(b),n.current=b;return}if("stream_event"===d){let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";o.current&&o.current.messageId===c?o.current.text+=a:o.current={messageId:c,text:a},p.current||(p.current=setTimeout(q,50))}return}if("assistant"===d){let d=a.message;if(d?.content){for(let a of d.content)if("name"in a&&a.name){let d={id:a.id||`tool-${Date.now()}`,name:a.name,input:a.input||{},isLoading:!0};b(a=>a.map(a=>a.id!==c||a.toolCalls?.some(a=>a.id===d.id)?a:{...a,toolCalls:[...a.toolCalls||[],d]}))}}}if("user"===d){let d=a.message;if(d?.content){for(let a of d.content)if("tool_use_id"in a&&a.tool_use_id){let d=a.tool_use_id,e="string"==typeof a.content?a.content:JSON.stringify(a.content);b(a=>a.map(a=>a.id===c?{...a,toolCalls:a.toolCalls?.map(a=>a.id===d?{...a,result:e,isLoading:!1}:a)}:a))}}}if("result"===d){p.current&&(clearTimeout(p.current),p.current=null),q();let d=n.current;d&&f&&b(a=>(2===a.length&&h(d),a));let e=a.usage,g=a.total_cost_usd;e&&l({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:g||0}),b(a=>a.map(a=>a.id===c?{...a,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a))}},[b,q,g,h,f]);return{isLoading:i,tokenUsage:k,handleSend:(0,d.useCallback)(async(a,c)=>{let d=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),g={id:`user-${Date.now()}`,role:"user",content:a,images:d};b(a=>[...a,g]),j(!0);let h=`assistant-${Date.now()}`,i={id:h,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,i]),m.current=new AbortController;try{let b=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:n.current,images:d,cwd:f}),signal:m.current.signal});if(!b.ok)throw Error(e.A.t("chat.requestFailed"));let c=b.body?.getReader();if(!c)throw Error(e.A.t("chat.cannotReadStream"));let g=new TextDecoder,i="";for(;;){let{done:a,value:b}=await c.read();if(a)break;let d=(i+=g.decode(b,{stream:!0})).split("\n");for(let a of(i=d.pop()||"",d))if(a.startsWith("data: ")){let b=a.slice(6);if("[DONE]"===b)continue;try{let a=JSON.parse(b);s(a,h)}catch{}}}}catch(a){a instanceof Error&&"AbortError"===a.name||(console.error("Chat error:",a),b(a=>a.map(a=>a.id===h?{...a,content:e.A.t("chat.errorRetry"),isStreaming:!1}:a)))}finally{m.current=null,j(!1),b(a=>a.map(a=>a.id===h?{...a,isStreaming:!1}:a))}},[f,b,s]),handleStop:r,abortControllerRef:m}}},56929:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,e$:()=>t,jU:()=>g,oK:()=>u,u:()=>s,xb:()=>i,zs:()=>q});var d=c(67484),e=c.n(d),f=c(41564);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}function i(a){try{let b=JSON.parse(a);return p(b,0)}catch{return a}}let j="#79c0ff",k="#a5d6ff",l="#ff7b72",m="#8b949e",n=(a,b)=>e().createElement("span",{style:{color:a}},b);function o({label:a,labelColor:b,value:c,indent:d}){let[g,h]=e().useState(!1),[i,j]=e().useState({x:0,y:0}),l="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,o={onMouseDown:a=>{j({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-i.x,c=a.clientY-i.y;b*b+c*c>25||(a.stopPropagation(),h(a=>!a))},style:{cursor:"pointer"}};if(l&&g&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],g=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",o,n(b,a),n(m,": "),n(k,d),n("#6e7681",` ${f.A.t("toolCall.foldedLines",{count:g})}`))}let q=e().createElement(e().Fragment,null,n(b,a),n(m,": "),p(c,d));return l?e().createElement("span",o,q):q}function p(a,b){let c=" ".repeat(b);if(null===a)return n(l,"null");if(void 0===a)return n(l,"undefined");if("string"==typeof a)return n(k,a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+c));if("number"==typeof a)return n("#79c0ff",String(a));if("boolean"==typeof a)return n(l,String(a));if(Array.isArray(a))return 0===a.length?n(m,"[]"):e().createElement(e().Fragment,null,n(m,"["),"\n",...a.map((d,f)=>e().createElement("span",{key:f},c+" ",e().createElement(o,{label:`[${f}]`,labelColor:j,value:d,indent:b+1}),f<a.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"]"));if("object"==typeof a){let d=Object.entries(a);return 0===d.length?n(m,"{}"):e().createElement(e().Fragment,null,n(m,"{"),"\n",...d.map(([a,f],g)=>e().createElement("span",{key:a},c+" ",e().createElement(o,{label:a,labelColor:j,value:f,indent:b+1}),g<d.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"}"))}return String(a)}function q(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let r=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function s(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return r.has(b)}function t(a){return a.toLowerCase().endsWith(".md")}function u(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},59347:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},61969:(a,b,c)=>{"use strict";c.d(b,{e:()=>g,g:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:g,onOpenSettings:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:g,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${j?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:j?i("chat.copiedCommandTooltip"):i("chat.copyCommandTooltip",{sessionId:b}),children:j?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}function h({tokenUsage:a}){let{t:b}=(0,f.Bd)();return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[b("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[b("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62862:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66185:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(4219);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,i=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&i(g,0,"text-muted-foreground"),i(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:j,onClose:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(0),q=(0,e.useRef)(null),r=(0,e.useRef)(null),s=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),t=(0,e.useMemo)(()=>{if(!m.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...s.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of s){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,m.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[m,s,c]),u=(0,e.useCallback)(a=>{n(a),p(0)},[]),v=(0,e.useCallback)(a=>{j(a),k()},[j,k]),w=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),p(a=>Math.min(a+1,t.length-1));break;case"ArrowUp":a.preventDefault(),p(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),t[o]&&v(t[o].path);break;case"Escape":a.preventDefault(),k()}},[t,o,v,k]);return(0,g.createPortal)((0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:k,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:q,value:m,onChange:a=>u(a.target.value),onKeyDown:w,placeholder:l("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:r,className:"flex-1 overflow-y-auto py-1",children:0===t.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("quickFileOpen.noMatch")}):t.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===o?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":a.path,onClick:()=>v(a.path),children:[(0,d.jsx)(h.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!m.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:l("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",l("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",l("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",l("quickFileOpen.closeHint")]})]})]})}),document.body)}},66254:(a,b,c)=>{"use strict";c.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(26068),i=c(4219);let j={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=null,loadingDirs:j,onSelect:l,onToggle:m,cwd:n,shouldScrollToSelected:o=!1,onScrolledToSelected:p,className:q,renderActions:r,onCreateFile:s,onDelete:t,onRefresh:u,onCopyFile:v,onPaste:w}){let x=(0,e.useRef)(null),{contextMenu:y,showContextMenu:z,hideContextMenu:A}=(0,h.Ee)(),B=(0,e.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,f,i),[a,c,f,i]),C=(0,g.Te)({count:B.length,getScrollElement:()=>x.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(p).current=p,0===B.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:x,className:q||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${C.getTotalSize()}px`,width:"100%",position:"relative"},children:C.getVirtualItems().map(a=>{let e=B[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:l,onToggle:m,onContextMenu:z,renderActions:r})},e.node.path)})}),y&&(0,d.jsx)(h.ft,{x:y.x,y:y.y,path:y.path,cwd:n,isDirectory:y.isDirectory,onClose:A,onCreateFile:s,onDelete:t,onRefresh:u,onCopyFile:v,onPaste:w})]})}},68502:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:g,onClose:h,onUpdateComment:i,onDeleteComment:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(c.content),p=(0,e.useRef)(null),[q,r]=(0,e.useState)({x:0,y:0}),s=async()=>{n.trim()&&(await i(c.id,n.trim()),m(!1))},t=async()=>{await j(c.id),h()};return(0,d.jsx)("div",{ref:p,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:q.x,top:q.y},children:(0,d.jsx)("div",{className:"p-3",children:l?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:n,onChange:a=>o(a.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),s()),"Escape"===a.key&&(m(!1),o(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{m(!1),o(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:k("common.cancel")}),(0,d.jsx)("button",{onClick:s,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:k("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:k("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:k("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{onClick:t,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:k("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},69648:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(80600),j=c(44218),k=c(19794),l=c(46674),m=c(86402),n=a([m]);function o(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function p({node:a,selectedUid:b,onSelect:c,depth:d=0}){let[g,h]=(0,f.useState)(!0);if(a.isFile&&a.change){let f=b===a.change.uid;return(0,e.jsxs)("button",{onClick:()=>c(a.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${f?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*d+8}px`},"data-tooltip":a.fullPath,children:[(0,e.jsx)(i.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,e.jsx)("span",{className:"truncate",children:a.name}),(0,e.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===a.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===a.change.type?"new":"edit"})]})}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{onClick:()=>h(!g),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*d+8}px`},children:[g?(0,e.jsx)(j.A,{className:"w-3 h-3"}):(0,e.jsx)(k.A,{className:"w-3 h-3"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),g&&a.children.map((a,f)=>(0,e.jsx)(p,{node:a,selectedUid:b,onSelect:c,depth:d+1},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${f}`))]})}function q({toolCalls:a,cwd:b,onClose:c}){let{t:d}=(0,g.Bd)(),i=(0,f.useMemo)(()=>(function(a,b){let c=[],d=0;for(let e of a)if("Edit"===e.name){let a=e.input;a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"edit",old_string:a.old_string,new_string:a.new_string})}else if("Write"===e.name){let a=e.input;a.file_path&&"string"==typeof a.content&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"write",old_string:"",new_string:a.content})}return c})(a,b),[a,b]),j=(0,f.useMemo)(()=>(function a(b){return b.map(b=>{if(!b.isFile&&1===b.children.length&&!b.children[0].isFile){let c=b.children[0];return{...c,name:b.name+"/"+c.name,children:a(c.children)}}return{...b,children:a(b.children)}})})(function(a){let b=[];for(let c of a){let a=c.filePath.split("/").filter(Boolean),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/");if(f){let a={name:e,fullPath:g,isFile:!0,children:[],change:c};d.push(a)}else{let a=d.find(a=>a.name===e&&!a.isFile);a||(a={name:e,fullPath:g,isFile:!1,children:[]},d.push(a)),d=a.children}}}return b}(i)),[i]),[k,n]=(0,f.useState)(i[0]||null),[q,r]=(0,f.useState)("unified"),[s,t]=(0,f.useState)(null),u=(0,f.useRef)(null);if(0===i.length)return null;let v=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:c,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:d("diffViewer.fileChanges",{count:i.length})})}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,e.jsx)("button",{onClick:()=>r("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===q?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,e.jsx)("button",{onClick:()=>r("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===q?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,e.jsx)("button",{onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{ref:u,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:j.map((a,b)=>(0,e.jsx)(p,{node:a,selectedUid:k?.uid||"",onSelect:n},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${b}`))}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:k?"unified"===q?(0,e.jsx)(m.xU,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath}):(0,e.jsx)(m.xZ,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath,isNew:"write"===k.type}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:d("diffViewer.selectFileToView")})})]})]})});return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(h.Z,{children:v}),s&&(0,e.jsx)(h.Z,{children:(0,e.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:s.x+12,top:s.y+16},children:s.text})})]})}m=(n.then?(await n)():n)[0],d()}catch(a){d(a)}})},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73136:a=>{"use strict";a.exports=require("node:url")},74405:(a,b,c)=>{Promise.resolve().then(c.bind(c,54338))},75005:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:e,onSave:f,getVisibleLineCount:g,scrollToLine:h,onSearchExecute:i,onSearchNext:j,onSearchPrev:k,onSearchClear:l}){let[m,n]=(0,d.useState)("normal"),[o,p]=(0,d.useState)(-1),[q,r]=(0,d.useState)(0),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(""),[w,x]=(0,d.useState)(""),[y,z]=(0,d.useState)(""),[A,B]=(0,d.useState)(""),C=(0,d.useRef)([]),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)(null),G=(0,d.useRef)(a),H=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(G.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let I=(0,d.useCallback)(()=>{F.current&&(clearTimeout(F.current),F.current=null),v("")},[]),J=(0,d.useCallback)(()=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{v(""),F.current=null},500)},[]),K=(0,d.useCallback)((a,b)=>{C.current.push(b),D.current=[],t(!0),c(a.join("\n"))},[c]),L=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,G.current.length-1));p(c),r(H(c,b??0)),h(c,"auto")},[h,H]),M=(0,d.useCallback)(a=>{p(b=>{let c=Math.max(0,Math.min(b+a,G.current.length-1));return h(c,"auto"),r(a=>Math.max(0,Math.min(a,Math.max(0,(G.current[c]??"").length-1)))),c})},[h]),N=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1);if(0===a.length)return;let c=a[b];E.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);K(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),p(e),r(0)},[o,K]),O=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1);a.length>0&&(E.current=[a[b]])},[o]),P=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=G.current,c=Math.min(o,b.length-1)+1,d=[...b];d.splice(c,0,...a),K(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:o}),p(c),r(0),h(c,"auto")},[o,K,h]),Q=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,K(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:o})},[o,K]),R=(0,d.useCallback)(()=>{let a=C.current;if(0===a.length)return;let b=a.pop(),d=[...G.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),D.current.push(b),c(d.join("\n")),p(Math.min(b.cursorLine,d.length-1)),h(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&t(!1)},[c,h]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...G.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),C.current.push(b),t(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);p(Math.min(e,d.length-1)),h(Math.min(e,d.length-1),"auto")},[c,h]),T=(0,d.useCallback)(a=>{let b=G.current,c=Math.min(o,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),K(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:o}),c=d,p(d)}n("insert"),e(c,q,a)},[o,q,K,e]),U=(0,d.useCallback)(()=>{n("normal"),I()},[I]),V=(0,d.useCallback)(()=>{n("command"),x("")},[]),W=(0,d.useCallback)(()=>{n("normal"),x("")},[]),X=(0,d.useCallback)(()=>{n("search"),z("")},[]),Y=(0,d.useCallback)(()=>{n("normal"),z("")},[]),Z=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){f?.(),n("normal"),x("");return}if("q"===b){n("normal"),x("");return}if("wq"===b){f?.(),n("normal"),x("");return}if("noh"===b||"nohlsearch"===b){l?.(),n("normal"),x("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,G.current.length-1);p(a),h(a,"center"),n("normal"),x("");return}n("normal"),x("")},[f,l,h]),$=(0,d.useCallback)(a=>{if(!a){n("normal"),z("");return}B(a),i?.(a),n("normal"),z("")},[i]),_=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===m)return("Escape"===a.key||!!c)&&(U(),!0);if("command"===m)return!a.isComposing&&("Escape"===a.key||c?W():"Enter"===a.key?Z(w):"Backspace"===a.key?0===w.length?W():x(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||x(b=>b+a.key),!0);if("search"===m)return!a.isComposing&&("Escape"===a.key||c?Y():"Enter"===a.key?$(y):"Backspace"===a.key?0===y.length?Y():z(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||z(b=>b+a.key),!0);if(o<0&&(p(0),r(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(M(Math.max(1,Math.floor(g()/2))),I(),!0):"u"===a.key?(M(-Math.max(1,Math.floor(g()/2))),I(),!0):"r"===a.key&&(S(),I(),!0);let d=a.key,e=u+d;if("g"===e)return v("g"),J(),!0;if("gg"===e)return L(0),I(),!0;if("d"===e)return v("d"),J(),!0;if("dd"===e)return N(),I(),!0;if("y"===e)return v("y"),J(),!0;if("yy"===e)return O(),I(),!0;if(u&&e!==d&&I(),"j"===d||"ArrowDown"===d)return M(1),!0;if("k"===d||"ArrowUp"===d)return M(-1),!0;if("h"===d||"ArrowLeft"===d)return r(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(G.current[o]??"").length-1);return r(b=>Math.min(a,b+1)),!0}if("0"===d)return r(0),!0;if("$"===d)return r(Math.max(0,(G.current[o]??"").length-1)),!0;if("^"===d){let a=(G.current[o]??"").search(/\S/);return r(a>=0?a:0),!0}return"G"===d?(L(G.current.length-1),!0):"x"===d?(Q(),!0):"p"===d?(P(),!0):"u"===d?(R(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(T(d),!0):"/"===d?(X(),!0):"n"===d?(j?.(),!0):"N"===d?(k?.(),!0):":"===d?(V(),!0):"Escape"!==d&&1===d.length},[b,m,u,w,y,o,U,T,V,W,X,Y,Z,$,M,L,g,N,O,P,Q,R,S,I,J,j,k]);return{state:{mode:m,cursorLine:o,cursorCol:q,isDirty:s,keyBuffer:u,commandInput:w,searchInput:y,lastSearch:A},handleKeyDown:_,enterNormal:U,enterInsert:T,setCursorLine:p,setCursorCol:r,setCommandInput:x,setSearchInput:z,setIsDirty:t,clearUndoHistory:(0,d.useCallback)(()=>{C.current=[],D.current=[]},[])}}},76760:a=>{"use strict";a.exports=require("node:path")},77033:(a,b,c)=>{"use strict";c.d(b,{k_:()=>g,nH:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g({children:a}){let b=(0,e.useRef)(new Map),c=(0,e.useRef)(null),[g,h]=(0,e.useState)(!1),i=(0,e.useCallback)((a,c)=>{b.current.set(c,a)},[]),j=(0,e.useCallback)(a=>{b.current.delete(a)},[]),k=(0,e.useCallback)(a=>{c.current=a},[]),l=(0,e.useCallback)(a=>{let d=c.current;if(!d)return void console.warn("No active tab to send message");let e=b.current.get(d);e?e(a):console.warn(`No chat sender registered for tab ${d}`)},[]),m=(0,e.useMemo)(()=>({sendMessage:l,isLoading:g,registerChat:i,unregisterChat:j,setActiveTab:k,setIsLoading:h}),[l,g,i,j,k]);return(0,d.jsx)(f.Provider,{value:m,children:a})}function h(){return(0,e.useContext)(f)}},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},77937:(a,b,c)=>{"use strict";c.d(b,{f:()=>h,w:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,visible:c,container:e,onAddComment:g,onSendToAI:h,onSearch:i,isChatLoading:j}){let{t:k}=(0,f.Bd)(),l=e.getBoundingClientRect(),m=a-l.left,n=Math.max(0,b-l.top-40);return(0,d.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:m+8,top:n,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:g,children:k("floatingToolbar.addComment")}),(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:h,disabled:j,title:k(j?"comments.aiResponding":"floatingToolbar.sendToAI"),children:k("floatingToolbar.sendToAI")}),i&&(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:i,children:k("floatingToolbar.search")})]})}let h=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j}){let[k,l]=(0,e.useState)(0),m=(0,e.useMemo)(()=>a.current,[k]);return(0,d.jsx)(g,{x:m?.x??0,y:m?.y??0,visible:!!m,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j})})},78908:a=>{"use strict";a.exports=import("shiki")},79029:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>y});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(26068),j=c(45214),k=c(90173),l=c(5811),m=c(77937),n=c(68502),o=c(95133),p=c(16306),q=c(94882),r=c(81749),s=c(75005),t=a([k,l,p]);[k,l,p]=t.then?(await t)():t;let x="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function u(a){let b=window.getSelection();if(!b?.rangeCount)return null;let c=b.getRangeAt(0),d=c.startContainer;for(;d&&d.parentElement!==a;)d=d.parentElement;if(!d)return null;let e=Array.from(a.children).indexOf(d);if(e<0)return null;let f=document.createRange();f.selectNodeContents(d),f.setEnd(c.startContainer,c.startOffset);let g=f.toString().length;return{line:e,offset:g}}function v(a,b){let c,d=a.children[b.line];if(!d)return;let e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=b.offset;for(;c=e.nextNode();){let a=c.textContent?.length||0;if(f<=a){let a=window.getSelection(),b=document.createRange();b.setStart(c,f),b.collapse(!0),a?.removeAllRanges(),a?.addRange(b);return}f-=a}let g=window.getSelection(),h=document.createRange();h.selectNodeContents(d),h.collapse(!1),g?.removeAllRanges(),g?.addRange(h)}function w(a){return a.map(a=>`<div style="${x}">${a}</div>`).join("")}let y=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:k="",cwd:t,enableComments:y=!1,scrollToLine:z=null,scrollToLineAlign:A="center",onScrollToLineComplete:B,highlightKeyword:C=null,visibleLineRef:D,onCmdClick:E,onTokenHover:F,onTokenHoverLeave:G,onTokenHoverCancel:H,blameLines:I,inlineBlameLines:J,onSelectCommit:K,editable:L=!1,initialMtime:M,onEditorClose:N,onSaved:O,onEditorStateChange:P,viMode:Q=!1,onContentMutate:R,onEnterInsertMode:S,onViSave:T,viStateRef:U,initialCursorLine:V,initialCursorCol:W,onInitialCursorSet:X,onContentSearch:Y},Z){let{t:$}=(0,g.Bd)(),_=(0,f.useRef)(a),aa=(0,f.useRef)(!1),[ab,ac]=(0,f.useState)(!1),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(()=>a.split("\n").length),ah=(0,f.useRef)(a.split("\n").length),[ai,aj]=(0,f.useState)({show:!1}),ak=(0,f.useRef)(null),al=(0,f.useRef)(null),am=(0,f.useRef)(M),an=(0,f.useRef)(null),ao=(0,f.useRef)(!1),ap=(0,f.useRef)(!1),{parentRef:aq,containerRef:ar,searchInputRef:as,floatingToolbarRef:at,suppressHoverRef:au,bumpToolbarRef:av,savedSelectionRef:aw,highlightedLines:ax,isMounted:ay,cmdHeld:az,flashLine:aA,isSearchVisible:aB,searchQuery:aC,caseSensitive:aD,wholeWord:aE,currentMatchIndex:aF,viewingComment:aG,addCommentInput:aH,sendToAIInput:aI,chatContext:aJ,commentsEnabled:aK,updateComment:aL,deleteComment:aM,lines:aN,matches:aO,rowData:aP,virtualizer:aQ,commentsByEndLine:aR,linesWithComments:aS,setIsSearchVisible:aT,setSearchQuery:aU,setCaseSensitive:aV,setWholeWord:aW,setViewingComment:aX,setAddCommentInput:aY,setSendToAIInput:aZ,goToNextMatch:a$,goToPrevMatch:a_,handleSearchKeyDown:a0,handleCommentBubbleClick:a1,handleToolbarAddComment:a2,handleToolbarSendToAI:a3,handleToolbarSearch:a4,handleCommentSubmit:a5,handleSendToAISubmit:a6,getHighlightedLineHtml:a7,suppressMatchScrollRef:a8,inlineBlameLineRef:a9,inlineBlameVersion:ba}=(0,p.d)({content:a,filePath:b,showSearch:d,cwd:t,enableComments:!L&&y,scrollToLine:L?null:z,scrollToLineAlign:L?"center":A,onScrollToLineComplete:L?void 0:B,visibleLineRef:L?void 0:D,onContentSearch:Y}),bb=(0,i.iN)(),bc=(0,f.useRef)(null),bd=(0,f.useRef)(null),be=(0,f.useRef)({line:0,col:0}),bf=(0,s.A)({lines:aN,enabled:Q&&!L,onContentChange:a=>{R?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aN[a]??"").length;else if("I"===c){let b=(aN[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);be.current={line:a,col:d},S?.(a)},onSave:T,getVisibleLineCount:()=>{let a=aq.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aP.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aQ.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aU(a),aT(!1)},onSearchNext:a$,onSearchPrev:a_,onSearchClear:()=>{aU("")}});(0,f.useEffect)(()=>{U&&(U.current={cursorLine:bf.state.cursorLine,cursorCol:bf.state.cursorCol})},[U,bf.state.cursorLine,bf.state.cursorCol]);let bg=(0,f.useRef)(null);(0,f.useEffect)(()=>{Q&&!L&&null!=V&&b&&bg.current!==b&&(bg.current=b,bf.setCursorLine(V-1),null!=W&&bf.setCursorCol(W-1),X?.())},[Q,L,V,W,b]),(0,f.useEffect)(()=>{if(!Q||L)return;let a=ar.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bf.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[Q,L,bf.handleKeyDown]),(0,f.useEffect)(()=>{if(!Q||L)return;let a=ar.current;a&&"normal"===bf.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[Q,L,bf.state.mode,a]);let bh=(0,f.useCallback)(a=>{if(!Q||L)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bf.setCursorLine(c-1);let d=b.querySelector("[data-code-content]");if(d){let b=document.caretRangeFromPoint(a.clientX,a.clientY);if(b&&d.contains(b.startContainer)){let a,e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=0;for(;a=e.nextNode();){if(a===b.startContainer){f+=b.startOffset;break}f+=a.textContent?.length||0}let g=aN[c-1]??"";bf.setCursorCol(Math.max(0,Math.min(f,Math.max(0,g.length-1))))}}}}let c=a.target;if("TEXTAREA"===c.tagName||"INPUT"===c.tagName||c.isContentEditable)return;let d=ar.current;d&&d.focus()},[Q,L,bf.setCursorLine,bf.setCursorCol,aN]),bi=(0,f.useCallback)(a=>{Q&&!L&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(a8.current=!0,aU(b))})},[Q,L,aU,a8]);(0,f.useEffect)(()=>{"command"===bf.state.mode?setTimeout(()=>bc.current?.focus(),0):"search"===bf.state.mode&&setTimeout(()=>bd.current?.focus(),0)},[bf.state.mode]),(0,f.useEffect)(()=>{let a=aq.current;if(!a)return;let b=()=>{(H??G)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[H,G]),(0,f.useEffect)(()=>{aH||aI?(au.current=!0,G?.()):at.current||(au.current=!1)},[aH,aI,G]),(0,f.useLayoutEffect)(()=>{let a=aw.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=aq.current;if(!c)return;let d=c.querySelector(`[data-line="${a.startLine}"]`),e=c.querySelector(`[data-line="${a.endLine}"]`);if(!d||!e)return;let f=(0,p.o)(d,a.startOffset),g=(0,p.o)(e,a.endOffset);if(f&&g)try{let a=document.createRange();a.setStart(f.node,f.offset),a.setEnd(g.node,g.offset),b?.removeAllRanges(),b?.addRange(a)}catch{}});let bj=(0,f.useCallback)((a,b,c)=>{au.current||F?.(a,b,c)},[F]),bk=(0,f.useCallback)((a,b)=>{au.current||E?.(a,b)},[E]),bl=Math.max(4,String(L?af:aN.length).length),bm=(0,f.useMemo)(()=>{let a=0;for(let b of aN){let c=0;for(let a=0;a<b.length;a++)" "===b[a]?c+=2-c%2:c+=1;c>a&&(a=c)}return a},[aN]);(0,f.useEffect)(()=>{if(L){_.current=a;let b=a.split("\n").length;ah.current=b,ag(b),aa.current=!1,ac(!1),aj({show:!1}),am.current=M}},[L,a,M]),(0,f.useEffect)(()=>{if(!L)return;let b=ak.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>ax[b]||(0,l.ZD)(a||" "));b.innerHTML=w(d),requestAnimationFrame(()=>{let a,d;Q?(a=Math.max(0,Math.min(be.current.line,c.length-1)),d=be.current.col):(a=Math.max(0,Math.min((D?.current??1)-1,c.length-1)),d=0),b.focus(),v(b,{line:a,offset:d});let e=D?.current??1;al.current&&(al.current.scrollTop=(e-1)*20)})},[L]),(0,f.useEffect)(()=>{L&&P?.({isDirty:ab,isSaving:ad})},[L,ab,ad,P]);let bn=(0,f.useCallback)(()=>{let a=ak.current;if(!a)return _.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),bo=(0,f.useCallback)(()=>{an.current&&clearTimeout(an.current),an.current=setTimeout(async()=>{let a=ak.current;if(a&&!ap.current){_.current=bn();try{let c=await (0,l.kS)(),d=(0,l.sQ)(b),e=document.documentElement.classList.contains("dark"),f=_.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,l.b8)(a)),h=u(a);ao.current=!0,a.innerHTML=w(g),ao.current=!1,h&&v(a,h)}catch{}}},300)},[b,bn]);(0,f.useEffect)(()=>{if(L)return()=>{an.current&&clearTimeout(an.current)}},[L]);let bp=(0,f.useCallback)(()=>{let a=ak.current;if(!a)return;aa.current||(aa.current=!0,ac(!0));let b=a.children.length;b!==ah.current&&(ah.current=b,ag(b))},[]),bq=(0,f.useCallback)(()=>{ao.current||ap.current||(bp(),bo())},[bp,bo]),br=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=ak.current;if(!b)return;let c=window.getSelection();if(!c?.rangeCount)return;let d=c.getRangeAt(0);d.deleteContents();let e=d.startContainer;for(;e&&e.parentElement!==b;)e=e.parentElement;if(!e||!(e instanceof HTMLElement))return;let f=u(b),g=Array.from(b.children).indexOf(e),h=e.textContent||"",i=f?.offset??h.length,j=h.substring(0,i),k=h.substring(i);e.innerHTML=(0,l.ZD)(j||" ");let m=document.createElement("div");m.setAttribute("style",x),m.innerHTML=(0,l.ZD)(k||" "),e.after(m),v(b,{line:g+1,offset:0}),bp(),bo()}},[bp,bo]),bs=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bt=(0,f.useCallback)(async(a=!1)=>{if(t){_.current=bn(),ae(!0);try{let c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:b,content:_.current,expectedMtime:a?void 0:am.current})}),d=await c.json();if(409===c.status&&d.conflict){try{let a=await fetch(`/api/files/read?cwd=${encodeURIComponent(t)}&path=${encodeURIComponent(b)}`),c=await a.json();aj({show:!0,diskContent:"text"===c.type?c.content:void 0})}catch{aj({show:!0})}return}if(!c.ok)throw Error("Failed to save file");d.mtime&&(am.current=d.mtime),aa.current=!1,ac(!1),aj({show:!1}),(0,r.oR)($("toast.savedSuccess"),"success"),O?.()}catch(a){console.error("Error saving file:",a),(0,r.oR)($("toast.saveFailed"),"error")}finally{ae(!1)}}},[t,b,bn,O]),bu=(0,f.useCallback)(async()=>{ab&&!ad&&await bt(!1)},[ab,ad,bt]),bv=(0,f.useCallback)(async()=>{aj({show:!1}),await bt(!0)},[bt]),bw=(0,f.useCallback)(()=>{if(void 0!==ai.diskContent){_.current=ai.diskContent;let b=ai.diskContent.split("\n").length;ah.current=b,ag(b);let c=ai.diskContent!==a;aa.current=c,ac(c);let d=ak.current;if(d){let a=ai.diskContent.split("\n");d.innerHTML=w(a.map(a=>(0,l.ZD)(a||" "))),bo()}}aj({show:!1}),O?.()},[ai.diskContent,a,O,bo]),bx=(0,f.useCallback)(()=>{let a=al.current;return a?Math.floor(a.scrollTop/20)+1:D?.current??1},[D]),by=(0,f.useCallback)(async()=>{(!ab||await (0,r.lJ)($("codeViewer.unsavedConfirm"),{danger:!0,confirmText:$("codeViewer.discardChanges"),cancelText:$("codeViewer.continueEditing")}))&&N?.(bx())},[ab,N,bx]);(0,f.useEffect)(()=>{if(!L)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bu())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[L,bu]);let bz=(0,f.useCallback)(()=>{let a=bn();R?.(a);let b=ak.current,c=b?u(b):null,d=bx();if(bf.enterNormal(),c){bf.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bf.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bf.setCursorLine(Math.max(0,d-1));N?.(d)},[bn,R,bx,N,bf]);(0,f.useEffect)(()=>{if(!L)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||Q&&c)&&(a.preventDefault(),a.stopPropagation(),Q?aa.current?(0,r.lJ)($("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:$("codeViewer.discardChanges"),cancelText:$("codeViewer.continueEditing")}).then(a=>{a&&bz()}):bz():by())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[L,Q,by,bz]),(0,f.useImperativeHandle)(Z,()=>({save:bu,close:by,get isDirty(){return ab},get isSaving(){return ad}}),[bu,by,ab,ad]);let bA=!!(I&&I.length>0),bB=(0,f.useMemo)(()=>{if(!I)return new Map;let a=[...new Set(I.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,o.j[c%o.j.length])}),b},[I]),[bC,bD]=(0,f.useState)(null),[bE,bF]=(0,f.useState)(null);(0,f.useEffect)(()=>{bD(null),bF(null)},[I]);let bG=(0,f.useCallback)((a,b)=>{bD(a.author);let c=b.currentTarget.getBoundingClientRect();bF({line:a,x:c.right+8,y:c.top})},[]),bH=(0,f.useCallback)(()=>{bD(null),bF(null)},[]),bI=(0,f.useCallback)(a=>{if(!K)return;let b={hash:a.hashFull,shortHash:a.hash,author:a.author,authorEmail:a.authorEmail,date:new Date(1e3*a.time).toISOString(),subject:a.message.split("\n")[0]||"",body:a.message.split("\n").slice(1).join("\n").trim(),time:a.time};K(b),bF(null)},[K]),bJ=`${bl+2}ch`;return(0,e.jsxs)("div",{ref:ar,className:`h-full flex flex-col outline-none ${k}`,tabIndex:0,onClick:bh,onDoubleClick:bi,children:[L&&ai.show&&(0,e.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,e.jsx)("span",{className:"text-sm text-foreground flex-1",children:$("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bw,className:"px-3 py-1 text-sm rounded border border-border hover:bg-accent transition-colors",children:$("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:bv,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:$("codeViewer.forceOverwrite")})]})]}),!L&&d&&aB&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("input",{ref:as,type:"text",value:aC,onChange:a=>aU(a.target.value),onKeyDown:a0,placeholder:$("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsx)("button",{onClick:()=>aV(!aD),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aD?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:$("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aW(!aE),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aE?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:$("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aO.length>0?`${aF+1}/${aO.length}`:$("common.noMatch")}),(0,e.jsx)("button",{onClick:a_,disabled:0===aO.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:$("common.previous"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:a$,disabled:0===aO.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:$("common.next"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:()=>{aT(!1),aU("")},className:"p-1 rounded hover:bg-accent",title:$("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),L?(0,e.jsx)("div",{ref:al,className:"flex-1 overflow-auto bg-secondary",children:(0,e.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,e.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-secondary",style:{width:bJ},children:Array.from({length:af},(a,b)=>(0,e.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:b+1},b))}),(0,e.jsx)("div",{ref:ak,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bq,onKeyDown:br,onPaste:bs,onCompositionStart:()=>{ap.current=!0},onCompositionEnd:()=>{ap.current=!1,bq()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,e.jsx)("div",{ref:aq,className:`flex-1 overflow-auto font-mono text-sm bg-secondary${az?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aQ.getTotalSize()}px`,minWidth:"100%",width:bA?`calc(${bl+bm+10}ch + 13rem)`:`${bl+bm+10}ch`,position:"relative"},children:aQ.getVirtualItems().map(a=>{let b=aP[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=ax[d]||(0,l.ZD)(aN[d]||""),h=a7(d,g,C),i=aS.has(f),j=aR.get(f),k=j?.[0],m=!!(aH&&f>=aH.range.start&&f<=aH.range.end),n=ba>=0?a9.current:null,p=!L&&J&&n===f?J[d]??null:null,q=bA?I[d]:void 0,r=bA&&d>0?I[d-1]:void 0,s=!!q&&(!r||r.hash!==q.hash),t=q?bB.get(q.author):void 0;return(0,e.jsx)(o.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:m,showLineNumbers:c,lineNumChars:bl,commentsEnabled:aK,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a1,onCmdClick:bk,onTokenHover:bj,onTokenHoverLeave:G,flashLine:aA,blameLine:q,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(q&&bC===q.author),onBlameClick:bI,onBlameMouseEnter:bG,onBlameMouseLeave:bH,inlineBlameData:p,onInlineBlameClick:bI,isCursorLine:Q&&!L&&bf.state.cursorLine===d,cursorCol:Q&&!L&&bf.state.cursorLine===d?bf.state.cursorCol:void 0},a.key)})})}),Q&&(0,e.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===bf.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bf.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bf.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:":"}),(0,e.jsx)("input",{ref:bc,value:bf.state.commandInput,onChange:a=>bf.setCommandInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bf.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bf.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:"/"}),(0,e.jsx)("input",{ref:bd,value:bf.state.searchInput,onChange:a=>bf.setSearchInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bf.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bf.state.keyBuffer&&"normal"===bf.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bf.state.keyBuffer}),bf.state.isDirty&&("normal"===bf.state.mode||"command"===bf.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bf.state.cursorLine+1,":",bf.state.cursorCol+1]})]}),ay&&bb&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!L&&(0,e.jsx)(m.f,{floatingToolbarRef:at,bumpRef:av,container:bb,onAddComment:a2,onSendToAI:a3,onSearch:Y?a4:void 0,isChatLoading:aJ?.isLoading}),!L&&aH&&(0,e.jsx)(j.t,{x:aH.x,y:aH.y,range:aH.range,codeContent:aH.codeContent,container:bb,onSubmit:a5,onClose:()=>aY(null)}),!L&&aI&&(0,e.jsx)(j.G,{x:aI.x,y:aI.y,range:aI.range,filePath:b,codeContent:aI.codeContent,container:bb,onSubmit:a6,onClose:()=>aZ(null),isChatLoading:aJ?.isLoading}),!L&&aG&&(0,e.jsx)(n.t,{x:aG.x,y:aG.y,comment:aG.comment,container:bb,onClose:()=>aX(null),onUpdateComment:aL,onDeleteComment:aM}),bE&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lg p-3 max-w-lg",style:{left:Math.min(bE.x,window.innerWidth-450),top:Math.max(8,Math.min(bE.y,window.innerHeight-200))},children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:bB.get(bE.line.author)?.border||"#666"},children:bE.line.hash}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:bE.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bE.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bE.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,q.fw)(bE.line.time)," \xb7 ",new Date(1e3*bE.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:$("codeViewer.clickToViewDetails")})]})]})]}),bb)]})});d()}catch(a){d(a)}})},80600:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},81190:(a,b,c)=>{"use strict";c.d(b,{B:()=>p});var d=c(48249),e=c(67484),f=c(92154),g=c(44384),h=c(13928),i=c(15622);let j="review-last-viewed";function k(){try{return JSON.parse(localStorage.getItem(j)||"{}")}catch{return{}}}function l(a,b){if(!a.lastCommentAt)return!1;let c=b[a.id];return!c||a.lastCommentAt>c}function m({cwd:a}){let{t:b}=(0,g.Bd)(),[c,f]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)({}),[u,v]=(0,e.useState)({open:!1,comments:[],title:"",userNameMap:{}}),w=(0,e.useRef)(null),x=(0,e.useRef)(null),[y,z]=(0,e.useState)(null),A=(0,e.useCallback)(async()=>{p(!0);try{let a=await fetch("/api/review");if(a.ok){let b=await a.json();n(b.reviews||[])}}catch{}p(!1)},[]),B=(0,e.useCallback)(a=>{let{data:b}=a;b?.some(a=>"review"===a.type)&&A()},[A]);(0,h.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"/")}`,onMessage:B,enabled:!!a});let C=(0,e.useMemo)(()=>m.filter(a=>a.active),[m]),D=(0,e.useMemo)(()=>C.some(a=>l(a,s)),[C,s]),E=(0,e.useCallback)(a=>{let b;(b=k())[a]=Date.now(),localStorage.setItem(j,JSON.stringify(b)),t(k()),window.open(`${window.location.origin}/review/${a}`,"_blank")},[]),F=(0,e.useCallback)(async(a,b)=>{a.stopPropagation();try{let[a,c]=await Promise.all([fetch(`/api/review/${b}`),fetch("/api/review/users")]);if(!a.ok)return;let{review:d}=await a.json(),e={};if(c.ok){let{users:a}=await c.json();for(let[b,c]of Object.entries(a))e[b]=c.name}v({open:!0,comments:d.comments||[],title:d.title,userNameMap:e})}catch{}},[]),G=(0,e.useCallback)((a,b)=>{x.current=b,a.dataTransfer.effectAllowed="move";let c=a.currentTarget;requestAnimationFrame(()=>c.classList.add("opacity-30"))},[]),H=(0,e.useCallback)(a=>{x.current=null,z(null),a.currentTarget instanceof HTMLElement&&a.currentTarget.classList.remove("opacity-30")},[]),I=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",x.current&&x.current!==b&&z(b)},[]),J=(0,e.useCallback)((a,b)=>{a.preventDefault(),z(null);let c=x.current;x.current=null,c&&c!==b&&n(a=>{let d=[...a],e=d.findIndex(a=>a.id===c),f=d.findIndex(a=>a.id===b);if(-1===e||-1===f)return a;let[g]=d.splice(e,1);return d.splice(f,0,g),fetch("/api/review/order",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:d.map(a=>a.id)})}).catch(()=>{}),d})},[]);return(0,d.jsxs)("div",{ref:w,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>f(a=>!a),className:`relative p-2 rounded-lg transition-colors ${c?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:b("review.reviewManagement"),children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),D&&(0,d.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),c&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:b("review.allReviews")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:C.length})]}),(0,d.jsx)("button",{onClick:A,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:b("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(0,d.jsx)("div",{className:"max-h-80 overflow-y-auto",children:o&&0===m.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("common.loading")}):0===C.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("review.noOpenReviews")}):C.map(a=>{let c,e,f,g,h,i=l(a,s);return(0,d.jsxs)("div",{draggable:!0,onDragStart:b=>G(b,a.id),onDragEnd:H,onDragOver:b=>I(b,a.id),onDrop:b=>J(b,a.id),onMouseEnter:b=>{let c=b.currentTarget.getBoundingClientRect();r({id:a.id,text:a.title,top:c.top+c.height/2,left:c.left})},onMouseLeave:()=>r(b=>b?.id===a.id?null:b),onClick:()=>E(a.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${y===a.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-accent/30`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:a.title}),a.commentCount>0&&(0,d.jsx)("button",{onClick:b=>F(b,a.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:b("review.viewComments"),children:(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,d.jsx)("span",{children:(e=String((c=new Date(a.updatedAt||a.createdAt)).getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),g=String(c.getHours()).padStart(2,"0"),h=String(c.getMinutes()).padStart(2,"0"),`${e}-${f} ${g}:${h}`)}),a.commentCount>0&&(0,d.jsx)("span",{children:b("review.nComments",{count:a.commentCount})})]})]},a.id)})})]}),q&&c&&(0,d.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-md whitespace-nowrap pointer-events-none",style:{top:q.top,left:q.left-8,transform:"translate(-100%, -50%)"},children:q.text}),(0,d.jsx)(i._,{isOpen:u.open,onClose:()=>v(a=>({...a,open:!1})),comments:u.comments,reviewTitle:u.title,userNameMap:u.userNameMap})]})}var n=c(81749);function o({cwd:a,currentBranch:b,onSwitched:c}){let{t:f}=(0,g.Bd)(),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null),t=(0,e.useRef)(null),u=(0,e.useCallback)(async()=>{m(!0);try{let b=await fetch(`/api/git/branches?cwd=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json(),c=[...a.local||[],...(a.remote||[]).filter(b=>!a.local.includes(b.replace(/^origin\//,"")))];k(c)}}catch{(0,n.oR)(f("toast.loadBranchFailed"),"error")}finally{m(!1)}},[a]),v=(0,e.useCallback)(()=>{i(!0),r(""),u()},[u]),w=(0,e.useCallback)(()=>{i(!1)},[]),x=async b=>{p(!0);try{let d=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"checkout",cwd:a,path:a,branch:b})});if(d.ok){let a=b.replace(/^origin\//,"");(0,n.oR)(f("toast.switchedToBranch",{branch:a}),"success"),w(),c()}else{let a=await d.json();(0,n.oR)(a.error||f("toast.switchBranchFailed"),"error")}}catch{(0,n.oR)(f("toast.switchBranchFailed"),"error")}finally{p(!1)}},y=j.filter(a=>a!==b&&a.toLowerCase().includes(q.toLowerCase()));return(0,d.jsxs)("div",{className:"relative",ref:s,children:[(0,d.jsx)("button",{onClick:h?w:v,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:f("git.switchBranch"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),h&&(0,d.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:t,type:"text",value:q,onChange:a=>r(a.target.value),placeholder:f("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:a=>{"Escape"===a.key&&w()}})}),(0,d.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:l?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:f("common.loading")}):0===y.length?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q?f("git.noMatchingBranches"):f("git.noBranches")}):y.map(a=>(0,d.jsx)("button",{onClick:()=>x(a),disabled:o,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,d.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function p({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:e,onOpenWorktree:h,onOpenProjectSessions:i,onOpenAliasManager:j,onBranchSwitched:k}){let{t:l}=(0,g.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:l("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,n.oR)(l("toast.copiedPageUrl"),"success")})}}),a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,n.oR)(l("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:l("tabManagerTopBar.copyDirPath"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}):(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsxs)("button",{onClick:h,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:"Git Worktrees",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,d.jsx)("span",{className:"text-sm",children:e||"main"})]}),(0,d.jsx)(o,{cwd:a,currentBranch:e,onSwitched:()=>k?.()})]})]}),(0,d.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,d.jsx)(f.gT,{})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(m,{cwd:a}),(0,d.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.refreshProject"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInVSCode"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-cursor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInCursor"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),b?.sessionId&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b.sessionId}`;navigator.clipboard.writeText(a).then(()=>{(0,n.oR)(l("toast.copiedCommand",{command:a}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("chat.copyCommandTooltip",{sessionId:b.sessionId}),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.aliasesGlobal"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,d.jsx)("button",{onClick:()=>window.parent.postMessage({type:"OPEN_TOKEN_STATS"},"*"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.tokenStats"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,d.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openSurething"),children:(0,d.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}},83634:(a,b,c)=>{"use strict";c.d(b,{V:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(31172);function h({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:a=>a.stopPropagation()}),(0,d.jsx)("button",{onClick:b,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});return(0,d.jsx)(g.Z,{children:e})}function i({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[i,j]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-secondary border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>j(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),i&&(0,d.jsx)(h,{image:i,onClose:()=>j(null)})]})}var j=c(81749),k=c(31037);let l=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,onShowGitStatus:g,onShowComments:h,onShowUserMessages:l,onOpenNote:m,onCreateScheduledTask:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)([]),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(0),[z,A]=(0,e.useState)(!1),B=(0,e.useRef)(null),C=(0,e.useRef)(null),D=(0,e.useCallback)(()=>{let a=B.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{D()},[p,D]),(0,e.useEffect)(()=>{(async()=>{try{let a=c?`/api/commands?cwd=${encodeURIComponent(c)}`:"/api/commands",b=await fetch(a);if(b.ok){let a=await b.json();u(a)}}catch(a){console.error("Failed to load commands:",a)}})()},[c]);let E=(0,e.useMemo)(()=>{if(!p.startsWith("/"))return[];let a=p.toLowerCase();return t.filter(b=>b.name.toLowerCase().startsWith(a))},[p,t]),F=!z&&p.startsWith("/")&&E.length>0,G=(0,e.useRef)(p);(0,e.useLayoutEffect)(()=>{G.current!==p&&(queueMicrotask(()=>y(0)),z&&queueMicrotask(()=>A(!1)),G.current=p)},[p,z]),(0,e.useLayoutEffect)(()=>{if(F&&C.current){let a=C.current.children[x];a&&a.scrollIntoView({block:"nearest"})}},[x,F]);let H=(0,e.useCallback)(()=>{let c=p.trim();(c||r.length>0)&&!b&&(a(c,r.length>0?r:void 0),q(""),s([]),B.current&&(B.current.style.height="auto"))},[p,r,b,a]),I=(0,e.useCallback)(a=>{q(a.name+" "),B.current?.focus()},[]),J=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(F&&E.length>0){if("ArrowDown"===a.key){a.preventDefault(),y(a=>(a+1)%E.length);return}if("ArrowUp"===a.key){a.preventDefault(),y(a=>(a-1+E.length)%E.length);return}if("Enter"===a.key){a.preventDefault(),I(E[x]);return}if("Escape"===a.key){a.preventDefault(),A(!0);return}if("Tab"===a.key){a.preventDefault(),I(E[x]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),H())}},[F,E,x,I,H]),K=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(o("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};s(a=>[...a,e])},e.readAsDataURL(c)}}},[o]),L=(0,e.useCallback)(a=>{s(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(i,{images:r,onRemove:L,disabled:b}),F&&E.length>0&&(0,d.jsx)("div",{ref:C,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:E.map((a,b)=>(0,d.jsxs)("div",{onClick:()=>I(a),className:`flex items-center gap-3 px-4 py-2 cursor-pointer ${b===x?"bg-brand/10":"hover:bg-accent"}`,children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:a.name}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return o("common.builtin");case"global":return o("common.global");case"project":return o("common.project")}})(a.source)})]},a.name))}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,d.jsx)("button",{onClick:async()=>{try{(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:c,files:["."]})})).ok?((0,j.oR)(o("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(0,j.oR)(o("toast.stageFailed"),"error")}catch(a){console.error("Error staging files:",a),(0,j.oR)(o("toast.stageFailed"),"error")}},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:o("chat.stageAll"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),g&&(0,d.jsx)("button",{onClick:g,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:o("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),h&&(0,d.jsx)("button",{onClick:h,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:o("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.userMessages"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),m&&(0,d.jsx)("button",{onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),n&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>w(!v),className:`p-2 rounded-lg transition-all ${v?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:o("chat.scheduledTasks"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),v&&(0,d.jsx)(k.E,{onClose:()=>w(!1),onCreate:n})]}),(0,d.jsx)("textarea",{ref:B,value:p,onChange:a=>q(a.target.value),onKeyDown:J,onPaste:K,placeholder:b?o("chat.placeholderDisabled"):o("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})})},84705:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>x});var e=c(48249),f=c(67484),g=c(31172),h=c(49681),i=c(21735),j=c(33740),k=c(55313),l=c(32616),m=c(86791),n=c(69648),o=c(31893),p=c(10164),q=c(26068),r=c(44741),s=c(81749),t=c(44384),u=a([m,n]);function v({image:a,onClose:b}){let{t:c}=(0,t.Bd)(),d=(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,e.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:c("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,e.jsx)(g.Z,{children:d})}function w({filePath:a,content:b,cwd:c,onClose:d}){let[h,i]=(0,f.useState)(null);return(0,e.jsx)(g.Z,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsx)("div",{ref:i,className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col relative",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.SU,{container:h,children:(0,e.jsx)(p.M,{content:b,filePath:a,cwd:c,onClose:d})})})})})}[m,n]=u.then?(await u)():u;let x=(0,f.memo)(function({message:a,cwd:b,sessionId:c,onFork:d}){let g,p,q,{t:u}=(0,t.Bd)(),[x,y]=(0,f.useState)(null),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(!1),F="user"===a.role,G=a.images&&a.images.length>0,H=a.toolCalls?.length||0,I=H>1,J=!!c&&!!b&&!!d,K=(0,f.useMemo)(()=>a.toolCalls?.some(a=>"Edit"===a.name||"Write"===a.name)||!1,[a.toolCalls]),L=(0,f.useMemo)(()=>{if(!a.toolCalls)return null;for(let b=a.toolCalls.length-1;b>=0;b--)if("TodoWrite"===a.toolCalls[b].name)return a.toolCalls[b];return null},[a.toolCalls]),M=(0,f.useMemo)(()=>a.toolCalls?a.toolCalls.filter(a=>"AskUserQuestion"===a.name):[],[a.toolCalls]),N=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=new Set,c=[];for(let d of a.toolCalls)if("Read"===d.name||"Edit"===d.name||"Write"===d.name){let a=d.input.file_path;a&&a.toLowerCase().endsWith(".md")&&!b.has(a)&&(b.add(a),c.push(a))}return c},[a.toolCalls]),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!O)return void queueMicrotask(()=>R(null));let a=!1;return fetch(`/api/file?path=${encodeURIComponent(O)}`).then(a=>a.ok?a.json():Promise.reject()).then(b=>{a||R(b.content)}).catch(()=>{a||((0,s.oR)(u("toast.readFileFailed"),"error"),P(null))}),()=>{a=!0}},[O]);let S=()=>{a.content&&(navigator.clipboard.writeText(a.content),(0,s.oR)(u("toast.copiedMessage")))},T=()=>{J&&d(a.id)},U=(a=>{if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`})(a.timestamp);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex flex-col ${F?"items-end":"items-start"} mb-4 group`,"data-role":a.role,children:[U&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:U}),(0,e.jsxs)("div",{className:`flex ${F?"justify-end":"justify-start"} w-full`,children:[F&&(0,e.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:S,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:u("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),J&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:u("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]}),(0,e.jsxs)("div",{className:`max-w-[80%] ${F?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[G&&(0,e.jsx)("div",{className:`flex flex-wrap gap-2 ${a.content?"mb-2":""}`,children:a.images.map((a,b)=>(0,e.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>y(a),children:(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:u("chat.imageN",{index:b+1}),className:"w-full h-full object-cover"})},b))}),a.content&&(0,e.jsxs)("div",{className:"break-words",children:[(0,e.jsx)(r.T,{content:a.content,isUser:F,isStreaming:a.isStreaming}),a.isStreaming&&(0,e.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),L&&(p=(g=L.input?.todos||[]).filter(a=>"completed"===a.status).length,q=g.length,(0,e.jsx)("div",{className:`${a.content||G?"mt-2":""}`,children:(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${q>0?p/q*100:0}%`}})}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[p,"/",q]})]}),g.map((a,b)=>(0,e.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===a.status?"opacity-50":""}`,children:["completed"===a.status?(0,e.jsx)(h.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===a.status?(0,e.jsx)(i.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,e.jsx)(j.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("span",{className:`text-xs truncate ${"completed"===a.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},b))]})})),N.length>0&&(0,e.jsx)("div",{className:`${a.content||G||L?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:N.map(a=>(0,e.jsxs)("button",{onClick:()=>P(a),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:a.split("/").pop()})]},a))})}),a.toolCalls&&a.toolCalls.length>0&&(0,e.jsx)("div",{className:`${a.content||G?"mt-2":""}`,children:I?(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsxs)("button",{onClick:()=>A(!z),className:"flex-1 px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,e.jsx)("span",{className:"text-lg",children:"\uD83D\uDD27"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:u("chat.toolCalls",{count:H})}),(0,e.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:z?u("chat.collapse"):u("chat.expand")})]}),M.length>0&&(0,e.jsx)("button",{onClick:()=>E(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:u("chat.viewQuestions"),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),K&&(0,e.jsx)("button",{onClick:()=>C(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:u("chat.viewAllFileChanges"),children:(0,e.jsx)(l.A,{className:"w-4 h-4"})})]}),z&&(0,e.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}):a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}),!F&&(0,e.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:S,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:u("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),J&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:u("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),x&&(0,e.jsx)(v,{image:x,onClose:()=>y(null)}),B&&a.toolCalls&&(0,e.jsx)(n.z,{toolCalls:a.toolCalls,cwd:b,onClose:()=>C(!1)}),D&&M.length>0&&(0,e.jsx)(o.$,{toolCalls:M,onClose:()=>E(!1)}),O&&null!==Q&&(0,e.jsx)(w,{filePath:O,content:Q,cwd:b||"",onClose:()=>P(null)})]})});d()}catch(a){d(a)}})},86402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>x,xZ:()=>w});var e=c(48249),f=c(67484),g=c(74429),h=c(44384),i=c(36043),j=c(47033),k=c(23434),l=c(26068),m=c(77033),n=c(45214),o=c(45050),p=c(81749),q=c(90173),r=c(5811),s=c(89976),t=c(77937),u=c(68502),v=a([q,r]);[q,r]=v.then?(await v)():v;let y=(0,f.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i}){let[j,k]=(0,f.useState)(0),l=(0,f.useMemo)(()=>a.current,[j]);return(0,e.jsx)(t.w,{x:l?.x??0,y:l?.y??0,visible:!!l,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i})});function w({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:t=!1,cwd:v,enableComments:w=!1,onPreview:x,previewLabel:z,onContentSearch:A}){let{t:B}=(0,h.Bd)(),C=z??B("common.preview"),D=(0,f.useMemo)(()=>(0,o.X)(a,b),[a,b]),E=(0,f.useRef)(null),F=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useRef)(!1);let[H,I]=(0,f.useState)(!1),J=(0,l.iN)(),K=(0,m.nH)(),L=w&&!!v,{comments:M,addComment:N,updateComment:O,deleteComment:P,refresh:Q}=(0,j._)({cwd:v||"",filePath:c}),[R,S]=(0,f.useState)(null),T=(0,f.useRef)(null),U=(0,f.useRef)(()=>{}),[V,W]=(0,f.useState)(null),[X,Y]=(0,f.useState)(null),Z=(0,f.useMemo)(()=>{let a=new Set;for(let b of M)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[M]),$=(0,f.useMemo)(()=>{let a=new Map;for(let b of M){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[M]),_=(0,f.useCallback)((a,b)=>{b.stopPropagation(),S({comment:a,x:b.clientX,y:b.clientY}),T.current=null,U.current(),W(null),Y(null)},[]),aa=(0,f.useCallback)(()=>{let a=T.current;a&&(W({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),T.current=null,U.current())},[]),ab=(0,f.useCallback)(()=>{let a=T.current;a&&(Y({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),T.current=null,U.current())},[]),ac=(0,f.useCallback)(()=>{let a=T.current;if(!a||!A)return;let b=a.codeContent.trim();T.current=null,U.current(),b&&A(b)},[A]),ad=(0,f.useCallback)(async a=>{if(X&&K&&v)try{let b=await (0,k.$3)(v),d=[];for(let a of b)d.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});d.push({filePath:c,startLine:X.range.start,endLine:X.range.end,codeContent:X.codeContent});let e=(0,k.Gw)(d,a);K.sendMessage(e),await (0,k.RP)(v),Q(),Y(null)}catch(a){console.error("Failed to send to AI:",a)}},[X,K,c,v,Q]),ae=(0,f.useCallback)(async a=>{V&&(await N(V.range.start,V.range.end,a),W(null))},[V,N]),{leftLines:af,rightLines:ag}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<D.length;e++){let f=D[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[D]),ah=(0,f.useMemo)(()=>D.map(a=>a.content),[D]),ai=(0,q.C)(ah,c),aj=(0,i.Te)({count:af.length,getScrollElement:()=>E.current,estimateSize:()=>20,overscan:20}),ak=d?"w-1/4":t?"w-3/4":"w-1/2",al=d?"w-3/4":t?"w-1/4":"w-1/2",am=(0,f.useMemo)(()=>af.map((a,b)=>{let c=ag[b];return"removed"===a.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[af,ag]),an=aj.getTotalSize(),ao=aj.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${ak} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":t?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${al} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:t?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[x&&(0,e.jsx)("button",{onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors",children:C}),!t&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,p.oR)(B("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:B("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:E,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${an}px`},children:[(0,e.jsx)("div",{ref:F,className:`${ak} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ao.map(a=>{let b=af[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:b.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:b.originalIdx>=0&&ai[b.originalIdx]||(0,r.ZD)(b.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:G,className:`${al} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ao.map(a=>{let b=ag[a.index],c=b?.lineNum||0,d=c>0&&Z.has(c),f=$.get(c),g=f?.[0],h=V&&c>=V.range.start&&c<=V.range.end,i=X&&c>=X.range.start&&c<=X.range.end,j=h||i;return(0,e.jsxs)("div",{"data-new-line":c||void 0,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${j?"bg-blue-9/20":d?"bg-amber-9/10":b?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${j?"bg-blue-9/30":""}`,style:{width:L?"52px":"40px"},children:[L&&c>0&&d&&g&&(0,e.jsx)("button",{onClick:a=>_(g,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:B("codeViewer.nComments",{count:f?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),L&&c>0&&!d&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:c||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:b?.originalIdx>=0&&ai[b.originalIdx]||(0,r.ZD)(b?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(s.b,{lines:am,containerRef:E})]}),H&&J&&(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{floatingToolbarRef:T,bumpRef:U,container:J,onAddComment:aa,onSendToAI:ab,onSearch:A?ac:void 0,isChatLoading:K?.isLoading??!1}),V&&(0,e.jsx)(n.t,{x:V.x,y:V.y,range:V.range,codeContent:V.codeContent,container:J,onSubmit:ae,onClose:()=>W(null)}),X&&(0,e.jsx)(n.G,{x:X.x,y:X.y,range:X.range,container:J,onSubmit:ad,onClose:()=>Y(null)}),R&&(0,e.jsx)(u.t,{x:R.x,y:R.y,comment:R.comment,container:J,onClose:()=>S(null),onUpdateComment:O,onDeleteComment:P})]}),J)]})}function x({oldContent:a,newContent:b,filePath:c}){let d=(0,f.useMemo)(()=>(0,o.X)(a,b),[a,b]),g=(0,f.useRef)(null),h=(0,f.useMemo)(()=>d.map(a=>a.content),[d]),j=(0,q.C)(h,c),k=(0,i.Te)({count:d.length,getScrollElement:()=>g.current,estimateSize:()=>20,overscan:20});return(0,e.jsx)("div",{ref:g,className:"font-mono text-sm overflow-auto h-full",children:(0,e.jsx)("div",{style:{height:`${k.getTotalSize()}px`,position:"relative"},children:k.getVirtualItems().map(a=>{let b=d[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":"added"===b.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==b.type?b.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==b.type?b.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===b.type?"text-red-11":"added"===b.type?"text-green-11":"text-slate-9"}`,children:"removed"===b.type?"-":"added"===b.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:j[a.index]||(0,r.ZD)(b.content||" ")}})]},a.key)})})})}d()}catch(a){d(a)}})},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},86753:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(67484),e=c(95836),f=c(81749),g=c(41564);function h({cwd:a,addToRecentFiles:b}){let[c,h]=(0,d.useState)(null),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(null),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(new Set),[u,v]=(0,d.useState)([]),[w,x]=(0,d.useState)([]),[y,z]=(0,d.useState)(!1),[A,B]=(0,d.useState)(0),C=(0,d.useCallback)(async()=>{j(!0),l(null);try{let b=`/api/git/status?cwd=${encodeURIComponent(a)}`,c=await fetch(b);if(!c.ok){let a=await c.json();throw Error(a.error||"Failed to fetch git status")}let d=await c.json();h(d);let f=(0,e.Do)(d.staged),g=(0,e.Do)(d.unstaged);v(f),x(g);let i=new Set([...(0,e.Sz)(f),...(0,e.Sz)(g)]);t(i)}catch(a){l(a instanceof Error?a.message:"Unknown error")}finally{j(!1)}},[a]),D=(0,d.useCallback)(a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),E=(0,d.useCallback)((a,c)=>{n({file:a,type:c}),b(a.path)},[b]),F=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to stage file");await C(),(0,f.oR)(g.A.t("toast.staged"),"success")}catch(a){console.error("Error staging file:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,C]),G=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to unstage file");await C(),(0,f.oR)(g.A.t("toast.unstaged"),"success")}catch(a){console.error("Error unstaging file:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,C]),H=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to stage files");await C(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error staging files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,C]),I=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to unstage files");await C(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error unstaging files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,C]),J=(0,d.useCallback)(async b=>{if(0!==b.length)try{let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path);if(c.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c,isUntracked:!0})})).ok)throw Error("Failed to discard untracked files");if(d.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})})).ok)throw Error("Failed to discard tracked files");await C(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:b.length}),"success")}catch(a){console.error("Error discarding files:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,C]),K=(0,d.useCallback)(async()=>{if(c?.unstaged.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.unstaged.map(a=>a.path)})})).ok)throw Error("Failed to stage all files");await C(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error staging all files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,c,C]),L=(0,d.useCallback)(async()=>{if(c?.staged.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.staged.map(a=>a.path)})})).ok)throw Error("Failed to unstage all files");await C(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"success")}catch(a){console.error("Error unstaging all files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,c,C]),M=(0,d.useCallback)(async b=>{try{let c="untracked"===b.status;if(!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b.path],isUntracked:c})})).ok)throw Error("Failed to discard file");await C(),(0,f.oR)(c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"success")}catch(a){console.error("Error discarding file:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,C]),N=(0,d.useCallback)(async()=>{if(c?.unstaged.length&&await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))try{let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path);d.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})}),b.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b,isUntracked:!0})}),await C(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error discarding all:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,c,C]);return{status:c,setStatus:h,statusLoading:i,statusError:k,statusSelectedFile:m,statusDiff:o,statusDiffLoading:q,statusExpandedPaths:s,setStatusExpandedPaths:t,stagedTree:u,setStagedTree:v,unstagedTree:w,setUnstagedTree:x,showStatusDiffPreview:y,setShowStatusDiffPreview:z,fetchStatus:C,handleStatusToggle:D,handleStatusFileSelect:E,handleStage:F,handleUnstage:G,handleStageFiles:H,handleUnstageFiles:I,handleDiscardFiles:J,handleStageAll:K,handleUnstageAll:L,handleDiscardFile:M,handleDiscardAll:N,refreshDiff:(0,d.useCallback)(()=>B(a=>a+1),[])}}},86791:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(92951),i=c(81749),j=a([h]);h=(j.then?(await j)():j)[0];let l={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D"};function k({toolCall:a,cwd:b}){let c,{t:d}=(0,g.Bd)(),[j,k]=(0,f.useState)(!1),[m,n]=(0,f.useState)(null),o=l[a.name]||"\uD83D\uDD27",p=(c=a.input,"Bash"===a.name&&c.command&&"string"==typeof c.command?c.command:"Glob"===a.name&&c.pattern&&"string"==typeof c.pattern||"Grep"===a.name&&c.pattern&&"string"==typeof c.pattern?c.pattern:c.file_path&&"string"==typeof c.file_path?c.file_path:c.path&&"string"==typeof c.path?c.path:null),q="Glob"===a.name||"Grep"===a.name||"Bash"===a.name,r=p?q?p:(a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a})(p):null,s=b=>{let c="input"===b?d("toolCall.inputParams"):d("toolCall.resultLabel"),e="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);n({title:`${a.name}${r?` ${r}`:""} - ${c}`,content:e,toolName:a.name})};return(0,e.jsxs)("div",{className:"my-2 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("button",{onClick:()=>k(!j),className:"w-full px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,e.jsx)("span",{className:"text-base",children:o}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:p||"",children:r}),(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),p&&(navigator.clipboard.writeText(p),(0,i.oR)(d("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),p&&(navigator.clipboard.writeText(p),(0,i.oR)(d("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:d("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[j&&!a.isLoading&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),s("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),s("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.inputParamsTitle"),children:d("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),s("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),s("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.resultTitle"),children:d("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:j?"▲":"▼"})]})]}),j&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]})]}),m&&(0,e.jsx)(h.M,{title:m.title,content:m.content,toolName:m.toolName,onClose:()=>n(null)})]})}d()}catch(a){d(a)}})},89976:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[f,g]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let h=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*h}%`,height:`${Math.max(h,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${f.top}px`,height:`${Math.max(f.height,10)}px`}})]})}},90173:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{C:()=>h});var e=c(67484),f=c(5811),g=a([f]);function h(a,b){let[c,d]=(0,e.useState)([]),[f,g]=(0,e.useState)(!1);return(0,e.useRef)(""),a.join("\n"),c}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},91645:a=>{"use strict";a.exports=require("net")},92050:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>i});var e=c(48249),f=c(67484),g=c(24266),h=a([g]);function i({tabId:a,cwd:b,sessionId:c,isActive:d,onStateChange:h,onShowGitStatus:i,onOpenNote:j,onCreateScheduledTask:k,onOpenSession:l,onContentSearch:m}){let n=(0,f.useCallback)(b=>{h(a,{isLoading:b})},[a,h]),o=(0,f.useCallback)(b=>{h(a,{sessionId:b})},[a,h]),p=(0,f.useCallback)(b=>{h(a,{title:b})},[a,h]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,hideHeader:!0,hideSidebar:!0,isActive:d,onLoadingChange:n,onSessionIdChange:o,onTitleChange:p,onShowGitStatus:i,onOpenNote:j,onCreateScheduledTask:k,onOpenSession:l,onContentSearch:m})}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},92154:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[j,k]=(0,e.useState)(!1);f.indexOf(a),f.length;let[l,m]=(0,e.useState)(!1),n={activeView:a,onViewChange:b,dragOffset:(()=>{if(!l)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:l&&j};return(0,d.jsx)(h.Provider,{value:n,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),k=(0,e.useRef)(null),l=(0,e.useRef)(null),m=f.indexOf(g),n=f.length;return(0,d.jsx)("div",{ref:k,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:l,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/n*100,c=-(100/n*m)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},92951:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(86402),j=c(79029),k=c(44741),l=c(30068),m=c(90500),n=c(81749),o=c(36645),p=c(56929),q=a([i,j]);function r({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,p.e$)(a);if((0,p.u)(a),h)return(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})});if(d)return(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})});if((0,p.u)(a)){let b=`/api/file?path=${encodeURIComponent(a)}&raw=true`;return(0,e.jsx)("div",{className:"flex items-center justify-center h-full overflow-auto",children:(0,e.jsx)("img",{src:b,alt:a.split("/").pop()||"image",className:"max-w-full max-h-full object-contain"})})}return b?k?(0,e.jsx)(s,{content:b}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[i,j]=q.then?(await q)():q;let u=[m.W];function s({content:a}){let b=(0,f.useRef)(null);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:b}),(0,e.jsx)("div",{ref:b,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,rehypePlugins:u})})]})}function t({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,p.jU)(b),l=(0,p.zs)(b),m=(0,p.oK)(b),q=!!l,s=!!m,[t,u]=(0,f.useState)(("Read"===c||"Write"===c)&&s?"file":q?"diff-unified":k?"readable":"json"),v=(0,f.useRef)(null),w=(0,o.o)(v),x=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[q&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>u("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>u("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),s&&(0,e.jsx)("button",{onClick:()=>u("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>u("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>u("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===t&&m?(0,e.jsx)(r,{filePath:m}):"diff-unified"===t&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===t&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===t&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o._,{search:w}),(0,e.jsx)("pre",{ref:v,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,p.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,p.C6)(b):b})})]})});return(0,e.jsx)(h.Z,{children:x})}d()}catch(a){d(a)}})},93053:(a,b,c)=>{"use strict";c.d(b,{i:()=>f});var d=c(67484),e=c(6440);function f({initialCwd:a,initialSessionId:b,activeView:c}){(0,d.useRef)(!1),(0,d.useRef)(!0);let f=(0,d.useRef)(c),g=(0,e.F)(),h=(0,d.useRef)(g),[i,j]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),[k,l]=(0,d.useState)(i[0].id),[m,n]=(0,d.useState)(new Set),o=(0,d.useRef)(i),p=(0,d.useCallback)((b,c)=>{a&&b&&fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})}).catch(()=>{})},[a]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),u=(0,d.useCallback)((a,b,c)=>{let d={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat")};j(a=>{let b=a.findIndex(a=>a.id===k);if(-1===b)return[...a,d];let c=[...a];return c.splice(b+1,0,d),c}),l(d.id)},[k]),v=(0,d.useCallback)(b=>{j(c=>{let d=c.filter(a=>a.id!==b);if(b===k&&d.length>0&&l(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return l(b.id),[b]}return d})},[k,a]),w=(0,d.useCallback)((b,c)=>{let d=i.find(a=>a.sessionId===b);d?l(d.id):u(a,b,c)},[i,a,u]),x=(0,d.useCallback)(()=>{u(a)},[a,u]),y=(0,d.useCallback)((b,c)=>{u(a,b,c)},[a,u]),z=(0,d.useCallback)((a,b)=>{j(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!f.current||"agent"===f.current;if(a===k&&c&&h.current){let a=d.sessionId||b.sessionId;a&&p(a,"normal")}else n(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[k,p]),A=(0,d.useCallback)(a=>{l(a),n(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=o.current.find(b=>b.id===a);return d?.sessionId&&p(d.sessionId,"normal"),c})},[p]),B=(0,d.useCallback)(a=>{r(a)},[]),C=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==q&&q!==b&&t(b)},[q]),D=(0,d.useCallback)(a=>{null!==q&&q!==a&&j(b=>{let c=[...b],[d]=c.splice(q,1);return c.splice(a,0,d),c}),r(null),t(null)},[q]),E=(0,d.useCallback)(()=>{r(null),t(null)},[]),F=i.find(a=>a.id===k);return{tabs:i,activeTabId:k,activeTab:F,unreadTabs:m,dragTabIndex:q,dragOverTabIndex:s,addTab:u,closeTab:v,switchTab:A,handleSelectSession:w,handleNewTab:x,handleOpenSession:y,updateTabState:z,handleTabDragStart:B,handleTabDragOver:C,handleTabDrop:D,handleTabDragEnd:E}}},94882:(a,b,c)=>{"use strict";function d(a,b){for(let c of a){if(c.path===b)return c;if(c.children){let a=d(c.children,b);if(a)return a}}return null}function e(a,b){if(!a)return"";let c=d(b,a);if(c?.isDirectory)return a;let e=a.split("/");return e.pop(),e.join("/")}function f(a){let b=[];for(let c of a){let a=c.split("/"),d=b;for(let b=0;b<a.length;b++){let c=a[b],e=b===a.length-1,f=a.slice(0,b+1).join("/"),g=d.find(a=>a.name===c);g||(g={name:c,path:f,isDirectory:!e,children:e?void 0:[]},d.push(g)),!e&&g.children&&(d=g.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>{a.children&&c(a.children)})};return c(b),b}function g(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),d.children&&c(d.children))};return c(a),b}c.d(b,{B_:()=>o,KH:()=>k,MB:()=>d,S7:()=>e,fw:()=>l,q3:()=>j,r6:()=>m,tE:()=>n,tW:()=>g,u:()=>i,v3:()=>f});let h=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function i(a){let b=a.split(".").pop()?.toLowerCase();return h.has(b||"")}function j(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase(),f=a=>{if(d.add(a.path),a.children)for(let b of a.children)f(b)},g=(a,b)=>{let h=a.name.toLowerCase(),i=c?h===e:h.includes(e);if(i&&a.children)return f(a),b.forEach(a=>d.add(a)),!0;let j=!1;if(a.children)for(let c of a.children)g(c,[...b,a.path])&&(j=!0);return(!!i||!!j)&&(d.add(a.path),b.forEach(a=>d.add(a)),!0)};for(let b of a)g(b,[]);return d}function k(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase();for(let b of a){let a=b.split("/");for(let b=0;b<a.length;b++){let f=a[b].toLowerCase();if(c?f===e:f.includes(e)){for(let b=0;b<=a.length-1;b++)d.add(a.slice(0,b+1).join("/"));break}}}return d}function l(a){let b=Math.floor(Math.floor((Date.now()-1e3*a)/1e3)/60),c=Math.floor(b/60),d=Math.floor(c/24),e=Math.floor(d/30),f=Math.floor(d/365);return f>0?`${f}y ago`:e>0?`${e}mo ago`:d>0?`${d}d ago`:c>0?`${c}h ago`:b>0?`${b}m ago`:"just now"}function m(a){let b=new Date(a),c=new Date,d=b.getFullYear()===c.getFullYear(),e=String(b.getMonth()+1).padStart(2,"0"),f=String(b.getDate()).padStart(2,"0"),g=String(b.getHours()).padStart(2,"0"),h=String(b.getMinutes()).padStart(2,"0");return d?`${e}-${f} ${g}:${h}`:`${b.getFullYear()}-${e}-${f} ${g}:${h}`}let n=()=>{},o=50},94924:(a,b,c)=>{"use strict";c.d(b,{Y:()=>k});var d=c(48249),e=c(67484),f=c(44384);let g=(0,c(47408).A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var h=c(46674),i=c(59347),j=c(24520);function k({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[k,l]=(0,e.useState)({}),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(!0),s=()=>{m.trim()&&o.trim()&&(l(a=>({...a,[m.trim()]:o.trim()})),n(""),p(""))},t=async()=>{try{(await fetch("/api/terminal/aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aliases:k})})).ok&&(b(k),a())}catch(a){console.error("Failed to save aliases:",a)}};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:q?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(k).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void l(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{l(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:m,onChange:a=>n(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}})]}),(0,d.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}})]}),(0,d.jsx)("button",{onClick:s,disabled:!m.trim()||!o.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(k).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},95133:(a,b,c)=>{"use strict";c.d(b,{S:()=>l,j:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(41564),h=c(74429);function i({blame:a,onClick:b}){let{t:c}=(0,f.Bd)(),i=(0,e.useRef)(null),j=(0,e.useRef)(null),k=(0,e.useRef)(!1),l=(0,e.useRef)(!1),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=(0,e.useRef)(null),p=(0,e.useRef)(a),q=(0,e.useRef)(b),r=(0,e.useCallback)(()=>{let a,b=j.current,c=i.current;if(!b||!c)return;let d=c.getBoundingClientRect(),e=b.getBoundingClientRect(),f=window.innerWidth,g=window.innerHeight,h=d.left;h+e.width>f-8&&(h=f-e.width-8),h<8&&(h=8),(a=d.top-e.height-4<0?d.bottom+4:d.top-e.height-4)+e.height>g-8&&(a=g-e.height-8),b.style.left=`${h}px`,b.style.top=`${a}px`},[]),s=(0,e.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),n.current&&(clearTimeout(n.current),n.current=null),k.current=!1,l.current=!1,j.current&&(j.current.style.display="none"),o.current&&(document.removeEventListener("mousedown",o.current.down),document.removeEventListener("mouseup",o.current.up),o.current=null)},[]),t=(0,e.useCallback)(()=>{let a=j.current;if(!a||k.current)return;k.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(r));let b=0,c=0,d=a=>{b=a.clientX,c=a.clientY},e=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,j.current?.contains(b)||i.current?.contains(b)||s()}};document.addEventListener("mousedown",d),document.addEventListener("mouseup",e),o.current={down:d,up:e}},[r,s]),u=(0,e.useCallback)(()=>{if(m.current&&clearTimeout(m.current),n.current&&(clearTimeout(n.current),n.current=null),k.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(m.current=setTimeout(t,500))},[t]),v=(0,e.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),k.current&&(n.current=setTimeout(()=>{l.current||s()},200))},[s]),w=(0,e.useCallback)(()=>{l.current=!0,n.current&&(clearTimeout(n.current),n.current=null)},[]),x=(0,e.useCallback)(()=>{l.current=!1,s()},[s]),y=(0,e.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&j.current?.contains(b.anchorNode)||(q.current?.(p.current),s())},[s]),z=a.message.split("\n")[0]||"",A=a.message.split("\n").slice(1).join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{ref:i,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:u,onMouseLeave:v,children:[a.author.split(" ")[0],", ",function(a){let b=g.A.t,c=Math.floor((Date.now()-1e3*a)/1e3);if(c<60)return b("common.justNow");let d=Math.floor(c/60);if(d<60)return b("common.minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return b("common.hoursAgo",{count:e});let f=Math.floor(e/24);if(f<30)return b("common.daysAgo",{count:f});let h=Math.floor(f/30);return h<12?b("common.monthsAgo",{count:h}):b("common.yearsAgo",{count:Math.floor(h/12)})}(a.time)," \xb7 ",z]}),(0,h.createPortal)((0,d.jsxs)("div",{ref:j,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:w,onMouseLeave:x,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,d.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,d.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,d.jsx)("div",{className:"font-medium",children:z}),A&&(0,d.jsx)("div",{className:"mt-1 text-muted-foreground",children:A}),(0,d.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:y,children:c("codeViewer.clickToViewDetails")})]}),document.body)]})}let j=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function k(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}let l=(0,e.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:g,firstComment:h,lineCommentsCount:j,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,f.Bd)(),I=(0,e.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,e.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=k(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,e.useCallback)(a=>{if(!t||0!==a.buttons)return;let c=window.getSelection();if(c&&!c.isCollapsed)return;let d=a.target;if("SPAN"!==d.tagName||!d.style.color)return;let e=a.currentTarget,f=k(a,e),g=d.getBoundingClientRect();t(b,f,{x:g.left,y:g.bottom+4})},[b,t]),L=(0,e.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,e.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,d.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":g?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,d.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:z&&y?y.bg:void 0},children:[w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,d.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,d.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,d.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[o&&g&&h&&(0,d.jsx)("button",{onClick:a=>r(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:H("codeViewer.nComments",{count:j}),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),o&&!g&&(0,d.jsx)("span",{className:"w-4"}),(0,d.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,d.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,d.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,d.jsx)(i,{blame:D,onClick:E})]})]},a)})},95836:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(26068),i=c(4219);function j({status:a}){let{label:b,className:c}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-slate-9 text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:l,emptyMessage:m,className:n}){let{t:o}=(0,g.Bd)(),p=m??o("gitFileTree.noFiles"),{contextMenu:q,showContextMenu:r,hideContextMenu:s}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:p}):(0,d.jsxs)("div",{className:n||"py-1 overflow-y-auto h-full min-w-max",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:r,showChanges:j,renderActions:l},a.path)),q&&(0,d.jsx)(h.ft,{x:q.x,y:q.y,path:q.path,cwd:i,isDirectory:q.isDirectory,onClose:s})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},96666:(a,b,c)=>{"use strict";c.d(b,{p:()=>f});var d=c(67484),e=c(41564);function f({cwd:a,onSearchComplete:b}){let[c,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(new Set),[o,p]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[q,r]=(0,d.useState)(null),s=(0,d.useRef)(null),t=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){h([]),r(null);return}if(d.length<2)return void l(e.A.t("fileBrowser.searchMinChars"));j(!0),l(null);try{let d=new URLSearchParams({cwd:a,q:c,caseSensitive:String(o.caseSensitive),wholeWord:String(o.wholeWord),regex:String(o.regex),fileType:o.fileType}),e=await fetch(`/api/files/search?${d}`),f=await e.json();if(f.error)throw Error(f.error);h(f.results),r({totalFiles:f.totalFiles,totalMatches:f.totalMatches,truncated:f.truncated});let g=new Set(f.results.map(a=>a.path));n(g),f.results.length>0&&b?.()}catch(a){l(a instanceof Error?a.message:"Search failed"),h([])}finally{j(!1)}},[a,o,b]);return{contentSearchQuery:c,setContentSearchQuery:f,contentSearchResults:g,isSearching:i,searchError:k,searchExpandedPaths:m,searchOptions:o,setSearchOptions:p,searchStats:q,contentSearchInputRef:s,performContentSearch:t,handleSearchToggle:(0,d.useCallback)(a=>{n(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},99117:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(0),k=(0,d.useRef)(null),l=(0,d.useRef)([]),m=(0,d.useCallback)(()=>{let b=a.current;b&&(b.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(a=>{let b=a.parentNode;b&&(b.replaceChild(document.createTextNode(a.textContent||""),a),b.normalize())}),l.current=[])},[a]);(0,d.useCallback)(b=>{if(m(),!b||!a.current){h([]),j(0);return}let c=[],d=[],e=b.toLowerCase();a.current.querySelectorAll("[data-message-id]").forEach(a=>{let f,g=a.getAttribute("data-message-id")||"",h=0,i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null),j=[];for(;f=i.nextNode();)j.push(f);for(let a of j){let f=(a.textContent||"").toLowerCase(),i=0,j=[];for(;;){let a=f.indexOf(e,i);if(-1===a)break;j.push({start:a,end:a+b.length}),i=a+1}if(0!==j.length)for(let b=j.length-1;b>=0;b--){let e=j[b];a.splitText(e.end);let f=a.splitText(e.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=f.textContent,f.parentNode.replaceChild(i,f),c.push({messageId:g,markIndex:h}),d.push(i),h++}}}),c.reverse(),d.reverse(),l.current=d,h(c),j(c.length>0?0:-1)},[a,m]);let n=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a+1)%g.length)},[g.length]),o=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a-1+g.length)%g.length)},[g.length]),p=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>k.current?.focus(),0)},[]),q=(0,d.useCallback)(()=>{c(!1),f(""),m(),h([]),j(0)},[m]),r=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?o():n()),"Escape"===a.key&&q()},[n,o,q]);return{isSearchVisible:b,searchQuery:e,setSearchQuery:f,matches:g,currentMatchIndex:i,goToNextMatch:n,goToPrevMatch:o,openSearch:p,closeSearch:q,searchInputRef:k,handleSearchKeyDown:r}}},99374:(a,b,c)=>{"use strict";c.d(b,{f:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(31172);function g({isOpen:a,onClose:b,messages:c,onSelectMessage:g}){let{t:h}=(0,e.Bd)();if(!a)return null;let i=c.filter(a=>"user"===a.role),j=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:h("userMessages.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===i.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:h("userMessages.noMessages")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:i.map((a,c)=>{let e,f,h,i=(e=a.id.match(/^user-(\d+)/))?parseInt(e[1],10):null,j=i?(f=new Date(i),h=new Date,f.toDateString()===h.toDateString()?f.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):f.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,d.jsx)("button",{onClick:()=>{g(a.id),b()},className:"w-full px-4 py-3 text-left hover:bg-accent transition-colors",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("p",{className:"text-sm text-foreground break-words",children:function(a,b=50){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:c.slice(0,b)+"..."}(a.content)})}),j&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,d.jsx)(f.Z,{children:j})}},99470:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:g}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=a?.local.filter(a=>a.toLowerCase().includes(k.toLowerCase()))||[],p=a?.remote.filter(a=>a.toLowerCase().includes(k.toLowerCase()))||[],q=a=>{c(a),j(!1),l("")};return(0,d.jsxs)("div",{className:"relative",ref:m,children:[(0,d.jsxs)("button",{onClick:()=>j(!i),disabled:g,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||h("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",h("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${i?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:n,type:"text",value:k,onChange:a=>l(a.target.value),placeholder:h("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[o.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:h("git.localBranches")}),o.map(c=>(0,d.jsxs)("div",{onClick:()=>q(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:h("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),p.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:h("git.remoteBranches")}),p.map(a=>(0,d.jsxs)("div",{onClick:()=>q(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===o.length&&0===p.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:h("git.noMatchingBranches")})]})]})]})}},99543:(a,b,c)=>{"use strict";c.d(b,{m:()=>e});var d=c(67484);function e(a,b,c,{cwd:e,initialSessionId:f,onSessionId:g,onTitleChange:h,onTokenUsage:i}){let[j,k]=(0,d.useState)(!1),[l,m]=(0,d.useState)(!1),[n,o]=(0,d.useState)(!1),[p,q]=(0,d.useState)(void 0),[r,s]=(0,d.useState)(0),t=(0,d.useRef)(h);t.current=h;let u=(0,d.useRef)(i);u.current=i;let v=(0,d.useRef)(void 0),w=(0,d.useRef)(0),x=(0,d.useCallback)(async(a,c,d=!1,e,f)=>{if(d){let a=Date.now();if(a-w.current<5e3)return;w.current=a}d||k(!0);try{let h={cwd:a,sessionId:c,limit:e,beforeTurnIndex:f};d&&v.current&&(h.ifFingerprint=v.current);let i=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(i.ok){let a=await i.json();if(a.notModified)return;a.fingerprint&&(v.current=a.fingerprint),void 0!==a.totalTurns&&s(a.totalTurns),void 0!==a.hasMore&&o(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>{let c=a.messages;if(b.length===c.length&&b.length>0&&b[b.length-1].content===c[c.length-1].content)return b;let d=0;for(let a=0;a<Math.min(b.length,c.length)&&b[a].id===c[a].id&&b[a].content===c[a].content;a++)d=a+1;return d===b.length&&d<c.length?[...b,...c.slice(d)]:c}):b(a.messages)),a.sessionId&&g(a.sessionId),a.title&&t.current?.(a.title),a.usage&&u.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||k(!1)}},[b,g]),y=(0,d.useCallback)(async()=>{if(e&&c&&!l&&n){m(!0);try{let d=void 0!==p?p:r-Math.ceil(a.filter(a=>"user"===a.role).length),f=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0})});if(f.ok){let a=await f.json();if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let c=a.messages.filter(a=>"user"===a.role).length;q(d-c)}void 0!==a.hasMore&&o(a.hasMore),a.fingerprint&&(v.current=a.fingerprint)}}catch(a){console.error("Failed to load more history:",a)}finally{m(!1)}}},[e,c,l,n,p,r,a,b]);return{isLoadingHistory:j,isLoadingMore:l,hasMoreHistory:n,loadMoreHistory:y,loadHistory:(0,d.useCallback)(async a=>{k(!0);try{let c=await fetch(`/api/session/${a}/history`);if(c.ok){let a=await c.json();a.messages&&a.messages.length>0&&b(a.messages)}}catch(a){console.error("Failed to load history:",a)}finally{k(!1)}},[b]),loadHistoryByCwdAndSessionId:x}}}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,6117,4793,6443,7514,6062,7284],()=>b(b.s=43501));module.exports=c})();
29
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ai&&ab&&!f&&!N)return(null==ac?void 0:ac.render404)?await ac.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(k=(0,v.parseFallbackField)(aj.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(al)&&(!as||an)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!N&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aE&&!q&&!_&&T&&(l||!ak)){if((l||aj)&&k===v.FallbackMode.NOT_FOUND){if(ad.experimental.adapterPath)return await aJ();throw new A.NoFallbackError}if(as&&(ad.cacheComponents?!aw:!ap)){let b=l&&"string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:ah,c=l&&(null==aj?void 0:aj.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ad,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:$,isRoutePPREnabled:as,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:N});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ai||g||!av?void 0:av;if(aA&&!N&&m&&aw&&!j){let b=await m.get(aa,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(aa,m,as,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(at&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==aj?void 0:aj.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aD,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ad,prerenderManifest:$,waitUntil:d.waitUntil,isMinimalMode:N});if(_&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aD)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;az&&!aw&&(!n||ao)&&(N||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(av)l={revalidate:0,expire:void 0};else if(aw)l={revalidate:0,expire:void 0};else if(!L.isDev)if(_)l={revalidate:0,expire:void 0};else if(az){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ad.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];N&&az&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=aA?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(N&&az||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(N&&az&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ap&&as||(b.statusCode=q.status),!N&&q.status&&E.RedirectStatusCode[q.status]&&ap&&(b.statusCode=200),n&&!aw&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ap&&!_){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ad.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||N||ap)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:m.cacheControl});if(at)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aI)return await aH.withPropagatedContext(a.headers,()=>aH.trace(i.BaseServerSpan.handleRequest,{spanName:`${aG} ${O}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aG,"http.target":a.url}},q));await q(aI)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:O,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:az,isOnDemandRevalidate:ai})},!1,ac),b}}},43609:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(67484),e=c(94882);function f({cwd:a}){let[b,c]=(0,d.useState)([]),[f,g]=(0,d.useState)(null),[h,i]=(0,d.useState)(new Set),[j,k]=(0,d.useState)([]),[l,m]=(0,d.useState)(null),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)(new Set),[r,s]=(0,d.useState)(null),[t,u]=(0,d.useState)(""),[v,w]=(0,d.useState)(!1),[x,y]=(0,d.useState)(null),[z,A]=(0,d.useState)(!1),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(null),F=(0,d.useRef)(null),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(null),[K,L]=(0,d.useState)("center"),[M,N]=(0,d.useState)(null),[O,P]=(0,d.useState)(null),[Q,R]=(0,d.useState)(!1),[S,T]=(0,d.useState)([]),[U,V]=(0,d.useState)(!1),[W,X]=(0,d.useState)(null),[Y,Z]=(0,d.useState)(null),[$,_]=(0,d.useState)(!1),[aa,ab]=(0,d.useState)(!1),ac=(0,d.useMemo)(()=>j.map(a=>a.path).filter(Boolean),[j]),ad=(0,d.useMemo)(()=>(0,e.v3)(ac),[ac]),ae=(0,d.useMemo)(()=>new Set((0,e.tW)(ad)),[ad]),af=(0,d.useMemo)(()=>t?f?(0,e.KH)(f,t,v):(0,e.q3)(b,t,v):null,[b,f,t,v]),ag=r??p,ah=(0,d.useRef)(null),ai=(0,d.useCallback)(b=>{ah.current&&clearTimeout(ah.current),ah.current=setTimeout(async()=>{try{await fetch("/api/files/expanded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,paths:Array.from(b)})})}catch(a){console.error("Error saving expanded paths:",a)}},500)},[a]),aj=(0,d.useCallback)(async()=>{A(!0),E(null);try{let b=await fetch(`/api/files/init?cwd=${encodeURIComponent(a)}`),d=await b.json();d.error?E(d.error):(c(d.files||[]),d.expandedPaths&&Array.isArray(d.expandedPaths)&&q(new Set(d.expandedPaths)))}catch(a){console.error("Error loading files:",a),E("Failed to load files")}finally{A(!1)}},[a]),ak=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/index?cwd=${encodeURIComponent(a)}`),c=await b.json();c.paths&&g(c.paths)}catch(a){console.error("Error loading file index:",a)}},[a]),al=(0,d.useCallback)(async b=>{i(a=>new Set([...a,b]));try{let d=await fetch(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),f=await d.json();f.children&&c(a=>{if(!b){let b=new Map(a.map(a=>[a.path,a]));return f.children.map(a=>{let c=b.get(a.path);return c?.children&&a.isDirectory?{...a,children:c.children}:a})}let c=structuredClone(a),d=(0,e.MB)(c,b);return d&&(d.children=f.children),c})}catch(a){console.error("Error loading directory:",a)}finally{i(a=>{let c=new Set(a);return c.delete(b),c})}},[a]);(0,d.useRef)(h).current=h;let am=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/recent?cwd=${encodeURIComponent(a)}`),c=await b.json();k(c.files||[])}catch(a){console.error("Error loading recent files:",a)}},[a]),an=(0,d.useCallback)(async b=>{k(a=>{let c=a.filter(a=>a.path!==b);return[{path:b},...c].slice(0,15)});try{await fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b})})}catch(a){console.error("Error adding to recent files:",a)}},[a]),ao=(0,d.useCallback)((b,c,d,e)=>{k(a=>a.map(a=>a.path===b?{...a,scrollLine:c,cursorLine:d,cursorCol:e}:a)),fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b,scrollLine:c,cursorLine:d,cursorCol:e})}).catch(()=>{})},[a]),ap=(0,d.useCallback)(a=>j.find(b=>b.path===a),[j]),aq=(0,d.useCallback)(async b=>{let c=b||l;if(c){V(!0),X(null);try{let b=await fetch(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(c)}`),d=await b.json();d.error?X(d.error):T(d.blame||[])}catch(a){console.error("Error loading blame:",a),X("Failed to load blame info")}finally{V(!1)}}},[a,l]),ar=(0,d.useCallback)(async b=>{C(!0),o(null),R(!1),T([]),X(null),Z(null);try{let c=await fetch(`/api/files/read?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),d=await c.json();o(d),an(b),aq(b)}catch(a){console.error("Error loading file content:",a),o({type:"error",message:"Failed to load file"})}finally{C(!1)}},[a,an,aq]),as=(0,d.useCallback)(()=>{Q?R(!1):(R(!0),0===S.length&&aq())},[Q,S.length,aq]),at=(0,d.useCallback)((a,b)=>{if(!a)return;if(m(a),J(b??null),null==b){let b=j.find(b=>b.path===a);b?.scrollLine?(J(b.scrollLine),L("start"),N(b.cursorLine??null),P(b.cursorCol??null)):(L("center"),N(null),P(null))}else L("center"),N(null),P(null);ar(a);let c=a.split("/");if(c.length>1){let a=[];for(let b=1;b<c.length;b++)a.push(c.slice(0,b).join("/"));q(b=>{let c=new Set(b),d=!1;for(let b of a)c.has(b)||(c.add(b),d=!0);return d&&ai(c),d?c:b})}},[ar,ai,j]),au=(0,d.useCallback)(a=>{if(r)s(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c});else{let c=!p.has(a);if(q(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),ai(c),c}),c){let c=(0,e.MB)(b,a);c&&c.isDirectory&&!c.children&&al(a)}}},[r,ai,p,b,al]);return{files:b,setFiles:c,fileIndex:f,setFileIndex:g,loadingDirs:h,expandedPaths:p,setExpandedPaths:q,searchTreeExpandedPaths:r,setSearchTreeExpandedPaths:s,effectiveExpandedPaths:ag,searchQuery:t,setSearchQuery:u,searchExactMatch:v,setSearchDirExact:w,matchedPaths:af,creatingItem:x,setCreatingItem:y,isLoadingFiles:z,fileError:D,searchInputRef:F,shouldScrollToSelected:G,setShouldScrollToSelected:H,targetLineNumber:I,setTargetLineNumber:J,targetScrollAlign:K,setTargetScrollAlign:L,initialCursorLine:M,initialCursorCol:O,setInitialCursorLine:N,setInitialCursorCol:P,selectedPath:l,setSelectedPath:m,fileContent:n,setFileContent:o,isLoadingContent:B,recentFiles:j,recentFilePaths:ac,setRecentFiles:k,recentFilesTree:ad,recentTreeDirPaths:ae,showBlame:Q,setShowBlame:R,blameLines:S,isLoadingBlame:U,blameError:W,blameSelectedCommit:Y,setBlameSelectedCommit:Z,showMarkdownPreview:$,setShowMarkdownPreview:_,showEditor:aa,setShowEditor:ab,saveExpandedPaths:ai,loadFiles:aj,loadFileIndex:ak,loadDirectory:al,loadRecentFiles:am,addToRecentFiles:an,updateRecentFilePosition:ao,getRecentFilePosition:ap,loadFileContent:ar,loadBlame:aq,handleToggleBlame:as,handleSelectFile:at,handleToggle:au}}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},44218:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},45050:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},45214:(a,b,c)=>{"use strict";c.d(b,{G:()=>h,t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,range:c,codeContent:g,container:h,onSubmit:i,onClose:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=g?.split("\n").slice(0,5).join("\n"),u=!!g&&g.split("\n").length>5;return(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:[(0,d.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-amber-11",children:k("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:k("comments.lineRange",{start:c.start,end:c.end})})]})}),g&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[t,u&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:q,value:l,onChange:a=>m(a.target.value),placeholder:k("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:n,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!n&&l.trim()&&(o(!0),i(l.trim()))),"Escape"!==a.key||n||j()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:k(n?"comments.submitting":"comments.enterSubmit")})]})]})}function h({x:a,y:b,range:c,filePath:g,codeContent:h,container:i,onSubmit:j,onClose:k,isChatLoading:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=h?.split("\n").slice(0,5).join("\n"),u=!!h&&h.split("\n").length>5;return(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-brand",children:m("comments.askAI")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:m("comments.lineRange",{start:c.start,end:c.end})})]}),g&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:g})]}),h&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[t,u&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:q,value:n,onChange:a=>o(a.target.value),placeholder:m("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:l,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!l&&n.trim()&&(j(n.trim()),k())),"Escape"===a.key&&k()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:m(l?"comments.aiGenerating":"comments.enterSend")})]})]})}},45832:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(5811),j=a([i]);function k({results:a,loading:b,totalMatches:c,onSelect:d,onClose:i}){let{t:j}=(0,g.Bd)(),k=function(a){let[b,c]=(0,f.useState)(new Map),[d,e]=(0,f.useState)(!1);return(0,f.useRef)(0),b}(0);return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("searchResults.title")," ",!b&&j("searchResults.nMatches",{count:c})]}),(0,e.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.noResults")}):a.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a.path}),a.matches.map((b,c)=>{let f=`${a.path}:${b.lineNumber}`,g=k.get(f);return(0,e.jsxs)("button",{onClick:()=>d(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),g?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:g}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},46674:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},47033:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});var d=c(67484);function e({cwd:a,filePath:b}){let[c,e]=(0,d.useState)([]),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),j=(0,d.useCallback)(async()=>{if(a&&b){g(!0),i(null);try{let c=await fetch(`/api/comments?cwd=${encodeURIComponent(a)}&filePath=${encodeURIComponent(b)}`);if(c.ok){let a=await c.json();e(a.comments||[])}else i("Failed to load comments")}catch(a){i(a instanceof Error?a.message:"Unknown error")}finally{g(!1)}}},[a,b]),k=(0,d.useCallback)(async(c,d,f,g)=>{try{let h=await fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,startLine:c,endLine:d,content:f,...g?{selectedText:g}:{}})});if(h.ok){let a=await h.json();return e(b=>[...b,a.comment]),a.comment}}catch(a){console.error("Failed to add comment:",a)}return null},[a,b]),l=(0,d.useCallback)(async(b,c)=>{try{let d=await fetch("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})});if(d.ok){let a=await d.json();return e(c=>c.map(c=>c.id===b?a.comment:c)),!0}}catch(a){console.error("Failed to update comment:",a)}return!1},[a]),m=(0,d.useCallback)(async b=>{try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"})).ok)return e(a=>a.filter(a=>a.id!==b)),!0}catch(a){console.error("Failed to delete comment:",a)}return!1},[a]),n=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:f,error:h,addComment:k,updateComment:l,deleteComment:m,refresh:j,getCommentsForLine:n}}c(23434)},47237:(a,b,c)=>{"use strict";c.d(b,{Q:()=>e});var d=c(67484);function e(){let a=(0,d.useRef)([]),b=(0,d.useRef)([]),c=(0,d.useCallback)(c=>{a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),b.current=[]},[]),e=(0,d.useCallback)(c=>{if(0===a.current.length)return null;let d=a.current.pop();return b.current.push(c),b.current.length>50&&(b.current=b.current.slice(-50)),d},[]),f=(0,d.useCallback)(c=>{if(0===b.current.length)return null;let d=b.current.pop();return a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),d},[]);return{push:c,goBack:e,goForward:f,canGoBack:(0,d.useCallback)(()=>a.current.length>0,[]),canGoForward:(0,d.useCallback)(()=>b.current.length>0,[])}}},47408:(a,b,c)=>{"use strict";c.d(b,{A:()=>i});var d=c(67484);let e=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),f=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let h=(0,d.forwardRef)(({color:a="currentColor",size:b=24,strokeWidth:c=2,absoluteStrokeWidth:f,className:h="",children:i,iconNode:j,...k},l)=>(0,d.createElement)("svg",{ref:l,...g,width:b,height:b,stroke:a,strokeWidth:f?24*Number(c)/Number(b):c,className:e("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,b])=>(0,d.createElement)(a,b)),...Array.isArray(i)?i:[i]])),i=(a,b)=>{let c=(0,d.forwardRef)(({className:c,...g},i)=>(0,d.createElement)(h,{ref:i,iconNode:b,className:e(`lucide-${f(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,c),...g}));return c.displayName=f(a),c}},48464:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249);c(67484);var e=c(69005),f=c(44384);function g({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function h({tabs:a,activeTabId:b,unreadTabs:c,dragTabIndex:h,dragOverTabIndex:i,isPinned:j,onTogglePin:k,onSwitchTab:l,onCloseTab:m,onNewTab:n,onDragStart:o,onDragOver:p,onDrop:q,onDragEnd:r}){let{t:s}=(0,f.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[a.map((f,n)=>(0,d.jsx)(e.m,{content:f.title,delay:200,children:(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>o(n),onDragOver:a=>p(a,n),onDrop:()=>q(n),onDragEnd:r,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${f.id===b?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${h===n?"opacity-50":""} ${i===n?"border-l-2 border-brand":""}`,onClick:()=>l(f.id),children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(g,{number:n+1,isActive:f.id===b}),f.isLoading&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!f.isLoading&&c.has(f.id)&&f.id!==b&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),k&&j?.(f.id)&&!f.isLoading&&!(c.has(f.id)&&f.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k(f.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:s("tabBar.unpin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),k&&!j?.(f.id)&&!f.isLoading&&!(c.has(f.id)&&f.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k(f.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:s("tabBar.pin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,d.jsx)("span",{className:"max-w-32 truncate",children:f.title}),a.length>1&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m(f.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:s("tabBar.closeTab"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},f.id)),(0,d.jsx)("button",{onClick:n,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:s("tabBar.newTab"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})})}},49681:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},52620:(a,b,c)=>{"use strict";c.d(b,{JL:()=>h,Sn:()=>e,Xm:()=>f,po:()=>g});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);try{let c=await fetch("/api/lsp/definition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})});return(await c.json()).definitions||[]}catch(a){return console.error("[useLSP] definition error:",a),[]}finally{c(!1)}},[a]),loading:b}}function f(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),f=(0,d.useRef)(null),g=(0,d.useRef)(0),h=(0,d.useRef)(!1),i=(0,d.useRef)(null),j=(0,d.useRef)({x:0,y:0}),k=(0,d.useRef)(!1),l=(0,d.useRef)(null),m=(0,d.useCallback)(()=>{let a=i.current;a&&k.current&&(a.style.pointerEvents="none"),k.current=!1,l.current&&(i.current?.removeEventListener("mouseleave",l.current),l.current=null)},[]),n=(0,d.useCallback)(()=>{let a=i.current;if(!a||k.current)return;k.current=!0,h.current=!0,a.style.pointerEvents="auto";let b=()=>{h.current=!1,m(),g.current++,c(null)};l.current=b,a.addEventListener("mouseleave",b)},[m]),o=(0,d.useCallback)((b,d,h,i)=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current);let j=++g.current;e.current=setTimeout(async()=>{try{let e=await fetch("/api/lsp/hover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:h})}),f=await e.json();if(j!==g.current)return;f.hover&&f.hover.displayString&&c({...f.hover,x:i.x,y:i.y,filePath:b,line:d,column:h})}catch{}},300)},[a]),p=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current++,f.current=setTimeout(function(){if(h.current)return;let a=i.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=j.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void n()}c(null)},150)},[n]),q=(0,d.useCallback)(()=>{h.current=!0,f.current&&clearTimeout(f.current)},[]);return{hoverInfo:b,onTokenMouseEnter:o,onTokenMouseLeave:p,onCardMouseEnter:q,onCardMouseLeave:(0,d.useCallback)(()=>{h.current=!1,g.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current),h.current=!1,m(),g.current++,c(null)},[m]),tooltipElRef:i}}function g(a){let[b,c]=(0,d.useState)([]),[e,f]=(0,d.useState)(!1),[g,h]=(0,d.useState)(!1);return{references:b,loading:e,visible:g,findReferences:(0,d.useCallback)(async(b,d,e)=>{f(!0),h(!0);try{let f=await fetch("/api/lsp/references",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})}),g=await f.json();c(g.references||[])}catch(a){console.error("[useLSP] references error:",a),c([])}finally{f(!1)}},[a]),closeReferences:(0,d.useCallback)(()=>{h(!1),c([])},[])}}function h(a,b){(0,d.useRef)(null)}c(62862)},54017:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>J});var e=c(48249),f=c(67484),g=c(74429),h=c(2868),i=c(86402),j=c(81749),k=c(66254),l=c(95836),m=c(26068),n=c(79029),o=c(56929),p=c(94882),q=c(10164),r=c(66185),s=c(13928),t=c(6440),u=c(99470),v=c(43609),w=c(96666),x=c(86753),y=c(34371),z=c(52620),A=c(47237),B=c(44384),C=c(36645),D=c(62862),E=c(24463),F=c(1906),G=c(45832),H=c(92154),I=a([h,i,n,F,G]);function J({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:I,searchQueryTrigger:J}){let{t:K}=(0,B.Bd)(),{activeView:L}=(0,H.R8)(),[M,N]=(0,f.useState)(c),O=(0,f.useRef)(null),P=(0,f.useRef)(!1),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)(null),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)(1),Z=(0,f.useRef)(null),[$,_]=(0,f.useState)(null),aa=(0,f.useRef)(null),[ab,ac]=(0,f.useState)({isDirty:!1,isSaving:!1}),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(null),aj=(0,f.useRef)(null),ak=(0,C.o)(aj),al=(0,f.useRef)(null),am=(0,C.o)(al),an=(0,z.Sn)(b),ao=(0,z.Xm)(b),ap=(0,z.po)(b),aq=(0,A.Q)(),ar=(0,t.F)(),as=(0,v.W)({cwd:b});(0,z.JL)(b,as.selectedPath);let at=(0,w.p)({cwd:b,onSearchComplete:()=>ae(!0)}),au=(0,x.e)({cwd:b,addToRecentFiles:as.addToRecentFiles}),av=(0,y.y)({cwd:b,addToRecentFiles:as.addToRecentFiles}),aw=(0,f.useCallback)(a=>{as.setFileContent(b=>b?.type==="text"?{...b,content:a}:b)},[as]),ax=(0,f.useCallback)(a=>{as.setShowEditor(!0)},[as]),ay=(0,f.useCallback)(async()=>{if(as.fileContent&&"text"===as.fileContent.type&&as.fileContent.content)try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:as.selectedPath,content:as.fileContent.content})});if(!a.ok)throw Error("Failed to save file");let c=await a.json();c.mtime&&as.setFileContent(a=>a?.type==="text"?{...a,mtime:c.mtime}:a),(0,j.oR)(K("toast.savedSuccess"),"success")}catch{(0,j.oR)(K("toast.saveFailed"),"error")}},[b,as]),az=(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a=Y.current,b=Z.current;a>0&&as.updateRecentFilePosition(as.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[as]),aA=(0,f.useCallback)((a,b)=>{a!==as.selectedPath&&az(),as.handleSelectFile(a,b)},[as,az]),aB=(0,f.useMemo)(()=>{let a=at.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,p.v3)(c),e=new Set((0,p.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[at.contentSearchResults]),[aC,aD]=(0,f.useState)(new Set),aE=(0,f.useCallback)(a=>{aD(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aF=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aB.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aB.matchMap]),aG=ad&&at.contentSearchResults.length>0,aH=!!as.selectedPath&&null!==(0,D.c)(as.selectedPath),aI=(0,f.useCallback)(async(a,c)=>{if(!as.selectedPath||!aH)return;let d=await an.goToDefinition(as.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;aq.push({filePath:as.selectedPath,lineNumber:Y.current}),g===as.selectedPath?as.setTargetLineNumber(e.line):aA(g,e.line)},[as,b,aH,an,aq]),aJ=(0,f.useCallback)((a,b,c)=>{as.selectedPath&&aH&&ao.onTokenMouseEnter(as.selectedPath,a,b,c)},[as.selectedPath,aH,ao]),aK=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;as.selectedPath&&aq.push({filePath:as.selectedPath,lineNumber:Y.current}),d===as.selectedPath?as.setTargetLineNumber(a.line):aA(d,a.line)},[as,b,aq]),aL=(0,f.useMemo)(()=>{if(!au.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of au.status.staged)a.set(c.path,b(c.status));for(let c of au.status.unstaged)a.set(c.path,b(c.status));return a},[au.status]),aM=(0,f.useCallback)(a=>{N(a),as.setBlameSelectedCommit(null),"history"===a&&av.selectedBranch&&av.loadCommits(av.selectedBranch)},[as,av.selectedBranch,av.loadCommits]);(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a={filePath:as.selectedPath,lineNumber:Y.current},b=aq.goBack(a);b&&(b.filePath===as.selectedPath?as.setTargetLineNumber(b.lineNumber):aA(b.filePath,b.lineNumber))},[as,aq]),(0,f.useCallback)(()=>{if(!as.selectedPath)return;let a={filePath:as.selectedPath,lineNumber:Y.current},b=aq.goForward(a);b&&(b.filePath===as.selectedPath?as.setTargetLineNumber(b.lineNumber):aA(b.filePath,b.lineNumber))},[as,aq]);let aN=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a;try{await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})}),(0,j.oR)(K("toast.copiedName",{name:c}),"success")}catch{(0,j.oR)(K("toast.copyFailed"),"error")}},[b]),aO=(0,f.useCallback)(async a=>{try{let c=await fetch("/api/files/clipboard"),d=await c.json();if(!d.path)return void(0,j.oR)(K("toast.noFileToPaste"),"info");let e=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,targetDir:a,sourceAbsPath:d.path})}),f=await e.json();e.ok?((0,j.oR)(K("toast.pastedFile",{name:f.newName}),"success"),as.loadDirectory(a),as.loadFileIndex()):(0,j.oR)(f.error||K("toast.pasteFailed"),"error")}catch{(0,j.oR)(K("toast.pasteFailed"),"error")}},[b,as]);(0,f.useRef)(0),(0,f.useRef)(ar),(0,f.useRef)(M);let aP=(0,f.useRef)(av.selectedBranch);aP.current=av.selectedBranch;let aQ=(0,f.useRef)(as.selectedPath);aQ.current=as.selectedPath;let aR=(0,f.useRef)(as.fileContent?.type);aR.current=as.fileContent?.type;let aS=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(fetch(`/api/files/init?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.error||as.setFiles(a.files||[])})),f.push(fetch(`/api/files/index?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.paths&&as.setFileIndex(a.paths)})),f.push(fetch(`/api/files/recent?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{as.setRecentFiles(a.files||[])}))),d||e){f.push(fetch(`/api/git/status?cwd=${encodeURIComponent(b)}`).then(a=>{if(a.ok)return a.json().then(a=>{au.setStatus(a);let b=(0,l.Do)(a.staged),c=(0,l.Do)(a.unstaged);au.setStagedTree(b),au.setUnstagedTree(c);let d=new Set([...(0,l.Sz)(b),...(0,l.Sz)(c)]);au.setStatusExpandedPaths(a=>new Set([...a,...d]))})})),au.refreshDiff(),d&&av.loadBranches();let a=aP.current;a&&f.push(fetch(`/api/git/commits?cwd=${encodeURIComponent(b)}&branch=${encodeURIComponent(a)}&limit=${p.B_}`).then(a=>a.json()).then(a=>{let b=a.commits||[];av.setCommits(b),av.setHasMoreCommits(b.length>=p.B_)}))}let g=aQ.current,h=aR.current;g&&"text"===h&&f.push(fetch(`/api/files/read?cwd=${encodeURIComponent(b)}&path=${encodeURIComponent(g)}`).then(a=>a.json()).then(a=>{"text"===a.type&&as.setFileContent(a)})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:aS,enabled:ar});let aT=(0,f.useCallback)(a=>{let b=a.split("/");if(b.length>1){let a=[];for(let c=1;c<b.length;c++)a.push(b.slice(0,c).join("/"));as.setExpandedPaths(b=>{let c=new Set(b);for(let b of a)c.add(b);return as.saveExpandedPaths(c),c})}as.setSelectedPath(a),as.setShouldScrollToSelected(!0),N("tree")},[as]);return(0,e.jsxs)(m.SU,{container:Q,children:[(0,e.jsxs)("div",{ref:O,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>aM("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>aM("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>aM("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>aM("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>aM("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===M?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:K("fileBrowser.historyTab")})]}),"tree"===M&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:as.searchInputRef,type:"text",value:as.searchQuery,onChange:a=>as.setSearchQuery(a.target.value),placeholder:K("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),as.searchQuery&&(0,e.jsx)("button",{onClick:()=>as.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:K("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>as.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${as.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:as.searchExactMatch?K("fileBrowser.exactMatchOn"):K("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>as.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>as.searchTreeExpandedPaths?as.setSearchTreeExpandedPaths(new Set):as.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===M&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:at.contentSearchInputRef,type:"text",value:at.contentSearchQuery,onChange:a=>at.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&at.performContentSearch(at.contentSearchQuery)},placeholder:K("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),at.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>at.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:K("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>at.performContentSearch(at.contentSearchQuery),disabled:at.isSearching||!at.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:at.isSearching?"...":K("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.caseSensitive,onChange:a=>at.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.wholeWord,onChange:a=>at.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:at.searchOptions.regex,onChange:a=>at.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:K("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:at.searchOptions.fileType,onChange:a=>at.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:K("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===M&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(u.e,{branches:av.branches,selectedBranch:av.selectedBranch,onSelect:a=>{av.setSelectedBranch(a),av.compareMode&&av.loadCompareFiles(a)},isLoading:av.isLoadingBranches})}),(0,e.jsx)("button",{onClick:()=>av.toggleCompareMode(!av.compareMode),className:`flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors ${av.compareMode?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent border border-border"}`,title:av.compareMode?K("fileBrowser.compareModeOff"):K("fileBrowser.compareModeOn"),children:K("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===M?"":"hidden"}`,children:[as.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:as.creatingItem.parentPath?K("fileBrowser.createFileIn",{path:as.creatingItem.parentPath}):K("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:K("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{P.current=!0},onCompositionEnd:()=>{P.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(P.current)return;let c=a.target.value.trim();if(!c)return;let d=as.creatingItem.parentPath,e=d?`${d}/${c}`:c;try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:e,content:""})});if(a.ok)(0,j.oR)(K("toast.createdFile",{name:c}),"success"),as.setCreatingItem(null),as.loadDirectory(d),as.loadFileIndex(),d&&as.setExpandedPaths(a=>new Set([...a,d])),aA(e);else{let b=await a.json();(0,j.oR)(b.error||K("toast.createFailed"),"error")}}catch(a){(0,j.oR)(K("toast.createFailed"),"error")}}else"Escape"===a.key&&as.setCreatingItem(null)},onBlur:()=>as.setCreatingItem(null)})]}),as.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("common.loading")}):as.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:as.fileError}):(0,e.jsx)(k.h,{files:as.files,selectedPath:as.selectedPath,expandedPaths:as.effectiveExpandedPaths,matchedPaths:as.matchedPaths,gitStatusMap:aL,loadingDirs:as.loadingDirs,onSelect:a=>{as.setShouldScrollToSelected(!1),aA(a)},onToggle:as.handleToggle,cwd:b,shouldScrollToSelected:as.shouldScrollToSelected,onScrolledToSelected:()=>as.setShouldScrollToSelected(!1),onCreateFile:a=>as.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>T({path:a,isDirectory:b,name:c}),onRefresh:()=>as.loadFiles(),onCopyFile:aN,onPaste:aO})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===M?"":"hidden"}`,children:at.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):at.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:at.searchError}):0===at.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:at.contentSearchQuery?K("fileBrowser.noContentSearchResults"):K("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[at.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[K("fileBrowser.nFilesNMatches",{files:at.searchStats.totalFiles,matches:at.searchStats.totalMatches}),at.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",K("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(k.h,{files:aB.files,selectedPath:as.selectedPath,expandedPaths:aC,onSelect:a=>{let b=aB.matchMap.get(a);aA(a,b?.matches[0]?.lineNumber),ad||ae(!0)},onToggle:aE,cwd:b,renderActions:aF,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===M?"":"hidden"}`,children:0===as.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noRecentFiles")}):(0,e.jsx)(k.h,{files:as.recentFilesTree,selectedPath:as.selectedPath,expandedPaths:as.recentTreeDirPaths,onSelect:aA,onToggle:p.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===M?"":"hidden"}`,children:au.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):au.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:au.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:K("fileBrowser.stagingArea",{count:au.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>au.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:K("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(au.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:au.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:K("fileBrowser.unstageAll")})]}),(0,e.jsx)(l.VO,{files:au.stagedTree,selectedPath:au.statusSelectedFile?.type==="staged"?au.statusSelectedFile.file.path:null,expandedPaths:au.statusExpandedPaths,onSelect:a=>a.file&&au.handleStatusFileSelect(a.file,"staged"),onToggle:au.handleStatusToggle,cwd:b,emptyMessage:K("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,l.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:K("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:K("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:K("fileBrowser.workspace",{count:au.status?.unstaged.length||0})}),(au.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:au.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:K("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:au.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:K("fileBrowser.stageAll")})]})]}),(0,e.jsx)(l.VO,{files:au.unstagedTree,selectedPath:au.statusSelectedFile?.type==="unstaged"?au.statusSelectedFile.file.path:null,expandedPaths:au.statusExpandedPaths,onSelect:a=>a.file&&au.handleStatusFileSelect(a.file,"unstaged"),onToggle:au.handleStatusToggle,cwd:b,emptyMessage:K("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,l.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:K("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),au.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:K("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:K("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),au.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:K("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===M?"":"hidden"}`,children:av.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:av.historyError})]})}):av.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:av.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.loadingDiff")}):0===av.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:K("fileBrowser.nFilesChanged",{count:av.compareFiles.length,branch:av.selectedBranch})})}),(0,e.jsx)(l.VO,{files:av.compareFileTree,expandedPaths:av.compareExpandedPaths,onToggle:av.handleCompareToggle,selectedPath:av.compareSelectedFile?.path||null,onSelect:a=>{a.file&&av.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:av.commitListRef,className:"flex-1 overflow-y-auto",onScroll:av.handleCommitListScroll,children:av.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.loadingCommits")}):0===av.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:K("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[av.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>av.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${av.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,p.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),av.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!av.hasMoreCommits&&av.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:K("fileBrowser.allLoaded",{count:av.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===M||"search"===M||"recent"===M)&&(as.blameSelectedCommit?(0,e.jsx)(h.n,{isOpen:!0,onClose:()=>as.setBlameSelectedCommit(null),commit:as.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:as.selectedPath||void 0,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):as.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:as.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${as.selectedPath}`),(0,j.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aT(as.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:as.showEditor?(0,e.jsxs)(e.Fragment,{children:[ab.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:K("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aa.current?.save(),disabled:!ab.isDirty||ab.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ab.isDirty&&!ab.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:ab.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):K("common.save")}),(0,e.jsx)("button",{onClick:()=>aa.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.closeEdit"),children:K("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[as.fileContent?.type==="text"&&as.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(as.fileContent.content),(0,j.oR)(K("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.copyFileContent"),children:K("common.copy")}),as.selectedPath?.endsWith(".json")&&as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ag(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${af?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:K("fileBrowser.toggleJsonReadable"),children:K("common.readable")}),as.fileContent?.type==="text"&&(0,o.e$)(as.selectedPath)&&(0,e.jsx)("button",{onClick:()=>as.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.previewMarkdown"),children:K("common.preview")}),as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:as.handleToggleBlame,disabled:as.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${as.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:K("fileBrowser.viewBlame"),children:as.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),as.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>as.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:K("fileBrowser.editFile"),children:K("common.edit")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:as.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):as.fileContent?"text"===as.fileContent.type&&"string"==typeof as.fileContent.content?as.showBlame&&as.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:as.blameError}),(0,e.jsx)("button",{onClick:()=>as.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:K("fileBrowser.backToPreview")})]})}):as.showBlame&&0===as.blameLines.length&&as.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):af&&as.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(C._,{search:ak}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:aj,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,o.xb)(as.fileContent.content)})})]}):(0,e.jsx)(n.Cv,{ref:aa,content:as.fileContent.content,filePath:as.selectedPath,cwd:b,enableComments:!0,scrollToLine:$??as.targetLineNumber,scrollToLineAlign:null!=$?"start":as.targetScrollAlign,onScrollToLineComplete:()=>{_(null),as.setTargetLineNumber(null)},highlightKeyword:"search"===M?at.contentSearchQuery:null,visibleLineRef:Y,viStateRef:Z,initialCursorLine:as.initialCursorLine,initialCursorCol:as.initialCursorCol,onInitialCursorSet:()=>{as.setInitialCursorLine(null),as.setInitialCursorCol(null)},onCmdClick:aH?aI:void 0,onTokenHover:aH?aJ:void 0,onTokenHoverLeave:aH?ao.onTokenMouseLeave:void 0,onTokenHoverCancel:aH?ao.clearHover:void 0,blameLines:as.showBlame&&as.blameLines.length>0?as.blameLines:void 0,inlineBlameLines:as.blameLines.length>0?as.blameLines:void 0,onSelectCommit:as.setBlameSelectedCommit,editable:as.showEditor,initialMtime:as.fileContent.mtime,onEditorClose:a=>{as.setShowEditor(!1),_(a)},onSaved:()=>{let a=Y.current??1;as.loadFileContent(as.selectedPath),as.setShowEditor(!1),_(a)},onEditorStateChange:ac,viMode:!0,onContentMutate:aw,onEnterInsertMode:ax,onViSave:ay,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):"image"===as.fileContent.type&&as.fileContent.content?(0,e.jsx)("div",{className:"h-full flex items-center justify-center p-4 bg-secondary",children:(0,e.jsx)("img",{src:as.fileContent.content,alt:as.selectedPath,className:"max-w-full max-h-full object-contain"})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:as.fileContent.message||K("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:K("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:K("fileBrowser.selectFileToPreview")})]})})),"status"===M&&(au.statusSelectedFile&&au.statusDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:au.statusSelectedFile.file.path}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${au.statusSelectedFile.file.path}`),(0,j.oR)(K("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aT(au.statusSelectedFile.file.path)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:K("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===au.statusSelectedFile.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===au.statusSelectedFile.type?K("fileBrowser.staged"):K("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,p.u)(au.statusSelectedFile.file.path)?(0,e.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,e.jsx)("img",{src:`/api/files/read?cwd=${encodeURIComponent(b)}&path=${encodeURIComponent(au.statusSelectedFile.file.path)}&raw=1`,alt:au.statusSelectedFile.file.path,className:"max-w-full max-h-[60vh] object-contain"})}):(0,e.jsx)(i.xZ,{oldContent:au.statusDiff.oldContent,newContent:au.statusDiff.newContent,filePath:au.statusDiff.filePath,isNew:au.statusDiff.isNew,isDeleted:au.statusDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!au.statusDiff.isDeleted&&(0,o.e$)(au.statusSelectedFile.file.path)?()=>au.setShowStatusDiffPreview(!0):!au.statusDiff.isDeleted&&au.statusSelectedFile.file.path.endsWith(".json")?()=>ai({content:au.statusDiff.newContent,filePath:au.statusDiff.filePath}):void 0,previewLabel:au.statusSelectedFile.file.path.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}})}),au.showStatusDiffPreview&&au.statusDiff&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>au.setShowStatusDiffPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.M,{content:au.statusDiff.newContent,filePath:au.statusDiff.filePath,cwd:b,onClose:()=>au.setShowStatusDiffPreview(!1)})})}),ah&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ai(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:ah.filePath}),(0,e.jsx)("button",{onClick:()=>ai(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(C._,{search:am}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:al,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,o.xb)(ah.content)})})]})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:K("fileBrowser.selectFileToViewDiff")})})),"history"===M&&!av.historyError&&(av.compareMode?av.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:K("fileBrowser.loadingDiffContent")}):av.compareFileDiff?(0,e.jsx)(i.xZ,{oldContent:av.compareFileDiff.oldContent,newContent:av.compareFileDiff.newContent,filePath:av.compareFileDiff.filePath,isNew:av.compareFileDiff.isNew,isDeleted:av.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!av.compareFileDiff.isDeleted&&av.compareFileDiff.filePath.endsWith(".json")?()=>ai({content:av.compareFileDiff.newContent,filePath:av.compareFileDiff.filePath}):void 0,previewLabel:K("common.readable"),onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:av.compareFiles.length>0?K("fileBrowser.selectFileToViewDiff"):K("fileBrowser.clickCompareToLoad")})}):av.selectedCommit?(0,e.jsx)(h.n,{isOpen:!0,onClose:()=>av.setSelectedCommit(null),commit:av.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:K("fileBrowser.selectCommitToView")})}))]})]}),as.showMarkdownPreview&&as.fileContent?.type==="text"&&as.selectedPath&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>as.setShowMarkdownPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.M,{content:as.fileContent.content||"",filePath:as.selectedPath,cwd:b,onClose:()=>as.setShowMarkdownPreview(!1)})})}),U&&(0,e.jsx)(r.c,{files:as.files,fileIndex:as.fileIndex,recentFiles:as.recentFilePaths,onSelectFile:a=>{aA(a),as.setShouldScrollToSelected(!0),N("tree")},onClose:()=>V(!1)}),(aG||ap.visible)&&(0,e.jsxs)("div",{className:`flex ${ap.visible&&aG?"":"flex-col"}`,children:[aG&&(0,e.jsx)("div",{className:ap.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(G.D,{results:at.contentSearchResults,loading:at.isSearching,totalMatches:at.searchStats?.totalMatches??0,onSelect:(a,b)=>{as.selectedPath&&aq.push({filePath:as.selectedPath,lineNumber:Y.current}),aA(a,b)},onClose:()=>ae(!1)})}),ap.visible&&(0,e.jsx)("div",{className:aG?"flex-1 min-w-0":"",children:(0,e.jsx)(F.D,{references:ap.references,loading:ap.loading,onSelect:aK,onClose:ap.closeReferences})})]})]}),W&&(0,g.createPortal)((0,e.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:W.x+12,top:W.y+16},children:W.text}),document.body),S&&(0,g.createPortal)((0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>T(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:K("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:K("fileBrowser.confirmDeleteMessage",{name:S.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>T(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:K("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=S;T(null);try{let d=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})});if(d.ok){(0,j.oR)(K("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";as.loadDirectory(b),as.loadFileIndex(),as.selectedPath===a&&aA("")}else{let a=await d.json();(0,j.oR)(a.error||K("toast.deleteFailed"),"error")}}catch{(0,j.oR)(K("toast.deleteFailed"),"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:K("common.delete")})]})]})}),document.body),ao.hoverInfo&&Q&&(0,g.createPortal)((0,e.jsx)(E.s,{ref:a=>{ao.tooltipElRef.current=a},displayString:ao.hoverInfo.displayString,documentation:ao.hoverInfo.documentation,x:ao.hoverInfo.x,y:ao.hoverInfo.y,container:Q,onMouseEnter:ao.onCardMouseEnter,onMouseLeave:ao.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=ao.hoverInfo;ao.clearHover(),ap.findReferences(a,b,c)},onSearch:a=>{ao.clearHover(),N("search"),at.setContentSearchQuery(a),at.performContentSearch(a)}}),Q)]})}[h,i,n,F,G]=I.then?(await I)():I,d()}catch(a){d(a)}})},54338:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(4667),i=c(54017),j=c(26130),k=c(27805),l=c(94924),m=c(77033),n=c(92154),o=c(93053),p=c(81190),q=c(48464),r=c(92050),s=c(13928),t=c(132),u=c(21108),v=a([i,r]);function w({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,v]=(0,f.useState)("agent"),{tabs:w,activeTabId:x,activeTab:y,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,closeTab:C,switchTab:D,handleSelectSession:E,handleNewTab:F,handleOpenSession:G,updateTabState:H,handleTabDragStart:I,handleTabDragOver:J,handleTabDrop:K,handleTabDragEnd:L}=(0,o.i)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:M,pinSession:N,unpinSession:O}=(0,t.P)(),{createTask:P}=(0,u.n)(),Q=(0,f.useCallback)(a=>{let b=w.find(b=>b.id===a);return!!b?.sessionId&&M(b.sessionId)},[w,M]),R=(0,f.useCallback)(b=>{let c=w.find(a=>a.id===b);c?.sessionId&&(M(c.sessionId)?O(c.sessionId):N(c.sessionId,c.cwd||a||"",c.title))},[w,M,N,O,a]),[S,T]=(0,f.useState)(!1),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(!1),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(!1),[aa,ab]=(0,f.useState)("tree"),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(null),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(!1);(0,f.useRef)(null);let ak=(0,f.useCallback)(b=>{v(b),a&&(fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,settings:{activeView:b}})}).catch(()=>{}),window.parent.postMessage({type:"VIEW_CHANGE",cwd:a,view:b},"*"))},[a]),al=(0,f.useCallback)(async()=>{if(a)try{let b=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(a)}`);if(b.ok){let c=await b.json();if(_(c.isGitRepo),c.isGitRepo&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&Z(b.branch)}}}catch(a){console.error("Failed to load git info:",a)}},[a]),am=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&al()},[al]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:am,enabled:!!a});let an=(0,f.useCallback)(()=>{ab("status"),ad(a=>a+1),ak("explorer")},[ak]),ao=(0,f.useCallback)(a=>{af(a),ah(a=>a+1),ak("explorer")},[ak]),ap=(0,f.useCallback)(()=>{a&&window.parent.postMessage({type:"OPEN_NOTE",cwd:a},"*")},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(n.fY,{activeView:d,onViewChange:ak,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(p.B,{initialCwd:a,activeTab:y,isGitRepo:$,currentBranch:Y,onOpenWorktree:()=>V(!0),onOpenProjectSessions:()=>T(!0),onOpenAliasManager:()=>X(!0),onBranchSwitched:al}),ai&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),c("console.screenshotting")]}),a?(0,e.jsxs)(n.c0,{children:[(0,e.jsxs)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(q.V,{tabs:w,activeTabId:x,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,isPinned:Q,onTogglePin:R,onSwitchTab:D,onCloseTab:C,onNewTab:F,onDragStart:I,onDragOver:J,onDrop:K,onDragEnd:L}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:w.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===x?"block":"hidden"}`,children:(0,e.jsx)(r.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,isActive:a.id===x&&"agent"===d,onStateChange:H,onShowGitStatus:an,onContentSearch:ao,onOpenNote:ap,onCreateScheduledTask:P,onOpenSession:G})},a.id))})]}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(i.g,{onClose:()=>ak("agent"),cwd:a,initialTab:aa,tabSwitchTrigger:ac,initialSearchQuery:ae,searchQueryTrigger:ag})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:ap})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(q.V,{tabs:w,activeTabId:x,unreadTabs:z,dragTabIndex:A,dragOverTabIndex:B,isPinned:Q,onTogglePin:R,onSwitchTab:D,onCloseTab:C,onNewTab:F,onDragStart:I,onDragOver:J,onDrop:K,onDragEnd:L}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:w.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===x?"block":"hidden"}`,children:(0,e.jsx)(r.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,isActive:a.id===x,onStateChange:H,onCreateScheduledTask:P,onOpenSession:G})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:S,onClose:()=>T(!1),cwd:a,onSelectSession:E}),a&&$&&(0,e.jsx)(j.x,{isOpen:U,onClose:()=>V(!1),cwd:a}),W&&(0,e.jsx)(l.Y,{onClose:()=>X(!1),onSave:()=>X(!1)})]})})})}[i,r]=v.then?(await v)():v,d()}catch(a){d(a)}})},55313:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},55511:a=>{"use strict";a.exports=require("crypto")},56111:(a,b,c)=>{"use strict";c.d(b,{e:()=>f});var d=c(67484),e=c(41564);function f(a,b,{sessionId:c,cwd:f,onSessionId:g,onFetchTitle:h}){let[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useRef)(null),n=(0,d.useRef)(c);n.current=c;let o=(0,d.useRef)(null),p=(0,d.useRef)(null),q=(0,d.useCallback)(()=>{let a=o.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a)),o.current={messageId:c,text:""}}p.current=null},[b]),r=(0,d.useCallback)(()=>{m.current&&(m.current.abort(),m.current=null)},[]),s=(0,d.useCallback)((a,c)=>{let d=a.type;if("system"===d&&"init"===a.subtype){let b=a.session_id;g(b),n.current=b;return}if("stream_event"===d){let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";o.current&&o.current.messageId===c?o.current.text+=a:o.current={messageId:c,text:a},p.current||(p.current=setTimeout(q,50))}return}if("assistant"===d){let d=a.message;if(d?.content){for(let a of d.content)if("name"in a&&a.name){let d={id:a.id||`tool-${Date.now()}`,name:a.name,input:a.input||{},isLoading:!0};b(a=>a.map(a=>a.id!==c||a.toolCalls?.some(a=>a.id===d.id)?a:{...a,toolCalls:[...a.toolCalls||[],d]}))}}}if("user"===d){let d=a.message;if(d?.content){for(let a of d.content)if("tool_use_id"in a&&a.tool_use_id){let d=a.tool_use_id,e="string"==typeof a.content?a.content:JSON.stringify(a.content);b(a=>a.map(a=>a.id===c?{...a,toolCalls:a.toolCalls?.map(a=>a.id===d?{...a,result:e,isLoading:!1}:a)}:a))}}}if("result"===d){p.current&&(clearTimeout(p.current),p.current=null),q();let d=n.current;d&&f&&b(a=>(2===a.length&&h(d),a));let e=a.usage,g=a.total_cost_usd;e&&l({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:g||0}),b(a=>a.map(a=>a.id===c?{...a,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a))}},[b,q,g,h,f]);return{isLoading:i,tokenUsage:k,handleSend:(0,d.useCallback)(async(a,c)=>{let d=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),g={id:`user-${Date.now()}`,role:"user",content:a,images:d};b(a=>[...a,g]),j(!0);let h=`assistant-${Date.now()}`,i={id:h,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,i]),m.current=new AbortController;try{let b=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:n.current,images:d,cwd:f}),signal:m.current.signal});if(!b.ok)throw Error(e.A.t("chat.requestFailed"));let c=b.body?.getReader();if(!c)throw Error(e.A.t("chat.cannotReadStream"));let g=new TextDecoder,i="";for(;;){let{done:a,value:b}=await c.read();if(a)break;let d=(i+=g.decode(b,{stream:!0})).split("\n");for(let a of(i=d.pop()||"",d))if(a.startsWith("data: ")){let b=a.slice(6);if("[DONE]"===b)continue;try{let a=JSON.parse(b);s(a,h)}catch{}}}}catch(a){a instanceof Error&&"AbortError"===a.name||(console.error("Chat error:",a),b(a=>a.map(a=>a.id===h?{...a,content:e.A.t("chat.errorRetry"),isStreaming:!1}:a)))}finally{m.current=null,j(!1),b(a=>a.map(a=>a.id===h?{...a,isStreaming:!1}:a))}},[f,b,s]),handleStop:r,abortControllerRef:m}}},56929:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,e$:()=>t,jU:()=>g,oK:()=>u,u:()=>s,xb:()=>i,zs:()=>q});var d=c(67484),e=c.n(d),f=c(41564);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}function i(a){try{let b=JSON.parse(a);return p(b,0)}catch{return a}}let j="#79c0ff",k="#a5d6ff",l="#ff7b72",m="#8b949e",n=(a,b)=>e().createElement("span",{style:{color:a}},b);function o({label:a,labelColor:b,value:c,indent:d}){let[g,h]=e().useState(!1),[i,j]=e().useState({x:0,y:0}),l="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,o={onMouseDown:a=>{j({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-i.x,c=a.clientY-i.y;b*b+c*c>25||(a.stopPropagation(),h(a=>!a))},style:{cursor:"pointer"}};if(l&&g&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],g=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",o,n(b,a),n(m,": "),n(k,d),n("#6e7681",` ${f.A.t("toolCall.foldedLines",{count:g})}`))}let q=e().createElement(e().Fragment,null,n(b,a),n(m,": "),p(c,d));return l?e().createElement("span",o,q):q}function p(a,b){let c=" ".repeat(b);if(null===a)return n(l,"null");if(void 0===a)return n(l,"undefined");if("string"==typeof a)return n(k,a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+c));if("number"==typeof a)return n("#79c0ff",String(a));if("boolean"==typeof a)return n(l,String(a));if(Array.isArray(a))return 0===a.length?n(m,"[]"):e().createElement(e().Fragment,null,n(m,"["),"\n",...a.map((d,f)=>e().createElement("span",{key:f},c+" ",e().createElement(o,{label:`[${f}]`,labelColor:j,value:d,indent:b+1}),f<a.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"]"));if("object"==typeof a){let d=Object.entries(a);return 0===d.length?n(m,"{}"):e().createElement(e().Fragment,null,n(m,"{"),"\n",...d.map(([a,f],g)=>e().createElement("span",{key:a},c+" ",e().createElement(o,{label:a,labelColor:j,value:f,indent:b+1}),g<d.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"}"))}return String(a)}function q(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let r=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function s(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return r.has(b)}function t(a){return a.toLowerCase().endsWith(".md")}function u(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},59347:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},61969:(a,b,c)=>{"use strict";c.d(b,{e:()=>g,g:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:g,onOpenSettings:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:g,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${j?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:j?i("chat.copiedCommandTooltip"):i("chat.copyCommandTooltip",{sessionId:b}),children:j?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}function h({tokenUsage:a}){let{t:b}=(0,f.Bd)();return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[b("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[b("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62862:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66185:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(4219);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,i=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&i(g,0,"text-muted-foreground"),i(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:j,onClose:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(0),q=(0,e.useRef)(null),r=(0,e.useRef)(null),s=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),t=(0,e.useMemo)(()=>{if(!m.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...s.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of s){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,m.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[m,s,c]),u=(0,e.useCallback)(a=>{n(a),p(0)},[]),v=(0,e.useCallback)(a=>{j(a),k()},[j,k]),w=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),p(a=>Math.min(a+1,t.length-1));break;case"ArrowUp":a.preventDefault(),p(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),t[o]&&v(t[o].path);break;case"Escape":a.preventDefault(),k()}},[t,o,v,k]);return(0,g.createPortal)((0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:k,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:q,value:m,onChange:a=>u(a.target.value),onKeyDown:w,placeholder:l("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:r,className:"flex-1 overflow-y-auto py-1",children:0===t.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("quickFileOpen.noMatch")}):t.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===o?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":a.path,onClick:()=>v(a.path),children:[(0,d.jsx)(h.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!m.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:l("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",l("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",l("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",l("quickFileOpen.closeHint")]})]})]})}),document.body)}},66254:(a,b,c)=>{"use strict";c.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(26068),i=c(4219);let j={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=null,loadingDirs:j,onSelect:l,onToggle:m,cwd:n,shouldScrollToSelected:o=!1,onScrolledToSelected:p,className:q,renderActions:r,onCreateFile:s,onDelete:t,onRefresh:u,onCopyFile:v,onPaste:w}){let x=(0,e.useRef)(null),{contextMenu:y,showContextMenu:z,hideContextMenu:A}=(0,h.Ee)(),B=(0,e.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,f,i),[a,c,f,i]),C=(0,g.Te)({count:B.length,getScrollElement:()=>x.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(p).current=p,0===B.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:x,className:q||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${C.getTotalSize()}px`,width:"100%",position:"relative"},children:C.getVirtualItems().map(a=>{let e=B[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:l,onToggle:m,onContextMenu:z,renderActions:r})},e.node.path)})}),y&&(0,d.jsx)(h.ft,{x:y.x,y:y.y,path:y.path,cwd:n,isDirectory:y.isDirectory,onClose:A,onCreateFile:s,onDelete:t,onRefresh:u,onCopyFile:v,onPaste:w})]})}},68502:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:g,onClose:h,onUpdateComment:i,onDeleteComment:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(c.content),p=(0,e.useRef)(null),[q,r]=(0,e.useState)({x:0,y:0}),s=async()=>{n.trim()&&(await i(c.id,n.trim()),m(!1))},t=async()=>{await j(c.id),h()};return(0,d.jsx)("div",{ref:p,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:q.x,top:q.y},children:(0,d.jsx)("div",{className:"p-3",children:l?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:n,onChange:a=>o(a.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),s()),"Escape"===a.key&&(m(!1),o(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{m(!1),o(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:k("common.cancel")}),(0,d.jsx)("button",{onClick:s,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:k("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:k("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:k("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{onClick:t,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:k("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},69648:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(80600),j=c(44218),k=c(19794),l=c(46674),m=c(86402),n=a([m]);function o(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function p({node:a,selectedUid:b,onSelect:c,depth:d=0}){let[g,h]=(0,f.useState)(!0);if(a.isFile&&a.change){let f=b===a.change.uid;return(0,e.jsxs)("button",{onClick:()=>c(a.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${f?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*d+8}px`},"data-tooltip":a.fullPath,children:[(0,e.jsx)(i.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,e.jsx)("span",{className:"truncate",children:a.name}),(0,e.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===a.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===a.change.type?"new":"edit"})]})}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{onClick:()=>h(!g),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*d+8}px`},children:[g?(0,e.jsx)(j.A,{className:"w-3 h-3"}):(0,e.jsx)(k.A,{className:"w-3 h-3"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),g&&a.children.map((a,f)=>(0,e.jsx)(p,{node:a,selectedUid:b,onSelect:c,depth:d+1},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${f}`))]})}function q({toolCalls:a,cwd:b,onClose:c}){let{t:d}=(0,g.Bd)(),i=(0,f.useMemo)(()=>(function(a,b){let c=[],d=0;for(let e of a)if("Edit"===e.name){let a=e.input;a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"edit",old_string:a.old_string,new_string:a.new_string})}else if("Write"===e.name){let a=e.input;a.file_path&&"string"==typeof a.content&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"write",old_string:"",new_string:a.content})}return c})(a,b),[a,b]),j=(0,f.useMemo)(()=>(function a(b){return b.map(b=>{if(!b.isFile&&1===b.children.length&&!b.children[0].isFile){let c=b.children[0];return{...c,name:b.name+"/"+c.name,children:a(c.children)}}return{...b,children:a(b.children)}})})(function(a){let b=[];for(let c of a){let a=c.filePath.split("/").filter(Boolean),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/");if(f){let a={name:e,fullPath:g,isFile:!0,children:[],change:c};d.push(a)}else{let a=d.find(a=>a.name===e&&!a.isFile);a||(a={name:e,fullPath:g,isFile:!1,children:[]},d.push(a)),d=a.children}}}return b}(i)),[i]),[k,n]=(0,f.useState)(i[0]||null),[q,r]=(0,f.useState)("unified"),[s,t]=(0,f.useState)(null),u=(0,f.useRef)(null);if(0===i.length)return null;let v=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:c,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:d("diffViewer.fileChanges",{count:i.length})})}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,e.jsx)("button",{onClick:()=>r("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===q?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,e.jsx)("button",{onClick:()=>r("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===q?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,e.jsx)("button",{onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{ref:u,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:j.map((a,b)=>(0,e.jsx)(p,{node:a,selectedUid:k?.uid||"",onSelect:n},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${b}`))}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:k?"unified"===q?(0,e.jsx)(m.xU,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath}):(0,e.jsx)(m.xZ,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath,isNew:"write"===k.type}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:d("diffViewer.selectFileToView")})})]})]})});return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(h.Z,{children:v}),s&&(0,e.jsx)(h.Z,{children:(0,e.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:s.x+12,top:s.y+16},children:s.text})})]})}m=(n.then?(await n)():n)[0],d()}catch(a){d(a)}})},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73136:a=>{"use strict";a.exports=require("node:url")},74405:(a,b,c)=>{Promise.resolve().then(c.bind(c,54338))},75005:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:e,onSave:f,getVisibleLineCount:g,scrollToLine:h,onSearchExecute:i,onSearchNext:j,onSearchPrev:k,onSearchClear:l}){let[m,n]=(0,d.useState)("normal"),[o,p]=(0,d.useState)(-1),[q,r]=(0,d.useState)(0),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(""),[w,x]=(0,d.useState)(""),[y,z]=(0,d.useState)(""),[A,B]=(0,d.useState)(""),C=(0,d.useRef)([]),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)(null),G=(0,d.useRef)(a),H=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(G.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let I=(0,d.useCallback)(()=>{F.current&&(clearTimeout(F.current),F.current=null),v("")},[]),J=(0,d.useCallback)(()=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{v(""),F.current=null},500)},[]),K=(0,d.useCallback)((a,b)=>{C.current.push(b),D.current=[],t(!0),c(a.join("\n"))},[c]),L=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,G.current.length-1));p(c),r(H(c,b??0)),h(c,"auto")},[h,H]),M=(0,d.useCallback)(a=>{p(b=>{let c=Math.max(0,Math.min(b+a,G.current.length-1));return h(c,"auto"),r(a=>Math.max(0,Math.min(a,Math.max(0,(G.current[c]??"").length-1)))),c})},[h]),N=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1);if(0===a.length)return;let c=a[b];E.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);K(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),p(e),r(0)},[o,K]),O=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1);a.length>0&&(E.current=[a[b]])},[o]),P=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=G.current,c=Math.min(o,b.length-1)+1,d=[...b];d.splice(c,0,...a),K(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:o}),p(c),r(0),h(c,"auto")},[o,K,h]),Q=(0,d.useCallback)(()=>{let a=G.current,b=Math.min(o,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,K(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:o})},[o,K]),R=(0,d.useCallback)(()=>{let a=C.current;if(0===a.length)return;let b=a.pop(),d=[...G.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),D.current.push(b),c(d.join("\n")),p(Math.min(b.cursorLine,d.length-1)),h(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&t(!1)},[c,h]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...G.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),C.current.push(b),t(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);p(Math.min(e,d.length-1)),h(Math.min(e,d.length-1),"auto")},[c,h]),T=(0,d.useCallback)(a=>{let b=G.current,c=Math.min(o,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),K(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:o}),c=d,p(d)}n("insert"),e(c,q,a)},[o,q,K,e]),U=(0,d.useCallback)(()=>{n("normal"),I()},[I]),V=(0,d.useCallback)(()=>{n("command"),x("")},[]),W=(0,d.useCallback)(()=>{n("normal"),x("")},[]),X=(0,d.useCallback)(()=>{n("search"),z("")},[]),Y=(0,d.useCallback)(()=>{n("normal"),z("")},[]),Z=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){f?.(),n("normal"),x("");return}if("q"===b){n("normal"),x("");return}if("wq"===b){f?.(),n("normal"),x("");return}if("noh"===b||"nohlsearch"===b){l?.(),n("normal"),x("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,G.current.length-1);p(a),h(a,"center"),n("normal"),x("");return}n("normal"),x("")},[f,l,h]),$=(0,d.useCallback)(a=>{if(!a){n("normal"),z("");return}B(a),i?.(a),n("normal"),z("")},[i]),_=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===m)return("Escape"===a.key||!!c)&&(U(),!0);if("command"===m)return!a.isComposing&&("Escape"===a.key||c?W():"Enter"===a.key?Z(w):"Backspace"===a.key?0===w.length?W():x(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||x(b=>b+a.key),!0);if("search"===m)return!a.isComposing&&("Escape"===a.key||c?Y():"Enter"===a.key?$(y):"Backspace"===a.key?0===y.length?Y():z(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||z(b=>b+a.key),!0);if(o<0&&(p(0),r(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(M(Math.max(1,Math.floor(g()/2))),I(),!0):"u"===a.key?(M(-Math.max(1,Math.floor(g()/2))),I(),!0):"r"===a.key&&(S(),I(),!0);let d=a.key,e=u+d;if("g"===e)return v("g"),J(),!0;if("gg"===e)return L(0),I(),!0;if("d"===e)return v("d"),J(),!0;if("dd"===e)return N(),I(),!0;if("y"===e)return v("y"),J(),!0;if("yy"===e)return O(),I(),!0;if(u&&e!==d&&I(),"j"===d||"ArrowDown"===d)return M(1),!0;if("k"===d||"ArrowUp"===d)return M(-1),!0;if("h"===d||"ArrowLeft"===d)return r(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(G.current[o]??"").length-1);return r(b=>Math.min(a,b+1)),!0}if("0"===d)return r(0),!0;if("$"===d)return r(Math.max(0,(G.current[o]??"").length-1)),!0;if("^"===d){let a=(G.current[o]??"").search(/\S/);return r(a>=0?a:0),!0}return"G"===d?(L(G.current.length-1),!0):"x"===d?(Q(),!0):"p"===d?(P(),!0):"u"===d?(R(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(T(d),!0):"/"===d?(X(),!0):"n"===d?(j?.(),!0):"N"===d?(k?.(),!0):":"===d?(V(),!0):"Escape"!==d&&1===d.length},[b,m,u,w,y,o,U,T,V,W,X,Y,Z,$,M,L,g,N,O,P,Q,R,S,I,J,j,k]);return{state:{mode:m,cursorLine:o,cursorCol:q,isDirty:s,keyBuffer:u,commandInput:w,searchInput:y,lastSearch:A},handleKeyDown:_,enterNormal:U,enterInsert:T,setCursorLine:p,setCursorCol:r,setCommandInput:x,setSearchInput:z,setIsDirty:t,clearUndoHistory:(0,d.useCallback)(()=>{C.current=[],D.current=[]},[])}}},76760:a=>{"use strict";a.exports=require("node:path")},77033:(a,b,c)=>{"use strict";c.d(b,{k_:()=>g,nH:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g({children:a}){let b=(0,e.useRef)(new Map),c=(0,e.useRef)(null),[g,h]=(0,e.useState)(!1),i=(0,e.useCallback)((a,c)=>{b.current.set(c,a)},[]),j=(0,e.useCallback)(a=>{b.current.delete(a)},[]),k=(0,e.useCallback)(a=>{c.current=a},[]),l=(0,e.useCallback)(a=>{let d=c.current;if(!d)return void console.warn("No active tab to send message");let e=b.current.get(d);e?e(a):console.warn(`No chat sender registered for tab ${d}`)},[]),m=(0,e.useMemo)(()=>({sendMessage:l,isLoading:g,registerChat:i,unregisterChat:j,setActiveTab:k,setIsLoading:h}),[l,g,i,j,k]);return(0,d.jsx)(f.Provider,{value:m,children:a})}function h(){return(0,e.useContext)(f)}},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},77937:(a,b,c)=>{"use strict";c.d(b,{f:()=>h,w:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,visible:c,container:e,onAddComment:g,onSendToAI:h,onSearch:i,isChatLoading:j}){let{t:k}=(0,f.Bd)(),l=e.getBoundingClientRect(),m=a-l.left,n=Math.max(0,b-l.top-40);return(0,d.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:m+8,top:n,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:g,children:k("floatingToolbar.addComment")}),(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:h,disabled:j,title:k(j?"comments.aiResponding":"floatingToolbar.sendToAI"),children:k("floatingToolbar.sendToAI")}),i&&(0,d.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:i,children:k("floatingToolbar.search")})]})}let h=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j}){let[k,l]=(0,e.useState)(0),m=(0,e.useMemo)(()=>a.current,[k]);return(0,d.jsx)(g,{x:m?.x??0,y:m?.y??0,visible:!!m,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j})})},78908:a=>{"use strict";a.exports=import("shiki")},79029:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>y});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(26068),j=c(45214),k=c(90173),l=c(5811),m=c(77937),n=c(68502),o=c(95133),p=c(16306),q=c(94882),r=c(81749),s=c(75005),t=a([k,l,p]);[k,l,p]=t.then?(await t)():t;let x="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function u(a){let b=window.getSelection();if(!b?.rangeCount)return null;let c=b.getRangeAt(0),d=c.startContainer;for(;d&&d.parentElement!==a;)d=d.parentElement;if(!d)return null;let e=Array.from(a.children).indexOf(d);if(e<0)return null;let f=document.createRange();f.selectNodeContents(d),f.setEnd(c.startContainer,c.startOffset);let g=f.toString().length;return{line:e,offset:g}}function v(a,b){let c,d=a.children[b.line];if(!d)return;let e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=b.offset;for(;c=e.nextNode();){let a=c.textContent?.length||0;if(f<=a){let a=window.getSelection(),b=document.createRange();b.setStart(c,f),b.collapse(!0),a?.removeAllRanges(),a?.addRange(b);return}f-=a}let g=window.getSelection(),h=document.createRange();h.selectNodeContents(d),h.collapse(!1),g?.removeAllRanges(),g?.addRange(h)}function w(a){return a.map(a=>`<div style="${x}">${a}</div>`).join("")}let y=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:k="",cwd:t,enableComments:y=!1,scrollToLine:z=null,scrollToLineAlign:A="center",onScrollToLineComplete:B,highlightKeyword:C=null,visibleLineRef:D,onCmdClick:E,onTokenHover:F,onTokenHoverLeave:G,onTokenHoverCancel:H,blameLines:I,inlineBlameLines:J,onSelectCommit:K,editable:L=!1,initialMtime:M,onEditorClose:N,onSaved:O,onEditorStateChange:P,viMode:Q=!1,onContentMutate:R,onEnterInsertMode:S,onViSave:T,viStateRef:U,initialCursorLine:V,initialCursorCol:W,onInitialCursorSet:X,onContentSearch:Y},Z){let{t:$}=(0,g.Bd)(),_=(0,f.useRef)(a),aa=(0,f.useRef)(!1),[ab,ac]=(0,f.useState)(!1),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(()=>a.split("\n").length),ah=(0,f.useRef)(a.split("\n").length),[ai,aj]=(0,f.useState)({show:!1}),ak=(0,f.useRef)(null),al=(0,f.useRef)(null),am=(0,f.useRef)(M),an=(0,f.useRef)(null),ao=(0,f.useRef)(!1),ap=(0,f.useRef)(!1),{parentRef:aq,containerRef:ar,searchInputRef:as,floatingToolbarRef:at,suppressHoverRef:au,bumpToolbarRef:av,savedSelectionRef:aw,highlightedLines:ax,isMounted:ay,cmdHeld:az,flashLine:aA,isSearchVisible:aB,searchQuery:aC,caseSensitive:aD,wholeWord:aE,currentMatchIndex:aF,viewingComment:aG,addCommentInput:aH,sendToAIInput:aI,chatContext:aJ,commentsEnabled:aK,updateComment:aL,deleteComment:aM,lines:aN,matches:aO,rowData:aP,virtualizer:aQ,commentsByEndLine:aR,linesWithComments:aS,setIsSearchVisible:aT,setSearchQuery:aU,setCaseSensitive:aV,setWholeWord:aW,setViewingComment:aX,setAddCommentInput:aY,setSendToAIInput:aZ,goToNextMatch:a$,goToPrevMatch:a_,handleSearchKeyDown:a0,handleCommentBubbleClick:a1,handleToolbarAddComment:a2,handleToolbarSendToAI:a3,handleToolbarSearch:a4,handleCommentSubmit:a5,handleSendToAISubmit:a6,getHighlightedLineHtml:a7,suppressMatchScrollRef:a8,inlineBlameLineRef:a9,inlineBlameVersion:ba}=(0,p.d)({content:a,filePath:b,showSearch:d,cwd:t,enableComments:!L&&y,scrollToLine:L?null:z,scrollToLineAlign:L?"center":A,onScrollToLineComplete:L?void 0:B,visibleLineRef:L?void 0:D,onContentSearch:Y}),bb=(0,i.iN)(),bc=(0,f.useRef)(null),bd=(0,f.useRef)(null),be=(0,f.useRef)({line:0,col:0}),bf=(0,s.A)({lines:aN,enabled:Q&&!L,onContentChange:a=>{R?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aN[a]??"").length;else if("I"===c){let b=(aN[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);be.current={line:a,col:d},S?.(a)},onSave:T,getVisibleLineCount:()=>{let a=aq.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aP.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aQ.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aU(a),aT(!1)},onSearchNext:a$,onSearchPrev:a_,onSearchClear:()=>{aU("")}});(0,f.useEffect)(()=>{U&&(U.current={cursorLine:bf.state.cursorLine,cursorCol:bf.state.cursorCol})},[U,bf.state.cursorLine,bf.state.cursorCol]);let bg=(0,f.useRef)(null);(0,f.useEffect)(()=>{Q&&!L&&null!=V&&b&&bg.current!==b&&(bg.current=b,bf.setCursorLine(V-1),null!=W&&bf.setCursorCol(W-1),X?.())},[Q,L,V,W,b]),(0,f.useEffect)(()=>{if(!Q||L)return;let a=ar.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bf.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[Q,L,bf.handleKeyDown]),(0,f.useEffect)(()=>{if(!Q||L)return;let a=ar.current;a&&"normal"===bf.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[Q,L,bf.state.mode,a]);let bh=(0,f.useCallback)(a=>{if(!Q||L)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bf.setCursorLine(c-1);let d=b.querySelector("[data-code-content]");if(d){let b=document.caretRangeFromPoint(a.clientX,a.clientY);if(b&&d.contains(b.startContainer)){let a,e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=0;for(;a=e.nextNode();){if(a===b.startContainer){f+=b.startOffset;break}f+=a.textContent?.length||0}let g=aN[c-1]??"";bf.setCursorCol(Math.max(0,Math.min(f,Math.max(0,g.length-1))))}}}}let c=a.target;if("TEXTAREA"===c.tagName||"INPUT"===c.tagName||c.isContentEditable)return;let d=ar.current;d&&d.focus()},[Q,L,bf.setCursorLine,bf.setCursorCol,aN]),bi=(0,f.useCallback)(a=>{Q&&!L&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(a8.current=!0,aU(b))})},[Q,L,aU,a8]);(0,f.useEffect)(()=>{"command"===bf.state.mode?setTimeout(()=>bc.current?.focus(),0):"search"===bf.state.mode&&setTimeout(()=>bd.current?.focus(),0)},[bf.state.mode]),(0,f.useEffect)(()=>{let a=aq.current;if(!a)return;let b=()=>{(H??G)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[H,G]),(0,f.useEffect)(()=>{aH||aI?(au.current=!0,G?.()):at.current||(au.current=!1)},[aH,aI,G]),(0,f.useLayoutEffect)(()=>{let a=aw.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=aq.current;if(!c)return;let d=c.querySelector(`[data-line="${a.startLine}"]`),e=c.querySelector(`[data-line="${a.endLine}"]`);if(!d||!e)return;let f=(0,p.o)(d,a.startOffset),g=(0,p.o)(e,a.endOffset);if(f&&g)try{let a=document.createRange();a.setStart(f.node,f.offset),a.setEnd(g.node,g.offset),b?.removeAllRanges(),b?.addRange(a)}catch{}});let bj=(0,f.useCallback)((a,b,c)=>{au.current||F?.(a,b,c)},[F]),bk=(0,f.useCallback)((a,b)=>{au.current||E?.(a,b)},[E]),bl=Math.max(4,String(L?af:aN.length).length),bm=(0,f.useMemo)(()=>{let a=0;for(let b of aN){let c=0;for(let a=0;a<b.length;a++)" "===b[a]?c+=2-c%2:c+=1;c>a&&(a=c)}return a},[aN]);(0,f.useEffect)(()=>{if(L){_.current=a;let b=a.split("\n").length;ah.current=b,ag(b),aa.current=!1,ac(!1),aj({show:!1}),am.current=M}},[L,a,M]),(0,f.useEffect)(()=>{if(!L)return;let b=ak.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>ax[b]||(0,l.ZD)(a||" "));b.innerHTML=w(d),requestAnimationFrame(()=>{let a,d;Q?(a=Math.max(0,Math.min(be.current.line,c.length-1)),d=be.current.col):(a=Math.max(0,Math.min((D?.current??1)-1,c.length-1)),d=0),b.focus(),v(b,{line:a,offset:d});let e=D?.current??1;al.current&&(al.current.scrollTop=(e-1)*20)})},[L]),(0,f.useEffect)(()=>{L&&P?.({isDirty:ab,isSaving:ad})},[L,ab,ad,P]);let bn=(0,f.useCallback)(()=>{let a=ak.current;if(!a)return _.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),bo=(0,f.useCallback)(()=>{an.current&&clearTimeout(an.current),an.current=setTimeout(async()=>{let a=ak.current;if(a&&!ap.current){_.current=bn();try{let c=await (0,l.kS)(),d=(0,l.sQ)(b),e=document.documentElement.classList.contains("dark"),f=_.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,l.b8)(a)),h=u(a);ao.current=!0,a.innerHTML=w(g),ao.current=!1,h&&v(a,h)}catch{}}},300)},[b,bn]);(0,f.useEffect)(()=>{if(L)return()=>{an.current&&clearTimeout(an.current)}},[L]);let bp=(0,f.useCallback)(()=>{let a=ak.current;if(!a)return;aa.current||(aa.current=!0,ac(!0));let b=a.children.length;b!==ah.current&&(ah.current=b,ag(b))},[]),bq=(0,f.useCallback)(()=>{ao.current||ap.current||(bp(),bo())},[bp,bo]),br=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=ak.current;if(!b)return;let c=window.getSelection();if(!c?.rangeCount)return;let d=c.getRangeAt(0);d.deleteContents();let e=d.startContainer;for(;e&&e.parentElement!==b;)e=e.parentElement;if(!e||!(e instanceof HTMLElement))return;let f=u(b),g=Array.from(b.children).indexOf(e),h=e.textContent||"",i=f?.offset??h.length,j=h.substring(0,i),k=h.substring(i);e.innerHTML=(0,l.ZD)(j||" ");let m=document.createElement("div");m.setAttribute("style",x),m.innerHTML=(0,l.ZD)(k||" "),e.after(m),v(b,{line:g+1,offset:0}),bp(),bo()}},[bp,bo]),bs=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bt=(0,f.useCallback)(async(a=!1)=>{if(t){_.current=bn(),ae(!0);try{let c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:b,content:_.current,expectedMtime:a?void 0:am.current})}),d=await c.json();if(409===c.status&&d.conflict){try{let a=await fetch(`/api/files/read?cwd=${encodeURIComponent(t)}&path=${encodeURIComponent(b)}`),c=await a.json();aj({show:!0,diskContent:"text"===c.type?c.content:void 0})}catch{aj({show:!0})}return}if(!c.ok)throw Error("Failed to save file");d.mtime&&(am.current=d.mtime),aa.current=!1,ac(!1),aj({show:!1}),(0,r.oR)($("toast.savedSuccess"),"success"),O?.()}catch(a){console.error("Error saving file:",a),(0,r.oR)($("toast.saveFailed"),"error")}finally{ae(!1)}}},[t,b,bn,O]),bu=(0,f.useCallback)(async()=>{ab&&!ad&&await bt(!1)},[ab,ad,bt]),bv=(0,f.useCallback)(async()=>{aj({show:!1}),await bt(!0)},[bt]),bw=(0,f.useCallback)(()=>{if(void 0!==ai.diskContent){_.current=ai.diskContent;let b=ai.diskContent.split("\n").length;ah.current=b,ag(b);let c=ai.diskContent!==a;aa.current=c,ac(c);let d=ak.current;if(d){let a=ai.diskContent.split("\n");d.innerHTML=w(a.map(a=>(0,l.ZD)(a||" "))),bo()}}aj({show:!1}),O?.()},[ai.diskContent,a,O,bo]),bx=(0,f.useCallback)(()=>{let a=al.current;return a?Math.floor(a.scrollTop/20)+1:D?.current??1},[D]),by=(0,f.useCallback)(async()=>{(!ab||await (0,r.lJ)($("codeViewer.unsavedConfirm"),{danger:!0,confirmText:$("codeViewer.discardChanges"),cancelText:$("codeViewer.continueEditing")}))&&N?.(bx())},[ab,N,bx]);(0,f.useEffect)(()=>{if(!L)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bu())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[L,bu]);let bz=(0,f.useCallback)(()=>{let a=bn();R?.(a);let b=ak.current,c=b?u(b):null,d=bx();if(bf.enterNormal(),c){bf.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bf.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bf.setCursorLine(Math.max(0,d-1));N?.(d)},[bn,R,bx,N,bf]);(0,f.useEffect)(()=>{if(!L)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||Q&&c)&&(a.preventDefault(),a.stopPropagation(),Q?aa.current?(0,r.lJ)($("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:$("codeViewer.discardChanges"),cancelText:$("codeViewer.continueEditing")}).then(a=>{a&&bz()}):bz():by())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[L,Q,by,bz]),(0,f.useImperativeHandle)(Z,()=>({save:bu,close:by,get isDirty(){return ab},get isSaving(){return ad}}),[bu,by,ab,ad]);let bA=!!(I&&I.length>0),bB=(0,f.useMemo)(()=>{if(!I)return new Map;let a=[...new Set(I.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,o.j[c%o.j.length])}),b},[I]),[bC,bD]=(0,f.useState)(null),[bE,bF]=(0,f.useState)(null);(0,f.useEffect)(()=>{bD(null),bF(null)},[I]);let bG=(0,f.useCallback)((a,b)=>{bD(a.author);let c=b.currentTarget.getBoundingClientRect();bF({line:a,x:c.right+8,y:c.top})},[]),bH=(0,f.useCallback)(()=>{bD(null),bF(null)},[]),bI=(0,f.useCallback)(a=>{if(!K)return;let b={hash:a.hashFull,shortHash:a.hash,author:a.author,authorEmail:a.authorEmail,date:new Date(1e3*a.time).toISOString(),subject:a.message.split("\n")[0]||"",body:a.message.split("\n").slice(1).join("\n").trim(),time:a.time};K(b),bF(null)},[K]),bJ=`${bl+2}ch`;return(0,e.jsxs)("div",{ref:ar,className:`h-full flex flex-col outline-none ${k}`,tabIndex:0,onClick:bh,onDoubleClick:bi,children:[L&&ai.show&&(0,e.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,e.jsx)("span",{className:"text-sm text-foreground flex-1",children:$("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bw,className:"px-3 py-1 text-sm rounded border border-border hover:bg-accent transition-colors",children:$("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:bv,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:$("codeViewer.forceOverwrite")})]})]}),!L&&d&&aB&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("input",{ref:as,type:"text",value:aC,onChange:a=>aU(a.target.value),onKeyDown:a0,placeholder:$("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsx)("button",{onClick:()=>aV(!aD),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aD?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:$("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aW(!aE),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aE?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:$("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aO.length>0?`${aF+1}/${aO.length}`:$("common.noMatch")}),(0,e.jsx)("button",{onClick:a_,disabled:0===aO.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:$("common.previous"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:a$,disabled:0===aO.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:$("common.next"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:()=>{aT(!1),aU("")},className:"p-1 rounded hover:bg-accent",title:$("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),L?(0,e.jsx)("div",{ref:al,className:"flex-1 overflow-auto bg-secondary",children:(0,e.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,e.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-secondary",style:{width:bJ},children:Array.from({length:af},(a,b)=>(0,e.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:b+1},b))}),(0,e.jsx)("div",{ref:ak,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bq,onKeyDown:br,onPaste:bs,onCompositionStart:()=>{ap.current=!0},onCompositionEnd:()=>{ap.current=!1,bq()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,e.jsx)("div",{ref:aq,className:`flex-1 overflow-auto font-mono text-sm bg-secondary${az?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aQ.getTotalSize()}px`,minWidth:"100%",width:bA?`calc(${bl+bm+10}ch + 13rem)`:`${bl+bm+10}ch`,position:"relative"},children:aQ.getVirtualItems().map(a=>{let b=aP[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=ax[d]||(0,l.ZD)(aN[d]||""),h=a7(d,g,C),i=aS.has(f),j=aR.get(f),k=j?.[0],m=!!(aH&&f>=aH.range.start&&f<=aH.range.end),n=ba>=0?a9.current:null,p=!L&&J&&n===f?J[d]??null:null,q=bA?I[d]:void 0,r=bA&&d>0?I[d-1]:void 0,s=!!q&&(!r||r.hash!==q.hash),t=q?bB.get(q.author):void 0;return(0,e.jsx)(o.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:m,showLineNumbers:c,lineNumChars:bl,commentsEnabled:aK,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a1,onCmdClick:bk,onTokenHover:bj,onTokenHoverLeave:G,flashLine:aA,blameLine:q,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(q&&bC===q.author),onBlameClick:bI,onBlameMouseEnter:bG,onBlameMouseLeave:bH,inlineBlameData:p,onInlineBlameClick:bI,isCursorLine:Q&&!L&&bf.state.cursorLine===d,cursorCol:Q&&!L&&bf.state.cursorLine===d?bf.state.cursorCol:void 0},a.key)})})}),Q&&(0,e.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===bf.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bf.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bf.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:":"}),(0,e.jsx)("input",{ref:bc,value:bf.state.commandInput,onChange:a=>bf.setCommandInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bf.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bf.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:"/"}),(0,e.jsx)("input",{ref:bd,value:bf.state.searchInput,onChange:a=>bf.setSearchInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bf.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bf.state.keyBuffer&&"normal"===bf.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bf.state.keyBuffer}),bf.state.isDirty&&("normal"===bf.state.mode||"command"===bf.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bf.state.cursorLine+1,":",bf.state.cursorCol+1]})]}),ay&&bb&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!L&&(0,e.jsx)(m.f,{floatingToolbarRef:at,bumpRef:av,container:bb,onAddComment:a2,onSendToAI:a3,onSearch:Y?a4:void 0,isChatLoading:aJ?.isLoading}),!L&&aH&&(0,e.jsx)(j.t,{x:aH.x,y:aH.y,range:aH.range,codeContent:aH.codeContent,container:bb,onSubmit:a5,onClose:()=>aY(null)}),!L&&aI&&(0,e.jsx)(j.G,{x:aI.x,y:aI.y,range:aI.range,filePath:b,codeContent:aI.codeContent,container:bb,onSubmit:a6,onClose:()=>aZ(null),isChatLoading:aJ?.isLoading}),!L&&aG&&(0,e.jsx)(n.t,{x:aG.x,y:aG.y,comment:aG.comment,container:bb,onClose:()=>aX(null),onUpdateComment:aL,onDeleteComment:aM}),bE&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lg p-3 max-w-lg",style:{left:Math.min(bE.x,window.innerWidth-450),top:Math.max(8,Math.min(bE.y,window.innerHeight-200))},children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:bB.get(bE.line.author)?.border||"#666"},children:bE.line.hash}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:bE.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bE.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bE.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,q.fw)(bE.line.time)," \xb7 ",new Date(1e3*bE.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:$("codeViewer.clickToViewDetails")})]})]})]}),bb)]})});d()}catch(a){d(a)}})},80600:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},81190:(a,b,c)=>{"use strict";c.d(b,{B:()=>p});var d=c(48249),e=c(67484),f=c(92154),g=c(44384),h=c(13928),i=c(15622);let j="review-last-viewed";function k(){try{return JSON.parse(localStorage.getItem(j)||"{}")}catch{return{}}}function l(a,b){if(!a.lastCommentAt)return!1;let c=b[a.id];return!c||a.lastCommentAt>c}function m({cwd:a}){let{t:b}=(0,g.Bd)(),[c,f]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)({}),[u,v]=(0,e.useState)({open:!1,comments:[],title:"",userNameMap:{}}),w=(0,e.useRef)(null),x=(0,e.useRef)(null),[y,z]=(0,e.useState)(null),A=(0,e.useCallback)(async()=>{p(!0);try{let a=await fetch("/api/review");if(a.ok){let b=await a.json();n(b.reviews||[])}}catch{}p(!1)},[]),B=(0,e.useCallback)(a=>{let{data:b}=a;b?.some(a=>"review"===a.type)&&A()},[A]);(0,h.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"/")}`,onMessage:B,enabled:!!a});let C=(0,e.useMemo)(()=>m.filter(a=>a.active),[m]),D=(0,e.useMemo)(()=>C.some(a=>l(a,s)),[C,s]),E=(0,e.useCallback)(a=>{let b;(b=k())[a]=Date.now(),localStorage.setItem(j,JSON.stringify(b)),t(k()),window.open(`${window.location.origin}/review/${a}`,"_blank")},[]),F=(0,e.useCallback)(async(a,b)=>{a.stopPropagation();try{let[a,c]=await Promise.all([fetch(`/api/review/${b}`),fetch("/api/review/users")]);if(!a.ok)return;let{review:d}=await a.json(),e={};if(c.ok){let{users:a}=await c.json();for(let[b,c]of Object.entries(a))e[b]=c.name}v({open:!0,comments:d.comments||[],title:d.title,userNameMap:e})}catch{}},[]),G=(0,e.useCallback)((a,b)=>{x.current=b,a.dataTransfer.effectAllowed="move";let c=a.currentTarget;requestAnimationFrame(()=>c.classList.add("opacity-30"))},[]),H=(0,e.useCallback)(a=>{x.current=null,z(null),a.currentTarget instanceof HTMLElement&&a.currentTarget.classList.remove("opacity-30")},[]),I=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",x.current&&x.current!==b&&z(b)},[]),J=(0,e.useCallback)((a,b)=>{a.preventDefault(),z(null);let c=x.current;x.current=null,c&&c!==b&&n(a=>{let d=[...a],e=d.findIndex(a=>a.id===c),f=d.findIndex(a=>a.id===b);if(-1===e||-1===f)return a;let[g]=d.splice(e,1);return d.splice(f,0,g),fetch("/api/review/order",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:d.map(a=>a.id)})}).catch(()=>{}),d})},[]);return(0,d.jsxs)("div",{ref:w,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>f(a=>!a),className:`relative p-2 rounded-lg transition-colors ${c?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:b("review.reviewManagement"),children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),D&&(0,d.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),c&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:b("review.allReviews")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:C.length})]}),(0,d.jsx)("button",{onClick:A,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:b("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(0,d.jsx)("div",{className:"max-h-80 overflow-y-auto",children:o&&0===m.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("common.loading")}):0===C.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("review.noOpenReviews")}):C.map(a=>{let c,e,f,g,h,i=l(a,s);return(0,d.jsxs)("div",{draggable:!0,onDragStart:b=>G(b,a.id),onDragEnd:H,onDragOver:b=>I(b,a.id),onDrop:b=>J(b,a.id),onMouseEnter:b=>{let c=b.currentTarget.getBoundingClientRect();r({id:a.id,text:a.title,top:c.top+c.height/2,left:c.left})},onMouseLeave:()=>r(b=>b?.id===a.id?null:b),onClick:()=>E(a.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${y===a.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-accent/30`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:a.title}),a.commentCount>0&&(0,d.jsx)("button",{onClick:b=>F(b,a.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:b("review.viewComments"),children:(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,d.jsx)("span",{children:(e=String((c=new Date(a.updatedAt||a.createdAt)).getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),g=String(c.getHours()).padStart(2,"0"),h=String(c.getMinutes()).padStart(2,"0"),`${e}-${f} ${g}:${h}`)}),a.commentCount>0&&(0,d.jsx)("span",{children:b("review.nComments",{count:a.commentCount})})]})]},a.id)})})]}),q&&c&&(0,d.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-md whitespace-nowrap pointer-events-none",style:{top:q.top,left:q.left-8,transform:"translate(-100%, -50%)"},children:q.text}),(0,d.jsx)(i._,{isOpen:u.open,onClose:()=>v(a=>({...a,open:!1})),comments:u.comments,reviewTitle:u.title,userNameMap:u.userNameMap})]})}var n=c(81749);function o({cwd:a,currentBranch:b,onSwitched:c}){let{t:f}=(0,g.Bd)(),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null),t=(0,e.useRef)(null),u=(0,e.useCallback)(async()=>{m(!0);try{let b=await fetch(`/api/git/branches?cwd=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json(),c=[...a.local||[],...(a.remote||[]).filter(b=>!a.local.includes(b.replace(/^origin\//,"")))];k(c)}}catch{(0,n.oR)(f("toast.loadBranchFailed"),"error")}finally{m(!1)}},[a]),v=(0,e.useCallback)(()=>{i(!0),r(""),u()},[u]),w=(0,e.useCallback)(()=>{i(!1)},[]),x=async b=>{p(!0);try{let d=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"checkout",cwd:a,path:a,branch:b})});if(d.ok){let a=b.replace(/^origin\//,"");(0,n.oR)(f("toast.switchedToBranch",{branch:a}),"success"),w(),c()}else{let a=await d.json();(0,n.oR)(a.error||f("toast.switchBranchFailed"),"error")}}catch{(0,n.oR)(f("toast.switchBranchFailed"),"error")}finally{p(!1)}},y=j.filter(a=>a!==b&&a.toLowerCase().includes(q.toLowerCase()));return(0,d.jsxs)("div",{className:"relative",ref:s,children:[(0,d.jsx)("button",{onClick:h?w:v,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:f("git.switchBranch"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),h&&(0,d.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:t,type:"text",value:q,onChange:a=>r(a.target.value),placeholder:f("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:a=>{"Escape"===a.key&&w()}})}),(0,d.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:l?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:f("common.loading")}):0===y.length?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q?f("git.noMatchingBranches"):f("git.noBranches")}):y.map(a=>(0,d.jsx)("button",{onClick:()=>x(a),disabled:o,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,d.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function p({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:e,onOpenWorktree:h,onOpenProjectSessions:i,onOpenAliasManager:j,onBranchSwitched:k}){let{t:l}=(0,g.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:l("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,n.oR)(l("toast.copiedPageUrl"),"success")})}}),a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,n.oR)(l("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:l("tabManagerTopBar.copyDirPath"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}):(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsxs)("button",{onClick:h,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:"Git Worktrees",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,d.jsx)("span",{className:"text-sm",children:e||"main"})]}),(0,d.jsx)(o,{cwd:a,currentBranch:e,onSwitched:()=>k?.()})]})]}),(0,d.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,d.jsx)(f.gT,{})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(m,{cwd:a}),(0,d.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.refreshProject"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInVSCode"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-cursor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInCursor"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),b?.sessionId&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b.sessionId}`;navigator.clipboard.writeText(a).then(()=>{(0,n.oR)(l("toast.copiedCommand",{command:a}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("chat.copyCommandTooltip",{sessionId:b.sessionId}),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.aliasesGlobal"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,d.jsx)("button",{onClick:()=>window.parent.postMessage({type:"OPEN_TOKEN_STATS"},"*"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.tokenStats"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,d.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openSurething"),children:(0,d.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}},83634:(a,b,c)=>{"use strict";c.d(b,{V:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(31172);function h({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:a=>a.stopPropagation()}),(0,d.jsx)("button",{onClick:b,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});return(0,d.jsx)(g.Z,{children:e})}function i({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[i,j]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-secondary border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>j(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),i&&(0,d.jsx)(h,{image:i,onClose:()=>j(null)})]})}var j=c(81749),k=c(31037);let l=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,onShowGitStatus:g,onShowComments:h,onShowUserMessages:l,onOpenNote:m,onCreateScheduledTask:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)([]),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(0),[z,A]=(0,e.useState)(!1),B=(0,e.useRef)(null),C=(0,e.useRef)(null),D=(0,e.useCallback)(()=>{let a=B.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{D()},[p,D]),(0,e.useEffect)(()=>{(async()=>{try{let a=c?`/api/commands?cwd=${encodeURIComponent(c)}`:"/api/commands",b=await fetch(a);if(b.ok){let a=await b.json();u(a)}}catch(a){console.error("Failed to load commands:",a)}})()},[c]);let E=(0,e.useMemo)(()=>{if(!p.startsWith("/"))return[];let a=p.toLowerCase();return t.filter(b=>b.name.toLowerCase().startsWith(a))},[p,t]),F=!z&&p.startsWith("/")&&E.length>0,G=(0,e.useRef)(p);(0,e.useLayoutEffect)(()=>{G.current!==p&&(queueMicrotask(()=>y(0)),z&&queueMicrotask(()=>A(!1)),G.current=p)},[p,z]),(0,e.useLayoutEffect)(()=>{if(F&&C.current){let a=C.current.children[x];a&&a.scrollIntoView({block:"nearest"})}},[x,F]);let H=(0,e.useCallback)(()=>{let c=p.trim();(c||r.length>0)&&!b&&(a(c,r.length>0?r:void 0),q(""),s([]),B.current&&(B.current.style.height="auto"))},[p,r,b,a]),I=(0,e.useCallback)(a=>{q(a.name+" "),B.current?.focus()},[]),J=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(F&&E.length>0){if("ArrowDown"===a.key){a.preventDefault(),y(a=>(a+1)%E.length);return}if("ArrowUp"===a.key){a.preventDefault(),y(a=>(a-1+E.length)%E.length);return}if("Enter"===a.key){a.preventDefault(),I(E[x]);return}if("Escape"===a.key){a.preventDefault(),A(!0);return}if("Tab"===a.key){a.preventDefault(),I(E[x]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),H())}},[F,E,x,I,H]),K=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(o("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};s(a=>[...a,e])},e.readAsDataURL(c)}}},[o]),L=(0,e.useCallback)(a=>{s(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(i,{images:r,onRemove:L,disabled:b}),F&&E.length>0&&(0,d.jsx)("div",{ref:C,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:E.map((a,b)=>(0,d.jsxs)("div",{onClick:()=>I(a),className:`flex items-center gap-3 px-4 py-2 cursor-pointer ${b===x?"bg-brand/10":"hover:bg-accent"}`,children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:a.name}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return o("common.builtin");case"global":return o("common.global");case"project":return o("common.project")}})(a.source)})]},a.name))}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,d.jsx)("button",{onClick:async()=>{try{(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:c,files:["."]})})).ok?((0,j.oR)(o("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(0,j.oR)(o("toast.stageFailed"),"error")}catch(a){console.error("Error staging files:",a),(0,j.oR)(o("toast.stageFailed"),"error")}},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:o("chat.stageAll"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),g&&(0,d.jsx)("button",{onClick:g,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:o("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),h&&(0,d.jsx)("button",{onClick:h,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:o("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.userMessages"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),m&&(0,d.jsx)("button",{onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),n&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>w(!v),className:`p-2 rounded-lg transition-all ${v?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:o("chat.scheduledTasks"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),v&&(0,d.jsx)(k.E,{onClose:()=>w(!1),onCreate:n})]}),(0,d.jsx)("textarea",{ref:B,value:p,onChange:a=>q(a.target.value),onKeyDown:J,onPaste:K,placeholder:b?o("chat.placeholderDisabled"):o("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})})},84705:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>x});var e=c(48249),f=c(67484),g=c(31172),h=c(49681),i=c(21735),j=c(33740),k=c(55313),l=c(32616),m=c(86791),n=c(69648),o=c(31893),p=c(10164),q=c(26068),r=c(44741),s=c(81749),t=c(44384),u=a([m,n]);function v({image:a,onClose:b}){let{t:c}=(0,t.Bd)(),d=(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-4 right-4 w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",children:(0,e.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:c("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,e.jsx)(g.Z,{children:d})}function w({filePath:a,content:b,cwd:c,onClose:d}){let[h,i]=(0,f.useState)(null);return(0,e.jsx)(g.Z,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsx)("div",{ref:i,className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col relative",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.SU,{container:h,children:(0,e.jsx)(p.M,{content:b,filePath:a,cwd:c,onClose:d})})})})})}[m,n]=u.then?(await u)():u;let x=(0,f.memo)(function({message:a,cwd:b,sessionId:c,onFork:d}){let g,p,q,u,{t:x}=(0,t.Bd)(),[y,z]=(0,f.useState)(null),[A,B]=(0,f.useState)(!1),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(!1),G="user"===a.role,H=a.images&&a.images.length>0,I=a.toolCalls?.length||0,J=I>1,K=!!c&&!!b&&!!d,L=(0,f.useMemo)(()=>a.toolCalls?.some(a=>"Edit"===a.name||"Write"===a.name)||!1,[a.toolCalls]),M=(0,f.useMemo)(()=>{if(!a.toolCalls)return null;for(let b=a.toolCalls.length-1;b>=0;b--)if("TodoWrite"===a.toolCalls[b].name)return a.toolCalls[b];return null},[a.toolCalls]),N=(0,f.useMemo)(()=>a.toolCalls?a.toolCalls.filter(a=>"AskUserQuestion"===a.name):[],[a.toolCalls]),O=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=new Set,c=[];for(let d of a.toolCalls)if("Read"===d.name||"Edit"===d.name||"Write"===d.name){let a=d.input.file_path;a&&a.toLowerCase().endsWith(".md")&&!b.has(a)&&(b.add(a),c.push(a))}return c},[a.toolCalls]),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!P)return void queueMicrotask(()=>S(null));let a=!1;return fetch(`/api/file?path=${encodeURIComponent(P)}`).then(a=>a.ok?a.json():Promise.reject()).then(b=>{a||S(b.content)}).catch(()=>{a||((0,s.oR)(x("toast.readFileFailed"),"error"),Q(null))}),()=>{a=!0}},[P]);let T=()=>{a.content&&(navigator.clipboard.writeText(a.content),(0,s.oR)(x("toast.copiedMessage")))},U=()=>{K&&d(a.id)},V=(a=>{if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`})(a.timestamp);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex flex-col ${G?"items-end":"items-start"} mb-4 group`,"data-role":a.role,children:[V&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:V}),(0,e.jsxs)("div",{className:`flex ${G?"justify-end":"justify-start"} w-full`,children:[G&&(0,e.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),K&&(0,e.jsx)("button",{onClick:U,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]}),(0,e.jsxs)("div",{className:`max-w-[80%] ${G?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[H&&(0,e.jsx)("div",{className:`flex flex-wrap gap-2 ${a.content?"mb-2":""}`,children:a.images.map((a,b)=>(0,e.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>z(a),children:(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:x("chat.imageN",{index:b+1}),className:"w-full h-full object-cover"})},b))}),a.content&&(0,e.jsxs)("div",{className:"break-words",children:[(0,e.jsx)(r.T,{content:a.content,isUser:G,isStreaming:a.isStreaming}),a.isStreaming&&(0,e.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),M&&(g=M.input?.todos,q=(p=Array.isArray(g)?g:[]).filter(a=>"completed"===a.status).length,u=p.length,(0,e.jsx)("div",{className:`${a.content||H?"mt-2":""}`,children:(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${u>0?q/u*100:0}%`}})}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[q,"/",u]})]}),p.map((a,b)=>(0,e.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===a.status?"opacity-50":""}`,children:["completed"===a.status?(0,e.jsx)(h.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===a.status?(0,e.jsx)(i.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,e.jsx)(j.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("span",{className:`text-xs truncate ${"completed"===a.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},b))]})})),O.length>0&&(0,e.jsx)("div",{className:`${a.content||H||M?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:O.map(a=>(0,e.jsxs)("button",{onClick:()=>Q(a),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:a.split("/").pop()})]},a))})}),a.toolCalls&&a.toolCalls.length>0&&(0,e.jsx)("div",{className:`${a.content||H?"mt-2":""}`,children:J?(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsxs)("button",{onClick:()=>B(!A),className:"flex-1 px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,e.jsx)("span",{className:"text-lg",children:"\uD83D\uDD27"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:x("chat.toolCalls",{count:I})}),(0,e.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:A?x("chat.collapse"):x("chat.expand")})]}),N.length>0&&(0,e.jsx)("button",{onClick:()=>F(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:x("chat.viewQuestions"),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),L&&(0,e.jsx)("button",{onClick:()=>D(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:x("chat.viewAllFileChanges"),children:(0,e.jsx)(l.A,{className:"w-4 h-4"})})]}),A&&(0,e.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}):a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}),!G&&(0,e.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),K&&(0,e.jsx)("button",{onClick:U,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),y&&(0,e.jsx)(v,{image:y,onClose:()=>z(null)}),C&&a.toolCalls&&(0,e.jsx)(n.z,{toolCalls:a.toolCalls,cwd:b,onClose:()=>D(!1)}),E&&N.length>0&&(0,e.jsx)(o.$,{toolCalls:N,onClose:()=>F(!1)}),P&&null!==R&&(0,e.jsx)(w,{filePath:P,content:R,cwd:b||"",onClose:()=>Q(null)})]})});d()}catch(a){d(a)}})},86402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>x,xZ:()=>w});var e=c(48249),f=c(67484),g=c(74429),h=c(44384),i=c(36043),j=c(47033),k=c(23434),l=c(26068),m=c(77033),n=c(45214),o=c(45050),p=c(81749),q=c(90173),r=c(5811),s=c(89976),t=c(77937),u=c(68502),v=a([q,r]);[q,r]=v.then?(await v)():v;let y=(0,f.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i}){let[j,k]=(0,f.useState)(0),l=(0,f.useMemo)(()=>a.current,[j]);return(0,e.jsx)(t.w,{x:l?.x??0,y:l?.y??0,visible:!!l,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i})});function w({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:t=!1,cwd:v,enableComments:w=!1,onPreview:x,previewLabel:z,onContentSearch:A}){let{t:B}=(0,h.Bd)(),C=z??B("common.preview"),D=(0,f.useMemo)(()=>(0,o.X)(a,b),[a,b]),E=(0,f.useRef)(null),F=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useRef)(!1);let[H,I]=(0,f.useState)(!1),J=(0,l.iN)(),K=(0,m.nH)(),L=w&&!!v,{comments:M,addComment:N,updateComment:O,deleteComment:P,refresh:Q}=(0,j._)({cwd:v||"",filePath:c}),[R,S]=(0,f.useState)(null),T=(0,f.useRef)(null),U=(0,f.useRef)(()=>{}),[V,W]=(0,f.useState)(null),[X,Y]=(0,f.useState)(null),Z=(0,f.useMemo)(()=>{let a=new Set;for(let b of M)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[M]),$=(0,f.useMemo)(()=>{let a=new Map;for(let b of M){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[M]),_=(0,f.useCallback)((a,b)=>{b.stopPropagation(),S({comment:a,x:b.clientX,y:b.clientY}),T.current=null,U.current(),W(null),Y(null)},[]),aa=(0,f.useCallback)(()=>{let a=T.current;a&&(W({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),T.current=null,U.current())},[]),ab=(0,f.useCallback)(()=>{let a=T.current;a&&(Y({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),T.current=null,U.current())},[]),ac=(0,f.useCallback)(()=>{let a=T.current;if(!a||!A)return;let b=a.codeContent.trim();T.current=null,U.current(),b&&A(b)},[A]),ad=(0,f.useCallback)(async a=>{if(X&&K&&v)try{let b=await (0,k.$3)(v),d=[];for(let a of b)d.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});d.push({filePath:c,startLine:X.range.start,endLine:X.range.end,codeContent:X.codeContent});let e=(0,k.Gw)(d,a);K.sendMessage(e),await (0,k.RP)(v),Q(),Y(null)}catch(a){console.error("Failed to send to AI:",a)}},[X,K,c,v,Q]),ae=(0,f.useCallback)(async a=>{V&&(await N(V.range.start,V.range.end,a),W(null))},[V,N]),{leftLines:af,rightLines:ag}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<D.length;e++){let f=D[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[D]),ah=(0,f.useMemo)(()=>D.map(a=>a.content),[D]),ai=(0,q.C)(ah,c),aj=(0,i.Te)({count:af.length,getScrollElement:()=>E.current,estimateSize:()=>20,overscan:20}),ak=d?"w-1/4":t?"w-3/4":"w-1/2",al=d?"w-3/4":t?"w-1/4":"w-1/2",am=(0,f.useMemo)(()=>af.map((a,b)=>{let c=ag[b];return"removed"===a.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[af,ag]),an=aj.getTotalSize(),ao=aj.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${ak} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":t?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${al} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:t?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[x&&(0,e.jsx)("button",{onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors",children:C}),!t&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,p.oR)(B("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:B("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:E,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${an}px`},children:[(0,e.jsx)("div",{ref:F,className:`${ak} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ao.map(a=>{let b=af[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:b.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:b.originalIdx>=0&&ai[b.originalIdx]||(0,r.ZD)(b.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:G,className:`${al} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ao.map(a=>{let b=ag[a.index],c=b?.lineNum||0,d=c>0&&Z.has(c),f=$.get(c),g=f?.[0],h=V&&c>=V.range.start&&c<=V.range.end,i=X&&c>=X.range.start&&c<=X.range.end,j=h||i;return(0,e.jsxs)("div",{"data-new-line":c||void 0,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${j?"bg-blue-9/20":d?"bg-amber-9/10":b?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${j?"bg-blue-9/30":""}`,style:{width:L?"52px":"40px"},children:[L&&c>0&&d&&g&&(0,e.jsx)("button",{onClick:a=>_(g,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:B("codeViewer.nComments",{count:f?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),L&&c>0&&!d&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:c||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:b?.originalIdx>=0&&ai[b.originalIdx]||(0,r.ZD)(b?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(s.b,{lines:am,containerRef:E})]}),H&&J&&(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{floatingToolbarRef:T,bumpRef:U,container:J,onAddComment:aa,onSendToAI:ab,onSearch:A?ac:void 0,isChatLoading:K?.isLoading??!1}),V&&(0,e.jsx)(n.t,{x:V.x,y:V.y,range:V.range,codeContent:V.codeContent,container:J,onSubmit:ae,onClose:()=>W(null)}),X&&(0,e.jsx)(n.G,{x:X.x,y:X.y,range:X.range,container:J,onSubmit:ad,onClose:()=>Y(null)}),R&&(0,e.jsx)(u.t,{x:R.x,y:R.y,comment:R.comment,container:J,onClose:()=>S(null),onUpdateComment:O,onDeleteComment:P})]}),J)]})}function x({oldContent:a,newContent:b,filePath:c}){let d=(0,f.useMemo)(()=>(0,o.X)(a,b),[a,b]),g=(0,f.useRef)(null),h=(0,f.useMemo)(()=>d.map(a=>a.content),[d]),j=(0,q.C)(h,c),k=(0,i.Te)({count:d.length,getScrollElement:()=>g.current,estimateSize:()=>20,overscan:20});return(0,e.jsx)("div",{ref:g,className:"font-mono text-sm overflow-auto h-full",children:(0,e.jsx)("div",{style:{height:`${k.getTotalSize()}px`,position:"relative"},children:k.getVirtualItems().map(a=>{let b=d[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":"added"===b.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==b.type?b.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==b.type?b.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===b.type?"text-red-11":"added"===b.type?"text-green-11":"text-slate-9"}`,children:"removed"===b.type?"-":"added"===b.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:j[a.index]||(0,r.ZD)(b.content||" ")}})]},a.key)})})})}d()}catch(a){d(a)}})},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},86753:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(67484),e=c(95836),f=c(81749),g=c(41564);function h({cwd:a,addToRecentFiles:b}){let[c,h]=(0,d.useState)(null),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(null),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(new Set),[u,v]=(0,d.useState)([]),[w,x]=(0,d.useState)([]),[y,z]=(0,d.useState)(!1),[A,B]=(0,d.useState)(0),C=(0,d.useCallback)(async()=>{j(!0),l(null);try{let b=`/api/git/status?cwd=${encodeURIComponent(a)}`,c=await fetch(b);if(!c.ok){let a=await c.json();throw Error(a.error||"Failed to fetch git status")}let d=await c.json();h(d);let f=(0,e.Do)(d.staged),g=(0,e.Do)(d.unstaged);v(f),x(g);let i=new Set([...(0,e.Sz)(f),...(0,e.Sz)(g)]);t(i)}catch(a){l(a instanceof Error?a.message:"Unknown error")}finally{j(!1)}},[a]),D=(0,d.useCallback)(a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),E=(0,d.useCallback)((a,c)=>{n({file:a,type:c}),b(a.path)},[b]),F=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to stage file");await C(),(0,f.oR)(g.A.t("toast.staged"),"success")}catch(a){console.error("Error staging file:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,C]),G=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to unstage file");await C(),(0,f.oR)(g.A.t("toast.unstaged"),"success")}catch(a){console.error("Error unstaging file:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,C]),H=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to stage files");await C(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error staging files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,C]),I=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to unstage files");await C(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error unstaging files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,C]),J=(0,d.useCallback)(async b=>{if(0!==b.length)try{let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path);if(c.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c,isUntracked:!0})})).ok)throw Error("Failed to discard untracked files");if(d.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})})).ok)throw Error("Failed to discard tracked files");await C(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:b.length}),"success")}catch(a){console.error("Error discarding files:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,C]),K=(0,d.useCallback)(async()=>{if(c?.unstaged.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.unstaged.map(a=>a.path)})})).ok)throw Error("Failed to stage all files");await C(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error staging all files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,c,C]),L=(0,d.useCallback)(async()=>{if(c?.staged.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.staged.map(a=>a.path)})})).ok)throw Error("Failed to unstage all files");await C(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"success")}catch(a){console.error("Error unstaging all files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,c,C]),M=(0,d.useCallback)(async b=>{try{let c="untracked"===b.status;if(!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b.path],isUntracked:c})})).ok)throw Error("Failed to discard file");await C(),(0,f.oR)(c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"success")}catch(a){console.error("Error discarding file:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,C]),N=(0,d.useCallback)(async()=>{if(c?.unstaged.length&&await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))try{let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path);d.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})}),b.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b,isUntracked:!0})}),await C(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error discarding all:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,c,C]);return{status:c,setStatus:h,statusLoading:i,statusError:k,statusSelectedFile:m,statusDiff:o,statusDiffLoading:q,statusExpandedPaths:s,setStatusExpandedPaths:t,stagedTree:u,setStagedTree:v,unstagedTree:w,setUnstagedTree:x,showStatusDiffPreview:y,setShowStatusDiffPreview:z,fetchStatus:C,handleStatusToggle:D,handleStatusFileSelect:E,handleStage:F,handleUnstage:G,handleStageFiles:H,handleUnstageFiles:I,handleDiscardFiles:J,handleStageAll:K,handleUnstageAll:L,handleDiscardFile:M,handleDiscardAll:N,refreshDiff:(0,d.useCallback)(()=>B(a=>a+1),[])}}},86791:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(92951),i=c(81749),j=a([h]);h=(j.then?(await j)():j)[0];let l={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D"};function k({toolCall:a,cwd:b}){let c,{t:d}=(0,g.Bd)(),[j,k]=(0,f.useState)(!1),[m,n]=(0,f.useState)(null),o=l[a.name]||"\uD83D\uDD27",p=(c=a.input,"Bash"===a.name&&c.command&&"string"==typeof c.command?c.command:"Glob"===a.name&&c.pattern&&"string"==typeof c.pattern||"Grep"===a.name&&c.pattern&&"string"==typeof c.pattern?c.pattern:c.file_path&&"string"==typeof c.file_path?c.file_path:c.path&&"string"==typeof c.path?c.path:null),q="Glob"===a.name||"Grep"===a.name||"Bash"===a.name,r=p?q?p:(a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a})(p):null,s=b=>{let c="input"===b?d("toolCall.inputParams"):d("toolCall.resultLabel"),e="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);n({title:`${a.name}${r?` ${r}`:""} - ${c}`,content:e,toolName:a.name})};return(0,e.jsxs)("div",{className:"my-2 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("button",{onClick:()=>k(!j),className:"w-full px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,e.jsx)("span",{className:"text-base",children:o}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:p||"",children:r}),(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),p&&(navigator.clipboard.writeText(p),(0,i.oR)(d("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),p&&(navigator.clipboard.writeText(p),(0,i.oR)(d("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:d("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[j&&!a.isLoading&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),s("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),s("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.inputParamsTitle"),children:d("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),s("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),s("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.resultTitle"),children:d("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:j?"▲":"▼"})]})]}),j&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]})]}),m&&(0,e.jsx)(h.M,{title:m.title,content:m.content,toolName:m.toolName,onClose:()=>n(null)})]})}d()}catch(a){d(a)}})},89976:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[f,g]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let h=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*h}%`,height:`${Math.max(h,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${f.top}px`,height:`${Math.max(f.height,10)}px`}})]})}},90173:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{C:()=>h});var e=c(67484),f=c(5811),g=a([f]);function h(a,b){let[c,d]=(0,e.useState)([]),[f,g]=(0,e.useState)(!1);return(0,e.useRef)(""),a.join("\n"),c}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},91645:a=>{"use strict";a.exports=require("net")},92050:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>i});var e=c(48249),f=c(67484),g=c(24266),h=a([g]);function i({tabId:a,cwd:b,sessionId:c,isActive:d,onStateChange:h,onShowGitStatus:i,onOpenNote:j,onCreateScheduledTask:k,onOpenSession:l,onContentSearch:m}){let n=(0,f.useCallback)(b=>{h(a,{isLoading:b})},[a,h]),o=(0,f.useCallback)(b=>{h(a,{sessionId:b})},[a,h]),p=(0,f.useCallback)(b=>{h(a,{title:b})},[a,h]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,hideHeader:!0,hideSidebar:!0,isActive:d,onLoadingChange:n,onSessionIdChange:o,onTitleChange:p,onShowGitStatus:i,onOpenNote:j,onCreateScheduledTask:k,onOpenSession:l,onContentSearch:m})}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},92154:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[j,k]=(0,e.useState)(!1);f.indexOf(a),f.length;let[l,m]=(0,e.useState)(!1),n={activeView:a,onViewChange:b,dragOffset:(()=>{if(!l)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:l&&j};return(0,d.jsx)(h.Provider,{value:n,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),k=(0,e.useRef)(null),l=(0,e.useRef)(null),m=f.indexOf(g),n=f.length;return(0,d.jsx)("div",{ref:k,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:l,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/n*100,c=-(100/n*m)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},92951:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(86402),j=c(79029),k=c(44741),l=c(30068),m=c(90500),n=c(81749),o=c(36645),p=c(56929),q=a([i,j]);function r({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,p.e$)(a);if((0,p.u)(a),h)return(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})});if(d)return(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})});if((0,p.u)(a)){let b=`/api/file?path=${encodeURIComponent(a)}&raw=true`;return(0,e.jsx)("div",{className:"flex items-center justify-center h-full overflow-auto",children:(0,e.jsx)("img",{src:b,alt:a.split("/").pop()||"image",className:"max-w-full max-h-full object-contain"})})}return b?k?(0,e.jsx)(s,{content:b}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[i,j]=q.then?(await q)():q;let u=[m.W];function s({content:a}){let b=(0,f.useRef)(null);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:b}),(0,e.jsx)("div",{ref:b,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,rehypePlugins:u})})]})}function t({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,p.jU)(b),l=(0,p.zs)(b),m=(0,p.oK)(b),q=!!l,s=!!m,[t,u]=(0,f.useState)(("Read"===c||"Write"===c)&&s?"file":q?"diff-unified":k?"readable":"json"),v=(0,f.useRef)(null),w=(0,o.o)(v),x=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[q&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>u("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>u("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),s&&(0,e.jsx)("button",{onClick:()=>u("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>u("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>u("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===t&&m?(0,e.jsx)(r,{filePath:m}):"diff-unified"===t&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===t&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===t&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o._,{search:w}),(0,e.jsx)("pre",{ref:v,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,p.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,p.C6)(b):b})})]})});return(0,e.jsx)(h.Z,{children:x})}d()}catch(a){d(a)}})},93053:(a,b,c)=>{"use strict";c.d(b,{i:()=>f});var d=c(67484),e=c(6440);function f({initialCwd:a,initialSessionId:b,activeView:c}){(0,d.useRef)(!1),(0,d.useRef)(!0);let f=(0,d.useRef)(c),g=(0,e.F)(),h=(0,d.useRef)(g),[i,j]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),[k,l]=(0,d.useState)(i[0].id),[m,n]=(0,d.useState)(new Set),o=(0,d.useRef)(i),p=(0,d.useCallback)((b,c)=>{a&&b&&fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})}).catch(()=>{})},[a]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),u=(0,d.useCallback)((a,b,c)=>{let d={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat")};j(a=>{let b=a.findIndex(a=>a.id===k);if(-1===b)return[...a,d];let c=[...a];return c.splice(b+1,0,d),c}),l(d.id)},[k]),v=(0,d.useCallback)(b=>{j(c=>{let d=c.filter(a=>a.id!==b);if(b===k&&d.length>0&&l(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return l(b.id),[b]}return d})},[k,a]),w=(0,d.useCallback)((b,c)=>{let d=i.find(a=>a.sessionId===b);d?l(d.id):u(a,b,c)},[i,a,u]),x=(0,d.useCallback)(()=>{u(a)},[a,u]),y=(0,d.useCallback)((b,c)=>{u(a,b,c)},[a,u]),z=(0,d.useCallback)((a,b)=>{j(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!f.current||"agent"===f.current;if(a===k&&c&&h.current){let a=d.sessionId||b.sessionId;a&&p(a,"normal")}else n(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[k,p]),A=(0,d.useCallback)(a=>{l(a),n(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=o.current.find(b=>b.id===a);return d?.sessionId&&p(d.sessionId,"normal"),c})},[p]),B=(0,d.useCallback)(a=>{r(a)},[]),C=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==q&&q!==b&&t(b)},[q]),D=(0,d.useCallback)(a=>{null!==q&&q!==a&&j(b=>{let c=[...b],[d]=c.splice(q,1);return c.splice(a,0,d),c}),r(null),t(null)},[q]),E=(0,d.useCallback)(()=>{r(null),t(null)},[]),F=i.find(a=>a.id===k);return{tabs:i,activeTabId:k,activeTab:F,unreadTabs:m,dragTabIndex:q,dragOverTabIndex:s,addTab:u,closeTab:v,switchTab:A,handleSelectSession:w,handleNewTab:x,handleOpenSession:y,updateTabState:z,handleTabDragStart:B,handleTabDragOver:C,handleTabDrop:D,handleTabDragEnd:E}}},94882:(a,b,c)=>{"use strict";function d(a,b){for(let c of a){if(c.path===b)return c;if(c.children){let a=d(c.children,b);if(a)return a}}return null}function e(a,b){if(!a)return"";let c=d(b,a);if(c?.isDirectory)return a;let e=a.split("/");return e.pop(),e.join("/")}function f(a){let b=[];for(let c of a){let a=c.split("/"),d=b;for(let b=0;b<a.length;b++){let c=a[b],e=b===a.length-1,f=a.slice(0,b+1).join("/"),g=d.find(a=>a.name===c);g||(g={name:c,path:f,isDirectory:!e,children:e?void 0:[]},d.push(g)),!e&&g.children&&(d=g.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>{a.children&&c(a.children)})};return c(b),b}function g(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),d.children&&c(d.children))};return c(a),b}c.d(b,{B_:()=>o,KH:()=>k,MB:()=>d,S7:()=>e,fw:()=>l,q3:()=>j,r6:()=>m,tE:()=>n,tW:()=>g,u:()=>i,v3:()=>f});let h=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function i(a){let b=a.split(".").pop()?.toLowerCase();return h.has(b||"")}function j(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase(),f=a=>{if(d.add(a.path),a.children)for(let b of a.children)f(b)},g=(a,b)=>{let h=a.name.toLowerCase(),i=c?h===e:h.includes(e);if(i&&a.children)return f(a),b.forEach(a=>d.add(a)),!0;let j=!1;if(a.children)for(let c of a.children)g(c,[...b,a.path])&&(j=!0);return(!!i||!!j)&&(d.add(a.path),b.forEach(a=>d.add(a)),!0)};for(let b of a)g(b,[]);return d}function k(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase();for(let b of a){let a=b.split("/");for(let b=0;b<a.length;b++){let f=a[b].toLowerCase();if(c?f===e:f.includes(e)){for(let b=0;b<=a.length-1;b++)d.add(a.slice(0,b+1).join("/"));break}}}return d}function l(a){let b=Math.floor(Math.floor((Date.now()-1e3*a)/1e3)/60),c=Math.floor(b/60),d=Math.floor(c/24),e=Math.floor(d/30),f=Math.floor(d/365);return f>0?`${f}y ago`:e>0?`${e}mo ago`:d>0?`${d}d ago`:c>0?`${c}h ago`:b>0?`${b}m ago`:"just now"}function m(a){let b=new Date(a),c=new Date,d=b.getFullYear()===c.getFullYear(),e=String(b.getMonth()+1).padStart(2,"0"),f=String(b.getDate()).padStart(2,"0"),g=String(b.getHours()).padStart(2,"0"),h=String(b.getMinutes()).padStart(2,"0");return d?`${e}-${f} ${g}:${h}`:`${b.getFullYear()}-${e}-${f} ${g}:${h}`}let n=()=>{},o=50},94924:(a,b,c)=>{"use strict";c.d(b,{Y:()=>k});var d=c(48249),e=c(67484),f=c(44384);let g=(0,c(47408).A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var h=c(46674),i=c(59347),j=c(24520);function k({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[k,l]=(0,e.useState)({}),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(!0),s=()=>{m.trim()&&o.trim()&&(l(a=>({...a,[m.trim()]:o.trim()})),n(""),p(""))},t=async()=>{try{(await fetch("/api/terminal/aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aliases:k})})).ok&&(b(k),a())}catch(a){console.error("Failed to save aliases:",a)}};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:q?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(k).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void l(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{l(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:m,onChange:a=>n(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}})]}),(0,d.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),s())}})]}),(0,d.jsx)("button",{onClick:s,disabled:!m.trim()||!o.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(k).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},95133:(a,b,c)=>{"use strict";c.d(b,{S:()=>l,j:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(41564),h=c(74429);function i({blame:a,onClick:b}){let{t:c}=(0,f.Bd)(),i=(0,e.useRef)(null),j=(0,e.useRef)(null),k=(0,e.useRef)(!1),l=(0,e.useRef)(!1),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=(0,e.useRef)(null),p=(0,e.useRef)(a),q=(0,e.useRef)(b),r=(0,e.useCallback)(()=>{let a,b=j.current,c=i.current;if(!b||!c)return;let d=c.getBoundingClientRect(),e=b.getBoundingClientRect(),f=window.innerWidth,g=window.innerHeight,h=d.left;h+e.width>f-8&&(h=f-e.width-8),h<8&&(h=8),(a=d.top-e.height-4<0?d.bottom+4:d.top-e.height-4)+e.height>g-8&&(a=g-e.height-8),b.style.left=`${h}px`,b.style.top=`${a}px`},[]),s=(0,e.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),n.current&&(clearTimeout(n.current),n.current=null),k.current=!1,l.current=!1,j.current&&(j.current.style.display="none"),o.current&&(document.removeEventListener("mousedown",o.current.down),document.removeEventListener("mouseup",o.current.up),o.current=null)},[]),t=(0,e.useCallback)(()=>{let a=j.current;if(!a||k.current)return;k.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(r));let b=0,c=0,d=a=>{b=a.clientX,c=a.clientY},e=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,j.current?.contains(b)||i.current?.contains(b)||s()}};document.addEventListener("mousedown",d),document.addEventListener("mouseup",e),o.current={down:d,up:e}},[r,s]),u=(0,e.useCallback)(()=>{if(m.current&&clearTimeout(m.current),n.current&&(clearTimeout(n.current),n.current=null),k.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(m.current=setTimeout(t,500))},[t]),v=(0,e.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),k.current&&(n.current=setTimeout(()=>{l.current||s()},200))},[s]),w=(0,e.useCallback)(()=>{l.current=!0,n.current&&(clearTimeout(n.current),n.current=null)},[]),x=(0,e.useCallback)(()=>{l.current=!1,s()},[s]),y=(0,e.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&j.current?.contains(b.anchorNode)||(q.current?.(p.current),s())},[s]),z=a.message.split("\n")[0]||"",A=a.message.split("\n").slice(1).join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{ref:i,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:u,onMouseLeave:v,children:[a.author.split(" ")[0],", ",function(a){let b=g.A.t,c=Math.floor((Date.now()-1e3*a)/1e3);if(c<60)return b("common.justNow");let d=Math.floor(c/60);if(d<60)return b("common.minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return b("common.hoursAgo",{count:e});let f=Math.floor(e/24);if(f<30)return b("common.daysAgo",{count:f});let h=Math.floor(f/30);return h<12?b("common.monthsAgo",{count:h}):b("common.yearsAgo",{count:Math.floor(h/12)})}(a.time)," \xb7 ",z]}),(0,h.createPortal)((0,d.jsxs)("div",{ref:j,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:w,onMouseLeave:x,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,d.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,d.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,d.jsx)("div",{className:"font-medium",children:z}),A&&(0,d.jsx)("div",{className:"mt-1 text-muted-foreground",children:A}),(0,d.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:y,children:c("codeViewer.clickToViewDetails")})]}),document.body)]})}let j=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function k(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}let l=(0,e.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:g,firstComment:h,lineCommentsCount:j,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,f.Bd)(),I=(0,e.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,e.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=k(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,e.useCallback)(a=>{if(!t||0!==a.buttons)return;let c=window.getSelection();if(c&&!c.isCollapsed)return;let d=a.target;if("SPAN"!==d.tagName||!d.style.color)return;let e=a.currentTarget,f=k(a,e),g=d.getBoundingClientRect();t(b,f,{x:g.left,y:g.bottom+4})},[b,t]),L=(0,e.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,e.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,d.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":g?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,d.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:z&&y?y.bg:void 0},children:[w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,d.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,d.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,d.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[o&&g&&h&&(0,d.jsx)("button",{onClick:a=>r(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:H("codeViewer.nComments",{count:j}),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),o&&!g&&(0,d.jsx)("span",{className:"w-4"}),(0,d.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,d.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,d.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,d.jsx)(i,{blame:D,onClick:E})]})]},a)})},95836:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(26068),i=c(4219);function j({status:a}){let{label:b,className:c}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-slate-9 text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:l,emptyMessage:m,className:n}){let{t:o}=(0,g.Bd)(),p=m??o("gitFileTree.noFiles"),{contextMenu:q,showContextMenu:r,hideContextMenu:s}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:p}):(0,d.jsxs)("div",{className:n||"py-1 overflow-y-auto h-full min-w-max",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:r,showChanges:j,renderActions:l},a.path)),q&&(0,d.jsx)(h.ft,{x:q.x,y:q.y,path:q.path,cwd:i,isDirectory:q.isDirectory,onClose:s})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},96666:(a,b,c)=>{"use strict";c.d(b,{p:()=>f});var d=c(67484),e=c(41564);function f({cwd:a,onSearchComplete:b}){let[c,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(new Set),[o,p]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[q,r]=(0,d.useState)(null),s=(0,d.useRef)(null),t=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){h([]),r(null);return}if(d.length<2)return void l(e.A.t("fileBrowser.searchMinChars"));j(!0),l(null);try{let d=new URLSearchParams({cwd:a,q:c,caseSensitive:String(o.caseSensitive),wholeWord:String(o.wholeWord),regex:String(o.regex),fileType:o.fileType}),e=await fetch(`/api/files/search?${d}`),f=await e.json();if(f.error)throw Error(f.error);h(f.results),r({totalFiles:f.totalFiles,totalMatches:f.totalMatches,truncated:f.truncated});let g=new Set(f.results.map(a=>a.path));n(g),f.results.length>0&&b?.()}catch(a){l(a instanceof Error?a.message:"Search failed"),h([])}finally{j(!1)}},[a,o,b]);return{contentSearchQuery:c,setContentSearchQuery:f,contentSearchResults:g,isSearching:i,searchError:k,searchExpandedPaths:m,searchOptions:o,setSearchOptions:p,searchStats:q,contentSearchInputRef:s,performContentSearch:t,handleSearchToggle:(0,d.useCallback)(a=>{n(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},99117:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(0),k=(0,d.useRef)(null),l=(0,d.useRef)([]),m=(0,d.useCallback)(()=>{let b=a.current;b&&(b.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(a=>{let b=a.parentNode;b&&(b.replaceChild(document.createTextNode(a.textContent||""),a),b.normalize())}),l.current=[])},[a]);(0,d.useCallback)(b=>{if(m(),!b||!a.current){h([]),j(0);return}let c=[],d=[],e=b.toLowerCase();a.current.querySelectorAll("[data-message-id]").forEach(a=>{let f,g=a.getAttribute("data-message-id")||"",h=0,i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null),j=[];for(;f=i.nextNode();)j.push(f);for(let a of j){let f=(a.textContent||"").toLowerCase(),i=0,j=[];for(;;){let a=f.indexOf(e,i);if(-1===a)break;j.push({start:a,end:a+b.length}),i=a+1}if(0!==j.length)for(let b=j.length-1;b>=0;b--){let e=j[b];a.splitText(e.end);let f=a.splitText(e.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=f.textContent,f.parentNode.replaceChild(i,f),c.push({messageId:g,markIndex:h}),d.push(i),h++}}}),c.reverse(),d.reverse(),l.current=d,h(c),j(c.length>0?0:-1)},[a,m]);let n=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a+1)%g.length)},[g.length]),o=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a-1+g.length)%g.length)},[g.length]),p=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>k.current?.focus(),0)},[]),q=(0,d.useCallback)(()=>{c(!1),f(""),m(),h([]),j(0)},[m]),r=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?o():n()),"Escape"===a.key&&q()},[n,o,q]);return{isSearchVisible:b,searchQuery:e,setSearchQuery:f,matches:g,currentMatchIndex:i,goToNextMatch:n,goToPrevMatch:o,openSearch:p,closeSearch:q,searchInputRef:k,handleSearchKeyDown:r}}},99374:(a,b,c)=>{"use strict";c.d(b,{f:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(31172);function g({isOpen:a,onClose:b,messages:c,onSelectMessage:g}){let{t:h}=(0,e.Bd)();if(!a)return null;let i=c.filter(a=>"user"===a.role),j=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:h("userMessages.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===i.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:h("userMessages.noMessages")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:i.map((a,c)=>{let e,f,h,i=(e=a.id.match(/^user-(\d+)/))?parseInt(e[1],10):null,j=i?(f=new Date(i),h=new Date,f.toDateString()===h.toDateString()?f.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):f.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,d.jsx)("button",{onClick:()=>{g(a.id),b()},className:"w-full px-4 py-3 text-left hover:bg-accent transition-colors",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("p",{className:"text-sm text-foreground break-words",children:function(a,b=50){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:c.slice(0,b)+"..."}(a.content)})}),j&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,d.jsx)(f.Z,{children:j})}},99470:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:g}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=a?.local.filter(a=>a.toLowerCase().includes(k.toLowerCase()))||[],p=a?.remote.filter(a=>a.toLowerCase().includes(k.toLowerCase()))||[],q=a=>{c(a),j(!1),l("")};return(0,d.jsxs)("div",{className:"relative",ref:m,children:[(0,d.jsxs)("button",{onClick:()=>j(!i),disabled:g,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||h("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",h("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${i?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:n,type:"text",value:k,onChange:a=>l(a.target.value),placeholder:h("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[o.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:h("git.localBranches")}),o.map(c=>(0,d.jsxs)("div",{onClick:()=>q(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:h("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),p.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:h("git.remoteBranches")}),p.map(a=>(0,d.jsxs)("div",{onClick:()=>q(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===o.length&&0===p.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:h("git.noMatchingBranches")})]})]})]})}},99543:(a,b,c)=>{"use strict";c.d(b,{m:()=>e});var d=c(67484);function e(a,b,c,{cwd:e,initialSessionId:f,onSessionId:g,onTitleChange:h,onTokenUsage:i}){let[j,k]=(0,d.useState)(!1),[l,m]=(0,d.useState)(!1),[n,o]=(0,d.useState)(!1),[p,q]=(0,d.useState)(void 0),[r,s]=(0,d.useState)(0),t=(0,d.useRef)(h);t.current=h;let u=(0,d.useRef)(i);u.current=i;let v=(0,d.useRef)(void 0),w=(0,d.useRef)(0),x=(0,d.useCallback)(async(a,c,d=!1,e,f)=>{if(d){let a=Date.now();if(a-w.current<5e3)return;w.current=a}d||k(!0);try{let h={cwd:a,sessionId:c,limit:e,beforeTurnIndex:f};d&&v.current&&(h.ifFingerprint=v.current);let i=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(i.ok){let a=await i.json();if(a.notModified)return;a.fingerprint&&(v.current=a.fingerprint),void 0!==a.totalTurns&&s(a.totalTurns),void 0!==a.hasMore&&o(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>{let c=a.messages;if(b.length===c.length&&b.length>0&&b[b.length-1].content===c[c.length-1].content)return b;let d=0;for(let a=0;a<Math.min(b.length,c.length)&&b[a].id===c[a].id&&b[a].content===c[a].content;a++)d=a+1;return d===b.length&&d<c.length?[...b,...c.slice(d)]:c}):b(a.messages)),a.sessionId&&g(a.sessionId),a.title&&t.current?.(a.title),a.usage&&u.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||k(!1)}},[b,g]),y=(0,d.useCallback)(async()=>{if(e&&c&&!l&&n){m(!0);try{let d=void 0!==p?p:r-Math.ceil(a.filter(a=>"user"===a.role).length),f=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0})});if(f.ok){let a=await f.json();if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let c=a.messages.filter(a=>"user"===a.role).length;q(d-c)}void 0!==a.hasMore&&o(a.hasMore),a.fingerprint&&(v.current=a.fingerprint)}}catch(a){console.error("Failed to load more history:",a)}finally{m(!1)}}},[e,c,l,n,p,r,a,b]);return{isLoadingHistory:j,isLoadingMore:l,hasMoreHistory:n,loadMoreHistory:y,loadHistory:(0,d.useCallback)(async a=>{k(!0);try{let c=await fetch(`/api/session/${a}/history`);if(c.ok){let a=await c.json();a.messages&&a.messages.length>0&&b(a.messages)}}catch(a){console.error("Failed to load history:",a)}finally{k(!1)}},[b]),loadHistoryByCwdAndSessionId:x}}}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,6117,4793,6443,7514,6062,7284],()=>b(b.s=43501));module.exports=c})();