@surething/cockpit 1.0.184 → 1.0.185

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 (69) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +21 -21
  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.html +2 -2
  6. package/.next-prod/server/app/_global-error.rsc +1 -1
  7. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next-prod/server/app/_not-found.html +2 -2
  14. package/.next-prod/server/app/_not-found.rsc +1 -1
  15. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +1 -1
  16. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next-prod/server/app/api/chat/codex/route.js +1 -1
  22. package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
  23. package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
  24. package/.next-prod/server/app/api/chat/route.js +1 -1
  25. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  26. package/.next-prod/server/app/api/commands/route.js +1 -1
  27. package/.next-prod/server/app/api/comments/route.js +1 -1
  28. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  29. package/.next-prod/server/app/api/files/init/route.js +1 -1
  30. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  31. package/.next-prod/server/app/api/global-state/route.js +1 -1
  32. package/.next-prod/server/app/api/note/route.js +1 -1
  33. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  34. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  35. package/.next-prod/server/app/api/project-state/route.js +1 -1
  36. package/.next-prod/server/app/api/projects/route.js +1 -1
  37. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  38. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  39. package/.next-prod/server/app/api/review/order/route.js +1 -1
  40. package/.next-prod/server/app/api/review/users/route.js +1 -1
  41. package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -1
  42. package/.next-prod/server/app/api/services/config/route.js +1 -1
  43. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  44. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  45. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  46. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  47. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  48. package/.next-prod/server/app/api/sessions/route.js +1 -1
  49. package/.next-prod/server/app/api/settings/route.js +1 -1
  50. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  51. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  52. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  53. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  54. package/.next-prod/server/app/project/page.js +1 -1
  55. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  56. package/.next-prod/server/app-paths-manifest.json +21 -21
  57. package/.next-prod/server/chunks/4098.js +1 -1
  58. package/.next-prod/server/pages/404.html +2 -2
  59. package/.next-prod/server/pages/500.html +2 -2
  60. package/.next-prod/server/server-reference-manifest.json +1 -1
  61. package/.next-prod/static/chunks/app/project/{page-94e2a1e77495f17f.js → page-b73536c67304e489.js} +19 -19
  62. package/.next-prod/trace +12 -12
  63. package/.next-prod/trace-build +1 -1
  64. package/dist/{chunk-YNAZMVAD.mjs → chunk-SWMKAZSL.mjs} +1 -1
  65. package/dist/scheduledTasks.mjs +1 -1
  66. package/dist/wsServer.mjs +1 -1
  67. package/package.json +1 -1
  68. /package/.next-prod/static/{Jd-PD9ePjHrv17OUyoAFo → ZA65Kd3f2tNa-NfgtOil4}/_buildManifest.js +0 -0
  69. /package/.next-prod/static/{Jd-PD9ePjHrv17OUyoAFo → ZA65Kd3f2tNa-NfgtOil4}/_ssgManifest.js +0 -0
@@ -4,7 +4,7 @@ ${f}`),ab(i,c)}catch(a){ab(G("chat.executedCommandFailed",{command:e,error:a}),c
4
4
  font-size: .6rem;
5
5
  font-weight: bold;
6
6
  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}`:""}
7
- 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:()=>k});var d=c(48249),e=c(67484),f=c(74429),g=c(69005),h=c(44384);function i({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 j({onNewTab:a,onNewCodexTab:b,onNewKimiTab:c,onNewOllamaTab:g}){let[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),k=(0,e.useRef)(null),[l,m]=(0,e.useState)({top:0,left:0}),n=d=>{i(!1),"codex"===d?b?.():"kimi"===d?c?.():"ollama"===d?g?.():a()},o=h?(0,f.createPortal)((0,d.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[140px]",style:{top:l.top,left:l.left},children:[(0,d.jsxs)("button",{onClick:()=>n("claude"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}),"Claude Code"]}),(0,d.jsxs)("button",{onClick:()=>n("codex"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),"OpenAI Codex"]}),(0,d.jsxs)("button",{onClick:()=>n("kimi"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"}),"Kimi"]}),(0,d.jsxs)("button",{onClick:()=>n("ollama"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-violet-500 flex-shrink-0"}),"Ollama"]})]}),document.body):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{ref:j,onClick:()=>{if(!h&&j.current){let a=0,b=0,c=j.current.parentElement;for(;c;){let d=getComputedStyle(c).transform;if(d&&"none"!==d){let d=c.getBoundingClientRect();a=d.left-c.offsetLeft,b=d.top-c.offsetTop;break}c=c.parentElement}let d=j.current.getBoundingClientRect();m({top:d.bottom+4-b,left:d.left-a})}i(a=>!a)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"New tab",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"})})}),o]})}function k({tabs:a,activeTabId:b,unreadTabs:c,dragTabIndex:e,dragOverTabIndex:f,isPinned:k,onTogglePin:l,onSwitchTab:m,onCloseTab:n,onNewTab:o,onNewCodexTab:p,onNewKimiTab:q,onNewOllamaTab:r,onDragStart:s,onDragOver:t,onDrop:u,onDragEnd:v}){let{t:w}=(0,h.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((h,j)=>(0,d.jsx)(g.m,{content:h.title,delay:200,children:(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>s(j),onDragOver:a=>t(a,j),onDrop:()=>u(j),onDragEnd:v,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${h.id===b?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${e===j?"opacity-50":""} ${f===j?"border-l-2 border-brand":""}`,onClick:()=>m(h.id),children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(i,{number:j+1,isActive:h.id===b}),h.isLoading&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!h.isLoading&&c.has(h.id)&&h.id!==b&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),l&&k?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l(h.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:w("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"})})}),l&&!k?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l(h.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:w("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:h.title}),"codex"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-emerald-500/15 text-emerald-400 font-medium leading-relaxed",children:"CX"}),"kimi"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-blue-500/15 text-blue-400 font-medium leading-relaxed",children:"KM"}),"ollama"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-violet-500/15 text-violet-400 font-medium leading-relaxed",children:"OL"}),a.length>1&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),n(h.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:w("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"})})})]})},h.id)),(0,d.jsx)(j,{onNewTab:o,onNewCodexTab:p,onNewKimiTab:q,onNewOllamaTab:r})]})})}},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(67122),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,handleNewCodexTab:G,handleNewKimiTab:H,handleNewOllamaTab:I,handleOpenSession:J,updateTabState:K,updateTabOllamaModel:L,handleTabDragStart:M,handleTabDragOver:N,handleTabDrop:O,handleTabDragEnd:P}=(0,o.i)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:Q,pinSession:R,unpinSession:S}=(0,t.P)(),{createTask:T}=(0,u.n)(),U=(0,f.useCallback)(a=>{let b=w.find(b=>b.id===a);return!!b?.sessionId&&Q(b.sessionId)},[w,Q]),V=(0,f.useCallback)(b=>{let c=w.find(a=>a.id===b);c?.sessionId&&(Q(c.sessionId)?S(c.sessionId):R(c.sessionId,c.cwd||a||"",c.title))},[w,Q,R,S,a]),[W,X]=(0,f.useState)(!1),[Y,Z]=(0,f.useState)(!1),[$,_]=(0,f.useState)(!1),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(!1),[ae,af]=(0,f.useState)("tree"),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(null),[ak,al]=(0,f.useState)(0),[am,an]=(0,f.useState)(!1);(0,f.useRef)(null);let ao=(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]),ap=(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(ad(c.isGitRepo),c.isGitRepo&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&ab(b.branch)}}}catch(a){console.error("Failed to load git info:",a)}},[a]),aq=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&ap()},[ap]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aq,enabled:!!a});let ar=(0,f.useCallback)(()=>{af("status"),ah(a=>a+1),ao("explorer")},[ao]),as=(0,f.useCallback)(a=>{aj(a),al(a=>a+1),ao("explorer")},[ao]),at=(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:ao,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:ac,currentBranch:aa,onOpenWorktree:()=>Z(!0),onOpenProjectSessions:()=>X(!0),onOpenAliasManager:()=>_(!0),onBranchSwitched:ap}),am&&(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:U,onTogglePin:V,onSwitchTab:D,onCloseTab:C,onNewTab:F,onNewCodexTab:G,onNewKimiTab:H,onNewOllamaTab:I,onDragStart:M,onDragOver:N,onDrop:O,onDragEnd:P}),(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,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:L,isActive:a.id===x&&"agent"===d,onStateChange:K,onShowGitStatus:ar,onContentSearch:as,onOpenNote:at,onCreateScheduledTask:T,onOpenSession:J})},a.id))})]}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(i.g,{onClose:()=>ao("agent"),cwd:a,initialTab:ae,tabSwitchTrigger:ag,initialSearchQuery:ai,searchQueryTrigger:ak})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:at})})]}):(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:U,onTogglePin:V,onSwitchTab:D,onCloseTab:C,onNewTab:F,onNewCodexTab:G,onNewKimiTab:H,onDragStart:M,onDragOver:N,onDrop:O,onDragEnd:P}),(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,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:L,isActive:a.id===x,onStateChange:K,onCreateScheduledTask:T,onOpenSession:J})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:W,onClose:()=>X(!1),cwd:a,onSelectSession:E}),a&&ac&&(0,e.jsx)(j.x,{isOpen:Y,onClose:()=>Z(!1),cwd:a}),$&&(0,e.jsx)(l.Y,{onClose:()=>_(!1),onSave:()=>_(!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,engine:g,ollamaModel:h,onSessionId:i,onFetchTitle:j}){let[k,l]=(0,d.useState)(!1),[m,n]=(0,d.useState)(null),o=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let q=(0,d.useRef)(null),r=(0,d.useRef)(null),s=(0,d.useCallback)(()=>{let a=q.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)),q.current={messageId:c,text:""}}r.current=null},[b]),t=(0,d.useCallback)(()=>{o.current&&(o.current.abort(),o.current=null)},[]),u=(0,d.useCallback)((a,c)=>{let d=a.type;if("system"===d&&"init"===a.subtype){let b=a.session_id;i(b),p.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||"";q.current&&q.current.messageId===c?q.current.text+=a:q.current={messageId:c,text:a},r.current||(r.current=setTimeout(s,50))}return}if("assistant"===d){let d=a.message;if(d?.content){let a=d.content.filter(a=>"text"===a.type&&a.text).map(a=>a.text);if(a.length>0){let d=a.join("");b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a))}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){r.current&&(clearTimeout(r.current),r.current=null),s();let d=p.current;d&&f&&b(a=>(2===a.length&&j(d),a));let e=a.usage,g=a.total_cost_usd;e&&n({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,s,i,j,f]);return{isLoading:k,tokenUsage:m,handleSend:(0,d.useCallback)(async(a,c)=>{let d=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),i={id:`user-${Date.now()}`,role:"user",content:a,images:d};b(a=>[...a,i]),l(!0);let j=`assistant-${Date.now()}`,k={id:j,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,k]),o.current=new AbortController;try{if("ollama"===g&&!h)throw Error("Please select an Ollama model first (click the model picker above)");let b=await fetch("codex"===g?"/api/chat/codex":"kimi"===g?"/api/chat/kimi":"ollama"===g?"/api/chat/ollama":"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:p.current,images:d,cwd:f,..."ollama"===g&&h&&{model:h}}),signal:o.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 i=new TextDecoder,k="";for(;;){let{done:a,value:b}=await c.read();if(a)break;let d=(k+=i.decode(b,{stream:!0})).split("\n");for(let a of(k=d.pop()||"",d))if(a.startsWith("data: ")){let b=a.slice(6);if("[DONE]"===b)continue;try{let a=JSON.parse(b);u(a,j)}catch{}}}}catch(a){if(a instanceof Error&&"AbortError"===a.name);else{console.error("Chat error:",a);let c=a instanceof Error?a.message:e.A.t("chat.errorRetry");b(a=>a.map(a=>a.id===j?{...a,content:c,isStreaming:!1}:a))}}finally{o.current=null,l(!1),b(a=>a.map(a=>a.id===j?{...a,isStreaming:!1}:a))}},[f,g,h,b,u]),handleStop:t,abortControllerRef:o}}},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")},63161:(a,b,c)=>{"use strict";c.d(b,{m:()=>g});var d=c(48249),e=c(67484),f=c(74429);function g({currentModel:a,onModelChange:b}){let[c,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({top:0,left:0}),t=(0,e.useCallback)(async()=>{k(!0),m(null);try{let a=await fetch("/api/ollama/models");if(503===a.status){o(!0);let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json();if(404===a.status){m(b.message||"Ollama is not installed"),o(!1);return}if(!a.ok){m("Failed to start Ollama"),o(!1);return}o(!1);let c=await fetch("/api/ollama/models");if(!c.ok)return void m("Ollama started but cannot fetch models");let d=await c.json();i(d.models||[])}else if(a.ok){let b=await a.json();i(b.models||[])}else m("Failed to fetch models")}catch{m("Connection error")}finally{k(!1)}},[]),u=a?a.replace(/:latest$/,""):"Select model",v=c?(0,f.createPortal)((0,d.jsx)("div",{ref:q,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[200px] max-h-[300px] overflow-y-auto",style:{top:r.top,left:r.left},children:j||n?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),n?"Starting Ollama...":"Loading models..."]}):l?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-400",children:l}):0===h.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):h.map(c=>{var e;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),g(!1)},className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs hover:bg-brand/10 transition-colors ${c.name===a?"text-brand":"text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})}),document.body):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:p,onClick:()=>{if(!c){if(p.current){let a=0,b=0,c=p.current.parentElement;for(;c;){let d=getComputedStyle(c).transform;if(d&&"none"!==d){let d=c.getBoundingClientRect();a=d.left-c.offsetLeft,b=d.top-c.offsetTop;break}c=c.parentElement}let d=p.current.getBoundingClientRect();s({top:d.bottom+4-b,left:d.left-a})}t()}g(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-violet-500/15 text-violet-400 hover:bg-violet-500/25 transition-colors",title:"Switch Ollama model",children:[(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500 flex-shrink-0"}),(0,d.jsx)("span",{className:"truncate max-w-[120px]",children:u}),(0,d.jsx)("svg",{className:"w-3 h-3 flex-shrink-0",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"})})]}),v]})}},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})]})}},67122:(a,b,c)=>{"use strict";c.d(b,{J:()=>bf});var d,e,f,g,h,i=c(48249),j=c(67484),k=c(44384),l=c(46674),m=c(15273),n=c(47408);let o=(0,n.A)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),p=(0,n.A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),q=(0,n.A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),r=(0,n.A)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var s=c(44218),t=c(81749),u=function(a,b){return Object.defineProperty?Object.defineProperty(a,"raw",{value:b}):a.raw=b,a};(d=e||(e={}))[d.EOS=0]="EOS",d[d.Text=1]="Text",d[d.Incomplete=2]="Incomplete",d[d.ESC=3]="ESC",d[d.Unknown=4]="Unknown",d[d.SGR=5]="SGR",d[d.OSCURL=6]="OSCURL";class v{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(a){this._use_classes=a}get use_classes(){return this._use_classes}set url_allowlist(a){this._url_allowlist=a}get url_allowlist(){return this._url_allowlist}set escape_html(a){this._escape_html=a}get escape_html(){return this._escape_html}set boldStyle(a){this._boldStyle=a}get boldStyle(){return this._boldStyle}set faintStyle(a){this._faintStyle=a}get faintStyle(){return this._faintStyle}set italicStyle(a){this._italicStyle=a}get italicStyle(){return this._italicStyle}set underlineStyle(a){this._underlineStyle=a}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(a=>{this.palette_256.push(a)})});let a=[0,95,135,175,215,255];for(let b=0;b<6;++b)for(let c=0;c<6;++c)for(let d=0;d<6;++d){let e={rgb:[a[b],a[c],a[d]],class_name:"truecolor"};this.palette_256.push(e)}let b=8;for(let a=0;a<24;++a,b+=10){let a={rgb:[b,b,b],class_name:"truecolor"};this.palette_256.push(a)}}escape_txt_for_html(a){return this._escape_html?a.replace(/[&<>"']/gm,a=>"&"===a?"&amp;":"<"===a?"&lt;":">"===a?"&gt;":'"'===a?"&quot;":"'"===a?"&#x27;":void 0):a}append_buffer(a){var b=this._buffer+a;this._buffer=b}get_next_packet(){var a={kind:e.EOS,text:"",url:""},b=this._buffer.length;if(0==b)return a;var c=this._buffer.indexOf("\x1b");if(-1==c)return a.kind=e.Text,a.text=this._buffer,this._buffer="",a;if(c>0)return a.kind=e.Text,a.text=this._buffer.slice(0,c),this._buffer=this._buffer.slice(c),a;if(0==c){if(b<3)return a.kind=e.Incomplete,a;var d=this._buffer.charAt(1);if("["!=d&&"]"!=d&&"("!=d)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;if("["==d){this._csi_regex||(this._csi_regex=w(f||(f=u(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1b[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1b[ # CSI\n [ -~]* # anything legal\n ([\0-\x1f:]) # anything illegal\n )\n "],["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]))));let b=this._buffer.match(this._csi_regex);if(null===b)return a.kind=e.Incomplete,a;if(b[4])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;""!=b[1]||"m"!=b[3]?a.kind=e.Unknown:a.kind=e.SGR,a.text=b[2];var i=b[0].length;return this._buffer=this._buffer.slice(i),a}if("]"==d){if(b<4)return a.kind=e.Incomplete,a;if("8"!=this._buffer.charAt(2)||";"!=this._buffer.charAt(3))return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;this._osc_st||(this._osc_st=RegExp((g||(g=u(["\n (?: # legal sequence\n (\x1b\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\x06] # anything illegal\n | # alternate\n [\b-\x1a] # anything illegal\n | # alternate\n [\x1c-\x1f] # anything illegal\n )\n "],["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "]))).raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""),"g")),this._osc_st.lastIndex=0;{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}this._osc_regex||(this._osc_regex=w(h||(h=u(["\n ^ # beginning of line\n #\n \x1b]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1b]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "],["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]))));let c=this._buffer.match(this._osc_regex);if(null===c)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;a.kind=e.OSCURL,a.url=c[1],a.text=c[2];var i=c[0].length;return this._buffer=this._buffer.slice(i),a}if("("==d)return a.kind=e.Unknown,this._buffer=this._buffer.slice(3),a}}ansi_to_html(a){this.append_buffer(a);for(var b=[];;){var c=this.get_next_packet();if(c.kind==e.EOS||c.kind==e.Incomplete)break;c.kind!=e.ESC&&c.kind!=e.Unknown&&(c.kind==e.Text?b.push(this.transform_to_html(this.with_state(c))):c.kind==e.SGR?this.process_ansi(c):c.kind==e.OSCURL&&b.push(this.process_hyperlink(c)))}return b.join("")}with_state(a){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:a.text}}process_ansi(a){let b=a.text.split(";");for(;b.length>0;){let a=parseInt(b.shift(),10);if(isNaN(a)||0===a)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(1===a)this.bold=!0;else if(2===a)this.faint=!0;else if(3===a)this.italic=!0;else if(4===a)this.underline=!0;else if(21===a)this.bold=!1;else if(22===a)this.faint=!1,this.bold=!1;else if(23===a)this.italic=!1;else if(24===a)this.underline=!1;else if(39===a)this.fg=null;else if(49===a)this.bg=null;else if(a>=30&&a<38)this.fg=this.ansi_colors[0][a-30];else if(a>=40&&a<48)this.bg=this.ansi_colors[0][a-40];else if(a>=90&&a<98)this.fg=this.ansi_colors[1][a-90];else if(a>=100&&a<108)this.bg=this.ansi_colors[1][a-100];else if((38===a||48===a)&&b.length>0){let c=38===a,d=b.shift();if("5"===d&&b.length>0){let a=parseInt(b.shift(),10);a>=0&&a<=255&&(c?this.fg=this.palette_256[a]:this.bg=this.palette_256[a])}if("2"===d&&b.length>2){let a=parseInt(b.shift(),10),d=parseInt(b.shift(),10),e=parseInt(b.shift(),10);if(a>=0&&a<=255&&d>=0&&d<=255&&e>=0&&e<=255){let b={rgb:[a,d,e],class_name:"truecolor"};c?this.fg=b:this.bg=b}}}}}transform_to_html(a){let b=a.text;if(0===b.length||(b=this.escape_txt_for_html(b),!a.bold&&!a.italic&&!a.faint&&!a.underline&&null===a.fg&&null===a.bg))return b;let c=[],d=[],e=a.fg,f=a.bg;a.bold&&c.push(this._boldStyle),a.faint&&c.push(this._faintStyle),a.italic&&c.push(this._italicStyle),a.underline&&c.push(this._underlineStyle),this._use_classes?(e&&("truecolor"!==e.class_name?d.push(`${e.class_name}-fg`):c.push(`color:rgb(${e.rgb.join(",")})`)),f&&("truecolor"!==f.class_name?d.push(`${f.class_name}-bg`):c.push(`background-color:rgb(${f.rgb.join(",")})`))):(e&&c.push(`color:rgb(${e.rgb.join(",")})`),f&&c.push(`background-color:rgb(${f.rgb})`));let g="",h="";return d.length&&(g=` class="${d.join(" ")}"`),c.length&&(h=` style="${c.join(";")}"`),`<span${h}${g}>${b}</span>`}process_hyperlink(a){let b=a.url.split(":");return b.length<1||!this._url_allowlist[b[0]]?"":`<a href="${this.escape_txt_for_html(a.url)}">${this.escape_txt_for_html(a.text)}</a>`}}function w(a){return new RegExp(a.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""))}function x(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}let y=(0,j.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)(!1),h=(0,j.useCallback)(async h=>{if(h.stopPropagation(),f)await d(),g(!1),(0,t.oR)(e("toast.disconnected",{id:a}));else{await c(),g(!0);let d=`cock ${b} ${a}`;navigator.clipboard.writeText(d),(0,t.oR)(e("toast.copiedCommand",{command:d}))}},[f,a,b,c,d,e]);return(0,i.jsxs)("button",{onClick:h,className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:f?e("shortIdBadge.clickToDisconnect"):e("shortIdBadge.clickToRegister"),children:[(0,i.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${f?"bg-green-500":"bg-muted-foreground/40"}`}),a]})});var z=c(30976);let A=(0,j.lazy)(()=>c.e(4490).then(c.bind(c,54490)).then(a=>({default:a.XtermRenderer}))),B={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},C=/\x1b\[[0-9;]*m/g;function D({output:a,query:b,mode:c,currentIdx:d,matchRefs:e}){let f=(0,j.useRef)(null);f.current||(f.current=new v,f.current.use_classes=!0);let g=a.split("\n"),h=b.toLowerCase(),k=0;return e.current=[],(0,i.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:g.map((a,b)=>{let g=a.replace(C,""),j=g.toLowerCase().includes(h);if("filter"===c&&!j)return null;if(!j){let c=f.current.ansi_to_html(a);return(0,i.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=g.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(h,o);if(-1===a)break;a>m&&l.push((0,i.jsx)("span",{children:g.slice(m,a)},`t${m}`));let b=k++,c=b===d;l.push((0,i.jsx)("mark",{ref:a=>{e.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:g.slice(a,a+h.length)},`m${a}`)),o=m=a+h.length}return m<g.length&&l.push((0,i.jsx)("span",{children:g.slice(m)},`t${m}`)),(0,i.jsx)("div",{children:l},b)})})}let E=(0,j.memo)(function({commandId:a,tabId:b,projectCwd:c,command:d,output:e,exitCode:f,isRunning:g,selected:h,onSelect:n,onInterrupt:u,onStdin:w,onDelete:C,onRerun:E,timestamp:F,usePty:G,onPtyResize:H,onToggleMaximize:I,maximized:J,expandedHeight:K,bubbleContentHeight:L,onTitleMouseDown:M}){let{t:N}=(0,k.Bd)(),O=(0,j.useRef)(null),P=(0,j.useRef)(null),Q=(0,j.useRef)(!0),R=(0,j.useRef)(null),S=(0,j.useRef)(null),T=(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}`})(F),U=a&&b?x(b+a):void 0,[V,W]=(0,j.useState)(!1),[X,Y]=(0,j.useState)(""),Z=(0,j.useRef)(null),$=(0,j.useRef)(null),[_,aa]=(0,j.useState)(!1),[ab,ac]=(0,j.useState)(""),[ad,ae]=(0,j.useState)("search"),[af,ag]=(0,j.useState)(0),ah=(0,j.useRef)([]),ai=(0,j.useRef)(null),aj=(0,j.useRef)(0);(0,j.useEffect)(()=>{ai.current||(ai.current=new v,ai.current.use_classes=!0)},[]),(0,j.useLayoutEffect)(()=>{let a=P.current;if(a&&ai.current){if(e.length<aj.current&&(ai.current=new v,ai.current.use_classes=!0,aj.current=0,a.innerHTML=""),e.length>aj.current){let b=e.slice(aj.current),c=ai.current.ansi_to_html(b);aj.current=e.length,a.insertAdjacentHTML("beforeend",c)}if(O.current){let a=O.current.scrollHeight>O.current.clientHeight;W(a),a&&(O.current.scrollTop=O.current.scrollHeight)}}},[e]),(0,j.useEffect)(()=>(g&&Q.current&&O.current&&(null!==R.current&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{O.current&&(O.current.scrollTop=O.current.scrollHeight),R.current=null})),()=>{null!==R.current&&cancelAnimationFrame(R.current)}),[e,g]),(0,j.useEffect)(()=>{if(!J)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),I?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[J,I]);let ak=e?e.split("\n").length:0,al=(0,j.useCallback)(()=>{aa(!0),requestAnimationFrame(()=>$.current?.focus())},[]),am=(0,j.useCallback)(()=>{aa(!1),ac(""),ag(0),Z.current?.clearSearch()},[]),an=(0,j.useCallback)(a=>{a.trim()&&(G?Z.current?.findNext(a):ag(a=>{let b=a+1,c=ah.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(ah.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[G]),ao=(0,j.useCallback)(a=>{a.trim()&&(G?Z.current?.findPrevious(a):ag(a=>{let b=a-1;if(b>=0)return ah.current[b]?.scrollIntoView({block:"nearest"}),b;let c=ah.current.length-1;return c>=0&&ah.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[G]);(0,j.useEffect)(()=>{if(!h)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),al();return}if("Escape"===a.key&&_){a.preventDefault(),a.stopPropagation(),am();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[h,_,al,am]);let ap=J&&K?K-41:L??360;return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${J?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${J?"":h?"border-brand":"border-brand/30"}`,onClick:n,children:[J?(0,i.jsxs)("div",{onDoubleClick:()=>I?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,i.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:d}),g&&(0,i.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),N("console.runningText")]}),g&&u&&(0,i.jsx)("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,i.jsx)("button",{onClick:()=>I?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.restoreTooltip",{modKey:(0,z.Mu)()}),children:(0,i.jsx)(l.A,{className:"w-4 h-4"})})]}):(0,i.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>M?.(),onDoubleClick:a=>{a.stopPropagation(),I?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${h?"border-brand":"border-brand/30"}`,children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),U&&a&&b&&(0,i.jsx)(y,{shortId:U,type:"terminal",onRegister:()=>{fetch("/api/terminal/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tabId:b,commandId:a,command:d,projectCwd:c})}).catch(()=>{})},onUnregister:()=>{fetch("/api/terminal/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandId:a})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"font-mono text-foreground truncate",children:d}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(d),(0,t.oR)(N("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.copyCommand"),children:(0,i.jsx)(m.A,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("span",{className:"flex-1"}),V&&!g&&(0,i.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:N("console.totalLines",{count:ak})}),e&&(0,i.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=e.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,t.oR)(N("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.copyOutput"),children:(0,i.jsx)(o,{className:"w-3.5 h-3.5"})}),E&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),E()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.rerun"),children:(0,i.jsx)(p,{className:"w-3.5 h-3.5"})}),C&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),C()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:N("console.deleteRecord"),children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),_&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,i.jsx)(q,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,i.jsx)("input",{ref:$,value:ab,onChange:a=>{let b=a.target.value;ac(b),ag(0),G&&(b.trim()?Z.current?.findNext(b):Z.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?ao(ab):an(ab))},placeholder:N("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!G&&(0,i.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,i.jsx)("button",{onClick:()=>ae("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===ad?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:N("console.searchMode")}),(0,i.jsx)("button",{onClick:()=>ae("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===ad?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:N("console.filterMode")})]}),(0,i.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,i.jsx)("button",{onClick:()=>ao(ab),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.prevShiftEnter"),children:(0,i.jsx)(r,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("button",{onClick:()=>an(ab),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.nextEnter"),children:(0,i.jsx)(s.A,{className:"w-3.5 h-3.5"})})]}),(0,i.jsx)("button",{onClick:am,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),G?(0,i.jsx)("div",{style:{height:ap,overflow:"hidden"},children:(0,i.jsx)(j.Suspense,{fallback:(0,i.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:ap},children:N("console.loadingTerminal")}),children:(0,i.jsx)(A,{ref:Z,output:e,isRunning:g,onInput:w,onResize:H,maximized:J,height:ap})})}):(0,i.jsx)("div",{ref:O,className:"overflow-auto px-4 py-2",style:{height:ap},onScroll:()=>{if(O.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=O.current;Q.current=b-a-c<50}},children:_&&ab.trim()?(0,i.jsx)(D,{output:e,query:ab,mode:ad,currentIdx:af,matchRefs:ah}):(0,i.jsx)("pre",{ref:P,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),g&&!J&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),G?(0,i.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:N("console.clickToInput")}):w?(0,i.jsx)("input",{ref:S,value:X,onChange:a=>Y(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=B[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),w(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w(X+"\n"),Y("")),"Tab"===a.key&&(a.preventDefault(),w(" "))},placeholder:N("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:N("console.runningText")}),u&&(0,i.jsx)("button",{onClick:u,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),T&&(0,i.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:T})]}),!g&&void 0!==f&&!J&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===f?"bg-green-500":"bg-red-500"}`}),(0,i.jsx)("span",{children:N("console.exitCode",{code:f})}),(0,i.jsx)("span",{className:"flex-1"}),T&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:T})]})]})})});var F=c(59347),G=c(24520);function H({cwd:a,tabId:b,onClose:c,onSave:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)({}),[h,m]=(0,j.useState)(""),[n,o]=(0,j.useState)(""),[p,q]=(0,j.useState)(!0),r=()=>{h.trim()&&(g(a=>({...a,[h.trim()]:n})),m(""),o(""))},s=async()=>{try{(await fetch("/api/terminal/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,env:f})})).ok&&(d(f),c())}catch(a){console.error("Failed to save env:",a)}};return(0,i.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,i.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,i.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:e("envManager.title")}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?e("envManager.tabScope"):e("envManager.globalScope")})]}),(0,i.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-5 h-5"})})]}),(0,i.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,i.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:e("common.loading")}):(0,i.jsxs)("div",{className:"space-y-3",children:[Object.entries(f).map(([a,b])=>(0,i.jsxs)("div",{className:"flex items-start gap-2",children:[(0,i.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,i.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void g(b=>({...b,[a]:c}))},placeholder:e("envManager.valuePlaceholder"),className:"flex-1 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,i.jsx)("button",{onClick:()=>{g(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,i.jsx)(F.A,{className:"w-4 h-4"})})]},a)),(0,i.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,i.jsx)("input",{type:"text",value:h,onChange:a=>m(a.target.value),placeholder:e("envManager.varNamePlaceholder"),className:"flex-1 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(),r())}}),(0,i.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:e("envManager.varValuePlaceholder"),className:"flex-1 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(),r())}}),(0,i.jsx)("button",{onClick:r,disabled:!h.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,i.jsx)(G.A,{className:"w-4 h-4"})})]}),0===Object.keys(f).length&&(0,i.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:e("envManager.noVars")})]})}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,i.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:e("common.cancel")}),(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:e("common.save")})]})]})})}var I=c(94924);let J=(0,n.A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),K=(0,n.A)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),L=(0,n.A)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),M=(0,n.A)("variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]),N=(0,n.A)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var O=c(69005);let P=null,Q="",R=0,S=null,T=!1,U=new Map,V=null,W=null;function X(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){V&&(V(b.commands),V=null);return}let d=b.commandId;if(!d)return;let e=U.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&U.delete(d)}}function Y(a){P?.readyState===WebSocket.OPEN&&P.send(JSON.stringify(a))}function Z(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);Q===c&&P||(function(){if(T=!0,S&&(clearTimeout(S),S=null),P){let a=P;P=null,a.close()}U.clear(),V&&(V([]),V=null),W=null,Q="",R=0}(),T=!1,Q=c,function a(){if(T||!Q)return;let b=new WebSocket(Q);P=b,b.onopen=()=>{for(let a of(R=0,U.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=X,b.onclose=()=>{if(P!==b||(P=null,T))return;S&&clearTimeout(S);let c=Math.min(1e3*Math.pow(1.5,R),1e4);R++,S=setTimeout(a,c)},b.onerror=()=>{}}())}function $(){return new Promise((a,b)=>{if(P?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{P?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(d),a())},50),d=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function _(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:i,rows:j,onData:k,onError:l}=a;Z(f);try{await $()}catch{l("WebSocket connection failed");return}U.delete(d),U.set(d,{onData:k,onError:l}),Y({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...i?{cols:i,rows:j}:{}})}async function aa(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;Z(c);try{await $()}catch{e("WebSocket connection failed");return}U.set(b,{onData:d,onError:e}),Y({type:"attach",commandId:b})}function ab(a,b){Y({type:"stdin",commandId:a,data:b})}function ac(a,b,c){Y({type:"resize",commandId:a,cols:b,rows:c})}function ad(a){Y({type:"interrupt",pid:a})}async function ae(a){try{Z(a);try{await $()}catch{return[]}return await new Promise(a=>{V=b=>{a(b)},Y({type:"running"}),setTimeout(()=>{V&&(V=null,a([]))},3e3)})}finally{W=null}}let af=new Map;function ag(a){af.set(a.type,a)}function ah(a){return af.get(a)}function ai(a){for(let b of af.values())if(b.match(a))return b;return null}var aj=c(74955);async function ak(a){let b=(0,aj.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function al({url:a,id:b,selected:c,maximized:d,expandedHeight:e,bubbleContentHeight:f,onSelect:g,onClose:h,onToggleMaximize:l,onNewTab:m,timestamp:n,onTitleMouseDown:o,initialSleeping:p,onSleep:q,onWake:r}){let{t:s}=(0,k.Bd)(),[u,v]=(0,j.useState)(!1),[w,A]=(0,j.useState)(null),[B,C]=(0,j.useState)(a),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)(p??!1),H=(0,j.useRef)(null),I=(0,j.useRef)(null),J=(0,j.useRef)(null);(0,j.useRef)(!0),(0,j.useCallback)(()=>{F||(G(!0),E(null),q?.(b))},[F,b,q]),(0,j.useCallback)(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]);let{shortId:K,connected:L,connect:M,disconnect:N}=function(a,b,c){let d=(0,j.useMemo)(()=>x(a),[a]),[e,f]=(0,j.useState)(!1),g=(0,j.useRef)(null);(0,j.useRef)([]),(0,j.useRef)(null),(0,j.useRef)(!1),(0,j.useRef)(c);let h=(0,j.useRef)([]);(0,j.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=g.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let i=(0,j.useCallback)(()=>e&&g.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{h.current.push(a),e||f(!0)}),[e]);return{shortId:d,connected:e,connect:i,disconnect:(0,j.useCallback)(()=>{f(!1)},[])}}(b,J,!!D&&!F&&!u);(0,j.useRef)(L).current=L;let O=(0,j.useCallback)(()=>{G(!1),r?.(b);let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?ak(a).then(()=>E(c)):E(c)},[a,b,r]),P=(0,j.useCallback)(()=>v(!1),[]),Q=(0,j.useCallback)(()=>{v(!1),A(s("browser.pageLoadFailed"))},[]),R=(0,j.useCallback)(()=>{if(F)return void O();let a=I.current?.querySelector("iframe");if(a&&D){v(!0),A(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[F,O,D]),S=(0,j.useCallback)(()=>{B&&window.open(B,"_blank")},[B]),T=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a}}(B);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
7
+ 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:()=>k});var d=c(48249),e=c(67484),f=c(74429),g=c(69005),h=c(44384);function i({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 j({onNewTab:a,onNewCodexTab:b,onNewKimiTab:c,onNewOllamaTab:g}){let[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),k=(0,e.useRef)(null),[l,m]=(0,e.useState)({top:0,right:0}),n=d=>{i(!1),"codex"===d?b?.():"kimi"===d?c?.():"ollama"===d?g?.():a()};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{ref:j,onClick:()=>{if(!h&&j.current){let a=j.current.getBoundingClientRect();m({top:a.bottom+4,right:window.innerWidth-a.right})}i(a=>!a)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"New tab",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"})})}),h&&(0,f.createPortal)((0,d.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[140px]",style:{top:l.top,right:l.right},children:[(0,d.jsxs)("button",{onClick:()=>n("claude"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}),"Claude Code"]}),(0,d.jsxs)("button",{onClick:()=>n("codex"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),"OpenAI Codex"]}),(0,d.jsxs)("button",{onClick:()=>n("kimi"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"}),"Kimi"]}),(0,d.jsxs)("button",{onClick:()=>n("ollama"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-violet-500 flex-shrink-0"}),"Ollama"]})]}),document.body)]})}function k({tabs:a,activeTabId:b,unreadTabs:c,dragTabIndex:e,dragOverTabIndex:f,isPinned:k,onTogglePin:l,onSwitchTab:m,onCloseTab:n,onNewTab:o,onNewCodexTab:p,onNewKimiTab:q,onNewOllamaTab:r,onDragStart:s,onDragOver:t,onDrop:u,onDragEnd:v}){let{t:w}=(0,h.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((h,j)=>(0,d.jsx)(g.m,{content:h.title,delay:200,children:(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>s(j),onDragOver:a=>t(a,j),onDrop:()=>u(j),onDragEnd:v,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${h.id===b?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${e===j?"opacity-50":""} ${f===j?"border-l-2 border-brand":""}`,onClick:()=>m(h.id),children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(i,{number:j+1,isActive:h.id===b}),h.isLoading&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!h.isLoading&&c.has(h.id)&&h.id!==b&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),l&&k?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l(h.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:w("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"})})}),l&&!k?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l(h.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:w("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:h.title}),"codex"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-emerald-500/15 text-emerald-400 font-medium leading-relaxed",children:"CX"}),"kimi"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-blue-500/15 text-blue-400 font-medium leading-relaxed",children:"KM"}),"ollama"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-violet-500/15 text-violet-400 font-medium leading-relaxed",children:"OL"}),a.length>1&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),n(h.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:w("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"})})})]})},h.id)),(0,d.jsx)(j,{onNewTab:o,onNewCodexTab:p,onNewKimiTab:q,onNewOllamaTab:r})]})})}},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(67122),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,handleNewCodexTab:G,handleNewKimiTab:H,handleNewOllamaTab:I,handleOpenSession:J,updateTabState:K,updateTabOllamaModel:L,handleTabDragStart:M,handleTabDragOver:N,handleTabDrop:O,handleTabDragEnd:P}=(0,o.i)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:Q,pinSession:R,unpinSession:S}=(0,t.P)(),{createTask:T}=(0,u.n)(),U=(0,f.useCallback)(a=>{let b=w.find(b=>b.id===a);return!!b?.sessionId&&Q(b.sessionId)},[w,Q]),V=(0,f.useCallback)(b=>{let c=w.find(a=>a.id===b);c?.sessionId&&(Q(c.sessionId)?S(c.sessionId):R(c.sessionId,c.cwd||a||"",c.title))},[w,Q,R,S,a]),[W,X]=(0,f.useState)(!1),[Y,Z]=(0,f.useState)(!1),[$,_]=(0,f.useState)(!1),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(!1),[ae,af]=(0,f.useState)("tree"),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(null),[ak,al]=(0,f.useState)(0),[am,an]=(0,f.useState)(!1);(0,f.useRef)(null);let ao=(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]),ap=(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(ad(c.isGitRepo),c.isGitRepo&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&ab(b.branch)}}}catch(a){console.error("Failed to load git info:",a)}},[a]),aq=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&ap()},[ap]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aq,enabled:!!a});let ar=(0,f.useCallback)(()=>{af("status"),ah(a=>a+1),ao("explorer")},[ao]),as=(0,f.useCallback)(a=>{aj(a),al(a=>a+1),ao("explorer")},[ao]),at=(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:ao,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:ac,currentBranch:aa,onOpenWorktree:()=>Z(!0),onOpenProjectSessions:()=>X(!0),onOpenAliasManager:()=>_(!0),onBranchSwitched:ap}),am&&(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:U,onTogglePin:V,onSwitchTab:D,onCloseTab:C,onNewTab:F,onNewCodexTab:G,onNewKimiTab:H,onNewOllamaTab:I,onDragStart:M,onDragOver:N,onDrop:O,onDragEnd:P}),(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,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:L,isActive:a.id===x&&"agent"===d,onStateChange:K,onShowGitStatus:ar,onContentSearch:as,onOpenNote:at,onCreateScheduledTask:T,onOpenSession:J})},a.id))})]}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(i.g,{onClose:()=>ao("agent"),cwd:a,initialTab:ae,tabSwitchTrigger:ag,initialSearchQuery:ai,searchQueryTrigger:ak})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:at})})]}):(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:U,onTogglePin:V,onSwitchTab:D,onCloseTab:C,onNewTab:F,onNewCodexTab:G,onNewKimiTab:H,onDragStart:M,onDragOver:N,onDrop:O,onDragEnd:P}),(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,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:L,isActive:a.id===x,onStateChange:K,onCreateScheduledTask:T,onOpenSession:J})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:W,onClose:()=>X(!1),cwd:a,onSelectSession:E}),a&&ac&&(0,e.jsx)(j.x,{isOpen:Y,onClose:()=>Z(!1),cwd:a}),$&&(0,e.jsx)(l.Y,{onClose:()=>_(!1),onSave:()=>_(!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,engine:g,ollamaModel:h,onSessionId:i,onFetchTitle:j}){let[k,l]=(0,d.useState)(!1),[m,n]=(0,d.useState)(null),o=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let q=(0,d.useRef)(null),r=(0,d.useRef)(null),s=(0,d.useCallback)(()=>{let a=q.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)),q.current={messageId:c,text:""}}r.current=null},[b]),t=(0,d.useCallback)(()=>{o.current&&(o.current.abort(),o.current=null)},[]),u=(0,d.useCallback)((a,c)=>{let d=a.type;if("system"===d&&"init"===a.subtype){let b=a.session_id;i(b),p.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||"";q.current&&q.current.messageId===c?q.current.text+=a:q.current={messageId:c,text:a},r.current||(r.current=setTimeout(s,50))}return}if("assistant"===d){let d=a.message;if(d?.content){let a=d.content.filter(a=>"text"===a.type&&a.text).map(a=>a.text);if(a.length>0){let d=a.join("");b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a))}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){r.current&&(clearTimeout(r.current),r.current=null),s();let d=p.current;d&&f&&b(a=>(2===a.length&&j(d),a));let e=a.usage,g=a.total_cost_usd;e&&n({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,s,i,j,f]);return{isLoading:k,tokenUsage:m,handleSend:(0,d.useCallback)(async(a,c)=>{let d=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),i={id:`user-${Date.now()}`,role:"user",content:a,images:d};b(a=>[...a,i]),l(!0);let j=`assistant-${Date.now()}`,k={id:j,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,k]),o.current=new AbortController;try{if("ollama"===g&&!h)throw Error("Please select an Ollama model first (click the model picker above)");let b=await fetch("codex"===g?"/api/chat/codex":"kimi"===g?"/api/chat/kimi":"ollama"===g?"/api/chat/ollama":"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:p.current,images:d,cwd:f,..."ollama"===g&&h&&{model:h}}),signal:o.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 i=new TextDecoder,k="";for(;;){let{done:a,value:b}=await c.read();if(a)break;let d=(k+=i.decode(b,{stream:!0})).split("\n");for(let a of(k=d.pop()||"",d))if(a.startsWith("data: ")){let b=a.slice(6);if("[DONE]"===b)continue;try{let a=JSON.parse(b);u(a,j)}catch{}}}}catch(a){if(a instanceof Error&&"AbortError"===a.name);else{console.error("Chat error:",a);let c=a instanceof Error?a.message:e.A.t("chat.errorRetry");b(a=>a.map(a=>a.id===j?{...a,content:c,isStreaming:!1}:a))}}finally{o.current=null,l(!1),b(a=>a.map(a=>a.id===j?{...a,isStreaming:!1}:a))}},[f,g,h,b,u]),handleStop:t,abortControllerRef:o}}},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")},63161:(a,b,c)=>{"use strict";c.d(b,{m:()=>g});var d=c(48249),e=c(67484),f=c(74429);function g({currentModel:a,onModelChange:b}){let[c,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),p=(0,e.useRef)(null),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({top:0,left:0}),t=(0,e.useCallback)(async()=>{k(!0),m(null);try{let a=await fetch("/api/ollama/models");if(503===a.status){o(!0);let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json();if(404===a.status){m(b.message||"Ollama is not installed"),o(!1);return}if(!a.ok){m("Failed to start Ollama"),o(!1);return}o(!1);let c=await fetch("/api/ollama/models");if(!c.ok)return void m("Ollama started but cannot fetch models");let d=await c.json();i(d.models||[])}else if(a.ok){let b=await a.json();i(b.models||[])}else m("Failed to fetch models")}catch{m("Connection error")}finally{k(!1)}},[]),u=a?a.replace(/:latest$/,""):"Select model",v=c?(0,f.createPortal)((0,d.jsx)("div",{ref:q,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[200px] max-h-[300px] overflow-y-auto",style:{top:r.top,left:r.left},children:j||n?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),n?"Starting Ollama...":"Loading models..."]}):l?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-400",children:l}):0===h.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):h.map(c=>{var e;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),g(!1)},className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs hover:bg-brand/10 transition-colors ${c.name===a?"text-brand":"text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})}),document.body):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:p,onClick:()=>{if(!c){if(p.current){let a=0,b=0,c=p.current.parentElement;for(;c;){let d=getComputedStyle(c).transform;if(d&&"none"!==d){let d=c.getBoundingClientRect();a=d.left-c.offsetLeft,b=d.top-c.offsetTop;break}c=c.parentElement}let d=p.current.getBoundingClientRect();s({top:d.bottom+4-b,left:d.left-a})}t()}g(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-violet-500/15 text-violet-400 hover:bg-violet-500/25 transition-colors",title:"Switch Ollama model",children:[(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500 flex-shrink-0"}),(0,d.jsx)("span",{className:"truncate max-w-[120px]",children:u}),(0,d.jsx)("svg",{className:"w-3 h-3 flex-shrink-0",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"})})]}),v]})}},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})]})}},67122:(a,b,c)=>{"use strict";c.d(b,{J:()=>bf});var d,e,f,g,h,i=c(48249),j=c(67484),k=c(44384),l=c(46674),m=c(15273),n=c(47408);let o=(0,n.A)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),p=(0,n.A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),q=(0,n.A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),r=(0,n.A)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var s=c(44218),t=c(81749),u=function(a,b){return Object.defineProperty?Object.defineProperty(a,"raw",{value:b}):a.raw=b,a};(d=e||(e={}))[d.EOS=0]="EOS",d[d.Text=1]="Text",d[d.Incomplete=2]="Incomplete",d[d.ESC=3]="ESC",d[d.Unknown=4]="Unknown",d[d.SGR=5]="SGR",d[d.OSCURL=6]="OSCURL";class v{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(a){this._use_classes=a}get use_classes(){return this._use_classes}set url_allowlist(a){this._url_allowlist=a}get url_allowlist(){return this._url_allowlist}set escape_html(a){this._escape_html=a}get escape_html(){return this._escape_html}set boldStyle(a){this._boldStyle=a}get boldStyle(){return this._boldStyle}set faintStyle(a){this._faintStyle=a}get faintStyle(){return this._faintStyle}set italicStyle(a){this._italicStyle=a}get italicStyle(){return this._italicStyle}set underlineStyle(a){this._underlineStyle=a}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(a=>{this.palette_256.push(a)})});let a=[0,95,135,175,215,255];for(let b=0;b<6;++b)for(let c=0;c<6;++c)for(let d=0;d<6;++d){let e={rgb:[a[b],a[c],a[d]],class_name:"truecolor"};this.palette_256.push(e)}let b=8;for(let a=0;a<24;++a,b+=10){let a={rgb:[b,b,b],class_name:"truecolor"};this.palette_256.push(a)}}escape_txt_for_html(a){return this._escape_html?a.replace(/[&<>"']/gm,a=>"&"===a?"&amp;":"<"===a?"&lt;":">"===a?"&gt;":'"'===a?"&quot;":"'"===a?"&#x27;":void 0):a}append_buffer(a){var b=this._buffer+a;this._buffer=b}get_next_packet(){var a={kind:e.EOS,text:"",url:""},b=this._buffer.length;if(0==b)return a;var c=this._buffer.indexOf("\x1b");if(-1==c)return a.kind=e.Text,a.text=this._buffer,this._buffer="",a;if(c>0)return a.kind=e.Text,a.text=this._buffer.slice(0,c),this._buffer=this._buffer.slice(c),a;if(0==c){if(b<3)return a.kind=e.Incomplete,a;var d=this._buffer.charAt(1);if("["!=d&&"]"!=d&&"("!=d)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;if("["==d){this._csi_regex||(this._csi_regex=w(f||(f=u(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1b[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1b[ # CSI\n [ -~]* # anything legal\n ([\0-\x1f:]) # anything illegal\n )\n "],["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]))));let b=this._buffer.match(this._csi_regex);if(null===b)return a.kind=e.Incomplete,a;if(b[4])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;""!=b[1]||"m"!=b[3]?a.kind=e.Unknown:a.kind=e.SGR,a.text=b[2];var i=b[0].length;return this._buffer=this._buffer.slice(i),a}if("]"==d){if(b<4)return a.kind=e.Incomplete,a;if("8"!=this._buffer.charAt(2)||";"!=this._buffer.charAt(3))return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;this._osc_st||(this._osc_st=RegExp((g||(g=u(["\n (?: # legal sequence\n (\x1b\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\x06] # anything illegal\n | # alternate\n [\b-\x1a] # anything illegal\n | # alternate\n [\x1c-\x1f] # anything illegal\n )\n "],["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "]))).raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""),"g")),this._osc_st.lastIndex=0;{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}this._osc_regex||(this._osc_regex=w(h||(h=u(["\n ^ # beginning of line\n #\n \x1b]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1b]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "],["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]))));let c=this._buffer.match(this._osc_regex);if(null===c)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;a.kind=e.OSCURL,a.url=c[1],a.text=c[2];var i=c[0].length;return this._buffer=this._buffer.slice(i),a}if("("==d)return a.kind=e.Unknown,this._buffer=this._buffer.slice(3),a}}ansi_to_html(a){this.append_buffer(a);for(var b=[];;){var c=this.get_next_packet();if(c.kind==e.EOS||c.kind==e.Incomplete)break;c.kind!=e.ESC&&c.kind!=e.Unknown&&(c.kind==e.Text?b.push(this.transform_to_html(this.with_state(c))):c.kind==e.SGR?this.process_ansi(c):c.kind==e.OSCURL&&b.push(this.process_hyperlink(c)))}return b.join("")}with_state(a){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:a.text}}process_ansi(a){let b=a.text.split(";");for(;b.length>0;){let a=parseInt(b.shift(),10);if(isNaN(a)||0===a)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(1===a)this.bold=!0;else if(2===a)this.faint=!0;else if(3===a)this.italic=!0;else if(4===a)this.underline=!0;else if(21===a)this.bold=!1;else if(22===a)this.faint=!1,this.bold=!1;else if(23===a)this.italic=!1;else if(24===a)this.underline=!1;else if(39===a)this.fg=null;else if(49===a)this.bg=null;else if(a>=30&&a<38)this.fg=this.ansi_colors[0][a-30];else if(a>=40&&a<48)this.bg=this.ansi_colors[0][a-40];else if(a>=90&&a<98)this.fg=this.ansi_colors[1][a-90];else if(a>=100&&a<108)this.bg=this.ansi_colors[1][a-100];else if((38===a||48===a)&&b.length>0){let c=38===a,d=b.shift();if("5"===d&&b.length>0){let a=parseInt(b.shift(),10);a>=0&&a<=255&&(c?this.fg=this.palette_256[a]:this.bg=this.palette_256[a])}if("2"===d&&b.length>2){let a=parseInt(b.shift(),10),d=parseInt(b.shift(),10),e=parseInt(b.shift(),10);if(a>=0&&a<=255&&d>=0&&d<=255&&e>=0&&e<=255){let b={rgb:[a,d,e],class_name:"truecolor"};c?this.fg=b:this.bg=b}}}}}transform_to_html(a){let b=a.text;if(0===b.length||(b=this.escape_txt_for_html(b),!a.bold&&!a.italic&&!a.faint&&!a.underline&&null===a.fg&&null===a.bg))return b;let c=[],d=[],e=a.fg,f=a.bg;a.bold&&c.push(this._boldStyle),a.faint&&c.push(this._faintStyle),a.italic&&c.push(this._italicStyle),a.underline&&c.push(this._underlineStyle),this._use_classes?(e&&("truecolor"!==e.class_name?d.push(`${e.class_name}-fg`):c.push(`color:rgb(${e.rgb.join(",")})`)),f&&("truecolor"!==f.class_name?d.push(`${f.class_name}-bg`):c.push(`background-color:rgb(${f.rgb.join(",")})`))):(e&&c.push(`color:rgb(${e.rgb.join(",")})`),f&&c.push(`background-color:rgb(${f.rgb})`));let g="",h="";return d.length&&(g=` class="${d.join(" ")}"`),c.length&&(h=` style="${c.join(";")}"`),`<span${h}${g}>${b}</span>`}process_hyperlink(a){let b=a.url.split(":");return b.length<1||!this._url_allowlist[b[0]]?"":`<a href="${this.escape_txt_for_html(a.url)}">${this.escape_txt_for_html(a.text)}</a>`}}function w(a){return new RegExp(a.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""))}function x(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}let y=(0,j.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)(!1),h=(0,j.useCallback)(async h=>{if(h.stopPropagation(),f)await d(),g(!1),(0,t.oR)(e("toast.disconnected",{id:a}));else{await c(),g(!0);let d=`cock ${b} ${a}`;navigator.clipboard.writeText(d),(0,t.oR)(e("toast.copiedCommand",{command:d}))}},[f,a,b,c,d,e]);return(0,i.jsxs)("button",{onClick:h,className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:f?e("shortIdBadge.clickToDisconnect"):e("shortIdBadge.clickToRegister"),children:[(0,i.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${f?"bg-green-500":"bg-muted-foreground/40"}`}),a]})});var z=c(30976);let A=(0,j.lazy)(()=>c.e(4490).then(c.bind(c,54490)).then(a=>({default:a.XtermRenderer}))),B={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},C=/\x1b\[[0-9;]*m/g;function D({output:a,query:b,mode:c,currentIdx:d,matchRefs:e}){let f=(0,j.useRef)(null);f.current||(f.current=new v,f.current.use_classes=!0);let g=a.split("\n"),h=b.toLowerCase(),k=0;return e.current=[],(0,i.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:g.map((a,b)=>{let g=a.replace(C,""),j=g.toLowerCase().includes(h);if("filter"===c&&!j)return null;if(!j){let c=f.current.ansi_to_html(a);return(0,i.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=g.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(h,o);if(-1===a)break;a>m&&l.push((0,i.jsx)("span",{children:g.slice(m,a)},`t${m}`));let b=k++,c=b===d;l.push((0,i.jsx)("mark",{ref:a=>{e.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:g.slice(a,a+h.length)},`m${a}`)),o=m=a+h.length}return m<g.length&&l.push((0,i.jsx)("span",{children:g.slice(m)},`t${m}`)),(0,i.jsx)("div",{children:l},b)})})}let E=(0,j.memo)(function({commandId:a,tabId:b,projectCwd:c,command:d,output:e,exitCode:f,isRunning:g,selected:h,onSelect:n,onInterrupt:u,onStdin:w,onDelete:C,onRerun:E,timestamp:F,usePty:G,onPtyResize:H,onToggleMaximize:I,maximized:J,expandedHeight:K,bubbleContentHeight:L,onTitleMouseDown:M}){let{t:N}=(0,k.Bd)(),O=(0,j.useRef)(null),P=(0,j.useRef)(null),Q=(0,j.useRef)(!0),R=(0,j.useRef)(null),S=(0,j.useRef)(null),T=(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}`})(F),U=a&&b?x(b+a):void 0,[V,W]=(0,j.useState)(!1),[X,Y]=(0,j.useState)(""),Z=(0,j.useRef)(null),$=(0,j.useRef)(null),[_,aa]=(0,j.useState)(!1),[ab,ac]=(0,j.useState)(""),[ad,ae]=(0,j.useState)("search"),[af,ag]=(0,j.useState)(0),ah=(0,j.useRef)([]),ai=(0,j.useRef)(null),aj=(0,j.useRef)(0);(0,j.useEffect)(()=>{ai.current||(ai.current=new v,ai.current.use_classes=!0)},[]),(0,j.useLayoutEffect)(()=>{let a=P.current;if(a&&ai.current){if(e.length<aj.current&&(ai.current=new v,ai.current.use_classes=!0,aj.current=0,a.innerHTML=""),e.length>aj.current){let b=e.slice(aj.current),c=ai.current.ansi_to_html(b);aj.current=e.length,a.insertAdjacentHTML("beforeend",c)}if(O.current){let a=O.current.scrollHeight>O.current.clientHeight;W(a),a&&(O.current.scrollTop=O.current.scrollHeight)}}},[e]),(0,j.useEffect)(()=>(g&&Q.current&&O.current&&(null!==R.current&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{O.current&&(O.current.scrollTop=O.current.scrollHeight),R.current=null})),()=>{null!==R.current&&cancelAnimationFrame(R.current)}),[e,g]),(0,j.useEffect)(()=>{if(!J)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),I?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[J,I]);let ak=e?e.split("\n").length:0,al=(0,j.useCallback)(()=>{aa(!0),requestAnimationFrame(()=>$.current?.focus())},[]),am=(0,j.useCallback)(()=>{aa(!1),ac(""),ag(0),Z.current?.clearSearch()},[]),an=(0,j.useCallback)(a=>{a.trim()&&(G?Z.current?.findNext(a):ag(a=>{let b=a+1,c=ah.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(ah.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[G]),ao=(0,j.useCallback)(a=>{a.trim()&&(G?Z.current?.findPrevious(a):ag(a=>{let b=a-1;if(b>=0)return ah.current[b]?.scrollIntoView({block:"nearest"}),b;let c=ah.current.length-1;return c>=0&&ah.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[G]);(0,j.useEffect)(()=>{if(!h)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),al();return}if("Escape"===a.key&&_){a.preventDefault(),a.stopPropagation(),am();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[h,_,al,am]);let ap=J&&K?K-41:L??360;return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${J?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${J?"":h?"border-brand":"border-brand/30"}`,onClick:n,children:[J?(0,i.jsxs)("div",{onDoubleClick:()=>I?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,i.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:d}),g&&(0,i.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),N("console.runningText")]}),g&&u&&(0,i.jsx)("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,i.jsx)("button",{onClick:()=>I?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.restoreTooltip",{modKey:(0,z.Mu)()}),children:(0,i.jsx)(l.A,{className:"w-4 h-4"})})]}):(0,i.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>M?.(),onDoubleClick:a=>{a.stopPropagation(),I?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${h?"border-brand":"border-brand/30"}`,children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),U&&a&&b&&(0,i.jsx)(y,{shortId:U,type:"terminal",onRegister:()=>{fetch("/api/terminal/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tabId:b,commandId:a,command:d,projectCwd:c})}).catch(()=>{})},onUnregister:()=>{fetch("/api/terminal/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandId:a})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"font-mono text-foreground truncate",children:d}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(d),(0,t.oR)(N("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.copyCommand"),children:(0,i.jsx)(m.A,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("span",{className:"flex-1"}),V&&!g&&(0,i.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:N("console.totalLines",{count:ak})}),e&&(0,i.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=e.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,t.oR)(N("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.copyOutput"),children:(0,i.jsx)(o,{className:"w-3.5 h-3.5"})}),E&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),E()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("console.rerun"),children:(0,i.jsx)(p,{className:"w-3.5 h-3.5"})}),C&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),C()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:N("console.deleteRecord"),children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),_&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,i.jsx)(q,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,i.jsx)("input",{ref:$,value:ab,onChange:a=>{let b=a.target.value;ac(b),ag(0),G&&(b.trim()?Z.current?.findNext(b):Z.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?ao(ab):an(ab))},placeholder:N("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!G&&(0,i.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,i.jsx)("button",{onClick:()=>ae("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===ad?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:N("console.searchMode")}),(0,i.jsx)("button",{onClick:()=>ae("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===ad?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:N("console.filterMode")})]}),(0,i.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,i.jsx)("button",{onClick:()=>ao(ab),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.prevShiftEnter"),children:(0,i.jsx)(r,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("button",{onClick:()=>an(ab),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:N("console.nextEnter"),children:(0,i.jsx)(s.A,{className:"w-3.5 h-3.5"})})]}),(0,i.jsx)("button",{onClick:am,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),G?(0,i.jsx)("div",{style:{height:ap,overflow:"hidden"},children:(0,i.jsx)(j.Suspense,{fallback:(0,i.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:ap},children:N("console.loadingTerminal")}),children:(0,i.jsx)(A,{ref:Z,output:e,isRunning:g,onInput:w,onResize:H,maximized:J,height:ap})})}):(0,i.jsx)("div",{ref:O,className:"overflow-auto px-4 py-2",style:{height:ap},onScroll:()=>{if(O.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=O.current;Q.current=b-a-c<50}},children:_&&ab.trim()?(0,i.jsx)(D,{output:e,query:ab,mode:ad,currentIdx:af,matchRefs:ah}):(0,i.jsx)("pre",{ref:P,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),g&&!J&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),G?(0,i.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:N("console.clickToInput")}):w?(0,i.jsx)("input",{ref:S,value:X,onChange:a=>Y(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=B[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),w(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w(X+"\n"),Y("")),"Tab"===a.key&&(a.preventDefault(),w(" "))},placeholder:N("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:N("console.runningText")}),u&&(0,i.jsx)("button",{onClick:u,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),T&&(0,i.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:T})]}),!g&&void 0!==f&&!J&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===f?"bg-green-500":"bg-red-500"}`}),(0,i.jsx)("span",{children:N("console.exitCode",{code:f})}),(0,i.jsx)("span",{className:"flex-1"}),T&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:T})]})]})})});var F=c(59347),G=c(24520);function H({cwd:a,tabId:b,onClose:c,onSave:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)({}),[h,m]=(0,j.useState)(""),[n,o]=(0,j.useState)(""),[p,q]=(0,j.useState)(!0),r=()=>{h.trim()&&(g(a=>({...a,[h.trim()]:n})),m(""),o(""))},s=async()=>{try{(await fetch("/api/terminal/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,env:f})})).ok&&(d(f),c())}catch(a){console.error("Failed to save env:",a)}};return(0,i.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,i.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,i.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:e("envManager.title")}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?e("envManager.tabScope"):e("envManager.globalScope")})]}),(0,i.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-5 h-5"})})]}),(0,i.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,i.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:e("common.loading")}):(0,i.jsxs)("div",{className:"space-y-3",children:[Object.entries(f).map(([a,b])=>(0,i.jsxs)("div",{className:"flex items-start gap-2",children:[(0,i.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,i.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void g(b=>({...b,[a]:c}))},placeholder:e("envManager.valuePlaceholder"),className:"flex-1 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,i.jsx)("button",{onClick:()=>{g(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,i.jsx)(F.A,{className:"w-4 h-4"})})]},a)),(0,i.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,i.jsx)("input",{type:"text",value:h,onChange:a=>m(a.target.value),placeholder:e("envManager.varNamePlaceholder"),className:"flex-1 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(),r())}}),(0,i.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:e("envManager.varValuePlaceholder"),className:"flex-1 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(),r())}}),(0,i.jsx)("button",{onClick:r,disabled:!h.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,i.jsx)(G.A,{className:"w-4 h-4"})})]}),0===Object.keys(f).length&&(0,i.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:e("envManager.noVars")})]})}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,i.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:e("common.cancel")}),(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:e("common.save")})]})]})})}var I=c(94924);let J=(0,n.A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),K=(0,n.A)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),L=(0,n.A)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),M=(0,n.A)("variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]),N=(0,n.A)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var O=c(69005);let P=null,Q="",R=0,S=null,T=!1,U=new Map,V=null,W=null;function X(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){V&&(V(b.commands),V=null);return}let d=b.commandId;if(!d)return;let e=U.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&U.delete(d)}}function Y(a){P?.readyState===WebSocket.OPEN&&P.send(JSON.stringify(a))}function Z(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);Q===c&&P||(function(){if(T=!0,S&&(clearTimeout(S),S=null),P){let a=P;P=null,a.close()}U.clear(),V&&(V([]),V=null),W=null,Q="",R=0}(),T=!1,Q=c,function a(){if(T||!Q)return;let b=new WebSocket(Q);P=b,b.onopen=()=>{for(let a of(R=0,U.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=X,b.onclose=()=>{if(P!==b||(P=null,T))return;S&&clearTimeout(S);let c=Math.min(1e3*Math.pow(1.5,R),1e4);R++,S=setTimeout(a,c)},b.onerror=()=>{}}())}function $(){return new Promise((a,b)=>{if(P?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{P?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(d),a())},50),d=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function _(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:i,rows:j,onData:k,onError:l}=a;Z(f);try{await $()}catch{l("WebSocket connection failed");return}U.delete(d),U.set(d,{onData:k,onError:l}),Y({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...i?{cols:i,rows:j}:{}})}async function aa(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;Z(c);try{await $()}catch{e("WebSocket connection failed");return}U.set(b,{onData:d,onError:e}),Y({type:"attach",commandId:b})}function ab(a,b){Y({type:"stdin",commandId:a,data:b})}function ac(a,b,c){Y({type:"resize",commandId:a,cols:b,rows:c})}function ad(a){Y({type:"interrupt",pid:a})}async function ae(a){try{Z(a);try{await $()}catch{return[]}return await new Promise(a=>{V=b=>{a(b)},Y({type:"running"}),setTimeout(()=>{V&&(V=null,a([]))},3e3)})}finally{W=null}}let af=new Map;function ag(a){af.set(a.type,a)}function ah(a){return af.get(a)}function ai(a){for(let b of af.values())if(b.match(a))return b;return null}var aj=c(74955);async function ak(a){let b=(0,aj.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function al({url:a,id:b,selected:c,maximized:d,expandedHeight:e,bubbleContentHeight:f,onSelect:g,onClose:h,onToggleMaximize:l,onNewTab:m,timestamp:n,onTitleMouseDown:o,initialSleeping:p,onSleep:q,onWake:r}){let{t:s}=(0,k.Bd)(),[u,v]=(0,j.useState)(!1),[w,A]=(0,j.useState)(null),[B,C]=(0,j.useState)(a),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)(p??!1),H=(0,j.useRef)(null),I=(0,j.useRef)(null),J=(0,j.useRef)(null);(0,j.useRef)(!0),(0,j.useCallback)(()=>{F||(G(!0),E(null),q?.(b))},[F,b,q]),(0,j.useCallback)(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]);let{shortId:K,connected:L,connect:M,disconnect:N}=function(a,b,c){let d=(0,j.useMemo)(()=>x(a),[a]),[e,f]=(0,j.useState)(!1),g=(0,j.useRef)(null);(0,j.useRef)([]),(0,j.useRef)(null),(0,j.useRef)(!1),(0,j.useRef)(c);let h=(0,j.useRef)([]);(0,j.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=g.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let i=(0,j.useCallback)(()=>e&&g.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{h.current.push(a),e||f(!0)}),[e]);return{shortId:d,connected:e,connect:i,disconnect:(0,j.useCallback)(()=>{f(!1)},[])}}(b,J,!!D&&!F&&!u);(0,j.useRef)(L).current=L;let O=(0,j.useCallback)(()=>{G(!1),r?.(b);let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?ak(a).then(()=>E(c)):E(c)},[a,b,r]),P=(0,j.useCallback)(()=>v(!1),[]),Q=(0,j.useCallback)(()=>{v(!1),A(s("browser.pageLoadFailed"))},[]),R=(0,j.useCallback)(()=>{if(F)return void O();let a=I.current?.querySelector("iframe");if(a&&D){v(!0),A(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[F,O,D]),S=(0,j.useCallback)(()=>{B&&window.open(B,"_blank")},[B]),T=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a}}(B);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
8
8
  relative transition-colors cursor-pointer
9
9
  ${d?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
10
10
  ${d?"":c?"border-brand":"border-brand/30"}`,onClick:d?void 0:g,children:[d?(0,i.jsxs)("div",{onDoubleClick:l,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,i.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),K&&(0,i.jsx)(y,{shortId:K,type:"browser",onRegister:()=>M(),onUnregister:async()=>{N(),await fetch("/api/browser/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:K})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:B||s("browser.blankPage")}),B&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(B),(0,t.oR)(s("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.copyUrl"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("span",{className:"flex-1"}),u&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,i.jsx)("button",{onClick:R,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("common.refresh"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("button",{onClick:S,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.openInNewWindow"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,i.jsx)("button",{onClick:l,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.exitMaximize",{modKey:(0,z.Mu)()}),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,i.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>o?.(),onDoubleClick:a=>{a.stopPropagation(),l()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing