specrails-desktop 2.26.1 → 2.26.2

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 (64) hide show
  1. package/client/dist/assets/{ActivityFeedPage-C1LftFSE.js → ActivityFeedPage-bDe4VitF.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-B5prW-V0.js → AgentBrowserCapture-DQyeEm2V.js} +1 -1
  3. package/client/dist/assets/{AgentModeCodePane-b6UmdjwB.js → AgentModeCodePane-Ci39DcOo.js} +2 -2
  4. package/client/dist/assets/{AgentModeJobsPane-DW3Wj5oi.js → AgentModeJobsPane-C-g1WNVG.js} +1 -1
  5. package/client/dist/assets/{AgentsPage-DBMnhdlq.js → AgentsPage-BWgglK7V.js} +1 -1
  6. package/client/dist/assets/{AnalyticsPage-DjFf1OxU.js → AnalyticsPage-Da21wWWw.js} +1 -1
  7. package/client/dist/assets/{BarChart-nmDbbUiR.js → BarChart-BiLTq3uC.js} +1 -1
  8. package/client/dist/assets/{CodePage-DHd46Sm7.js → CodePage-BUcAp7SC.js} +1 -1
  9. package/client/dist/assets/{DesktopAnalyticsPage-ee0bpk-F.js → DesktopAnalyticsPage-COkzgMmd.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-CGUzB1zX.js → DocsDialog-PZHMN18B.js} +1 -1
  11. package/client/dist/assets/{DocsPage-96iws84I.js → DocsPage-D3fChfkj.js} +1 -1
  12. package/client/dist/assets/{ExportDropdown-Dzk2Lkxw.js → ExportDropdown-DDhJH-Jr.js} +1 -1
  13. package/client/dist/assets/{IntegrationsPage-Bta2lAhq.js → IntegrationsPage-F87uxxVH.js} +1 -1
  14. package/client/dist/assets/{InteractiveJobComposer-B9S_ZGJS.js → InteractiveJobComposer-DqDCiCa0.js} +1 -1
  15. package/client/dist/assets/{JobDetailModal-DhrwU2z0.js → JobDetailModal-BWJR60fi.js} +1 -1
  16. package/client/dist/assets/{JobDetailPage-BnhoXkql.js → JobDetailPage-CjWE_jyd.js} +1 -1
  17. package/client/dist/assets/{JobsPage-BBT9fyhg.js → JobsPage-LmnXkyCa.js} +1 -1
  18. package/client/dist/assets/{LoopBuilderPage-5ucN9Hq9.js → LoopBuilderPage-DsLLrtHa.js} +1 -1
  19. package/client/dist/assets/{LoopPreviewModal-wKAts-Wf.js → LoopPreviewModal-C-fDEgnu.js} +1 -1
  20. package/client/dist/assets/{LoopsPage-COyxf6Pa.js → LoopsPage-DDNO9h9T.js} +1 -1
  21. package/client/dist/assets/{ProjectSettingsDialog-CcToBI-Z.js → ProjectSettingsDialog-CX854C8e.js} +1 -1
  22. package/client/dist/assets/{TemplatePreviewModal-_Dy6ceXg.js → TemplatePreviewModal-DcHFbLA8.js} +1 -1
  23. package/client/dist/assets/{agent-Cg49-TGZ.js → agent-BI6vr-To.js} +1 -1
  24. package/client/dist/assets/{agent-DgDtg-0Y2.js → agent-BUGXI3Ok2.js} +1 -1
  25. package/client/dist/assets/{agent-DolxzTol.js → agent-Bph_-xt7.js} +1 -1
  26. package/client/dist/assets/{agent-Bxb9RRNW.js → agent-Bvy2Csyd.js} +1 -1
  27. package/client/dist/assets/{agent-gFi-qvxO2.js → agent-Bwkyg2oX2.js} +1 -1
  28. package/client/dist/assets/{agent-_tfCgFUk.js → agent-CLCyDaZh.js} +1 -1
  29. package/client/dist/assets/{agent-DwDR2Exf2.js → agent-Cqs14QMr2.js} +1 -1
  30. package/client/dist/assets/{agent-BmH52J4j.js → agent-DJ0EBUuP.js} +1 -1
  31. package/client/dist/assets/{brain-BJ2Gd98j.js → brain-BBNUUrUI.js} +1 -1
  32. package/client/dist/assets/dashboard-BjjS1OrL.js +1 -0
  33. package/client/dist/assets/dashboard-Bk6oSk1H2.js +1 -0
  34. package/client/dist/assets/dashboard-BrH-GdOg2.js +1 -0
  35. package/client/dist/assets/dashboard-BurhUI8_.js +1 -0
  36. package/client/dist/assets/dashboard-C6w0rICe.js +1 -0
  37. package/client/dist/assets/dashboard-CAUnfDQL2.js +1 -0
  38. package/client/dist/assets/dashboard-C_ljpeYO.js +1 -0
  39. package/client/dist/assets/dashboard-D6OqDdj6.js +1 -0
  40. package/client/dist/assets/{dist-js-CXAsO0Z8.js → dist-js-BxjTIvdT.js} +1 -1
  41. package/client/dist/assets/{dist-js-D7smLA35.js → dist-js-DdP_Gl3p.js} +1 -1
  42. package/client/dist/assets/index-Dw1N2-ci.js +156 -0
  43. package/client/dist/assets/{lib-BIHmUkcn.js → lib-BviHZ_gK.js} +1 -1
  44. package/client/dist/assets/{upload-xdQuJvXN.js → upload-CRuuzzvp.js} +1 -1
  45. package/client/dist/assets/{value-Bk2f9AUg.js → value-CIr5hDMt.js} +1 -1
  46. package/client/dist/index.html +3 -3
  47. package/package.json +1 -1
  48. package/server/dist/mcp/tools/rails.js +2 -0
  49. package/server/dist/pr-publisher.js +17 -15
  50. package/server/dist/project-git.js +57 -0
  51. package/server/dist/rail-isolated-launch.js +22 -2
  52. package/server/dist/rail-pr-decision.js +69 -1
  53. package/server/dist/rail-worktree-release.js +25 -0
  54. package/server/dist/rail-worktrees-store.js +2 -2
  55. package/server/dist/rails-router.js +89 -9
  56. package/client/dist/assets/dashboard-90r0QcUc2.js +0 -1
  57. package/client/dist/assets/dashboard-B0C6mJP-.js +0 -1
  58. package/client/dist/assets/dashboard-BOx0FR1L2.js +0 -1
  59. package/client/dist/assets/dashboard-BcjUOLJr.js +0 -1
  60. package/client/dist/assets/dashboard-C27kNpjn.js +0 -1
  61. package/client/dist/assets/dashboard-DJAj2EbH.js +0 -1
  62. package/client/dist/assets/dashboard-DNd1Gobs.js +0 -1
  63. package/client/dist/assets/dashboard-DZWrDAYm2.js +0 -1
  64. package/client/dist/assets/index-B3ejvKSt.js +0 -156
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-C9J2ikJK.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-C3B0tp2x.js","assets/editor-Br_kD0ds.css","assets/workers-U0UXyLUf.js","assets/monaco.contribution-Desq7oq4.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{A as n,Bt as r,Cn as i,Gn as a,Gt as o,Hn as s,Ht as c,Kn as l,Kt as u,Ln as d,Q as f,Rn as p,Sn as m,Ut as h,Wn as g,Yt as _,Z as v,an as y,at as b,bt as x,g as S,gn as C,in as w,j as T,mt as E,on as D,qt as O,rt as k,vn as A,wn as j,y as ee,yn as M}from"./index-B3ejvKSt.js";var N=C(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),P=C(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),F=e(l(),1),I=e(a(),1);function L(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function R(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function te(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ne=(e,t)=>Math.abs(e-t)<1.01,re=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},z,B=()=>{if(z!==void 0)return z;if(typeof navigator>`u`)return z=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return z=!0;let e=navigator.maxTouchPoints;return z=navigator.platform===`MacIntel`&&e!==void 0&&e>0},V=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},H=e=>e,U=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},ie=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(V(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(V(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},W={passive:!0},G=typeof window>`u`?!0:`onscrollend`in window,K=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&G,o=0,s=a?null:re(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,W),a&&r.addEventListener(`scrollend`,u,W),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},q=(e,t)=>K(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ae=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},oe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:H,rangeExtractor:U,onChange:()=>{},measureElement:J,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,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=R(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{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(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!B()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,W),e.addEventListener(`touchend`,n,W),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,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??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=R(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=R(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=L(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=R(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=R(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(B()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=R(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return te(t[Y(0,t.length-1,r?e=>n[e*2]:e=>te(t[e]).start,e)])},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 e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&ne(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var ce=typeof document<`u`?F.useLayoutEffect:F.useEffect;function le({useFlushSync:e=!0,...t}){let n=F.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,I.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=F.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:ie,observeElementOffset:q,scrollToFn:ae,...e})}var X=i(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:i}){let{t:a}=p(`code`),{activeProjectId:o}=A(),{openTicketDetail:s}=ee(),{registerHandler:l,unregisterHandler:u}=m(),[d,f]=(0,F.useState)(()=>{if(!o)return`touched-by-ai`;try{let e=localStorage.getItem(Z(o));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,F.useEffect)(()=>{if(o)try{localStorage.setItem(Z(o),d)}catch{}},[d,o]);let[g,_]=(0,F.useState)(()=>{if(!o)return new Set;try{let e=localStorage.getItem(de(o));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,F.useEffect)(()=>{if(o)try{localStorage.setItem(de(o),JSON.stringify([...g]))}catch{}},[g,o]);let v=(0,F.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),b=(0,F.useCallback)(()=>{_(new Set)},[]),{data:x,refresh:S,isFirstLoad:C}=M({namespace:`code-tree:${d}:${d===`touched-by-ai`?`${n??`all-jobs`}:${i??`all-specs`}`:`all`}`,projectId:o,initialValue:[],fetcher:(0,F.useCallback)(async()=>{let e=[],t=null;for(let r=0;r<100;r+=1){let r=new URLSearchParams({withProvenance:`1`,filter:d});d===`touched-by-ai`&&n&&r.set(`jobId`,n),d===`touched-by-ai`&&typeof i==`number`&&r.set(`ticketId`,String(i)),t&&r.set(`cursor`,t);let a=await fetch(`${j()}/code/tree?${r.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[d,n,i])}),w=(0,F.useRef)(o);(0,F.useEffect)(()=>{w.current=o},[o]),(0,F.useEffect)(()=>{if(!o)return;let e=`code-tree-${o}`;return l(e,e=>{let t=e;t.projectId===w.current&&t.type===`file.provenance_updated`&&S()}),()=>u(e)},[o,l,u,S]);let T=(0,F.useRef)(null),E=(0,F.useMemo)(()=>(x??[]).filter(e=>!ge(e.path,g)),[x,g]),O=(0,F.useCallback)(()=>{_(new Set((x??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[x]),P=ue({count:E.length,getScrollElement:()=>T.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),I=E.length===0,L=(0,F.useMemo)(()=>(x??[]).filter(e=>e.kind===`file`).length,[x]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`touched-by-ai`),className:k(`px-2 py-1 rounded-md transition-colors`,d===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`touched-by-ai`,children:a(n?`tree.jobFiles`:i?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:k(`px-2 py-1 rounded-md transition-colors`,d===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`all`,children:a(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:O,title:a(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.collapseAll`),children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:b,title:a(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.expandAll`),children:(0,X.jsx)(D,{className:`w-3.5 h-3.5`})})]}),d===`touched-by-ai`&&L>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:a(`tree.touchedCount`,{count:L})})})]}),I&&C?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:a(`tree.loadingFiles`)})}):I&&d===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:a(`tree.showAllFiles`)})]}):I?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:a(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:T,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let i=E[n.index],o=fe(i.path)*12,l=i.kind===`file`&&i.path===t,u=i.provenance?.createdByTicketId,d=i.provenance?.modifiedByTicketIds??[],f=i.provenance?.latest??null,p=me(f?.jobId),m=he(f?.kind),_=i.kind===`dir`,b=_&&g.has(i.path),x=i.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:k(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,l&&`bg-muted text-foreground`),onClick:()=>{_?v(i.path):e(i.path)},role:`button`,tabIndex:0,"aria-expanded":_?!b:void 0,"data-testid":`file-tree-row-${i.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:o},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,X.jsxs)(X.Fragment,{children:[b?(0,X.jsx)(y,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(D,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),b?(0,X.jsx)(c,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(h,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(N,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(i.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&x>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:a(`tree.folderTouched`,{count:x}),children:x}),!_&&m&&(0,X.jsx)(`span`,{className:k(`text-[10px] px-1.5 py-0.5 rounded`,f?.kind===`created`&&`bg-accent-success/15 text-accent-success`,f?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,f?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:f?.kind===`created`?a(`tree.latestTitleCreated`):f?.kind===`deleted`?a(`tree.latestTitleDeleted`):a(`tree.latestTitleModified`),children:a(`action.${m}`)}),!_&&p&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:a(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,X.jsx)(r,{className:`h-3 w-3`}),p]}),!_&&typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(u)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${u}`,title:a(`tree.createdBySpec`,{id:u}),children:[`#`,u]}),!_&&d.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:a(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},i.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=p(`code`),o=S(),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),f=(0,F.useRef)(e),m=(0,F.useRef)(n),h=(0,F.useRef)(o),g=(0,F.useRef)(r),_=(0,F.useRef)(i);return(0,F.useEffect)(()=>{f.current=e},[e]),(0,F.useEffect)(()=>{m.current=n},[n]),(0,F.useEffect)(()=>{h.current=o},[o]),(0,F.useEffect)(()=>{g.current=r},[r]),(0,F.useEffect)(()=>{_.current=i},[i]),(0,F.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=Ee(t,h.current),r=t.editor.create(s.current,{value:f.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{_.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,F.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,F.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,F.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,F.useEffect)(()=>{let e=l.current;if(!e)return;let t=Ee(e,o);e.editor.setTheme(t)},[o]),u?(0,X.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,X.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,X.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,F.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=p(`code`);return(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,X.jsx)(ke,{content:e,language:t,readOnly:n,onChange:r})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=p(`code`),{openTicketDetail:c}=ee();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let l=je(t.generatedAt,s.language),u=t.triggeredBy?.ticketId,d=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,X.jsx)(`span`,{className:k(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(u),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,u]}),d.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),l&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:l})]})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(T,{remarkPlugins:[n],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?u:e===`deleted`?O:o}function Ie({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=p(`code`),{activeProjectId:a}=A(),{registerHandler:o,unregisterHandler:s}=m(),[c,l]=(0,F.useState)(null),[u,f]=(0,F.useState)(!1),[h,g]=(0,F.useState)({}),_=(0,F.useRef)(a);(0,F.useEffect)(()=>{_.current=a},[a]);let v=(0,F.useRef)(e);(0,F.useEffect)(()=>{v.current=e},[e]);let y=(0,F.useRef)(0),b=(0,F.useCallback)(async()=>{let t=++y.current;try{let n=await fetch(`${j()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==y.current)return;if(!n.ok){l([]),f(!0);return}let r=await n.json();if(t!==y.current)return;l(Array.isArray(r.story)?r.story:[]),f(!1)}catch{t===y.current&&(l([]),f(!0))}},[e,a]);(0,F.useEffect)(()=>{l(null),g({}),b()},[b]),(0,F.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return o(e,e=>{let t=e;t.projectId===_.current&&t.path===v.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&b()}),()=>s(e)},[a,o,s,b]);let x=(0,F.useCallback)(async(t,n)=>{g(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${j()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),a=await r.json().catch(()=>({}));if(a.skipped===`budget`){g(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){d.error(i(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n});return}await b(),g(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{d.error(i(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n})}},[b,e,i]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:c===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):u?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):c.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:c.map(e=>(0,X.jsx)(Le,{entry:e,state:h[e.provenanceId],onOpenTicket:n,onFilterJob:r,onExplain:t=>{x(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=p(`code`),o=Fe(e.kind),s=e.ticket?.status??null,c=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:a(`story.spec`,{ticketId:e.ticketId}),l=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),a(`story.kindLabel.${e.kind}`)]}),c!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:a(`story.openSpec`,{ticketId:e.ticketId}),children:c}),c==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`story.unknownSpec`)}),s&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[s]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:s}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:a(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:a(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:a(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:a(`story.fallback.${l}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:a(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:a(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(E,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),a(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&r&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:i}=p(`code`),{activeProjectId:a}=A(),{openTicketDetail:o}=ee(),{registerHandler:s,unregisterHandler:c}=m(),l=f({allowMove:!1}),u=(0,F.useRef)(null),[h,g]=(0,F.useState)(null),[_,y]=(0,F.useState)(!0),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(!1),[T,E]=(0,F.useState)(()=>Xe(a)),[O,k]=(0,F.useState)(()=>Je(a)),[M,N]=(0,F.useState)(()=>Qe(a)),[P,I]=(0,F.useState)(()=>Ke(a)),L=(0,F.useRef)(a);(0,F.useEffect)(()=>{L.current=a},[a]);let R=(0,F.useRef)(e);(0,F.useEffect)(()=>{R.current=e},[e]),(0,F.useEffect)(()=>{let e=u.current?.clientHeight||window.innerHeight;E(Xe(a)),k(et(Je(a),e)),N(Qe(a)),I(Ke(a))},[a]);let te=(0,F.useCallback)(e=>{let t=e.clientY,n=O,r=u.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){k(et(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),k(e=>{let t=et(e,r);return Ye(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,O]),ne=(0,F.useCallback)(()=>{let e=et(ze,u.current?.clientHeight||window.innerHeight);k(e),Ye(a,e)},[a]),re=(0,F.useCallback)(()=>{E(e=>{let t=!e;return Ze(a,t),t})},[a]),z=(0,F.useCallback)(()=>{N(e=>{let t=!e;return $e(a,t),t})},[a]),B=(0,F.useCallback)(e=>{I(e),qe(a,e)},[a]);(0,F.useEffect)(()=>{x(!1),C(!1),K(`preview`),J(!1)},[e]);let V=(0,F.useRef)(0),H=(0,F.useCallback)(async()=>{let t=++V.current;y(!0);try{let n=await fetch(`${j()}/code/file?path=${encodeURIComponent(e)}`);if(t!==V.current)return;if(!n.ok){g(null);return}let r=await n.json();if(t!==V.current)return;g(r)}catch{t===V.current&&g(null)}finally{t===V.current&&y(!1)}},[e,a]);(0,F.useEffect)(()=>{H()},[H]),(0,F.useEffect)(()=>{if(!a)return;let e=`code-file-${a}`;return s(e,e=>{let t=e;t.projectId===L.current&&(t.type===`file.summary_updated`&&t.path===R.current?(x(!1),H()):t.type===`file.summary_failed`&&t.path===R.current?(d.error(t.reason??i(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===R.current&&(t.reason&&d(i(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>c(e)},[a,s,c,H,i]);let U=(0,F.useCallback)(async t=>{x(!0);try{let n=await fetch(`${j()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;d.error(e?i(`summary.skipped`,{reason:e}):i(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),C(!0);return}if(r.skipped){x(!1),d(i(`summary.skipped`,{reason:r.skipped}));return}await H(),x(!1)}catch{x(!1),d.error(i(`summary.generationFailed`))}},[H,e,i]),ie=(0,F.useCallback)(async()=>{let t=h?.absolutePath??e;try{await navigator.clipboard?.writeText(t),d.success(i(`viewer.pathCopied`))}catch{d.error(i(`viewer.copyPathFailed`))}},[h,e,i]),W=(0,F.useMemo)(()=>Re(e,h?.language),[e,h?.language]),[G,K]=(0,F.useState)(`preview`),[q,J]=(0,F.useState)(!1),[ae,oe]=(0,F.useState)(``),[Y,se]=(0,F.useState)(!1),ce=h?.content!==void 0&&!h.binary&&!h.tooLarge&&h.reason!==`not-found`,le=(0,F.useCallback)(()=>{oe(h?.content??``),K(`raw`),J(!0)},[h]),ue=(0,F.useCallback)(async()=>{se(!0);try{let t=await fetch(`${j()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:ae})});if(!t.ok){let e=await t.json().catch(()=>({}));d.error(e.error??i(`viewer.saveFailed`));return}d.success(i(`viewer.saved`)),J(!1),H()}catch{d.error(i(`viewer.saveFailed`))}finally{se(!1)}},[e,ae,i,H]),Z=h?.summary??null,de=!!h?.summaryStale,fe=h?.provenance??[],pe=h?.reason===`not-found`,me=pe?i(`summary.reason.missing`):h?.binary?i(`summary.reason.binary`):h?.tooLarge?i(`summary.reason.tooLarge`):null;return(0,F.useEffect)(()=>{if(n){if(_&&!h){n(null);return}return n({hasSummary:!!Z,regenerating:b,disabledReason:me,onClick:()=>U(!1)}),()=>n(null)}},[h,U,_,n,b,Z,me]),(0,F.useEffect)(()=>{if(r){if(_&&!h){r(null);return}return r({onClick:ie}),()=>r(null)}},[ie,h,_,r]),_&&!h?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:u,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[T?(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(D,{className:`h-3.5 w-3.5`}),i(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:b,generateDisabledReason:me,onCollapse:re}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:W&&h?.content!==void 0&&!h.binary&&!h.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":i(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`preview`),"aria-pressed":G===`preview`,className:G===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`raw`),"aria-pressed":G===`raw`,className:G===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!q&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.edit`)}),q&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:i(`actions.cancel`,{ns:`common`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:i(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:i(`viewer.missingFile`)}):h?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:i(`viewer.binaryFile`)}):h?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:i(`viewer.tooLarge`,{size:Math.round((h.sizeBytes??0)/1024/1024)})}):h?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`viewer.noContent`)}):q?(0,X.jsx)(Ae,{content:ae,language:h.language??`plaintext`,readOnly:!1,onChange:oe}):W&&G===`preview`?(0,X.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(Ne,{content:h.content})}):(0,X.jsx)(Ae,{content:h.content,language:h.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":i(`history.resize`),onPointerDown:M?void 0:te,onDoubleClick:M?void 0:ne,className:M?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:M?void 0:i(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i(P===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!M&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":i(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`story`),"aria-pressed":P===`story`,className:P===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`log`),"aria-pressed":P===`log`,className:P===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:z,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[M?(0,X.jsx)(w,{className:`h-3.5 w-3.5`}):(0,X.jsx)(D,{className:`h-3.5 w-3.5`}),i(M?`history.show`:`history.hide`)]})]})]}),!M&&(P===`story`?(0,X.jsx)(Ie,{relPath:e,height:O,onOpenTicket:o,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:o,onFilterJob:t,height:O}))]}),S&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:l.guardBackdrop(()=>C(!1)),children:[(0,X.jsxs)(`div`,{ref:l.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:l.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:i(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),U(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:i(`common:actions.confirm`)})]})]}),(0,X.jsx)(v,{handles:l.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:i}){let{t:a}=p(`code`),[s,c]=(0,F.useState)(null),[l,d]=(0,F.useState)({});if(e.length===0)return null;async function f(e,t){if(s===t){c(null);return}if(c(t),!(!e.jobId||l[t])){d(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${j()}/code/diff?${n.toString()}`);if(r.status===404){d(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();d(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{d(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:i},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,i)=>{let c=e.kind===`created`?u:e.kind===`deleted`?O:o,d=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),p=`${e.jobId??`job`}:${e.path}:${e.at}:${i}`,m=l[p];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:d}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:d}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(e,p),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:a(`history.diff`)}),typeof e.ticketId==`number`&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:a(`history.openSpec`,{ticketId:e.ticketId}),children:a(`history.specChip`,{ticketId:e.ticketId})})]}),(0,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),s===p&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:m===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):m===`missing`||!m?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,X.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[m.patch,m.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},p)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=p(`code`),{activeProjectId:i}=A(),[a]=g(),o=s(),c=(0,F.useRef)(null),[l,u]=(0,F.useState)(e?t:a.get(`path`)),d=(0,F.useCallback)(e=>{u(e),n?.(e)},[n]),[f,m]=(0,F.useState)(null),[h,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(()=>st(i)),[b,x]=(0,F.useState)(null),[S,C]=(0,F.useState)(null),w=e?b:a.get(`jobId`),T=(0,F.useMemo)(()=>{if(e)return S;let t=a.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,a]),[E,D]=(0,F.useState)(T==null?``:String(T));(0,F.useEffect)(()=>{if(e)return;let t=a.get(`path`);t!==l&&u(t)},[a,e]),(0,F.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,F.useEffect)(()=>{let e=c.current?.clientWidth||window.innerWidth;y($(st(i),e))},[i]),(0,F.useEffect)(()=>{let e=c.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&y(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,F.useCallback)(e=>{let t=e.clientX,n=v,r=c.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){y($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),y(e=>{let t=$(e,r);return ct(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[i,v]),k=(0,F.useCallback)(()=>{let e=$(rt,c.current?.clientWidth||window.innerWidth);y(e),ct(i,e)},[i]),j=(0,F.useCallback)(t=>{if(d(t),e)return;let n=new URLSearchParams(a);n.set(`path`,t),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a,d]),ee=(0,F.useCallback)(t=>{if(e){x(t),C(null);return}let n=new URLSearchParams(a);n.set(`jobId`,t),n.delete(`ticketId`),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a]),M=(0,F.useCallback)(()=>{if(e){x(null),C(null);return}let t=new URLSearchParams(a);t.delete(`jobId`),t.delete(`ticketId`),o({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,o,a]),N=(0,F.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){M();return}if(e){C(n),x(null);return}let r=new URLSearchParams(a);r.set(`ticketId`,String(n)),r.delete(`jobId`),o({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[M,e,o,a]);return(0,X.jsxs)(`div`,{ref:c,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,X.jsx)(_e,{onOpenFile:j,selectedPath:l,filterJobId:w,filterTicketId:T},i??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:w,ticketId:T,ticketInput:E,onTicketInputChange:D,onApplyTicket:N,onClear:M,summaryAction:f,copyPathAction:h}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:j}),l?(0,X.jsx)(tt,{relPath:l,onFilterJob:ee,onSummaryActionChange:m,onCopyPathActionChange:_}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:c}=p(`code`),l=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(P,{className:`h-3.5 w-3.5`}),c(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":l===`all`,className:l===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.allAi`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":l===`spec`,className:l===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.spec`)}),(0,X.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:c(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,X.jsx)(`div`,{className:`flex-1`}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.copyFilePath`)}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?c(`toolbar.regenerateSummary`):c(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:o.disabledReason?c(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,X.jsx)(x,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?c(`toolbar.regenerating`):c(`toolbar.regenerateSummary`):o.regenerating?c(`toolbar.generating`):c(`toolbar.generateSummary`)]}),l===`job-context`&&(0,X.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:c(`toolbar.jobContext`)}),(e||t)&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(b,{className:`h-3.5 w-3.5`}),c(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=p(`code`),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${j()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,F.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),s=i?.length??0;return(0,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,X.jsx)(n===`created`?u:n===`deleted`?O:o,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{lt as default};
2
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{A as n,Bt as r,Cn as i,Gn as a,Gt as o,Hn as s,Ht as c,Kn as l,Kt as u,Ln as d,Q as f,Rn as p,Sn as m,Ut as h,Wn as g,Yt as _,Z as v,an as y,at as b,bt as x,g as S,gn as C,in as w,j as T,mt as E,on as D,qt as O,rt as k,vn as A,wn as j,y as ee,yn as M}from"./index-Dw1N2-ci.js";var N=C(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),P=C(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),F=e(l(),1),I=e(a(),1);function L(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function R(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function te(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ne=(e,t)=>Math.abs(e-t)<1.01,re=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},z,B=()=>{if(z!==void 0)return z;if(typeof navigator>`u`)return z=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return z=!0;let e=navigator.maxTouchPoints;return z=navigator.platform===`MacIntel`&&e!==void 0&&e>0},V=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},H=e=>e,U=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},ie=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(V(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(V(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},W={passive:!0},G=typeof window>`u`?!0:`onscrollend`in window,K=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&G,o=0,s=a?null:re(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,W),a&&r.addEventListener(`scrollend`,u,W),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},q=(e,t)=>K(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ae=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},oe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:H,rangeExtractor:U,onChange:()=>{},measureElement:J,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,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=R(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{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(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!B()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,W),e.addEventListener(`touchend`,n,W),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,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??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=R(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=R(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=L(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=R(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=R(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(B()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=R(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return te(t[Y(0,t.length-1,r?e=>n[e*2]:e=>te(t[e]).start,e)])},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 e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&ne(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var ce=typeof document<`u`?F.useLayoutEffect:F.useEffect;function le({useFlushSync:e=!0,...t}){let n=F.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,I.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=F.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:ie,observeElementOffset:q,scrollToFn:ae,...e})}var X=i(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:i}){let{t:a}=p(`code`),{activeProjectId:o}=A(),{openTicketDetail:s}=ee(),{registerHandler:l,unregisterHandler:u}=m(),[d,f]=(0,F.useState)(()=>{if(!o)return`touched-by-ai`;try{let e=localStorage.getItem(Z(o));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,F.useEffect)(()=>{if(o)try{localStorage.setItem(Z(o),d)}catch{}},[d,o]);let[g,_]=(0,F.useState)(()=>{if(!o)return new Set;try{let e=localStorage.getItem(de(o));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,F.useEffect)(()=>{if(o)try{localStorage.setItem(de(o),JSON.stringify([...g]))}catch{}},[g,o]);let v=(0,F.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),b=(0,F.useCallback)(()=>{_(new Set)},[]),{data:x,refresh:S,isFirstLoad:C}=M({namespace:`code-tree:${d}:${d===`touched-by-ai`?`${n??`all-jobs`}:${i??`all-specs`}`:`all`}`,projectId:o,initialValue:[],fetcher:(0,F.useCallback)(async()=>{let e=[],t=null;for(let r=0;r<100;r+=1){let r=new URLSearchParams({withProvenance:`1`,filter:d});d===`touched-by-ai`&&n&&r.set(`jobId`,n),d===`touched-by-ai`&&typeof i==`number`&&r.set(`ticketId`,String(i)),t&&r.set(`cursor`,t);let a=await fetch(`${j()}/code/tree?${r.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[d,n,i])}),w=(0,F.useRef)(o);(0,F.useEffect)(()=>{w.current=o},[o]),(0,F.useEffect)(()=>{if(!o)return;let e=`code-tree-${o}`;return l(e,e=>{let t=e;t.projectId===w.current&&t.type===`file.provenance_updated`&&S()}),()=>u(e)},[o,l,u,S]);let T=(0,F.useRef)(null),E=(0,F.useMemo)(()=>(x??[]).filter(e=>!ge(e.path,g)),[x,g]),O=(0,F.useCallback)(()=>{_(new Set((x??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[x]),P=ue({count:E.length,getScrollElement:()=>T.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),I=E.length===0,L=(0,F.useMemo)(()=>(x??[]).filter(e=>e.kind===`file`).length,[x]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`touched-by-ai`),className:k(`px-2 py-1 rounded-md transition-colors`,d===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`touched-by-ai`,children:a(n?`tree.jobFiles`:i?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:k(`px-2 py-1 rounded-md transition-colors`,d===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`all`,children:a(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:O,title:a(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.collapseAll`),children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:b,title:a(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.expandAll`),children:(0,X.jsx)(D,{className:`w-3.5 h-3.5`})})]}),d===`touched-by-ai`&&L>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:a(`tree.touchedCount`,{count:L})})})]}),I&&C?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:a(`tree.loadingFiles`)})}):I&&d===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:a(`tree.showAllFiles`)})]}):I?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:a(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:T,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let i=E[n.index],o=fe(i.path)*12,l=i.kind===`file`&&i.path===t,u=i.provenance?.createdByTicketId,d=i.provenance?.modifiedByTicketIds??[],f=i.provenance?.latest??null,p=me(f?.jobId),m=he(f?.kind),_=i.kind===`dir`,b=_&&g.has(i.path),x=i.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:k(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,l&&`bg-muted text-foreground`),onClick:()=>{_?v(i.path):e(i.path)},role:`button`,tabIndex:0,"aria-expanded":_?!b:void 0,"data-testid":`file-tree-row-${i.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:o},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,X.jsxs)(X.Fragment,{children:[b?(0,X.jsx)(y,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(D,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),b?(0,X.jsx)(c,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(h,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(N,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(i.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&x>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:a(`tree.folderTouched`,{count:x}),children:x}),!_&&m&&(0,X.jsx)(`span`,{className:k(`text-[10px] px-1.5 py-0.5 rounded`,f?.kind===`created`&&`bg-accent-success/15 text-accent-success`,f?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,f?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:f?.kind===`created`?a(`tree.latestTitleCreated`):f?.kind===`deleted`?a(`tree.latestTitleDeleted`):a(`tree.latestTitleModified`),children:a(`action.${m}`)}),!_&&p&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:a(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,X.jsx)(r,{className:`h-3 w-3`}),p]}),!_&&typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(u)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${u}`,title:a(`tree.createdBySpec`,{id:u}),children:[`#`,u]}),!_&&d.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:a(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},i.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=p(`code`),o=S(),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),f=(0,F.useRef)(e),m=(0,F.useRef)(n),h=(0,F.useRef)(o),g=(0,F.useRef)(r),_=(0,F.useRef)(i);return(0,F.useEffect)(()=>{f.current=e},[e]),(0,F.useEffect)(()=>{m.current=n},[n]),(0,F.useEffect)(()=>{h.current=o},[o]),(0,F.useEffect)(()=>{g.current=r},[r]),(0,F.useEffect)(()=>{_.current=i},[i]),(0,F.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=Ee(t,h.current),r=t.editor.create(s.current,{value:f.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{_.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,F.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,F.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,F.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,F.useEffect)(()=>{let e=l.current;if(!e)return;let t=Ee(e,o);e.editor.setTheme(t)},[o]),u?(0,X.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,X.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,X.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,F.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=p(`code`);return(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,X.jsx)(ke,{content:e,language:t,readOnly:n,onChange:r})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=p(`code`),{openTicketDetail:c}=ee();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let l=je(t.generatedAt,s.language),u=t.triggeredBy?.ticketId,d=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,X.jsx)(`span`,{className:k(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(u),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,u]}),d.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),l&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:l})]})]}),a&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(T,{remarkPlugins:[n],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?u:e===`deleted`?O:o}function Ie({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=p(`code`),{activeProjectId:a}=A(),{registerHandler:o,unregisterHandler:s}=m(),[c,l]=(0,F.useState)(null),[u,f]=(0,F.useState)(!1),[h,g]=(0,F.useState)({}),_=(0,F.useRef)(a);(0,F.useEffect)(()=>{_.current=a},[a]);let v=(0,F.useRef)(e);(0,F.useEffect)(()=>{v.current=e},[e]);let y=(0,F.useRef)(0),b=(0,F.useCallback)(async()=>{let t=++y.current;try{let n=await fetch(`${j()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==y.current)return;if(!n.ok){l([]),f(!0);return}let r=await n.json();if(t!==y.current)return;l(Array.isArray(r.story)?r.story:[]),f(!1)}catch{t===y.current&&(l([]),f(!0))}},[e,a]);(0,F.useEffect)(()=>{l(null),g({}),b()},[b]),(0,F.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return o(e,e=>{let t=e;t.projectId===_.current&&t.path===v.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&b()}),()=>s(e)},[a,o,s,b]);let x=(0,F.useCallback)(async(t,n)=>{g(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${j()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),a=await r.json().catch(()=>({}));if(a.skipped===`budget`){g(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){d.error(i(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n});return}await b(),g(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{d.error(i(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n})}},[b,e,i]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:c===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):u?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):c.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:c.map(e=>(0,X.jsx)(Le,{entry:e,state:h[e.provenanceId],onOpenTicket:n,onFilterJob:r,onExplain:t=>{x(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=p(`code`),o=Fe(e.kind),s=e.ticket?.status??null,c=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:a(`story.spec`,{ticketId:e.ticketId}),l=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),a(`story.kindLabel.${e.kind}`)]}),c!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:a(`story.openSpec`,{ticketId:e.ticketId}),children:c}),c==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`story.unknownSpec`)}),s&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[s]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:s}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:a(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:a(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:a(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:a(`story.fallback.${l}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:a(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:a(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(E,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),a(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&r&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:i}=p(`code`),{activeProjectId:a}=A(),{openTicketDetail:o}=ee(),{registerHandler:s,unregisterHandler:c}=m(),l=f({allowMove:!1}),u=(0,F.useRef)(null),[h,g]=(0,F.useState)(null),[_,y]=(0,F.useState)(!0),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(!1),[T,E]=(0,F.useState)(()=>Xe(a)),[O,k]=(0,F.useState)(()=>Je(a)),[M,N]=(0,F.useState)(()=>Qe(a)),[P,I]=(0,F.useState)(()=>Ke(a)),L=(0,F.useRef)(a);(0,F.useEffect)(()=>{L.current=a},[a]);let R=(0,F.useRef)(e);(0,F.useEffect)(()=>{R.current=e},[e]),(0,F.useEffect)(()=>{let e=u.current?.clientHeight||window.innerHeight;E(Xe(a)),k(et(Je(a),e)),N(Qe(a)),I(Ke(a))},[a]);let te=(0,F.useCallback)(e=>{let t=e.clientY,n=O,r=u.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){k(et(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),k(e=>{let t=et(e,r);return Ye(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,O]),ne=(0,F.useCallback)(()=>{let e=et(ze,u.current?.clientHeight||window.innerHeight);k(e),Ye(a,e)},[a]),re=(0,F.useCallback)(()=>{E(e=>{let t=!e;return Ze(a,t),t})},[a]),z=(0,F.useCallback)(()=>{N(e=>{let t=!e;return $e(a,t),t})},[a]),B=(0,F.useCallback)(e=>{I(e),qe(a,e)},[a]);(0,F.useEffect)(()=>{x(!1),C(!1),K(`preview`),J(!1)},[e]);let V=(0,F.useRef)(0),H=(0,F.useCallback)(async()=>{let t=++V.current;y(!0);try{let n=await fetch(`${j()}/code/file?path=${encodeURIComponent(e)}`);if(t!==V.current)return;if(!n.ok){g(null);return}let r=await n.json();if(t!==V.current)return;g(r)}catch{t===V.current&&g(null)}finally{t===V.current&&y(!1)}},[e,a]);(0,F.useEffect)(()=>{H()},[H]),(0,F.useEffect)(()=>{if(!a)return;let e=`code-file-${a}`;return s(e,e=>{let t=e;t.projectId===L.current&&(t.type===`file.summary_updated`&&t.path===R.current?(x(!1),H()):t.type===`file.summary_failed`&&t.path===R.current?(d.error(t.reason??i(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===R.current&&(t.reason&&d(i(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>c(e)},[a,s,c,H,i]);let U=(0,F.useCallback)(async t=>{x(!0);try{let n=await fetch(`${j()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;d.error(e?i(`summary.skipped`,{reason:e}):i(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),C(!0);return}if(r.skipped){x(!1),d(i(`summary.skipped`,{reason:r.skipped}));return}await H(),x(!1)}catch{x(!1),d.error(i(`summary.generationFailed`))}},[H,e,i]),ie=(0,F.useCallback)(async()=>{let t=h?.absolutePath??e;try{await navigator.clipboard?.writeText(t),d.success(i(`viewer.pathCopied`))}catch{d.error(i(`viewer.copyPathFailed`))}},[h,e,i]),W=(0,F.useMemo)(()=>Re(e,h?.language),[e,h?.language]),[G,K]=(0,F.useState)(`preview`),[q,J]=(0,F.useState)(!1),[ae,oe]=(0,F.useState)(``),[Y,se]=(0,F.useState)(!1),ce=h?.content!==void 0&&!h.binary&&!h.tooLarge&&h.reason!==`not-found`,le=(0,F.useCallback)(()=>{oe(h?.content??``),K(`raw`),J(!0)},[h]),ue=(0,F.useCallback)(async()=>{se(!0);try{let t=await fetch(`${j()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:ae})});if(!t.ok){let e=await t.json().catch(()=>({}));d.error(e.error??i(`viewer.saveFailed`));return}d.success(i(`viewer.saved`)),J(!1),H()}catch{d.error(i(`viewer.saveFailed`))}finally{se(!1)}},[e,ae,i,H]),Z=h?.summary??null,de=!!h?.summaryStale,fe=h?.provenance??[],pe=h?.reason===`not-found`,me=pe?i(`summary.reason.missing`):h?.binary?i(`summary.reason.binary`):h?.tooLarge?i(`summary.reason.tooLarge`):null;return(0,F.useEffect)(()=>{if(n){if(_&&!h){n(null);return}return n({hasSummary:!!Z,regenerating:b,disabledReason:me,onClick:()=>U(!1)}),()=>n(null)}},[h,U,_,n,b,Z,me]),(0,F.useEffect)(()=>{if(r){if(_&&!h){r(null);return}return r({onClick:ie}),()=>r(null)}},[ie,h,_,r]),_&&!h?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:u,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[T?(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(D,{className:`h-3.5 w-3.5`}),i(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:b,generateDisabledReason:me,onCollapse:re}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:W&&h?.content!==void 0&&!h.binary&&!h.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":i(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`preview`),"aria-pressed":G===`preview`,className:G===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`raw`),"aria-pressed":G===`raw`,className:G===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!q&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.edit`)}),q&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:i(`actions.cancel`,{ns:`common`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:i(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:i(`viewer.missingFile`)}):h?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:i(`viewer.binaryFile`)}):h?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:i(`viewer.tooLarge`,{size:Math.round((h.sizeBytes??0)/1024/1024)})}):h?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`viewer.noContent`)}):q?(0,X.jsx)(Ae,{content:ae,language:h.language??`plaintext`,readOnly:!1,onChange:oe}):W&&G===`preview`?(0,X.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(Ne,{content:h.content})}):(0,X.jsx)(Ae,{content:h.content,language:h.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":i(`history.resize`),onPointerDown:M?void 0:te,onDoubleClick:M?void 0:ne,className:M?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:M?void 0:i(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i(P===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!M&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":i(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`story`),"aria-pressed":P===`story`,className:P===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`log`),"aria-pressed":P===`log`,className:P===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:z,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[M?(0,X.jsx)(w,{className:`h-3.5 w-3.5`}):(0,X.jsx)(D,{className:`h-3.5 w-3.5`}),i(M?`history.show`:`history.hide`)]})]})]}),!M&&(P===`story`?(0,X.jsx)(Ie,{relPath:e,height:O,onOpenTicket:o,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:o,onFilterJob:t,height:O}))]}),S&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:l.guardBackdrop(()=>C(!1)),children:[(0,X.jsxs)(`div`,{ref:l.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:l.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:i(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),U(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:i(`common:actions.confirm`)})]})]}),(0,X.jsx)(v,{handles:l.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:i}){let{t:a}=p(`code`),[s,c]=(0,F.useState)(null),[l,d]=(0,F.useState)({});if(e.length===0)return null;async function f(e,t){if(s===t){c(null);return}if(c(t),!(!e.jobId||l[t])){d(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${j()}/code/diff?${n.toString()}`);if(r.status===404){d(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();d(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{d(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:i},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,i)=>{let c=e.kind===`created`?u:e.kind===`deleted`?O:o,d=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),p=`${e.jobId??`job`}:${e.path}:${e.at}:${i}`,m=l[p];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:d}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:d}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(e,p),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:a(`history.diff`)}),typeof e.ticketId==`number`&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:a(`history.openSpec`,{ticketId:e.ticketId}),children:a(`history.specChip`,{ticketId:e.ticketId})})]}),(0,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),s===p&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:m===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):m===`missing`||!m?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,X.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[m.patch,m.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},p)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=p(`code`),{activeProjectId:i}=A(),[a]=g(),o=s(),c=(0,F.useRef)(null),[l,u]=(0,F.useState)(e?t:a.get(`path`)),d=(0,F.useCallback)(e=>{u(e),n?.(e)},[n]),[f,m]=(0,F.useState)(null),[h,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(()=>st(i)),[b,x]=(0,F.useState)(null),[S,C]=(0,F.useState)(null),w=e?b:a.get(`jobId`),T=(0,F.useMemo)(()=>{if(e)return S;let t=a.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,a]),[E,D]=(0,F.useState)(T==null?``:String(T));(0,F.useEffect)(()=>{if(e)return;let t=a.get(`path`);t!==l&&u(t)},[a,e]),(0,F.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,F.useEffect)(()=>{let e=c.current?.clientWidth||window.innerWidth;y($(st(i),e))},[i]),(0,F.useEffect)(()=>{let e=c.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&y(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,F.useCallback)(e=>{let t=e.clientX,n=v,r=c.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){y($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),y(e=>{let t=$(e,r);return ct(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[i,v]),k=(0,F.useCallback)(()=>{let e=$(rt,c.current?.clientWidth||window.innerWidth);y(e),ct(i,e)},[i]),j=(0,F.useCallback)(t=>{if(d(t),e)return;let n=new URLSearchParams(a);n.set(`path`,t),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a,d]),ee=(0,F.useCallback)(t=>{if(e){x(t),C(null);return}let n=new URLSearchParams(a);n.set(`jobId`,t),n.delete(`ticketId`),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a]),M=(0,F.useCallback)(()=>{if(e){x(null),C(null);return}let t=new URLSearchParams(a);t.delete(`jobId`),t.delete(`ticketId`),o({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,o,a]),N=(0,F.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){M();return}if(e){C(n),x(null);return}let r=new URLSearchParams(a);r.set(`ticketId`,String(n)),r.delete(`jobId`),o({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[M,e,o,a]);return(0,X.jsxs)(`div`,{ref:c,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,X.jsx)(_e,{onOpenFile:j,selectedPath:l,filterJobId:w,filterTicketId:T},i??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:w,ticketId:T,ticketInput:E,onTicketInputChange:D,onApplyTicket:N,onClear:M,summaryAction:f,copyPathAction:h}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:j}),l?(0,X.jsx)(tt,{relPath:l,onFilterJob:ee,onSummaryActionChange:m,onCopyPathActionChange:_}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:c}=p(`code`),l=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(P,{className:`h-3.5 w-3.5`}),c(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":l===`all`,className:l===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.allAi`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":l===`spec`,className:l===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.spec`)}),(0,X.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:c(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,X.jsx)(`div`,{className:`flex-1`}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:c(`toolbar.copyFilePath`)}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?c(`toolbar.regenerateSummary`):c(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:o.disabledReason?c(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,X.jsx)(x,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?c(`toolbar.regenerating`):c(`toolbar.regenerateSummary`):o.regenerating?c(`toolbar.generating`):c(`toolbar.generateSummary`)]}),l===`job-context`&&(0,X.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:c(`toolbar.jobContext`)}),(e||t)&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(b,{className:`h-3.5 w-3.5`}),c(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=p(`code`),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${j()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,F.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),s=i?.length??0;return(0,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(_,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,X.jsx)(n===`created`?u:n===`deleted`?O:o,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{lt as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{Cn as n,Ct as r,Kn as i,Rn as a,Sn as o,bn as s,g as c,gn as l,rt as u,x as d}from"./index-B3ejvKSt.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-nmDbbUiR.js";var Se=l(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(i());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=et(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function c(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:u(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>c(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})})]})}function wt({data:e}){let{t}=a(`analytics`),n=c(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%i===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:s()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=a(`analytics`),[t,n]=(0,U.useState)(`7d`),[i,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=o(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,c)},[t,i,c]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,c)},[t,i,c]);function b(e,t,r){n(e),t!==void 0&&s(t),r!==void 0&&l(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:c,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,c),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(r,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{Cn as n,Ct as r,Kn as i,Rn as a,Sn as o,bn as s,g as c,gn as l,rt as u,x as d}from"./index-Dw1N2-ci.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-BiLTq3uC.js";var Se=l(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(i());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=et(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function c(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:u(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>c(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})})]})}function wt({data:e}){let{t}=a(`analytics`),n=c(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%i===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:s()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=a(`analytics`),[t,n]=(0,U.useState)(`7d`),[i,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=o(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,c)},[t,i,c]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,c)},[t,i,c]);function b(e,t,r){n(e),t!==void 0&&s(t),r!==void 0&&l(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:c,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,c),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(r,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,Cn as n,G as r,Gt as i,K as a,Kn as o,Pt as s,Rn as c,X as l,Y as u,an as d,j as f,ln as p,q as m,rt as h}from"./index-B3ejvKSt.js";import{t as g}from"./lib-BIHmUkcn.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(o(),1),y=n();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:r,onHome:a}){let{t:o}=c(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:a,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:o(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=t===e.slug&&n===a.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,a.slug),title:a.title,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(i,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=c(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:r===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:r}),categories:n(`docs.categoryCount`,{count:a})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(d,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:n,onNavigateDoc:r}){return(0,y.jsx)(f,{remarkPlugins:[t],rehypePlugins:[g],components:{a({href:e,children:t,...i}){return(0,y.jsx)(`a`,{href:e,onClick:t=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){t.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;t.preventDefault();let i=_(e,n);i&&r(i.category,i.slug)},...i,children:t})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=c(`integrations`),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let i=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===p.current&&e&&(u(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===p.current&&f(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!l&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!l?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):l?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,Cn as n,G as r,Gt as i,K as a,Kn as o,Pt as s,Rn as c,X as l,Y as u,an as d,j as f,ln as p,q as m,rt as h}from"./index-Dw1N2-ci.js";import{t as g}from"./lib-BviHZ_gK.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(o(),1),y=n();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:r,onHome:a}){let{t:o}=c(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:a,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:o(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=t===e.slug&&n===a.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,a.slug),title:a.title,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(i,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=c(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:r===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:r}),categories:n(`docs.categoryCount`,{count:a})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(d,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:n,onNavigateDoc:r}){return(0,y.jsx)(f,{remarkPlugins:[t],rehypePlugins:[g],components:{a({href:e,children:t,...i}){return(0,y.jsx)(`a`,{href:e,onClick:t=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){t.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;t.preventDefault();let i=_(e,n);i&&r(i.category,i.slug)},...i,children:t})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=c(`integrations`),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let i=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===p.current&&e&&(u(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===p.current&&f(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!l&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!l?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):l?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,Cn as n,Gt as r,Hn as i,Kn as a,Pt as o,Rn as s,Un as c,Vn as l,an as u,j as d,ln as f,rt as p}from"./index-B3ejvKSt.js";import{t as m}from"./lib-BIHmUkcn.js";import{t as h}from"./atom-one-dark-BMDPFwRZ.js";var g=e(a(),1),_=n();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:i}=s(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(l,{to:`/docs`,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:i(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=t===e.slug&&n===i.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(l,{to:`/docs/${e.slug}/${i.slug}`,title:i.title,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i.title})]})},i.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=s(`integrations`),n=e.reduce((e,t)=>e+t.docs.length,0),i=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(f,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:n}),categories:t(`docs.categoryCount`,{count:i})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(l,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(u,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:n,onNavigateDoc:r}){return(0,_.jsx)(d,{remarkPlugins:[t],rehypePlugins:[m],components:{a({href:e,children:t,...i}){return(0,_.jsx)(`a`,{href:e,onClick:t=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){t.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;t.preventDefault();let i=h(e,n);i&&r(i.category,i.slug)},...i,children:t})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:r}){let{t:a}=s(`integrations`),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=i();return(0,g.useEffect)(()=>{let i=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===f.current&&e&&(l(e),r.current&&(r.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:a(`docs.loadError`))})},[e,t,n,p,r]),!c&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(o,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):c?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,Cn as n,Gt as r,Hn as i,Kn as a,Pt as o,Rn as s,Un as c,Vn as l,an as u,j as d,ln as f,rt as p}from"./index-Dw1N2-ci.js";import{t as m}from"./lib-BviHZ_gK.js";import{t as h}from"./atom-one-dark-BMDPFwRZ.js";var g=e(a(),1),_=n();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:i}=s(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(l,{to:`/docs`,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:i(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=t===e.slug&&n===i.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(l,{to:`/docs/${e.slug}/${i.slug}`,title:i.title,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i.title})]})},i.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=s(`integrations`),n=e.reduce((e,t)=>e+t.docs.length,0),i=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(f,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:n}),categories:t(`docs.categoryCount`,{count:i})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(l,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(u,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:n,onNavigateDoc:r}){return(0,_.jsx)(d,{remarkPlugins:[t],rehypePlugins:[m],components:{a({href:e,children:t,...i}){return(0,_.jsx)(`a`,{href:e,onClick:t=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){t.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;t.preventDefault();let i=h(e,n);i&&r(i.category,i.slug)},...i,children:t})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:r}){let{t:a}=s(`integrations`),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=i();return(0,g.useEffect)(()=>{let i=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===f.current&&e&&(l(e),r.current&&(r.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:a(`docs.loadError`))})},[e,t,n,p,r]),!c&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(o,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):c?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,Kn as n,Ln as r,Rn as i,Xt as a}from"./index-B3ejvKSt.js";var o=e(n(),1),s=t(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:n,disabled:u}){let{t:d}=i(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),r.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):n??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,Kn as n,Ln as r,Rn as i,Xt as a}from"./index-Dw1N2-ci.js";var o=e(n(),1),s=t(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:n,disabled:u}){let{t:d}=i(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),r.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):n??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};