@newrelic/preflight 1.14.29 → 1.14.30
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/dist/dashboard/routes/api-handler.d.ts.map +1 -1
- package/dist/dashboard/routes/api-handler.js +7 -0
- package/dist/dashboard/routes/api-handler.js.map +1 -1
- package/dist/web/assets/index-CJRa61WL.css +2 -0
- package/dist/web/assets/{index-DZC9_gwP.js → index-CZYfFRqA.js} +2 -2
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-BRjjDCoR.css +0 -2
|
@@ -60,5 +60,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
60
60
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function EI(e,t){if(e){if(typeof e==`string`)return DI(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?DI(e,t):void 0}}function DI(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function OI(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function kI(e){if(Array.isArray(e))return e}function AI(e,t){if(e==null)return{};var n,r,i=jI(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 jI(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 MI(){return MI=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},MI.apply(null,arguments)}function NI(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 PI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?NI(Object(n),!0).forEach(function(t){FI(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function FI(e,t,n){return(t=II(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function II(e){var t=LI(e,`string`);return typeof t==`symbol`?t:t+``}function LI(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 RI={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:Bv.axis};function zI(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=PI(PI(PI({},c),to(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=PI(PI({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=PI(PI({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return F.createElement(`line`,MI({},l,{className:Ya(`recharts-cartesian-axis-line`,(0,To.default)(s,`className`))}))}function BI(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=G(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function VI(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function HI(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function UI(e){var t=e.option,n=e.tickProps,r=e.value,i,a=Ya(n.className,`recharts-cartesian-axis-tick-value`);if(F.isValidElement(t))i=F.cloneElement(t,PI(PI({},n),{},{className:a}));else if(typeof t==`function`)i=t(PI(PI({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=Ya(o,nN(t))),i=F.createElement(dM,MI({},n,{className:o}),r)}return i}function WI(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=Wc(),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(!(r==null||n==null)){var e=t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),o=a.current;o!=null&&o.axisId===r&&o.axisType===n&&(0,SI.default)(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(yI({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,F.useEffect)(()=>r==null||n==null?zo:()=>{i(bI({axisId:r,axisType:n}))},[i,r,n]),null}var GI=(0,F.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,v=e.tickMargin,y=e.fontSize,b=e.letterSpacing,x=e.getTicksConfig,S=e.events,C=e.axisType,w=e.axisId,T=mI(PI(PI({},x),{},{ticks:r}),y,b),E=to(x),D=no(i),O=eM(E.textAnchor)?E.textAnchor:VI(d,f),k=HI(d,f),A={};typeof a==`object`&&(A=a);var j=PI(PI({},E),{},{fill:`none`},A),ee=T.map(e=>PI({entry:e},BI(e,p,m,h,g,d,_,f,v))),M=ee.map(e=>{var t=e.entry,n=e.line;return F.createElement(mo,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&F.createElement(`line`,MI({},j,n,{className:Ya(`recharts-cartesian-axis-tick-line`,(0,To.default)(a,`className`))})))}),te=ee.map((e,t)=>{var n=e.entry,r=e.tick,a=PI(PI({},PI(PI(PI(PI({verticalAnchor:k},E),{},{textAnchor:O,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:T.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??E.angle??0})),D);return F.createElement(mo,MI({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},$s(S,n,t)),i&&F.createElement(UI,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return F.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},F.createElement(WI,{ticks:T,axisId:w,axisType:C}),te.length>0&&F.createElement(Qk,{zIndex:Bv.label},F.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},te)),M.length>0&&F.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},M))}),KI=(0,F.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=AI(e,CI),d=wI((0,F.useState)(``),2),f=d[0],p=d[1],m=wI((0,F.useState)(``),2),h=m[0],g=m[1],_=(0,F.useRef)(null);(0,F.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>hI({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>gI({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var v=(0,F.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:F.createElement(Qk,{zIndex:e.zIndex},F.createElement(mo,{className:Ya(`recharts-cartesian-axis`,a)},F.createElement(zI,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:to(e)}),F.createElement(GI,{ref:v,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),F.createElement(CM,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},F.createElement(LM,{label:e.label,labelRef:e.labelRef}),e.children)))}),qI=F.forwardRef((e,t)=>{var n=ac(e,RI);return F.createElement(KI,MI({},n,{ref:t}))});qI.displayName=`CartesianAxis`;var JI=(0,F.createContext)({grid:{stroke:`#ccc`,fill:`none`}});JI.Provider;var YI=()=>(0,F.useContext)(JI),XI=[`x1`,`y1`,`x2`,`y2`,`key`],ZI=[`offset`],QI=[`xAxisId`,`yAxisId`],$I=[`xAxisId`,`yAxisId`];function eL(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 tL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?eL(Object(n),!0).forEach(function(t){nL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function nL(e,t,n){return(t=rL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rL(e){var t=iL(e,`string`);return typeof t==`symbol`?t:t+``}function iL(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 aL(){return aL=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},aL.apply(null,arguments)}function oL(e,t){if(e==null)return{};var n,r,i=sL(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 sL(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 cL=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return F.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function lL(e){var t=e.option,n=e.lineItemProps,r;if(F.isValidElement(t))r=F.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=to(oL(n,XI))??{};l.offset;var u=oL(l,ZI),d=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(`,`):u.strokeDasharray;r=F.createElement(`line`,aL({},u,{strokeDasharray:d,x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function uL(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0||r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=oL(e,QI),s=a.map((e,r)=>{var a=tL(tL({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return F.createElement(lL,{key:`line-${r}`,option:i,lineItemProps:a})});return F.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function dL(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0||r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=oL(e,$I),s=a.map((e,r)=>{var a=tL(tL({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return F.createElement(lL,{option:i,lineItemProps:a,key:`line-${r}`})});return F.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function fL(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return F.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return F.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function pL(e){var t=e.vertical,n=t===void 0||t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return F.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return F.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var mL=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return Pf(mI(tL(tL(tL({},RI),n),{},{ticks:Ff(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},hL=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return Pf(mI(tL(tL(tL({},RI),n),{},{ticks:Ff(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},gL={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Bv.grid};function _L(e){var t=sm(),n=cm(),r=om(),i=tL(tL({},ac(e,gL)),{},{x:G(e.x)?e.x:r.left,y:G(e.y)?e.y:r.top,width:G(e.width)?e.width:r.width,height:G(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=bp(),h=K(e=>SD(e,`xAxis`,a,m)),g=K(e=>SD(e,`yAxis`,o,m)),_=YI(),v={stroke:i.stroke??_.grid.stroke,strokeWidth:i.strokeWidth??_.grid.strokeWidth,strokeOpacity:i.strokeOpacity??_.grid.strokeOpacity,strokeDasharray:i.strokeDasharray??_.grid.strokeDasharray};if(!Tf(l)||!Tf(u)||!G(s)||!G(c))return null;var y=i.verticalCoordinatesGenerator||mL,b=i.horizontalCoordinatesGenerator||hL,x=i.horizontalPoints,S=i.verticalPoints;if((!x||!x.length)&&typeof b==`function`){var C=f&&f.length,w=b({yAxis:g?tL(tL({},g),{},{ticks:C?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},C?!0:d);Dp(Array.isArray(w),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof w}]`),Array.isArray(w)&&(x=w)}if((!S||!S.length)&&typeof y==`function`){var T=p&&p.length,E=y({xAxis:h?tL(tL({},h),{},{ticks:T?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},T?!0:d);Dp(Array.isArray(E),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof E}]`),Array.isArray(E)&&(S=E)}return F.createElement(Qk,{zIndex:i.zIndex},F.createElement(`g`,{className:`recharts-cartesian-grid`},F.createElement(cL,{fill:i.fill??_.grid.fill,fillOpacity:i.fillOpacity??_.grid.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),F.createElement(fL,aL({},i,{horizontalPoints:x})),F.createElement(pL,aL({},i,{verticalPoints:S})),F.createElement(uL,aL({},i,v,{offset:r,horizontalPoints:x,xAxis:h,yAxis:g})),F.createElement(dL,aL({},i,v,{offset:r,verticalPoints:S,xAxis:h,yAxis:g}))))}_L.displayName=`CartesianGrid`;var vL=Od({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),yL=vL.actions;yL.addErrorBar,yL.replaceErrorBar,yL.removeErrorBar;var bL=vL.reducer,xL=[`children`];function SL(e,t){if(e==null)return{};var n,r,i=CL(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 CL(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 wL=(0,F.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function TL(e){var t=e.children,n=SL(e,xL);return F.createElement(wL.Provider,{value:n},t)}function EL(e,t){var n=K(t=>CT(t,e)),r=K(e=>ET(e,t)),i=n?.allowDataOverflow??xT.allowDataOverflow,a=r?.allowDataOverflow??wT.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function DL(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=HP(),a=EL(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=K(e=>XE(e,t,!1)),u=K(e=>ZE(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,v=s&&u?Math.abs(u[1]-u[0]):m*2;return F.createElement(`clipPath`,{id:`clipPath-${r}`},F.createElement(`rect`,{x:h,y:g,width:_,height:v}))}function OL(e){var t=no(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,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}}function kL(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function AL(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var jL=(e,t,n)=>TD(e,`xAxis`,kL(e,t),n),ML=(e,t,n)=>wD(e,`xAxis`,kL(e,t),n),NL=(e,t,n)=>TD(e,`yAxis`,AL(e,t),n),PL=(e,t,n)=>wD(e,`yAxis`,AL(e,t),n),FL=q([lm,jL,NL,ML,PL],(e,t,n,r,i)=>Nf(e,`xAxis`)?Jf(t,r,!1):Jf(n,i,!1)),IL=q([PT,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),LL=e=>Nf(lm(e),`xAxis`)?`yAxis`:`xAxis`,RL=(e,t)=>LL(e)===`yAxis`?AL(e,t):kL(e,t),zL=(e,t,n)=>oE(e,LL(e),RL(e,t),n),BL=q([lm,jL,NL,ML,PL,q([IL,zL],(e,t)=>{if(!(e==null||t==null)){var n=e.stackId,r=ly(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),ev,FL,IL,zv,q([IL,zL],(e,t)=>{if(!(e==null||e.stackId==null||t==null)){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(Ro)}})],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return yR({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),VL=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],HL=[`id`,`baseLine`];function UL(){return UL=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},UL.apply(null,arguments)}function WL(e,t){if(e==null)return{};var n,r,i=GL(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 GL(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 KL(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!$(a)||!$(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return G(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),G(c)?F.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function qL(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!$(a)||!$(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return G(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),G(c)?F.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function JL(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?F.createElement(qL,{alpha:t,points:r,baseLine:i,strokeWidth:a}):F.createElement(KL,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function YL(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=WL(e,VL),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=nP(),h=d.id,g=d.baseLine,_=to(WL(d,HL)),v=F.createElement(Gh,UL({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),y=l!==`none`&&F.createElement(Gh,UL({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),b=l!==`none`&&c&&Array.isArray(g)&&F.createElement(Gh,UL({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?F.createElement(mo,null,F.createElement(`defs`,null,F.createElement(`clipPath`,{id:m},F.createElement(JL,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),F.createElement(mo,{clipPath:`url(#${m})`},v,y,b)):F.createElement(F.Fragment,null,v,y,b)}var XL=[`id`],ZL=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function QL(){return QL=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},QL.apply(null,arguments)}function $L(e,t){if(e==null)return{};var n,r,i=eR(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 eR(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 tR(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 nR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tR(Object(n),!0).forEach(function(t){rR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rR(e,t,n){return(t=iR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function iR(e){var t=aR(e,`string`);return typeof t==`symbol`?t:t+``}function aR(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 oR={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:NN,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[nR(nR({},e.next),{},{x:Po(e.prev.x,e.next.x,t),y:Po(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:YL,xAxisId:0,yAxisId:0,zIndex:Bv.area};function sR(e,t){return e&&e!==`none`?e:t}var cR=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:sR(r,i),value:Xf(n,t),payload:e}]},lR=F.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:zo,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Xf(o,t),hide:s,type:u,color:sR(r,a),unit:c,formatter:l,graphicalItemId:d}};return F.createElement(TN,{tooltipEntrySettings:f})});function uR(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=to(r);return F.createElement(wP,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function dR(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return nR(nR({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return F.createElement(GM,{value:t?r:void 0},n)}function fR(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=$L(a,XL),_=nR(nR({},ro(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return F.createElement(F.Fragment,null,t?.length>1&&F.createElement(mo,{clipPath:r?`url(#clipPath-${i})`:void 0},F.createElement(xN,{option:m,DefaultShape:oR.shape,shapeProps:_})),F.createElement(uR,{points:t,props:g,clipPathId:i}))}function pR(e,t,n){return G(e)?Po(G(t)?t:void 0,e,n):Io(e)||Do(e)?Po(G(t)?t:void 0,0,n):e}function mR(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,F.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=VN(m,a),g=dm(),_=JN(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,b=_.handleAnimationEnd,x=h.startValue;if(g==null)return null;var S=Array.isArray(s)&&Array.isArray(x)?BN(x,s,f):Array.isArray(s)?BN(null,s,f):null;return F.createElement(YN,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:b,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(S,i,g):a?s:pR(s,x,i);return h.syncStepValue(c,i),F.createElement(dR,{showLabels:!v,points:o},r.children,F.createElement(fR,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),F.createElement(XM,{label:r.label}))})}function hR(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,F.useRef)(null),a=(0,F.useRef)();return F.createElement(mR,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var gR=class extends F.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=Ya(`recharts-area`,i),g=f,_=OL(n),v=_.r,y=_.strokeWidth,b=uN(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return F.createElement(Qk,{zIndex:m},F.createElement(mo,{className:h},s&&F.createElement(`defs`,null,F.createElement(DL,{clipPathId:g,xAxisId:c,yAxisId:l}),!b&&F.createElement(`clipPath`,{id:`clipPath-dots-${g}`},F.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:d+x}))),F.createElement(hR,{needClip:s,clipPathId:g,props:this.props})),F.createElement(XP,{points:r,mainColor:sR(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(p)&&F.createElement(XP,{points:p,mainColor:sR(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}};function _R(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=$L(e,ZL),g=um(),_=vk(),v=EL(p,m).needClip,y=bp(),b=K(t=>BL(t,e.id,y))??{},x=b.points,S=b.isRange,C=b.baseLine,w=HP();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var T=w.height,E=w.width,D=w.x,O=w.y;return!x||!x.length?null:F.createElement(gR,QL({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:D,top:O,xAxisId:p,yAxisId:m}))}var vR=(e,t,n,r,i)=>{var a=n??t;if(G(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function yR(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=vR(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=jf(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=jf(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>jf(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:Bf({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:Bf({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function bR(e){var t=ac(e,oR),n=bp();return F.createElement(aP,{id:t.id,type:`area`},e=>F.createElement(F.Fragment,null,F.createElement(EN,{legendPayload:cR(t)}),F.createElement(lR,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),F.createElement(fP,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:zf(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),F.createElement(_R,QL({},t,{id:e}))))}var xR=F.memo(bR,zm);xR.displayName=`Area`;var SR=`Invariant failed`;function CR(e,t){if(!e)throw Error(SR)}var wR=[`option`];function TR(e,t){if(e==null)return{};var n,r,i=ER(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 ER(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 DR=h_;function OR(e){var t=e.option,n=TR(e,wR);return F.createElement(xN,{option:t,DefaultShape:DR,shapeProps:n,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`})}var kR=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(G(e))return e;var i=G(n)||Io(n);return i?e(n,r):(!i&&CR(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},AR=(e,t,n)=>n,jR=q([PT,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),MR=q([jR],e=>e?.maxBarSize),NR=(e,t,n,r)=>r,PR=q([lm,PT,kL,AL,AR],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),FR=(e,t,n)=>{var r=lm(e),i=kL(e,t),a=AL(e,t);if(!(i==null||a==null))return r===`horizontal`?oE(e,`yAxis`,a,n):oE(e,`xAxis`,i,n)},IR=q([PR,Mv,(e,t)=>{var n=lm(e),r=kL(e,t),i=AL(e,t);if(!(r==null||i==null))return n===`horizontal`?yD(e,`xAxis`,r):yD(e,`yAxis`,i)}],iF),LR=(e,t,n)=>{var r=jR(e,t);if(r==null)return 0;var i=kL(e,t),a=AL(e,t);if(i==null||a==null)return 0;var o=lm(e),s=kv(e),c=r.maxBarSize,l=Io(c)?s:c,u,d;return o===`horizontal`?(u=TD(e,`xAxis`,i,n),d=wD(e,`xAxis`,i,n)):(u=TD(e,`yAxis`,a,n),d=wD(e,`yAxis`,a,n)),Jf(u,d,!0)??l??0},RR=(e,t,n)=>{var r=lm(e),i=kL(e,t),a=AL(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=TD(e,`xAxis`,i,n),s=wD(e,`xAxis`,i,n)):(o=TD(e,`yAxis`,a,n),s=wD(e,`yAxis`,a,n)),Jf(o,s)}},zR=q([gp,vp,(e,t,n)=>{var r=kL(e,t);if(r!=null)return TD(e,`xAxis`,r,n)},(e,t,n)=>{var r=AL(e,t);if(r!=null)return TD(e,`yAxis`,r,n)},(e,t,n)=>{var r=kL(e,t);if(r!=null)return wD(e,`xAxis`,r,n)},(e,t,n)=>{var r=AL(e,t);if(r!=null)return wD(e,`yAxis`,r,n)},q([q([IR,kv,Av,jv,LR,RR,MR],dF),jR],pF),lm,ev,RR,q([FR,jR],fF),jR,NR],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var p=c.chartData,m=c.dataStartIndex,h=c.dataEndIndex;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var g=d.data,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return Oz({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),BR=[`index`];function VR(){return VR=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},VR.apply(null,arguments)}function HR(e,t){if(e==null)return{};var n,r,i=UR(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 UR(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 WR=(0,F.createContext)(void 0),GR=e=>{var t=(0,F.useContext)(WR);if(t!=null)return t.stackId;if(e!=null)return zf(e)},KR=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,qR=e=>{var t=(0,F.useContext)(WR);if(t!=null){var n=t.stackId;return`url(#${KR(n,e)})`}},JR=e=>{var t=e.index,n=HR(e,BR),r=qR(t);return F.createElement(mo,VR({className:`recharts-bar-stack-layer`,clipPath:r},n))},YR=[`onMouseEnter`,`onMouseLeave`,`onClick`],XR=[`value`,`background`,`tooltipPosition`],ZR=[`id`],QR=[`onMouseEnter`,`onClick`,`onMouseLeave`];function $R(e,t){return iz(e)||rz(e,t)||tz(e,t)||ez()}function ez(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
61
61
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tz(e,t){if(e){if(typeof e==`string`)return nz(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nz(e,t):void 0}}function nz(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function rz(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function iz(e){if(Array.isArray(e))return e}function az(){return az=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},az.apply(null,arguments)}function oz(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 sz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?oz(Object(n),!0).forEach(function(t){cz(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cz(e,t,n){return(t=lz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lz(e){var t=uz(e,`string`);return typeof t==`symbol`?t:t+``}function uz(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 dz(e,t){if(e==null)return{};var n,r,i=fz(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 fz(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 pz=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:Xf(n,t),payload:e}]},mz=F.memo(e=>{var t=e.dataKey,n=e.stroke,r=e.strokeWidth,i=e.fill,a=e.name,o=e.hide,s=e.unit,c=e.formatter,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:void 0,getPosition:zo,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Xf(a,t),hide:o,type:l,color:i,unit:s,formatter:c,graphicalItemId:u}};return F.createElement(TN,{tooltipEntrySettings:d})});function hz(e){var t=K(JO),n=e.data,r=e.dataKey,i=e.background,a=e.allOtherBarProps,o=a.onMouseEnter,s=a.onMouseLeave,c=a.onClick,l=dz(a,YR),u=SN(o,r,a.id),d=CN(s),f=wN(c,r,a.id);if(!i||n==null)return null;var p=no(i);return F.createElement(Qk,{zIndex:mF(i,Bv.barBackground)},n.map((e,n)=>{e.value;var a=e.background;e.tooltipPosition;var o=dz(e,XR);if(!a)return null;var s=u(e,e.originalDataIndex),c=d(e,e.originalDataIndex),m=f(e,e.originalDataIndex),h=sz(sz(sz(sz(sz({option:i,isActive:String(e.originalDataIndex)===t},o),{},{fill:`#eee`},a),p),$s(l,e,n)),{},{onMouseEnter:s,onMouseLeave:c,onClick:m,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return F.createElement(OR,az({key:`background-bar-${n}`},h))}))}function gz(e){var t=e.showLabels,n=e.children,r=e.rects?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return sz(sz({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return F.createElement(GM,{value:t?r:void 0},n)}function _z(e){var t=e.shape,n=e.activeBar,r=e.baseProps,i=e.entry,a=e.index,o=e.dataKey,s=K(JO),c=K(XO),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),u=s!=null&&(String(i.originalDataIndex)!==s||c!=null&&o!==c),d=$R((0,F.useState)(!1),2),f=d[0],p=d[1],m=$R((0,F.useState)(!1),2),h=m[0],g=m[1];(0,F.useEffect)(()=>{var e;return l?(p(!0),e=requestAnimationFrame(()=>{g(!0)})):(g(!1),u&&p(!1)),()=>{cancelAnimationFrame(e)}},[l,u]);var _=(0,F.useCallback)(()=>{l||p(!1)},[l]),v=l&&h,y=l||f,b=l?n===!0?t:n:t,x=F.createElement(OR,az({},r,{name:String(r.name)},i,{isActive:v,option:b,index:a,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:_}));return y?F.createElement(Qk,{zIndex:Bv.activeBar},F.createElement(JR,{index:i.originalDataIndex},x)):x}function vz(e){var t=e.shape,n=e.baseProps,r=e.entry,i=e.index,a=e.dataKey;return F.createElement(OR,az({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function yz(e){var t=e.data,n=e.props,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=to(n)??{},s=o.id,c=dz(o,ZR),l=n.shape,u=n.dataKey,d=n.activeBar,f=n.onMouseEnter,p=n.onClick,m=n.onMouseLeave,h=dz(n,QR),g=SN(f,u,s),_=CN(m),v=wN(p,u,s);return t?F.createElement(F.Fragment,null,t.map((e,t)=>F.createElement(JR,az({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},$s(h,e,t),{onMouseEnter:g(e,e.originalDataIndex),onMouseLeave:_(e,e.originalDataIndex),onClick:v(e,e.originalDataIndex)}),d?F.createElement(_z,{shape:l,activeBar:d,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a}):F.createElement(vz,{shape:l,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a})))):null}var bz=(e,t,n)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>{if(e.status===`removed`)return n===`horizontal`?[sz(sz({},e.prev),{},{height:Po(e.prev.height,0,t),y:Po(e.prev.y,e.prev.y+e.prev.height,t)})]:[sz(sz({},e.prev),{},{width:Po(e.prev.width,0,t)})];if(e.status===`matched`)return[sz(sz({},e.next),{},{x:Po(e.prev.x,e.next.x,t),y:Po(e.prev.y,e.next.y,t),width:Po(e.prev.width,e.next.width,t),height:Po(e.prev.height,e.next.height,t)})];var r=e.next;return n===`horizontal`?[sz(sz({},r),{},{height:Po(0,r.height,t),y:Po(r.stackedBarStart,r.y,t)})]:[sz(sz({},r),{},{width:Po(0,r.width,t),x:Po(r.stackedBarStart,r.x,t)})]});function xz(e){var t=e.props,n=e.previousRectanglesRef,r=t.data,i=t.isAnimationActive,a=t.animationBegin,o=t.animationDuration,s=t.animationEasing,c=t.animationInterpolateFn,l=t.layout,u=JN(t.onAnimationStart,t.onAnimationEnd),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd;return F.createElement(gz,{showLabels:!d,rects:r},F.createElement(YN,{animationInput:r,animationIdPrefix:`recharts-bar-`,items:r,previousItemsRef:n,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:p,animationInterpolateFn:c,animationMatchBy:t.animationMatchBy,layout:l},(e,n,r)=>F.createElement(mo,null,F.createElement(yz,{props:t,data:e,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))),F.createElement(XM,{label:t.label}),t.children)}function Sz(e){var t=(0,F.useRef)(null);return F.createElement(xz,{previousRectanglesRef:t,props:e})}var Cz=0,wz=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:jf(e,t)}},Tz=class extends F.PureComponent{render(){var e=this.props,t=e.hide,n=e.data,r=e.dataKey,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.needClip,c=e.background,l=e.id;if(t||n==null)return null;var u=Ya(`recharts-bar`,i),d=l;return F.createElement(mo,{className:u,id:l},s&&F.createElement(`defs`,null,F.createElement(DL,{clipPathId:d,xAxisId:a,yAxisId:o})),F.createElement(mo,{className:`recharts-bar-rectangles`,clipPath:s?`url(#clipPath-${d})`:void 0},F.createElement(hz,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),F.createElement(Sz,this.props)))}},Ez={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,animationInterpolateFn:bz,animationMatchBy:PN,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:Cz,shape:DR,xAxisId:0,yAxisId:0,zIndex:Bv.bar};function Dz(e){var t=e.xAxisId,n=e.yAxisId,r=e.hide,i=e.legendType,a=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,u=e.isAnimationActive,d=EL(t,n).needClip,f=um(),p=bp(),m=lN(e.children,QA),h=K(t=>zR(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,F.createElement(TL,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:wz,errorBarOffset:g},F.createElement(Tz,az({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function Oz(e){var t=e.layout,n=e.barSettings,r=n.dataKey,i=n.minPointSize,a=n.hasCustomShape,o=e.pos,s=e.bandSize,c=e.xAxis,l=e.yAxis,u=e.xAxisTicks,d=e.yAxisTicks,f=e.stackedData,p=e.displayedData,m=e.offset,h=e.cells,g=e.parentViewBox,_=e.dataStartIndex,v=t===`horizontal`?l:c,y=f?v.scale.domain():null,b=Hf({numericAxis:v}),x=v.scale.map(b);return p.map((e,n)=>{var p,v,S,C,w,T;if(f){var E=f[n+_];if(E==null)return null;p=If(E,y)}else p=jf(e,r),Array.isArray(p)||(p=[b,p]);var D=kR(i,Cz)(p[1],n);if(t===`horizontal`){var O=l.scale.map(p[0]),k=l.scale.map(p[1]);if(O==null||k==null)return null;v=Vf({axis:c,ticks:u,bandSize:s,offset:o.offset,entry:e,index:n}),S=k??O??void 0,C=o.size;var A=O-k;if(w=Do(A)?0:A,T={x:v,y:m.top,width:C,height:m.height},Math.abs(D)>0&&Math.abs(w)<Math.abs(D)){var j=Eo(w||D)*(Math.abs(D)-Math.abs(w));S-=j,w+=j}}else{var ee=c.scale.map(p[0]),M=c.scale.map(p[1]);if(ee==null||M==null)return null;if(v=ee,S=Vf({axis:l,ticks:d,bandSize:s,offset:o.offset,entry:e,index:n}),C=M-ee,w=o.size,T={x:m.left,y:S,width:m.width,height:w},Math.abs(D)>0&&Math.abs(C)<Math.abs(D)){var te=Eo(C||D)*(Math.abs(D)-Math.abs(C));C+=te}}return v==null||S==null||C==null||w==null||!a&&(C===0||w===0)?null:sz(sz({},e),{},{stackedBarStart:x,x:v,y:S,width:C,height:w,value:f?p:p[1],payload:e,background:T,tooltipPosition:{x:v+C/2,y:S+w/2},parentViewBox:g,originalDataIndex:n},h&&h[n]&&h[n].props)}).filter(Boolean)}function kz(e){var t=ac(e,Ez),n=GR(t.stackId),r=bp();return F.createElement(aP,{id:t.id,type:`bar`},e=>F.createElement(F.Fragment,null,F.createElement(EN,{legendPayload:pz(t)}),F.createElement(mz,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),F.createElement(fP,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null&&t.shape!==DR}),F.createElement(Qk,{zIndex:t.zIndex},F.createElement(Dz,az({},t,{id:e})))))}var Az=F.memo(kz,zm);Az.displayName=`Bar`;var jz=[`domain`,`range`],Mz=[`domain`,`range`];function Nz(e,t){if(e==null)return{};var n,r,i=Pz(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 Pz(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 Fz(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function Iz(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=Nz(e,jz),a=t.domain,o=t.range,s=Nz(t,Mz);return!Fz(n,a)||!Fz(r,o)?!1:zm(i,s)}var Lz=[`type`],Rz=[`dangerouslySetInnerHTML`,`ticks`,`scale`],zz=[`id`,`scale`];function Bz(){return Bz=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},Bz.apply(null,arguments)}function Vz(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 Hz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Vz(Object(n),!0).forEach(function(t){Uz(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Uz(e,t,n){return(t=Wz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wz(e){var t=Gz(e,`string`);return typeof t==`symbol`?t:t+``}function Gz(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 Kz(e,t){if(e==null)return{};var n,r,i=qz(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 qz(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 Jz(e){var t=Wc(),n=(0,F.useRef)(null),r=dm(),i=e.type,a=Kz(e,Lz),o=Wv(r,`xAxis`,i),s=(0,F.useMemo)(()=>{if(o!=null)return Hz(Hz({},a),{},{type:o})},[a,o]);return(0,F.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(MP(s)):n.current!==s&&t(NP({prev:n.current,next:s})),n.current=s)},[s,t]),(0,F.useLayoutEffect)(()=>()=>{n.current&&=(t(PP(n.current)),null)},[t]),null}var Yz=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,F.useRef)(null),o=(0,F.useRef)(null),s=K(vp),c=bp(),l=Wc(),u=`xAxis`,d=K(e=>CD(e,u,t,c)),f=K(e=>dD(e,t)),p=K(e=>gD(e,t)),m=K(e=>ST(e,t));if((0,F.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||OM(i)||(0,F.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(zP({id:t,height:n}))}}},[d,f,l,i,t,r,m]),f==null||p==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=Kz(e,Rz);m.id,m.scale;var g=Kz(m,zz);return F.createElement(qI,Bz({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:Ya(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},Xz={allowDataOverflow:xT.allowDataOverflow,allowDecimals:xT.allowDecimals,allowDuplicatedCategory:xT.allowDuplicatedCategory,angle:xT.angle,axisLine:RI.axisLine,height:xT.height,hide:!1,includeHidden:xT.includeHidden,interval:xT.interval,label:!1,minTickGap:xT.minTickGap,mirror:xT.mirror,orientation:xT.orientation,padding:xT.padding,reversed:xT.reversed,scale:xT.scale,tick:xT.tick,tickCount:xT.tickCount,tickLine:RI.tickLine,tickSize:RI.tickSize,type:xT.type,niceTicks:xT.niceTicks,xAxisId:0},Zz=F.memo(e=>{var t=ac(e,Xz);return F.createElement(F.Fragment,null,F.createElement(Jz,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),F.createElement(Yz,t))},Iz);Zz.displayName=`XAxis`;var Qz=[`type`],$z=[`dangerouslySetInnerHTML`,`ticks`,`scale`],eB=[`id`,`scale`];function tB(){return tB=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},tB.apply(null,arguments)}function nB(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 rB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nB(Object(n),!0).forEach(function(t){iB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function iB(e,t,n){return(t=aB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aB(e){var t=oB(e,`string`);return typeof t==`symbol`?t:t+``}function oB(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 sB(e,t){if(e==null)return{};var n,r,i=cB(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 cB(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 lB(e){var t=Wc(),n=(0,F.useRef)(null),r=dm(),i=e.type,a=sB(e,Qz),o=Wv(r,`yAxis`,i),s=(0,F.useMemo)(()=>{if(o!=null)return rB(rB({},a),{},{type:o})},[o,a]);return(0,F.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(FP(s)):n.current!==s&&t(IP({prev:n.current,next:s})),n.current=s)},[s,t]),(0,F.useLayoutEffect)(()=>()=>{n.current&&=(t(LP(n.current)),null)},[t]),null}function uB(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,F.useRef)(null),o=(0,F.useRef)(null),s=K(vp),c=bp(),l=Wc(),u=`yAxis`,d=K(e=>vD(e,t)),f=K(e=>_D(e,t)),p=K(e=>CD(e,u,t,c)),m=K(e=>TT(e,t));if((0,F.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||OM(i)||(0,F.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(RP({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=sB(e,$z);m.id,m.scale;var g=sB(m,eB);return F.createElement(qI,tB({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:Ya(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var dB={allowDataOverflow:wT.allowDataOverflow,allowDecimals:wT.allowDecimals,allowDuplicatedCategory:wT.allowDuplicatedCategory,angle:wT.angle,axisLine:RI.axisLine,hide:!1,includeHidden:wT.includeHidden,interval:wT.interval,label:!1,minTickGap:wT.minTickGap,mirror:wT.mirror,orientation:wT.orientation,padding:wT.padding,reversed:wT.reversed,scale:wT.scale,tick:wT.tick,tickCount:wT.tickCount,tickLine:RI.tickLine,tickSize:RI.tickSize,type:wT.type,niceTicks:wT.niceTicks,width:wT.width,yAxisId:0},fB=F.memo(e=>{var t=ac(e,dB);return F.createElement(F.Fragment,null,F.createElement(lB,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),F.createElement(uB,t))},Iz);fB.displayName=`YAxis`;var pB=q([(e,t)=>t,lm,oy,hy,VO,UO,Sk,gp],Pk);function mB(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function hB(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(mB(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var gB=sd(`mouseClick`),_B=hf();_B.startListening({actionCreator:gB,effect:(e,t)=>{var n=e.payload,r=pB(t.getState(),hB(n));r?.activeIndex!=null&&t.dispatch(KD({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var vB=sd(`mouseMove`),yB=hf(),bB=null,xB=null,SB=null;yB.startListening({actionCreator:vB,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);bB!==null&&(cancelAnimationFrame(bB),bB=null),xB!==null&&(typeof i!=`number`||!o)&&(clearTimeout(xB),xB=null),SB=hB(n);var s=()=>{var e=t.getState(),n=AD(e,e.tooltip.settings.shared);if(!SB){bB=null,xB=null;return}if(n===`axis`){var r=pB(e,SB);r?.activeIndex==null?t.dispatch(UD()):t.dispatch(GD({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}bB=null,xB=null};if(!o){s();return}i===`raf`?bB=requestAnimationFrame(s):typeof i==`number`&&xB===null&&(xB=setTimeout(s,i))}});function CB(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var wB={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},TB=Od({name:`rootProps`,initialState:wB,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??wB.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),EB=TB.reducer,DB=TB.actions.updateOptions,OB=Od({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}});OB.actions.updatePolarOptions;var kB=OB.reducer,AB=sd(`keyDown`),jB=sd(`focus`),MB=sd(`blur`),NB=hf(),PB=null,FB=null,IB=null;NB.startListening({actionCreator:AB,effect:(e,t)=>{IB=e.payload,PB!==null&&(cancelAnimationFrame(PB),PB=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);FB!==null&&(typeof r!=`number`||!a)&&(clearTimeout(FB),FB=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=IB;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=sO(n,kO(e),rE(e),RO(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=UO(e),c=kO(e),l=AD(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=Dk(e,l,`hover`,String(n.index));t.dispatch(JD({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=ED(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=rE(e),h=RO(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(sO(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(sO(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=Dk(e,l,`hover`,String(p));t.dispatch(JD({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{PB=null,FB=null}};if(!a){o();return}r===`raf`?PB=requestAnimationFrame(o):typeof r==`number`&&FB===null&&(o(),IB=null,FB=setTimeout(()=>{IB?o():(FB=null,PB=null)},r))}}),NB.startListening({actionCreator:jB,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=Dk(n,AD(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(JD({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),NB.startListening({actionCreator:MB,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(JD({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function LB(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var RB=sd(`externalEvent`),zB=hf(),BB=new Map,VB=new Map,HB=new Map;zB.startListening({actionCreator:RB,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=LB(i);HB.set(a,{handler:r,reactEvent:o});var s=BB.get(a);s!==void 0&&(cancelAnimationFrame(s),BB.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=VB.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),VB.delete(a));var p=()=>{var e=HB.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:$O(i),activeDataKey:XO(i),activeIndex:JO(i),activeLabel:YO(i),activeTooltipIndex:JO(i),isTooltipActive:ek(i)};n&&n(o,r)}finally{BB.delete(a),VB.delete(a),HB.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);BB.set(a,m)}else if(typeof l==`number`){if(!VB.has(a)){p();var h=setTimeout(p,l);VB.set(a,h)}}else p()}}});var UB=q([q([dO],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),WB=sd(`touchMove`),GB=hf(),KB=null,qB=null,JB=null,YB=null;GB.startListening({actionCreator:WB,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){YB=LB(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);KB!==null&&(cancelAnimationFrame(KB),KB=null),qB!==null&&(typeof i!=`number`||!o)&&(clearTimeout(qB),qB=null),JB=Array.from(n.touches).map(e=>hB({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(YB!=null){var e=t.getState(),n=AD(e,e.tooltip.settings.shared);if(n===`axis`){var r=JB?.[0];if(r==null){KB=null,qB=null;return}var i=pB(e,r);i?.activeIndex!=null&&t.dispatch(GD({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=YB.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(ap),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=TO(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=UB(e,s,c);t.dispatch(VD({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}KB=null,qB=null}};if(!o){s();return}i===`raf`?KB=requestAnimationFrame(s):typeof i==`number`&&qB===null&&(s(),YB=null,qB=setTimeout(()=>{YB?s():(qB=null,KB=null)},i))}}});var XB={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},ZB=Od({name:`eventSettings`,initialState:XB,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=Z(t.payload.throttledEvents))}}}),QB=ZB.actions.setEventSettings,$B=ZB.reducer,eV=Pl({brush:vF,cartesianAxis:BP,chartData:CA,errorBars:bL,eventSettings:$B,graphicalItems:dP,layout:Cf,legend:bm,options:gA,polarAxis:tN,polarOptions:kB,referenceElements:EF,renderedTicks:xI,rootProps:EB,tooltip:YD,zIndex:Zk}),tV=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return yd({reducer:eV,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([_B.middleware,yB.middleware,NB.middleware,zB.middleware,GB.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(_d({type:`raf`}))},devTools:ch.devToolsEnabled&&{serialize:{replacer:CB},name:`recharts-${t}`}})};function nV(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=bp(),a=(0,F.useRef)(null);if(i)return n;a.current??=tV(t,r);var o=Vc;return F.createElement(Im,{context:o,store:a.current},n)}function rV(e){var t=e.layout,n=e.margin,r=Wc(),i=bp();return(0,F.useEffect)(()=>{i||(r(bf(t)),r(yf(n)))},[r,i,t,n]),null}var iV=(0,F.memo)(rV,zm);function aV(e){var t=Wc();return(0,F.useEffect)(()=>{t(DB(e))},[t,e]),null}var oV=(0,F.memo)(e=>{var t=Wc();return(0,F.useEffect)(()=>{t(QB(e))},[t,e]),null},zm);function sV(e){var t=e.zIndex,n=e.isPanorama,r=(0,F.useRef)(null),i=Wc();return(0,F.useLayoutEffect)(()=>(r.current&&i(Yk({zIndex:t,element:r.current,isPanorama:n})),()=>{i(Xk({zIndex:t,isPanorama:n}))}),[i,t,n]),F.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function cV(e){var t=e.children,n=e.isPanorama,r=K(Ik);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return F.createElement(F.Fragment,null,i.map(e=>F.createElement(sV,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>F.createElement(sV,{key:e,zIndex:e,isPanorama:n})))}var lV=[`children`];function uV(e,t){if(e==null)return{};var n,r,i=dV(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 dV(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 fV(){return fV=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},fV.apply(null,arguments)}var pV={width:`100%`,height:`100%`,display:`block`},mV=(0,F.forwardRef)((e,t)=>{var n=sm(),r=cm(),i=Ah();if(!Tf(n)||!Tf(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),F.createElement(W,fV({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:pV,ref:t}),a)}),hV=e=>{var t=e.children,n=K(Sp);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return F.createElement(W,{width:r,height:i,x:o,y:a},t)},gV=(0,F.forwardRef)((e,t)=>{var n=e.children,r=uV(e,lV);return bp()?F.createElement(hV,null,F.createElement(cV,{isPanorama:!0},n)):F.createElement(mV,fV({ref:t},r),F.createElement(cV,{isPanorama:!1},n))});function _V(e,t){return SV(e)||xV(e,t)||yV(e,t)||vV()}function vV(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
62
62
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yV(e,t){if(e){if(typeof e==`string`)return bV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bV(e,t):void 0}}function bV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function SV(e){if(Array.isArray(e))return e}function CV(){var e=Wc(),t=_V((0,F.useState)(null),2),n=t[0],r=t[1],i=K(tp);return(0,F.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;$(t)&&t!==i&&e(Sf(t))}},[n,e,i]),r}function wV(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 TV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wV(Object(n),!0).forEach(function(t){EV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function EV(e,t,n){return(t=DV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DV(e){var t=OV(e,`string`);return typeof t==`symbol`?t:t+``}function OV(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 kV(){return kV=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},kV.apply(null,arguments)}function AV(e,t){return FV(e)||PV(e,t)||MV(e,t)||jV()}function jV(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
63
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MV(e,t){if(e){if(typeof e==`string`)return NV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?NV(e,t):void 0}}function NV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function FV(e){if(Array.isArray(e))return e}var IV=()=>(PA(),null);function LV(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var RV=(0,F.forwardRef)((e,t)=>{var n=(0,F.useRef)(null),r=AV((0,F.useState)({containerWidth:LV(e.style?.width),containerHeight:LV(e.style?.height)}),2),i=r[0],a=r[1],o=(0,F.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,F.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,F.useEffect)(()=>()=>{n.current?.disconnect()},[o]),F.createElement(F.Fragment,null,F.createElement(mm,{width:i.containerWidth,height:i.containerHeight}),F.createElement(`div`,kV({ref:s},e)))}),zV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=AV((0,F.useState)({containerWidth:LV(n),containerHeight:LV(r)}),2),a=i[0],o=i[1],s=(0,F.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,F.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return F.createElement(F.Fragment,null,F.createElement(mm,{width:a.containerWidth,height:a.containerHeight}),F.createElement(`div`,kV({ref:c},e)))}),BV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height;return F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(`div`,kV({ref:t},e)))}),VV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?F.createElement(zV,kV({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?F.createElement(BV,kV({},e,{width:n,height:r,ref:t})):F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(`div`,kV({ref:t},e)))});function HV(e){return e?RV:VV}var UV=(0,F.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,b=y===void 0||y,x=(0,F.useRef)(null),S=Wc(),C=AV((0,F.useState)(null),2),w=C[0],T=C[1],E=AV((0,F.useState)(null),2),D=E[0],O=E[1],k=CV(),A=tm(),j=A?.width>0?A.width:_,ee=A?.height>0?A.height:i,M=(0,F.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),te=(0,F.useCallback)(e=>{S(gB(e)),S(RB({handler:a,reactEvent:e}))},[S,a]),ne=(0,F.useCallback)(e=>{S(vB(e)),S(RB({handler:l,reactEvent:e}))},[S,l]),N=(0,F.useCallback)(e=>{S(UD()),S(RB({handler:u,reactEvent:e}))},[S,u]),P=(0,F.useCallback)(e=>{S(vB(e)),S(RB({handler:d,reactEvent:e}))},[S,d]),re=(0,F.useCallback)(()=>{S(jB())},[S]),ie=(0,F.useCallback)(()=>{S(MB())},[S]),ae=(0,F.useCallback)(e=>{S(AB(e.key))},[S]),oe=(0,F.useCallback)(e=>{S(RB({handler:o,reactEvent:e}))},[S,o]),se=(0,F.useCallback)(e=>{S(RB({handler:s,reactEvent:e}))},[S,s]),ce=(0,F.useCallback)(e=>{S(RB({handler:c,reactEvent:e}))},[S,c]),le=(0,F.useCallback)(e=>{S(RB({handler:f,reactEvent:e}))},[S,f]),ue=(0,F.useCallback)(e=>{S(RB({handler:h,reactEvent:e}))},[S,h]),de=(0,F.useCallback)(e=>{b&&S(WB(e)),S(RB({handler:m,reactEvent:e}))},[S,b,m]),fe=(0,F.useCallback)(e=>{S(RB({handler:p,reactEvent:e}))},[S,p]),pe=HV(v);return F.createElement(cA.Provider,{value:w},F.createElement(Yo.Provider,{value:D},F.createElement(pe,{width:j??g?.width,height:ee??g?.height,className:Ya(`recharts-wrapper`,r),style:TV({position:`relative`,cursor:`default`,width:j,height:ee},g),onClick:te,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:ne,onMouseLeave:N,onMouseMove:P,onMouseUp:le,onTouchEnd:fe,onTouchMove:de,onTouchStart:ue,ref:M},F.createElement(IV,null),n)))}),WV=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function GV(e,t){if(e==null)return{};var n,r,i=KV(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 KV(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 qV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=to(GV(e,WV));return c?F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(gV,{otherAttributes:d,title:l,desc:u},a)):F.createElement(UV,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},F.createElement(gV,{otherAttributes:d,title:l,desc:u,ref:t},F.createElement(PF,null,a)))});function JV(){return JV=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},JV.apply(null,arguments)}function YV(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 XV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YV(Object(n),!0).forEach(function(t){ZV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZV(e,t,n){return(t=QV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QV(e){var t=$V(e,`string`);return typeof t==`symbol`?t:t+``}function $V(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 eH=XV({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},XB),tH=(0,F.forwardRef)(function(e,t){var n=ac(e.categoricalChartProps,eH),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return F.createElement(nV,{preloadedState:{options:c},reduxStoreName:s.id??r},F.createElement(hF,{chartData:s.data}),F.createElement(iV,{layout:n.layout,margin:n.margin}),F.createElement(oV,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),F.createElement(aV,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),F.createElement(qV,JV({},n,{ref:t})))}),nH=[`axis`,`item`],rH=(0,F.forwardRef)((e,t)=>F.createElement(tH,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nH,tooltipPayloadSearcher:mA,categoricalChartProps:e,ref:t})),iH=[`axis`],aH=(0,F.forwardRef)((e,t)=>F.createElement(tH,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:iH,tooltipPayloadSearcher:mA,categoricalChartProps:e,ref:t})),oH=[`system`,`tools`,`user`,`assistant`],sH={system:`bg-accent-indigo`,tools:`bg-accent-amber`,user:`bg-accent-blue`,assistant:`bg-accent-green`},cH={system:`shadow-[0_0_8px_rgba(99,102,241,0.4)]`,tools:`shadow-[0_0_8px_rgba(255,178,36,0.4)]`,user:`shadow-[0_0_8px_rgba(0,149,255,0.4)]`,assistant:`shadow-[0_0_8px_rgba(28,231,131,0.4)]`},lH={system:`bg-accent-indigo`,tools:`bg-accent-amber`,user:`bg-accent-blue`,assistant:`bg-accent-green`},uH={system:`System`,tools:`Tools`,user:`User`,assistant:`Assistant`},dH={system:`#6366f1`,tools:`#ffb224`,user:`#0095ff`,assistant:`#1ce783`},fH={fontSize:10,fill:`#6b7280`},pH=`#2a2a3a`;function mH({history:e,contextWindow:t}){let n=(0,F.useId)();return e.length<2?null:(0,I.jsx)(`div`,{className:`mt-2 pt-2 border-t border-surface-3`,children:(0,I.jsx)(rm,{width:`100%`,height:120,children:(0,I.jsxs)(aH,{data:e.map(e=>({turn:e.turnNumber,system:t>0?e.breakdown.system/t*100:0,tools:t>0?e.breakdown.tools/t*100:0,user:t>0?e.breakdown.user/t*100:0,assistant:t>0?e.breakdown.assistant/t*100:0})),margin:{top:4,right:4,bottom:0,left:-20},children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`1`,x2:`0`,y2:`0`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#f59e0b`,stopOpacity:.15}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#ef4444`,stopOpacity:.25})]})}),(0,I.jsx)(_L,{strokeDasharray:`3 3`,stroke:pH}),(0,I.jsx)(Zz,{dataKey:`turn`,tick:fH,stroke:pH}),(0,I.jsx)(fB,{domain:[0,100],unit:`%`,tick:fH,stroke:pH}),(0,I.jsx)(ZA,{contentStyle:{backgroundColor:`#1a1a2e`,border:`1px solid #2a2a3a`,fontSize:11},formatter:(e,t)=>[`${e.toFixed(1)}%`,t],labelFormatter:e=>`Turn ${e}`}),(0,I.jsx)(JF,{y1:80,y2:100,fill:`url(#${n})`,ifOverflow:`visible`}),oH.map(e=>(0,I.jsx)(xR,{type:`monotone`,dataKey:e,stackId:`context`,stroke:dH[e],fill:dH[e],fillOpacity:.4,strokeWidth:1,dot:!1},e))]})})})}function hH(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function gH(e,t=``){return{sessionId:t,turnNumber:e.turnCount,totalTokens:e.growth.currentTokens,fillPercent:e.fillPercent,contextWindow:e.contextWindow,breakdown:e.currentBreakdown,growth:{startTokens:e.growth.startTokens,currentTokens:e.growth.currentTokens,delta:e.growth.deltaTokens},topTools:e.toolContributions.map(e=>({tool:e.tool,estimatedTokens:e.estimatedTokens}))}}function _H({data:e,sessionId:t,expandable:n=!0}){let r=Yn(e=>e.contextBySession),i=t?r.get(t)??null:null,[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=(0,F.useRef)(0),f=(0,F.useRef)(0);(0,F.useEffect)(()=>{u(!1)},[t]);let{data:p}=L({queryKey:t?[`context`,t]:z.context,queryFn:()=>Ar(t??void 0),refetchInterval:1e4,enabled:!e}),{data:m}=L({queryKey:[`context-composition`,t],queryFn:jr,enabled:l}),{data:h}=L({queryKey:[`context-efficiency`,t],queryFn:Mr,enabled:l}),g=e??p,_=t??``,v=e?gH(e,_):i??(g?gH(g,_):null),y=v?.growth.currentTokens??0,b=Math.min(v?.fillPercent??0,100),x=f.current>0&&b>d.current;if((0,F.useEffect)(()=>{if(f.current>0&&y<f.current*.7){c(!0);let e=setTimeout(()=>c(!1),1e3);return f.current=y,d.current=b,()=>clearTimeout(e)}f.current=y,d.current=b},[b,y]),!v||v.totalTokens===0)return null;let{breakdown:S,growth:C,fillPercent:w,totalTokens:T}=v,E=w>=100,D=v.contextWindow,O=l&&g?.history&&g.history.length>=2?g.history:null;return(0,I.jsxs)(`div`,{className:`group`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(V,{children:`Context`}),E&&(0,I.jsx)(ei,{tone:`danger`,size:`sm`,uppercase:!0,className:`animate-pulse motion-reduce:animate-none`,children:`at capacity`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-ink-subtle tabular-nums`,children:[hH(C.currentTokens),D&&D>0&&(0,I.jsx)(`span`,{className:`text-ink-muted`,children:` / ${hH(D)}`}),C.delta>0&&(0,I.jsxs)(`span`,{className:`text-accent-amber ml-1`,children:[`+`,hH(C.delta)]}),C.delta<0&&(0,I.jsx)(`span`,{className:`text-accent-cyan ml-1`,children:`compacted`}),n&&(g?.history?.length??0)>=2&&(0,I.jsx)(`button`,{onClick:()=>u(e=>!e),className:`ml-1 text-ink-muted hover:text-ink-base transition-colors`,"aria-label":`Toggle context timeline`,"aria-expanded":l,children:l?`▾`:`▸`})]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[s&&(0,I.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-accent-cyan/20 animate-compact-flash pointer-events-none`}),(0,I.jsx)(`div`,{className:`w-full h-3 bg-surface-3 rounded-full overflow-hidden flex transition-colors duration-150 ${x?`shadow-[0_0_12px_rgba(255,178,36,0.3)]`:``} ${s?`animate-compact`:``}`,children:oH.map(e=>{let t=S[e];if(t<=0)return null;let n=Math.round(t/T*100),r=a===e;return(0,I.jsx)(`div`,{className:`${sH[e]} transition-all duration-500 ease-out cursor-default relative ${r?`brightness-125 ${cH[e]}`:``}`,style:{width:`${t/T*b}%`},title:`${uH[e]}: ${hH(t)} (${n}%)`,onMouseEnter:()=>o(e),onMouseLeave:()=>o(null)},e)})})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-[10px] text-ink-muted`,children:[oH.map(e=>{let t=S[e],n=a===e;return(0,I.jsxs)(`span`,{className:`flex items-center gap-1 transition-colors duration-200 cursor-default ${n?`text-ink-base`:``}`,onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${lH[e]} ${n?`scale-150`:``} transition-transform duration-200`}),uH[e],n&&t>0&&(0,I.jsx)(`span`,{className:`text-ink-subtle ml-0.5`,children:hH(t)})]},e)}),(0,I.jsxs)(`span`,{className:`ml-auto tabular-nums ${E?`text-accent-red`:b>=75?`text-accent-amber`:``}`,children:[b.toFixed(0),`%`]})]}),n&&(0,I.jsxs)(`div`,{className:`overflow-hidden transition-all duration-300 ${l?`max-h-56`:`max-h-0`}`,children:[O&&(0,I.jsx)(mH,{history:O,contextWindow:D}),l&&h&&h.repeatedReadRatio!==null&&(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-ink-muted`,children:[(0,I.jsxs)(`span`,{children:[`Repeated reads: `,Math.round(h.repeatedReadRatio*100),`%`]}),h.topRepeatedFiles[0]&&(0,I.jsxs)(`span`,{className:`ml-2`,children:[`top:`,` `,(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:h.topRepeatedFiles[0].file}),` `,`(`,h.topRepeatedFiles[0].readCount,`x)`]})]}),l&&m&&(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-ink-muted`,children:[`Dominant this turn:`,` `,Object.entries(m.currentBreakdown).sort((e,t)=>t[1]-e[1])[0]?.[0]]})]})]})}var vH={success:`success`,failure:`danger`,unknown:`neutral`};function yH({decisionTree:e,turnCosts:t,contextHistory:n,contextWindow:r,contextComposition:i,contextEfficiency:a,onClose:o}){let s=(0,F.useRef)(null),c=(0,F.useRef)(null);(0,F.useEffect)(()=>{function e(e){if(e.key===`Escape`){o();return}if(e.key===`Tab`&&s.current){let t=s.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`),n=t[0],r=t[t.length-1];!e.shiftKey&&document.activeElement===r?(e.preventDefault(),n?.focus()):e.shiftKey&&document.activeElement===n&&(e.preventDefault(),r?.focus())}}return document.addEventListener(`keydown`,e),c.current?.focus(),()=>document.removeEventListener(`keydown`,e)},[o]);let l=e!=null&&e.totalBranches>0,u=t?.turns!=null&&t.turns.length>0,d=(n?.length??0)>=2;return(0,si.createPortal)((0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 backdrop-blur-sm`,"aria-hidden":`true`,onClick:o}),(0,I.jsxs)(`div`,{ref:s,role:`dialog`,"aria-modal":`true`,"aria-label":`Session decision-tree and turn-cost detail`,className:`fixed right-0 top-0 bottom-0 z-50 w-[640px] max-w-full flex flex-col bg-bg-panel border-l border-border-medium shadow-2xl overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border-subtle shrink-0`,children:[(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold text-ink-base`,children:`Session Detail`}),(0,I.jsx)(`p`,{className:`mt-1 text-[10px] text-ink-muted`,children:`Live, current-process-only — reflects this dashboard process’s own current session.`})]}),(0,I.jsx)(`button`,{ref:c,type:`button`,"aria-label":`Close session detail`,onClick:o,className:`shrink-0 p-1.5 rounded-md text-ink-muted hover:text-ink-base hover:bg-surface-5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:(0,I.jsx)(Nn,{className:`w-4 h-4`,"aria-hidden":`true`})})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-5`,children:[(0,I.jsxs)(`section`,{"aria-label":`Decision tree`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Decision Tree`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,I.jsx)(bH,{label:`Longest failure streak`,value:String(e.longestFailureStreak)}),(0,I.jsx)(bH,{label:`Success rate`,value:e.successRate===null?`—`:`${Math.round(e.successRate*100)}%`}),(0,I.jsx)(bH,{label:`Total branches`,value:String(e.totalBranches)})]}),e.failurePoints.length>0&&(0,I.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border-subtle space-y-2`,children:e.failurePoints.map((e,t)=>(0,I.jsx)(`div`,{className:`flex items-start justify-between gap-2 text-xs`,children:(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,I.jsxs)(`span`,{className:`text-ink-muted`,children:[`Turn `,e.turnNumber]}),e.toolName&&(0,I.jsx)(`code`,{className:`text-[10px] bg-surface-5 px-1 rounded`,children:e.toolName}),(0,I.jsx)(ei,{tone:vH[e.outcome],size:`sm`,children:e.outcome})]}),(0,I.jsx)(`p`,{className:`mt-0.5 text-ink-subtle break-words`,children:e.reasoning})]})},`${e.turnNumber}-${t}`))}),e.note&&(0,I.jsx)(`p`,{className:`mt-3 pt-3 border-t border-border-subtle text-[10px] text-ink-muted`,children:e.note})]}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No decision-tree data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Turn costs`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Turn Costs`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-3 pb-3 border-b border-border-subtle`,children:[(0,I.jsx)(bH,{label:`Total attributed cost`,value:`$${t.totalAttributedCost.toFixed(2)}`}),(0,I.jsx)(bH,{label:`Attribution rate`,value:`${Math.round(t.attributionRate*100)}%`})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:t.turns.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-ink-base`,children:e.toolNames.join(`, `)}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted font-mono`,children:[e.model,` · `,Ci(e.inputTokens),` in /`,` `,Ci(e.outputTokens),` out /`,` `,Ci(e.cacheReadTokens),` cache`]})]}),(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums text-ink-base`,children:[`$`,e.estimatedCostUsd.toFixed(2)]})]},e.turnId))})]}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No turn-cost data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Context timeline`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Context Timeline`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:d?(0,I.jsx)(mH,{history:n??[],contextWindow:r??0}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No context timeline data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Context composition and efficiency`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Context Composition & Efficiency`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:!i&&!a?(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No composition/efficiency data yet.`}):(0,I.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[i&&(0,I.jsxs)(`div`,{className:`text-ink-muted`,children:[`Dominant this turn:`,` `,(0,I.jsx)(`span`,{className:`text-ink-base`,children:Object.entries(i.currentBreakdown).sort((e,t)=>t[1]-e[1])[0]?.[0]})]}),a&&a.repeatedReadRatio!==null&&(0,I.jsxs)(`div`,{className:`text-ink-muted`,children:[`Repeated reads:`,` `,(0,I.jsxs)(`span`,{className:`text-ink-base`,children:[Math.round(a.repeatedReadRatio*100),`%`]}),a.topRepeatedFiles[0]&&(0,I.jsxs)(I.Fragment,{children:[` `,`— top:`,` `,(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:a.topRepeatedFiles[0].file}),` `,`(`,a.topRepeatedFiles[0].readCount,`x)`]})]})]})})]})]})]})]}),document.body)}function bH({label:e,value:t}){return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-[10px] text-ink-muted uppercase tracking-wider`,children:e}),(0,I.jsx)(`div`,{className:`text-sm font-bold tabular-nums text-ink-base mt-0.5`,children:t})]})}var xH=`var(--color-chart-block)`,SH=`var(--color-chart-block-peak)`,CH=10,wH=13;function TH({data:e,maxCount:t,ariaLabel:n}){let r=(0,F.useRef)(null),[i,a]=(0,F.useState)(null);if(e.length===0||e.every(e=>e.count===0))return null;let o=Math.max(t??0,...e.map(e=>e.count),1),s=o*12;return(0,I.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,I.jsx)(`svg`,{width:`100%`,height:s,role:`img`,"aria-label":n,viewBox:`0 0 ${e.length*wH} ${s}`,preserveAspectRatio:`xMidYMax meet`,onMouseLeave:()=>a(null),children:e.map((e,t)=>{let n=[];for(let r=0;r<e.count;r++){let i=e.count===o;n.push((0,I.jsx)(`rect`,{x:t*wH,y:s-(r+1)*12,width:CH,height:CH,rx:1,fill:i?SH:xH,className:`heatmap-cell`,style:{animationDelay:`${t*20+r*10}ms`}},`${t}-${r}`))}return(0,I.jsxs)(`g`,{onMouseEnter:t=>{let n=r.current;if(!n)return;let i=n.getBoundingClientRect(),o=t.currentTarget,s=o.querySelectorAll(`rect.heatmap-cell`),c=(s[s.length-1]??o).getBoundingClientRect();a({x:c.left-i.left+c.width/2,y:c.top-i.top,text:e.tooltip})},children:[(0,I.jsx)(`rect`,{x:t*wH,y:0,width:wH,height:s,fill:`transparent`}),n]},t)})}),i&&(0,I.jsx)(`div`,{className:`absolute px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:i.x,top:i.y,transform:`translate(-50%, calc(-100% - 4px))`},children:i.text})]})}var EH=`nr-observe-peak-concurrent`;function DH({current:e,peak:t,allTimePeak:n,buckets:r}){let[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(null),s=r.some(e=>e.count>0);(0,F.useEffect)(()=>{let e=n??t;if(e<=0)return;let r=parseInt(localStorage.getItem(EH)??`0`,10);if(o.current===null&&(o.current=r),e>o.current){localStorage.setItem(EH,String(e)),o.current=e,a(!0);let t=setTimeout(()=>a(!1),3e3);return()=>clearTimeout(t)}},[t,n]);let c=r.map(e=>{let t=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`});return{count:e.count,tooltip:`${t} — ${e.count} concurrent`}});return(0,I.jsxs)(B,{padding:`sm`,className:`relative overflow-hidden${i?` new-peak-glow`:``}`,children:[i&&(0,I.jsx)(OH,{}),(0,I.jsx)(V,{className:`mb-1.5`,children:`Concurrent Sessions`}),(0,I.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold text-accent-teal tabular-nums`,children:e}),(0,I.jsxs)(`span`,{className:`text-xs text-ink-muted tabular-nums`,children:[`today peak `,t,n&&n>t?` · all-time ${n}`:``]}),i&&(0,I.jsx)(`span`,{className:`text-[10px] text-accent-green font-semibold animate-bounce`,children:`NEW RECORD!`})]}),s&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(TH,{data:c,ariaLabel:`Concurrency over time, peak ${t}`})})]})}function OH(){return(0,I.jsx)(I.Fragment,{children:Array.from({length:12},(e,t)=>{let n=t/12*360,r=40+Math.random()*30;return(0,I.jsx)(`span`,{className:`absolute w-1.5 h-1.5 rounded-full`,style:{left:`50%`,top:`50%`,backgroundColor:t%3==0?`#1CE783`:t%3==1?`#00D4AA`:`#9945FF`,animation:`particle-burst 1s ease-out forwards`,animationDelay:`${t*40}ms`,transform:`translate(-50%, -50%) rotate(${n}deg) translateY(-${r}px)`,opacity:0}},t)})})}var kH=5,AH=[`var(--color-heatmap-0)`,`var(--color-heatmap-1)`,`var(--color-heatmap-2)`,`var(--color-heatmap-3)`,`var(--color-heatmap-4)`];function jH(e,t){if(e===0)return AH[0];let n=e/t;return AH[Math.min(Math.ceil(n*(kH-1)),kH-1)]}function MH(e,t,n){let r=e+n*t;return new Date(r).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function NH({variant:e,buckets:t,maxCount:n,bucketSizeMs:r,startTimestamp:i,width:a,height:o,ariaLabel:s,days:c}){return e===`grid`&&c?(0,I.jsx)(IH,{days:c,maxCount:n,width:a,height:o,ariaLabel:s}):(0,I.jsx)(PH,{buckets:t,maxCount:n,bucketSizeMs:r,startTimestamp:i,width:a,height:o,ariaLabel:s})}function PH({buckets:e,maxCount:t,bucketSizeMs:n=9e5,startTimestamp:r=0,width:i,height:a=24,ariaLabel:o}){let[s,c]=(0,F.useState)(null),l=Math.max(4,Math.min(12,i?(i-e.length*1)/e.length:8)),u=i??e.length*(l+1);return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`svg`,{width:u,height:a,role:`img`,"aria-label":o??`Activity heatmap: ${e.length} time buckets`,className:`w-full`,style:{maxWidth:u},viewBox:`0 0 ${u} ${a}`,preserveAspectRatio:`none`,onMouseLeave:()=>c(null),children:e.map((e,i)=>(0,I.jsx)(`rect`,{x:i*(l+1),y:0,width:l,height:a,rx:2,fill:jH(e,t),className:`heatmap-cell`,style:{animationDelay:`${Math.min(i*8,400)}ms`},onMouseEnter:t=>{let a=MH(r,n,i);c({x:t.currentTarget.x.baseVal.value,text:`${a}: ${e} calls`})}},i))}),s&&(0,I.jsx)(`div`,{className:`absolute -top-7 px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:s.x},children:s.text})]})}var FH=[`Mon`,``,`Wed`,``,`Fri`,``,`Sun`];function IH({days:e,maxCount:t,ariaLabel:n}){let[r,i]=(0,F.useState)(null),a=(0,F.useMemo)(()=>{if(e.length===0)return{weeks:0,cells:[]};let t=(new Date(e[0].date).getUTCDay()+6)%7,n=[];for(let r=0;r<e.length;r++){let i=r+t,a=i%7,o=Math.floor(i/7);n.push({...e[r],row:a,col:o})}return{weeks:n.length>0?n[n.length-1].col+1:0,cells:n}},[e]),o=28+a.weeks*12,s=(0,F.useMemo)(()=>{let e=[],t=``;for(let n of a.cells){if(n.row!==0)continue;let r=new Date(n.date).toLocaleString(void 0,{month:`short`,timeZone:`UTC`});r!==t&&(e.push({text:r,col:n.col}),t=r)}return e},[a.cells]);return(0,I.jsxs)(`div`,{className:`relative flex justify-center`,children:[(0,I.jsxs)(`svg`,{width:`100%`,height:98,role:`img`,"aria-label":n??`Activity grid: ${e.length} days`,viewBox:`0 0 ${o} 98`,preserveAspectRatio:`xMidYMid meet`,onMouseLeave:()=>i(null),children:[FH.map((e,t)=>e?(0,I.jsx)(`text`,{x:0,y:14+t*12+10-2,className:`fill-ink-muted`,fontSize:10,children:e},t):null),s.map(({text:e,col:t})=>(0,I.jsx)(`text`,{x:28+t*12,y:10,className:`fill-ink-muted`,fontSize:10,children:e},`${e}-${t}`)),a.cells.map((e,n)=>(0,I.jsx)(`rect`,{x:28+e.col*12,y:14+e.row*12,width:10,height:10,rx:2,fill:jH(e.count,t),className:`heatmap-cell`,style:{animationDelay:`${Math.min(n*3,300)}ms`},onMouseEnter:t=>{let n=t.currentTarget;i({x:n.x.baseVal.value,y:n.y.baseVal.value-16,text:`${e.date}: ${e.count} calls`})}},n))]}),r&&(0,I.jsx)(`div`,{className:`absolute px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:r.x,top:r.y},children:r.text}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5 text-[10px] text-ink-muted`,children:[(0,I.jsx)(`span`,{children:`Less`}),AH.map((e,t)=>(0,I.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm`,style:{backgroundColor:e}},t)),(0,I.jsx)(`span`,{children:`More`})]})]})}function LH({theme:e=`observatory`}){return(0,I.jsxs)(`div`,{className:`geo-banner`,"aria-hidden":`true`,children:[e===`observatory`&&(0,I.jsx)(RH,{}),e===`sessions`&&(0,I.jsx)(zH,{}),e===`history`&&(0,I.jsx)(BH,{}),e===`audit`&&(0,I.jsx)(VH,{}),e===`git`&&(0,I.jsx)(HH,{})]})}function RH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`obsSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#1a3a5c`}),(0,I.jsx)(`stop`,{offset:`40%`,stopColor:`#2d5a7b`}),(0,I.jsx)(`stop`,{offset:`70%`,stopColor:`#e8834a`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#f4a261`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#obsSky)`}),(0,I.jsx)(`polygon`,{points:`0,80 0,45 80,38 160,48 240,30 340,42 420,25 500,38 580,32 660,40 740,28 800,35 800,80`,fill:`#1a3a5c`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`0,80 0,55 60,48 140,58 220,42 300,52 380,40 460,50 520,38 600,48 680,42 760,52 800,48 800,80`,fill:`#234e6f`}),(0,I.jsx)(`polygon`,{points:`0,80 0,62 100,58 200,65 300,55 400,60 500,54 600,62 700,56 800,60 800,80`,fill:`#2a6b4a`,opacity:`0.8`}),(0,I.jsx)(`circle`,{cx:`680`,cy:`28`,r:`14`,fill:`#f4a261`,opacity:`0.6`}),(0,I.jsx)(`circle`,{cx:`680`,cy:`28`,r:`8`,fill:`#ffd166`,opacity:`0.5`}),(0,I.jsx)(`ellipse`,{cx:`150`,cy:`56`,rx:`18`,ry:`10`,fill:`#1a3a5c`}),(0,I.jsx)(`line`,{x1:`150`,y1:`46`,x2:`172`,y2:`34`,stroke:`#5ce0d8`,strokeWidth:`1.5`,opacity:`0.8`})]})}function zH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`seaSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#4aa8c7`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#3a8fb7`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#2d7a9e`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#seaSky)`}),(0,I.jsx)(`polygon`,{points:`600,48 640,35 680,48`,fill:`#2d7a4a`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`700,50 730,40 760,50`,fill:`#3d9b5b`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`0,80 0,15 40,12 80,20 120,18 160,25 180,30 180,80`,fill:`#c05a3c`}),(0,I.jsx)(`polygon`,{points:`0,80 0,25 30,22 60,28 100,25 140,30 160,35 160,80`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`20,20 35,8 50,20`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`60,22 72,12 84,24`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`100,20 115,10 130,22`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`140,28 150,18 160,28`,fill:`#4aad6b`,opacity:`0.8`}),(0,I.jsx)(`rect`,{x:`120`,y:`30`,width:`8`,height:`50`,fill:`#87ceeb`,opacity:`0.5`}),(0,I.jsx)(`rect`,{x:`122`,y:`30`,width:`4`,height:`50`,fill:`#fff`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`620,80 620,30 660,25 700,32 740,28 780,35 800,30 800,80`,fill:`#c05a3c`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`650,30 665,18 680,30`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`720,32 732,22 744,32`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`180,80 180,55 250,52 350,56 450,52 550,55 620,52 620,80`,fill:`#2d7a9e`,opacity:`0.6`}),(0,I.jsx)(`line`,{x1:`200`,y1:`60`,x2:`280`,y2:`58`,stroke:`#5ce0d8`,strokeWidth:`0.8`,opacity:`0.3`}),(0,I.jsx)(`line`,{x1:`350`,y1:`56`,x2:`450`,y2:`55`,stroke:`#5ce0d8`,strokeWidth:`0.8`,opacity:`0.25`}),(0,I.jsx)(`line`,{x1:`480`,y1:`58`,x2:`580`,y2:`56`,stroke:`#87ceeb`,strokeWidth:`0.8`,opacity:`0.3`})]})}function BH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`histSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#3a7ca5`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#5bb8d4`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#8ed4c0`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#histSky)`}),(0,I.jsx)(`polygon`,{points:`100,50 140,20 180,50`,fill:`#e8834a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`160,50 210,15 260,50`,fill:`#d4694a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`550,50 600,18 650,50`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`620,50 660,22 700,50`,fill:`#c05a3c`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`350,50 370,12 390,50`,fill:`#5ce0d8`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`380,50 395,20 410,50`,fill:`#87ceeb`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`700,50 715,25 730,50`,fill:`#5ce0d8`,opacity:`0.35`}),(0,I.jsx)(`polygon`,{points:`300,80 380,50 420,50 500,80`,fill:`#2a5a6b`,opacity:`0.6`}),(0,I.jsx)(`line`,{x1:`390`,y1:`52`,x2:`350`,y2:`78`,stroke:`#f4a261`,strokeWidth:`1`,opacity:`0.4`}),(0,I.jsx)(`line`,{x1:`410`,y1:`52`,x2:`450`,y2:`78`,stroke:`#f4a261`,strokeWidth:`1`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`0,80 0,55 80,52 160,58 240,50 320,55 500,52 580,56 660,50 740,55 800,52 800,80`,fill:`#2d8a4a`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`0,80 0,65 60,62 140,68 220,60 400,65 500,62 600,66 700,60 800,65 800,80`,fill:`#1e6b3a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`30,65 42,42 54,65`,fill:`#3d9b5b`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`50,65 60,48 70,65`,fill:`#2d8a4a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`720,65 732,45 744,65`,fill:`#3d9b5b`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`760,65 770,50 780,65`,fill:`#2d8a4a`,opacity:`0.8`})]})}function VH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`auditSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#1a5c3a`}),(0,I.jsx)(`stop`,{offset:`50%`,stopColor:`#2d7a4a`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#3d9b5b`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#auditSky)`}),(0,I.jsx)(`polygon`,{points:`200,0 210,80 220,0`,fill:`#ffd166`,opacity:`0.08`}),(0,I.jsx)(`polygon`,{points:`500,0 510,80 520,0`,fill:`#ffd166`,opacity:`0.06`}),(0,I.jsx)(`polygon`,{points:`650,0 660,80 670,0`,fill:`#fff`,opacity:`0.05`}),(0,I.jsx)(`rect`,{x:`80`,y:`20`,width:`6`,height:`60`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`180`,y:`10`,width:`7`,height:`70`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`320`,y:`15`,width:`6`,height:`65`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`500`,y:`8`,width:`7`,height:`72`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`620`,y:`18`,width:`6`,height:`62`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`740`,y:`12`,width:`7`,height:`68`,fill:`#1a4a2e`}),(0,I.jsx)(`polygon`,{points:`55,25 83,5 111,25`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`60,35 83,15 106,35`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`155,15 183,0 211,18`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`160,28 183,8 206,28`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`295,20 323,2 351,22`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`300,32 323,12 346,32`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`475,12 503,0 531,15`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`480,25 503,5 526,25`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`595,22 623,5 651,22`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`600,34 623,14 646,34`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`715,16 743,0 771,18`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`720,30 743,10 766,30`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`0,80 0,68 100,65 200,70 300,64 400,68 500,63 600,67 700,64 800,68 800,80`,fill:`#1e6b3a`}),(0,I.jsx)(`polygon`,{points:`250,80 258,65 266,80`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`450,80 456,68 462,80`,fill:`#f4a261`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`650,80 656,66 662,80`,fill:`#e8834a`,opacity:`0.55`})]})}function HH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`gitSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#2d5a7b`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#3a8fb7`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#5bb8d4`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#gitSky)`}),(0,I.jsx)(`polygon`,{points:`0,80 0,20 60,25 120,18 180,28 220,22 260,30 260,80`,fill:`#2d7a4a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`540,80 540,22 600,28 660,20 720,25 780,18 800,22 800,80`,fill:`#2d7a4a`,opacity:`0.7`}),(0,I.jsx)(`path`,{d:`M 260,50 Q 320,48 400,45 Q 480,42 540,50`,fill:`none`,stroke:`#5ce0d8`,strokeWidth:`4`,opacity:`0.5`}),(0,I.jsx)(`path`,{d:`M 350,45 Q 370,35 400,28`,fill:`none`,stroke:`#87ceeb`,strokeWidth:`2`,opacity:`0.4`}),(0,I.jsx)(`path`,{d:`M 420,44 Q 440,52 470,60`,fill:`none`,stroke:`#87ceeb`,strokeWidth:`2`,opacity:`0.4`}),(0,I.jsx)(`path`,{d:`M 400,28 Q 430,25 460,30`,fill:`none`,stroke:`#5ce0d8`,strokeWidth:`1.5`,opacity:`0.35`}),(0,I.jsx)(`circle`,{cx:`400`,cy:`45`,r:`3`,fill:`#5ce0d8`,opacity:`0.6`}),(0,I.jsx)(`circle`,{cx:`350`,cy:`45`,r:`2`,fill:`#1ce783`,opacity:`0.5`}),(0,I.jsx)(`circle`,{cx:`460`,cy:`44`,r:`2`,fill:`#1ce783`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`300,65 310,55 320,65`,fill:`#3a6b4a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`480,62 492,52 504,62`,fill:`#3a6b4a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`240,35 250,18 260,35`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`540,35 550,20 560,35`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`270,50 278,38 286,50`,fill:`#3d9b5b`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`520,48 528,36 536,48`,fill:`#3d9b5b`,opacity:`0.8`})]})}function UH(e){let t=e==null?new Date:new Date(e);return t.setHours(0,0,0,0),t.getTime()}function WH(e,t){let n=new Date(e),r=t==null?new Date:new Date(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}var GH={weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`},KH=3e4,qH={info:`text-ink-muted`,warning:`text-accent-amber`,critical:`text-accent-red`},JH=1e4;function YH(){let e=Yn(e=>e.cost),t=Yn(e=>e.antiPatterns),n=$n(),r=er(),{data:i}=L({queryKey:[`observability-health`],queryFn:zr,refetchInterval:3e4}),{isPending:a}=L({queryKey:z.cost,queryFn:lr}),{data:o,isPending:s}=L({queryKey:z.sessionsTodayAggregate,queryFn:or,refetchInterval:1e4}),{data:c,isPending:l}=L({queryKey:z.sessionsList(200),queryFn:()=>ar(200),refetchInterval:1e4}),{data:u,isPending:d}=L({queryKey:z.antiPatterns,queryFn:ur}),{data:f}=L({queryKey:[`retry-alerts`],queryFn:dr,refetchInterval:1e4}),{data:p,isPending:m}=L({queryKey:z.concurrency,queryFn:Dr,refetchInterval:1e4}),{data:h,isPending:g}=L({queryKey:z.activityHeatmap(`today`),queryFn:()=>kr(`today`),refetchInterval:3e4}),{data:_,isPending:v}=L({queryKey:z.sessionsLive,queryFn:sr,refetchInterval:1e4}),y=(0,F.useMemo)(()=>lU(c??[]),[c]),b=(0,F.useMemo)(()=>uU(c??[]),[c]),x=(0,F.useMemo)(()=>dU(c??[]),[c]),S=(0,F.useMemo)(()=>fU(c??[]),[c]),C=(0,F.useMemo)(()=>(c??[]).flatMap(e=>e.antiPatterns??[]),[c]),w=Math.max(o?.toolCallCount??0,b),T=(a||l||s)&&!e&&y===0&&o===void 0,E=Math.max(e?.todayTotalUsd??0,o?.totalCostUsd??0,y),D=Math.max(u?.length??0,t.length),O=Math.max(o?.antiPatternCount??0,x+D),k=Math.max(o?.subagentUsd??0,n.usd),A=Math.max(o?.subagentTurnCount??0,n.turns),j=o!==void 0||n.turns>0,[ee,M]=(0,F.useState)(()=>new Date().toLocaleString(void 0,GH));(0,F.useEffect)(()=>{let e=setInterval(()=>M(new Date().toLocaleString(void 0,GH)),6e4);return()=>clearInterval(e)},[]);let te=o?.avgEfficiencyScore??null,ne=te!==null&&Number.isFinite(te)?`${Math.round(te*100)}%`:`—`,N=te===null?`needs more data`:Math.round(te*100)>=80?`strong session`:Math.round(te*100)>=50?`mixed signals`:`needs attention`;return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Today`}),(0,I.jsx)(`span`,{className:`text-xs text-ink-muted`,children:ee})]}),!T&&!s&&!l&&!d&&!m&&!g&&!v&&w===0&&E===0&&O===0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yi,{index:0,className:`glass-card p-8 mb-4`,children:(0,I.jsx)(U,{icon:`code`,title:`No activity yet today`,subtitle:`Metrics will appear here once you start a coding session with Claude.`})}),(0,I.jsx)(Yi,{index:1,children:(0,I.jsx)(aU,{})})]}):(0,I.jsxs)(I.Fragment,{children:[(r?.watcherDisabledByLock===!0||i?.watcherDisabledByLock===!0)&&(0,I.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-300 mb-4`,children:`Subagent watcher is disabled (lock conflict). Subagent costs may be undercounted. Check Settings → Observability health.`}),i?.watcherActive===!1&&n.turns===0&&i?.watcherDisabledReason!==`mode_mismatch`&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border-subtle bg-surface-5 px-4 py-3 text-sm text-ink-muted mb-4`,children:[`Subagent cost tracking is disabled (`,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=0`}),`), so spend shown here excludes subagents. Unset that variable (it is on by default) and restart to see full spend.`]}),i?.watcherActive===!1&&n.turns===0&&i?.watcherDisabledReason===`mode_mismatch`&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border-subtle bg-surface-5 px-4 py-3 text-sm text-ink-muted mb-4`,children:[`This dashboard process isn’t running its own subagent watcher — expected for a background `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`--local`}),` dashboard (the watcher only auto-starts in `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`--stdio`}),` mode). Spend shown here still includes subagent activity from other sessions, read from their persisted totals. To track subagents live from this process too, set`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`NR_AI_WATCHER_MODE=local`}),` and restart.`]}),(0,I.jsx)(Yi,{index:0,className:`mb-4`,children:(0,I.jsx)(B,{padding:`lg`,tone:`elevated`,glow:`green`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-5 gap-4`,children:[(0,I.jsx)(Ji,{label:`efficiency`,hero:!0,value:ne,sub:N,...te===null?{}:{animate:!0,numericValue:Math.round(te*100),suffix:`%`}}),(0,I.jsx)(Ji,{label:`spend today`,tone:`good`,value:T?`…`:xi(E),...T?{}:{animate:!0,numericValue:E,format:xi}}),(0,I.jsx)(Ji,{label:`subagent spend`,value:j?xi(k):`—`,sub:`${A} turns`,...j?{animate:!0,numericValue:k,format:xi}:{}}),(0,I.jsx)(Ji,{label:`tool calls`,value:String(w),animate:!0,numericValue:w}),(0,I.jsx)(Ji,{label:`flags`,tone:O>0?`warn`:`neutral`,value:String(O),animate:!0,numericValue:O})]})})}),(0,I.jsxs)(Yi,{index:1,className:`grid grid-cols-2 gap-3 mb-3`,children:[(0,I.jsx)(pU,{todayTotal:E,forecastEod:T?null:e?.forecastEodUsd??o?.forecastEndOfDayUsd??null,hourlySpend:S,subagentUsd:k}),p&&p.buckets&&(0,I.jsx)(DH,{current:p.current,peak:p.peak,allTimePeak:p.allTimePeak,bucketSizeMs:p.bucketSizeMs,startTimestamp:p.startTimestamp,buckets:p.buckets})]}),O>0&&(t.length>0||u&&u.length>0||C.length>0)&&(0,I.jsx)(Yi,{index:2,className:`mb-3`,children:(0,I.jsx)(B,{padding:`sm`,tone:`warning`,className:`text-xs`,children:t.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:t[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[t[0].count,`× on `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:t[0].target}),t[0].sessionId&&(0,I.jsxs)(ei,{tone:`neutral`,size:`sm`,className:`ml-2`,children:[`Session: `,iU(t[0].sessionId,_??[])]}),t[0].type===`thrashing`&&f?.alerts?.find(e=>e.toolName===t[0].target)?.tokensWastedEstimate!==void 0&&(0,I.jsxs)(`span`,{className:`text-ink-muted ml-2`,children:[`~`,f.alerts.find(e=>e.toolName===t[0].target).tokensWastedEstimate,` `,`tokens wasted`]})]}):u&&u.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:u[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[u[0].count??u[0].iterations??u[0].readCount??u[0].repeatCount??u[0].editCount??u[0].agentCount??`?`,`× on`,` `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:u[0].file??u[0].command??`unknown`})]}):C.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:C[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[C[0].count??C[0].iterations??C[0].readCount??C[0].repeatCount??C[0].editCount??C[0].agentCount??`?`,`× on`,` `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:C[0].file??C[0].command??`unknown`})]}):null})}),(0,I.jsxs)(Yi,{index:3,className:`grid grid-cols-3 gap-3 mb-3`,children:[(0,I.jsx)(XH,{}),(0,I.jsx)(ZH,{}),(0,I.jsx)(QH,{aggregate:o}),(0,I.jsx)($H,{}),(0,I.jsx)(tU,{aggregate:o})]}),(0,I.jsx)(Yi,{index:4,children:(0,I.jsx)(rU,{sessions:c??[],liveSessions:_??[]})}),h&&h.buckets?.length>0&&(0,I.jsx)(Yi,{index:5,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`sm`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Activity Today`}),(0,I.jsx)(ci,{text:`Tool-call activity in 15-minute blocks across today. Darker blocks mean more calls in that window.`})]}),(0,I.jsx)(NH,{variant:`strip`,buckets:h.buckets,maxCount:h.maxCount,bucketSizeMs:h.bucketSizeMs,startTimestamp:h.startTimestamp,ariaLabel:`Today's activity density in 15-minute blocks`})]})}),(0,I.jsx)(Yi,{index:6,children:(0,I.jsx)(aU,{})})]})]})}function XH(){let{data:e}=L({queryKey:z.qualityProxy,queryFn:Cr,refetchInterval:JH});return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Quality`}),(0,I.jsx)(ci,{text:`Diff apply rate and test pass rate across today's sessions, plus how often you backtracked or self-corrected. Watch for the degrading flag if quality drops mid-session.`})]}),!e||e.totalSignals===0?(0,I.jsx)(U,{icon:`checkmark`,title:`Waiting for edits and test runs`,subtitle:`Quality metrics appear after editing files and running tests.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Diff Apply `}),(0,I.jsx)(`span`,{className:mi(e.diffApplyRate),children:e.diffApplyRate===null?`—`:`${(e.diffApplyRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Test Pass `}),(0,I.jsx)(`span`,{className:mi(e.testPassRate),children:e.testPassRate===null?`—`:`${(e.testPassRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Backtracks `}),(0,I.jsx)(`span`,{className:e.backtrackCount>0?`text-accent-amber`:``,children:e.backtrackCount})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Self-corrections `}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.selfCorrectionCount})]})]}),e.degradationDetected&&(0,I.jsx)(`div`,{className:`text-accent-amber text-xs mt-2`,children:`⚠ Quality degrading`})]})]})}function ZH(){let{data:e}=L({queryKey:z.toolSelectionScore,queryFn:wr,refetchInterval:JH});return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Tool Selection`}),(0,I.jsx)(ci,{text:`Scores how efficiently tools were chosen today: penalizes re-reading a file without editing it, retrying a failing call, or fetching output that's never used.`})]}),!e||Array.isArray(e)||e.totalCalls===0?(0,I.jsx)(U,{icon:`radar`,title:`Waiting for tool calls`,subtitle:`Start a Claude Code session to begin scoring. Reflects today's activity across all sessions.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${hi(e.score)}`,children:e.score.toFixed(2)}),(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,children:`/ 1.0`})]}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted mt-1`,children:[e.penalizedCalls,` of `,e.totalCalls,` calls penalized`]}),(e.redundantReadCount>0||e.repeatedFailureCount>0||e.unusedOutputCount>0)&&(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-subtle mt-1 space-x-2`,children:[e.redundantReadCount>0&&(0,I.jsxs)(`span`,{children:[`re-reads: `,e.redundantReadCount]}),e.repeatedFailureCount>0&&(0,I.jsxs)(`span`,{children:[`repeat fails: `,e.repeatedFailureCount]}),e.unusedOutputCount>0&&(0,I.jsxs)(`span`,{children:[`unused output: `,e.unusedOutputCount]})]}),(0,I.jsx)(`div`,{className:`text-[10px] text-ink-subtle/60 mt-2`,children:`Penalizes: reading the same file 3+ times without editing, repeated tool failures, fetching large outputs never referenced.`})]})]})}function QH({aggregate:e}){let t=e?.latency,n=t?.byTool?Object.entries(t.byTool).filter(e=>e[1]!==null&&e[1].count>0).sort((e,t)=>t[1].p95-e[1].p95).slice(0,4):[];return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Latency (ms)`}),(0,I.jsx)(ci,{text:`How long tool calls took today — p50/p95/p99 across all calls, plus the slowest tools by p95.`})]}),!t||!t.overall?(0,I.jsx)(U,{icon:`clock`,title:`Waiting for tool calls`,subtitle:`Latency percentiles appear after tool calls complete.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex gap-4 text-xs mb-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p50 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p50})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p95 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p95})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p99 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p99})]})]}),n.length>0&&(0,I.jsx)(`div`,{className:`space-y-1`,children:n.map(([e,t])=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted truncate w-28 shrink-0`,children:wi(e)}),(0,I.jsxs)(`span`,{className:`tabular-nums text-ink-subtle`,children:[t.p95,`ms p95`]})]},e))})]})]})}function $H(){let{data:e}=L({queryKey:z.modelUsage,queryFn:Nr,refetchInterval:JH}),t=e?.byModel?Object.entries(e.byModel).filter(([,e])=>e.requestCount>0).sort((e,t)=>t[1].totalCostUsd-e[1].totalCostUsd).slice(0,4):[];return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Model Usage`}),(0,I.jsx)(ci,{text:`Cost and request volume per model used today, combining this server's live usage with every other session's saved totals. The live slice resets if the server process restarts.`})]}),!e||t.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No model data yet`,subtitle:`Start a Claude Code session to see model cost breakdown. Resets when the process restarts.`}):(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[t.map(([e,t])=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs gap-2`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted truncate`,children:e}),(0,I.jsxs)(`div`,{className:`flex gap-3 shrink-0 tabular-nums`,children:[(0,I.jsxs)(`span`,{className:`text-ink-subtle`,children:[t.requestCount,`req`]}),(0,I.jsxs)(`span`,{className:`text-ink-subtle`,children:[Si(t.costPerMillionTokens),`/1M tok`]}),(0,I.jsx)(`span`,{className:`text-ink-base`,children:xi(t.totalCostUsd)})]})]},e)),e?.mostEfficientModel&&(0,I.jsxs)(`div`,{className:`text-[10px] text-accent-green mt-1`,children:[`Most efficient: `,e.mostEfficientModel]})]})]})}function eU(e,t){let n=t===null?null:`${t}%`;return e===`excellent`?n?`Cache hit rate is ${n}. Cache is well-structured.`:`Cache is well-structured. No changes needed.`:e===`can_improve`?n?`Cache hit rate is ${n}. Placing stable content before variable content in prompts could improve this.`:`Place stable content before variable content in prompts to improve.`:n?`Cache hit rate is ${n}. Restructuring your system prompt so stable context appears at the top could bring this above 60%.`:`Restructure your system prompt so stable context appears at the top.`}function tU({aggregate:e}){let{data:t}=L({queryKey:z.cacheHealth,queryFn:Pr,refetchInterval:JH}),n=e?.cacheHealth,r=!n||n.status===`no_cache_activity`||n.cacheHitRatePct==null;return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Cache Health`}),(0,I.jsx)(ci,{text:`Prompt cache hit rate today, with a suggestion for improving it — usually by moving stable context earlier in the prompt.`})]}),r?(0,I.jsx)(U,{icon:`radar`,title:`No cache data yet`,subtitle:`Appears once token usage with cache reads is reported.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-1`,children:[(0,I.jsxs)(`span`,{className:`text-2xl font-semibold tabular-nums ${n.status===`excellent`?`text-accent-green`:n.status===`needs_attention`?`text-accent-amber`:`text-ink-base`}`,children:[n.cacheHitRatePct,`%`]}),(0,I.jsx)(ei,{tone:n.status===`needs_attention`?`warning`:`neutral`,size:`sm`,children:n.status===`excellent`?`excellent`:n.status.replace(`_`,` `)})]}),n.totalSavingsUsd>0&&(0,I.jsxs)(`div`,{className:`text-xs text-accent-green mb-1`,children:[`$`,n.totalSavingsUsd.toFixed(4),` saved`]}),t?.week_over_week_delta_pts!=null&&t.week_over_week_delta_pts!==0&&(0,I.jsxs)(`div`,{className:`text-[10px] font-medium mb-1 ${t.week_over_week_delta_pts>0?`text-accent-green`:`text-accent-amber`}`,children:[t.week_over_week_delta_pts>0?`↑`:`↓`,Math.abs(t.week_over_week_delta_pts),`pts vs last week`]}),(0,I.jsx)(`div`,{className:`text-[10px] text-ink-subtle/70 leading-snug`,children:eU(n.status,n.cacheHitRatePct)})]})]})}var nU=3e3;function rU({sessions:e,liveSessions:t}){let[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[,c]=qt(),l=Yn(e=>e.setActiveSession),{data:u}=L({queryKey:z.sessionCurrent,queryFn:ir}),d=(0,F.useMemo)(()=>{let e=new Set;for(let n of t)e.add(n.sessionId);if(e.size===0)if(u?.liveSessions?.length)for(let t of u.liveSessions)e.add(t);else u?.sessionId&&e.add(u.sessionId);return e},[t,u]),f=(t.length>0?t[0].sessionId:null)??(d.size>0?[...d][0]:null),p=n??f,m=p!==null&&d.has(p),h=n!==null&&!d.has(n);(0,F.useEffect)(()=>{l(p)},[p,l]);let{data:g}=L({queryKey:p?z.sessionReplay(p):[`replay`,`none`],queryFn:()=>br(p),enabled:p!==null,retry:!1,refetchInterval:m?nU:!1}),{data:_}=L({queryKey:p?z.sessionSubagents(p):[`subagents`,`none`],queryFn:()=>xr(p),enabled:p!==null,retry:!1,refetchInterval:m?nU:!1}),{data:v}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:m?1e4:!1}),{data:y}=L({queryKey:[`turn-costs`],queryFn:pr,refetchInterval:1e4}),{data:b}=L({queryKey:[`decision-tree`],queryFn:fr,refetchInterval:1e4}),{data:x}=L({queryKey:p?[`context`,p]:z.context,queryFn:()=>Ar(p??void 0),refetchInterval:1e4,enabled:m&&!!p}),{data:S}=L({queryKey:[`context-composition`],queryFn:jr,refetchInterval:1e4}),{data:C}=L({queryKey:[`context-efficiency`],queryFn:Mr,refetchInterval:1e4}),w=(0,F.useRef)(null);(0,F.useEffect)(()=>{m&&w.current&&(w.current.scrollTop=w.current.scrollHeight)},[g?.timeline.length,m]);let T=(0,F.useMemo)(()=>{let n=Date.now()-360*60*1e3,r=new Map;for(let e of t)r.set(e.sessionId,e);let i=new Map;for(let t of e){if(!t.sessionId)continue;let e=t.startTime!=null&&sU(t.startTime),a=r.has(t.sessionId),o=t.startTime!=null&&t.durationMs!=null?t.startTime+t.durationMs:null,s=o!=null&&o>=n&&sU(o);(e||a||s)&&i.set(t.sessionId,t)}for(let e of t)e.sessionId&&(i.has(e.sessionId)||i.set(e.sessionId,{sessionId:e.sessionId,sessionName:e.sessionName,startTime:e.startTime,toolCallCount:0,estimatedCostUsd:null}));let a=e=>{let t=r.get(e.sessionId);return t?t.lastActivity:e.startTime!=null&&e.durationMs!=null?e.startTime+e.durationMs:e.startTime??0};return[...i.values()].sort((e,t)=>a(t)-a(e)).slice(0,10)},[e,t]),E=(0,F.useMemo)(()=>g?.timeline??[],[g]),D=(0,F.useMemo)(()=>Array.isArray(_?.agents)?_.agents:[],[_]),O=(0,F.useMemo)(()=>{let e=null,t=null;for(let n of E){let r=n.timestamp+(n.durationMs??50);(e===null||n.timestamp<e)&&(e=n.timestamp),(t===null||r>t)&&(t=r)}let n=_?.window;return n&&Number.isFinite(n.startMs)&&Number.isFinite(n.endMs)&&(e=e===null?n.startMs:Math.min(e,n.startMs),t=t===null?n.endMs:Math.max(t,n.endMs)),e===null||t===null?{startMs:0,endMs:1}:{startMs:e,endMs:t>e?t:e+1}},[E,_]),k=(0,F.useMemo)(()=>{let e={};if(Array.isArray(v))for(let t of v)t&&typeof t.runId==`string`&&typeof t.status==`string`&&t.parentSessionId===p&&(e[t.runId]=t.status);return e},[v,p]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`glass-card mb-3 grid grid-cols-[220px_1fr] overflow-hidden`,style:{height:`320px`},children:[(0,I.jsxs)(`div`,{className:`border-r border-border-subtle flex flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5 p-2 border-b border-border-subtle shrink-0`,children:[(0,I.jsx)(V,{children:`Session Live Tail`}),(0,I.jsx)(ci,{text:`Today's sessions on the left; select one to stream its live tool-call trace on the right.`})]}),(0,I.jsxs)(`div`,{className:`overflow-auto flex-1`,children:[T.map(e=>{let t=d.has(e.sessionId);return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r(e.sessionId),className:`block w-full text-left p-2 border-b border-border-subtle text-xs transition-colors duration-150 hover:bg-surface-5 `+(p===e.sessionId?`bg-surface-5`:``),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base`,children:e.sessionName||e.sessionId.slice(0,8)}),t?(0,I.jsx)(ni,{label:`live`,size:`sm`}):(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,title:e.startTime?`Started ${_i(e.startTime)}`:void 0,children:e.startTime?_i(e.startTime+(e.durationMs??0)):``})]}),(0,I.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[10px] text-ink-subtle`,children:[(0,I.jsxs)(`span`,{children:[e.toolCallCount??0,` calls`]}),e.estimatedCostUsd!=null&&e.estimatedCostUsd>0?(0,I.jsx)(`span`,{children:xi(e.estimatedCostUsd)}):(0,I.jsx)(`span`,{children:`—`})]})]},e.sessionId)}),d.size===0&&T.length===0&&(0,I.jsx)(U,{icon:`code`,title:`No sessions today`,subtitle:`Start coding with Claude to see sessions here.`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[p&&(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 border-b border-border-subtle shrink-0`,children:[(0,I.jsx)(V,{children:`Trace`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h&&(0,I.jsx)(`span`,{"data-testid":`session-ended-badge`,children:(0,I.jsx)(ei,{tone:`neutral`,size:`sm`,uppercase:!0,children:`Session ended`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>c(`/sessions?id=${p}`),className:`text-[10px] text-accent-cyan hover:underline transition-colors duration-150`,children:`full session →`})]})]}),(0,I.jsxs)(`div`,{ref:w,className:`overflow-auto flex-1 p-2`,children:[!p&&(0,I.jsx)(`div`,{className:`text-ink-muted text-xs p-2`,children:`Select a session to view its timeline.`}),p&&E.length===0&&D.length===0&&(0,I.jsx)(U,{icon:`timeline`,title:m?`Waiting for tool calls`:`No tool calls`,subtitle:m?`Tool calls will appear here in real time.`:`This session has no recorded tool calls.`}),p&&(E.length>0||D.length>0)&&(0,I.jsx)(Ca,{sessionId:p,parentEntries:E,agents:D,window:O,runStatusById:k,parentSegments:g?.segments??[],onSelectRun:e=>a(e)},p)]}),m&&p&&(0,I.jsx)(`div`,{className:`border-t border-bg-line px-3 py-2 shrink-0`,children:(0,I.jsx)(_H,{sessionId:p,expandable:!1})}),((b?.totalBranches??0)>0||(y?.turns?.length??0)>0||(x?.history?.length??0)>=2)&&(0,I.jsx)(`div`,{className:`border-t border-bg-line px-3 py-2 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-accent-cyan hover:underline transition-colors duration-150 text-left`,children:(()=>{let e=[];return b&&b.totalBranches>0&&e.push(`${b.longestFailureStreak} failure streak`),y?.turns&&y.turns.length>0&&e.push(`${y.turns.length} turns · $${y.totalAttributedCost.toFixed(2)}`),e.length>0?`${e.join(` · `)} — session detail →`:`session detail →`})()})})]})]}),i!=null&&(0,I.jsx)(qa,{runId:i,onClose:()=>a(null)}),o&&(0,I.jsx)(yH,{decisionTree:b,turnCosts:y,contextHistory:x?.history,contextWindow:x?.contextWindow,contextComposition:S,contextEfficiency:C,onClose:()=>s(!1)})]})}function iU(e,t){let n=t.find(t=>t.sessionId===e);return n?.sessionName?n.sessionName:e.slice(0,8)}function aU(){let{data:e,isLoading:t,error:n}=L({queryKey:z.alertsRecent,queryFn:async()=>{try{return await yr()}catch(e){if(e instanceof nr)return null;throw e}},refetchInterval:KH,retry:!1});if(e===null)return null;let r=[...e??[]].sort((e,t)=>t.firedAt-e.firedAt);return(0,I.jsxs)(B,{padding:`sm`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Recent Alerts`}),(0,I.jsx)(ci,{text:`The most recent alert firings and resolutions from your configured alert rules, newest first.`})]}),t&&(0,I.jsx)(U,{variant:`loading`,title:`Loading...`}),n&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading recent alerts.`}),!t&&!n&&r.length===0&&(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`No alerts in recent history.`}),!t&&!n&&r.length>0&&(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`when`}),(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`sev`}),(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`rule`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`value / threshold`}),(0,I.jsx)(`th`,{className:`text-left pb-1 pl-2`,children:`state`})]})}),(0,I.jsx)(`tbody`,{children:r.slice(0,50).map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`py-1 text-ink-subtle tabular-nums whitespace-nowrap`,children:oU(e.firedAt)}),(0,I.jsxs)(`td`,{className:`py-1`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:qH[e.severity],children:`●`}),` `,(0,I.jsx)(`span`,{className:`text-ink-subtle uppercase tracking-wider text-[10px]`,children:e.severity})]}),(0,I.jsx)(`td`,{className:`py-1`,children:e.title}),(0,I.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[bi(e.value),` / `,bi(e.threshold)]}),(0,I.jsx)(`td`,{className:`py-1 pl-2 `+(e.state===`firing`?`text-accent-amber`:`text-ink-muted`),children:e.state})]},`${e.id}-${e.firedAt}-${e.state}`))})]})]})}function oU(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var sU=e=>WH(e);function cU(e){let t=e.estimatedCostUsd;if(t==null||t<=0||e.startTime==null)return 0;let n=UH(),r=n+864e5,i=e.startTime,a=typeof e.endTime==`number`?e.endTime:typeof e.durationMs==`number`?e.startTime+e.durationMs:Date.now();return a<n||i>=r?0:i>=n&&a<r?t:t*((Math.min(a,r)-Math.max(i,n))/Math.max(1,a-i))}function lU(e){let t=0;for(let n of e)t+=cU(n);return t}function uU(e){let t=0;for(let n of e)(n.startTime&&sU(n.startTime)||cU(n)>0)&&(t+=n.toolCallCount??0);return t}function dU(e){let t=0;for(let n of e)(n.startTime&&sU(n.startTime)||cU(n)>0)&&(t+=n.antiPatterns?.length??0);return t}function fU(e){let t=Array(24).fill(0);for(let n of e){if(!n.startTime||!sU(n.startTime)||n.estimatedCostUsd==null)continue;let e=new Date(n.startTime).getHours();t[e]+=n.estimatedCostUsd}return t.map((e,t)=>({hour:t,cost:e}))}function pU({todayTotal:e,forecastEod:t,hourlySpend:n,subagentUsd:r=0}){let i=t!==null&&Number.isFinite(t),a=i?Math.max(t,e):0,o=i?a-e:0,s=i&&e>0?o/e*100:0,c=n.some(e=>e.cost>0),l=r>0?Math.max(0,e-r):0;return(0,I.jsxs)(B,{padding:`sm`,className:`mb-3 h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,I.jsx)(V,{children:`Forecast · End of Day`}),(0,I.jsx)(ci,{text:`Projects today's total spend by midnight, based on the spending trend so far this hour-by-hour.`})]}),i?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold text-accent-cyan tabular-nums`,children:xi(a)}),(0,I.jsx)(`span`,{className:`text-xs text-ink-muted tabular-nums`,children:o>0?(0,I.jsxs)(I.Fragment,{children:[`+`,xi(o),e>0&&` (+${s.toFixed(0)}%)`,` from now`]}):(0,I.jsx)(I.Fragment,{children:`on pace`})})]}),c&&(0,I.jsxs)(`div`,{className:`mt-2`,children:[(0,I.jsx)(na,{hours:n}),r>0&&(0,I.jsxs)(`div`,{className:`flex gap-3 mt-1 text-[10px] text-ink-muted tabular-nums`,children:[(0,I.jsxs)(`span`,{children:[`parent `,xi(l)]}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:`·`}),(0,I.jsxs)(`span`,{children:[`subagent `,xi(r)]})]})]})]}):(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`Insufficient data — forecast appears once burn rate stabilizes.`})]})}function mU(e,t){let{startMs:n,endMs:r,bucketSizeMs:i}=t,a=Math.max(1,Math.ceil((r-n)/i)),o=Array(a).fill(0);for(let t of e){let e=Math.floor((t.timestamp-n)/i);e>=0&&e<a&&o[e]++}return o}function hU(e){return e<6e5?3e4:e<36e5?6e4:e<144e5?3e5:9e5}var gU=50,_U={thrashing:`Edit/Test Thrashing`,stuck_loop:`Stuck Loop`,blind_editing:`Blind Editing`,re_reading:`Repeated Reads`},vU={running:{tone:`info`,label:`Running`},completed:{tone:`success`,label:`Completed`},failed:{tone:`danger`,label:`Failed`},cancelled:{tone:`warning`,label:`Cancelled`},unknown:{tone:`neutral`,label:`Unknown`}},yU=[{value:`today`,label:`Today`},{value:`7d`,label:`7 days`},{value:`30d`,label:`30 days`},{value:`all`,label:`All`}],bU=[{value:`all`,label:`All sources`},{value:`script`,label:`Script`},{value:`agent_tool`,label:`Agent tool`}],xU=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`completed`,label:`Completed`},{value:`failed`,label:`Failed`},{value:`cancelled`,label:`Cancelled`}];function SU(e,t){if(t===`all`||e==null)return!0;let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return!0;let r=Date.now();return n>={today:new Date().setHours(0,0,0,0),"7d":r-10080*60*1e3,"30d":r-720*60*60*1e3}[t]}function CU(e){let t;try{let n=new URLSearchParams(e);t=n.get(`session`)??n.get(`id`)}catch{return null}if(t==null)return null;let n=t.trim();return n.length===0||n.length>256?null:n}function wU(e){return typeof e.startTime==`number`?e.startTime:new Date(e.startTime??0).getTime()}function TU(e){return wU(e)+(e.durationMs??0)}function EU(e,t){let n=[...e];switch(t){case`date`:n.sort((e,t)=>wU(t)-wU(e));break;case`lastActive`:n.sort((e,t)=>TU(t)-TU(e));break;case`cost`:n.sort((e,t)=>(t.estimatedCostUsd??0)-(e.estimatedCostUsd??0));break;case`calls`:n.sort((e,t)=>(t.toolCallCount??0)-(e.toolCallCount??0));break}return n}function DU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function OU(){let e=Jt(),[t,n]=(0,F.useState)(()=>CU(window.location.search)),[r,i]=(0,F.useState)(`date`),[a,o]=(0,F.useState)(`all`),[s,c]=(0,F.useState)(`all`),[l,u]=(0,F.useState)(`all`),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(()=>new Set),[h,g]=(0,F.useState)(()=>new Set),_=(0,F.useMemo)(()=>CU(e),[e]);(0,F.useEffect)(()=>{_&&n(_)},[_]);let v=L({queryKey:z.sessionsList(gU),queryFn:()=>ar(gU),refetchInterval:1e4}),{data:y}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:1e4}),b=L({queryKey:z.sessionCurrent,queryFn:ir,refetchInterval:1e4}),x=(0,F.useMemo)(()=>{let e=new Set;if(b.data?.liveSessions?.length)for(let t of b.data.liveSessions)e.add(t);else b.data?.sessionId&&e.add(b.data.sessionId);return e},[b.data]),S=L({queryKey:t?z.sessionDetail(t):[`session`,`none`],queryFn:()=>cr(t),enabled:t!==null,refetchInterval:b.isLoading||t&&x.has(t)?1e4:!1}),C=(0,F.useMemo)(()=>EU(v.data??[],r),[v.data,r]),w=(0,F.useMemo)(()=>Array.isArray(y)?y:[],[y]),T=(0,F.useMemo)(()=>w.filter(e=>!(!SU(e.startedAt,a)||s!==`all`&&e.runSource!==s||l!==`all`&&e.status!==l)),[w,a,s,l]),E=(0,F.useMemo)(()=>{let e=T.length,t=T.reduce((e,t)=>e+(t.agentCount??0),0),n=T.map(e=>e.totalUsd).filter(e=>e!=null),r=n.length>0?n.reduce((e,t)=>e+t,0):null,i=T.map(e=>e.durationMs).filter(e=>e!=null);return{totalRuns:e,totalAgents:t,totalSpend:r,avgDurationMs:i.length>0?i.reduce((e,t)=>e+t,0)/i.length:null}},[T]),D=(0,F.useMemo)(()=>{let e=new Map;for(let t of T){let n=t.parentSessionId;if(typeof n!=`string`)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}return e},[T]),O=a!==`all`||s!==`all`||l!==`all`,k=(0,F.useMemo)(()=>O?C.filter(e=>D.has(e.sessionId)):C,[O,C,D]);(0,F.useEffect)(()=>{if(t)return;let e=x.size>0?[...x][0]:null;e?n(e):C.length>0&&n(C[0].sessionId)},[x,C,t]);let A=e=>{n(e)},j=(0,F.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ee=(0,F.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=(0,F.useCallback)(e=>{f(e)},[]);return(0,I.jsxs)(`section`,{className:`flex flex-col h-full`,children:[(0,I.jsx)(`div`,{className:`h-8 overflow-hidden rounded-lg mb-2 shrink-0`,children:(0,I.jsx)(LH,{theme:`sessions`})}),(0,I.jsx)(`h1`,{className:`text-lg font-semibold gradient-text mb-2 shrink-0`,children:`Sessions`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,className:`mb-2 shrink-0`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4 divide-x divide-border-subtle`,children:[(0,I.jsx)(`div`,{className:`px-3 first:pl-0`,children:(0,I.jsx)(Ji,{label:`Workflow runs`,value:String(E.totalRuns),numericValue:E.totalRuns,animate:!0})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Subagents`,value:String(E.totalAgents),numericValue:E.totalAgents,animate:!0})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Workflow spend`,value:Si(E.totalSpend),tone:E.totalSpend===null?`neutral`:`warn`})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Avg duration`,value:E.avgDurationMs===null?`—`:yi(E.avgDurationMs)})})]})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap mb-2 shrink-0`,children:[(0,I.jsx)(ai,{value:a,onChange:o,options:yU,ariaLabel:`Time window`}),(0,I.jsx)(`div`,{className:`h-4 w-px bg-border-subtle`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Run source filter`,children:bU.map(e=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":s===e.value,onClick:()=>c(e.value),className:[`px-2.5 py-1 rounded-full text-[11px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,s===e.value?`bg-accent-cyan/20 text-accent-cyan font-medium`:`text-ink-muted hover:text-ink-subtle`].join(` `),children:e.label},e.value))}),(0,I.jsx)(`div`,{className:`h-4 w-px bg-border-subtle`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Status filter`,children:xU.map(e=>{let t=l===e.value;return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>u(e.value),className:[`px-2.5 py-1 rounded-full text-[11px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,t?`bg-accent-green/20 text-accent-green font-medium`:`text-ink-muted hover:text-ink-subtle`].join(` `),children:e.label},e.value)})}),O&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{o(`all`),c(`all`),u(`all`)},className:`text-[10px] text-ink-muted hover:text-ink-subtle underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40 rounded-sm`,children:`Clear filters`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[260px_1fr] gap-3 flex-1 min-h-0`,children:[(0,I.jsxs)(B,{padding:`none`,tone:`static`,className:`overflow-hidden flex flex-col`,children:[(0,I.jsx)(`header`,{className:`p-2 border-b border-border-subtle`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(V,{as:`h2`,children:`List`}),(0,I.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`text-[10px] bg-surface-5 border border-border-medium rounded-md px-1.5 py-0.5 text-ink-subtle`,children:[(0,I.jsx)(`option`,{value:`date`,children:`Newest`}),(0,I.jsx)(`option`,{value:`lastActive`,children:`Last active`}),(0,I.jsx)(`option`,{value:`cost`,children:`Cost`}),(0,I.jsx)(`option`,{value:`calls`,children:`Calls`})]})]})}),(0,I.jsxs)(`div`,{className:`overflow-auto`,children:[v.isLoading&&(0,I.jsx)(U,{variant:`loading`,icon:`timeline`,title:`Loading sessions`}),!v.isLoading&&k.length===0&&x.size===0&&(0,I.jsx)(U,{icon:`code`,title:O?`No matching sessions`:`No sessions yet`,subtitle:O?`No sessions own a workflow run matching these filters.`:`Start coding with Claude to see your sessions here.`}),k.map(e=>(0,I.jsx)(kU,{row:e,isLive:x.has(e.sessionId),isSelected:t===e.sessionId,isExpanded:p.has(e.sessionId),sortKey:r,runs:D.get(e.sessionId)??[],expandedRuns:h,onSelect:A,onToggleSession:j,onToggleRun:ee,onOpenRun:M},e.sessionId)),C.length>=gU&&(0,I.jsxs)(`div`,{className:`p-2 text-[10px] text-ink-muted text-center border-t border-border-subtle`,children:[`Showing `,gU,` most recent sessions.`]})]})]}),(0,I.jsxs)(`div`,{className:`glass-card glass-card-static p-4 overflow-auto`,children:[!t&&(0,I.jsx)(U,{icon:`timeline`,title:`Loading sessions`,subtitle:`Selecting the most recent session…`}),t&&S.isLoading&&(0,I.jsx)(U,{variant:`loading`,icon:`timeline`,title:`Loading detail`}),t&&S.data&&(0,I.jsx)(MU,{data:S.data,isLive:!!t&&x.has(t),onOpenRun:M})]})]}),d!=null&&(0,I.jsx)(qa,{runId:d,onClose:()=>f(null)})]})}function kU({row:e,isLive:t,isSelected:n,isExpanded:r,sortKey:i,runs:a,expandedRuns:o,onSelect:s,onToggleSession:c,onToggleRun:l,onOpenRun:u}){return(0,I.jsxs)(`div`,{className:`border-b border-border-subtle`,children:[(0,I.jsxs)(`div`,{className:`flex items-stretch text-xs transition-colors duration-150 hover:bg-surface-5 `+(n?`bg-surface-5`:``),children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":r?`Collapse workflows`:`Expand workflows`,"aria-expanded":r,onClick:t=>{t.stopPropagation(),c(e.sessionId)},className:`shrink-0 flex items-center justify-center w-6 text-ink-muted hover:text-ink-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:r?(0,I.jsx)(vn,{size:13,"aria-hidden":`true`}):(0,I.jsx)(yn,{size:13,"aria-hidden":`true`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>s(e.sessionId),className:`flex-1 min-w-0 text-left py-2 pr-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base truncate`,children:e.sessionName||e.sessionId.slice(0,8)}),t&&(0,I.jsx)(ni,{size:`sm`,label:`live`,className:`shrink-0`})]}),(0,I.jsxs)(`div`,{className:`flex justify-between mt-1 text-ink-subtle text-[11px] tabular-nums`,children:[(0,I.jsxs)(`span`,{children:[e.toolCallCount??0,` calls`]}),(0,I.jsx)(`span`,{className:`text-ink-muted`,title:i===`lastActive`&&e.startTime?`Started ${gi(e.startTime)}`:void 0,children:e.startTime?gi(i===`lastActive`?TU(e):e.startTime):`—`}),(0,I.jsx)(`span`,{children:Si(e.estimatedCostUsd)})]})]})]}),r&&(0,I.jsx)(`div`,{className:`pl-3 border-l border-border-subtle ml-3 mb-1`,children:a.length===0?(0,I.jsx)(`div`,{className:`py-1.5 pl-1 text-[10px] text-ink-muted`,children:`No workflows in this session.`}):a.map(e=>(0,I.jsx)(AU,{run:e,isExpanded:o.has(e.runId),onToggleRun:l,onOpenRun:u},e.runId))})]})}function AU({run:e,isExpanded:t,onToggleRun:n,onOpenRun:r}){let{data:i}=L({queryKey:z.workflowDetail(e.runId),queryFn:()=>Vr(e.runId),enabled:t}),a=(0,F.useMemo)(()=>i?.agents??[],[i]),o=vU[e.status]??vU.unknown;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-stretch hover:bg-surface-5 rounded transition-colors`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":t?`Collapse agents`:`Expand agents`,"aria-expanded":t,onClick:t=>{t.stopPropagation(),n(e.runId)},className:`shrink-0 flex items-center justify-center w-5 text-ink-muted hover:text-ink-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:t?(0,I.jsx)(vn,{size:12,"aria-hidden":`true`}):(0,I.jsx)(yn,{size:12,"aria-hidden":`true`})}),(0,I.jsxs)(`button`,{type:`button`,"aria-label":`View workflow run ${e.workflowName??e.runId}`,onClick:()=>r(e.runId),className:`flex-1 min-w-0 flex items-center gap-1.5 text-left py-1.5 pr-1 text-[10px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40 rounded`,children:[(0,I.jsx)(`span`,{className:`flex-1 min-w-0 font-medium text-ink-base truncate`,children:e.workflowName??e.runId}),(0,I.jsxs)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:[e.agentCount==null?0:e.agentCount,`a`]}),(0,I.jsx)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:Si(e.totalUsd)}),(0,I.jsx)(ei,{tone:o.tone,size:`sm`,bordered:!0,children:o.label})]})]}),t&&(0,I.jsx)(`div`,{className:`pl-3 border-l border-border-subtle ml-2.5`,children:a.length===0?(0,I.jsx)(`div`,{className:`py-1 pl-1 text-[10px] text-ink-muted`,children:`No agents recorded.`}):a.map(t=>(0,I.jsxs)(`button`,{type:`button`,"aria-label":`View agent ${t.label} in run ${e.workflowName??e.runId}`,onClick:()=>r(e.runId),className:`flex w-full items-center gap-1.5 text-left py-1 pr-1 text-[10px] hover:bg-surface-5 rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:[(0,I.jsx)(`span`,{className:`flex-1 min-w-0 text-ink-subtle truncate`,title:t.label,children:t.label}),(0,I.jsx)(`span`,{className:`font-mono text-ink-muted truncate max-w-[72px] shrink-0`,title:t.model,children:t.model}),(0,I.jsx)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:DU(t.tokens)})]},t.agentId))})]})}function jU(e){return e===`Read`?`bg-accent-blue/80`:e===`Edit`||e===`Write`?`bg-accent-green/80`:e===`Bash`?`bg-accent-purple/80`:e===`Agent`?`bg-accent-teal/80`:`bg-ink-subtle/80`}function MU({data:e,isLive:t,onOpenRun:n}){let r=e.toolBreakdown??{},i=Object.entries(r).sort((e,t)=>t[1]-e[1]),a=e.toolCallCount??0,o=e.durationMs==null?null:yi(e.durationMs),s=e.timeline??[],c=s.length>0?s[0].timestamp:0;return s.length===0&&i.length===0?(0,I.jsx)(U,{icon:`timeline`,title:`No tool calls`,subtitle:`This session has no recorded tool calls.`}):(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`text-xs tracking-wider text-ink-muted flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base ${e.sessionName?`font-medium`:`uppercase`}`,children:e.sessionName||e.sessionId.slice(0,8)}),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsxs)(`span`,{className:`uppercase`,children:[a,` calls`]}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:o})]}),t&&(0,I.jsx)(ni,{size:`sm`,label:`live`})]}),c>0&&(0,I.jsx)(`div`,{className:`text-[11px] text-ink-subtle mt-0.5`,children:new Date(c).toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-4 text-xs`,children:[e.model&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Model`}),(0,I.jsx)(`div`,{className:`font-mono`,children:e.model})]}),e.estimatedCostUsd!=null&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Cost`}),(0,I.jsx)(`div`,{className:`tabular-nums`,children:xi(e.estimatedCostUsd)})]}),e.outcome&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Status`}),(0,I.jsx)(`div`,{className:`capitalize`,children:e.outcome})]})]}),(e.antiPatterns?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Anti-Patterns`}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.antiPatterns.map(({type:e,count:t})=>(0,I.jsxs)(ei,{tone:`warning`,size:`sm`,bordered:!0,children:[_U[e]??e,(0,I.jsxs)(`span`,{className:`opacity-70`,children:[`× `,t]})]},e))})]}),(e.qualityProxy||e.toolSelectionScore)&&(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-4`,children:[e.qualityProxy&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Session Quality`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Diff Apply `}),(0,I.jsx)(`span`,{className:mi(e.qualityProxy.diffApplyRate),children:e.qualityProxy.diffApplyRate===null?`—`:`${(e.qualityProxy.diffApplyRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Test Pass `}),(0,I.jsx)(`span`,{className:mi(e.qualityProxy.testPassRate),children:e.qualityProxy.testPassRate===null?`—`:`${(e.qualityProxy.testPassRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Backtracks `}),(0,I.jsx)(`span`,{className:e.qualityProxy.backtrackCount>0?`text-accent-amber`:``,children:e.qualityProxy.backtrackCount})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Self-corrections `}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.qualityProxy.selfCorrectionCount})]})]})]}),e.toolSelectionScore&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Tool Selection`}),(0,I.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums ${hi(e.toolSelectionScore.score)}`,children:e.toolSelectionScore.score.toFixed(2)}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted mt-1`,children:[`re-reads: `,e.toolSelectionScore.redundantReadCount,` · repeat fails:`,` `,e.toolSelectionScore.repeatedFailureCount,` · unused:`,` `,e.toolSelectionScore.unusedOutputCount]})]})]}),t&&(0,I.jsx)(`div`,{className:`mb-4`,children:(0,I.jsx)(_H,{sessionId:e.sessionId})}),i.length>0&&(0,I.jsx)(PU,{breakdownEntries:i,totalCalls:a,isLive:t,sessionId:e.sessionId}),(0,I.jsx)(IU,{timeline:s}),(e.filesRead?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Files Read`}),(0,I.jsx)(`ul`,{className:`text-[11px] text-ink-subtle space-y-0.5`,children:e.filesRead.map(e=>(0,I.jsx)(`li`,{className:`font-mono truncate`,children:e.split(`/`).slice(-2).join(`/`)},e))})]}),(e.filesModified?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Files Modified`}),(0,I.jsx)(`ul`,{className:`text-[11px] text-ink-subtle space-y-0.5`,children:e.filesModified.map(e=>(0,I.jsx)(`li`,{className:`font-mono truncate`,children:e.split(`/`).slice(-2).join(`/`)},e))})]}),(0,I.jsx)(NU,{sessionId:e.sessionId,isLive:t,parentEntries:s,onOpenRun:n},e.sessionId)]})}function NU({sessionId:e,isLive:t,parentEntries:n,onOpenRun:r}){let{data:i,isLoading:a,isError:o}=L({queryKey:z.sessionSubagents(e),queryFn:()=>xr(e),retry:!1,refetchInterval:t?1e4:!1}),{data:s}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:t?1e4:3e4}),c=(0,F.useMemo)(()=>{let t={};if(!Array.isArray(s))return t;for(let n of s)n.parentSessionId===e&&(t[n.runId]=n.status);return t},[s,e]),l=(0,F.useMemo)(()=>i?.agents??[],[i]),u=(0,F.useMemo)(()=>{let e=i!==void 0&&(i.agents?.length??0)>0,t=e?i.window.startMs:null,r=e?i.window.endMs:null,a=null,o=null;for(let e of n){let t=e.timestamp,n=e.timestamp+(e.durationMs??50);(a===null||t<a)&&(a=t),(o===null||n>o)&&(o=n)}let s=[a,t].filter(e=>e!==null),c=[o,r].filter(e=>e!==null);return s.length===0||c.length===0?null:{startMs:Math.min(...s),endMs:Math.max(...c)}},[i,n]),d=(0,F.useMemo)(()=>n.map(e=>({timestamp:e.timestamp,toolName:e.toolName,durationMs:e.durationMs,success:e.success,filePath:e.filePath,command:e.command})),[n]);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Session trace`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:a?(0,I.jsx)(U,{variant:`loading`,icon:`radar`,title:`Loading subagents`}):o||i===void 0?(0,I.jsx)(Ca,{sessionId:e,parentEntries:d,agents:[],window:u??{startMs:0,endMs:1},onSelectRun:r,runStatusById:c}):(0,I.jsx)(Ca,{sessionId:e,parentEntries:d,agents:l,window:u??i.window,onSelectRun:r,runStatusById:c})})]})}function PU({breakdownEntries:e,totalCalls:t,isLive:n,sessionId:r}){let[i,a]=(0,F.useState)(`calls`),o=`/api/context?sessionId=${encodeURIComponent(r)}`,{data:s}=L({queryKey:[`context`,r],queryFn:()=>fetch(o).then(e=>e.ok?e.json():null),refetchInterval:1e4,enabled:n&&i===`context`}),c=s?.toolContributions??[],l=c.length>0?c[0].estimatedTokens:0;return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,I.jsx)(V,{children:`Tools`}),n&&(0,I.jsx)(ai,{value:i,onChange:a,options:[{value:`calls`,label:`Calls`},{value:`context`,label:`Context`}],size:`sm`,tone:`cyan`,ariaLabel:`Tools view`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i===`calls`&&e.map(([e,n])=>{let r=t>0?n/t*100:0;return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`w-28 text-ink-subtle truncate`,title:e,children:wi(e)}),(0,I.jsx)(`div`,{className:`flex-1 h-3 bg-surface-3 relative rounded`,children:(0,I.jsx)(`div`,{className:`h-3 rounded ${jU(e)}`,style:{width:`${r}%`}})}),(0,I.jsx)(`span`,{className:`w-10 text-right text-ink-muted tabular-nums`,children:n})]},e)}),i===`context`&&c.map(e=>{let t=l>0?e.estimatedTokens/l*100:0;return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`w-28 text-ink-subtle truncate`,title:e.tool,children:wi(e.tool)}),(0,I.jsx)(`div`,{className:`flex-1 h-3 bg-surface-3 relative rounded`,children:(0,I.jsx)(`div`,{className:`h-3 rounded bg-accent-amber/80`,style:{width:`${t}%`}})}),(0,I.jsxs)(`span`,{className:`w-16 text-right text-ink-muted tabular-nums text-[10px]`,children:[`~`,FU(e.estimatedTokens)]})]},e.tool)}),i===`context`&&c.length===0&&(0,I.jsx)(`div`,{className:`text-[11px] text-ink-muted`,children:`No context data available yet`})]})]})}function FU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function IU({timeline:e}){let t=(0,F.useMemo)(()=>{if(e.length<2)return null;let t=e[0].timestamp,n=e[e.length-1].timestamp,r=n-t;if(r<1e3)return null;let i=hU(r),a=mU(e,{startMs:t,endMs:n+i,bucketSizeMs:i});return{buckets:a,maxCount:Math.max(...a,1),bucketSizeMs:i,startMs:t}},[e]);return t?(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Activity Density`}),(0,I.jsx)(NH,{variant:`strip`,buckets:t.buckets,maxCount:t.maxCount,bucketSizeMs:t.bucketSizeMs,startTimestamp:t.startMs,ariaLabel:`Session activity density`})]}):null}var LU={fill:`var(--color-ink-muted)`,fontSize:10},RU=`var(--color-border-subtle)`,zU={background:`var(--color-bg-elevated)`,border:`1px solid var(--color-border-medium)`,borderRadius:8,fontSize:12,color:`var(--color-ink-base)`},BU=`var(--color-accent-green)`,VU=`var(--color-accent-amber)`,HU=`var(--color-accent-green)`,UU=`var(--color-accent-purple)`,WU=`var(--color-accent-blue)`,GU=`var(--color-accent-teal)`;function KU(e){return e===`Read`?WU:e===`Edit`||e===`Write`?HU:e===`Bash`?UU:e===`Agent`?GU:`var(--color-ink-muted)`}function qU(e){let t=e.toLowerCase();return t===`bug fix`||t===`fix`?`#FF6B6B`:t===`feature`?HU:t===`refactor`?WU:t===`configuration`||t===`config`?VU:t===`test`?GU:t===`docs`?`#C4B5FD`:UU}function JU(e){return typeof e==`string`&&e.length>=10?e.slice(5,10):e}var YU=`Compares session outcomes before and after your most recent change to an instruction file (CLAUDE.md, or the active platform's equivalent) — success rate, token usage, and thrashing incidents. A degraded verdict means sessions got worse after the edit, not better.`;function XU({label:e,value:t}){return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-[10px] text-ink-muted uppercase tracking-wider`,children:e}),(0,I.jsx)(`div`,{className:`text-sm font-bold tabular-nums mt-0.5`,children:t})]})}function ZU({data:e}){if(!e)return(0,I.jsx)($U,{title:`Instruction Drift`,tooltip:YU,children:(0,I.jsx)(U,{variant:`loading`,title:`Loading drift data…`})});let t=e.recentCorrelations[e.recentCorrelations.length-1];return t?(0,I.jsx)($U,{title:`Instruction Drift — most recent instruction file change`,tooltip:YU,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,I.jsx)(ei,{tone:{improved:`success`,degraded:`danger`,neutral:`neutral`,insufficient_data:`neutral`}[t.verdict],children:t.verdict}),(0,I.jsx)(XU,{label:`Success`,value:t.successRateDelta===null?`—`:`${t.successRateDelta>0?`+`:``}${Math.round(t.successRateDelta*100)}%`}),(0,I.jsx)(XU,{label:`Tokens`,value:`${t.tokensDelta>0?`+`:``}${t.tokensDelta}`}),(0,I.jsx)(XU,{label:`Thrashing`,value:`${t.thrashingDelta>0?`+`:``}${t.thrashingDelta}`})]})}):(0,I.jsx)($U,{title:`Instruction Drift`,tooltip:YU,children:(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`No instruction file changes tracked yet.`})})}function QU(){let e=L({queryKey:z.weekly,queryFn:hr}),t=L({queryKey:z.sessionsList(200),queryFn:()=>ar(200)}),n=L({queryKey:z.costPerOutcome(30),queryFn:()=>_r(30)}),r=L({queryKey:z.personalCoach,queryFn:vr}),i=L({queryKey:z.activityHeatmap(`history`),queryFn:()=>kr(`history`,12)}),a=L({queryKey:z.concurrencyHistory(30),queryFn:()=>Or(30)}),o=L({queryKey:z.instructionDrift,queryFn:Hr}),s=e.isError||t.isError||n.isError||a.isError,c=[...e.data??[]].reverse(),l=c.map(e=>{let t=e.avgEfficiencyScore;return{week:e.week||`?`,efficiency:t===null?null:Math.round(t*100)}}),u=rW(tW(t.data??[],30),30),d=nW(n.data),f=iW(c),p=oW(t.data??[]),m=sW(t.data??[]),h=a.data?.dailyPeaks??[],g=h.some(e=>e.peak>0);return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`history`}),(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text mb-4`,children:`History`}),s&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs mb-3`,children:`Error loading some history data. Charts below may be incomplete.`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)($U,{title:`Weekly Efficiency · Last 12`,children:(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(aH,{data:l,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`effGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:BU,stopOpacity:.3}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:BU,stopOpacity:0})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`week`,tick:LU,stroke:RU,tickFormatter:JU}),(0,I.jsx)(fB,{tick:LU,stroke:RU,domain:[0,100],unit:`%`}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(xR,{type:`monotone`,dataKey:`efficiency`,stroke:BU,strokeWidth:2,fill:`url(#effGradient)`,dot:{r:2,fill:BU}})]})})})}),(0,I.jsx)($U,{title:`Daily Spend · Last 30 Days (most recent 200)`,children:(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:u,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`costGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:BU,stopOpacity:.9}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:BU,stopOpacity:.4})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`day`,tick:LU,stroke:RU,tickFormatter:JU,interval:`preserveStartEnd`,minTickGap:20}),(0,I.jsx)(fB,{tick:LU,stroke:RU,unit:`$`}),(0,I.jsx)(ZA,{contentStyle:zU,labelFormatter:e=>JU(String(e)),cursor:!1}),(0,I.jsx)(Az,{dataKey:`cost`,fill:`url(#costGradient)`,radius:[3,3,0,0]})]})})})}),(0,I.jsx)($U,{title:`Cost Per Outcome · Last 30 Days`,children:d.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No outcomes yet`,subtitle:`Finish a few sessions and check back.`}):(0,I.jsx)(`div`,{className:`min-w-0`,style:{height:`${Math.max(176,d.length*32+40)}px`},children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:d,layout:`vertical`,children:[(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{type:`number`,tick:LU,stroke:RU,unit:`$`}),(0,I.jsx)(fB,{type:`category`,dataKey:`outcome`,tick:LU,stroke:RU,width:110}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(Az,{dataKey:`totalCost`,radius:[0,3,3,0],children:d.map(e=>(0,I.jsx)(QA,{fill:qU(e.outcome),fillOpacity:.8},e.outcome))})]})})})}),(0,I.jsx)($U,{title:`Anti-Pattern Frequency · Weekly`,children:f.length===0?(0,I.jsx)(U,{icon:`checkmark`,title:`No anti-patterns detected`,subtitle:`No anti-patterns detected in the loaded weeks.`}):(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:f,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`antiPatternGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:VU,stopOpacity:.9}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:VU,stopOpacity:.4})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`week`,tick:LU,stroke:RU,tickFormatter:JU}),(0,I.jsx)(fB,{tick:LU,stroke:RU}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(Az,{dataKey:`count`,fill:`url(#antiPatternGradient)`,radius:[3,3,0,0]})]})})})}),(0,I.jsx)($U,{title:`Model Performance`,children:p.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No model data yet`,subtitle:`Complete a few sessions to see model performance.`}):(0,I.jsxs)(`div`,{className:`h-44 overflow-y-auto text-xs`,children:[(0,I.jsxs)(`table`,{className:`w-full`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted sticky top-0 bg-bg-panel`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`Model`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Sessions`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Eff.`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Success`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Avg $`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`$/1M tok`})]})}),(0,I.jsx)(`tbody`,{children:p.map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-bg-line`,children:[(0,I.jsx)(`td`,{className:`py-1 font-medium`,children:e.model}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.sessions}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.avgEfficiency===null?`—`:`${Math.min(100,Math.round(e.avgEfficiency*100))}%`}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums ${e.flagged?`text-accent-amber`:``}`,children:e.avgSuccessRate===null?`—`:`${Math.min(100,Math.round(e.avgSuccessRate*100))}%`}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:Si(e.avgCost)}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums text-ink-subtle`,children:Si(e.costPerMillionTokens)})]},e.model))})]}),p.some(e=>e.flagged)&&(0,I.jsx)(`div`,{className:`text-accent-amber text-[10px] mt-1`,children:`⚠ Highlighted models had sessions with elevated error rates`})]})}),(0,I.jsx)($U,{title:`Top Tools · Most Recent 200 Sessions`,children:m.length===0?(0,I.jsx)(U,{icon:`code`,title:`No tool data yet`,subtitle:`Tool usage data will appear after coding sessions.`}):(0,I.jsx)(`div`,{className:`min-w-0`,style:{height:`${Math.max(176,m.length*28+40)}px`},children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:m,layout:`vertical`,children:[(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{type:`number`,tick:LU,stroke:RU}),(0,I.jsx)(fB,{type:`category`,dataKey:`tool`,tick:LU,tickFormatter:wi,stroke:RU,width:120}),(0,I.jsx)(ZA,{contentStyle:zU,labelFormatter:e=>wi(String(e))}),(0,I.jsx)(Az,{dataKey:`count`,radius:[0,3,3,0],children:m.map(e=>(0,I.jsx)(QA,{fill:KU(wi(e.tool)),fillOpacity:.8},e.tool))})]})})})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mt-3`,children:[i.data&&i.data.days.length>0&&(0,I.jsx)($U,{title:`Activity · Last 12 Weeks`,children:(0,I.jsx)(NH,{variant:`grid`,buckets:[],maxCount:i.data.maxCount,days:i.data.days,ariaLabel:`Daily activity heatmap for the last 12 weeks`})}),(0,I.jsxs)(B,{padding:`md`,className:`flex flex-col`,children:[(0,I.jsxs)(V,{className:`mb-3`,children:[`Peak Concurrent Sessions · Last 30 Days`,g&&`: ${Math.max(...h.map(e=>e.peak))}`]}),g?(0,I.jsx)(`div`,{className:`flex-1 flex items-end justify-center`,children:(0,I.jsx)(cW,{data:h})}):(0,I.jsx)(U,{icon:`code`,title:`No concurrent sessions yet`,subtitle:`Run two or more Claude Code sessions at the same time to populate this chart.`})]})]}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(ZU,{data:o.data})}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(eW,{data:r.data})})]})}function $U({title:e,tooltip:t,children:n}){return(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(V,{children:e}),t&&(0,I.jsx)(ci,{text:t})]}),(0,I.jsx)(`div`,{className:`mt-3`,children:n})]})}function eW({data:e}){return e?e.status===`insufficient_data`?(0,I.jsx)($U,{title:`Personal Coach`,children:(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:e.message})}):(0,I.jsx)($U,{title:`Personal coach`,children:(0,I.jsxs)(`div`,{className:`text-xs space-y-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-accent-cyan font-semibold`,children:`Top recommendation: `}),e.topRecommendation]}),e.highlights.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-accent-green`,children:e.highlights.map(e=>(0,I.jsx)(`li`,{children:e},`hl-${e}`))}),e.regressions.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-accent-amber`,children:e.regressions.map(e=>(0,I.jsx)(`li`,{children:e},`rg-${e}`))}),e.streaks.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-ink-muted`,children:e.streaks.map(e=>(0,I.jsx)(`li`,{children:e},`st-${e}`))})]})}):(0,I.jsx)($U,{title:`Personal Coach`,children:(0,I.jsx)(U,{variant:`loading`,title:`Loading coaching insights…`})})}function tW(e,t){let n=new Map;for(let t of e){if(t.estimatedCostUsd==null||t.startTime==null)continue;let e=new Date(t.startTime),r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;n.set(r,(n.get(r)??0)+t.estimatedCostUsd)}return Array.from(n.entries()).sort((e,t)=>e[0].localeCompare(t[0])).slice(-t).map(([e,t])=>({day:e,cost:Number(t.toFixed(2))}))}function nW(e){return e?Object.entries(e.outcomeDistribution).map(([e,t])=>({outcome:e.replace(/_/g,` `),totalCost:Number(t.totalCost.toFixed(2)),count:t.count})).filter(e=>e.totalCost>0).sort((e,t)=>t.totalCost-e.totalCost):[]}function rW(e,t,n=new Date){let r=new Map(e.map(e=>[e.day,e.cost])),i=[];for(let e=t-1;e>=0;e--){let t=new Date(n);t.setDate(t.getDate()-e);let a=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;i.push({day:a,cost:r.get(a)??0})}return i}function iW(e){let t=[];for(let n of e){let e=n.antiPatternCounts??{},r=Object.values(e).reduce((e,t)=>e+t,0);r>0&&t.push({week:n.week||`?`,count:r})}return t}var aW=.85;function oW(e){let t=new Map;for(let n of e){let e=n.model??`unknown`,r=t.get(e);r||(r={sessions:0,effSum:0,effCount:0,successSum:0,successCount:0,costSum:0,costCount:0,blendedCostSum:0,blendedTokensSum:0,lowSuccessSessions:0},t.set(e,r)),r.sessions++,n.efficiencyScore!=null&&(r.effSum+=n.efficiencyScore,r.effCount++),n.toolSuccessRate!=null&&(r.successSum+=n.toolSuccessRate,r.successCount++,n.toolSuccessRate<aW&&r.lowSuccessSessions++),n.estimatedCostUsd!=null&&(r.costSum+=n.estimatedCostUsd,r.costCount++,(n.tokensInput!=null||n.tokensOutput!=null)&&(r.blendedCostSum+=n.estimatedCostUsd,r.blendedTokensSum+=(n.tokensInput??0)+(n.tokensOutput??0)))}let n=[];for(let[e,r]of t)n.push({model:e,sessions:r.sessions,avgEfficiency:r.effCount>0?r.effSum/r.effCount:null,avgSuccessRate:r.successCount>0?r.successSum/r.successCount:null,avgCost:r.costCount>0?r.costSum/r.costCount:null,costPerMillionTokens:r.blendedTokensSum>0?r.blendedCostSum/r.blendedTokensSum*1e6:null,flagged:r.lowSuccessSessions>0});return n.sort((e,t)=>t.sessions-e.sessions)}function sW(e){let t=new Map;for(let n of e)if(n.toolBreakdown)for(let[e,r]of Object.entries(n.toolBreakdown))t.set(e,(t.get(e)??0)+r);return Array.from(t.entries()).map(([e,t])=>({tool:e,count:t})).sort((e,t)=>t.count-e.count).slice(0,8)}function cW({data:e}){return(0,I.jsx)(TH,{data:e.map(e=>({count:e.peak,tooltip:`${e.date.slice(5)}: ${e.peak}`})),ariaLabel:`Peak concurrent sessions over ${e.length} days`})}var lW=[{key:`all`,label:`All`},{key:`sensitive_file`,label:`Sensitive files`},{key:`destructive_command`,label:`Destructive`},{key:`external_network`,label:`External network`}],uW={critical:`danger`,high:`warning`,medium:`info`};function dW(e){let t=e.map(e=>JSON.stringify(e)).join(`
|
|
64
|
-
`),n=new Blob([t],{type:`application/x-ndjson`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`audit-${new Date().toISOString().slice(0,10)}.jsonl`,i.rel=`noopener`,document.body.appendChild(i);try{i.click()}finally{document.body.removeChild(i),URL.revokeObjectURL(r)}}function fW(){let[e,t]=(0,F.useState)(`all`),{data:n,isLoading:r,error:i}=L({queryKey:z.audit,queryFn:()=>mr()}),a=n??[],o=e===`all`?a:a.filter(t=>t.classification===e),s=o.slice(0,200);return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`audit`}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Audit`}),(0,I.jsx)(Xr,{variant:`secondary`,size:`md`,onClick:()=>dW(s),children:`Export JSONL`})]}),(0,I.jsx)(`div`,{className:`flex gap-2 mb-3 flex-wrap`,children:lW.map(({key:n,label:r})=>(0,I.jsx)(Xr,{variant:e===n?`primary`:`secondary`,size:`sm`,onClick:()=>t(n),children:r},n))}),r&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading audit log.`}),!r&&!i&&o.length>200&&(0,I.jsxs)(`div`,{className:`text-[11px] text-ink-muted mb-2`,children:[`Showing first `,200,` of `,o.length,` entries.`]}),!r&&!i&&(0,I.jsx)(B,{padding:`sm`,tone:`static`,className:`overflow-hidden`,children:(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted bg-surface-3`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left p-2`,children:`When`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Tool`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Target`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Classification`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Session`})]})}),(0,I.jsxs)(`tbody`,{children:[o.length===0&&(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:5,className:`p-3 text-ink-muted text-center`,children:`No matching entries.`})}),s.map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`p-2 tabular-nums`,children:new Date(e.ts).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}),(0,I.jsx)(`td`,{className:`p-2`,children:e.tool}),(0,I.jsx)(`td`,{className:`p-2 font-mono text-[11px]`,children:e.target}),(0,I.jsx)(`td`,{className:`p-2`,children:(0,I.jsx)(ei,{tone:e.severity?uW[e.severity]??`neutral`:`neutral`,size:`sm`,children:lW.find(t=>t.key===e.classification)?.label??e.classification})}),(0,I.jsx)(`td`,{className:`p-2 text-ink-subtle`,children:e.sessionId??`—`})]},`${e.ts}-${e.tool}-${e.target}`))]})]})})]})}var pW={info:`border-l-accent-blue bg-accent-blue/5`,warning:`border-l-accent-amber bg-accent-amber/5`,critical:`border-l-accent-red bg-accent-red/5`},mW={info:`info`,warning:`warning`,critical:`danger`},hW={resolved:`text-accent-green`,aborted:`text-accent-red`,pending:`text-accent-amber`},gW={merge_conflict:`bg-accent-red/20 text-accent-red`,rebase_conflict:`bg-accent-red/20 text-accent-red`,merge_abort:`bg-accent-amber/20 text-accent-amber`,rebase_abort:`bg-accent-amber/20 text-accent-amber`,force_push:`bg-accent-red/20 text-accent-red`,reset_hard:`bg-accent-amber/20 text-accent-amber`,commit:`bg-accent-green/20 text-accent-green`,push:`bg-accent-blue/20 text-accent-blue`,pull:`bg-accent-blue/20 text-accent-blue`};function _W(e){return e===null?`—`:e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function vW(e){return e.replace(/_/g,` `)}function yW({score:e}){if(e===null)return(0,I.jsx)(`div`,{className:`flex items-center justify-center w-20 h-20 rounded-full border-4 border-border-medium`,children:(0,I.jsx)(`span`,{className:`text-ink-muted text-xs`,children:`N/A`})});let t=Math.max(0,Math.min(100,e)),[n,r]=t>=80?[`text-accent-green`,`border-accent-green`]:t>=60?[`text-accent-amber`,`border-accent-amber`]:[`text-accent-red`,`border-accent-red`],i=2*Math.PI*34,a=i-t/100*i;return(0,I.jsxs)(`div`,{className:`relative w-20 h-20`,children:[(0,I.jsxs)(`svg`,{className:`w-20 h-20 -rotate-90`,viewBox:`0 0 80 80`,children:[(0,I.jsx)(`circle`,{cx:`40`,cy:`40`,r:`34`,fill:`none`,stroke:`rgba(255,255,255,0.08)`,strokeWidth:`6`}),(0,I.jsx)(`circle`,{cx:`40`,cy:`40`,r:`34`,fill:`none`,className:r,stroke:`currentColor`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:i,strokeDashoffset:a,style:{transition:`stroke-dashoffset 0.8s ease-out`}})]}),(0,I.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-lg font-bold ${n}`,children:e})]})}function bW(){let{data:e,isLoading:t,error:n}=L({queryKey:z.gitEfficiency,queryFn:Tr,refetchInterval:5e3}),{data:r}=L({queryKey:z.gitEfficiencyRepos,queryFn:Er,refetchInterval:3e4});return t?(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}):n?(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading git efficiency data.`}):!e||e.totalGitCommands===0?(0,I.jsxs)(I.Fragment,{children:[r&&r.repos.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-4`,children:[(0,I.jsx)(V,{as:`div`,className:`mr-1`,children:`Repos Today:`}),r.repos.map(e=>{let t=e.split(`/`).pop()||e;return(0,I.jsx)(ei,{tone:e===r.currentRepo?`success`:`neutral`,size:`sm`,bordered:!0,className:`font-mono`,children:t},e)})]}),(0,I.jsx)(U,{icon:`code`,title:`No Git activity yet`,subtitle:`Git efficiency metrics will appear here as git commands are executed during the session.`})]}):(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`git`}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Git Efficiency`}),e.repoContext.repoName&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[11px] text-ink-muted`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.repoContext.repoName}),e.repoContext.branch&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`/`}),(0,I.jsx)(`span`,{className:`font-mono text-ink-subtle`,children:e.repoContext.branch})]})]}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-ink-muted`,children:`Today's activity across all sessions`}),r&&r.repos.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted uppercase tracking-wider mr-1`,children:`Repos today:`}),r.repos.map(e=>{let t=e.split(`/`).pop()||e;return(0,I.jsx)(ei,{tone:e===r.currentRepo?`success`:`neutral`,size:`sm`,bordered:!0,className:`font-mono`,children:t},e)})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(V,{as:`div`,className:`mb-1`,children:`Prevention`}),(0,I.jsx)(yW,{score:e.preventionScore})]}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(V,{as:`div`,className:`mb-1`,children:`Efficiency`}),(0,I.jsx)(yW,{score:e.efficiencyScore})]})]})]}),(0,I.jsx)(Yi,{index:0,className:`mb-3`,children:(0,I.jsx)(B,{padding:`lg`,tone:`elevated`,glow:`green`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4`,children:[(0,I.jsx)(Ji,{label:`commits today`,hero:!0,value:String(e.commitCount),animate:!0,numericValue:e.commitCount}),(0,I.jsx)(Ji,{label:`PRs opened`,tone:e.prMetrics.created>0?`good`:`neutral`,value:String(e.prMetrics.created),sub:e.prMetrics.merged>0?`${e.prMetrics.merged} merged`:void 0,animate:!0,numericValue:e.prMetrics.created}),(0,I.jsx)(Ji,{label:`conflicts`,tone:e.mergeConflicts+e.rebaseConflicts>0?`bad`:`good`,value:String(e.mergeConflicts+e.rebaseConflicts),sub:e.mergeConflicts+e.rebaseConflicts===0?`clean session`:`${e.abortedOperations} aborted`,animate:!0,numericValue:e.mergeConflicts+e.rebaseConflicts}),(0,I.jsx)(Ji,{label:`behind main`,tone:(e.riskIndicators.commitsBehindMain??0)>20?`bad`:(e.riskIndicators.commitsBehindMain??0)>5?`warn`:`good`,value:e.riskIndicators.commitsBehindMain===null?`—`:String(e.riskIndicators.commitsBehindMain),sub:e.riskIndicators.commitsBehindMain===0?`up to date`:e.riskIndicators.commitsBehindMain!==null&&e.riskIndicators.commitsBehindMain>10?`rebase soon`:void 0,animate:!0,numericValue:e.riskIndicators.commitsBehindMain??0})]})})}),e.bestPractices.length>0&&(0,I.jsx)(Yi,{index:1,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Best Practices`,action:(0,I.jsx)(`span`,{className:`text-[11px] text-ink-muted`,children:(()=>{let t=e.bestPractices.filter(e=>e.status!==`unknown`).length;return t===0?`No data yet`:`${e.bestPractices.filter(e=>e.status===`pass`).length}/${t} passing`})()})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[e.bestPractices.filter(e=>e.status===`pass`).map(e=>(0,I.jsxs)(ei,{tone:`success`,size:`sm`,bordered:!0,children:[(0,I.jsx)(`span`,{children:`✓`}),` `,e.label]},e.id)),e.bestPractices.filter(e=>e.status===`unknown`).map(e=>(0,I.jsxs)(ei,{tone:`neutral`,size:`sm`,bordered:!0,children:[(0,I.jsx)(`span`,{children:`●`}),` `,e.label]},e.id))]}),e.bestPractices.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>(0,I.jsxs)(`div`,{className:`flex items-start gap-2 px-2.5 py-2 rounded-lg mt-1.5 ${e.status===`fail`?`bg-accent-red/5 border border-accent-red/20`:`bg-accent-amber/5 border border-accent-amber/20`}`,children:[(0,I.jsx)(`span`,{className:`shrink-0 mt-0.5 text-xs`,children:e.status===`fail`?(0,I.jsx)(`span`,{className:`text-accent-red`,children:`✗`}):(0,I.jsx)(`span`,{className:`text-accent-amber`,children:`⚠`})}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-ink-base`,children:e.label}),(0,I.jsx)(`div`,{className:`text-[11px] text-ink-muted mt-0.5 leading-relaxed`,children:e.detail})]})]},e.id))]})}),(e.mergeConflicts>0||e.rebaseConflicts>0)&&(0,I.jsx)(Yi,{index:2,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Conflict Resolution`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Resolution rate`,value:e.conflictResolutionRate===null?`—`:`${Math.round(e.conflictResolutionRate*100)}%`}),(0,I.jsx)(Ji,{label:`Avg resolution time`,value:_W(e.avgConflictResolutionMs)}),(0,I.jsx)(Ji,{label:`Aborted ops`,value:String(e.abortedOperations)}),(0,I.jsx)(Ji,{label:`Stale branch pulls`,value:String(e.staleBranchPulls)})]}),e.conflictHistory.length>0&&(0,I.jsxs)(`div`,{className:`mt-3`,children:[(0,I.jsx)(V,{as:`h3`,className:`mb-2`,children:`Conflict History`}),(0,I.jsx)(`div`,{className:`space-y-1`,children:e.conflictHistory.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs py-1 border-t border-border-subtle`,children:[(0,I.jsx)(`span`,{className:`tabular-nums text-ink-subtle w-28 shrink-0`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})}),(0,I.jsx)(`span`,{className:`font-medium ${hW[e.resolution]}`,children:e.resolution}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:_W(e.resolutionTimeMs)}),(0,I.jsx)(`span`,{className:`text-ink-subtle font-mono text-[11px] truncate`,children:e.command})]},`${e.timestamp}-${e.command}`))})]})]})}),e.suggestions.length>0&&(0,I.jsx)(Yi,{index:3,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Suggestions`}),(0,I.jsx)(`div`,{className:`space-y-2`,children:e.suggestions.map((e,t)=>(0,I.jsx)(`div`,{className:`border-l-[3px] rounded-r-lg px-3 py-2 ${pW[e.severity]}`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(ei,{tone:mW[e.severity],size:`sm`,className:`font-semibold`,children:e.severity}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-xs text-ink-base`,children:e.message}),(0,I.jsx)(`p`,{className:`text-[11px] text-ink-muted mt-0.5`,children:e.evidence})]})]})},`${e.category}-${e.severity}-${t}`))})]})}),e.commitCount>=2&&(0,I.jsx)(Yi,{index:4,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Velocity & Workflow`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Avg time between commits`,value:_W(e.velocityMetrics.avgTimeBetweenCommitsMs)}),(0,I.jsx)(Ji,{label:`Longest gap`,value:_W(e.velocityMetrics.longestGapMs)}),(0,I.jsx)(Ji,{label:`Commit bursts`,value:String(e.velocityMetrics.commitBurstCount)}),(0,I.jsx)(Ji,{label:`Worktree ops`,value:String(e.velocityMetrics.worktreeCount)})]}),e.velocityMetrics.buildBeforePush!==null&&(0,I.jsxs)(`div`,{className:`mt-3 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Verified before push: `}),e.velocityMetrics.buildBeforePush?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`yes (build/test ran first)`}):(0,I.jsx)(`span`,{className:`text-accent-amber`,children:`no build/test detected before push`})]})]})}),(e.prMetrics.created>0||e.prMetrics.merged>0||e.prMetrics.checksViewed>0)&&(0,I.jsx)(Yi,{index:5,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Pull Requests`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`PRs created`,value:String(e.prMetrics.created),tone:e.prMetrics.created>0?`good`:`neutral`}),(0,I.jsx)(Ji,{label:`PRs merged`,value:String(e.prMetrics.merged),tone:e.prMetrics.merged>0?`good`:`neutral`}),(0,I.jsx)(Ji,{label:`CI checks viewed`,value:String(e.prMetrics.checksViewed)}),(0,I.jsx)(Ji,{label:`Time to PR`,value:_W(e.prMetrics.avgTimeToCreateMs)})]}),e.prMetrics.prActivity.length>0&&(0,I.jsxs)(`div`,{className:`mt-3`,children:[(0,I.jsx)(V,{as:`h3`,className:`mb-2`,children:`Activity`}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.prMetrics.prActivity.map(e=>(0,I.jsxs)(ei,{tone:e.action===`create`?`success`:e.action===`merge`?`info`:`neutral`,size:`sm`,children:[e.action,e.prNumber?` #${e.prNumber}`:``]},`${e.timestamp}-${e.action}`))})]})]})}),e.conflictResolutionStrategy.totalResolutions>0&&(0,I.jsx)(Yi,{index:6,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Conflict Resolution Strategy`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Accept ours`,value:String(e.conflictResolutionStrategy.oursCount)}),(0,I.jsx)(Ji,{label:`Accept theirs`,value:String(e.conflictResolutionStrategy.theirsCount)}),(0,I.jsx)(Ji,{label:`Manual merge`,value:String(e.conflictResolutionStrategy.manualMergeCount)}),(0,I.jsx)(Ji,{label:`Cherry-picks`,value:String(e.conflictResolutionStrategy.cherryPickCount)})]})]})}),(e.resetHards>0||e.discardedChanges>0||e.forcePushes>0)&&(0,I.jsx)(Yi,{index:7,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Destructive Operations`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,I.jsx)(Ji,{label:`Hard resets`,value:String(e.resetHards)}),(0,I.jsx)(Ji,{label:`Discarded changes`,value:String(e.discardedChanges)}),(0,I.jsx)(Ji,{label:`Force pushes`,value:String(e.forcePushes)})]})]})}),(0,I.jsx)(Yi,{index:8,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Recent Git Activity`}),(0,I.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted bg-surface-3 sticky top-0`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Time`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Type`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Duration`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Status`})]})}),(0,I.jsx)(`tbody`,{children:[...e.gitCommandTimeline].reverse().slice(0,30).map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`p-2 tabular-nums text-ink-subtle`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})}),(0,I.jsx)(`td`,{className:`p-2`,children:(0,I.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${gW[e.type]??`bg-surface-8 text-ink-subtle`}`,children:vW(e.type)})}),(0,I.jsx)(`td`,{className:`p-2 tabular-nums text-ink-subtle`,children:_W(e.durationMs)}),(0,I.jsx)(`td`,{className:`p-2`,children:e.success?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`ok`}):(0,I.jsx)(`span`,{className:`text-accent-red`,children:`fail`})})]},`${e.type}-${e.timestamp}`))})]})})]})})]})}function xW({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:e}),(0,I.jsx)(`span`,{className:`text-xs font-mono text-ink-subtle bg-surface-3 px-2 py-0.5 rounded-md`,children:t??`—`})]})}function SW({label:e,value:t,onChange:n,placeholder:r,min:i}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:e}),(0,I.jsx)(`input`,{type:`number`,min:i,step:`any`,value:t??``,placeholder:r??`unlimited`,onChange:e=>{let t=e.target.value;n(t===``?null:Number(t))},className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-32 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]})}var CW={ok:`●`,warn:`▲`,fail:`✗`,skip:`–`},wW={ok:`text-accent-green`,warn:`text-accent-amber`,fail:`text-accent-red`,skip:`text-ink-muted`};function TW(){let{data:e,isLoading:t,isError:n,refetch:r}=L({queryKey:z.diagnostics,queryFn:()=>Ir(),refetchInterval:6e4,staleTime:55e3}),i=e??[],a=i.some(e=>e.status===`fail`||e.status===`warn`);return(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,I.jsx)(oi,{title:`System Health`}),(0,I.jsx)(`button`,{onClick:()=>void r(),className:`text-[10px] text-ink-muted hover:text-ink-base transition-colors`,children:`Re-check`})]}),t&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Checking system…`}),n&&(0,I.jsx)(`div`,{className:`text-xs text-accent-red`,children:`Failed to load diagnostics.`}),!t&&!n&&!a&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-accent-green`,children:[(0,I.jsx)(`span`,{children:`●`}),(0,I.jsx)(`span`,{children:`System healthy`})]}),!t&&!n&&a&&(0,I.jsx)(`div`,{className:`space-y-1.5`,children:i.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`shrink-0 ${wW[e.status]??`text-ink-muted`}`,children:CW[e.status]??`?`}),(0,I.jsx)(`span`,{className:`text-ink-muted w-36 shrink-0`,children:e.check}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.detail})]}),e.fix&&(e.status===`fail`||e.status===`warn`)&&(0,I.jsxs)(`div`,{className:`ml-[1.25rem] mt-0.5 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] font-mono text-ink-subtle bg-surface-3 px-1.5 py-0.5 rounded`,children:e.fix}),(0,I.jsx)(`button`,{className:`text-[10px] text-ink-muted hover:text-ink-base transition-colors`,onClick:()=>void navigator.clipboard.writeText(e.fix??``),children:`copy`})]})]},e.check))})]})}function EW(){let e=Ye(),{data:t,isLoading:n,error:r}=L({queryKey:z.settings,queryFn:()=>Fr()}),{data:i}=L({queryKey:[`observability-health`],queryFn:zr,refetchInterval:3e4}),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(void 0),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(void 0),[p,m]=(0,F.useState)(void 0),[h,g]=(0,F.useState)(void 0),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(null),x=ut({mutationFn:e=>Lr(e),onSuccess:()=>{e.invalidateQueries({queryKey:z.settings}),b(null)},onError:e=>{b(String(e))}});if(n)return(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`});if(r||!t)return(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Failed to load settings.`});let S=a??t.developer,C=s===void 0?t.teamId:s,w=l===void 0?t.sessionBudgetUsd:l,T=d===void 0?t.dailyBudgetUsd:d,E=p===void 0?t.weeklyBudgetUsd:p,D=h===void 0?t.retainSessionsDays:h;function O(){let e={};a!==null&&(e.developer=a),s!==void 0&&(e.teamId=s),x.mutate(e,{onSuccess:()=>{v(`identity`),setTimeout(()=>v(null),3e3)}})}function k(){let e={};l!==void 0&&(e.sessionBudgetUsd=l),d!==void 0&&(e.dailyBudgetUsd=d),p!==void 0&&(e.weeklyBudgetUsd=p),h!==void 0&&(e.retainSessionsDays=h),x.mutate(e,{onSuccess:()=>{v(`budgets`),setTimeout(()=>v(null),3e3)}})}let A=e=>_===e?(0,I.jsx)(`div`,{className:`mt-2 text-xs text-accent-amber`,children:`Saved. Restart the server for changes to take effect.`}):null;return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(TW,{}),(0,I.jsxs)(`header`,{className:`mb-6`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Settings`}),(0,I.jsx)(`p`,{className:`text-xs text-ink-muted mt-1`,children:`Changes are written to config.json on disk. Most require a server restart.`})]}),y&&(0,I.jsx)(`div`,{className:`mb-4 text-xs text-accent-red bg-accent-red/10 border border-accent-red/30 rounded-md px-3 py-2`,children:y}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Identity & Account`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:`Developer name`}),(0,I.jsx)(`input`,{type:`text`,value:S,maxLength:128,onChange:e=>o(e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-48 focus:outline-none focus:border-accent-green text-ink-base`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:`Team ID`}),(0,I.jsx)(`input`,{type:`text`,value:C??``,placeholder:`optional`,onChange:e=>c(e.target.value===``?null:e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-48 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]}),(0,I.jsx)(xW,{label:`Account ID`,value:t.accountId}),(0,I.jsx)(xW,{label:`App name`,value:t.appName}),(0,I.jsx)(xW,{label:`Mode`,value:t.mode}),(0,I.jsx)(xW,{label:`Storage path`,value:t.storagePath}),(0,I.jsx)(xW,{label:`High security`,value:t.highSecurity?`enabled`:`disabled`}),(0,I.jsx)(xW,{label:`License key`,value:t.licenseKey}),(0,I.jsx)(`div`,{className:`mt-3 flex items-center gap-3`,children:(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:O,disabled:x.isPending,loading:x.isPending,children:x.isPending?`Saving…`:`Save identity`})}),A(`identity`)]}),(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Cost & Retention`,subtitle:`Budget caps trigger warnings at 50%, 80%, and 100%. Leave blank for no limit.`}),(0,I.jsx)(SW,{label:`Session budget (USD)`,value:w,onChange:u,min:.01}),(0,I.jsx)(SW,{label:`Daily budget (USD)`,value:T,onChange:f,min:.01}),(0,I.jsx)(SW,{label:`Weekly budget (USD)`,value:E,onChange:m,min:.01}),(0,I.jsx)(SW,{label:`Retain sessions (days)`,value:D,onChange:g,placeholder:`forever`,min:1}),(0,I.jsx)(`div`,{className:`mt-3 flex items-center gap-3`,children:(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:k,disabled:x.isPending,loading:x.isPending,children:x.isPending?`Saving…`:`Save budgets`})}),A(`budgets`)]}),(0,I.jsxs)(`section`,{className:`mt-8`,children:[(0,I.jsx)(V,{children:`Observability`}),(0,I.jsxs)(B,{padding:`md`,className:`mt-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-ink mb-3`,children:`Subagent & Workflow Watcher`}),(0,I.jsx)(`p`,{className:`text-xs text-ink-muted mb-4`,children:`Monitors subagent JSONL transcripts and workflow records to provide accurate cost tracking. Default: enabled in --stdio mode.`}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 text-xs text-ink-muted`,children:[(0,I.jsxs)(`div`,{children:[`Subagent watcher:`,` `,i?.watcherActive===!0?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`enabled`}):i?.watcherActive===!1?(0,I.jsx)(`span`,{className:`text-accent-red`,children:`disabled`}):(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`checking…`}),i?.watcherActive===!0&&(0,I.jsxs)(`span`,{className:`text-ink-muted`,children:[` `,`(`,i.filesWatched??0,` files watched, `,i.parseErrors??0,` parse errors)`]})]}),(0,I.jsxs)(`div`,{children:[`Set`,` `,(0,I.jsx)(`code`,{className:`font-mono bg-surface-5 px-1 rounded`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=0`}),` `,`to disable, or`,` `,(0,I.jsx)(`code`,{className:`font-mono bg-surface-5 px-1 rounded`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=1`}),` `,`to explicitly enable.`]})]})]})]})]})}function DW({pct:e,exceeded:t}){let n=e??0;return(0,I.jsx)(`div`,{className:`w-24 h-1.5 bg-surface-5 rounded-full overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${t?`bg-accent-red`:n>=80?`bg-accent-amber`:`bg-accent-green`}`,style:{width:`${Math.min(n,100)}%`}})})}function OW({label:e,p:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-ink-muted w-20 shrink-0 capitalize`,children:e}),(0,I.jsx)(DW,{pct:t.pctUsed,exceeded:t.exceeded}),(0,I.jsxs)(`span`,{className:`text-xs tabular-nums text-ink-base`,children:[xi(t.spentUsd),t.budgetUsd===null?``:` / ${xi(t.budgetUsd)}`,t.pctUsed===null?``:` (${t.pctUsed.toFixed(0)}%)`]}),t.exceeded&&(0,I.jsx)(ei,{tone:`danger`,size:`sm`,children:`exceeded`})]})}function kW(){let e=Ye(),t=L({queryKey:z.budget,queryFn:()=>gr(),refetchInterval:1e4}),n=L({queryKey:z.settings,queryFn:()=>Fr()}),r=t.data,i=n.data,[a,o]=(0,F.useState)({}),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(null),h=ut({mutationFn:e=>Lr(e),onSuccess:()=>void e.invalidateQueries({queryKey:z.settings})}),g=ut({mutationFn:()=>Rr(),onSuccess:e=>{let t=e.content[0]?.text??``;try{let e=JSON.parse(t);m(e.ok?`Digest sent.`:e.error??`Failed to send.`)}catch{m(`Done.`)}setTimeout(()=>m(null),4e3)},onError:e=>{m(`Error: ${String(e)}`)}});function _(){Object.keys(a).length!==0&&h.mutate({alerts:{personal:a}},{onSuccess:()=>{c(!0),setTimeout(()=>c(!1),3e3)}})}function v(){let e={};l!==void 0&&(e.digestWebhookUrl=l),d!==null&&(e.digestSchedule=d??i?.digestSchedule),h.mutate(e)}function y(e){return a[e]??i?.alerts.personal[e]??0}function b(e,t,n={}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-44 shrink-0`,children:e}),(0,I.jsx)(`input`,{type:`number`,value:y(t),min:n.min,max:n.max,step:n.step??`any`,onChange:e=>o(n=>({...n,[t]:Number(e.target.value)})),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-24 focus:outline-none focus:border-accent-green text-ink-base`})]})}return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`header`,{className:`mb-6`,children:(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Alerts`})}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Budget Status`}),t.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),t.isError&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading budget status.`}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(OW,{label:`session`,p:r.session}),(0,I.jsx)(OW,{label:`daily`,p:r.daily}),(0,I.jsx)(OW,{label:`weekly`,p:r.weekly}),r.alerts.length>0&&(0,I.jsxs)(`div`,{className:`mt-3 border-t border-border-subtle pt-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Recent Warnings`}),(0,I.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.alerts.slice(-5).reverse().map((e,t)=>(0,I.jsxs)(`div`,{className:`text-xs text-ink-subtle flex gap-2`,children:[(0,I.jsxs)(`span`,{className:`text-accent-amber tabular-nums`,children:[e.thresholdPct,`%`]}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.period}),(0,I.jsxs)(`span`,{className:`text-ink-muted tabular-nums`,children:[xi(e.spentUsd),` / `,xi(e.budgetUsd)]}),(0,I.jsx)(`span`,{className:`text-ink-muted ml-auto tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})})]},t))})]}),r.alerts.length===0&&r.session.budgetUsd===null&&r.daily.budgetUsd===null&&r.weekly.budgetUsd===null&&(0,I.jsxs)(`p`,{className:`text-xs text-ink-muted mt-2`,children:[`No budget caps configured.`,` `,(0,I.jsx)(en,{href:`/settings`,className:`text-accent-cyan hover:underline transition-colors duration-150`,children:`Set limits in Settings`}),` `,`to enable warnings.`]})]})]}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Alert Thresholds`,subtitle:"Thresholds used by the `deploy-alerts` CLI (`npm run deploy:alerts`) when templating cloud alert conditions. Have no effect on this dashboard or any running session."}),n.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsxs)(I.Fragment,{children:[b(`Daily cost ($)`,`dailyCostUsd`,{min:0,step:.1}),b(`Session cost ($)`,`sessionCostUsd`,{min:0,step:.1}),b(`Min efficiency score (0–1)`,`efficiencyScoreMin`,{min:0,max:1,step:.05}),b(`Max anti-patterns`,`antiPatternCountMax`,{min:0,step:1}),b(`Max stuck loops`,`stuckLoopCountMax`,{min:0,step:1}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:_,disabled:h.isPending||Object.keys(a).length===0,loading:h.isPending,children:h.isPending?`Saving…`:`Save thresholds`}),s&&(0,I.jsx)(`span`,{className:`text-xs text-accent-amber`,children:"Saved. Run `npm run deploy:alerts` to apply these to your cloud alert conditions."})]})]})]}),(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Slack Digest`,subtitle:`Weekly digest sent to a Slack incoming webhook. URL changes take effect immediately.`}),n.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`flex items-center gap-2 mb-3`,children:(0,I.jsx)(ei,{tone:i.digestWebhookUrl?`success`:`neutral`,size:`sm`,children:i.digestWebhookUrl?`Configured`:`Not configured`})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-28 shrink-0`,children:`Webhook URL`}),(0,I.jsx)(`input`,{type:`url`,value:l===void 0?i.digestWebhookUrl??``:l??``,placeholder:`https://hooks.slack.com/...`,onChange:e=>u(e.target.value===``?null:e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-72 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsxs)(`label`,{className:`text-xs text-ink-muted w-28 shrink-0`,children:[`Schedule`,(0,I.jsx)(`span`,{className:`block text-[10px] text-ink-muted font-normal`,children:`(cron, restart req.)`})]}),(0,I.jsx)(`input`,{type:`text`,value:d??i.digestSchedule,onChange:e=>f(e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-36 focus:outline-none focus:border-accent-green text-ink-base font-mono`}),(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,children:`default: Mon 9am`})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 flex-wrap`,children:[(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:v,disabled:h.isPending,loading:h.isPending,children:h.isPending?`Saving…`:`Save`}),i.digestWebhookUrl&&(0,I.jsx)(Xr,{variant:`danger`,size:`md`,onClick:()=>h.mutate({digestWebhookUrl:null},{onSuccess:()=>u(void 0)}),disabled:h.isPending,children:`Unsubscribe`}),(0,I.jsx)(Xr,{variant:`secondary`,size:`md`,onClick:()=>g.mutate(),disabled:g.isPending||!i.digestWebhookUrl,loading:g.isPending,children:g.isPending?`Sending…`:`Send test now`}),p&&(0,I.jsx)(`span`,{className:`text-xs text-ink-subtle`,children:p})]})]})]})]})}function AW(){zi();let e=Yn(e=>e.connected),[t,n]=qt(),[r,i]=(0,F.useState)(!1),{theme:a,toggleTheme:o}=Wi(),s=(0,F.useCallback)(()=>i(e=>!e),[]),c=(0,F.useCallback)(()=>i(!1),[]);return Bi({navigate:n,onToggleHelp:s,onToggleTheme:o}),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-col h-full mesh-bg`,children:[(0,I.jsx)(Mi,{}),(0,I.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,I.jsx)(pi,{currentPath:t,onNavigate:n,connected:e,theme:a,onToggleTheme:o}),(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-6`,children:(0,I.jsx)(Ni,{resetKey:t,children:(0,I.jsxs)(nn,{children:[(0,I.jsx)($t,{path:`/sessions`,component:OU}),(0,I.jsx)($t,{path:`/history`,component:QU}),(0,I.jsx)($t,{path:`/audit`,component:fW}),(0,I.jsx)($t,{path:`/git`,component:bW}),(0,I.jsx)($t,{path:`/settings`,component:EW}),(0,I.jsx)($t,{path:`/alerts`,component:kW}),(0,I.jsx)($t,{path:`/`,component:YH}),(0,I.jsx)($t,{children:(0,I.jsx)(`div`,{className:`text-ink-muted`,children:`Not found`})})]})})})]})]}),(0,I.jsx)(Fi,{open:r,onClose:c})]})}var jW=new Ge({defaultOptions:{queries:{staleTime:5e3,retry:0,refetchOnWindowFocus:!1}}}),MW=document.getElementById(`root`);if(!MW)throw Error(`Mount node #root not found`);(0,dt.createRoot)(MW).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(Xe,{client:jW,children:(0,I.jsx)(AW,{})})}));
|
|
63
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MV(e,t){if(e){if(typeof e==`string`)return NV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?NV(e,t):void 0}}function NV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function FV(e){if(Array.isArray(e))return e}var IV=()=>(PA(),null);function LV(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var RV=(0,F.forwardRef)((e,t)=>{var n=(0,F.useRef)(null),r=AV((0,F.useState)({containerWidth:LV(e.style?.width),containerHeight:LV(e.style?.height)}),2),i=r[0],a=r[1],o=(0,F.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,F.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,F.useEffect)(()=>()=>{n.current?.disconnect()},[o]),F.createElement(F.Fragment,null,F.createElement(mm,{width:i.containerWidth,height:i.containerHeight}),F.createElement(`div`,kV({ref:s},e)))}),zV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=AV((0,F.useState)({containerWidth:LV(n),containerHeight:LV(r)}),2),a=i[0],o=i[1],s=(0,F.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,F.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return F.createElement(F.Fragment,null,F.createElement(mm,{width:a.containerWidth,height:a.containerHeight}),F.createElement(`div`,kV({ref:c},e)))}),BV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height;return F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(`div`,kV({ref:t},e)))}),VV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?F.createElement(zV,kV({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?F.createElement(BV,kV({},e,{width:n,height:r,ref:t})):F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(`div`,kV({ref:t},e)))});function HV(e){return e?RV:VV}var UV=(0,F.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,b=y===void 0||y,x=(0,F.useRef)(null),S=Wc(),C=AV((0,F.useState)(null),2),w=C[0],T=C[1],E=AV((0,F.useState)(null),2),D=E[0],O=E[1],k=CV(),A=tm(),j=A?.width>0?A.width:_,ee=A?.height>0?A.height:i,M=(0,F.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),te=(0,F.useCallback)(e=>{S(gB(e)),S(RB({handler:a,reactEvent:e}))},[S,a]),ne=(0,F.useCallback)(e=>{S(vB(e)),S(RB({handler:l,reactEvent:e}))},[S,l]),N=(0,F.useCallback)(e=>{S(UD()),S(RB({handler:u,reactEvent:e}))},[S,u]),P=(0,F.useCallback)(e=>{S(vB(e)),S(RB({handler:d,reactEvent:e}))},[S,d]),re=(0,F.useCallback)(()=>{S(jB())},[S]),ie=(0,F.useCallback)(()=>{S(MB())},[S]),ae=(0,F.useCallback)(e=>{S(AB(e.key))},[S]),oe=(0,F.useCallback)(e=>{S(RB({handler:o,reactEvent:e}))},[S,o]),se=(0,F.useCallback)(e=>{S(RB({handler:s,reactEvent:e}))},[S,s]),ce=(0,F.useCallback)(e=>{S(RB({handler:c,reactEvent:e}))},[S,c]),le=(0,F.useCallback)(e=>{S(RB({handler:f,reactEvent:e}))},[S,f]),ue=(0,F.useCallback)(e=>{S(RB({handler:h,reactEvent:e}))},[S,h]),de=(0,F.useCallback)(e=>{b&&S(WB(e)),S(RB({handler:m,reactEvent:e}))},[S,b,m]),fe=(0,F.useCallback)(e=>{S(RB({handler:p,reactEvent:e}))},[S,p]),pe=HV(v);return F.createElement(cA.Provider,{value:w},F.createElement(Yo.Provider,{value:D},F.createElement(pe,{width:j??g?.width,height:ee??g?.height,className:Ya(`recharts-wrapper`,r),style:TV({position:`relative`,cursor:`default`,width:j,height:ee},g),onClick:te,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:ne,onMouseLeave:N,onMouseMove:P,onMouseUp:le,onTouchEnd:fe,onTouchMove:de,onTouchStart:ue,ref:M},F.createElement(IV,null),n)))}),WV=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function GV(e,t){if(e==null)return{};var n,r,i=KV(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 KV(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 qV=(0,F.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=to(GV(e,WV));return c?F.createElement(F.Fragment,null,F.createElement(mm,{width:n,height:r}),F.createElement(gV,{otherAttributes:d,title:l,desc:u},a)):F.createElement(UV,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},F.createElement(gV,{otherAttributes:d,title:l,desc:u,ref:t},F.createElement(PF,null,a)))});function JV(){return JV=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},JV.apply(null,arguments)}function YV(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 XV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YV(Object(n),!0).forEach(function(t){ZV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZV(e,t,n){return(t=QV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QV(e){var t=$V(e,`string`);return typeof t==`symbol`?t:t+``}function $V(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 eH=XV({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},XB),tH=(0,F.forwardRef)(function(e,t){var n=ac(e.categoricalChartProps,eH),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return F.createElement(nV,{preloadedState:{options:c},reduxStoreName:s.id??r},F.createElement(hF,{chartData:s.data}),F.createElement(iV,{layout:n.layout,margin:n.margin}),F.createElement(oV,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),F.createElement(aV,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),F.createElement(qV,JV({},n,{ref:t})))}),nH=[`axis`,`item`],rH=(0,F.forwardRef)((e,t)=>F.createElement(tH,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nH,tooltipPayloadSearcher:mA,categoricalChartProps:e,ref:t})),iH=[`axis`],aH=(0,F.forwardRef)((e,t)=>F.createElement(tH,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:iH,tooltipPayloadSearcher:mA,categoricalChartProps:e,ref:t})),oH=[`system`,`tools`,`user`,`assistant`],sH={system:`bg-accent-indigo`,tools:`bg-accent-amber`,user:`bg-accent-blue`,assistant:`bg-accent-green`},cH={system:`shadow-[0_0_8px_rgba(99,102,241,0.4)]`,tools:`shadow-[0_0_8px_rgba(255,178,36,0.4)]`,user:`shadow-[0_0_8px_rgba(0,149,255,0.4)]`,assistant:`shadow-[0_0_8px_rgba(28,231,131,0.4)]`},lH={system:`bg-accent-indigo`,tools:`bg-accent-amber`,user:`bg-accent-blue`,assistant:`bg-accent-green`},uH={system:`System`,tools:`Tools`,user:`User`,assistant:`Assistant`},dH={system:`#6366f1`,tools:`#ffb224`,user:`#0095ff`,assistant:`#1ce783`},fH={fontSize:10,fill:`#6b7280`},pH=`#2a2a3a`;function mH({history:e,contextWindow:t}){let n=(0,F.useId)();return e.length<2?null:(0,I.jsx)(`div`,{className:`mt-2 pt-2 border-t border-surface-3`,children:(0,I.jsx)(rm,{width:`100%`,height:120,children:(0,I.jsxs)(aH,{data:e.map(e=>({turn:e.turnNumber,system:t>0?e.breakdown.system/t*100:0,tools:t>0?e.breakdown.tools/t*100:0,user:t>0?e.breakdown.user/t*100:0,assistant:t>0?e.breakdown.assistant/t*100:0})),margin:{top:4,right:4,bottom:0,left:-20},children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`1`,x2:`0`,y2:`0`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#f59e0b`,stopOpacity:.15}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#ef4444`,stopOpacity:.25})]})}),(0,I.jsx)(_L,{strokeDasharray:`3 3`,stroke:pH}),(0,I.jsx)(Zz,{dataKey:`turn`,tick:fH,stroke:pH}),(0,I.jsx)(fB,{domain:[0,100],unit:`%`,tick:fH,stroke:pH}),(0,I.jsx)(ZA,{contentStyle:{backgroundColor:`#1a1a2e`,border:`1px solid #2a2a3a`,fontSize:11},formatter:(e,t)=>[`${e.toFixed(1)}%`,t],labelFormatter:e=>`Turn ${e}`}),(0,I.jsx)(JF,{y1:80,y2:100,fill:`url(#${n})`,ifOverflow:`visible`}),oH.map(e=>(0,I.jsx)(xR,{type:`monotone`,dataKey:e,stackId:`context`,stroke:dH[e],fill:dH[e],fillOpacity:.4,strokeWidth:1,dot:!1},e))]})})})}function hH(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function gH(e,t=``){return{sessionId:t,turnNumber:e.turnCount,totalTokens:e.growth.currentTokens,fillPercent:e.fillPercent,contextWindow:e.contextWindow,breakdown:e.currentBreakdown,growth:{startTokens:e.growth.startTokens,currentTokens:e.growth.currentTokens,delta:e.growth.deltaTokens},topTools:e.toolContributions.map(e=>({tool:e.tool,estimatedTokens:e.estimatedTokens}))}}function _H({data:e,sessionId:t,expandable:n=!0}){let r=Yn(e=>e.contextBySession),i=t?r.get(t)??null:null,[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=(0,F.useRef)(0),f=(0,F.useRef)(0);(0,F.useEffect)(()=>{u(!1)},[t]);let{data:p}=L({queryKey:t?[`context`,t]:z.context,queryFn:()=>Ar(t??void 0),refetchInterval:1e4,enabled:!e}),{data:m}=L({queryKey:[`context-composition`,t],queryFn:jr,enabled:l}),{data:h}=L({queryKey:[`context-efficiency`,t],queryFn:Mr,enabled:l}),g=e??p,_=t??``,v=e?gH(e,_):i??(g?gH(g,_):null),y=v?.growth.currentTokens??0,b=Math.min(v?.fillPercent??0,100),x=f.current>0&&b>d.current;if((0,F.useEffect)(()=>{if(f.current>0&&y<f.current*.7){c(!0);let e=setTimeout(()=>c(!1),1e3);return f.current=y,d.current=b,()=>clearTimeout(e)}f.current=y,d.current=b},[b,y]),!v||v.totalTokens===0)return null;let{breakdown:S,growth:C,fillPercent:w,totalTokens:T}=v,E=w>=100,D=v.contextWindow,O=l&&g?.history&&g.history.length>=2?g.history:null;return(0,I.jsxs)(`div`,{className:`group`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(V,{children:`Context`}),E&&(0,I.jsx)(ei,{tone:`danger`,size:`sm`,uppercase:!0,className:`animate-pulse motion-reduce:animate-none`,children:`at capacity`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-ink-subtle tabular-nums`,children:[hH(C.currentTokens),D&&D>0&&(0,I.jsx)(`span`,{className:`text-ink-muted`,children:` / ${hH(D)}`}),C.delta>0&&(0,I.jsxs)(`span`,{className:`text-accent-amber ml-1`,children:[`+`,hH(C.delta)]}),C.delta<0&&(0,I.jsx)(`span`,{className:`text-accent-cyan ml-1`,children:`compacted`}),n&&(g?.history?.length??0)>=2&&(0,I.jsx)(`button`,{onClick:()=>u(e=>!e),className:`ml-1 text-ink-muted hover:text-ink-base transition-colors`,"aria-label":`Toggle context timeline`,"aria-expanded":l,children:l?`▾`:`▸`})]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[s&&(0,I.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-accent-cyan/20 animate-compact-flash pointer-events-none`}),(0,I.jsx)(`div`,{className:`w-full h-3 bg-surface-3 rounded-full overflow-hidden flex transition-colors duration-150 ${x?`shadow-[0_0_12px_rgba(255,178,36,0.3)]`:``} ${s?`animate-compact`:``}`,children:oH.map(e=>{let t=S[e];if(t<=0)return null;let n=Math.round(t/T*100),r=a===e;return(0,I.jsx)(`div`,{className:`${sH[e]} transition-all duration-500 ease-out cursor-default relative ${r?`brightness-125 ${cH[e]}`:``}`,style:{width:`${t/T*b}%`},title:`${uH[e]}: ${hH(t)} (${n}%)`,onMouseEnter:()=>o(e),onMouseLeave:()=>o(null)},e)})})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-[10px] text-ink-muted`,children:[oH.map(e=>{let t=S[e],n=a===e;return(0,I.jsxs)(`span`,{className:`flex items-center gap-1 transition-colors duration-200 cursor-default ${n?`text-ink-base`:``}`,onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${lH[e]} ${n?`scale-150`:``} transition-transform duration-200`}),uH[e],n&&t>0&&(0,I.jsx)(`span`,{className:`text-ink-subtle ml-0.5`,children:hH(t)})]},e)}),(0,I.jsxs)(`span`,{className:`ml-auto tabular-nums ${E?`text-accent-red`:b>=75?`text-accent-amber`:``}`,children:[b.toFixed(0),`%`]})]}),n&&(0,I.jsxs)(`div`,{className:`overflow-hidden transition-all duration-300 ${l?`max-h-56`:`max-h-0`}`,children:[O&&(0,I.jsx)(mH,{history:O,contextWindow:D}),l&&h&&h.repeatedReadRatio!==null&&(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-ink-muted`,children:[(0,I.jsxs)(`span`,{children:[`Repeated reads: `,Math.round(h.repeatedReadRatio*100),`%`]}),h.topRepeatedFiles[0]&&(0,I.jsxs)(`span`,{className:`ml-2`,children:[`top:`,` `,(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:h.topRepeatedFiles[0].file}),` `,`(`,h.topRepeatedFiles[0].readCount,`x)`]})]}),l&&m&&(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-ink-muted`,children:[`Dominant this turn:`,` `,Object.entries(m.currentBreakdown).sort((e,t)=>t[1]-e[1])[0]?.[0]]})]})]})}var vH={success:`success`,failure:`danger`,unknown:`neutral`};function yH({decisionTree:e,turnCosts:t,contextHistory:n,contextWindow:r,contextComposition:i,contextEfficiency:a,onClose:o}){let s=(0,F.useRef)(null),c=(0,F.useRef)(null);(0,F.useEffect)(()=>{function e(e){if(e.key===`Escape`){o();return}if(e.key===`Tab`&&s.current){let t=s.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`),n=t[0],r=t[t.length-1];!e.shiftKey&&document.activeElement===r?(e.preventDefault(),n?.focus()):e.shiftKey&&document.activeElement===n&&(e.preventDefault(),r?.focus())}}return document.addEventListener(`keydown`,e),c.current?.focus(),()=>document.removeEventListener(`keydown`,e)},[o]);let l=e!=null&&e.totalBranches>0,u=t?.turns!=null&&t.turns.length>0,d=(n?.length??0)>=2;return(0,si.createPortal)((0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 backdrop-blur-sm`,"aria-hidden":`true`,onClick:o}),(0,I.jsxs)(`div`,{ref:s,role:`dialog`,"aria-modal":`true`,"aria-label":`Session decision-tree and turn-cost detail`,className:`fixed right-0 top-0 bottom-0 z-50 w-[640px] max-w-full flex flex-col bg-bg-panel border-l border-border-medium shadow-2xl overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border-subtle shrink-0`,children:[(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold text-ink-base`,children:`Session Detail`}),(0,I.jsx)(`p`,{className:`mt-1 text-[10px] text-ink-muted`,children:`Live, current-process-only — reflects this dashboard process’s own current session.`})]}),(0,I.jsx)(`button`,{ref:c,type:`button`,"aria-label":`Close session detail`,onClick:o,className:`shrink-0 p-1.5 rounded-md text-ink-muted hover:text-ink-base hover:bg-surface-5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:(0,I.jsx)(Nn,{className:`w-4 h-4`,"aria-hidden":`true`})})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-5`,children:[(0,I.jsxs)(`section`,{"aria-label":`Decision tree`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Decision Tree`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,I.jsx)(bH,{label:`Longest failure streak`,value:String(e.longestFailureStreak)}),(0,I.jsx)(bH,{label:`Success rate`,value:e.successRate===null?`—`:`${Math.round(e.successRate*100)}%`}),(0,I.jsx)(bH,{label:`Total branches`,value:String(e.totalBranches)})]}),e.failurePoints.length>0&&(0,I.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border-subtle space-y-2`,children:e.failurePoints.map((e,t)=>(0,I.jsx)(`div`,{className:`flex items-start justify-between gap-2 text-xs`,children:(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,I.jsxs)(`span`,{className:`text-ink-muted`,children:[`Turn `,e.turnNumber]}),e.toolName&&(0,I.jsx)(`code`,{className:`text-[10px] bg-surface-5 px-1 rounded`,children:e.toolName}),(0,I.jsx)(ei,{tone:vH[e.outcome],size:`sm`,children:e.outcome})]}),(0,I.jsx)(`p`,{className:`mt-0.5 text-ink-subtle break-words`,children:e.reasoning})]})},`${e.turnNumber}-${t}`))}),e.note&&(0,I.jsx)(`p`,{className:`mt-3 pt-3 border-t border-border-subtle text-[10px] text-ink-muted`,children:e.note})]}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No decision-tree data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Turn costs`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Turn Costs`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-3 pb-3 border-b border-border-subtle`,children:[(0,I.jsx)(bH,{label:`Total attributed cost`,value:`$${t.totalAttributedCost.toFixed(2)}`}),(0,I.jsx)(bH,{label:`Attribution rate`,value:`${Math.round(t.attributionRate*100)}%`})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:t.turns.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-ink-base`,children:e.toolNames.join(`, `)}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted font-mono`,children:[e.model,` · `,Ci(e.inputTokens),` in /`,` `,Ci(e.outputTokens),` out /`,` `,Ci(e.cacheReadTokens),` cache`]})]}),(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums text-ink-base`,children:[`$`,e.estimatedCostUsd.toFixed(2)]})]},e.turnId))})]}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No turn-cost data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Context timeline`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Context Timeline`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:d?(0,I.jsx)(mH,{history:n??[],contextWindow:r??0}):(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No context timeline data yet.`})})]}),(0,I.jsxs)(`section`,{"aria-label":`Context composition and efficiency`,children:[(0,I.jsx)(V,{className:`mb-3`,children:`Context Composition & Efficiency`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:!i&&!a?(0,I.jsx)(`div`,{className:`py-2 text-center text-xs text-ink-muted`,children:`No composition/efficiency data yet.`}):(0,I.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[i&&(0,I.jsxs)(`div`,{className:`text-ink-muted`,children:[`Dominant this turn:`,` `,(0,I.jsx)(`span`,{className:`text-ink-base`,children:Object.entries(i.currentBreakdown).sort((e,t)=>t[1]-e[1])[0]?.[0]})]}),a&&a.repeatedReadRatio!==null&&(0,I.jsxs)(`div`,{className:`text-ink-muted`,children:[`Repeated reads:`,` `,(0,I.jsxs)(`span`,{className:`text-ink-base`,children:[Math.round(a.repeatedReadRatio*100),`%`]}),a.topRepeatedFiles[0]&&(0,I.jsxs)(I.Fragment,{children:[` `,`— top:`,` `,(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:a.topRepeatedFiles[0].file}),` `,`(`,a.topRepeatedFiles[0].readCount,`x)`]})]})]})})]})]})]})]}),document.body)}function bH({label:e,value:t}){return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-[10px] text-ink-muted uppercase tracking-wider`,children:e}),(0,I.jsx)(`div`,{className:`text-sm font-bold tabular-nums text-ink-base mt-0.5`,children:t})]})}var xH=`var(--color-chart-block)`,SH=`var(--color-chart-block-peak)`,CH=10,wH=13;function TH({data:e,maxCount:t,ariaLabel:n}){let r=(0,F.useRef)(null),[i,a]=(0,F.useState)(null);if(e.length===0||e.every(e=>e.count===0))return null;let o=Math.max(t??0,...e.map(e=>e.count),1),s=o*12;return(0,I.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,I.jsx)(`svg`,{width:`100%`,height:s,role:`img`,"aria-label":n,viewBox:`0 0 ${e.length*wH} ${s}`,preserveAspectRatio:`xMidYMax meet`,onMouseLeave:()=>a(null),children:e.map((e,t)=>{let n=[];for(let r=0;r<e.count;r++){let i=e.count===o;n.push((0,I.jsx)(`rect`,{x:t*wH,y:s-(r+1)*12,width:CH,height:CH,rx:1,fill:i?SH:xH,className:`heatmap-cell`,style:{animationDelay:`${t*20+r*10}ms`}},`${t}-${r}`))}return(0,I.jsxs)(`g`,{onMouseEnter:t=>{let n=r.current;if(!n)return;let i=n.getBoundingClientRect(),o=t.currentTarget,s=o.querySelectorAll(`rect.heatmap-cell`),c=(s[s.length-1]??o).getBoundingClientRect();a({x:c.left-i.left+c.width/2,y:c.top-i.top,text:e.tooltip})},children:[(0,I.jsx)(`rect`,{x:t*wH,y:0,width:wH,height:s,fill:`transparent`}),n]},t)})}),i&&(0,I.jsx)(`div`,{className:`absolute px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:i.x,top:i.y,transform:`translate(-50%, calc(-100% - 4px))`},children:i.text})]})}var EH=`nr-observe-peak-concurrent`;function DH({current:e,peak:t,allTimePeak:n,buckets:r}){let[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(null),s=r.some(e=>e.count>0);(0,F.useEffect)(()=>{let e=n??t;if(e<=0)return;let r=parseInt(localStorage.getItem(EH)??`0`,10);if(o.current===null&&(o.current=r),e>o.current){localStorage.setItem(EH,String(e)),o.current=e,a(!0);let t=setTimeout(()=>a(!1),3e3);return()=>clearTimeout(t)}},[t,n]);let c=r.map(e=>{let t=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`});return{count:e.count,tooltip:`${t} — ${e.count} concurrent`}});return(0,I.jsxs)(B,{padding:`sm`,className:`relative overflow-hidden${i?` new-peak-glow`:``}`,children:[i&&(0,I.jsx)(OH,{}),(0,I.jsx)(V,{className:`mb-1.5`,children:`Concurrent Sessions`}),(0,I.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold text-accent-teal tabular-nums`,children:e}),(0,I.jsxs)(`span`,{className:`text-xs text-ink-muted tabular-nums`,children:[`today peak `,t,n&&n>t?` · all-time ${n}`:``]}),i&&(0,I.jsx)(`span`,{className:`text-[10px] text-accent-green font-semibold animate-bounce`,children:`NEW RECORD!`})]}),s&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(TH,{data:c,ariaLabel:`Concurrency over time, peak ${t}`})})]})}function OH(){return(0,I.jsx)(I.Fragment,{children:Array.from({length:12},(e,t)=>{let n=t/12*360,r=40+Math.random()*30;return(0,I.jsx)(`span`,{className:`absolute w-1.5 h-1.5 rounded-full`,style:{left:`50%`,top:`50%`,backgroundColor:t%3==0?`#1CE783`:t%3==1?`#00D4AA`:`#9945FF`,animation:`particle-burst 1s ease-out forwards`,animationDelay:`${t*40}ms`,transform:`translate(-50%, -50%) rotate(${n}deg) translateY(-${r}px)`,opacity:0}},t)})})}var kH=5,AH=[`var(--color-heatmap-0)`,`var(--color-heatmap-1)`,`var(--color-heatmap-2)`,`var(--color-heatmap-3)`,`var(--color-heatmap-4)`];function jH(e,t){if(e===0)return AH[0];let n=e/t;return AH[Math.min(Math.ceil(n*(kH-1)),kH-1)]}function MH(e,t,n){let r=e+n*t;return new Date(r).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function NH({variant:e,buckets:t,maxCount:n,bucketSizeMs:r,startTimestamp:i,width:a,height:o,ariaLabel:s,days:c}){return e===`grid`&&c?(0,I.jsx)(IH,{days:c,maxCount:n,width:a,height:o,ariaLabel:s}):(0,I.jsx)(PH,{buckets:t,maxCount:n,bucketSizeMs:r,startTimestamp:i,width:a,height:o,ariaLabel:s})}function PH({buckets:e,maxCount:t,bucketSizeMs:n=9e5,startTimestamp:r=0,width:i,height:a=24,ariaLabel:o}){let[s,c]=(0,F.useState)(null),l=Math.max(4,Math.min(12,i?(i-e.length*1)/e.length:8)),u=i??e.length*(l+1);return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`svg`,{width:u,height:a,role:`img`,"aria-label":o??`Activity heatmap: ${e.length} time buckets`,className:`w-full`,style:{maxWidth:u},viewBox:`0 0 ${u} ${a}`,preserveAspectRatio:`none`,onMouseLeave:()=>c(null),children:e.map((e,i)=>(0,I.jsx)(`rect`,{x:i*(l+1),y:0,width:l,height:a,rx:2,fill:jH(e,t),className:`heatmap-cell`,style:{animationDelay:`${Math.min(i*8,400)}ms`},onMouseEnter:t=>{let a=MH(r,n,i);c({x:t.currentTarget.x.baseVal.value,text:`${a}: ${e} calls`})}},i))}),s&&(0,I.jsx)(`div`,{className:`absolute -top-7 px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:s.x},children:s.text})]})}var FH=[`Mon`,``,`Wed`,``,`Fri`,``,`Sun`];function IH({days:e,maxCount:t,ariaLabel:n}){let[r,i]=(0,F.useState)(null),a=(0,F.useMemo)(()=>{if(e.length===0)return{weeks:0,cells:[]};let t=(new Date(e[0].date).getUTCDay()+6)%7,n=[];for(let r=0;r<e.length;r++){let i=r+t,a=i%7,o=Math.floor(i/7);n.push({...e[r],row:a,col:o})}return{weeks:n.length>0?n[n.length-1].col+1:0,cells:n}},[e]),o=28+a.weeks*12,s=(0,F.useMemo)(()=>{let e=[],t=``;for(let n of a.cells){if(n.row!==0)continue;let r=new Date(n.date).toLocaleString(void 0,{month:`short`,timeZone:`UTC`});r!==t&&(e.push({text:r,col:n.col}),t=r)}return e},[a.cells]);return(0,I.jsxs)(`div`,{className:`relative flex justify-center`,children:[(0,I.jsxs)(`svg`,{width:`100%`,height:98,role:`img`,"aria-label":n??`Activity grid: ${e.length} days`,viewBox:`0 0 ${o} 98`,preserveAspectRatio:`xMidYMid meet`,onMouseLeave:()=>i(null),children:[FH.map((e,t)=>e?(0,I.jsx)(`text`,{x:0,y:14+t*12+10-2,className:`fill-ink-muted`,fontSize:10,children:e},t):null),s.map(({text:e,col:t})=>(0,I.jsx)(`text`,{x:28+t*12,y:10,className:`fill-ink-muted`,fontSize:10,children:e},`${e}-${t}`)),a.cells.map((e,n)=>(0,I.jsx)(`rect`,{x:28+e.col*12,y:14+e.row*12,width:10,height:10,rx:2,fill:jH(e.count,t),className:`heatmap-cell`,style:{animationDelay:`${Math.min(n*3,300)}ms`},onMouseEnter:t=>{let n=t.currentTarget;i({x:n.x.baseVal.value,y:n.y.baseVal.value-16,text:`${e.date}: ${e.count} calls`})}},n))]}),r&&(0,I.jsx)(`div`,{className:`absolute px-1.5 py-0.5 bg-bg-elevated border border-border-subtle text-[10px] text-ink-base rounded-md shadow-md pointer-events-none whitespace-nowrap tabular-nums`,style:{left:r.x,top:r.y},children:r.text}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5 text-[10px] text-ink-muted`,children:[(0,I.jsx)(`span`,{children:`Less`}),AH.map((e,t)=>(0,I.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm`,style:{backgroundColor:e}},t)),(0,I.jsx)(`span`,{children:`More`})]})]})}function LH({theme:e=`observatory`}){return(0,I.jsxs)(`div`,{className:`geo-banner`,"aria-hidden":`true`,children:[e===`observatory`&&(0,I.jsx)(RH,{}),e===`sessions`&&(0,I.jsx)(zH,{}),e===`history`&&(0,I.jsx)(BH,{}),e===`audit`&&(0,I.jsx)(VH,{}),e===`git`&&(0,I.jsx)(HH,{})]})}function RH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`obsSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#1a3a5c`}),(0,I.jsx)(`stop`,{offset:`40%`,stopColor:`#2d5a7b`}),(0,I.jsx)(`stop`,{offset:`70%`,stopColor:`#e8834a`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#f4a261`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#obsSky)`}),(0,I.jsx)(`polygon`,{points:`0,80 0,45 80,38 160,48 240,30 340,42 420,25 500,38 580,32 660,40 740,28 800,35 800,80`,fill:`#1a3a5c`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`0,80 0,55 60,48 140,58 220,42 300,52 380,40 460,50 520,38 600,48 680,42 760,52 800,48 800,80`,fill:`#234e6f`}),(0,I.jsx)(`polygon`,{points:`0,80 0,62 100,58 200,65 300,55 400,60 500,54 600,62 700,56 800,60 800,80`,fill:`#2a6b4a`,opacity:`0.8`}),(0,I.jsx)(`circle`,{cx:`680`,cy:`28`,r:`14`,fill:`#f4a261`,opacity:`0.6`}),(0,I.jsx)(`circle`,{cx:`680`,cy:`28`,r:`8`,fill:`#ffd166`,opacity:`0.5`}),(0,I.jsx)(`ellipse`,{cx:`150`,cy:`56`,rx:`18`,ry:`10`,fill:`#1a3a5c`}),(0,I.jsx)(`line`,{x1:`150`,y1:`46`,x2:`172`,y2:`34`,stroke:`#5ce0d8`,strokeWidth:`1.5`,opacity:`0.8`})]})}function zH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`seaSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#4aa8c7`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#3a8fb7`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#2d7a9e`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#seaSky)`}),(0,I.jsx)(`polygon`,{points:`600,48 640,35 680,48`,fill:`#2d7a4a`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`700,50 730,40 760,50`,fill:`#3d9b5b`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`0,80 0,15 40,12 80,20 120,18 160,25 180,30 180,80`,fill:`#c05a3c`}),(0,I.jsx)(`polygon`,{points:`0,80 0,25 30,22 60,28 100,25 140,30 160,35 160,80`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`20,20 35,8 50,20`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`60,22 72,12 84,24`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`100,20 115,10 130,22`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`140,28 150,18 160,28`,fill:`#4aad6b`,opacity:`0.8`}),(0,I.jsx)(`rect`,{x:`120`,y:`30`,width:`8`,height:`50`,fill:`#87ceeb`,opacity:`0.5`}),(0,I.jsx)(`rect`,{x:`122`,y:`30`,width:`4`,height:`50`,fill:`#fff`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`620,80 620,30 660,25 700,32 740,28 780,35 800,30 800,80`,fill:`#c05a3c`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`650,30 665,18 680,30`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`720,32 732,22 744,32`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`180,80 180,55 250,52 350,56 450,52 550,55 620,52 620,80`,fill:`#2d7a9e`,opacity:`0.6`}),(0,I.jsx)(`line`,{x1:`200`,y1:`60`,x2:`280`,y2:`58`,stroke:`#5ce0d8`,strokeWidth:`0.8`,opacity:`0.3`}),(0,I.jsx)(`line`,{x1:`350`,y1:`56`,x2:`450`,y2:`55`,stroke:`#5ce0d8`,strokeWidth:`0.8`,opacity:`0.25`}),(0,I.jsx)(`line`,{x1:`480`,y1:`58`,x2:`580`,y2:`56`,stroke:`#87ceeb`,strokeWidth:`0.8`,opacity:`0.3`})]})}function BH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`histSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#3a7ca5`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#5bb8d4`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#8ed4c0`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#histSky)`}),(0,I.jsx)(`polygon`,{points:`100,50 140,20 180,50`,fill:`#e8834a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`160,50 210,15 260,50`,fill:`#d4694a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`550,50 600,18 650,50`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`620,50 660,22 700,50`,fill:`#c05a3c`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`350,50 370,12 390,50`,fill:`#5ce0d8`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`380,50 395,20 410,50`,fill:`#87ceeb`,opacity:`0.3`}),(0,I.jsx)(`polygon`,{points:`700,50 715,25 730,50`,fill:`#5ce0d8`,opacity:`0.35`}),(0,I.jsx)(`polygon`,{points:`300,80 380,50 420,50 500,80`,fill:`#2a5a6b`,opacity:`0.6`}),(0,I.jsx)(`line`,{x1:`390`,y1:`52`,x2:`350`,y2:`78`,stroke:`#f4a261`,strokeWidth:`1`,opacity:`0.4`}),(0,I.jsx)(`line`,{x1:`410`,y1:`52`,x2:`450`,y2:`78`,stroke:`#f4a261`,strokeWidth:`1`,opacity:`0.4`}),(0,I.jsx)(`polygon`,{points:`0,80 0,55 80,52 160,58 240,50 320,55 500,52 580,56 660,50 740,55 800,52 800,80`,fill:`#2d8a4a`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`0,80 0,65 60,62 140,68 220,60 400,65 500,62 600,66 700,60 800,65 800,80`,fill:`#1e6b3a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`30,65 42,42 54,65`,fill:`#3d9b5b`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`50,65 60,48 70,65`,fill:`#2d8a4a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`720,65 732,45 744,65`,fill:`#3d9b5b`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`760,65 770,50 780,65`,fill:`#2d8a4a`,opacity:`0.8`})]})}function VH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`auditSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#1a5c3a`}),(0,I.jsx)(`stop`,{offset:`50%`,stopColor:`#2d7a4a`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#3d9b5b`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#auditSky)`}),(0,I.jsx)(`polygon`,{points:`200,0 210,80 220,0`,fill:`#ffd166`,opacity:`0.08`}),(0,I.jsx)(`polygon`,{points:`500,0 510,80 520,0`,fill:`#ffd166`,opacity:`0.06`}),(0,I.jsx)(`polygon`,{points:`650,0 660,80 670,0`,fill:`#fff`,opacity:`0.05`}),(0,I.jsx)(`rect`,{x:`80`,y:`20`,width:`6`,height:`60`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`180`,y:`10`,width:`7`,height:`70`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`320`,y:`15`,width:`6`,height:`65`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`500`,y:`8`,width:`7`,height:`72`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`620`,y:`18`,width:`6`,height:`62`,fill:`#1a4a2e`}),(0,I.jsx)(`rect`,{x:`740`,y:`12`,width:`7`,height:`68`,fill:`#1a4a2e`}),(0,I.jsx)(`polygon`,{points:`55,25 83,5 111,25`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`60,35 83,15 106,35`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`155,15 183,0 211,18`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`160,28 183,8 206,28`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`295,20 323,2 351,22`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`300,32 323,12 346,32`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`475,12 503,0 531,15`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`480,25 503,5 526,25`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`595,22 623,5 651,22`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`600,34 623,14 646,34`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`715,16 743,0 771,18`,fill:`#5bc47a`}),(0,I.jsx)(`polygon`,{points:`720,30 743,10 766,30`,fill:`#3d9b5b`}),(0,I.jsx)(`polygon`,{points:`0,80 0,68 100,65 200,70 300,64 400,68 500,63 600,67 700,64 800,68 800,80`,fill:`#1e6b3a`}),(0,I.jsx)(`polygon`,{points:`250,80 258,65 266,80`,fill:`#e8834a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`450,80 456,68 462,80`,fill:`#f4a261`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`650,80 656,66 662,80`,fill:`#e8834a`,opacity:`0.55`})]})}function HH(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 800 80`,preserveAspectRatio:`xMidYMid slice`,className:`w-full h-full`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`gitSky`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:`#2d5a7b`}),(0,I.jsx)(`stop`,{offset:`60%`,stopColor:`#3a8fb7`}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:`#5bb8d4`})]})}),(0,I.jsx)(`rect`,{width:`800`,height:`80`,fill:`url(#gitSky)`}),(0,I.jsx)(`polygon`,{points:`0,80 0,20 60,25 120,18 180,28 220,22 260,30 260,80`,fill:`#2d7a4a`,opacity:`0.7`}),(0,I.jsx)(`polygon`,{points:`540,80 540,22 600,28 660,20 720,25 780,18 800,22 800,80`,fill:`#2d7a4a`,opacity:`0.7`}),(0,I.jsx)(`path`,{d:`M 260,50 Q 320,48 400,45 Q 480,42 540,50`,fill:`none`,stroke:`#5ce0d8`,strokeWidth:`4`,opacity:`0.5`}),(0,I.jsx)(`path`,{d:`M 350,45 Q 370,35 400,28`,fill:`none`,stroke:`#87ceeb`,strokeWidth:`2`,opacity:`0.4`}),(0,I.jsx)(`path`,{d:`M 420,44 Q 440,52 470,60`,fill:`none`,stroke:`#87ceeb`,strokeWidth:`2`,opacity:`0.4`}),(0,I.jsx)(`path`,{d:`M 400,28 Q 430,25 460,30`,fill:`none`,stroke:`#5ce0d8`,strokeWidth:`1.5`,opacity:`0.35`}),(0,I.jsx)(`circle`,{cx:`400`,cy:`45`,r:`3`,fill:`#5ce0d8`,opacity:`0.6`}),(0,I.jsx)(`circle`,{cx:`350`,cy:`45`,r:`2`,fill:`#1ce783`,opacity:`0.5`}),(0,I.jsx)(`circle`,{cx:`460`,cy:`44`,r:`2`,fill:`#1ce783`,opacity:`0.5`}),(0,I.jsx)(`polygon`,{points:`300,65 310,55 320,65`,fill:`#3a6b4a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`480,62 492,52 504,62`,fill:`#3a6b4a`,opacity:`0.6`}),(0,I.jsx)(`polygon`,{points:`240,35 250,18 260,35`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`540,35 550,20 560,35`,fill:`#4aad6b`}),(0,I.jsx)(`polygon`,{points:`270,50 278,38 286,50`,fill:`#3d9b5b`,opacity:`0.8`}),(0,I.jsx)(`polygon`,{points:`520,48 528,36 536,48`,fill:`#3d9b5b`,opacity:`0.8`})]})}function UH(e){let t=e==null?new Date:new Date(e);return t.setHours(0,0,0,0),t.getTime()}function WH(e,t){let n=new Date(e),r=t==null?new Date:new Date(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}var GH={weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`},KH=3e4,qH={info:`text-ink-muted`,warning:`text-accent-amber`,critical:`text-accent-red`},JH=1e4;function YH(){let e=Yn(e=>e.cost),t=Yn(e=>e.antiPatterns),n=$n(),r=er(),{data:i}=L({queryKey:[`observability-health`],queryFn:zr,refetchInterval:3e4}),{isPending:a}=L({queryKey:z.cost,queryFn:lr}),{data:o,isPending:s}=L({queryKey:z.sessionsTodayAggregate,queryFn:or,refetchInterval:1e4}),{data:c,isPending:l}=L({queryKey:z.sessionsList(200),queryFn:()=>ar(200),refetchInterval:1e4}),{data:u,isPending:d}=L({queryKey:z.antiPatterns,queryFn:ur}),{data:f}=L({queryKey:[`retry-alerts`],queryFn:dr,refetchInterval:1e4}),{data:p,isPending:m}=L({queryKey:z.concurrency,queryFn:Dr,refetchInterval:1e4}),{data:h,isPending:g}=L({queryKey:z.activityHeatmap(`today`),queryFn:()=>kr(`today`),refetchInterval:3e4}),{data:_,isPending:v}=L({queryKey:z.sessionsLive,queryFn:sr,refetchInterval:1e4}),y=(0,F.useMemo)(()=>lU(c??[]),[c]),b=(0,F.useMemo)(()=>uU(c??[]),[c]),x=(0,F.useMemo)(()=>dU(c??[]),[c]),S=(0,F.useMemo)(()=>fU(c??[]),[c]),C=(0,F.useMemo)(()=>(c??[]).flatMap(e=>e.antiPatterns??[]),[c]),w=Math.max(o?.toolCallCount??0,b),T=(a||l||s)&&!e&&y===0&&o===void 0,E=Math.max(e?.todayTotalUsd??0,o?.totalCostUsd??0,y),D=Math.max(u?.length??0,t.length),O=Math.max(o?.antiPatternCount??0,x+D),k=Math.max(o?.subagentUsd??0,n.usd),A=Math.max(o?.subagentTurnCount??0,n.turns),j=o!==void 0||n.turns>0,[ee,M]=(0,F.useState)(()=>new Date().toLocaleString(void 0,GH));(0,F.useEffect)(()=>{let e=setInterval(()=>M(new Date().toLocaleString(void 0,GH)),6e4);return()=>clearInterval(e)},[]);let te=o?.avgEfficiencyScore??null,ne=te!==null&&Number.isFinite(te)?`${Math.round(te*100)}%`:`—`,N=te===null?`needs more data`:Math.round(te*100)>=80?`strong session`:Math.round(te*100)>=50?`mixed signals`:`needs attention`;return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Today`}),(0,I.jsx)(`span`,{className:`text-xs text-ink-muted`,children:ee})]}),!T&&!s&&!l&&!d&&!m&&!g&&!v&&w===0&&E===0&&O===0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yi,{index:0,className:`glass-card p-8 mb-4`,children:(0,I.jsx)(U,{icon:`code`,title:`No activity yet today`,subtitle:`Metrics will appear here once you start a coding session with Claude.`})}),(0,I.jsx)(Yi,{index:1,children:(0,I.jsx)(aU,{})})]}):(0,I.jsxs)(I.Fragment,{children:[(r?.watcherDisabledByLock===!0||i?.watcherDisabledByLock===!0)&&(0,I.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-300 mb-4`,children:`Subagent watcher is disabled (lock conflict). Subagent costs may be undercounted. Check Settings → Observability health.`}),i?.watcherActive===!1&&n.turns===0&&i?.watcherDisabledReason!==`mode_mismatch`&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border-subtle bg-surface-5 px-4 py-3 text-sm text-ink-muted mb-4`,children:[`Subagent cost tracking is disabled (`,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=0`}),`), so spend shown here excludes subagents. Unset that variable (it is on by default) and restart to see full spend.`]}),i?.watcherActive===!1&&n.turns===0&&i?.watcherDisabledReason===`mode_mismatch`&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border-subtle bg-surface-5 px-4 py-3 text-sm text-ink-muted mb-4`,children:[`This dashboard process isn’t running its own subagent watcher — expected for a background `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`--local`}),` dashboard (the watcher only auto-starts in `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`--stdio`}),` mode). Spend shown here still includes subagent activity from other sessions, read from their persisted totals. To track subagents live from this process too, set`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`NR_AI_WATCHER_MODE=local`}),` and restart.`]}),(0,I.jsx)(Yi,{index:0,className:`mb-4`,children:(0,I.jsx)(B,{padding:`lg`,tone:`elevated`,glow:`green`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-5 gap-4`,children:[(0,I.jsx)(Ji,{label:`efficiency`,hero:!0,value:ne,sub:N,...te===null?{}:{animate:!0,numericValue:Math.round(te*100),suffix:`%`}}),(0,I.jsx)(Ji,{label:`spend today`,tone:`good`,value:T?`…`:xi(E),...T?{}:{animate:!0,numericValue:E,format:xi}}),(0,I.jsx)(Ji,{label:`subagent spend`,value:j?xi(k):`—`,sub:`${A} turns`,...j?{animate:!0,numericValue:k,format:xi}:{}}),(0,I.jsx)(Ji,{label:`tool calls`,value:String(w),animate:!0,numericValue:w}),(0,I.jsx)(Ji,{label:`flags`,tone:O>0?`warn`:`neutral`,value:String(O),animate:!0,numericValue:O})]})})}),(0,I.jsxs)(Yi,{index:1,className:`grid grid-cols-2 gap-3 mb-3`,children:[(0,I.jsx)(pU,{todayTotal:E,forecastEod:T?null:e?.forecastEodUsd??o?.forecastEndOfDayUsd??null,hourlySpend:S,subagentUsd:k}),p&&p.buckets&&(0,I.jsx)(DH,{current:p.current,peak:p.peak,allTimePeak:p.allTimePeak,bucketSizeMs:p.bucketSizeMs,startTimestamp:p.startTimestamp,buckets:p.buckets})]}),O>0&&(t.length>0||u&&u.length>0||C.length>0)&&(0,I.jsx)(Yi,{index:2,className:`mb-3`,children:(0,I.jsx)(B,{padding:`sm`,tone:`warning`,className:`text-xs`,children:t.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:t[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[t[0].count,`× on `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:t[0].target}),t[0].sessionId&&(0,I.jsxs)(ei,{tone:`neutral`,size:`sm`,className:`ml-2`,children:[`Session: `,iU(t[0].sessionId,_??[])]}),t[0].type===`thrashing`&&f?.alerts?.find(e=>e.toolName===t[0].target)?.tokensWastedEstimate!==void 0&&(0,I.jsxs)(`span`,{className:`text-ink-muted ml-2`,children:[`~`,f.alerts.find(e=>e.toolName===t[0].target).tokensWastedEstimate,` `,`tokens wasted`]})]}):u&&u.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:u[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[u[0].count??u[0].iterations??u[0].readCount??u[0].repeatCount??u[0].editCount??u[0].agentCount??`?`,`× on`,` `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:u[0].file??u[0].command??`unknown`})]}):C.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ei,{tone:`warning`,size:`sm`,className:`mr-2`,children:C[0].type}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`— `}),(0,I.jsxs)(`span`,{children:[C[0].count??C[0].iterations??C[0].readCount??C[0].repeatCount??C[0].editCount??C[0].agentCount??`?`,`× on`,` `]}),(0,I.jsx)(`code`,{className:`bg-surface-5 px-1 rounded`,children:C[0].file??C[0].command??`unknown`})]}):null})}),(0,I.jsxs)(Yi,{index:3,className:`grid grid-cols-3 gap-3 mb-3`,children:[(0,I.jsx)(XH,{}),(0,I.jsx)(ZH,{}),(0,I.jsx)(QH,{aggregate:o}),(0,I.jsx)($H,{}),(0,I.jsx)(tU,{aggregate:o})]}),(0,I.jsx)(Yi,{index:4,children:(0,I.jsx)(rU,{sessions:c??[],liveSessions:_??[]})}),h&&h.buckets?.length>0&&(0,I.jsx)(Yi,{index:5,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`sm`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Activity Today`}),(0,I.jsx)(ci,{text:`Tool-call activity in 15-minute blocks across today. Darker blocks mean more calls in that window.`})]}),(0,I.jsx)(NH,{variant:`strip`,buckets:h.buckets,maxCount:h.maxCount,bucketSizeMs:h.bucketSizeMs,startTimestamp:h.startTimestamp,ariaLabel:`Today's activity density in 15-minute blocks`})]})}),(0,I.jsx)(Yi,{index:6,children:(0,I.jsx)(aU,{})})]})]})}function XH(){let{data:e}=L({queryKey:z.qualityProxy,queryFn:Cr,refetchInterval:JH});return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Quality`}),(0,I.jsx)(ci,{text:`Diff apply rate and test pass rate across today's sessions, plus how often you backtracked or self-corrected. Watch for the degrading flag if quality drops mid-session.`})]}),!e||e.totalSignals===0?(0,I.jsx)(U,{icon:`checkmark`,title:`Waiting for edits and test runs`,subtitle:`Quality metrics appear after editing files and running tests.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Diff Apply `}),(0,I.jsx)(`span`,{className:mi(e.diffApplyRate),children:e.diffApplyRate===null?`—`:`${(e.diffApplyRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Test Pass `}),(0,I.jsx)(`span`,{className:mi(e.testPassRate),children:e.testPassRate===null?`—`:`${(e.testPassRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Backtracks `}),(0,I.jsx)(`span`,{className:e.backtrackCount>0?`text-accent-amber`:``,children:e.backtrackCount})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Self-corrections `}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.selfCorrectionCount})]})]}),e.degradationDetected&&(0,I.jsx)(`div`,{className:`text-accent-amber text-xs mt-2`,children:`⚠ Quality degrading`})]})]})}function ZH(){let{data:e}=L({queryKey:z.toolSelectionScore,queryFn:wr,refetchInterval:JH});return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Tool Selection`}),(0,I.jsx)(ci,{text:`Scores how efficiently tools were chosen today: penalizes re-reading a file without editing it, retrying a failing call, or fetching output that's never used.`})]}),!e||Array.isArray(e)||e.totalCalls===0?(0,I.jsx)(U,{icon:`radar`,title:`Waiting for tool calls`,subtitle:`Start a Claude Code session to begin scoring. Reflects today's activity across all sessions.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${hi(e.score)}`,children:e.score.toFixed(2)}),(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,children:`/ 1.0`})]}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted mt-1`,children:[e.penalizedCalls,` of `,e.totalCalls,` calls penalized`]}),(e.redundantReadCount>0||e.repeatedFailureCount>0||e.unusedOutputCount>0)&&(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-subtle mt-1 space-x-2`,children:[e.redundantReadCount>0&&(0,I.jsxs)(`span`,{children:[`re-reads: `,e.redundantReadCount]}),e.repeatedFailureCount>0&&(0,I.jsxs)(`span`,{children:[`repeat fails: `,e.repeatedFailureCount]}),e.unusedOutputCount>0&&(0,I.jsxs)(`span`,{children:[`unused output: `,e.unusedOutputCount]})]}),(0,I.jsx)(`div`,{className:`text-[10px] text-ink-subtle/60 mt-2`,children:`Penalizes: reading the same file 3+ times without editing, repeated tool failures, fetching large outputs never referenced.`})]})]})}function QH({aggregate:e}){let t=e?.latency,n=t?.byTool?Object.entries(t.byTool).filter(e=>e[1]!==null&&e[1].count>0).sort((e,t)=>t[1].p95-e[1].p95).slice(0,4):[];return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Latency (ms)`}),(0,I.jsx)(ci,{text:`How long tool calls took today — p50/p95/p99 across all calls, plus the slowest tools by p95.`})]}),!t||!t.overall?(0,I.jsx)(U,{icon:`clock`,title:`Waiting for tool calls`,subtitle:`Latency percentiles appear after tool calls complete.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex gap-4 text-xs mb-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p50 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p50})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p95 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p95})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`p99 `}),(0,I.jsx)(`span`,{className:`text-ink-base tabular-nums`,children:t.overall.p99})]})]}),n.length>0&&(0,I.jsx)(`div`,{className:`space-y-1`,children:n.map(([e,t])=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted truncate w-28 shrink-0`,children:wi(e)}),(0,I.jsxs)(`span`,{className:`tabular-nums text-ink-subtle`,children:[t.p95,`ms p95`]})]},e))})]})]})}function $H(){let{data:e}=L({queryKey:z.modelUsage,queryFn:Nr,refetchInterval:JH}),t=e?.byModel?Object.entries(e.byModel).filter(([,e])=>e.requestCount>0).sort((e,t)=>t[1].totalCostUsd-e[1].totalCostUsd).slice(0,4):[];return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Model Usage`}),(0,I.jsx)(ci,{text:`Cost and request volume per model used today, combining this server's live usage with every other session's saved totals. The live slice resets if the server process restarts.`})]}),!e||t.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No model data yet`,subtitle:`Start a Claude Code session to see model cost breakdown. Resets when the process restarts.`}):(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[t.map(([e,t])=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs gap-2`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted truncate`,children:e}),(0,I.jsxs)(`div`,{className:`flex gap-3 shrink-0 tabular-nums`,children:[(0,I.jsxs)(`span`,{className:`text-ink-subtle`,children:[t.requestCount,`req`]}),(0,I.jsxs)(`span`,{className:`text-ink-subtle`,children:[Si(t.costPerMillionTokens),`/1M tok`]}),(0,I.jsx)(`span`,{className:`text-ink-base`,children:xi(t.totalCostUsd)})]})]},e)),e?.mostEfficientModel&&(0,I.jsxs)(`div`,{className:`text-[10px] text-accent-green mt-1`,children:[`Most efficient: `,e.mostEfficientModel]})]})]})}function eU(e,t){let n=t===null?null:`${t}%`;return e===`excellent`?n?`Cache hit rate is ${n}. Cache is well-structured.`:`Cache is well-structured. No changes needed.`:e===`can_improve`?n?`Cache hit rate is ${n}. Placing stable content before variable content in prompts could improve this.`:`Place stable content before variable content in prompts to improve.`:n?`Cache hit rate is ${n}. Restructuring your system prompt so stable context appears at the top could bring this above 60%.`:`Restructure your system prompt so stable context appears at the top.`}function tU({aggregate:e}){let{data:t}=L({queryKey:z.cacheHealth,queryFn:Pr,refetchInterval:JH}),n=e?.cacheHealth,r=!n||n.status===`no_cache_activity`||n.cacheHitRatePct==null;return(0,I.jsxs)(B,{padding:`sm`,className:`h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Cache Health`}),(0,I.jsx)(ci,{text:`Prompt cache hit rate today, with a suggestion for improving it — usually by moving stable context earlier in the prompt.`})]}),r?(0,I.jsx)(U,{icon:`radar`,title:`No cache data yet`,subtitle:`Appears once token usage with cache reads is reported.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-1`,children:[(0,I.jsxs)(`span`,{className:`text-2xl font-semibold tabular-nums ${n.status===`excellent`?`text-accent-green`:n.status===`needs_attention`?`text-accent-amber`:`text-ink-base`}`,children:[n.cacheHitRatePct,`%`]}),(0,I.jsx)(ei,{tone:n.status===`needs_attention`?`warning`:`neutral`,size:`sm`,children:n.status===`excellent`?`excellent`:n.status.replace(`_`,` `)})]}),n.totalSavingsUsd>0&&(0,I.jsxs)(`div`,{className:`text-xs text-accent-green mb-1`,children:[`$`,n.totalSavingsUsd.toFixed(4),` saved`]}),t?.week_over_week_delta_pts!=null&&t.week_over_week_delta_pts!==0&&(0,I.jsxs)(`div`,{className:`text-[10px] font-medium mb-1 ${t.week_over_week_delta_pts>0?`text-accent-green`:`text-accent-amber`}`,children:[t.week_over_week_delta_pts>0?`↑`:`↓`,Math.abs(t.week_over_week_delta_pts),`pts vs last week`]}),(0,I.jsx)(`div`,{className:`text-[10px] text-ink-subtle/70 leading-snug`,children:eU(n.status,n.cacheHitRatePct)})]})]})}var nU=3e3;function rU({sessions:e,liveSessions:t}){let[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[,c]=qt(),l=Yn(e=>e.setActiveSession),{data:u}=L({queryKey:z.sessionCurrent,queryFn:ir}),d=(0,F.useMemo)(()=>{let e=new Set;for(let n of t)e.add(n.sessionId);if(e.size===0)if(u?.liveSessions?.length)for(let t of u.liveSessions)e.add(t);else u?.sessionId&&e.add(u.sessionId);return e},[t,u]),f=(t.length>0?t[0].sessionId:null)??(d.size>0?[...d][0]:null),p=n??f,m=p!==null&&d.has(p),h=n!==null&&!d.has(n);(0,F.useEffect)(()=>{l(p)},[p,l]);let{data:g}=L({queryKey:p?z.sessionReplay(p):[`replay`,`none`],queryFn:()=>br(p),enabled:p!==null,retry:!1,refetchInterval:m?nU:!1}),{data:_}=L({queryKey:p?z.sessionSubagents(p):[`subagents`,`none`],queryFn:()=>xr(p),enabled:p!==null,retry:!1,refetchInterval:m?nU:!1}),{data:v}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:m?1e4:!1}),{data:y}=L({queryKey:[`turn-costs`],queryFn:pr,refetchInterval:1e4}),{data:b}=L({queryKey:[`decision-tree`],queryFn:fr,refetchInterval:1e4}),{data:x}=L({queryKey:p?[`context`,p]:z.context,queryFn:()=>Ar(p??void 0),refetchInterval:1e4,enabled:m&&!!p}),{data:S}=L({queryKey:[`context-composition`],queryFn:jr,refetchInterval:1e4}),{data:C}=L({queryKey:[`context-efficiency`],queryFn:Mr,refetchInterval:1e4}),w=(0,F.useRef)(null);(0,F.useEffect)(()=>{m&&w.current&&(w.current.scrollTop=w.current.scrollHeight)},[g?.timeline.length,m]);let T=(0,F.useMemo)(()=>{let n=Date.now()-360*60*1e3,r=new Map;for(let e of t)r.set(e.sessionId,e);let i=new Map;for(let t of e){if(!t.sessionId)continue;let e=t.startTime!=null&&sU(t.startTime),a=r.has(t.sessionId),o=t.startTime!=null&&t.durationMs!=null?t.startTime+t.durationMs:null,s=o!=null&&o>=n&&sU(o);(e||a||s)&&i.set(t.sessionId,t)}for(let e of t)e.sessionId&&(i.has(e.sessionId)||i.set(e.sessionId,{sessionId:e.sessionId,sessionName:e.sessionName,startTime:e.startTime,toolCallCount:0,estimatedCostUsd:null}));let a=e=>{let t=r.get(e.sessionId);return t?t.lastActivity:e.startTime!=null&&e.durationMs!=null?e.startTime+e.durationMs:e.startTime??0};return[...i.values()].sort((e,t)=>a(t)-a(e)).slice(0,10)},[e,t]),E=(0,F.useMemo)(()=>g?.timeline??[],[g]),D=(0,F.useMemo)(()=>Array.isArray(_?.agents)?_.agents:[],[_]),O=(0,F.useMemo)(()=>{let e=null,t=null;for(let n of E){let r=n.timestamp+(n.durationMs??50);(e===null||n.timestamp<e)&&(e=n.timestamp),(t===null||r>t)&&(t=r)}let n=_?.window;return n&&Number.isFinite(n.startMs)&&Number.isFinite(n.endMs)&&(e=e===null?n.startMs:Math.min(e,n.startMs),t=t===null?n.endMs:Math.max(t,n.endMs)),e===null||t===null?{startMs:0,endMs:1}:{startMs:e,endMs:t>e?t:e+1}},[E,_]),k=(0,F.useMemo)(()=>{let e={};if(Array.isArray(v))for(let t of v)t&&typeof t.runId==`string`&&typeof t.status==`string`&&t.parentSessionId===p&&(e[t.runId]=t.status);return e},[v,p]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`glass-card mb-3 grid grid-cols-[220px_1fr] overflow-hidden`,style:{height:`320px`},children:[(0,I.jsxs)(`div`,{className:`border-r border-border-subtle flex flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5 p-2 border-b border-border-subtle shrink-0`,children:[(0,I.jsx)(V,{children:`Session Live Tail`}),(0,I.jsx)(ci,{text:`Today's sessions on the left; select one to stream its live tool-call trace on the right.`})]}),(0,I.jsxs)(`div`,{className:`overflow-auto flex-1`,children:[T.map(e=>{let t=d.has(e.sessionId);return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r(e.sessionId),className:`block w-full text-left p-2 border-b border-border-subtle text-xs transition-colors duration-150 hover:bg-surface-5 `+(p===e.sessionId?`bg-surface-5`:``),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base`,children:e.sessionName||e.sessionId.slice(0,8)}),t?(0,I.jsx)(ni,{label:`live`,size:`sm`}):(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,title:e.startTime?`Started ${_i(e.startTime)}`:void 0,children:e.startTime?_i(e.startTime+(e.durationMs??0)):``})]}),(0,I.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[10px] text-ink-subtle`,children:[(0,I.jsxs)(`span`,{children:[e.toolCallCount??0,` calls`]}),e.estimatedCostUsd!=null&&e.estimatedCostUsd>0?(0,I.jsx)(`span`,{children:xi(e.estimatedCostUsd)}):(0,I.jsx)(`span`,{children:`—`})]})]},e.sessionId)}),d.size===0&&T.length===0&&(0,I.jsx)(U,{icon:`code`,title:`No sessions today`,subtitle:`Start coding with Claude to see sessions here.`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[p&&(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 border-b border-border-subtle shrink-0`,children:[(0,I.jsx)(V,{children:`Trace`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h&&(0,I.jsx)(`span`,{"data-testid":`session-ended-badge`,children:(0,I.jsx)(ei,{tone:`neutral`,size:`sm`,uppercase:!0,children:`Session ended`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>c(`/sessions?id=${p}`),className:`text-[10px] text-accent-cyan hover:underline transition-colors duration-150`,children:`full session →`})]})]}),(0,I.jsxs)(`div`,{ref:w,className:`overflow-auto flex-1 p-2`,children:[!p&&(0,I.jsx)(`div`,{className:`text-ink-muted text-xs p-2`,children:`Select a session to view its timeline.`}),p&&E.length===0&&D.length===0&&(0,I.jsx)(U,{icon:`timeline`,title:m?`Waiting for tool calls`:`No tool calls`,subtitle:m?`Tool calls will appear here in real time.`:`This session has no recorded tool calls.`}),p&&(E.length>0||D.length>0)&&(0,I.jsx)(Ca,{sessionId:p,parentEntries:E,agents:D,window:O,runStatusById:k,parentSegments:g?.segments??[],onSelectRun:e=>a(e)},p)]}),m&&p&&(0,I.jsx)(`div`,{className:`border-t border-bg-line px-3 py-2 shrink-0`,children:(0,I.jsx)(_H,{sessionId:p,expandable:!1})}),((b?.totalBranches??0)>0||(y?.turns?.length??0)>0||(x?.history?.length??0)>=2)&&(0,I.jsx)(`div`,{className:`border-t border-bg-line px-3 py-2 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-accent-cyan hover:underline transition-colors duration-150 text-left`,children:(()=>{let e=[];return b&&b.totalBranches>0&&e.push(`${b.longestFailureStreak} failure streak`),y?.turns&&y.turns.length>0&&e.push(`${y.turns.length} turns · $${y.totalAttributedCost.toFixed(2)}`),e.length>0?`${e.join(` · `)} — session detail →`:`session detail →`})()})})]})]}),i!=null&&(0,I.jsx)(qa,{runId:i,onClose:()=>a(null)}),o&&(0,I.jsx)(yH,{decisionTree:b,turnCosts:y,contextHistory:x?.history,contextWindow:x?.contextWindow,contextComposition:S,contextEfficiency:C,onClose:()=>s(!1)})]})}function iU(e,t){let n=t.find(t=>t.sessionId===e);return n?.sessionName?n.sessionName:e.slice(0,8)}function aU(){let{data:e,isLoading:t,error:n}=L({queryKey:z.alertsRecent,queryFn:async()=>{try{return await yr()}catch(e){if(e instanceof nr)return null;throw e}},refetchInterval:KH,retry:!1});if(e===null)return null;let r=[...e??[]].sort((e,t)=>t.firedAt-e.firedAt);return(0,I.jsxs)(B,{padding:`sm`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,I.jsx)(V,{children:`Recent Alerts`}),(0,I.jsx)(ci,{text:`The most recent alert firings and resolutions from your configured alert rules, newest first.`})]}),t&&(0,I.jsx)(U,{variant:`loading`,title:`Loading...`}),n&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading recent alerts.`}),!t&&!n&&r.length===0&&(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`No alerts in recent history.`}),!t&&!n&&r.length>0&&(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`when`}),(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`sev`}),(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`rule`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`value / threshold`}),(0,I.jsx)(`th`,{className:`text-left pb-1 pl-2`,children:`state`})]})}),(0,I.jsx)(`tbody`,{children:r.slice(0,50).map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`py-1 text-ink-subtle tabular-nums whitespace-nowrap`,children:oU(e.firedAt)}),(0,I.jsxs)(`td`,{className:`py-1`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:qH[e.severity],children:`●`}),` `,(0,I.jsx)(`span`,{className:`text-ink-subtle uppercase tracking-wider text-[10px]`,children:e.severity})]}),(0,I.jsx)(`td`,{className:`py-1`,children:e.title}),(0,I.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[bi(e.value),` / `,bi(e.threshold)]}),(0,I.jsx)(`td`,{className:`py-1 pl-2 `+(e.state===`firing`?`text-accent-amber`:`text-ink-muted`),children:e.state})]},`${e.id}-${e.firedAt}-${e.state}`))})]})]})}function oU(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var sU=e=>WH(e);function cU(e){let t=e.estimatedCostUsd;if(t==null||t<=0||e.startTime==null)return 0;let n=UH(),r=n+864e5,i=e.startTime,a=typeof e.endTime==`number`?e.endTime:typeof e.durationMs==`number`?e.startTime+e.durationMs:Date.now();return a<n||i>=r?0:i>=n&&a<r?t:t*((Math.min(a,r)-Math.max(i,n))/Math.max(1,a-i))}function lU(e){let t=0;for(let n of e)t+=cU(n);return t}function uU(e){let t=0;for(let n of e)(n.startTime&&sU(n.startTime)||cU(n)>0)&&(t+=n.toolCallCount??0);return t}function dU(e){let t=0;for(let n of e)(n.startTime&&sU(n.startTime)||cU(n)>0)&&(t+=n.antiPatterns?.length??0);return t}function fU(e){let t=Array(24).fill(0);for(let n of e){if(!n.startTime||!sU(n.startTime)||n.estimatedCostUsd==null)continue;let e=new Date(n.startTime).getHours();t[e]+=n.estimatedCostUsd}return t.map((e,t)=>({hour:t,cost:e}))}function pU({todayTotal:e,forecastEod:t,hourlySpend:n,subagentUsd:r=0}){let i=t!==null&&Number.isFinite(t),a=i?Math.max(t,e):0,o=i?a-e:0,s=i&&e>0?o/e*100:0,c=n.some(e=>e.cost>0),l=r>0?Math.max(0,e-r):0;return(0,I.jsxs)(B,{padding:`sm`,className:`mb-3 h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,I.jsx)(V,{children:`Forecast · End of Day`}),(0,I.jsx)(ci,{text:`Projects today's total spend by midnight, based on the spending trend so far this hour-by-hour.`})]}),i?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold text-accent-cyan tabular-nums`,children:xi(a)}),(0,I.jsx)(`span`,{className:`text-xs text-ink-muted tabular-nums`,children:o>0?(0,I.jsxs)(I.Fragment,{children:[`+`,xi(o),e>0&&` (+${s.toFixed(0)}%)`,` from now`]}):(0,I.jsx)(I.Fragment,{children:`on pace`})})]}),c&&(0,I.jsxs)(`div`,{className:`mt-2`,children:[(0,I.jsx)(na,{hours:n}),r>0&&(0,I.jsxs)(`div`,{className:`flex gap-3 mt-1 text-[10px] text-ink-muted tabular-nums`,children:[(0,I.jsxs)(`span`,{children:[`parent `,xi(l)]}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:`·`}),(0,I.jsxs)(`span`,{children:[`subagent `,xi(r)]})]})]})]}):(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`Insufficient data — forecast appears once burn rate stabilizes.`})]})}function mU(e,t){let{startMs:n,endMs:r,bucketSizeMs:i}=t,a=Math.max(1,Math.ceil((r-n)/i)),o=Array(a).fill(0);for(let t of e){let e=Math.floor((t.timestamp-n)/i);e>=0&&e<a&&o[e]++}return o}function hU(e){return e<6e5?3e4:e<36e5?6e4:e<144e5?3e5:9e5}var gU=50,_U={thrashing:`Edit/Test Thrashing`,stuck_loop:`Stuck Loop`,blind_editing:`Blind Editing`,re_reading:`Repeated Reads`},vU={running:{tone:`info`,label:`Running`},completed:{tone:`success`,label:`Completed`},failed:{tone:`danger`,label:`Failed`},cancelled:{tone:`warning`,label:`Cancelled`},unknown:{tone:`neutral`,label:`Unknown`}},yU=[{value:`today`,label:`Today`},{value:`7d`,label:`7 days`},{value:`30d`,label:`30 days`},{value:`all`,label:`All`}],bU=[{value:`all`,label:`All sources`},{value:`script`,label:`Script`},{value:`agent_tool`,label:`Agent tool`}],xU=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`completed`,label:`Completed`},{value:`failed`,label:`Failed`},{value:`cancelled`,label:`Cancelled`}];function SU(e,t){if(t===`all`||e==null)return!0;let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return!0;let r=Date.now();return n>={today:new Date().setHours(0,0,0,0),"7d":r-10080*60*1e3,"30d":r-720*60*60*1e3}[t]}function CU(e){let t;try{let n=new URLSearchParams(e);t=n.get(`session`)??n.get(`id`)}catch{return null}if(t==null)return null;let n=t.trim();return n.length===0||n.length>256?null:n}function wU(e){return typeof e.startTime==`number`?e.startTime:new Date(e.startTime??0).getTime()}function TU(e){return wU(e)+(e.durationMs??0)}function EU(e,t){let n=[...e];switch(t){case`date`:n.sort((e,t)=>wU(t)-wU(e));break;case`lastActive`:n.sort((e,t)=>TU(t)-TU(e));break;case`cost`:n.sort((e,t)=>(t.estimatedCostUsd??0)-(e.estimatedCostUsd??0));break;case`calls`:n.sort((e,t)=>(t.toolCallCount??0)-(e.toolCallCount??0));break}return n}function DU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function OU(){let e=Jt(),[t,n]=(0,F.useState)(()=>CU(window.location.search)),[r,i]=(0,F.useState)(`date`),[a,o]=(0,F.useState)(`all`),[s,c]=(0,F.useState)(`all`),[l,u]=(0,F.useState)(`all`),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(()=>new Set),[h,g]=(0,F.useState)(()=>new Set),_=(0,F.useMemo)(()=>CU(e),[e]);(0,F.useEffect)(()=>{_&&n(_)},[_]);let v=L({queryKey:z.sessionsList(gU),queryFn:()=>ar(gU),refetchInterval:1e4}),{data:y}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:1e4}),b=L({queryKey:z.sessionCurrent,queryFn:ir,refetchInterval:1e4}),x=(0,F.useMemo)(()=>{let e=new Set;if(b.data?.liveSessions?.length)for(let t of b.data.liveSessions)e.add(t);else b.data?.sessionId&&e.add(b.data.sessionId);return e},[b.data]),S=L({queryKey:t?z.sessionDetail(t):[`session`,`none`],queryFn:()=>cr(t),enabled:t!==null,refetchInterval:b.isLoading||t&&x.has(t)?1e4:!1}),C=(0,F.useMemo)(()=>EU(v.data??[],r),[v.data,r]),w=(0,F.useMemo)(()=>Array.isArray(y)?y:[],[y]),T=(0,F.useMemo)(()=>w.filter(e=>!(!SU(e.startedAt,a)||s!==`all`&&e.runSource!==s||l!==`all`&&e.status!==l)),[w,a,s,l]),E=(0,F.useMemo)(()=>{let e=T.length,t=T.reduce((e,t)=>e+(t.agentCount??0),0),n=T.map(e=>e.totalUsd).filter(e=>e!=null),r=n.length>0?n.reduce((e,t)=>e+t,0):null,i=T.map(e=>e.durationMs).filter(e=>e!=null);return{totalRuns:e,totalAgents:t,totalSpend:r,avgDurationMs:i.length>0?i.reduce((e,t)=>e+t,0)/i.length:null}},[T]),D=(0,F.useMemo)(()=>{let e=new Map;for(let t of T){let n=t.parentSessionId;if(typeof n!=`string`)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}return e},[T]),O=a!==`all`||s!==`all`||l!==`all`,k=(0,F.useMemo)(()=>O?C.filter(e=>D.has(e.sessionId)):C,[O,C,D]);(0,F.useEffect)(()=>{if(t)return;let e=x.size>0?[...x][0]:null;e?n(e):C.length>0&&n(C[0].sessionId)},[x,C,t]);let A=e=>{n(e)},j=(0,F.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ee=(0,F.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=(0,F.useCallback)(e=>{f(e)},[]);return(0,I.jsxs)(`section`,{className:`flex flex-col h-full`,children:[(0,I.jsx)(`div`,{className:`h-8 overflow-hidden rounded-lg mb-2 shrink-0`,children:(0,I.jsx)(LH,{theme:`sessions`})}),(0,I.jsx)(`h1`,{className:`text-lg font-semibold gradient-text mb-2 shrink-0`,children:`Sessions`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,className:`mb-2 shrink-0`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4 divide-x divide-border-subtle`,children:[(0,I.jsx)(`div`,{className:`px-3 first:pl-0`,children:(0,I.jsx)(Ji,{label:`Workflow runs`,value:String(E.totalRuns),numericValue:E.totalRuns,animate:!0})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Subagents`,value:String(E.totalAgents),numericValue:E.totalAgents,animate:!0})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Workflow spend`,value:Si(E.totalSpend),tone:E.totalSpend===null?`neutral`:`warn`})}),(0,I.jsx)(`div`,{className:`px-3`,children:(0,I.jsx)(Ji,{label:`Avg duration`,value:E.avgDurationMs===null?`—`:yi(E.avgDurationMs)})})]})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap mb-2 shrink-0`,children:[(0,I.jsx)(ai,{value:a,onChange:o,options:yU,ariaLabel:`Time window`}),(0,I.jsx)(`div`,{className:`h-4 w-px bg-border-subtle`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Run source filter`,children:bU.map(e=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":s===e.value,onClick:()=>c(e.value),className:[`px-2.5 py-1 rounded-full text-[11px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,s===e.value?`bg-accent-cyan/20 text-accent-cyan font-medium`:`text-ink-muted hover:text-ink-subtle`].join(` `),children:e.label},e.value))}),(0,I.jsx)(`div`,{className:`h-4 w-px bg-border-subtle`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Status filter`,children:xU.map(e=>{let t=l===e.value;return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>u(e.value),className:[`px-2.5 py-1 rounded-full text-[11px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,t?`bg-accent-green/20 text-accent-green font-medium`:`text-ink-muted hover:text-ink-subtle`].join(` `),children:e.label},e.value)})}),O&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{o(`all`),c(`all`),u(`all`)},className:`text-[10px] text-ink-muted hover:text-ink-subtle underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40 rounded-sm`,children:`Clear filters`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[260px_1fr] gap-3 flex-1 min-h-0`,children:[(0,I.jsxs)(B,{padding:`none`,tone:`static`,className:`overflow-hidden flex flex-col`,children:[(0,I.jsx)(`header`,{className:`p-2 border-b border-border-subtle`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(V,{as:`h2`,children:`List`}),(0,I.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`text-[10px] bg-surface-5 border border-border-medium rounded-md px-1.5 py-0.5 text-ink-subtle`,children:[(0,I.jsx)(`option`,{value:`date`,children:`Newest`}),(0,I.jsx)(`option`,{value:`lastActive`,children:`Last active`}),(0,I.jsx)(`option`,{value:`cost`,children:`Cost`}),(0,I.jsx)(`option`,{value:`calls`,children:`Calls`})]})]})}),(0,I.jsxs)(`div`,{className:`overflow-auto`,children:[v.isLoading&&(0,I.jsx)(U,{variant:`loading`,icon:`timeline`,title:`Loading sessions`}),!v.isLoading&&k.length===0&&x.size===0&&(0,I.jsx)(U,{icon:`code`,title:O?`No matching sessions`:`No sessions yet`,subtitle:O?`No sessions own a workflow run matching these filters.`:`Start coding with Claude to see your sessions here.`}),k.map(e=>(0,I.jsx)(kU,{row:e,isLive:x.has(e.sessionId),isSelected:t===e.sessionId,isExpanded:p.has(e.sessionId),sortKey:r,runs:D.get(e.sessionId)??[],expandedRuns:h,onSelect:A,onToggleSession:j,onToggleRun:ee,onOpenRun:M},e.sessionId)),C.length>=gU&&(0,I.jsxs)(`div`,{className:`p-2 text-[10px] text-ink-muted text-center border-t border-border-subtle`,children:[`Showing `,gU,` most recent sessions.`]})]})]}),(0,I.jsxs)(`div`,{className:`glass-card glass-card-static p-4 overflow-auto`,children:[!t&&(0,I.jsx)(U,{icon:`timeline`,title:`Loading sessions`,subtitle:`Selecting the most recent session…`}),t&&S.isLoading&&(0,I.jsx)(U,{variant:`loading`,icon:`timeline`,title:`Loading detail`}),t&&S.data&&(0,I.jsx)(MU,{data:S.data,isLive:!!t&&x.has(t),onOpenRun:M})]})]}),d!=null&&(0,I.jsx)(qa,{runId:d,onClose:()=>f(null)})]})}function kU({row:e,isLive:t,isSelected:n,isExpanded:r,sortKey:i,runs:a,expandedRuns:o,onSelect:s,onToggleSession:c,onToggleRun:l,onOpenRun:u}){return(0,I.jsxs)(`div`,{className:`border-b border-border-subtle`,children:[(0,I.jsxs)(`div`,{className:`flex items-stretch text-xs transition-colors duration-150 hover:bg-surface-5 `+(n?`bg-surface-5`:``),children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":r?`Collapse workflows`:`Expand workflows`,"aria-expanded":r,onClick:t=>{t.stopPropagation(),c(e.sessionId)},className:`shrink-0 flex items-center justify-center w-6 text-ink-muted hover:text-ink-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:r?(0,I.jsx)(vn,{size:13,"aria-hidden":`true`}):(0,I.jsx)(yn,{size:13,"aria-hidden":`true`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>s(e.sessionId),className:`flex-1 min-w-0 text-left py-2 pr-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base truncate`,children:e.sessionName||e.sessionId.slice(0,8)}),t&&(0,I.jsx)(ni,{size:`sm`,label:`live`,className:`shrink-0`})]}),(0,I.jsxs)(`div`,{className:`flex justify-between mt-1 text-ink-subtle text-[11px] tabular-nums`,children:[(0,I.jsxs)(`span`,{children:[e.toolCallCount??0,` calls`]}),(0,I.jsx)(`span`,{className:`text-ink-muted`,title:i===`lastActive`&&e.startTime?`Started ${gi(e.startTime)}`:void 0,children:e.startTime?gi(i===`lastActive`?TU(e):e.startTime):`—`}),(0,I.jsx)(`span`,{children:Si(e.estimatedCostUsd)})]})]})]}),r&&(0,I.jsx)(`div`,{className:`pl-3 border-l border-border-subtle ml-3 mb-1`,children:a.length===0?(0,I.jsx)(`div`,{className:`py-1.5 pl-1 text-[10px] text-ink-muted`,children:`No workflows in this session.`}):a.map(e=>(0,I.jsx)(AU,{run:e,isExpanded:o.has(e.runId),onToggleRun:l,onOpenRun:u},e.runId))})]})}function AU({run:e,isExpanded:t,onToggleRun:n,onOpenRun:r}){let{data:i}=L({queryKey:z.workflowDetail(e.runId),queryFn:()=>Vr(e.runId),enabled:t}),a=(0,F.useMemo)(()=>i?.agents??[],[i]),o=vU[e.status]??vU.unknown;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-stretch hover:bg-surface-5 rounded transition-colors`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":t?`Collapse agents`:`Expand agents`,"aria-expanded":t,onClick:t=>{t.stopPropagation(),n(e.runId)},className:`shrink-0 flex items-center justify-center w-5 text-ink-muted hover:text-ink-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:t?(0,I.jsx)(vn,{size:12,"aria-hidden":`true`}):(0,I.jsx)(yn,{size:12,"aria-hidden":`true`})}),(0,I.jsxs)(`button`,{type:`button`,"aria-label":`View workflow run ${e.workflowName??e.runId}`,onClick:()=>r(e.runId),className:`flex-1 min-w-0 flex items-center gap-1.5 text-left py-1.5 pr-1 text-[10px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40 rounded`,children:[(0,I.jsx)(`span`,{className:`flex-1 min-w-0 font-medium text-ink-base truncate`,children:e.workflowName??e.runId}),(0,I.jsxs)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:[e.agentCount==null?0:e.agentCount,`a`]}),(0,I.jsx)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:Si(e.totalUsd)}),(0,I.jsx)(ei,{tone:o.tone,size:`sm`,bordered:!0,children:o.label})]})]}),t&&(0,I.jsx)(`div`,{className:`pl-3 border-l border-border-subtle ml-2.5`,children:a.length===0?(0,I.jsx)(`div`,{className:`py-1 pl-1 text-[10px] text-ink-muted`,children:`No agents recorded.`}):a.map(t=>(0,I.jsxs)(`button`,{type:`button`,"aria-label":`View agent ${t.label} in run ${e.workflowName??e.runId}`,onClick:()=>r(e.runId),className:`flex w-full items-center gap-1.5 text-left py-1 pr-1 text-[10px] hover:bg-surface-5 rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cyan/40`,children:[(0,I.jsx)(`span`,{className:`flex-1 min-w-0 text-ink-subtle truncate`,title:t.label,children:t.label}),(0,I.jsx)(`span`,{className:`font-mono text-ink-muted truncate max-w-[72px] shrink-0`,title:t.model,children:t.model}),(0,I.jsx)(`span`,{className:`text-ink-muted tabular-nums shrink-0`,children:DU(t.tokens)})]},t.agentId))})]})}function jU(e){return e===`Read`?`bg-accent-blue/80`:e===`Edit`||e===`Write`?`bg-accent-green/80`:e===`Bash`?`bg-accent-purple/80`:e===`Agent`?`bg-accent-teal/80`:`bg-ink-subtle/80`}function MU({data:e,isLive:t,onOpenRun:n}){let r=e.toolBreakdown??{},i=Object.entries(r).sort((e,t)=>t[1]-e[1]),a=e.toolCallCount??0,o=e.durationMs==null?null:yi(e.durationMs),s=e.timeline??[],c=s.length>0?s[0].timestamp:0;return s.length===0&&i.length===0?(0,I.jsx)(U,{icon:`timeline`,title:`No tool calls`,subtitle:`This session has no recorded tool calls.`}):(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`text-xs tracking-wider text-ink-muted flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-ink-base ${e.sessionName?`font-medium`:`uppercase`}`,children:e.sessionName||e.sessionId.slice(0,8)}),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsxs)(`span`,{className:`uppercase`,children:[a,` calls`]}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:o})]}),t&&(0,I.jsx)(ni,{size:`sm`,label:`live`})]}),c>0&&(0,I.jsx)(`div`,{className:`text-[11px] text-ink-subtle mt-0.5`,children:new Date(c).toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mb-4 text-xs`,children:[e.model&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Model`}),(0,I.jsx)(`div`,{className:`font-mono`,children:e.model})]}),e.estimatedCostUsd!=null&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Cost`}),(0,I.jsx)(`div`,{className:`tabular-nums`,children:xi(e.estimatedCostUsd)})]}),e.outcome&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-2.5`,children:[(0,I.jsx)(V,{children:`Status`}),(0,I.jsx)(`div`,{className:`capitalize`,children:e.outcome})]})]}),(e.antiPatterns?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Anti-Patterns`}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.antiPatterns.map(({type:e,count:t})=>(0,I.jsxs)(ei,{tone:`warning`,size:`sm`,bordered:!0,children:[_U[e]??e,(0,I.jsxs)(`span`,{className:`opacity-70`,children:[`× `,t]})]},e))})]}),(e.qualityProxy||e.toolSelectionScore)&&(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-4`,children:[e.qualityProxy&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Session Quality`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Diff Apply `}),(0,I.jsx)(`span`,{className:mi(e.qualityProxy.diffApplyRate),children:e.qualityProxy.diffApplyRate===null?`—`:`${(e.qualityProxy.diffApplyRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Test Pass `}),(0,I.jsx)(`span`,{className:mi(e.qualityProxy.testPassRate),children:e.qualityProxy.testPassRate===null?`—`:`${(e.qualityProxy.testPassRate*100).toFixed(0)}%`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Backtracks `}),(0,I.jsx)(`span`,{className:e.qualityProxy.backtrackCount>0?`text-accent-amber`:``,children:e.qualityProxy.backtrackCount})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Self-corrections `}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.qualityProxy.selfCorrectionCount})]})]})]}),e.toolSelectionScore&&(0,I.jsxs)(`div`,{className:`bg-surface-3 rounded-lg p-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Tool Selection`}),(0,I.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums ${hi(e.toolSelectionScore.score)}`,children:e.toolSelectionScore.score.toFixed(2)}),(0,I.jsxs)(`div`,{className:`text-[10px] text-ink-muted mt-1`,children:[`re-reads: `,e.toolSelectionScore.redundantReadCount,` · repeat fails:`,` `,e.toolSelectionScore.repeatedFailureCount,` · unused:`,` `,e.toolSelectionScore.unusedOutputCount]})]})]}),t&&(0,I.jsx)(`div`,{className:`mb-4`,children:(0,I.jsx)(_H,{sessionId:e.sessionId})}),i.length>0&&(0,I.jsx)(PU,{breakdownEntries:i,totalCalls:a,isLive:t,sessionId:e.sessionId}),(0,I.jsx)(IU,{timeline:s}),(e.filesRead?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Files Read`}),(0,I.jsx)(`ul`,{className:`text-[11px] text-ink-subtle space-y-0.5`,children:e.filesRead.map(e=>(0,I.jsx)(`li`,{className:`font-mono truncate`,children:e.split(`/`).slice(-2).join(`/`)},e))})]}),(e.filesModified?.length??0)>0&&(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Files Modified`}),(0,I.jsx)(`ul`,{className:`text-[11px] text-ink-subtle space-y-0.5`,children:e.filesModified.map(e=>(0,I.jsx)(`li`,{className:`font-mono truncate`,children:e.split(`/`).slice(-2).join(`/`)},e))})]}),(0,I.jsx)(NU,{sessionId:e.sessionId,isLive:t,parentEntries:s,onOpenRun:n},e.sessionId)]})}function NU({sessionId:e,isLive:t,parentEntries:n,onOpenRun:r}){let{data:i,isLoading:a,isError:o}=L({queryKey:z.sessionSubagents(e),queryFn:()=>xr(e),retry:!1,refetchInterval:t?1e4:!1}),{data:s}=L({queryKey:z.workflows,queryFn:Br,refetchInterval:t?1e4:3e4}),c=(0,F.useMemo)(()=>{let t={};if(!Array.isArray(s))return t;for(let n of s)n.parentSessionId===e&&(t[n.runId]=n.status);return t},[s,e]),l=(0,F.useMemo)(()=>i?.agents??[],[i]),u=(0,F.useMemo)(()=>{let e=i!==void 0&&(i.agents?.length??0)>0,t=e?i.window.startMs:null,r=e?i.window.endMs:null,a=null,o=null;for(let e of n){let t=e.timestamp,n=e.timestamp+(e.durationMs??50);(a===null||t<a)&&(a=t),(o===null||n>o)&&(o=n)}let s=[a,t].filter(e=>e!==null),c=[o,r].filter(e=>e!==null);return s.length===0||c.length===0?null:{startMs:Math.min(...s),endMs:Math.max(...c)}},[i,n]),d=(0,F.useMemo)(()=>n.map(e=>({timestamp:e.timestamp,toolName:e.toolName,durationMs:e.durationMs,success:e.success,filePath:e.filePath,command:e.command})),[n]);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Session trace`}),(0,I.jsx)(B,{tone:`static`,padding:`sm`,children:a?(0,I.jsx)(U,{variant:`loading`,icon:`radar`,title:`Loading subagents`}):o||i===void 0?(0,I.jsx)(Ca,{sessionId:e,parentEntries:d,agents:[],window:u??{startMs:0,endMs:1},onSelectRun:r,runStatusById:c}):(0,I.jsx)(Ca,{sessionId:e,parentEntries:d,agents:l,window:u??i.window,onSelectRun:r,runStatusById:c})})]})}function PU({breakdownEntries:e,totalCalls:t,isLive:n,sessionId:r}){let[i,a]=(0,F.useState)(`calls`),o=`/api/context?sessionId=${encodeURIComponent(r)}`,{data:s}=L({queryKey:[`context`,r],queryFn:()=>fetch(o).then(e=>e.ok?e.json():null),refetchInterval:1e4,enabled:n&&i===`context`}),c=s?.toolContributions??[],l=c.length>0?c[0].estimatedTokens:0;return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,I.jsx)(V,{children:`Tools`}),n&&(0,I.jsx)(ai,{value:i,onChange:a,options:[{value:`calls`,label:`Calls`},{value:`context`,label:`Context`}],size:`sm`,tone:`cyan`,ariaLabel:`Tools view`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i===`calls`&&e.map(([e,n])=>{let r=t>0?n/t*100:0;return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`w-28 text-ink-subtle truncate`,title:e,children:wi(e)}),(0,I.jsx)(`div`,{className:`flex-1 h-3 bg-surface-3 relative rounded`,children:(0,I.jsx)(`div`,{className:`h-3 rounded ${jU(e)}`,style:{width:`${r}%`}})}),(0,I.jsx)(`span`,{className:`w-10 text-right text-ink-muted tabular-nums`,children:n})]},e)}),i===`context`&&c.map(e=>{let t=l>0?e.estimatedTokens/l*100:0;return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`w-28 text-ink-subtle truncate`,title:e.tool,children:wi(e.tool)}),(0,I.jsx)(`div`,{className:`flex-1 h-3 bg-surface-3 relative rounded`,children:(0,I.jsx)(`div`,{className:`h-3 rounded bg-accent-amber/80`,style:{width:`${t}%`}})}),(0,I.jsxs)(`span`,{className:`w-16 text-right text-ink-muted tabular-nums text-[10px]`,children:[`~`,FU(e.estimatedTokens)]})]},e.tool)}),i===`context`&&c.length===0&&(0,I.jsx)(`div`,{className:`text-[11px] text-ink-muted`,children:`No context data available yet`})]})]})}function FU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function IU({timeline:e}){let t=(0,F.useMemo)(()=>{if(e.length<2)return null;let t=e[0].timestamp,n=e[e.length-1].timestamp,r=n-t;if(r<1e3)return null;let i=hU(r),a=mU(e,{startMs:t,endMs:n+i,bucketSizeMs:i});return{buckets:a,maxCount:Math.max(...a,1),bucketSizeMs:i,startMs:t}},[e]);return t?(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(V,{className:`mb-1`,children:`Activity Density`}),(0,I.jsx)(NH,{variant:`strip`,buckets:t.buckets,maxCount:t.maxCount,bucketSizeMs:t.bucketSizeMs,startTimestamp:t.startMs,ariaLabel:`Session activity density`})]}):null}var LU={fill:`var(--color-ink-muted)`,fontSize:10},RU=`var(--color-border-subtle)`,zU={background:`var(--color-bg-elevated)`,border:`1px solid var(--color-border-medium)`,borderRadius:8,fontSize:12,color:`var(--color-ink-base)`},BU=`var(--color-accent-green)`,VU=`var(--color-accent-amber)`,HU=`var(--color-accent-green)`,UU=`var(--color-accent-purple)`,WU=`var(--color-accent-blue)`,GU=`var(--color-accent-teal)`;function KU(e){return e===`Read`?WU:e===`Edit`||e===`Write`?HU:e===`Bash`?UU:e===`Agent`?GU:`var(--color-ink-muted)`}function qU(e){let t=e.toLowerCase();return t===`bug fix`||t===`fix`?`#FF6B6B`:t===`feature`?HU:t===`refactor`?WU:t===`configuration`||t===`config`?VU:t===`test`?GU:t===`docs`?`#C4B5FD`:UU}function JU(e){return typeof e==`string`&&e.length>=10?e.slice(5,10):e}var YU=`Compares session outcomes before and after your most recent change to an instruction file (CLAUDE.md, or the active platform's equivalent) — success rate, token usage, and thrashing incidents. A degraded verdict means sessions got worse after the edit, not better.`;function XU({label:e,value:t}){return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-[10px] text-ink-muted uppercase tracking-wider`,children:e}),(0,I.jsx)(`div`,{className:`text-sm font-bold tabular-nums mt-0.5`,children:t})]})}function ZU({data:e}){if(!e)return(0,I.jsx)($U,{title:`Instruction Drift`,tooltip:YU,children:(0,I.jsx)(U,{variant:`loading`,title:`Loading drift data…`})});let t=e.recentCorrelations[e.recentCorrelations.length-1];return t?(0,I.jsx)($U,{title:`Instruction Drift — most recent instruction file change`,tooltip:YU,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,I.jsx)(ei,{tone:{improved:`success`,degraded:`danger`,neutral:`neutral`,insufficient_data:`neutral`}[t.verdict],children:t.verdict}),(0,I.jsx)(XU,{label:`Success`,value:t.successRateDelta===null?`—`:`${t.successRateDelta>0?`+`:``}${Math.round(t.successRateDelta*100)}%`}),(0,I.jsx)(XU,{label:`Tokens`,value:`${t.tokensDelta>0?`+`:``}${t.tokensDelta}`}),(0,I.jsx)(XU,{label:`Thrashing`,value:`${t.thrashingDelta>0?`+`:``}${t.thrashingDelta}`})]})}):(0,I.jsx)($U,{title:`Instruction Drift`,tooltip:YU,children:(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:`No instruction file changes tracked yet.`})})}function QU(){let e=L({queryKey:z.weekly,queryFn:hr}),t=L({queryKey:z.sessionsList(200),queryFn:()=>ar(200)}),n=L({queryKey:z.costPerOutcome(30),queryFn:()=>_r(30)}),r=L({queryKey:z.personalCoach,queryFn:vr}),i=L({queryKey:z.activityHeatmap(`history`),queryFn:()=>kr(`history`,12)}),a=L({queryKey:z.concurrencyHistory(30),queryFn:()=>Or(30)}),o=L({queryKey:z.instructionDrift,queryFn:Hr}),s=e.isError||t.isError||n.isError||a.isError,c=[...e.data??[]].reverse(),l=c.map(e=>{let t=e.avgEfficiencyScore;return{week:e.week||`?`,efficiency:t===null?null:Math.round(t*100)}}),u=iW(nW(t.data??[],30),30),d=rW(n.data),f=aW(c),p=sW(t.data??[]),m=cW(t.data??[]),h=a.data?.dailyPeaks??[],g=h.some(e=>e.peak>0);return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`history`}),(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text mb-4`,children:`History`}),s&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs mb-3`,children:`Error loading some history data. Charts below may be incomplete.`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)($U,{title:`Weekly Efficiency · Last 12`,children:(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(aH,{data:l,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`effGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:BU,stopOpacity:.3}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:BU,stopOpacity:0})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`week`,tick:LU,stroke:RU,tickFormatter:JU}),(0,I.jsx)(fB,{tick:LU,stroke:RU,domain:[0,100],unit:`%`}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(xR,{type:`monotone`,dataKey:`efficiency`,stroke:BU,strokeWidth:2,fill:`url(#effGradient)`,dot:{r:2,fill:BU}})]})})})}),(0,I.jsx)($U,{title:`Daily Spend · Last 30 Days (most recent 200)`,children:(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:u,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`costGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:BU,stopOpacity:.9}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:BU,stopOpacity:.4})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`day`,tick:LU,stroke:RU,tickFormatter:JU,interval:`preserveStartEnd`,minTickGap:20}),(0,I.jsx)(fB,{tick:LU,stroke:RU,unit:`$`}),(0,I.jsx)(ZA,{contentStyle:zU,labelFormatter:e=>JU(String(e)),cursor:!1}),(0,I.jsx)(Az,{dataKey:`cost`,fill:`url(#costGradient)`,radius:[3,3,0,0]})]})})})}),(0,I.jsx)($U,{title:`Cost Per Outcome · Last 30 Days`,children:d.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No outcomes yet`,subtitle:`Finish a few sessions and check back.`}):(0,I.jsx)(`div`,{className:`min-w-0`,style:{height:`${Math.max(176,d.length*32+40)}px`},children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:d,layout:`vertical`,children:[(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{type:`number`,tick:LU,stroke:RU,unit:`$`}),(0,I.jsx)(fB,{type:`category`,dataKey:`outcome`,tick:LU,stroke:RU,width:110}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(Az,{dataKey:`totalCost`,radius:[0,3,3,0],children:d.map(e=>(0,I.jsx)(QA,{fill:qU(e.outcome),fillOpacity:.8},e.outcome))})]})})})}),(0,I.jsx)($U,{title:`Anti-Pattern Frequency · Weekly`,children:f.length===0?(0,I.jsx)(U,{icon:`checkmark`,title:`No anti-patterns detected`,subtitle:`No anti-patterns detected in the loaded weeks.`}):(0,I.jsx)(`div`,{className:`h-44 min-w-0`,children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:f,children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`linearGradient`,{id:`antiPatternGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,I.jsx)(`stop`,{offset:`0%`,stopColor:VU,stopOpacity:.9}),(0,I.jsx)(`stop`,{offset:`100%`,stopColor:VU,stopOpacity:.4})]})}),(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{dataKey:`week`,tick:LU,stroke:RU,tickFormatter:JU}),(0,I.jsx)(fB,{tick:LU,stroke:RU}),(0,I.jsx)(ZA,{contentStyle:zU}),(0,I.jsx)(Az,{dataKey:`count`,fill:`url(#antiPatternGradient)`,radius:[3,3,0,0]})]})})})}),(0,I.jsx)($U,{title:`Model Performance`,children:p.length===0?(0,I.jsx)(U,{icon:`radar`,title:`No model data yet`,subtitle:`Complete a few sessions to see model performance.`}):(0,I.jsxs)(`div`,{className:`h-44 overflow-y-auto text-xs`,children:[(0,I.jsxs)(`table`,{className:`w-full`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted sticky top-0 bg-bg-panel`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left pb-1`,children:`Model`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Sessions`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Eff.`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Success`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`Avg $`}),(0,I.jsx)(`th`,{className:`text-right pb-1`,children:`$/1M tok`})]})}),(0,I.jsx)(`tbody`,{children:p.map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-bg-line`,children:[(0,I.jsx)(`td`,{className:`py-1 font-medium`,children:e.model}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.sessions}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.avgEfficiency===null?`—`:`${Math.min(100,Math.round(e.avgEfficiency*100))}%`}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums ${e.flagged?`text-accent-amber`:``}`,children:e.avgSuccessRate===null?`—`:`${Math.min(100,Math.round(e.avgSuccessRate*100))}%`}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:Si(e.avgCost)}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums text-ink-subtle`,children:Si(e.costPerMillionTokens)})]},e.model))})]}),p.some(e=>e.flagged)&&(0,I.jsx)(`div`,{className:`text-accent-amber text-[10px] mt-1`,children:`⚠ Highlighted models had sessions with elevated error rates`})]})}),(0,I.jsx)($U,{title:`Top Tools · Most Recent 200 Sessions`,children:m.length===0?(0,I.jsx)(U,{icon:`code`,title:`No tool data yet`,subtitle:`Tool usage data will appear after coding sessions.`}):(0,I.jsx)(`div`,{className:`min-w-0`,style:{height:`${Math.max(176,m.length*28+40)}px`},children:(0,I.jsx)(rm,{width:`100%`,height:`100%`,minWidth:1,minHeight:1,children:(0,I.jsxs)(rH,{data:m,layout:`vertical`,children:[(0,I.jsx)(_L,{stroke:RU,strokeDasharray:`3 3`}),(0,I.jsx)(Zz,{type:`number`,tick:LU,stroke:RU}),(0,I.jsx)(fB,{type:`category`,dataKey:`tool`,tick:LU,tickFormatter:wi,stroke:RU,width:120}),(0,I.jsx)(ZA,{contentStyle:zU,labelFormatter:e=>wi(String(e))}),(0,I.jsx)(Az,{dataKey:`count`,radius:[0,3,3,0],children:m.map(e=>(0,I.jsx)(QA,{fill:KU(wi(e.tool)),fillOpacity:.8},e.tool))})]})})})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mt-3`,children:[i.data&&i.data.days.length>0&&(0,I.jsx)($U,{title:`Activity · Last 12 Weeks`,children:(0,I.jsx)(NH,{variant:`grid`,buckets:[],maxCount:i.data.maxCount,days:i.data.days,ariaLabel:`Daily activity heatmap for the last 12 weeks`})}),(0,I.jsxs)(B,{padding:`md`,className:`flex flex-col`,children:[(0,I.jsxs)(V,{className:`mb-3`,children:[`Peak Concurrent Sessions · Last 30 Days`,g&&`: ${Math.max(...h.map(e=>e.peak))}`]}),g?(0,I.jsx)(`div`,{className:`flex-1 flex items-end justify-center`,children:(0,I.jsx)(lW,{data:h})}):(0,I.jsx)(U,{icon:`code`,title:`No concurrent sessions yet`,subtitle:`Run two or more Claude Code sessions at the same time to populate this chart.`})]})]}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(ZU,{data:o.data})}),(0,I.jsx)(`div`,{className:`mt-3`,children:(0,I.jsx)(tW,{data:r.data})})]})}function $U({title:e,tooltip:t,children:n}){return(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(V,{children:e}),t&&(0,I.jsx)(ci,{text:t})]}),(0,I.jsx)(`div`,{className:`mt-3`,children:n})]})}function eW({thisWeek:e,baseline:t}){let n=e.avgEfficiencyScore!==null&&t.avgEfficiencyScore!==null?Math.round((e.avgEfficiencyScore-t.avgEfficiencyScore)*100):null,r=t.avgCostPerSession>0?(e.avgCostPerSession-t.avgCostPerSession)/t.avgCostPerSession:null,i=t.antiPatternRate>0?(e.antiPatternRate-t.antiPatternRate)/t.antiPatternRate:null,a=Math.round(e.sessionsCount-t.sessionsCount);function o(e){return e===null?`text-ink-muted`:e>=5?`text-accent-green`:e<=-5?`text-accent-amber`:`text-ink-muted`}function s(e){return e===null?`text-ink-muted`:e<=-.15?`text-accent-green`:e>=.25?`text-accent-amber`:`text-ink-muted`}function c(e){return e===null?`text-ink-muted`:e<=-.2?`text-accent-green`:e>=.25?`text-accent-amber`:`text-ink-muted`}function l(e){return e===null?`—`:e===0?`0pts`:`${e>0?`↑`:`↓`}${Math.abs(e)}pts`}function u(e){return e===null?`—`:e===0?`0%`:`${e>0?`↑`:`↓`}${Math.abs(Math.round(e*100))}%`}function d(e){return e===0?`0`:e>0?`+${e}`:`${e}`}let f=e.avgEfficiencyScore===null?`—`:Math.round(e.avgEfficiencyScore*100).toString();return(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-x-4 gap-y-1 text-xs mb-3`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted`}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`This wk`}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`vs baseline`}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Efficiency`}),(0,I.jsx)(`span`,{className:`font-mono`,children:f}),(0,I.jsx)(`span`,{className:o(n),children:l(n)}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Cost / session`}),(0,I.jsxs)(`span`,{className:`font-mono`,children:[`$`,e.avgCostPerSession.toFixed(2)]}),(0,I.jsx)(`span`,{className:s(r),children:u(r)}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Anti-pattern rate`}),(0,I.jsxs)(`span`,{className:`font-mono`,children:[(e.antiPatternRate*100).toFixed(1),`%`]}),(0,I.jsx)(`span`,{className:c(i),children:u(i)}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Sessions`}),(0,I.jsx)(`span`,{className:`font-mono`,children:Math.round(e.sessionsCount)}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:d(a)})]})}function tW({data:e}){return e?e.status===`insufficient_data`?(0,I.jsx)($U,{title:`Personal Coach`,children:(0,I.jsx)(`div`,{className:`text-ink-muted text-xs`,children:e.message})}):(0,I.jsx)($U,{title:`Personal coach`,children:(0,I.jsxs)(`div`,{className:`text-xs space-y-2`,children:[(0,I.jsx)(eW,{thisWeek:e.thisWeek,baseline:e.baseline}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-accent-cyan font-semibold`,children:`Top recommendation: `}),e.topRecommendation]}),e.highlights.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-accent-green`,children:e.highlights.map(e=>(0,I.jsx)(`li`,{children:e},`hl-${e}`))}),e.regressions.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-accent-amber`,children:e.regressions.map(e=>(0,I.jsx)(`li`,{children:e},`rg-${e}`))}),e.streaks.length>0&&(0,I.jsx)(`ul`,{className:`list-disc list-inside text-ink-muted`,children:e.streaks.map(e=>(0,I.jsx)(`li`,{children:e},`st-${e}`))})]})}):(0,I.jsx)($U,{title:`Personal Coach`,children:(0,I.jsx)(U,{variant:`loading`,title:`Loading coaching insights…`})})}function nW(e,t){let n=new Map;for(let t of e){if(t.estimatedCostUsd==null||t.startTime==null)continue;let e=new Date(t.startTime),r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;n.set(r,(n.get(r)??0)+t.estimatedCostUsd)}return Array.from(n.entries()).sort((e,t)=>e[0].localeCompare(t[0])).slice(-t).map(([e,t])=>({day:e,cost:Number(t.toFixed(2))}))}function rW(e){return e?Object.entries(e.outcomeDistribution).map(([e,t])=>({outcome:e.replace(/_/g,` `),totalCost:Number(t.totalCost.toFixed(2)),count:t.count})).filter(e=>e.totalCost>0).sort((e,t)=>t.totalCost-e.totalCost):[]}function iW(e,t,n=new Date){let r=new Map(e.map(e=>[e.day,e.cost])),i=[];for(let e=t-1;e>=0;e--){let t=new Date(n);t.setDate(t.getDate()-e);let a=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;i.push({day:a,cost:r.get(a)??0})}return i}function aW(e){let t=[];for(let n of e){let e=n.antiPatternCounts??{},r=Object.values(e).reduce((e,t)=>e+t,0);r>0&&t.push({week:n.week||`?`,count:r})}return t}var oW=.85;function sW(e){let t=new Map;for(let n of e){let e=n.model??`unknown`,r=t.get(e);r||(r={sessions:0,effSum:0,effCount:0,successSum:0,successCount:0,costSum:0,costCount:0,blendedCostSum:0,blendedTokensSum:0,lowSuccessSessions:0},t.set(e,r)),r.sessions++,n.efficiencyScore!=null&&(r.effSum+=n.efficiencyScore,r.effCount++),n.toolSuccessRate!=null&&(r.successSum+=n.toolSuccessRate,r.successCount++,n.toolSuccessRate<oW&&r.lowSuccessSessions++),n.estimatedCostUsd!=null&&(r.costSum+=n.estimatedCostUsd,r.costCount++,(n.tokensInput!=null||n.tokensOutput!=null)&&(r.blendedCostSum+=n.estimatedCostUsd,r.blendedTokensSum+=(n.tokensInput??0)+(n.tokensOutput??0)))}let n=[];for(let[e,r]of t)n.push({model:e,sessions:r.sessions,avgEfficiency:r.effCount>0?r.effSum/r.effCount:null,avgSuccessRate:r.successCount>0?r.successSum/r.successCount:null,avgCost:r.costCount>0?r.costSum/r.costCount:null,costPerMillionTokens:r.blendedTokensSum>0?r.blendedCostSum/r.blendedTokensSum*1e6:null,flagged:r.lowSuccessSessions>0});return n.sort((e,t)=>t.sessions-e.sessions)}function cW(e){let t=new Map;for(let n of e)if(n.toolBreakdown)for(let[e,r]of Object.entries(n.toolBreakdown))t.set(e,(t.get(e)??0)+r);return Array.from(t.entries()).map(([e,t])=>({tool:e,count:t})).sort((e,t)=>t.count-e.count).slice(0,8)}function lW({data:e}){return(0,I.jsx)(TH,{data:e.map(e=>({count:e.peak,tooltip:`${e.date.slice(5)}: ${e.peak}`})),ariaLabel:`Peak concurrent sessions over ${e.length} days`})}var uW=[{key:`all`,label:`All`},{key:`sensitive_file`,label:`Sensitive files`},{key:`destructive_command`,label:`Destructive`},{key:`external_network`,label:`External network`}],dW={critical:`danger`,high:`warning`,medium:`info`};function fW(e){let t=e.map(e=>JSON.stringify(e)).join(`
|
|
64
|
+
`),n=new Blob([t],{type:`application/x-ndjson`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`audit-${new Date().toISOString().slice(0,10)}.jsonl`,i.rel=`noopener`,document.body.appendChild(i);try{i.click()}finally{document.body.removeChild(i),URL.revokeObjectURL(r)}}function pW(){let[e,t]=(0,F.useState)(`all`),{data:n,isLoading:r,error:i}=L({queryKey:z.audit,queryFn:()=>mr()}),a=n??[],o=e===`all`?a:a.filter(t=>t.classification===e),s=o.slice(0,200);return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`audit`}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Audit`}),(0,I.jsx)(Xr,{variant:`secondary`,size:`md`,onClick:()=>fW(s),children:`Export JSONL`})]}),(0,I.jsx)(`div`,{className:`flex gap-2 mb-3 flex-wrap`,children:uW.map(({key:n,label:r})=>(0,I.jsx)(Xr,{variant:e===n?`primary`:`secondary`,size:`sm`,onClick:()=>t(n),children:r},n))}),r&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading audit log.`}),!r&&!i&&o.length>200&&(0,I.jsxs)(`div`,{className:`text-[11px] text-ink-muted mb-2`,children:[`Showing first `,200,` of `,o.length,` entries.`]}),!r&&!i&&(0,I.jsx)(B,{padding:`sm`,tone:`static`,className:`overflow-hidden`,children:(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted bg-surface-3`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left p-2`,children:`When`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Tool`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Target`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Classification`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Session`})]})}),(0,I.jsxs)(`tbody`,{children:[o.length===0&&(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:5,className:`p-3 text-ink-muted text-center`,children:`No matching entries.`})}),s.map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`p-2 tabular-nums`,children:new Date(e.ts).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}),(0,I.jsx)(`td`,{className:`p-2`,children:e.tool}),(0,I.jsx)(`td`,{className:`p-2 font-mono text-[11px]`,children:e.target}),(0,I.jsx)(`td`,{className:`p-2`,children:(0,I.jsx)(ei,{tone:e.severity?dW[e.severity]??`neutral`:`neutral`,size:`sm`,children:uW.find(t=>t.key===e.classification)?.label??e.classification})}),(0,I.jsx)(`td`,{className:`p-2 text-ink-subtle`,children:e.sessionId??`—`})]},`${e.ts}-${e.tool}-${e.target}`))]})]})})]})}var mW={info:`border-l-accent-blue bg-accent-blue/5`,warning:`border-l-accent-amber bg-accent-amber/5`,critical:`border-l-accent-red bg-accent-red/5`},hW={info:`info`,warning:`warning`,critical:`danger`},gW={resolved:`text-accent-green`,aborted:`text-accent-red`,pending:`text-accent-amber`},_W={merge_conflict:`bg-accent-red/20 text-accent-red`,rebase_conflict:`bg-accent-red/20 text-accent-red`,merge_abort:`bg-accent-amber/20 text-accent-amber`,rebase_abort:`bg-accent-amber/20 text-accent-amber`,force_push:`bg-accent-red/20 text-accent-red`,reset_hard:`bg-accent-amber/20 text-accent-amber`,commit:`bg-accent-green/20 text-accent-green`,push:`bg-accent-blue/20 text-accent-blue`,pull:`bg-accent-blue/20 text-accent-blue`};function vW(e){return e===null?`—`:e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function yW(e){return e.replace(/_/g,` `)}function bW({score:e}){if(e===null)return(0,I.jsx)(`div`,{className:`flex items-center justify-center w-20 h-20 rounded-full border-4 border-border-medium`,children:(0,I.jsx)(`span`,{className:`text-ink-muted text-xs`,children:`N/A`})});let t=Math.max(0,Math.min(100,e)),[n,r]=t>=80?[`text-accent-green`,`border-accent-green`]:t>=60?[`text-accent-amber`,`border-accent-amber`]:[`text-accent-red`,`border-accent-red`],i=2*Math.PI*34,a=i-t/100*i;return(0,I.jsxs)(`div`,{className:`relative w-20 h-20`,children:[(0,I.jsxs)(`svg`,{className:`w-20 h-20 -rotate-90`,viewBox:`0 0 80 80`,children:[(0,I.jsx)(`circle`,{cx:`40`,cy:`40`,r:`34`,fill:`none`,stroke:`rgba(255,255,255,0.08)`,strokeWidth:`6`}),(0,I.jsx)(`circle`,{cx:`40`,cy:`40`,r:`34`,fill:`none`,className:r,stroke:`currentColor`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:i,strokeDashoffset:a,style:{transition:`stroke-dashoffset 0.8s ease-out`}})]}),(0,I.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-lg font-bold ${n}`,children:e})]})}function xW(){let{data:e,isLoading:t,error:n}=L({queryKey:z.gitEfficiency,queryFn:Tr,refetchInterval:5e3}),{data:r}=L({queryKey:z.gitEfficiencyRepos,queryFn:Er,refetchInterval:3e4});return t?(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}):n?(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading git efficiency data.`}):!e||e.totalGitCommands===0?(0,I.jsxs)(I.Fragment,{children:[r&&r.repos.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-4`,children:[(0,I.jsx)(V,{as:`div`,className:`mr-1`,children:`Repos Today:`}),r.repos.map(e=>{let t=e.split(`/`).pop()||e;return(0,I.jsx)(ei,{tone:e===r.currentRepo?`success`:`neutral`,size:`sm`,bordered:!0,className:`font-mono`,children:t},e)})]}),(0,I.jsx)(U,{icon:`code`,title:`No Git activity yet`,subtitle:`Git efficiency metrics will appear here as git commands are executed during the session.`})]}):(0,I.jsxs)(`section`,{children:[(0,I.jsx)(LH,{theme:`git`}),(0,I.jsxs)(`header`,{className:`flex items-baseline justify-between mb-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Git Efficiency`}),e.repoContext.repoName&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[11px] text-ink-muted`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.repoContext.repoName}),e.repoContext.branch&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`/`}),(0,I.jsx)(`span`,{className:`font-mono text-ink-subtle`,children:e.repoContext.branch})]})]}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-ink-muted`,children:`Today's activity across all sessions`}),r&&r.repos.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted uppercase tracking-wider mr-1`,children:`Repos today:`}),r.repos.map(e=>{let t=e.split(`/`).pop()||e;return(0,I.jsx)(ei,{tone:e===r.currentRepo?`success`:`neutral`,size:`sm`,bordered:!0,className:`font-mono`,children:t},e)})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(V,{as:`div`,className:`mb-1`,children:`Prevention`}),(0,I.jsx)(bW,{score:e.preventionScore})]}),(0,I.jsxs)(`div`,{className:`text-center`,children:[(0,I.jsx)(V,{as:`div`,className:`mb-1`,children:`Efficiency`}),(0,I.jsx)(bW,{score:e.efficiencyScore})]})]})]}),(0,I.jsx)(Yi,{index:0,className:`mb-3`,children:(0,I.jsx)(B,{padding:`lg`,tone:`elevated`,glow:`green`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4`,children:[(0,I.jsx)(Ji,{label:`commits today`,hero:!0,value:String(e.commitCount),animate:!0,numericValue:e.commitCount}),(0,I.jsx)(Ji,{label:`PRs opened`,tone:e.prMetrics.created>0?`good`:`neutral`,value:String(e.prMetrics.created),sub:e.prMetrics.merged>0?`${e.prMetrics.merged} merged`:void 0,animate:!0,numericValue:e.prMetrics.created}),(0,I.jsx)(Ji,{label:`conflicts`,tone:e.mergeConflicts+e.rebaseConflicts>0?`bad`:`good`,value:String(e.mergeConflicts+e.rebaseConflicts),sub:e.mergeConflicts+e.rebaseConflicts===0?`clean session`:`${e.abortedOperations} aborted`,animate:!0,numericValue:e.mergeConflicts+e.rebaseConflicts}),(0,I.jsx)(Ji,{label:`behind main`,tone:(e.riskIndicators.commitsBehindMain??0)>20?`bad`:(e.riskIndicators.commitsBehindMain??0)>5?`warn`:`good`,value:e.riskIndicators.commitsBehindMain===null?`—`:String(e.riskIndicators.commitsBehindMain),sub:e.riskIndicators.commitsBehindMain===0?`up to date`:e.riskIndicators.commitsBehindMain!==null&&e.riskIndicators.commitsBehindMain>10?`rebase soon`:void 0,animate:!0,numericValue:e.riskIndicators.commitsBehindMain??0})]})})}),e.bestPractices.length>0&&(0,I.jsx)(Yi,{index:1,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Best Practices`,action:(0,I.jsx)(`span`,{className:`text-[11px] text-ink-muted`,children:(()=>{let t=e.bestPractices.filter(e=>e.status!==`unknown`).length;return t===0?`No data yet`:`${e.bestPractices.filter(e=>e.status===`pass`).length}/${t} passing`})()})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[e.bestPractices.filter(e=>e.status===`pass`).map(e=>(0,I.jsxs)(ei,{tone:`success`,size:`sm`,bordered:!0,children:[(0,I.jsx)(`span`,{children:`✓`}),` `,e.label]},e.id)),e.bestPractices.filter(e=>e.status===`unknown`).map(e=>(0,I.jsxs)(ei,{tone:`neutral`,size:`sm`,bordered:!0,children:[(0,I.jsx)(`span`,{children:`●`}),` `,e.label]},e.id))]}),e.bestPractices.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>(0,I.jsxs)(`div`,{className:`flex items-start gap-2 px-2.5 py-2 rounded-lg mt-1.5 ${e.status===`fail`?`bg-accent-red/5 border border-accent-red/20`:`bg-accent-amber/5 border border-accent-amber/20`}`,children:[(0,I.jsx)(`span`,{className:`shrink-0 mt-0.5 text-xs`,children:e.status===`fail`?(0,I.jsx)(`span`,{className:`text-accent-red`,children:`✗`}):(0,I.jsx)(`span`,{className:`text-accent-amber`,children:`⚠`})}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-ink-base`,children:e.label}),(0,I.jsx)(`div`,{className:`text-[11px] text-ink-muted mt-0.5 leading-relaxed`,children:e.detail})]})]},e.id))]})}),(e.mergeConflicts>0||e.rebaseConflicts>0)&&(0,I.jsx)(Yi,{index:2,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Conflict Resolution`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Resolution rate`,value:e.conflictResolutionRate===null?`—`:`${Math.round(e.conflictResolutionRate*100)}%`}),(0,I.jsx)(Ji,{label:`Avg resolution time`,value:vW(e.avgConflictResolutionMs)}),(0,I.jsx)(Ji,{label:`Aborted ops`,value:String(e.abortedOperations)}),(0,I.jsx)(Ji,{label:`Stale branch pulls`,value:String(e.staleBranchPulls)})]}),e.conflictHistory.length>0&&(0,I.jsxs)(`div`,{className:`mt-3`,children:[(0,I.jsx)(V,{as:`h3`,className:`mb-2`,children:`Conflict History`}),(0,I.jsx)(`div`,{className:`space-y-1`,children:e.conflictHistory.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs py-1 border-t border-border-subtle`,children:[(0,I.jsx)(`span`,{className:`tabular-nums text-ink-subtle w-28 shrink-0`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})}),(0,I.jsx)(`span`,{className:`font-medium ${gW[e.resolution]}`,children:e.resolution}),(0,I.jsx)(`span`,{className:`text-ink-muted`,children:vW(e.resolutionTimeMs)}),(0,I.jsx)(`span`,{className:`text-ink-subtle font-mono text-[11px] truncate`,children:e.command})]},`${e.timestamp}-${e.command}`))})]})]})}),e.suggestions.length>0&&(0,I.jsx)(Yi,{index:3,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Suggestions`}),(0,I.jsx)(`div`,{className:`space-y-2`,children:e.suggestions.map((e,t)=>(0,I.jsx)(`div`,{className:`border-l-[3px] rounded-r-lg px-3 py-2 ${mW[e.severity]}`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(ei,{tone:hW[e.severity],size:`sm`,className:`font-semibold`,children:e.severity}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-xs text-ink-base`,children:e.message}),(0,I.jsx)(`p`,{className:`text-[11px] text-ink-muted mt-0.5`,children:e.evidence})]})]})},`${e.category}-${e.severity}-${t}`))})]})}),e.commitCount>=2&&(0,I.jsx)(Yi,{index:4,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Velocity & Workflow`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Avg time between commits`,value:vW(e.velocityMetrics.avgTimeBetweenCommitsMs)}),(0,I.jsx)(Ji,{label:`Longest gap`,value:vW(e.velocityMetrics.longestGapMs)}),(0,I.jsx)(Ji,{label:`Commit bursts`,value:String(e.velocityMetrics.commitBurstCount)}),(0,I.jsx)(Ji,{label:`Worktree ops`,value:String(e.velocityMetrics.worktreeCount)})]}),e.velocityMetrics.buildBeforePush!==null&&(0,I.jsxs)(`div`,{className:`mt-3 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`Verified before push: `}),e.velocityMetrics.buildBeforePush?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`yes (build/test ran first)`}):(0,I.jsx)(`span`,{className:`text-accent-amber`,children:`no build/test detected before push`})]})]})}),(e.prMetrics.created>0||e.prMetrics.merged>0||e.prMetrics.checksViewed>0)&&(0,I.jsx)(Yi,{index:5,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Pull Requests`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`PRs created`,value:String(e.prMetrics.created),tone:e.prMetrics.created>0?`good`:`neutral`}),(0,I.jsx)(Ji,{label:`PRs merged`,value:String(e.prMetrics.merged),tone:e.prMetrics.merged>0?`good`:`neutral`}),(0,I.jsx)(Ji,{label:`CI checks viewed`,value:String(e.prMetrics.checksViewed)}),(0,I.jsx)(Ji,{label:`Time to PR`,value:vW(e.prMetrics.avgTimeToCreateMs)})]}),e.prMetrics.prActivity.length>0&&(0,I.jsxs)(`div`,{className:`mt-3`,children:[(0,I.jsx)(V,{as:`h3`,className:`mb-2`,children:`Activity`}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.prMetrics.prActivity.map(e=>(0,I.jsxs)(ei,{tone:e.action===`create`?`success`:e.action===`merge`?`info`:`neutral`,size:`sm`,children:[e.action,e.prNumber?` #${e.prNumber}`:``]},`${e.timestamp}-${e.action}`))})]})]})}),e.conflictResolutionStrategy.totalResolutions>0&&(0,I.jsx)(Yi,{index:6,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Conflict Resolution Strategy`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,I.jsx)(Ji,{label:`Accept ours`,value:String(e.conflictResolutionStrategy.oursCount)}),(0,I.jsx)(Ji,{label:`Accept theirs`,value:String(e.conflictResolutionStrategy.theirsCount)}),(0,I.jsx)(Ji,{label:`Manual merge`,value:String(e.conflictResolutionStrategy.manualMergeCount)}),(0,I.jsx)(Ji,{label:`Cherry-picks`,value:String(e.conflictResolutionStrategy.cherryPickCount)})]})]})}),(e.resetHards>0||e.discardedChanges>0||e.forcePushes>0)&&(0,I.jsx)(Yi,{index:7,className:`mb-3`,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Destructive Operations`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,I.jsx)(Ji,{label:`Hard resets`,value:String(e.resetHards)}),(0,I.jsx)(Ji,{label:`Discarded changes`,value:String(e.discardedChanges)}),(0,I.jsx)(Ji,{label:`Force pushes`,value:String(e.forcePushes)})]})]})}),(0,I.jsx)(Yi,{index:8,children:(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Recent Git Activity`}),(0,I.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,I.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,I.jsx)(`thead`,{className:`text-ink-muted bg-surface-3 sticky top-0`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Time`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Type`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Duration`}),(0,I.jsx)(`th`,{className:`text-left p-2`,children:`Status`})]})}),(0,I.jsx)(`tbody`,{children:[...e.gitCommandTimeline].reverse().slice(0,30).map(e=>(0,I.jsxs)(`tr`,{className:`border-t border-border-subtle`,children:[(0,I.jsx)(`td`,{className:`p-2 tabular-nums text-ink-subtle`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})}),(0,I.jsx)(`td`,{className:`p-2`,children:(0,I.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${_W[e.type]??`bg-surface-8 text-ink-subtle`}`,children:yW(e.type)})}),(0,I.jsx)(`td`,{className:`p-2 tabular-nums text-ink-subtle`,children:vW(e.durationMs)}),(0,I.jsx)(`td`,{className:`p-2`,children:e.success?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`ok`}):(0,I.jsx)(`span`,{className:`text-accent-red`,children:`fail`})})]},`${e.type}-${e.timestamp}`))})]})})]})})]})}function SW({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:e}),(0,I.jsx)(`span`,{className:`text-xs font-mono text-ink-subtle bg-surface-3 px-2 py-0.5 rounded-md`,children:t??`—`})]})}function CW({label:e,value:t,onChange:n,placeholder:r,min:i}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:e}),(0,I.jsx)(`input`,{type:`number`,min:i,step:`any`,value:t??``,placeholder:r??`unlimited`,onChange:e=>{let t=e.target.value;n(t===``?null:Number(t))},className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-32 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]})}var wW={ok:`●`,warn:`▲`,fail:`✗`,skip:`–`},TW={ok:`text-accent-green`,warn:`text-accent-amber`,fail:`text-accent-red`,skip:`text-ink-muted`};function EW(){let{data:e,isLoading:t,isError:n,refetch:r}=L({queryKey:z.diagnostics,queryFn:()=>Ir(),refetchInterval:6e4,staleTime:55e3}),i=e??[],a=i.some(e=>e.status===`fail`||e.status===`warn`);return(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,I.jsx)(oi,{title:`System Health`}),(0,I.jsx)(`button`,{onClick:()=>void r(),className:`text-[10px] text-ink-muted hover:text-ink-base transition-colors`,children:`Re-check`})]}),t&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Checking system…`}),n&&(0,I.jsx)(`div`,{className:`text-xs text-accent-red`,children:`Failed to load diagnostics.`}),!t&&!n&&!a&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-accent-green`,children:[(0,I.jsx)(`span`,{children:`●`}),(0,I.jsx)(`span`,{children:`System healthy`})]}),!t&&!n&&a&&(0,I.jsx)(`div`,{className:`space-y-1.5`,children:i.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`shrink-0 ${TW[e.status]??`text-ink-muted`}`,children:wW[e.status]??`?`}),(0,I.jsx)(`span`,{className:`text-ink-muted w-36 shrink-0`,children:e.check}),(0,I.jsx)(`span`,{className:`text-ink-subtle`,children:e.detail})]}),e.fix&&(e.status===`fail`||e.status===`warn`)&&(0,I.jsxs)(`div`,{className:`ml-[1.25rem] mt-0.5 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] font-mono text-ink-subtle bg-surface-3 px-1.5 py-0.5 rounded`,children:e.fix}),(0,I.jsx)(`button`,{className:`text-[10px] text-ink-muted hover:text-ink-base transition-colors`,onClick:()=>void navigator.clipboard.writeText(e.fix??``),children:`copy`})]})]},e.check))})]})}function DW(){let e=Ye(),{data:t,isLoading:n,error:r}=L({queryKey:z.settings,queryFn:()=>Fr()}),{data:i}=L({queryKey:[`observability-health`],queryFn:zr,refetchInterval:3e4}),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(void 0),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(void 0),[p,m]=(0,F.useState)(void 0),[h,g]=(0,F.useState)(void 0),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(null),x=ut({mutationFn:e=>Lr(e),onSuccess:()=>{e.invalidateQueries({queryKey:z.settings}),b(null)},onError:e=>{b(String(e))}});if(n)return(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`});if(r||!t)return(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Failed to load settings.`});let S=a??t.developer,C=s===void 0?t.teamId:s,w=l===void 0?t.sessionBudgetUsd:l,T=d===void 0?t.dailyBudgetUsd:d,E=p===void 0?t.weeklyBudgetUsd:p,D=h===void 0?t.retainSessionsDays:h;function O(){let e={};a!==null&&(e.developer=a),s!==void 0&&(e.teamId=s),x.mutate(e,{onSuccess:()=>{v(`identity`),setTimeout(()=>v(null),3e3)}})}function k(){let e={};l!==void 0&&(e.sessionBudgetUsd=l),d!==void 0&&(e.dailyBudgetUsd=d),p!==void 0&&(e.weeklyBudgetUsd=p),h!==void 0&&(e.retainSessionsDays=h),x.mutate(e,{onSuccess:()=>{v(`budgets`),setTimeout(()=>v(null),3e3)}})}let A=e=>_===e?(0,I.jsx)(`div`,{className:`mt-2 text-xs text-accent-amber`,children:`Saved. Restart the server for changes to take effect.`}):null;return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(EW,{}),(0,I.jsxs)(`header`,{className:`mb-6`,children:[(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Settings`}),(0,I.jsx)(`p`,{className:`text-xs text-ink-muted mt-1`,children:`Changes are written to config.json on disk. Most require a server restart.`})]}),y&&(0,I.jsx)(`div`,{className:`mb-4 text-xs text-accent-red bg-accent-red/10 border border-accent-red/30 rounded-md px-3 py-2`,children:y}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Identity & Account`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:`Developer name`}),(0,I.jsx)(`input`,{type:`text`,value:S,maxLength:128,onChange:e=>o(e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-48 focus:outline-none focus:border-accent-green text-ink-base`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-36 shrink-0`,children:`Team ID`}),(0,I.jsx)(`input`,{type:`text`,value:C??``,placeholder:`optional`,onChange:e=>c(e.target.value===``?null:e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-48 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]}),(0,I.jsx)(SW,{label:`Account ID`,value:t.accountId}),(0,I.jsx)(SW,{label:`App name`,value:t.appName}),(0,I.jsx)(SW,{label:`Mode`,value:t.mode}),(0,I.jsx)(SW,{label:`Storage path`,value:t.storagePath}),(0,I.jsx)(SW,{label:`High security`,value:t.highSecurity?`enabled`:`disabled`}),(0,I.jsx)(SW,{label:`License key`,value:t.licenseKey}),(0,I.jsx)(`div`,{className:`mt-3 flex items-center gap-3`,children:(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:O,disabled:x.isPending,loading:x.isPending,children:x.isPending?`Saving…`:`Save identity`})}),A(`identity`)]}),(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Cost & Retention`,subtitle:`Budget caps trigger warnings at 50%, 80%, and 100%. Leave blank for no limit.`}),(0,I.jsx)(CW,{label:`Session budget (USD)`,value:w,onChange:u,min:.01}),(0,I.jsx)(CW,{label:`Daily budget (USD)`,value:T,onChange:f,min:.01}),(0,I.jsx)(CW,{label:`Weekly budget (USD)`,value:E,onChange:m,min:.01}),(0,I.jsx)(CW,{label:`Retain sessions (days)`,value:D,onChange:g,placeholder:`forever`,min:1}),(0,I.jsx)(`div`,{className:`mt-3 flex items-center gap-3`,children:(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:k,disabled:x.isPending,loading:x.isPending,children:x.isPending?`Saving…`:`Save budgets`})}),A(`budgets`)]}),(0,I.jsxs)(`section`,{className:`mt-8`,children:[(0,I.jsx)(V,{children:`Observability`}),(0,I.jsxs)(B,{padding:`md`,className:`mt-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium text-ink mb-3`,children:`Subagent & Workflow Watcher`}),(0,I.jsx)(`p`,{className:`text-xs text-ink-muted mb-4`,children:`Monitors subagent JSONL transcripts and workflow records to provide accurate cost tracking. Default: enabled in --stdio mode.`}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 text-xs text-ink-muted`,children:[(0,I.jsxs)(`div`,{children:[`Subagent watcher:`,` `,i?.watcherActive===!0?(0,I.jsx)(`span`,{className:`text-accent-green`,children:`enabled`}):i?.watcherActive===!1?(0,I.jsx)(`span`,{className:`text-accent-red`,children:`disabled`}):(0,I.jsx)(`span`,{className:`text-ink-muted`,children:`checking…`}),i?.watcherActive===!0&&(0,I.jsxs)(`span`,{className:`text-ink-muted`,children:[` `,`(`,i.filesWatched??0,` files watched, `,i.parseErrors??0,` parse errors)`]})]}),(0,I.jsxs)(`div`,{children:[`Set`,` `,(0,I.jsx)(`code`,{className:`font-mono bg-surface-5 px-1 rounded`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=0`}),` `,`to disable, or`,` `,(0,I.jsx)(`code`,{className:`font-mono bg-surface-5 px-1 rounded`,children:`NR_AI_ENABLE_SUBAGENT_WATCHER=1`}),` `,`to explicitly enable.`]})]})]})]})]})}function OW({pct:e,exceeded:t}){let n=e??0;return(0,I.jsx)(`div`,{className:`w-24 h-1.5 bg-surface-5 rounded-full overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${t?`bg-accent-red`:n>=80?`bg-accent-amber`:`bg-accent-green`}`,style:{width:`${Math.min(n,100)}%`}})})}function kW({label:e,p:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-ink-muted w-20 shrink-0 capitalize`,children:e}),(0,I.jsx)(OW,{pct:t.pctUsed,exceeded:t.exceeded}),(0,I.jsxs)(`span`,{className:`text-xs tabular-nums text-ink-base`,children:[xi(t.spentUsd),t.budgetUsd===null?``:` / ${xi(t.budgetUsd)}`,t.pctUsed===null?``:` (${t.pctUsed.toFixed(0)}%)`]}),t.exceeded&&(0,I.jsx)(ei,{tone:`danger`,size:`sm`,children:`exceeded`})]})}function AW(){let e=Ye(),t=L({queryKey:z.budget,queryFn:()=>gr(),refetchInterval:1e4}),n=L({queryKey:z.settings,queryFn:()=>Fr()}),r=t.data,i=n.data,[a,o]=(0,F.useState)({}),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(null),h=ut({mutationFn:e=>Lr(e),onSuccess:()=>void e.invalidateQueries({queryKey:z.settings})}),g=ut({mutationFn:()=>Rr(),onSuccess:e=>{let t=e.content[0]?.text??``;try{let e=JSON.parse(t);m(e.ok?`Digest sent.`:e.error??`Failed to send.`)}catch{m(`Done.`)}setTimeout(()=>m(null),4e3)},onError:e=>{m(`Error: ${String(e)}`)}});function _(){Object.keys(a).length!==0&&h.mutate({alerts:{personal:a}},{onSuccess:()=>{c(!0),setTimeout(()=>c(!1),3e3)}})}function v(){let e={};l!==void 0&&(e.digestWebhookUrl=l),d!==null&&(e.digestSchedule=d??i?.digestSchedule),h.mutate(e)}function y(e){return a[e]??i?.alerts.personal[e]??0}function b(e,t,n={}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-44 shrink-0`,children:e}),(0,I.jsx)(`input`,{type:`number`,value:y(t),min:n.min,max:n.max,step:n.step??`any`,onChange:e=>o(n=>({...n,[t]:Number(e.target.value)})),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-24 focus:outline-none focus:border-accent-green text-ink-base`})]})}return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`header`,{className:`mb-6`,children:(0,I.jsx)(`h1`,{className:`text-xl font-semibold gradient-text`,children:`Alerts`})}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Budget Status`}),t.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),t.isError&&(0,I.jsx)(`div`,{className:`text-accent-red text-xs`,children:`Error loading budget status.`}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(kW,{label:`session`,p:r.session}),(0,I.jsx)(kW,{label:`daily`,p:r.daily}),(0,I.jsx)(kW,{label:`weekly`,p:r.weekly}),r.alerts.length>0&&(0,I.jsxs)(`div`,{className:`mt-3 border-t border-border-subtle pt-3`,children:[(0,I.jsx)(V,{className:`mb-2`,children:`Recent Warnings`}),(0,I.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.alerts.slice(-5).reverse().map((e,t)=>(0,I.jsxs)(`div`,{className:`text-xs text-ink-subtle flex gap-2`,children:[(0,I.jsxs)(`span`,{className:`text-accent-amber tabular-nums`,children:[e.thresholdPct,`%`]}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.period}),(0,I.jsxs)(`span`,{className:`text-ink-muted tabular-nums`,children:[xi(e.spentUsd),` / `,xi(e.budgetUsd)]}),(0,I.jsx)(`span`,{className:`text-ink-muted ml-auto tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})})]},t))})]}),r.alerts.length===0&&r.session.budgetUsd===null&&r.daily.budgetUsd===null&&r.weekly.budgetUsd===null&&(0,I.jsxs)(`p`,{className:`text-xs text-ink-muted mt-2`,children:[`No budget caps configured.`,` `,(0,I.jsx)(en,{href:`/settings`,className:`text-accent-cyan hover:underline transition-colors duration-150`,children:`Set limits in Settings`}),` `,`to enable warnings.`]})]})]}),(0,I.jsxs)(B,{padding:`md`,className:`mb-4`,children:[(0,I.jsx)(oi,{title:`Alert Thresholds`,subtitle:"Thresholds used by the `deploy-alerts` CLI (`npm run deploy:alerts`) when templating cloud alert conditions. Have no effect on this dashboard or any running session."}),n.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsxs)(I.Fragment,{children:[b(`Daily cost ($)`,`dailyCostUsd`,{min:0,step:.1}),b(`Session cost ($)`,`sessionCostUsd`,{min:0,step:.1}),b(`Min efficiency score (0–1)`,`efficiencyScoreMin`,{min:0,max:1,step:.05}),b(`Max anti-patterns`,`antiPatternCountMax`,{min:0,step:1}),b(`Max stuck loops`,`stuckLoopCountMax`,{min:0,step:1}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:_,disabled:h.isPending||Object.keys(a).length===0,loading:h.isPending,children:h.isPending?`Saving…`:`Save thresholds`}),s&&(0,I.jsx)(`span`,{className:`text-xs text-accent-amber`,children:"Saved. Run `npm run deploy:alerts` to apply these to your cloud alert conditions."})]})]})]}),(0,I.jsxs)(B,{padding:`md`,children:[(0,I.jsx)(oi,{title:`Slack Digest`,subtitle:`Weekly digest sent to a Slack incoming webhook. URL changes take effect immediately.`}),n.isLoading&&(0,I.jsx)(U,{icon:`clock`,variant:`loading`,title:`Loading...`}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`flex items-center gap-2 mb-3`,children:(0,I.jsx)(ei,{tone:i.digestWebhookUrl?`success`:`neutral`,size:`sm`,children:i.digestWebhookUrl?`Configured`:`Not configured`})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsx)(`label`,{className:`text-xs text-ink-muted w-28 shrink-0`,children:`Webhook URL`}),(0,I.jsx)(`input`,{type:`url`,value:l===void 0?i.digestWebhookUrl??``:l??``,placeholder:`https://hooks.slack.com/...`,onChange:e=>u(e.target.value===``?null:e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-72 focus:outline-none focus:border-accent-green text-ink-base placeholder:text-ink-muted`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[(0,I.jsxs)(`label`,{className:`text-xs text-ink-muted w-28 shrink-0`,children:[`Schedule`,(0,I.jsx)(`span`,{className:`block text-[10px] text-ink-muted font-normal`,children:`(cron, restart req.)`})]}),(0,I.jsx)(`input`,{type:`text`,value:d??i.digestSchedule,onChange:e=>f(e.target.value),className:`text-xs bg-surface-3 border border-border-subtle rounded-md px-2 py-1 w-36 focus:outline-none focus:border-accent-green text-ink-base font-mono`}),(0,I.jsx)(`span`,{className:`text-[10px] text-ink-muted`,children:`default: Mon 9am`})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 flex-wrap`,children:[(0,I.jsx)(Xr,{variant:`primary`,size:`md`,onClick:v,disabled:h.isPending,loading:h.isPending,children:h.isPending?`Saving…`:`Save`}),i.digestWebhookUrl&&(0,I.jsx)(Xr,{variant:`danger`,size:`md`,onClick:()=>h.mutate({digestWebhookUrl:null},{onSuccess:()=>u(void 0)}),disabled:h.isPending,children:`Unsubscribe`}),(0,I.jsx)(Xr,{variant:`secondary`,size:`md`,onClick:()=>g.mutate(),disabled:g.isPending||!i.digestWebhookUrl,loading:g.isPending,children:g.isPending?`Sending…`:`Send test now`}),p&&(0,I.jsx)(`span`,{className:`text-xs text-ink-subtle`,children:p})]})]})]})]})}function jW(){zi();let e=Yn(e=>e.connected),[t,n]=qt(),[r,i]=(0,F.useState)(!1),{theme:a,toggleTheme:o}=Wi(),s=(0,F.useCallback)(()=>i(e=>!e),[]),c=(0,F.useCallback)(()=>i(!1),[]);return Bi({navigate:n,onToggleHelp:s,onToggleTheme:o}),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-col h-full mesh-bg`,children:[(0,I.jsx)(Mi,{}),(0,I.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,I.jsx)(pi,{currentPath:t,onNavigate:n,connected:e,theme:a,onToggleTheme:o}),(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-6`,children:(0,I.jsx)(Ni,{resetKey:t,children:(0,I.jsxs)(nn,{children:[(0,I.jsx)($t,{path:`/sessions`,component:OU}),(0,I.jsx)($t,{path:`/history`,component:QU}),(0,I.jsx)($t,{path:`/audit`,component:pW}),(0,I.jsx)($t,{path:`/git`,component:xW}),(0,I.jsx)($t,{path:`/settings`,component:DW}),(0,I.jsx)($t,{path:`/alerts`,component:AW}),(0,I.jsx)($t,{path:`/`,component:YH}),(0,I.jsx)($t,{children:(0,I.jsx)(`div`,{className:`text-ink-muted`,children:`Not found`})})]})})})]})]}),(0,I.jsx)(Fi,{open:r,onClose:c})]})}var MW=new Ge({defaultOptions:{queries:{staleTime:5e3,retry:0,refetchOnWindowFocus:!1}}}),NW=document.getElementById(`root`);if(!NW)throw Error(`Mount node #root not found`);(0,dt.createRoot)(NW).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(Xe,{client:MW,children:(0,I.jsx)(jW,{})})}));
|