specrails-desktop 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-Cq4UlyrP.js → ActivityFeedPage-D0HbUDeS.js} +1 -1
- package/client/dist/assets/AgentBrowserCapture-Brth-3zu.js +1 -0
- package/client/dist/assets/{AgentModeCodePane-W7XIIcKj.js → AgentModeCodePane-UuKgXzPX.js} +2 -2
- package/client/dist/assets/AgentModeJobsPane-_P5Xm6ij.js +1 -0
- package/client/dist/assets/AgentsPage-BHpan6kZ.js +86 -0
- package/client/dist/assets/{AnalyticsPage-27FMsav_.js → AnalyticsPage-kryIHuZy.js} +1 -1
- package/client/dist/assets/{BarChart-BiFF8sw8.js → BarChart-C5W41oN4.js} +1 -1
- package/client/dist/assets/CodePage-B0WhKBeS.js +2 -0
- package/client/dist/assets/DesktopAnalyticsPage-u9a30yar.js +1 -0
- package/client/dist/assets/{DocsDialog-DG_c7_6k.js → DocsDialog-GSzYhxfg.js} +2 -2
- package/client/dist/assets/{DocsPage-CDieUvMv.js → DocsPage-Bm0J873n.js} +2 -2
- package/client/dist/assets/{ExportDropdown-Cokk4zlC.js → ExportDropdown-CXc3MBkq.js} +1 -1
- package/client/dist/assets/IntegrationsPage-Z5Qy3n6G.js +3 -0
- package/client/dist/assets/{InteractiveJobComposer-C2w9yVm8.js → InteractiveJobComposer-BbBSAQm1.js} +6 -6
- package/client/dist/assets/JobDetailModal-CdPgkHdb.js +1 -0
- package/client/dist/assets/{JobDetailPage-BqdQ1wOs.js → JobDetailPage-CprNUYlt.js} +1 -1
- package/client/dist/assets/JobsPage-ClIaG5ow.js +1 -0
- package/client/dist/assets/{LoopBuilderPage-B8QhQ4FV.js → LoopBuilderPage-rWwSzVr_.js} +2 -2
- package/client/dist/assets/{LoopPreviewModal-CK58XIQ_.js → LoopPreviewModal-B0VUdegW.js} +1 -1
- package/client/dist/assets/LoopsPage-Brrl03uv.js +1 -0
- package/client/dist/assets/ProjectSettingsDialog-i1aAs49_.js +1 -0
- package/client/dist/assets/{TemplatePreviewModal-Rtc2P5v3.js → TemplatePreviewModal-C92-Ygm2.js} +1 -1
- package/client/dist/assets/{agent-BrmiC8zZ.js → agent-2gmrdgKk.js} +1 -1
- package/client/dist/assets/{agent-Bpm3uEw7.js → agent-Bq74VvOq.js} +1 -1
- package/client/dist/assets/{agent-CZ7HdyTA.js → agent-BrhvIxZF.js} +1 -1
- package/client/dist/assets/agent-CbHTqhBt.js +1 -0
- package/client/dist/assets/{agent-CBOOT08j2.js → agent-Ch_OIjXA2.js} +1 -1
- package/client/dist/assets/{agent-A0LpODvj2.js → agent-E-X9b1uz2.js} +1 -1
- package/client/dist/assets/{agent-DPGlEboi2.js → agent-i5VEzNfj2.js} +1 -1
- package/client/dist/assets/{agent-BmmZdeg7.js → agent-zI95bSiF.js} +1 -1
- package/client/dist/assets/{brain-DDEGUEos.js → brain-CJ92kxwM.js} +1 -1
- package/client/dist/assets/{dist-js-BP83ZCIg.js → dist-js-BVonQLiD.js} +1 -1
- package/client/dist/assets/{dist-js-Qk8DW7W3.js → dist-js-CAU8gTUN.js} +1 -1
- package/client/dist/assets/index-B9483NYu.css +2 -0
- package/client/dist/assets/{index-BQbiBIg_.js → index-CfHBmcjb.js} +49 -49
- package/client/dist/assets/{lib-CtyGolSR.js → lib-DJy6HBRz.js} +1 -1
- package/client/dist/assets/{upload-BOOCdPin.js → upload-D_1UxNS_.js} +1 -1
- package/client/dist/assets/{value-BHbZ4o6V.js → value-BH0Vlt96.js} +1 -1
- package/client/dist/index.html +3 -3
- package/docs/internals/companion-rails-as-loops-contract.md +1 -1
- package/package.json +1 -1
- package/server/dist/agent-operator-prompt.js +52 -15
- package/server/dist/claude-trust.js +150 -0
- package/server/dist/git-diagnostics.js +78 -0
- package/server/dist/loop-command-catalog.js +13 -7
- package/server/dist/loop-decider.js +6 -4
- package/server/dist/loop-executors.js +34 -0
- package/server/dist/loop-run-manager.js +52 -3
- package/server/dist/mcp/tools/catalog.js +2 -0
- package/server/dist/mcp/tools/git.js +58 -0
- package/server/dist/mcp/tools/rails.js +25 -2
- package/server/dist/project-registry.js +6 -1
- package/server/dist/project-router-git.js +19 -0
- package/server/dist/queue-manager.js +14 -0
- package/server/dist/workspace-manager.js +101 -10
- package/client/dist/assets/AgentBrowserCapture-BqGtoL0L.js +0 -1
- package/client/dist/assets/AgentModeJobsPane-CryUvMB9.js +0 -1
- package/client/dist/assets/AgentsPage-Re0K2JCa.js +0 -86
- package/client/dist/assets/CodePage-Ud12s91j.js +0 -2
- package/client/dist/assets/DesktopAnalyticsPage-BdjWlYgU.js +0 -1
- package/client/dist/assets/IntegrationsPage-oyvHxjdV.js +0 -3
- package/client/dist/assets/JobDetailModal-DEStK2P4.js +0 -1
- package/client/dist/assets/JobsPage-BH5pl9o_.js +0 -1
- package/client/dist/assets/LoopsPage-C0aVmXxN.js +0 -1
- package/client/dist/assets/ProjectSettingsDialog-Bf_x-MSF.js +0 -1
- package/client/dist/assets/agent-BCi1xJEH.js +0 -1
- package/client/dist/assets/index-DPX6_xIC.css +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
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{$n as n,A as r,An as i,Bt as a,Gn as o,Gt as s,Ht as c,Kn as l,Kt as u,Mn as d,Q as f,Qn as p,Ut as m,Xn as h,Yt as g,Z as _,an as v,at as y,bt as b,d as x,er as S,gn as C,in as w,j as T,jn as E,mt as D,on as O,qt as k,rt as A,vn as ee,y as te,yn as j}from"./index-BQbiBIg_.js";var M=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`}]]),N=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`}]]),P=e(S(),1),F=e(n(),1);function I(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 L(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 ne(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var re=(e,t)=>Math.abs(e-t)<1.01,ie=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},R,z=()=>{if(R!==void 0)return R;if(typeof navigator>`u`)return R=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return R=!0;let e=navigator.maxTouchPoints;return R=navigator.platform===`MacIntel`&&e!==void 0&&e>0},B=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},V=e=>e,H=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},ae=(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(B(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(B(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},U={passive:!0},W=typeof window>`u`?!0:`onscrollend`in window,G=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&W,o=0,s=a?null:ie(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,U),a&&r.addEventListener(`scrollend`,u,U),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},K=(e,t)=>G(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),q=(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`]},J=(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:V,rangeExtractor:H,onChange:()=>{},measureElement:q,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=L(()=>(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,!(!z()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,U),e.addEventListener(`touchend`,n,U),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=L(()=>[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=L(()=>[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=I(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=L(()=>[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=L(()=>{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))&&(z()&&(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=L(()=>[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 ne(t[Y(0,t.length-1,r?e=>n[e*2]:e=>ne(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&&re(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`?P.useLayoutEffect:P.useEffect;function le({useFlushSync:e=!0,...t}){let n=P.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,F.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=P.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:ae,observeElementOffset:K,scrollToFn:J,...e})}var X=E(),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:r}){let{t:o}=l(`code`),{activeProjectId:s}=ee(),{openTicketDetail:u}=te(),{registerHandler:f,unregisterHandler:p}=i(),[h,g]=(0,P.useState)(()=>{if(!s)return`touched-by-ai`;try{let e=localStorage.getItem(Z(s));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,P.useEffect)(()=>{if(s)try{localStorage.setItem(Z(s),h)}catch{}},[h,s]);let[_,y]=(0,P.useState)(()=>{if(!s)return new Set;try{let e=localStorage.getItem(de(s));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,P.useEffect)(()=>{if(s)try{localStorage.setItem(de(s),JSON.stringify([..._]))}catch{}},[_,s]);let b=(0,P.useCallback)(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),x=(0,P.useCallback)(()=>{y(new Set)},[]),{data:S,refresh:C,isFirstLoad:w}=j({namespace:`code-tree:${h}:${h===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`}`,projectId:s,initialValue:[],fetcher:(0,P.useCallback)(async()=>{let e=[],t=null;for(let i=0;i<100;i+=1){let i=new URLSearchParams({withProvenance:`1`,filter:h});h===`touched-by-ai`&&n&&i.set(`jobId`,n),h===`touched-by-ai`&&typeof r==`number`&&i.set(`ticketId`,String(r)),t&&i.set(`cursor`,t);let a=await fetch(`${d()}/code/tree?${i.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},[h,n,r])}),T=(0,P.useRef)(s);(0,P.useEffect)(()=>{T.current=s},[s]),(0,P.useEffect)(()=>{if(!s)return;let e=`code-tree-${s}`;return f(e,e=>{let t=e;t.projectId===T.current&&t.type===`file.provenance_updated`&&C()}),()=>p(e)},[s,f,p,C]);let E=(0,P.useRef)(null),D=(0,P.useMemo)(()=>(S??[]).filter(e=>!ge(e.path,_)),[S,_]),k=(0,P.useCallback)(()=>{y(new Set((S??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[S]),N=ue({count:D.length,getScrollElement:()=>E.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()=>{}}}),F=D.length===0,I=(0,P.useMemo)(()=>(S??[]).filter(e=>e.kind===`file`).length,[S]);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:()=>g(`touched-by-ai`),className:A(`px-2 py-1 rounded-md transition-colors`,h===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":h===`touched-by-ai`,children:o(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(`all`),className:A(`px-2 py-1 rounded-md transition-colors`,h===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":h===`all`,children:o(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:k,title:o(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.collapseAll`),children:(0,X.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:x,title:o(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.expandAll`),children:(0,X.jsx)(O,{className:`w-3.5 h-3.5`})})]}),h===`touched-by-ai`&&I>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:o(`tree.touchedCount`,{count:I})})})]}),F&&w?(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:o(`tree.loadingFiles`)})}):F&&h===`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:o(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:o(`tree.showAllFiles`)})]}):F?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:o(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:E,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:N.getTotalSize(),position:`relative`,width:`100%`},children:N.getVirtualItems().map(n=>{let r=D[n.index],i=fe(r.path)*12,s=r.kind===`file`&&r.path===t,l=r.provenance?.createdByTicketId,d=r.provenance?.modifiedByTicketIds??[],f=r.provenance?.latest??null,p=me(f?.jobId),h=he(f?.kind),g=r.kind===`dir`,y=g&&_.has(r.path),x=r.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:A(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{g?b(r.path):e(r.path)},role:`button`,tabIndex:0,"aria-expanded":g?!y:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:i},className:`flex items-center gap-1 min-w-0 flex-1`,children:[g?(0,X.jsxs)(X.Fragment,{children:[y?(0,X.jsx)(v,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(O,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),y?(0,X.jsx)(c,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(m,{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)(M,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(r.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[g&&x>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:o(`tree.folderTouched`,{count:x}),children:x}),!g&&h&&(0,X.jsx)(`span`,{className:A(`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`?o(`tree.latestTitleCreated`):f?.kind===`deleted`?o(`tree.latestTitleDeleted`):o(`tree.latestTitleModified`),children:o(`action.${h}`)}),!g&&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:o(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,X.jsx)(a,{className:`h-3 w-3`}),p]}),!g&&typeof l==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u(l)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${l}`,title:o(`tree.createdBySpec`,{id:l}),children:[`#`,l]}),!g&&d.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),u(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:o(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.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}=l(`code`),o=x(),s=(0,P.useRef)(null),c=(0,P.useRef)(null),u=(0,P.useRef)(null),[d,f]=(0,P.useState)(!1),p=(0,P.useRef)(e),m=(0,P.useRef)(n),h=(0,P.useRef)(o),g=(0,P.useRef)(r),_=(0,P.useRef)(i);return(0,P.useEffect)(()=>{p.current=e},[e]),(0,P.useEffect)(()=>{m.current=n},[n]),(0,P.useEffect)(()=>{h.current=o},[o]),(0,P.useEffect)(()=>{g.current=r},[r]),(0,P.useEffect)(()=>{_.current=i},[i]),(0,P.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!s.current)return;u.current=t;let n=Ee(t,h.current),r=t.editor.create(s.current,{value:p.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||f(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,P.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,P.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,P.useEffect)(()=>{let e=u.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,P.useEffect)(()=>{let e=u.current;if(!e)return;let t=Ee(e,o);e.editor.setTheme(t)},[o]),d?(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,P.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=l(`code`);return(0,X.jsx)(P.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}=l(`code`),{openTicketDetail:c}=te();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 u=je(t.generatedAt,s.language),d=t.triggeredBy?.ticketId,f=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:A(`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 d==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(d),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,d]}),f.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)),u&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),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:[r],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`?k:s}function Ie({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:a}=l(`code`),{activeProjectId:s}=ee(),{registerHandler:c,unregisterHandler:u}=i(),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)({}),v=(0,P.useRef)(s);(0,P.useEffect)(()=>{v.current=s},[s]);let y=(0,P.useRef)(e);(0,P.useEffect)(()=>{y.current=e},[e]);let b=(0,P.useRef)(0),x=(0,P.useCallback)(async()=>{let t=++b.current;try{let n=await fetch(`${d()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==b.current)return;if(!n.ok){p([]),h(!0);return}let r=await n.json();if(t!==b.current)return;p(Array.isArray(r.story)?r.story:[]),h(!1)}catch{t===b.current&&(p([]),h(!0))}},[e,s]);(0,P.useEffect)(()=>{p(null),_({}),x()},[x]),(0,P.useEffect)(()=>{if(!s)return;let e=`code-story-${s}`;return c(e,e=>{let t=e;t.projectId===v.current&&t.path===y.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&x()}),()=>u(e)},[s,c,u,x]);let S=(0,P.useCallback)(async(t,n)=>{_(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${d()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),i=await r.json().catch(()=>({}));if(i.skipped===`budget`){_(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!i.ok){o.error(a(`story.explainFailed`)),_(e=>{let n={...e};return delete n[t.provenanceId],n});return}await x(),_(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{o.error(a(`story.explainFailed`)),_(e=>{let n={...e};return delete n[t.provenanceId],n})}},[x,e,a]);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:f===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:a(`story.loading`)}):m?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:a(`story.loadFailed`)}):f.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:a(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:f.map(e=>(0,X.jsx)(Le,{entry:e,state:g[e.provenanceId],onOpenTicket:n,onFilterJob:r,onExplain:t=>{S(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=l(`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}),u=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.${u}`)}),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)(D,{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:a}=l(`code`),{activeProjectId:s}=ee(),{openTicketDetail:c}=te(),{registerHandler:u,unregisterHandler:p}=i(),m=f({allowMove:!1}),h=(0,P.useRef)(null),[g,v]=(0,P.useState)(null),[y,b]=(0,P.useState)(!0),[x,S]=(0,P.useState)(!1),[C,T]=(0,P.useState)(!1),[E,D]=(0,P.useState)(()=>Xe(s)),[k,A]=(0,P.useState)(()=>Je(s)),[j,M]=(0,P.useState)(()=>Qe(s)),[N,F]=(0,P.useState)(()=>Ke(s)),I=(0,P.useRef)(s);(0,P.useEffect)(()=>{I.current=s},[s]);let L=(0,P.useRef)(e);(0,P.useEffect)(()=>{L.current=e},[e]),(0,P.useEffect)(()=>{let e=h.current?.clientHeight||window.innerHeight;D(Xe(s)),A(et(Je(s),e)),M(Qe(s)),F(Ke(s))},[s]);let ne=(0,P.useCallback)(e=>{let t=e.clientY,n=k,r=h.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){A(et(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),A(e=>{let t=et(e,r);return Ye(s,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[s,k]),re=(0,P.useCallback)(()=>{let e=et(ze,h.current?.clientHeight||window.innerHeight);A(e),Ye(s,e)},[s]),ie=(0,P.useCallback)(()=>{D(e=>{let t=!e;return Ze(s,t),t})},[s]),R=(0,P.useCallback)(()=>{M(e=>{let t=!e;return $e(s,t),t})},[s]),z=(0,P.useCallback)(e=>{F(e),qe(s,e)},[s]);(0,P.useEffect)(()=>{S(!1),T(!1),G(`preview`),q(!1)},[e]);let B=(0,P.useRef)(0),V=(0,P.useCallback)(async()=>{let t=++B.current;b(!0);try{let n=await fetch(`${d()}/code/file?path=${encodeURIComponent(e)}`);if(t!==B.current)return;if(!n.ok){v(null);return}let r=await n.json();if(t!==B.current)return;v(r)}catch{t===B.current&&v(null)}finally{t===B.current&&b(!1)}},[e,s]);(0,P.useEffect)(()=>{V()},[V]),(0,P.useEffect)(()=>{if(!s)return;let e=`code-file-${s}`;return u(e,e=>{let t=e;t.projectId===I.current&&(t.type===`file.summary_updated`&&t.path===L.current?(S(!1),V()):t.type===`file.summary_failed`&&t.path===L.current?(o.error(t.reason??a(`summary.generationFailed`)),S(!1)):t.type===`file.summary_skipped`&&t.path===L.current&&(t.reason&&o(a(`summary.skipped`,{reason:t.reason})),S(!1)))}),()=>p(e)},[s,u,p,V,a]);let H=(0,P.useCallback)(async t=>{S(!0);try{let n=await fetch(`${d()}/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){S(!1);let e=typeof r.skipped==`string`?r.skipped:null;o.error(e?a(`summary.skipped`,{reason:e}):a(`summary.generationFailed`));return}if(r.skipped===`budget`){S(!1),T(!0);return}if(r.skipped){S(!1),o(a(`summary.skipped`,{reason:r.skipped}));return}await V(),S(!1)}catch{S(!1),o.error(a(`summary.generationFailed`))}},[V,e,a]),ae=(0,P.useCallback)(async()=>{let t=g?.absolutePath??e;try{await navigator.clipboard?.writeText(t),o.success(a(`viewer.pathCopied`))}catch{o.error(a(`viewer.copyPathFailed`))}},[g,e,a]),U=(0,P.useMemo)(()=>Re(e,g?.language),[e,g?.language]),[W,G]=(0,P.useState)(`preview`),[K,q]=(0,P.useState)(!1),[J,oe]=(0,P.useState)(``),[Y,se]=(0,P.useState)(!1),ce=g?.content!==void 0&&!g.binary&&!g.tooLarge&&g.reason!==`not-found`,le=(0,P.useCallback)(()=>{oe(g?.content??``),G(`raw`),q(!0)},[g]),ue=(0,P.useCallback)(async()=>{se(!0);try{let t=await fetch(`${d()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:J})});if(!t.ok){let e=await t.json().catch(()=>({}));o.error(e.error??a(`viewer.saveFailed`));return}o.success(a(`viewer.saved`)),q(!1),V()}catch{o.error(a(`viewer.saveFailed`))}finally{se(!1)}},[e,J,a,V]),Z=g?.summary??null,de=!!g?.summaryStale,fe=g?.provenance??[],pe=g?.reason===`not-found`,me=pe?a(`summary.reason.missing`):g?.binary?a(`summary.reason.binary`):g?.tooLarge?a(`summary.reason.tooLarge`):null;return(0,P.useEffect)(()=>{if(n){if(y&&!g){n(null);return}return n({hasSummary:!!Z,regenerating:x,disabledReason:me,onClick:()=>H(!1)}),()=>n(null)}},[g,H,y,n,x,Z,me]),(0,P.useEffect)(()=>{if(r){if(y&&!g){r(null);return}return r({onClick:ae}),()=>r(null)}},[ae,g,y,r]),y&&!g?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:h,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[E?(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:ie,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)(O,{className:`h-3.5 w-3.5`}),a(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:x,generateDisabledReason:me,onCollapse:ie}),(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:U&&g?.content!==void 0&&!g.binary&&!g.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":a(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>G(`preview`),"aria-pressed":W===`preview`,className:W===`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:a(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>G(`raw`),"aria-pressed":W===`raw`,className:W===`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:a(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!K&&(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:a(`viewer.edit`)}),K&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>q(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:a(`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:a(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:a(`viewer.missingFile`)}):g?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:a(`viewer.binaryFile`)}):g?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:a(`viewer.tooLarge`,{size:Math.round((g.sizeBytes??0)/1024/1024)})}):g?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:a(`viewer.noContent`)}):K?(0,X.jsx)(Ae,{content:J,language:g.language??`plaintext`,readOnly:!1,onChange:oe}):U&&W===`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:g.content})}):(0,X.jsx)(Ae,{content:g.content,language:g.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`history.resize`),onPointerDown:j?void 0:ne,onDoubleClick:j?void 0:re,className:j?`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:j?void 0:a(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:a(N===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!j&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":a(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>z(`story`),"aria-pressed":N===`story`,className:N===`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:a(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>z(`log`),"aria-pressed":N===`log`,className:N===`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:a(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:R,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:[j?(0,X.jsx)(w,{className:`h-3.5 w-3.5`}):(0,X.jsx)(O,{className:`h-3.5 w-3.5`}),a(j?`history.show`:`history.hide`)]})]})]}),!j&&(N===`story`?(0,X.jsx)(Ie,{relPath:e,height:k,onOpenTicket:c,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:c,onFilterJob:t,height:k}))]}),C&&(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:m.guardBackdrop(()=>T(!1)),children:[(0,X.jsxs)(`div`,{ref:m.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:m.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>T(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:a(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{T(!1),H(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:a(`common:actions.confirm`)})]})]}),(0,X.jsx)(_,{handles:m.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=l(`code`),[o,c]=(0,P.useState)(null),[f,p]=(0,P.useState)({});if(e.length===0)return null;async function m(e,t){if(o===t){c(null);return}if(c(t),!(!e.jobId||f[t])){p(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${d()}/code/diff?${n.toString()}`);if(r.status===404){p(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();p(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{p(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:r},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let c=e.kind===`created`?u:e.kind===`deleted`?k:s,l=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),d=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,p=f[d];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:i(`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)(a,{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:i(`history.filterByJob`,{jobId:e.jobId}),children:l}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:l}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(e,d),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:i(`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:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`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()})]}),o===d&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:p===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):p===`missing`||!p?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`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:[p.patch,p.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},d)})})})}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}=l(`code`),{activeProjectId:i}=ee(),[a]=p(),o=h(),s=(0,P.useRef)(null),[c,u]=(0,P.useState)(e?t:a.get(`path`)),d=(0,P.useCallback)(e=>{u(e),n?.(e)},[n]),[f,m]=(0,P.useState)(null),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(()=>st(i)),[b,x]=(0,P.useState)(null),[S,C]=(0,P.useState)(null),w=e?b:a.get(`jobId`),T=(0,P.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,P.useState)(T==null?``:String(T));(0,P.useEffect)(()=>{if(e)return;let t=a.get(`path`);t!==c&&u(t)},[a,e]),(0,P.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,P.useEffect)(()=>{let e=s.current?.clientWidth||window.innerWidth;y($(st(i),e))},[i]),(0,P.useEffect)(()=>{let e=s.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,P.useCallback)(e=>{let t=e.clientX,n=v,r=s.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){y($(n+(e.clientX-t),r))}function c(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),y(e=>{let t=$(e,r);return ct(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[i,v]),k=(0,P.useCallback)(()=>{let e=$(rt,s.current?.clientWidth||window.innerWidth);y(e),ct(i,e)},[i]),A=(0,P.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]),te=(0,P.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]),j=(0,P.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]),M=(0,P.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){j();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})},[j,e,o,a]);return(0,X.jsxs)(`div`,{ref:s,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:A,selectedPath:c,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:M,onClear:j,summaryAction:f,copyPathAction:g}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:A}),c?(0,X.jsx)(tt,{relPath:c,onFilterJob:te,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}=l(`code`),u=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)(N,{className:`h-3.5 w-3.5`}),c(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":u===`all`,className:u===`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":u===`spec`,className:u===`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)(b,{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`)]}),u===`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)(y,{className:`h-3.5 w-3.5`}),c(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=l(`code`),[i,a]=(0,P.useState)(null);(0,P.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${d()}/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,P.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)(g,{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`?k:s,{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 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{An as n,Cn as r,Ct as i,Dn as a,En as o,Kn as s,On as c,Sn as l,Tn as u,bn as d,d as f,er as p,gn as m,jn as h,kn as g,rt as _,wn as v,x as y}from"./index-BQbiBIg_.js";import{$ as b,A as x,B as S,E as ee,F as C,H as w,K as T,L as E,N as D,O,P as te,Q as ne,R as re,S as ie,T as ae,U as oe,W as se,X as ce,Y as le,Z as ue,_ as de,_t as fe,a as pe,c as me,d as he,dt as k,et as A,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as j,it as xe,j as Se,k as Ce,l as we,lt as M,mt as Te,n as Ee,nt as De,o as Oe,pt as N,q as ke,r as Ae,rt as je,s as Me,t as Ne,u as Pe,ut as P,v as Fe,w as F,z as Ie}from"./BarChart-BiFF8sw8.js";var Le=m(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);function I(e,t){return r(e,{...t,weekStartsOn:1})}function L(e,t){let n=v(e,t?.in),r=n.getFullYear(),i=a(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let o=I(i),s=a(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);let c=I(s);return n.getTime()>=o.getTime()?r+1:n.getTime()>=c.getTime()?r:r-1}function R(e,t){let n=v(e,t?.in);return n.setHours(0,0,0,0),n}function Re(e,t,n){let[r,i]=o(n?.in,e,t),a=R(r),s=R(i),l=+a-y(a),u=+s-y(s);return Math.round((l-u)/c)}function ze(e,t){let n=L(e,t),r=a(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),I(r)}function Be(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ve(e){return!(!Be(e)&&typeof e!=`number`||isNaN(+v(e)))}function He(e,t){let n=v(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ue(e,t){let n=v(e,t?.in);return Re(n,He(n))+1}function We(e,t){let n=v(e,t?.in),r=I(n)-+ze(n);return Math.round(r/g)+1}function z(e,t){let n=v(e,t?.in),i=n.getFullYear(),o=u(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,c=a(t?.in||e,0);c.setFullYear(i+1,0,s),c.setHours(0,0,0,0);let l=r(c,t),d=a(t?.in||e,0);d.setFullYear(i,0,s),d.setHours(0,0,0,0);let f=r(d,t);return+n>=+l?i+1:+n>=+f?i:i-1}function Ge(e,t){let n=u(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=z(e,t),s=a(t?.in||e,0);return s.setFullYear(o,0,i),s.setHours(0,0,0,0),r(s,t)}function Ke(e,t){let n=v(e,t?.in),i=r(n,t)-+Ge(n,t);return Math.round(i/g)+1}function B(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var V={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return B(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):B(n+1,2)},d(e,t){return B(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return B(e.getHours()%12||12,t.length)},H(e,t){return B(e.getHours(),t.length)},m(e,t){return B(e.getMinutes(),t.length)},s(e,t){return B(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return B(Math.trunc(r*10**(n-3)),t.length)}},H={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qe={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return V.y(e,t)},Y:function(e,t,n,r){let i=z(e,r),a=i>0?i:1-i;return t===`YY`?B(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):B(a,t.length)},R:function(e,t){return B(L(e),t.length)},u:function(e,t){return B(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return B(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return B(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return V.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return B(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Ke(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):B(i,t.length)},I:function(e,t,n){let r=We(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):B(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):V.d(e,t)},D:function(e,t,n){let r=Ue(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):B(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return B(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return B(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return B(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?H.noon:r===0?H.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?H.evening:r>=12?H.afternoon:r>=4?H.morning:H.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return V.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):V.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):V.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):V.s(e,t)},S:function(e,t){return V.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ye(r);case`XXXX`:case`XX`:return U(r);default:return U(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ye(r);case`xxxx`:case`xx`:return U(r);default:return U(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},t:function(e,t,n){return B(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return B(+e,t.length)}};function Je(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+B(a,2)}function Ye(e,t){return e%60==0?(e>0?`-`:`+`)+B(Math.abs(e)/60,2):U(e,t)}function U(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=B(Math.trunc(r/60),2),a=B(r%60,2);return n+i+t+a}var Xe=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Ze=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Qe={p:Ze,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Xe(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Xe(r,t)).replace(`{{time}}`,Ze(i,t))}},$e=/^D+$/,et=/^Y+$/,tt=[`D`,`DD`,`YY`,`YYYY`];function nt(e){return $e.test(e)}function rt(e){return et.test(e)}function it(e,t,n){let r=at(e,t,n);if(console.warn(r),tt.includes(e))throw RangeError(r)}function at(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var ot=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,st=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ct=/^'([^]*?)'?$/,lt=/''/g,ut=/[a-zA-Z]/;function dt(e,t,n){let r=u(),i=n?.locale??r.locale??l,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=v(e,n?.in);if(!Ve(s))throw RangeError(`Invalid time value`);let c=t.match(st).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qe[t];return n(e,i.formatLong)}return e}).join(``).match(ot).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ft(e)};if(qe[t])return{isToken:!0,value:e};if(t.match(ut))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let d={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&rt(a)||!n?.useAdditionalDayOfYearTokens&&nt(a))&&it(a,t,String(e));let o=qe[a[0]];return o(s,a,i.localize,d)}).join(``)}function ft(e){let t=e.match(ct);return t?t[1].replace(lt,`'`):e}var W=e(p());function G(){return G=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},G.apply(null,arguments)}var pt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return k(n)&&k(r)&&k(i)?W.createElement(`circle`,G({},ve(e),xe(e),{className:o,cx:n,cy:r,r:i})):null},mt=[`points`];function ht(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ht(Object(n),!0).forEach(function(t){gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gt(e,t,n){return(t=_t(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _t(e){var t=vt(e,`string`);return typeof t==`symbol`?t:t+``}function vt(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(){return q=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},q.apply(null,arguments)}function yt(e,t){if(e==null)return{};var n,r,i=bt(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 bt(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 xt(e){var{option:n,dotProps:r,className:i}=e;if((0,W.isValidElement)(n))return(0,W.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=yt(o,mt);return W.createElement(pt,q({},c,{className:a}))}function St(e,t){return e==null?!1:t?!0:e.length===1}function Ct(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=E.scatter}=e;if(!St(t,n))return null;var u=F(n),d=be(n),f=t.map((e,r)=>{var s=K(K(K({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 W.createElement(xt,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),W.createElement(x,{zIndex:l},W.createElement(N,q({className:r},p),f))}function wt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wt(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(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 Ot=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=J(J(J({},{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}),fe(i)),xe(i)),c=(0,W.isValidElement)(i)?(0,W.cloneElement)(i,s):typeof i==`function`?i(s):W.createElement(pt,s);return W.createElement(N,{className:`recharts-active-dot`,clipPath:o},c)};function kt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=E.activeDot}=e,s=De(Se),c=Pe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return P(l)?null:W.createElement(x,{zIndex:o},W.createElement(Ot,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var At=(e,t,n,r)=>D(e,`xAxis`,t,r),jt=(e,t,n,r)=>te(e,`xAxis`,t,r),Mt=(e,t,n,r)=>D(e,`yAxis`,n,r),Nt=(e,t,n,r)=>te(e,`yAxis`,n,r),Pt=A([oe,At,Mt,jt,Nt],(e,t,n,r,i)=>b(e,`xAxis`)?le(t,r,!1):le(n,i,!1)),Ft=(e,t,n,r,i)=>i;function It(e){return e.type===`line`}var Lt=A([oe,At,Mt,jt,Nt,A([C,Ft],(e,t)=>e.filter(It).find(e=>e.id===t)),Pt,re],(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 cn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rt(e){var t=fe(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 zt=[`id`],Bt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Vt=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=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},Y.apply(null,arguments)}function Ht(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 X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ht(Object(n),!0).forEach(function(t){Ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ut(e,t,n){return(t=Wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wt(e){var t=Gt(e,`string`);return typeof t==`symbol`?t:t+``}function Gt(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 Z(e,t){if(e==null)return{};var n,r,i=Kt(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 Kt(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 qt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:ue(n,t),payload:e}]},Jt=W.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:ge,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ue(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return W.createElement(Fe,{tooltipEntrySettings:d})}),Q=(e,t)=>`${t}px ${e}px`;function Yt(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Xt=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Q(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[...Yt(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Zt(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ve(Z(r,zt));return W.createElement(Ct,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qt(e){var{showLabels:t,children:n,points:r}=e,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ae,{value:t?i:void 0},n)}function $t(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=X(X({},Te(Z(a,Bt))),{},{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 W.createElement(W.Fragment,null,r?.length>1&&W.createElement(ie,Y({shapeType:`curve`,option:u},d,{pathRef:n})),W.createElement(Zt,{points:r,clipPathId:t,props:a}))}function en(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function tn(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:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,W.useRef)(v),[b,x]=(0,W.useState)(!1),C=!b,w=(0,W.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),T=(0,W.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),E=en(r.current),D=(0,W.useRef)(0);y.current!==v&&(D.current=a.current,y.current=v);var O=D.current;return W.createElement(Qt,{points:o,showLabels:C},n.children,W.createElement(S,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=M(O,E+O,e),u=Math.min(l,E),d=c?s?Xt(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Q(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return X(X({},t),{},{x:M(i.x,t.x,e),y:M(i.y,t.y,e)})}return f?X(X({},t),{},{x:M(p*2,t.x,e),y:M(m/2,t.y,e)}):X(X({},t),{},{x:t.x,y:t.y})});return i.current=g,W.createElement($t,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return W.createElement($t,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),W.createElement(ee,{label:n.label}))}function nn(e){var{clipPathId:t,props:n}=e,r=(0,W.useRef)(null),i=(0,W.useRef)(0),a=(0,W.useRef)(null);return W.createElement(tn,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var rn=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:ne(e.payload,t)}),an=class extends W.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:p}=this.props;if(e)return null;var m=t(`recharts-line`,i),h=d,{r:g,strokeWidth:_}=Rt(n),v=F(n),y=g*2+_,b=f?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return W.createElement(x,{zIndex:p},W.createElement(N,{className:m},f&&W.createElement(`defs`,null,W.createElement(Oe,{clipPathId:h,xAxisId:a,yAxisId:o}),!v&&W.createElement(`clipPath`,{id:`clipPath-dots-${h}`},W.createElement(`rect`,{x:c-y/2,y:s-y/2,width:l+y,height:u+y}))),W.createElement(me,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:rn,errorBarOffset:0},W.createElement(nn,{props:this.props,clipPathId:h}))),W.createElement(kt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},on={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:E.line,type:`linear`};function sn(e){var t=je(e,on),{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=Z(t,Vt),{needClip:_}=Me(p,m),v=he(),y=se(),b=ke(),x=De(e=>Lt(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:ee,x:C,y:w}=v;return W.createElement(an,Y({},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:ee,left:C,top:w,needClip:_}))}function cn(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=ne(e,o);if(t===`horizontal`)return{x:ce({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(P(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=P(l)?null:n.scale.map(l),d=ce({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 ln(e){var t=je(e,on),n=ke();return W.createElement(_e,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(de,{legendPayload:qt(t)}),W.createElement(Jt,{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}),W.createElement(ye,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(sn,Y({},t,{id:e}))))}var un=W.memo(ln,w);un.displayName=`Line`;var dn=[`axis`],fn=(0,W.forwardRef)((e,t)=>W.createElement(Ee,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dn,tooltipPayloadSearcher:Ce,categoricalChartProps:e,ref:t})),$=h(),pn=[{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 mn({period:e,from:t,to:n,onChange:r}){let{t:i}=s(`analytics`);function a(e){e===`custom`?r(`custom`,t,n):r(e)}function o(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:pn.map(t=>(0,$.jsx)(`button`,{onClick:()=>a(t.value),className:_(`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=>o(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 hn({kpi:e,windowLabel:t}){let{t:n}=s(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,a=e.includesEstimated??r>0,o=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:`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:o,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?`${o?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:o&&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))}),a&&(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 gn({data:e}){let{t}=s(`analytics`),n=f(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),a=e.filter((e,t)=>t%i===0).map(e=>e.date),o=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),c=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`)}),c&&(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)(T,{width:`100%`,height:200,children:(0,$.jsxs)(fn,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`date`,ticks:a,tickFormatter:e=>{try{return dt(new Date(e),`MMM d`,{locale:d()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(o.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)(un,{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 _n({projects:e}){let{t}=s(`analytics`),n=f();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 vn({projects:e}){let{t}=s(`analytics`),n=f();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)(T,{width:`100%`,height:180,children:(0,$.jsxs)(Ne,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(pe,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function yn(){let{t:e}=s(`analytics`),[t,r]=(0,W.useState)(`7d`),[a,o]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(null),{registerHandler:g,unregisterHandler:_}=n(),v=(0,W.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,a,c)},[t,a,c]);(0,W.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,W.useEffect)(()=>{y(t,a,c)},[t,a,c]);function b(e,t,n){r(e),t!==void 0&&o(t),n!==void 0&&l(n)}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)(Le,{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)(mn,{period:t,from:a,to:c,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,a,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)(i,{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)(hn,{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)(gn,{data:u.costTimeline}),(0,$.jsx)(vn,{projects:u.projectBreakdown})]}),(0,$.jsx)(_n,{projects:u.projectBreakdown})]})]})})}export{yn as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{An as t,Et as n,G as r,Gn as i,Jn as a,K as o,Kn as s,Mn as c,Pt as l,Q as u,U as d,W as f,X as p,Xt as m,Y as h,Z as g,_n as _,c as v,ct as y,er as b,jn as x,lt as S,nn as C,nt as w,tn as T,vn as E,wt as D,yn as O}from"./index-BQbiBIg_.js";var k=e(b(),1),A=x(),j=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=s(`jira`),r=e.connection,[a,o]=(0,k.useState)(r.enabled),[c,l]=(0,k.useState)(!1),[u,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)([]),[h,g]=(0,k.useState)([]),[_,v]=(0,k.useState)(r.discardStatus??``),[y,b]=(0,k.useState)(r.statusMap??{}),x=e.outbox??{pending:0,inflight:0,done:0,dead:0},S=(0,k.useCallback)(async()=>{try{let{ops:e}=await d.listOutbox(`dead`);m(e)}catch{m([])}},[]);(0,k.useEffect)(()=>{S()},[S]),(0,k.useEffect)(()=>{let e=!1;return d.listStatuses().then(({statuses:t})=>{e||g(t)}).catch(()=>{e||g([])}),()=>{e=!0}},[]);async function C(e){let r=_;v(e);try{await d.patchConnection({discardStatus:e||null}),t()}catch(e){v(r),i.error(F(e,n))}}async function T(e,r){let a=y,o={...y,[e]:r||void 0};b(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{await d.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){b(a),i.error(F(e,n))}}async function E(){let e=!a;o(e),f(!0);try{await d.setEnabled(e)}catch(t){o(!e),i.error(F(t,n))}finally{f(!1)}}async function D(){l(!0);try{let e=await d.syncNow();i.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){i.error(F(e,n))}finally{l(!1)}}async function O(){if(window.confirm(n(`status.disconnectConfirm`))){f(!0);try{await d.disconnect(),i.success(n(`status.disconnectedToast`)),t()}catch(e){i.error(F(e,n))}finally{f(!1)}}}async function N(e){try{await d.retryOutbox(e),await S()}catch(e){i.error(F(e,n))}}let I=x.pending+x.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:r.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.baseUrl,` · `,r.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${r.baseUrl}/browse/${r.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n(`status.enabledLabel`),disabled:u,onClick:E,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${a?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:y[e]??``,onChange:t=>void T(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!h.some(t=>t.name===y[e])&&(0,A.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:_,onChange:e=>void C(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,A.jsx)(`option`,{value:_,children:_})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(w,{variant:`outline`,size:`sm`,onClick:D,disabled:c,children:n(c?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(w,{variant:`ghost`,size:`sm`,onClick:O,disabled:u,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),x.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:x.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),p.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),p.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(w,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t}=s(`integrations`),[i,a]=(0,k.useState)(null),[c,l]=(0,k.useState)(!0),[u,m]=(0,k.useState)(!1),[g,_]=(0,k.useState)(!1),y=(0,k.useCallback)(async()=>{try{a(await d.getConnection())}catch{a({connected:!1})}finally{l(!1)}},[]);if((0,k.useEffect)(()=>{!f||!e||(l(!0),y())},[e,y]),!f)return null;let b=!!(i?.connected&&i.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(n,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`jiraCard.title`)}),b&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(C,{className:`w-3 h-3`}),` `,t(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:t(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:b&&i?.connection?t(`jiraCard.connectedDescription`,{key:i.connection.jiraProjectKey}):t(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:t(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:c?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):b?(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:t(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(n,{className:`w-3.5 h-3.5`}),t(`jiraCard.connect`)]})}),(0,A.jsx)(r,{open:u,onOpenChange:m,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(h,{children:(0,A.jsx)(p,{children:t(`jiraCard.modalTitle`)})}),(0,A.jsx)(v,{onConnected:()=>{m(!1),y()},onSkip:()=>m(!1)})]})}),(0,A.jsx)(r,{open:g,onOpenChange:_,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(h,{children:(0,A.jsx)(p,{children:t(`jiraCard.manageTitle`)})}),i?.connected&&i.connection&&(0,A.jsx)(N,{state:i,onChanged:()=>{y().then(()=>_(!1))}})]})})]})}function L(){let{t:e}=s(`integrations`),{activeProjectId:n,projects:r}=E(),i=r.find(e=>e.id===n),a=i?_(i).includes(`claude`):!0,{registerHandler:o,unregisterHandler:l}=t(),u=(0,k.useRef)(n);(0,k.useEffect)(()=>{u.current=n},[n]);let[d,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),{data:g,isLoading:v,isFirstLoad:b,refresh:x}=O({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${c()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(o(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==u.current||t.type.startsWith(`plugin.`)&&x())}),()=>l(`integrations-page`)),[o,l,x]),(0,k.useEffect)(()=>{p(!v&&!g?`Failed to load plugins`:null)},[v,g]);let S=(0,k.useMemo)(()=>(g??[]).filter(e=>e.status!==`orphan`),[g]),C=(0,k.useMemo)(()=>(g??[]).filter(e=>e.status===`orphan`),[g]);return n?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(D,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:b&&v?(0,A.jsx)(q,{}):d&&a?(0,A.jsx)(J,{onRetry:x}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:n}),a&&S.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:m===e.name,onInstall:()=>h(e.name),onCloseInstall:()=>{h(null),x()}},e.name))]}),a&&C.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(y,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:x},e.name))})]}),!f&&(!a||S.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:i}=s(`integrations`),[o,c]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,A.jsx)(C,{className:`w-3 h-3`}),` `,i(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(T,{className:`w-3 h-3`}),` `,i(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,A.jsx)(y,{className:`w-3 h-3`}),` `,i(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,A.jsx)(m,{className:`w-3 h-3`}),` `,i(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(a,{t:i,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:i(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(S,{className:`w-3 h-3`}),` `,i(`card.uninstall`)]})]})}),t&&(0,A.jsx)(W,{pluginName:e.name,onClose:r}),o&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>c(!1),onUninstalled:()=>{c(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=s(`integrations`),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${c()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){o(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function B({keys:e}){let{t}=s(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(y,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(a,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t}=s(`integrations`),[n,r]=(0,k.useState)(!1),[i,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(m,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(a,{t,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0),o(null);try{let t=await fetch(`${c()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){o(e.message)}finally{r(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[n&&(0,A.jsx)(l,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(a,{t,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),i&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:i})]})}function H({pluginName:e,conflicts:t}){let{t:n}=s(`integrations`),[r,i]=(0,k.useState)(null),[o,u]=(0,k.useState)(null),d=async e=>{i(e),u(null);try{let t=await fetch(`${c()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){u(e.message)}finally{i(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(y,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(a,{t:n,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:r===e,onClick:()=>d(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[r===e&&(0,A.jsx)(l,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(a,{t:n,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),o&&(0,A.jsx)(`div`,{className:`text-destructive`,children:o})]})}function U({plugin:e,onRemoved:t}){let{t:n}=s(`integrations`),[r,i]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${c()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(S,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:n}){let{t:r}=s(`integrations`),[i,a]=(0,k.useState)(null),[o,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(!1),[p,h]=(0,k.useState)(null),[g,_]=(0,k.useState)([]),[v,b]=(0,k.useState)(null),[x,S]=(0,k.useState)([]),{registerHandler:w,unregisterHandler:E}=t(),D=(0,k.useCallback)(()=>{a(null),u(null),fetch(`${c()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>a(e)).catch(e=>u(e.message))},[e]);(0,k.useEffect)(()=>{D()},[D]),(0,k.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&_(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&S(t=>[...t,`► ${e}`]),n.ok&&D()}}),()=>E(`install-${e}`)),[e,w,E,D]);let O=async e=>{b(e),S([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${c()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){S(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(i?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:n,title:r(`installDialog.title`,{name:e}),children:[o&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),!i&&!o&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(l,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),i&&(0,A.jsxs)(A.Fragment,{children:[i.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(y,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:i.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:i.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),i.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:i.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,n=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(C,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(T,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&n&&(0,A.jsxs)(`button`,{type:`button`,disabled:v===e.name,onClick:()=>O(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[v===e.name&&(0,A.jsx)(l,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),x.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:x.join(`
|
|
2
|
-
`)})]}),g.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,A.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:g.join(`
|
|
3
|
-
`)})]}),p&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:p})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:!i||!j||d,onClick:async()=>{f(!0),h(null);try{let t=await fetch(`${c()}/plugins/${e}/install`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);setTimeout(n,1500)}catch(e){h(e.message)}finally{f(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[d?(0,A.jsx)(l,{className:`w-3 h-3 animate-spin`}):(0,A.jsx)(m,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function G({pluginName:e,onClose:t,onUninstalled:n}){let{t:r}=s(`integrations`),[i,o]=(0,k.useState)(!1),[u,d]=(0,k.useState)(null);return(0,A.jsxs)(K,{onClose:t,title:r(`uninstallDialog.title`,{name:e}),children:[(0,A.jsx)(`p`,{className:`text-xs`,children:(0,A.jsx)(a,{t:r,i18nKey:`uninstallDialog.body`,components:{code:(0,A.jsx)(`code`,{})}})}),u&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:u}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:i,onClick:async()=>{o(!0);try{let t=await fetch(`${c()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);n()}catch(e){d(e.message)}finally{o(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[i&&(0,A.jsx)(l,{className:`w-3 h-3 animate-spin`}),r(`card.uninstall`)]})]})]})}function K({title:e,onClose:t,children:n}){let{panelRef:r,panelStyle:i,headerHandleProps:a,resizeHandles:o,isFloating:s,guardBackdrop:c}=u();return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:c(t),children:[(0,A.jsxs)(`div`,{ref:r,className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),style:i,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold ${s?`cursor-grab active:cursor-grabbing`:``}`,...a,children:e}),n]}),(0,A.jsx)(g,{handles:o})]})}function q(){return(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function J({onRetry:e}){let{t}=s(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,A.jsx)(y,{className:`w-5 h-5 text-destructive`}),(0,A.jsx)(`p`,{children:t(`page.loadError`)}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function Y(){let{t:e}=s(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,A.jsx)(D,{className:`w-6 h-6`}),(0,A.jsx)(`p`,{children:e(`page.empty`)})]})}export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{a as t,n}from"./auth-Cvsb7-Ek.js";import{a as r,i,n as a,o,r as s,t as c}from"./InteractiveJobComposer-C2w9yVm8.js";import{$n as l,B as ee,G as u,Gn as d,H as te,I as ne,J as re,K as f,Kn as p,Mn as m,Pt as h,Q as ie,V as g,X as _,Y as v,Z as y,at as b,b as x,bn as S,er as C,jn as w,nt as T,q as ae,tt as oe,z as se}from"./index-BQbiBIg_.js";var ce=e(l(),1),E=e(C(),1),D=[1e3,2e3,4e3,8e3,16e3];function O(e,t){let[r,i]=(0,E.useState)(`connecting`),a=(0,E.useRef)(null),o=(0,E.useRef)(0),s=(0,E.useRef)(null),c=(0,E.useRef)(t);c.current=t;let l=(0,E.useCallback)(()=>{let t=n(),r=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);a.current=r,i(`connecting`),r.onopen=()=>{o.current=0,i(`connected`)},r.onmessage=e=>{try{let t=JSON.parse(e.data);c.current(t)}catch{}},r.onclose=()=>{a.current=null;let e=o.current;if(e>=D.length){i(`disconnected`);return}let t=D[e];o.current+=1,s.current=setTimeout(l,t)}},[e]);return(0,E.useEffect)(()=>(l(),()=>{s.current&&clearTimeout(s.current);let e=a.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),a.current=null}),[l]),{connectionStatus:r}}var k=w();function A(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}var j={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function M({jobId:e,onClose:n,projectId:l}){let{t:C}=p(`jobs`),w=(0,E.useCallback)(()=>l?`${t}/api/projects/${l}`:m(),[l]),[D,M]=(0,E.useState)(null),[N,P]=(0,E.useState)([]),[F,I]=(0,E.useState)([]),[L,R]=(0,E.useState)({}),[z,B]=(0,E.useState)(!0),[V,H]=(0,E.useState)(!1),[le,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(!1);(0,E.useEffect)(()=>{async function t(){try{let t=await fetch(`${w()}/jobs/${e}`);if(t.status===404){H(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(M(n.job),P(n.events),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{H(!0)}finally{B(!1)}}t()},[e,w]);let K=(0,E.useCallback)(()=>{fetch(`${w()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&M(e.job)}).catch(()=>{})},[e,w]),q=(0,E.useRef)([]),J=(0,E.useRef)(null),Y=(0,E.useCallback)(()=>{J.current=null;let e=q.current;e.length!==0&&(q.current=[],P(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,E.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),O(ne,(0,E.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`job.finalized`&&n.jobId===e)K();else if(n.type===`phase`){let e=n.phase,t=n.state;R(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&D&&M(e=>e&&{...e,status:t.status})}},[e,D,Y,K])),(0,E.useEffect)(()=>{function e(e){e.key===`Escape`&&n()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let X=D?o(D):`job`,Z=X===`loop-run`;async function ue(){G(!0);try{let t=await r({projectId:l??null,jobId:e,kind:X});t.ok?(d.success(C(Z?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:C(Z?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):d.error(C(`modal.toast.cancelFailed`),{description:t.error})}finally{G(!1)}}let Q=D?j[D.status]??j.queued:j.queued,$=D?.status===`running`,{panelRef:de,panelStyle:fe,headerHandleProps:pe,resizeHandles:me,isFloating:he,guardBackdrop:ge}=ie();return(0,ce.createPortal)((0,k.jsx)(g,{delayDuration:400,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:ge(n)}),(0,k.jsxs)(`div`,{ref:de,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:fe,children:[(0,k.jsxs)(`div`,{...pe,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${he?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(se,{children:[(0,k.jsx)(te,{asChild:!0,children:(0,k.jsx)(`div`,{children:(0,k.jsx)(oe,{variant:Q.variant,children:C(Q.labelKey)})})}),(0,k.jsx)(ee,{children:C(Q.tooltipKey)})]}),(0,k.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:D.command}),(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:x(new Date(D.started_at),{addSuffix:!0,locale:S()})}),D.total_cost_usd!=null&&D.total_cost_usd>0&&(0,k.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,D.total_cost_usd.toFixed(4)]}),D.finished_at&&(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:A(D.started_at,D.finished_at)})]}),z&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`common:states.loading`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[F.length>0&&(0,k.jsx)(`div`,{className:`mr-3`,children:(0,k.jsx)(i,{phases:L,phaseDefinitions:F})}),$&&(0,k.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),disabled:W,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[W&&(0,k.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),C(Z?`dashboard:railControls.stop`:X===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,k.jsx)(`button`,{onClick:n,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,k.jsx)(b,{className:`w-4 h-4`})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:V?(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:C(`modal.notFound`)})}):D?.command.startsWith(`loop:`)?(0,k.jsx)(a,{events:N,jobStatus:D.status,isLoading:z,variant:`glass`,projectId:l}):(0,k.jsx)(s,{events:N,isLoading:z,projectId:l})}),!!D?.interactive&&D.status===`running`&&(0,k.jsx)(c,{jobId:e,projectId:l,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,k.jsx)(y,{handles:me}),(0,k.jsx)(u,{open:le,onOpenChange:U,children:(0,k.jsxs)(f,{className:`max-w-sm`,children:[(0,k.jsxs)(v,{children:[(0,k.jsx)(_,{children:C(Z?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,k.jsx)(ae,{children:C(Z?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)})]}),(0,k.jsxs)(re,{children:[(0,k.jsx)(T,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:C(`modal.keepRunning`)}),(0,k.jsx)(T,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),ue()},children:C(Z?`modal.stopRun`:X===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})})]})}),document.body)}export{M as JobDetailModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{$t as t,A as n,B as r,Ft as i,G as a,Gn as o,H as s,J as c,K as l,Kn as u,Mn as d,Q as f,X as p,Xn as m,Y as h,Z as g,at as _,b as v,bn as y,er as b,gn as x,j as ee,jn as S,lt as te,nn as C,nt as w,q as ne,t as T,tn as E,tt as D,vn as re,yn as O,z as k}from"./index-BQbiBIg_.js";import{t as ie}from"./format-command-CuWuRvka.js";import{t as A}from"./ExportDropdown-Cokk4zlC.js";var ae=x(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),j=e(b(),1),M=S();function N(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function P(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function F(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function I({label:e,a:t,b:n,highlight:r}){return(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function L(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function oe({jobIds:e,onClose:t}){let{t:n}=u(`jobs`),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(!0),[s,c]=(0,j.useState)(null),{panelRef:l,panelStyle:p,headerHandleProps:m,resizeHandles:h,isFloating:v,guardBackdrop:y}=f();(0,j.useEffect)(()=>{let t=new AbortController;return fetch(`${d()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(c(e.message),o(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,M.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,M.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,M.jsx)(C,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,M.jsx)(E,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,M.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,M.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,M.jsxs)(`div`,{ref:l,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:p,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,M.jsx)(_,{className:`w-4 h-4`})})]}),a&&(0,M.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,M.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),s&&(0,M.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:s})}),r&&(()=>{let[e,t]=r.jobs,i=L(e.durationMs,t.durationMs,!0),a=L(e.totalCostUsd,t.totalCostUsd,!0),o=L(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,M.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,M.jsx)(I,{label:n(`comparison.duration`),a:N(e.durationMs),b:N(t.durationMs),highlight:i}),(0,M.jsx)(I,{label:n(`comparison.cost`),a:P(e.totalCostUsd),b:P(t.totalCostUsd),highlight:a}),(0,M.jsx)(I,{label:n(`comparison.tokensOut`),a:F(e.tokensOut),b:F(t.tokensOut),highlight:o}),(0,M.jsx)(I,{label:n(`comparison.tokensIn`),a:F(e.tokensIn),b:F(t.tokensIn),highlight:null}),(0,M.jsx)(I,{label:n(`comparison.cacheRead`),a:F(e.tokensCacheRead),b:F(t.tokensCacheRead),highlight:null}),(0,M.jsx)(I,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,M.jsx)(I,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,M.jsx)(g,{handles:h})]})}var se={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ce=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],R={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function le(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ue(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function de(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function fe(e){try{return v(new Date(e),{addSuffix:!0,locale:y()})}catch{return e}}function z(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function B(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function V(e,t,n){if(!t&&!n)return!0;let r=new Date(e).getTime();return Number.isNaN(r)?!0:!(t&&r<z(t)||n&&r>B(n))}var H=10;function U({jobs:e,isLoading:n,onJobsCleared:_,onProposalClick:v,onProposalDelete:y}){let{t:b}=u(`jobs`),x=m(),{activeProjectId:ee,projects:S}=re(),C=S.find(e=>e.id===ee)?.provider,[T,E]=(0,j.useState)(null),[O,A]=(0,j.useState)(``),[N,P]=(0,j.useState)(``),[F,I]=(0,j.useState)(!1),[L,U]=(0,j.useState)(``),[W,pe]=(0,j.useState)(``),[me,he]=(0,j.useState)(!1),[G,K]=(0,j.useState)(null),[q,ge]=(0,j.useState)(H),[J,_e]=(0,j.useState)(!1),[Y,X]=(0,j.useState)([]),[ve,Z]=(0,j.useState)(null),{panelRef:ye,panelStyle:be,headerHandleProps:xe,resizeHandles:Se,isFloating:Ce,guardBackdrop:we}=f();(0,j.useEffect)(()=>{ge(H)},[e.length]);function Te(){_e(e=>!e),X([])}function Ee(e){X(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Z(n),n})}let Q=e.filter(e=>T&&e.status!==T?!1:V(e.started_at,O,N)),De=e.filter(e=>V(e.started_at,L,W)).length;async function $(e){he(!0);try{let t={};e===`range`&&(L&&(t.from=new Date(z(L)).toISOString()),W&&(t.to=new Date(B(W)).toISOString()));let n=await fetch(`${d()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();o.success(b(`recent.toast.cleared`,{count:e.deleted})),I(!1),U(``),pe(``),_?.()}else o.error(b(`recent.toast.clearFailed`))}catch{o.error(b(`recent.toast.networkError`))}finally{he(!1)}}return n?(0,M.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,M.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,M.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,M.jsx)(t,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,M.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:b(`recent.emptyTitle`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:b(`recent.emptyDescription`)})]}):(0,M.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:b(`recent.filterAll`,{count:e.length})}),ce.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,M.jsx)(`button`,{type:`button`,onClick:()=>E(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:b(`recent.filterStatus`,{status:b(`statusName.${t}`),count:n})},t)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:O,onChange:e=>A(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:b(`recent.fromDate`)}),(0,M.jsx)(`input`,{type:`date`,value:N,onChange:e=>P(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:b(`recent.toDate`)}),(O||N)&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>{A(``),P(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:b(`recent.clear`)}),(0,M.jsxs)(k,{children:[(0,M.jsx)(s,{asChild:!0,children:(0,M.jsx)(w,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${J?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Te,children:(0,M.jsx)(ae,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(r,{children:b(J?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,M.jsxs)(k,{children:[(0,M.jsx)(s,{asChild:!0,children:(0,M.jsx)(w,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>I(!0),children:(0,M.jsx)(te,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(r,{children:b(`recent.clearJobs`)})]})]})]}),J&&(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,M.jsxs)(`span`,{children:[Y.length===0&&b(`recent.selectTwoToCompare`),Y.length===1&&b(`recent.selectOneMore`),Y.length===2&&b(`recent.readyToCompare`)]}),Y.length===2&&(0,M.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Z(Y),children:b(`recent.compareAction`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,M.jsx)(`span`,{className:`w-14`,children:b(`recent.colStatus`)}),(0,M.jsx)(`span`,{className:`flex-1 min-w-0`,children:b(`recent.colCommand`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:b(`recent.colDuration`)}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:b(`recent.colTokens`)}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:b(`recent.colCost`)}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:b(`recent.colStarted`)})]})]}),(0,M.jsx)(`div`,{className:`space-y-0.5`,children:Q.slice(0,q).map(e=>{let t=se[e.status]??se.queued,n=le(e.total_cost_usd),a=ue(e.started_at,e.finished_at),o=de((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),c=e.id.startsWith(`proposal:`),l=c?e.id.replace(`proposal:`,``):null,u=Y.includes(e.id),d=J&&!c&&Y.length===2&&!u;return(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${u?`bg-accent/70 ring-1 ring-border`:d?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(J&&!c){Ee(e.id);return}c&&l?v?.(l):x(`/jobs/${e.id}`)},children:[(0,M.jsxs)(k,{children:[(0,M.jsx)(s,{asChild:!0,children:(0,M.jsx)(`div`,{children:(0,M.jsx)(D,{variant:t.variant,children:b(t.labelKey)})})}),(0,M.jsx)(r,{children:b(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,M.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${R[e.priority].className}`,children:b(R[e.priority].labelKey)}),e.profile_name&&(0,M.jsxs)(k,{children:[(0,M.jsx)(s,{asChild:!0,children:(0,M.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,M.jsx)(r,{children:b(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,M.jsxs)(k,{children:[(0,M.jsx)(s,{asChild:!0,children:(0,M.jsx)(i,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,M.jsxs)(r,{children:[b(`recent.pipelinePart`),e.depends_on_job_id&&` ${b(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,M.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ie(e.command,C)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:a??`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:o?`${o}`:`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:fe(e.started_at)}),c&&l&&(0,M.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),K(l)},title:b(`recent.deleteProposal`),children:(0,M.jsx)(te,{className:`w-3 h-3`})})]})]},e.id)})}),Q.length>q&&(0,M.jsx)(`div`,{className:`pt-1 text-center`,children:(0,M.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>e+H),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:b(`recent.loadMore`,{count:Q.length-q})})}),F&&(0,M.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:we(()=>I(!1)),children:[(0,M.jsxs)(`div`,{ref:ye,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:be,children:[(0,M.jsxs)(`div`,{...xe,className:Ce?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:b(`recent.clearModal.title`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:b(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,M.jsx)(w,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:me,onClick:()=>$(`all`),children:b(`recent.clearModal.clearAll`,{count:e.length})}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`recent.clearModal.orByRange`)}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:L,onChange:e=>U(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:b(`recent.clearModal.fromPlaceholder`)}),(0,M.jsx)(`input`,{type:`date`,value:W,onChange:e=>pe(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:b(`recent.clearModal.toPlaceholder`)})]}),(0,M.jsx)(w,{variant:`outline`,size:`sm`,className:`w-full`,disabled:me||!L&&!W,onClick:()=>$(`range`),children:L||W?b(`recent.clearModal.clearInRange`,{count:De}):b(`recent.clearModal.clearRange`)})]}),(0,M.jsx)(w,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>I(!1),children:b(`common:actions.cancel`)})]}),(0,M.jsx)(g,{handles:Se})]}),(0,M.jsx)(a,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,M.jsxs)(l,{className:`max-w-sm`,children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(p,{children:b(`recent.deleteProposalConfirm.title`)}),(0,M.jsx)(ne,{children:b(`recent.deleteProposalConfirm.description`)})]}),(0,M.jsxs)(c,{children:[(0,M.jsx)(w,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:b(`common:actions.cancel`)}),(0,M.jsx)(w,{variant:`destructive`,size:`sm`,onClick:()=>{G&&y?.(G),K(null)},children:b(`common:actions.delete`)})]})]})}),ve&&(0,M.jsx)(oe,{jobIds:ve,onClose:()=>{Z(null),X([]),_e(!1)}})]})}function W(){let{t:e}=u(`jobs`),{activeProjectId:t}=re(),{recentJobs:r}=T(t),{data:i,isFirstLoad:s,refresh:f}=O({namespace:`jobs`,projectId:t,initialValue:r,fetcher:async()=>{let e=await fetch(`${d()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:m}=O({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async()=>{let e=await fetch(`${d()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),g={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},_=m.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:g[e.status]??`queued`})),v=[...i,..._].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,b]=(0,j.useState)(null),x=(0,j.useCallback)(async e=>{try{let t=await fetch(`${d()}/propose/${e}`);if(!t.ok)return;b((await t.json()).proposal)}catch{}},[]),S=(0,j.useCallback)(async t=>{try{(await fetch(`${d()}/propose/${t}`,{method:`DELETE`})).ok&&(o.success(e(`page.proposalDeleted`)),f())}catch{}},[f,e]);return(0,M.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,M.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,M.jsx)(A,{baseUrl:`${d()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,M.jsx)(U,{jobs:v,isLoading:s,onJobsCleared:f,onProposalClick:x,onProposalDelete:S}),(0,M.jsx)(a,{open:y!==null,onOpenChange:e=>!e&&b(null),children:(0,M.jsx)(l,{className:`max-w-3xl glass-card`,children:y&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(h,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(p,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,M.jsx)(D,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,M.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,M.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,M.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,M.jsx)(ee,{remarkPlugins:[n],children:y.result_markdown})})}):(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,M.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,M.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,M.jsxs)(c,{children:[(0,M.jsx)(w,{variant:`destructive`,size:`sm`,onClick:()=>{S(y.id),b(null)},children:e(`common:actions.delete`)}),(0,M.jsx)(w,{variant:`ghost`,size:`sm`,onClick:()=>b(null),children:e(`common:actions.close`)})]})]})})})]})}export{W as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./upload-BOOCdPin.js";import{D as n,Dt as r,E as i,G as a,Gn as o,J as s,Jt as c,K as l,Kn as u,O as d,R as f,T as p,Tt as m,X as ee,Xn as h,Xt as g,Y as te,Zt as _,_n as v,er as y,gn as b,jn as x,kt as S,lt as C,mt as w,nt as T,ot as E,q as D,rt as O,vn as ne,w as k}from"./index-BQbiBIg_.js";import{n as re}from"./TemplatePreviewModal-Rtc2P5v3.js";var A=b(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ie=b(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),j=e(y(),1);function ae(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function M(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function oe(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:M(t)?[t]:[]).filter(M);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function se(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var ce=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function le(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:n?`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n):!0)}function ue(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of ce){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var N=x();function de({loop:e,projects:t,onClose:n,onExecute:i}){let{t:o}=u(`loops`),c=e!==null,[d,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(`medium`),x=t.find(e=>e.id===(d||t[0]?.id)),S=(0,j.useMemo)(()=>x?.providers??(x?.provider?[x.provider]:[]),[x]),C=h||S[0]||``,w=(0,j.useMemo)(()=>p(C),[C]),E=_||k(C),O=C?f(C):!1;return(0,N.jsx)(a,{open:c,onOpenChange:e=>{e||n()},children:(0,N.jsx)(l,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(te,{children:[(0,N.jsx)(ee,{children:o(`run.title`,{name:e.name})}),(0,N.jsx)(D,{children:o(`run.subtitle`)})]}),(0,N.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:o(`run.project`)}),t.length===0?(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`run.noProjects`)}):(0,N.jsx)(`select`,{"aria-label":o(`run.project`),"data-testid":`run-project-select`,value:d||t[0]?.id,onChange:e=>{m(e.target.value),g(``),v(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))}),S.length>1&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:o(`run.provider`)}),(0,N.jsx)(`select`,{"aria-label":o(`run.provider`),value:C,onChange:e=>{g(e.target.value),v(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:S.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))})]}),w.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:o(`run.model`)}),(0,N.jsx)(`select`,{"aria-label":o(`run.model`),"data-testid":`run-model-select`,value:E,onChange:e=>v(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:w.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),O&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:o(`run.effort`)}),(0,N.jsxs)(`select`,{"aria-label":o(`run.effort`),value:y,onChange:e=>b(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:[(0,N.jsx)(`option`,{value:`low`,children:`low`}),(0,N.jsx)(`option`,{value:`medium`,children:`medium`}),(0,N.jsx)(`option`,{value:`high`,children:`high`})]})]}),(0,N.jsxs)(s,{children:[(0,N.jsx)(T,{variant:`ghost`,onClick:n,children:o(`common:actions.cancel`)}),(0,N.jsxs)(T,{onClick:()=>{let e=d||t[0]?.id;e&&i({projectId:e,provider:S.length>1?C:void 0,model:w.length>0?E:void 0,effort:O?y:void 0})},disabled:t.length===0,children:[(0,N.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),o(`run.execute`)]})]})]})})})}var fe={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function P({status:e}){let{t}=u(`loops`);return(0,N.jsx)(`span`,{className:O(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,fe[e]),children:t(`status.${e}`)})}function F(){let{t:e}=u(`loops`),t=h(),r=(0,j.useCallback)(e=>e.replace(/:/g,`_`),[]),f=(0,j.useCallback)((t,n)=>e(`catalog.${r(t)}.name`,{defaultValue:n}),[e,r]),p=(0,j.useCallback)((t,n)=>e(`catalog.${r(t)}.description`,{defaultValue:n}),[e,r]),[y,b]=(0,j.useState)([]),[x,S]=(0,j.useState)([]),[k,M]=(0,j.useState)([]),[ce,fe]=(0,j.useState)(!0),[P,F]=(0,j.useState)(null),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(`use`),[H,U]=(0,j.useState)(null),[W,pe]=(0,j.useState)(new Set),G=`specrails-desktop:loop-template-filter`,me=(()=>{try{let e=localStorage.getItem(G),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[K,he]=(0,j.useState)(me.query),[q,ge]=(0,j.useState)(me.categories);(0,j.useEffect)(()=>{try{localStorage.setItem(G,JSON.stringify({query:K,categories:q}))}catch{}},[K,q]);let _e=(0,j.useCallback)(e=>{ge(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ve=(0,j.useCallback)(()=>{he(``),ge([])},[]),ye=(0,j.useRef)(null),{projects:be,setActiveProjectId:xe}=ne(),Se=(0,j.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),J=(0,j.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(ae(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=se(e),r.click(),URL.revokeObjectURL(n)},[]),Y=(0,j.useCallback)(async()=>{try{let[e,t]=await Promise.all([d.list(),d.templates()]);b(e),S(t)}catch{o.error(e(`errors.load`))}finally{fe(!1)}try{M(await d.factoryLoops())}catch{M([])}},[e]);(0,j.useEffect)(()=>{Y()},[Y]);let Ce=(0,j.useCallback)(async t=>{try{let n=oe(await t.text()),{imported:r,skipped:i}=await d.importLoops(n);await Y(),r.length&&o.success(e(`import.done`,{count:r.length})),i.length&&o.warning(e(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&o.warning(e(`import.invalid`))}catch(t){let n=t instanceof Error?t.message:``;o.error(e(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[Y,e]),X=(0,j.useCallback)(e=>t(`/loops/${e}/edit`),[t]),we=(0,j.useCallback)(async()=>{try{X((await d.create({name:e(`newLoopName`)})).id)}catch{o.error(e(`errors.save`))}},[e,X]),Te=(0,j.useCallback)(async t=>{try{X((await d.fromTemplate(t)).id)}catch{o.error(e(`errors.save`))}},[e,X]),Ee=(0,j.useCallback)(async t=>{try{X((await d.forkFactory(t)).id)}catch{o.error(e(`errors.save`))}},[e,X]),De=(0,j.useCallback)(async({projectId:n,provider:r,model:i,effort:a})=>{let s=H;if(s){U(null);try{let{loopRunId:c}=await d.runStandalone(n,s.id,{aiEngine:r,model:i,reasoning_effort:a});xe(n),t(`/jobs/${c}`),o.success(e(`run.launched`,{name:s.name}))}catch{o.error(e(`errors.save`))}}},[H,t,xe,e]),Oe=(0,j.useCallback)(e=>{V(`fork`),z({id:e.id,name:f(e.id,e.name),description:p(e.id,e.description),tags:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[f,p]),ke=(0,j.useCallback)(async t=>{try{await d.publish(t),await Y()}catch(t){t instanceof n?o.error(e(`errors.publishInvalid`)):o.error(e(`errors.save`))}},[e,Y]),Ae=(0,j.useCallback)(async t=>{try{await d.unpublish(t),await Y()}catch{o.error(e(`errors.save`))}},[e,Y]),je=(0,j.useCallback)(async t=>{try{await d.duplicate(t),await Y()}catch{o.error(e(`errors.save`))}},[e,Y]),Me=(0,j.useCallback)(e=>F(e),[]),Ne=(0,j.useCallback)(async()=>{let t=P;if(t){F(null);try{await d.remove(t),await Y()}catch{o.error(e(`errors.save`))}}},[P,e,Y]),Z=y.filter(e=>e.status===`draft`),Q=y.filter(e=>e.status===`published`),Pe=ue(x),$=le(x.map(t=>({...t,searchTerms:`${f(t.id,t.name)} ${p(t.id,t.description)} ${t.category?e(`categories.${t.category}`,{defaultValue:t.category}):``}`})),{query:K,categories:q}),Fe=K.trim()!==``||q.length>0;return(0,N.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,N.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,N.jsx)(E,{className:`w-5 h-5 text-accent-primary`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:e(`title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`subtitle`)})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[W.size>0&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>J(y.filter(e=>W.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,N.jsx)(A,{className:`w-3.5 h-3.5`}),e(`actions.export`),` (`,W.size,`)`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>ye.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,N.jsx)(ie,{className:`w-3.5 h-3.5`}),e(`actions.import`)]}),(0,N.jsx)(`input`,{ref:ye,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Ce(t),e.target.value=``}}),(0,N.jsxs)(`button`,{type:`button`,onClick:we,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,N.jsx)(m,{className:`w-3.5 h-3.5`}),e(`newLoop`)]})]})]}),ce?(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,N.jsxs)(`div`,{className:`space-y-8`,children:[Z.length===0&&Q.length===0&&(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e(`empty.title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e(`empty.body`)})]}),Q.length>0&&(0,N.jsx)(I,{title:e(`sections.published`),children:Q.map(e=>(0,N.jsx)(L,{loop:e,selected:W.has(e.id),onToggleSelect:()=>Se(e.id),onEdit:()=>X(e.id),onUnpublish:()=>Ae(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id),onRun:i(e.graph)?void 0:()=>U(e)},e.id))}),Z.length>0&&(0,N.jsx)(I,{title:e(`sections.drafts`),children:Z.map(e=>(0,N.jsx)(L,{loop:e,selected:W.has(e.id),onToggleSelect:()=>Se(e.id),onEdit:()=>X(e.id),onPublish:()=>ke(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id)},e.id))}),k.length>0&&(0,N.jsx)(I,{title:e(`sections.builtIn`),children:k.map(t=>(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(E,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:f(t.id,t.name)}),(0,N.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e(`builtInBadge`)})]}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:p(t.id,t.description)}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>Oe(t),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,N.jsx)(c,{className:`w-3 h-3`}),e(`actions.preview`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(t.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,N.jsx)(_,{className:`w-3 h-3`}),e(`actions.fork`)]})]})]},t.id))}),x.length>0&&(0,N.jsxs)(`section`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,N.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`sections.templates`)}),(0,N.jsx)(`input`,{type:`search`,value:K,onChange:e=>he(e.target.value),placeholder:e(`gallery.search`),"aria-label":e(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:t,count:n})=>{let r=q.includes(t);return(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>_e(t),className:O(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[e(`categories.${t}`,{defaultValue:t}),(0,N.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},t)}),Fe&&(0,N.jsx)(`button`,{type:`button`,onClick:ve,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:e(`gallery.clearFilter`)})]}),$.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`gallery.noResults`)}),(0,N.jsx)(`button`,{type:`button`,onClick:ve,className:`mt-2 text-xs text-accent-primary hover:underline`,children:e(`gallery.clearFilter`)})]}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:$.map(t=>(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(w,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:f(t.id,t.name)}),t.category&&(0,N.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:e(`categories.${t.category}`,{defaultValue:t.category})})]}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:p(t.id,t.description)}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i(t.graph)?(0,N.jsx)(`span`,{title:e(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:e(`gallery.needsSpec`)}):(0,N.jsx)(`span`,{title:e(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:e(`gallery.standalone`)}),t.tags.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),z({...t,name:f(t.id,t.name),description:p(t.id,t.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,N.jsx)(c,{className:`w-3 h-3`}),e(`actions.preview`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>Te(t.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,N.jsx)(g,{className:`w-3 h-3`}),e(`actions.use`)]})]})]},t.id))})]})]})]}),(0,N.jsx)(a,{open:P!==null,onOpenChange:e=>{e||F(null)},children:(0,N.jsxs)(l,{className:`max-w-sm`,children:[(0,N.jsxs)(te,{children:[(0,N.jsxs)(ee,{className:`flex items-center gap-2`,children:[(0,N.jsx)(C,{className:`w-4 h-4 text-destructive`}),y.find(e=>e.id===P)?.name??e(`actions.delete`)]}),(0,N.jsx)(D,{children:e(`confirmDelete`)})]}),(0,N.jsxs)(s,{children:[(0,N.jsx)(T,{variant:`ghost`,onClick:()=>F(null),children:e(`common:actions.cancel`)}),(0,N.jsx)(T,{variant:`destructive`,onClick:()=>void Ne(),children:e(`common:actions.delete`)})]})]})}),(0,N.jsx)(re,{template:R,mode:B,onClose:()=>z(null),onUse:e=>{z(null),B===`fork`?Ee(e):Te(e)}}),(0,N.jsx)(de,{loop:H?{id:H.id,name:H.name}:null,projects:be.map(e=>({id:e.id,name:e.name,providers:v(e)})),onClose:()=>U(null),onExecute:De})]})}function I({title:e,children:t}){return(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,N.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function L({loop:e,selected:n,onToggleSelect:i,onEdit:a,onPublish:o,onUnpublish:s,onDuplicate:c,onExport:l,onDelete:d,onRun:f}){let{t:p}=u(`loops`),m=e.graph?.nodes?.length??0;return(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:n,onChange:i,"aria-label":p(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,N.jsx)(P,{status:e.status})]}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`card.nodes`,{count:m})}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[f&&(0,N.jsx)(R,{icon:r,label:p(`actions.run`),onClick:f}),(0,N.jsx)(R,{icon:S,label:p(`actions.edit`),onClick:a}),o&&(0,N.jsx)(R,{icon:t,label:p(`actions.publish`),onClick:o}),s&&(0,N.jsx)(R,{icon:g,label:p(`actions.unpublish`),onClick:s}),(0,N.jsx)(R,{icon:_,label:p(`actions.duplicate`),onClick:c}),(0,N.jsx)(R,{icon:A,label:p(`actions.export`),onClick:l}),(0,N.jsx)(R,{icon:C,label:p(`actions.delete`),onClick:d,danger:!0})]})]})}function R({icon:e,label:t,onClick:n,danger:r}){return(0,N.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:O(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,N.jsx)(e,{className:`w-3.5 h-3.5`})})}export{F as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{G as t,K as n,Kn as r,X as i,Y as a,er as o,f as s,gt as c,h as l,hn as u,ht as d,jn as f,m as p,p as m,pt as h,q as g,rt as _,st as v,vn as y}from"./index-BQbiBIg_.js";var b=e(o(),1),x=f(),S=[{id:`general`,icon:d,labelKey:`projectDialog.nav.general`},{id:`budget`,icon:v,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:u,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:h,labelKey:`projectDialog.nav.terminal`}];function C({open:e,onClose:o}){let{t:u}=r(`settings`),{activeProjectId:d,projects:f}=y(),h=f.find(e=>e.id===d),[v,C]=(0,b.useState)(`general`),w=e=>_(`space-y-5`,v===e?``:`hidden`);return(0,x.jsx)(t,{open:e,onOpenChange:e=>{e||o()},children:(0,x.jsxs)(n,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,x.jsxs)(a,{children:[(0,x.jsxs)(i,{className:`flex items-center gap-2`,children:[(0,x.jsx)(c,{className:`w-4 h-4`}),h?u(`projectDialog.title`,{name:h.name}):u(`page.title`)]}),(0,x.jsx)(g,{children:u(`projectDialog.description`)})]}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,x.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:S.map(e=>{let t=e.icon;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>C(e.id),className:_(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,v===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,x.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,x.jsx)(`span`,{className:`truncate`,children:u(e.labelKey)})]},e.id)})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,x.jsx)(`div`,{className:w(`general`),children:(0,x.jsx)(m,{})}),(0,x.jsx)(`div`,{className:w(`budget`),children:(0,x.jsx)(s,{})}),(0,x.jsx)(`div`,{className:w(`telemetry`),children:(0,x.jsx)(p,{})}),(0,x.jsx)(`div`,{className:w(`terminal`),children:(0,x.jsx)(l,{mode:`project`})})]})]})]})})}export{C as ProjectSettingsDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-BNv3lrIs.js";var t=e({approval:()=>D,attachFile:()=>H,chip:()=>P,close:()=>f,composerPlaceholder:()=>a,confirmDeleteConversation:()=>W,confirmShort:()=>G,connecting:()=>_,consultingCode:()=>v,copy:()=>c,default:()=>Q,degraded:()=>j,deleteConversation:()=>U,effort:()=>q,emptyHint:()=>h,emptyTitle:()=>m,emptyTitleMatrix:()=>J,error:()=>N,git:()=>w,history:()=>x,home:()=>z,imagesUnsupported:()=>K,maximize:()=>l,minimize:()=>d,mission:()=>k,model:()=>b,newAgent:()=>F,newConversation:()=>p,noProvider:()=>A,prCard:()=>Y,project:()=>O,provider:()=>T,queue:()=>S,queueEdit:()=>C,refs:()=>Z,restore:()=>u,search:()=>R,send:()=>o,size:()=>y,specDraft:()=>X,stop:()=>s,subtitle:()=>r,switchToAgent:()=>I,switchToKanban:()=>L,thinking:()=>g,tier:()=>E,title:()=>n,toolCard:()=>M,trigger:()=>i,untitled:()=>B,workspace:()=>V}),n=`Mission Control`,r=`Operate Specrails by chatting`,i=`Mission Control`,a=`Ask the agent to do anything…`,o=`Send`,s=`Stop`,c=`Copy`,l=`Maximize`,u=`Restore`,d=`Minimize`,f=`Close`,p=`New mission`,m=`What's the mission?`,h=`Pick a project, then ask. The board updates live as the agent works.`,g=`Thinking…`,_=`Connecting…`,v=`Consulting the app…`,y={compact:`Compact`,comfortable:`Comfortable`,max:`Maximize`},b={label:`Model`},x={hint:`Browsing prompt history — type to edit, ↑↓ to navigate`},S={queued:`Queued`,send:`Send to queue`,sendHint:`The agent is still working — this message will queue and run next`,placeholder:`Add more while the agent works — it will queue…`},C={editing:`Editing queued message {{n}} of {{m}}`,hint:`↑↓ to navigate · Enter saves · Esc cancels`,save:`Save queued message`,cancel:`Cancel editing`,dispatched:`That queued message was already sent — your text is kept as a draft`,saveFailed:`Couldn't save the queued message`},w={branch:`Branch`,detached:`(detached)`,dirty:`Uncommitted changes`,switched:`Switched to {{branch}}`,switchFailed:`Couldn't switch branch`,lockedWhileWorking:`Branch locked while the agent works`,searchPlaceholder:`Search branches…`,noMatches:`No branches match`,worktrees:`Worktrees`,worktreePathCopied:`Worktree path copied`,copyWorktreePath:`Copy worktree path`},T={label:`Provider`,claude:`Claude`,codex:`Codex`,gemini:`Gemini`},E={cycleHint:`⇧⇥ to change`,observe:{name:`Observe`,desc:`Read only — nothing changes`},edit:{name:`Edit`,desc:`Create and edit (reversible)`},operate:{name:`Operate`,desc:`Launch AI — costs money`},autonomous:{name:`Autonomous`,desc:`Delete and kill — irreversible`},lockedTitle:`Needs a higher level`,lockedBody:`That action needs the "{{level}}" level. You're on "{{current}}".`,raiseHint:`⇧⇥ to raise the level, or ask another way.`},D={title:`Confirm action`,costAction:`{{action}} · ~{{cost}} · {{tier}}`,approve:`Approve`,cancel:`Cancel`,dontAskAgain:`Don't ask again this session`,approved:`Approved`,cancelled:`Cancelled`},O={home:`Home`,searchPlaceholder:`Talk to Specrails…`,recents:`Recents`,allProjects:`All projects`,searchAll:`Search across all projects`,addProject:`Add project…`,homeHint:`No project selected — operating across all projects.`,askCreateOrSearch:`No project is selected. Do you want to create a new project, or search across all projects?`},k={label:`Switch mission`,untitled:`New mission`,new:`New mission`,searchPlaceholder:`Search missions…`,noMatches:`No missions match`,working:`Agent working`,queuedBadge:`{{n}} queued`,delete:`Delete mission "{{title}}"`,deleteConfirm:`Delete?`,deleteLiveConfirm:`Agent is working — delete anyway?`,confirmDelete:`Confirm delete`,cancelDelete:`Keep mission`,deleteFailed:`Couldn't delete the mission`},A={title:`No AI provider installed`,body:`The agent needs Claude, Codex or Gemini on your machine. Install one, then reopen the agent to start chatting.`,placeholder:`Install an AI provider to use the agent…`},j={title:`Specrails MCP is off`,body:`The agent needs the embedded MCP server to operate the app.`,enable:`Enable Specrails MCP`,enabling:`Enabling…`,enabled:`MCP enabled`},M={live:`live`,queued:`queued`,running:`running`,done:`done`,failed:`failed`},N={generic:`Something went wrong. Try again.`,busy:`The agent is busy. Try again in a moment.`},P={kindAgent:`Agent mission`},F=`New Mission`,I=`Switch to Mission Control`,L=`Switch to Board`,R=`Search`,z=`Home`,B=`Untitled`,V={title:`On workspace`,terminal:`Terminal`,files:`Files`,browser:`Browser`,requiresProject:`Select a project to use this tool`,resizeCode:`Resize code pane`,closeFiles:`Close code`,browserConfirm:`Add to agent`,browserCaptured:`Capture added`,uploadFailed:`Upload failed`,requiresConversation:`Start a mission to use this tool`,jobs:`Jobs`,closeJobs:`Close jobs`,resizeJobs:`Resize jobs pane`,noJobs:`No jobs yet — ask the agent to launch one`},H=`Attach file`,U=`Delete "{{title}}"`,W=`Confirm delete "{{title}}"`,G=`confirm?`,K=`This provider can't read images yet — attach text files instead`,q={label:`Effort`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`},J=`What's the mission, Neo?`,Y={rail:`Rail {{index}}`,specCount_one:`{{count}} spec`,specCount_other:`{{count}} specs`,base:`Base branch`,openPr:`Open PR`,title:{building:`Implementing in an isolated worktree…`,on_review:`Implementation ready for review`,pr_draft:`Draft PR created`,pr_draft_degraded:`PR delivery incomplete`,pr_ready:`PR ready for merge`,pr_failed:`PR creation failed`,merged:`PR merged`,discarded:`Discarded`},buildingHint:`You'll be asked to create the PR when it settles.`,createPr:`Create PR`,publish:`Publish`,retry:`Retry`,retryPr:`Retry PR`,checkMerge:`Check merge`,discard:`Discard`,confirmDiscard:`Confirm discard?`,mergedNote:`Merged — specs moved to Done`,discardedNote:`Discarded — specs returned to the backlog`,degraded:{pushed:`The branch was pushed but the PR could not be created — retry to finish.`,localOnly:`The changes were assembled locally but not pushed — retry to publish the PR.`},alreadyResolved:`Already resolved elsewhere`,actionFailed:`Action failed`,notMergedYet:`Not merged yet`,viewLog:`View run log for {{ref}}`,runElapsedAria:`{{elapsed}} elapsed`,runCostAria:`{{cost}} spent`,pinned:{label:`Pinned`,marker:`Implementation card — pinned above`,collapse:`Minimize pinned card`,expand:`Expand pinned card`,expandCard:`Expand this card`,collapseCard:`Minimize this card`,collapsed_one:`Implementation card`,collapsed_other:`{{count}} implementation cards`,state:{building:`Building`,on_review:`Review`,pr_draft:`Draft PR`,pr_ready:`Published`,pr_failed:`Failed`,merged:`Merged`,discarded:`Discarded`}},mergeLocal:`Integrate locally`,mergeLocalTooltip:`Merge the delivered branches into {{base}} in your local checkout (no GitHub needed)`,mergeLocalBlockedDirty:`Cannot integrate: your working tree on {{base}} has uncommitted changes. Commit or stash them, then retry.`,mergeLocalBlockedBranch:`Cannot integrate: your checkout is on {{current}}, not {{base}}. Check out {{base}}, then retry.`,mergedLocally:`Integrated into {{base}} locally`},X={heading:`Spec draft`,drafting:`Updating draft…`,acceptanceCriteria:`Acceptance criteria`,untitled:`Untitled spec`,expand:`Show full description`,collapse:`Collapse description`},Z={openTicket:`Open spec #{{id}}`,openJob:`Open job {{id}}`,openLoop:`Open loop {{id}}`,ticketNotFound:`Spec #{{id}} not found — it may have been deleted`,jobNotFound:`Job not found — it may have been deleted`,loopNotFound:`Loop not found — it may have been deleted`,lookupFailed:`Couldn't verify the reference — try again`},Q={title:n,subtitle:r,trigger:i,composerPlaceholder:a,send:o,stop:s,copy:c,maximize:l,restore:u,minimize:d,close:f,newConversation:p,emptyTitle:m,emptyHint:h,thinking:g,connecting:_,consultingCode:v,size:y,model:b,history:x,queue:S,queueEdit:C,git:w,provider:T,tier:E,approval:D,project:O,mission:k,noProvider:A,degraded:j,toolCard:M,error:N,chip:P,newAgent:F,switchToAgent:I,switchToKanban:L,search:R,home:z,untitled:B,workspace:V,attachFile:H,deleteConversation:U,confirmDeleteConversation:W,confirmShort:G,imagesUnsupported:K,effort:q,emptyTitleMatrix:J,prCard:Y,specDraft:X,refs:Z};export{t};
|