agentic-ui-libs 0.1.5 → 0.1.7

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.
@@ -202,7 +202,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
202
202
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function u8(e,t){if(e){if(typeof e=="string")return Uc(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Uc(e,t)}}function c8(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function f8(e){if(Array.isArray(e))return Uc(e)}function Uc(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jg(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Cg(n.key),n)}}function h8(e,t,r){return t&&jg(e.prototype,t),r&&jg(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function p8(e,t,r){return t=vs(t),v8(e,$g()?Reflect.construct(t,r||[],vs(e).constructor):t.apply(e,r))}function v8(e,t){if(t&&(Kn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return y8(e)}function y8(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($g=function(){return!!e})()}function vs(e){return vs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},vs(e)}function m8(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zc(e,t)}function zc(e,t){return zc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},zc(e,t)}function Lt(e,t,r){return t=Cg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Cg(e){var t=g8(e,"string");return Kn(t)=="symbol"?t:t+""}function g8(e,t){if(Kn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Kn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var hi=function(e){function t(){var r;d8(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=p8(this,t,[].concat(a)),Lt(r,"state",{isAnimationFinished:!0,totalLength:0}),Lt(r,"generateSimpleStrokeDasharray",function(o,s){return"".concat(s,"px ").concat(o-s,"px")}),Lt(r,"getStrokeDasharray",function(o,s,l){var u=l.reduce(function(b,S){return b+S});if(!u)return r.generateSimpleStrokeDasharray(s,o);for(var c=Math.floor(o/u),f=o%u,d=s-o,h=[],v=0,y=0;v<l.length;y+=l[v],++v)if(y+l[v]>f){h=[].concat(Vn(l.slice(0,v)),[f-y]);break}var p=h.length%2===0?[0,d]:[d];return[].concat(Vn(t.repeat(l,c)),Vn(h),p).map(function(b){return"".concat(b,"px")}).join(", ")}),Lt(r,"id",$r("recharts-line-")),Lt(r,"pathRef",function(o){r.mainCurve=o}),Lt(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Lt(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return m8(t,e),h8(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,s=i.xAxis,l=i.yAxis,u=i.layout,c=i.children,f=dt(c,jn);if(!f)return null;var d=function(y,p){return{x:y.x,y:y.y,value:y.value,errorVal:Ze(y.payload,p)}},h={clipPath:n?"url(#clipPath-".concat(a,")"):null};return A.createElement(xe,h,f.map(function(v){return A.cloneElement(v,{key:"bar-".concat(v.props.dataKey),data:o,xAxis:s,yAxis:l,layout:u,dataPointFormatter:d})}))}},{key:"renderDots",value:function(n,a,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var s=this.props,l=s.dot,u=s.points,c=s.dataKey,f=de(this.props,!1),d=de(l,!0),h=u.map(function(y,p){var b=bt(bt(bt({key:"dot-".concat(p),r:3},f),d),{},{index:p,cx:y.x,cy:y.y,value:y.value,dataKey:c,payload:y.payload,points:u});return t.renderDotItem(l,b)}),v={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return A.createElement(xe,di({className:"recharts-line-dots",key:"dots"},v),h)}},{key:"renderCurveStatically",value:function(n,a,i,o){var s=this.props,l=s.type,u=s.layout,c=s.connectNulls;s.ref;var f=_g(s,i8),d=bt(bt(bt({},de(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:n},o),{},{type:l,layout:u,connectNulls:c});return A.createElement(Gr,di({},d,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var i=this,o=this.props,s=o.points,l=o.strokeDasharray,u=o.isAnimationActive,c=o.animationBegin,f=o.animationDuration,d=o.animationEasing,h=o.animationId,v=o.animateNewValues,y=o.width,p=o.height,b=this.state,S=b.prevPoints,x=b.totalLength;return A.createElement(Dt,{begin:c,duration:f,isActive:u,easing:d,from:{t:0},to:{t:1},key:"line-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(T){var m=T.t;if(S){var w=S.length/s.length,O=s.map(function($,R){var k=Math.floor(R*w);if(S[k]){var D=S[k],C=Ue(D.x,$.x),B=Ue(D.y,$.y);return bt(bt({},$),{},{x:C(m),y:B(m)})}if(v){var U=Ue(y*2,$.x),G=Ue(p/2,$.y);return bt(bt({},$),{},{x:U(m),y:G(m)})}return bt(bt({},$),{},{x:$.x,y:$.y})});return i.renderCurveStatically(O,n,a)}var P=Ue(0,x),j=P(m),M;if(l){var _="".concat(l).split(/[,\s]+/gim).map(function($){return parseFloat($)});M=i.getStrokeDasharray(j,x,_)}else M=i.generateSimpleStrokeDasharray(x,j);return i.renderCurveStatically(s,n,a,{strokeDasharray:M})})}},{key:"renderCurve",value:function(n,a){var i=this.props,o=i.points,s=i.isAnimationActive,l=this.state,u=l.prevPoints,c=l.totalLength;return s&&o&&o.length&&(!u&&c>0||!Br(u,o))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(o,n,a)}},{key:"render",value:function(){var n,a=this.props,i=a.hide,o=a.dot,s=a.points,l=a.className,u=a.xAxis,c=a.yAxis,f=a.top,d=a.left,h=a.width,v=a.height,y=a.isAnimationActive,p=a.id;if(i||!s||!s.length)return null;var b=this.state.isAnimationFinished,S=s.length===1,x=ye("recharts-line",l),T=u&&u.allowDataOverflow,m=c&&c.allowDataOverflow,w=T||m,O=fe(p)?this.id:p,P=(n=de(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},j=P.r,M=j===void 0?3:j,_=P.strokeWidth,$=_===void 0?2:_,R=ed(o)?o:{},k=R.clipDot,D=k===void 0?!0:k,C=M*2+$;return A.createElement(xe,{className:x},T||m?A.createElement("defs",null,A.createElement("clipPath",{id:"clipPath-".concat(O)},A.createElement("rect",{x:T?d:d-h/2,y:m?f:f-v/2,width:T?h:h*2,height:m?v:v*2})),!D&&A.createElement("clipPath",{id:"clipPath-dots-".concat(O)},A.createElement("rect",{x:d-C/2,y:f-C/2,width:h+C,height:v+C}))):null,!S&&this.renderCurve(w,O),this.renderErrorBar(w,O),(S||o)&&this.renderDots(w,D,O),(!y||b)&&Kt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var i=n.length%2!==0?[].concat(Vn(n),[0]):n,o=[],s=0;s<a;++s)o=[].concat(Vn(o),Vn(i));return o}},{key:"renderDotItem",value:function(n,a){var i;if(A.isValidElement(n))i=A.cloneElement(n,a);else if(he(n))i=n(a);else{var o=a.key,s=_g(a,o8),l=ye("recharts-line-dot",typeof n!="boolean"?n.className:"");i=A.createElement(Ho,di({key:o},s,{className:l}))}return i}}])}(A.PureComponent);Lt(hi,"displayName","Line"),Lt(hi,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!vr.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1}),Lt(hi,"getComposedData",function(e){var t=e.props,r=e.xAxis,n=e.yAxis,a=e.xAxisTicks,i=e.yAxisTicks,o=e.dataKey,s=e.bandSize,l=e.displayedData,u=e.offset,c=t.layout,f=l.map(function(d,h){var v=Ze(d,o);return c==="horizontal"?{x:Cn({axis:r,ticks:a,bandSize:s,entry:d,index:h}),y:fe(v)?null:n.scale(v),value:v,payload:d}:{x:fe(v)?null:r.scale(v),y:Cn({axis:n,ticks:i,bandSize:s,entry:d,index:h}),value:v,payload:d}});return bt({points:f,layout:c},u)});var b8=["layout","type","stroke","connectNulls","isRange","ref"],x8=["key"],kg;function qn(e){"@babel/helpers - typeof";return qn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qn(e)}function Mg(e,t){if(e==null)return{};var r=w8(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function w8(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Hr(){return Hr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Hr.apply(this,arguments)}function Ng(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Sr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ng(Object(r),!0).forEach(function(n){qt(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ng(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function O8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Dg(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Lg(n.key),n)}}function S8(e,t,r){return t&&Dg(e.prototype,t),r&&Dg(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function A8(e,t,r){return t=ys(t),T8(e,Ig()?Reflect.construct(t,r||[],ys(e).constructor):t.apply(e,r))}function T8(e,t){if(t&&(qn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return P8(e)}function P8(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ig(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ig=function(){return!!e})()}function ys(e){return ys=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ys(e)}function _8(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Gc(e,t)}function Gc(e,t){return Gc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},Gc(e,t)}function qt(e,t,r){return t=Lg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Lg(e){var t=E8(e,"string");return qn(t)=="symbol"?t:t+""}function E8(e,t){if(qn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(qn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Ar=function(e){function t(){var r;O8(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=A8(this,t,[].concat(a)),qt(r,"state",{isAnimationFinished:!0}),qt(r,"id",$r("recharts-area-")),qt(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),he(o)&&o()}),qt(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),he(o)&&o()}),r}return _8(t,e),S8(t,[{key:"renderDots",value:function(n,a,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var l=this.props,u=l.dot,c=l.points,f=l.dataKey,d=de(this.props,!1),h=de(u,!0),v=c.map(function(p,b){var S=Sr(Sr(Sr({key:"dot-".concat(b),r:3},d),h),{},{index:b,cx:p.x,cy:p.y,dataKey:f,value:p.value,payload:p.payload,points:c});return t.renderDotItem(u,S)}),y={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return A.createElement(xe,Hr({className:"recharts-area-dots"},y),v)}},{key:"renderHorizontalRect",value:function(n){var a=this.props,i=a.baseLine,o=a.points,s=a.strokeWidth,l=o[0].x,u=o[o.length-1].x,c=n*Math.abs(l-u),f=br(o.map(function(d){return d.y||0}));return Z(i)&&typeof i=="number"?f=Math.max(i,f):i&&Array.isArray(i)&&i.length&&(f=Math.max(br(i.map(function(d){return d.y||0})),f)),Z(f)?A.createElement("rect",{x:l<u?l:l-c,y:0,width:c,height:Math.floor(f+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(n){var a=this.props,i=a.baseLine,o=a.points,s=a.strokeWidth,l=o[0].y,u=o[o.length-1].y,c=n*Math.abs(l-u),f=br(o.map(function(d){return d.x||0}));return Z(i)&&typeof i=="number"?f=Math.max(i,f):i&&Array.isArray(i)&&i.length&&(f=Math.max(br(i.map(function(d){return d.x||0})),f)),Z(f)?A.createElement("rect",{x:0,y:l<u?l:l-c,width:f+(s?parseInt("".concat(s),10):1),height:Math.floor(c)}):null}},{key:"renderClipRect",value:function(n){var a=this.props.layout;return a==="vertical"?this.renderVerticalRect(n):this.renderHorizontalRect(n)}},{key:"renderAreaStatically",value:function(n,a,i,o){var s=this.props,l=s.layout,u=s.type,c=s.stroke,f=s.connectNulls,d=s.isRange;s.ref;var h=Mg(s,b8);return A.createElement(xe,{clipPath:i?"url(#clipPath-".concat(o,")"):null},A.createElement(Gr,Hr({},de(h,!0),{points:n,connectNulls:f,type:u,baseLine:a,layout:l,stroke:"none",className:"recharts-area-area"})),c!=="none"&&A.createElement(Gr,Hr({},de(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:f,fill:"none",points:n})),c!=="none"&&d&&A.createElement(Gr,Hr({},de(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:f,fill:"none",points:a})))}},{key:"renderAreaWithAnimation",value:function(n,a){var i=this,o=this.props,s=o.points,l=o.baseLine,u=o.isAnimationActive,c=o.animationBegin,f=o.animationDuration,d=o.animationEasing,h=o.animationId,v=this.state,y=v.prevPoints,p=v.prevBaseLine;return A.createElement(Dt,{begin:c,duration:f,isActive:u,easing:d,from:{t:0},to:{t:1},key:"area-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(b){var S=b.t;if(y){var x=y.length/s.length,T=s.map(function(P,j){var M=Math.floor(j*x);if(y[M]){var _=y[M],$=Ue(_.x,P.x),R=Ue(_.y,P.y);return Sr(Sr({},P),{},{x:$(S),y:R(S)})}return P}),m;if(Z(l)&&typeof l=="number"){var w=Ue(p,l);m=w(S)}else if(fe(l)||sn(l)){var O=Ue(p,0);m=O(S)}else m=l.map(function(P,j){var M=Math.floor(j*x);if(p[M]){var _=p[M],$=Ue(_.x,P.x),R=Ue(_.y,P.y);return Sr(Sr({},P),{},{x:$(S),y:R(S)})}return P});return i.renderAreaStatically(T,m,n,a)}return A.createElement(xe,null,A.createElement("defs",null,A.createElement("clipPath",{id:"animationClipPath-".concat(a)},i.renderClipRect(S))),A.createElement(xe,{clipPath:"url(#animationClipPath-".concat(a,")")},i.renderAreaStatically(s,l,n,a)))})}},{key:"renderArea",value:function(n,a){var i=this.props,o=i.points,s=i.baseLine,l=i.isAnimationActive,u=this.state,c=u.prevPoints,f=u.prevBaseLine,d=u.totalLength;return l&&o&&o.length&&(!c&&d>0||!Br(c,o)||!Br(f,s))?this.renderAreaWithAnimation(n,a):this.renderAreaStatically(o,s,n,a)}},{key:"render",value:function(){var n,a=this.props,i=a.hide,o=a.dot,s=a.points,l=a.className,u=a.top,c=a.left,f=a.xAxis,d=a.yAxis,h=a.width,v=a.height,y=a.isAnimationActive,p=a.id;if(i||!s||!s.length)return null;var b=this.state.isAnimationFinished,S=s.length===1,x=ye("recharts-area",l),T=f&&f.allowDataOverflow,m=d&&d.allowDataOverflow,w=T||m,O=fe(p)?this.id:p,P=(n=de(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},j=P.r,M=j===void 0?3:j,_=P.strokeWidth,$=_===void 0?2:_,R=ed(o)?o:{},k=R.clipDot,D=k===void 0?!0:k,C=M*2+$;return A.createElement(xe,{className:x},T||m?A.createElement("defs",null,A.createElement("clipPath",{id:"clipPath-".concat(O)},A.createElement("rect",{x:T?c:c-h/2,y:m?u:u-v/2,width:T?h:h*2,height:m?v:v*2})),!D&&A.createElement("clipPath",{id:"clipPath-dots-".concat(O)},A.createElement("rect",{x:c-C/2,y:u-C/2,width:h+C,height:v+C}))):null,S?null:this.renderArea(w,O),(o||S)&&this.renderDots(w,D,O),(!y||b)&&Kt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,curBaseLine:n.baseLine,prevPoints:a.curPoints,prevBaseLine:a.curBaseLine}:n.points!==a.curPoints||n.baseLine!==a.curBaseLine?{curPoints:n.points,curBaseLine:n.baseLine}:null}}])}(A.PureComponent);kg=Ar,qt(Ar,"displayName","Area"),qt(Ar,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!vr.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"}),qt(Ar,"getBaseValue",function(e,t,r,n){var a=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(Z(s)&&typeof s=="number")return s;var l=a==="horizontal"?n:r,u=l.scale.domain();if(l.type==="number"){var c=Math.max(u[0],u[1]),f=Math.min(u[0],u[1]);return s==="dataMin"?f:s==="dataMax"||c<0?c:Math.max(Math.min(u[0],u[1]),0)}return s==="dataMin"?u[0]:s==="dataMax"?u[1]:u[0]}),qt(Ar,"getComposedData",function(e){var t=e.props,r=e.item,n=e.xAxis,a=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,l=e.dataKey,u=e.stackedData,c=e.dataStartIndex,f=e.displayedData,d=e.offset,h=t.layout,v=u&&u.length,y=kg.getBaseValue(t,r,n,a),p=h==="horizontal",b=!1,S=f.map(function(T,m){var w;v?w=u[c+m]:(w=Ze(T,l),Array.isArray(w)?b=!0:w=[y,w]);var O=w[1]==null||v&&Ze(T,l)==null;return p?{x:Cn({axis:n,ticks:i,bandSize:s,entry:T,index:m}),y:O?null:a.scale(w[1]),value:w,payload:T}:{x:O?null:n.scale(w[1]),y:Cn({axis:a,ticks:o,bandSize:s,entry:T,index:m}),value:w,payload:T}}),x;return v||b?x=S.map(function(T){var m=Array.isArray(T.value)?T.value[0]:null;return p?{x:T.x,y:m!=null&&T.y!=null?a.scale(m):null}:{x:m!=null?n.scale(m):null,y:T.y}}):x=p?a.scale(y):n.scale(y),Sr({points:S,baseLine:x,layout:h,isRange:b},d)}),qt(Ar,"renderDotItem",function(e,t){var r;if(A.isValidElement(e))r=A.cloneElement(e,t);else if(he(e))r=e(t);else{var n=ye("recharts-area-dot",typeof e!="boolean"?e.className:""),a=t.key,i=Mg(t,x8);r=A.createElement(Ho,Hr({},i,{key:a,className:n}))}return r});function Hn(e){"@babel/helpers - typeof";return Hn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hn(e)}function j8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $8(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Fg(n.key),n)}}function C8(e,t,r){return t&&$8(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function k8(e,t,r){return t=ms(t),M8(e,Rg()?Reflect.construct(t,r||[],ms(e).constructor):t.apply(e,r))}function M8(e,t){if(t&&(Hn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return N8(e)}function N8(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Rg(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Rg=function(){return!!e})()}function ms(e){return ms=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ms(e)}function D8(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Kc(e,t)}function Kc(e,t){return Kc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},Kc(e,t)}function Bg(e,t,r){return t=Fg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fg(e){var t=I8(e,"string");return Hn(t)=="symbol"?t:t+""}function I8(e,t){if(Hn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Hn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var gs=function(e){function t(){return j8(this,t),k8(this,t,arguments)}return D8(t,e),C8(t,[{key:"render",value:function(){return null}}])}(xt.Component);Bg(gs,"displayName","ZAxis"),Bg(gs,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var L8=["option","isActive"];function pi(){return pi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},pi.apply(this,arguments)}function R8(e,t){if(e==null)return{};var r=B8(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function B8(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function F8(e){var t=e.option,r=e.isActive,n=R8(e,L8);return typeof t=="string"?xt.createElement(bc,pi({option:xt.createElement(Vi,pi({type:t},n)),isActive:r,shapeType:"symbols"},n)):xt.createElement(bc,pi({option:t,isActive:r,shapeType:"symbols"},n))}function Yn(e){"@babel/helpers - typeof";return Yn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yn(e)}function vi(){return vi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},vi.apply(this,arguments)}function Wg(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Et(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Wg(Object(r),!0).forEach(function(n){Tr(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wg(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function W8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ug(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Gg(n.key),n)}}function U8(e,t,r){return t&&Ug(e.prototype,t),r&&Ug(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function z8(e,t,r){return t=bs(t),G8(e,zg()?Reflect.construct(t,r||[],bs(e).constructor):t.apply(e,r))}function G8(e,t){if(t&&(Yn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return K8(e)}function K8(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zg(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zg=function(){return!!e})()}function bs(e){return bs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},bs(e)}function V8(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Vc(e,t)}function Vc(e,t){return Vc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},Vc(e,t)}function Tr(e,t,r){return t=Gg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Gg(e){var t=q8(e,"string");return Yn(t)=="symbol"?t:t+""}function q8(e,t){if(Yn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Yn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var xs=function(e){function t(){var r;W8(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=z8(this,t,[].concat(a)),Tr(r,"state",{isAnimationFinished:!1}),Tr(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0})}),Tr(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1})}),Tr(r,"id",$r("recharts-scatter-")),r}return V8(t,e),U8(t,[{key:"renderSymbolsStatically",value:function(n){var a=this,i=this.props,o=i.shape,s=i.activeShape,l=i.activeIndex,u=de(this.props,!1);return n.map(function(c,f){var d=l===f,h=d?s:o,v=Et(Et({},u),c);return A.createElement(xe,vi({className:"recharts-scatter-symbol",key:"symbol-".concat(c==null?void 0:c.cx,"-").concat(c==null?void 0:c.cy,"-").concat(c==null?void 0:c.size,"-").concat(f)},pa(a.props,c,f),{role:"img"}),A.createElement(F8,vi({option:h,isActive:d,key:"symbol-".concat(f)},v)))})}},{key:"renderSymbolsWithAnimation",value:function(){var n=this,a=this.props,i=a.points,o=a.isAnimationActive,s=a.animationBegin,l=a.animationDuration,u=a.animationEasing,c=a.animationId,f=this.state.prevPoints;return A.createElement(Dt,{begin:s,duration:l,isActive:o,easing:u,from:{t:0},to:{t:1},key:"pie-".concat(c),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(d){var h=d.t,v=i.map(function(y,p){var b=f&&f[p];if(b){var S=Ue(b.cx,y.cx),x=Ue(b.cy,y.cy),T=Ue(b.size,y.size);return Et(Et({},y),{},{cx:S(h),cy:x(h),size:T(h)})}var m=Ue(0,y.size);return Et(Et({},y),{},{size:m(h)})});return A.createElement(xe,null,n.renderSymbolsStatically(v))})}},{key:"renderSymbols",value:function(){var n=this.props,a=n.points,i=n.isAnimationActive,o=this.state.prevPoints;return i&&a&&a.length&&(!o||!Br(o,a))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(a)}},{key:"renderErrorBar",value:function(){var n=this.props.isAnimationActive;if(n&&!this.state.isAnimationFinished)return null;var a=this.props,i=a.points,o=a.xAxis,s=a.yAxis,l=a.children,u=dt(l,jn);return u?u.map(function(c,f){var d=c.props,h=d.direction,v=d.dataKey;return A.cloneElement(c,{key:"".concat(h,"-").concat(v,"-").concat(i[f]),data:i,xAxis:o,yAxis:s,layout:h==="x"?"vertical":"horizontal",dataPointFormatter:function(p,b){return{x:p.cx,y:p.cy,value:h==="x"?+p.node.x:+p.node.y,errorVal:Ze(p,b)}}})}):null}},{key:"renderLine",value:function(){var n=this.props,a=n.points,i=n.line,o=n.lineType,s=n.lineJointType,l=de(this.props,!1),u=de(i,!1),c,f;if(o==="joint")c=a.map(function(x){return{x:x.cx,y:x.cy}});else if(o==="fitting"){var d=gO(a),h=d.xmin,v=d.xmax,y=d.a,p=d.b,b=function(T){return y*T+p};c=[{x:h,y:b(h)},{x:v,y:b(v)}]}var S=Et(Et(Et({},l),{},{fill:"none",stroke:l&&l.fill},u),{},{points:c});return A.isValidElement(i)?f=A.cloneElement(i,S):he(i)?f=i(S):f=A.createElement(Gr,vi({},S,{type:s})),A.createElement(xe,{className:"recharts-scatter-line",key:"recharts-scatter-line"},f)}},{key:"render",value:function(){var n=this.props,a=n.hide,i=n.points,o=n.line,s=n.className,l=n.xAxis,u=n.yAxis,c=n.left,f=n.top,d=n.width,h=n.height,v=n.id,y=n.isAnimationActive;if(a||!i||!i.length)return null;var p=this.state.isAnimationFinished,b=ye("recharts-scatter",s),S=l&&l.allowDataOverflow,x=u&&u.allowDataOverflow,T=S||x,m=fe(v)?this.id:v;return A.createElement(xe,{className:b,clipPath:T?"url(#clipPath-".concat(m,")"):null},S||x?A.createElement("defs",null,A.createElement("clipPath",{id:"clipPath-".concat(m)},A.createElement("rect",{x:S?c:c-d/2,y:x?f:f-h/2,width:S?d:d*2,height:x?h:h*2}))):null,o&&this.renderLine(),this.renderErrorBar(),A.createElement(xe,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!y||p)&&Kt.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}}])}(A.PureComponent);Tr(xs,"displayName","Scatter"),Tr(xs,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!vr.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"}),Tr(xs,"getComposedData",function(e){var t=e.xAxis,r=e.yAxis,n=e.zAxis,a=e.item,i=e.displayedData,o=e.xAxisTicks,s=e.yAxisTicks,l=e.offset,u=a.props.tooltipType,c=dt(a.props.children,Hl),f=fe(t.dataKey)?a.props.dataKey:t.dataKey,d=fe(r.dataKey)?a.props.dataKey:r.dataKey,h=n&&n.dataKey,v=n?n.range:gs.defaultProps.range,y=v&&v[0],p=t.scale.bandwidth?t.scale.bandwidth():0,b=r.scale.bandwidth?r.scale.bandwidth():0,S=i.map(function(x,T){var m=Ze(x,f),w=Ze(x,d),O=!fe(h)&&Ze(x,h)||"-",P=[{name:fe(t.dataKey)?a.props.name:t.name||t.dataKey,unit:t.unit||"",value:m,payload:x,dataKey:f,type:u},{name:fe(r.dataKey)?a.props.name:r.name||r.dataKey,unit:r.unit||"",value:w,payload:x,dataKey:d,type:u}];O!=="-"&&P.push({name:n.name||n.dataKey,unit:n.unit||"",value:O,payload:x,dataKey:h,type:u});var j=Cn({axis:t,ticks:o,bandSize:p,entry:x,index:T,dataKey:f}),M=Cn({axis:r,ticks:s,bandSize:b,entry:x,index:T,dataKey:d}),_=O!=="-"?n.scale(O):y,$=Math.sqrt(Math.max(_,0)/Math.PI);return Et(Et({},x),{},{cx:j,cy:M,x:j-$,y:M-$,xAxis:t,yAxis:r,zAxis:n,width:2*$,height:2*$,size:_,node:{x:m,y:w,z:O},tooltipPayload:P,tooltipPosition:{x:j,y:M},payload:x},c&&c[T]&&c[T].props)});return Et({points:S},l)});function Xn(e){"@babel/helpers - typeof";return Xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xn(e)}function H8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Y8(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,qg(n.key),n)}}function X8(e,t,r){return t&&Y8(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Z8(e,t,r){return t=ws(t),J8(e,Kg()?Reflect.construct(t,r||[],ws(e).constructor):t.apply(e,r))}function J8(e,t){if(t&&(Xn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Q8(e)}function Q8(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Kg(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Kg=function(){return!!e})()}function ws(e){return ws=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ws(e)}function eF(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&qc(e,t)}function qc(e,t){return qc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},qc(e,t)}function Vg(e,t,r){return t=qg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qg(e){var t=tF(e,"string");return Xn(t)=="symbol"?t:t+""}function tF(e,t){if(Xn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Xn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Hc(){return Hc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Hc.apply(this,arguments)}function rF(e){var t=e.xAxisId,r=Ec(),n=jc(),a=rg(t);return a==null?null:xt.createElement(zn,Hc({},a,{className:ye("recharts-".concat(a.axisType," ").concat(a.axisType),a.className),viewBox:{x:0,y:0,width:r,height:n},ticksGenerator:function(o){return ur(o,!0)}}))}var Os=function(e){function t(){return H8(this,t),Z8(this,t,arguments)}return eF(t,e),X8(t,[{key:"render",value:function(){return xt.createElement(rF,this.props)}}])}(xt.Component);Vg(Os,"displayName","XAxis"),Vg(Os,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function Zn(e){"@babel/helpers - typeof";return Zn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zn(e)}function nF(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function aF(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Xg(n.key),n)}}function iF(e,t,r){return t&&aF(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function oF(e,t,r){return t=Ss(t),sF(e,Hg()?Reflect.construct(t,r||[],Ss(e).constructor):t.apply(e,r))}function sF(e,t){if(t&&(Zn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return lF(e)}function lF(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Hg(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Hg=function(){return!!e})()}function Ss(e){return Ss=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ss(e)}function uF(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Yc(e,t)}function Yc(e,t){return Yc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},Yc(e,t)}function Yg(e,t,r){return t=Xg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xg(e){var t=cF(e,"string");return Zn(t)=="symbol"?t:t+""}function cF(e,t){if(Zn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Zn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Xc(){return Xc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Xc.apply(this,arguments)}var fF=function(t){var r=t.yAxisId,n=Ec(),a=jc(),i=ng(r);return i==null?null:xt.createElement(zn,Xc({},i,{className:ye("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:n,height:a},ticksGenerator:function(s){return ur(s,!0)}}))},As=function(e){function t(){return nF(this,t),oF(this,t,arguments)}return uF(t,e),iF(t,[{key:"render",value:function(){return xt.createElement(fF,this.props)}}])}(xt.Component);Yg(As,"displayName","YAxis"),Yg(As,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function Zg(e){return vF(e)||pF(e)||hF(e)||dF()}function dF(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
203
203
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hF(e,t){if(e){if(typeof e=="string")return Zc(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Zc(e,t)}}function pF(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function vF(e){if(Array.isArray(e))return Zc(e)}function Zc(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Jc=function(t,r,n,a,i){var o=dt(t,Mc),s=dt(t,us),l=[].concat(Zg(o),Zg(s)),u=dt(t,ds),c="".concat(a,"Id"),f=a[0],d=r;if(l.length&&(d=l.reduce(function(y,p){if(p.props[c]===n&&Vt(p.props,"extendDomain")&&Z(p.props[f])){var b=p.props[f];return[Math.min(y[0],b),Math.max(y[1],b)]}return y},d)),u.length){var h="".concat(f,"1"),v="".concat(f,"2");d=u.reduce(function(y,p){if(p.props[c]===n&&Vt(p.props,"extendDomain")&&Z(p.props[h])&&Z(p.props[v])){var b=p.props[h],S=p.props[v];return[Math.min(y[0],b,S),Math.max(y[1],b,S)]}return y},d)}return i&&i.length&&(d=i.reduce(function(y,p){return Z(p)?[Math.min(y[0],p),Math.max(y[1],p)]:y},d)),d},Jg={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function a(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function i(l,u,c,f,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var h=new a(c,f||l,d),v=r?r+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],h]:l._events[v].push(h):(l._events[v]=h,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new n:delete l._events[u]}function s(){this._events=new n,this._eventsCount=0}s.prototype.eventNames=function(){var u=[],c,f;if(this._eventsCount===0)return u;for(f in c=this._events)t.call(c,f)&&u.push(r?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},s.prototype.listeners=function(u){var c=r?r+u:u,f=this._events[c];if(!f)return[];if(f.fn)return[f.fn];for(var d=0,h=f.length,v=new Array(h);d<h;d++)v[d]=f[d].fn;return v},s.prototype.listenerCount=function(u){var c=r?r+u:u,f=this._events[c];return f?f.fn?1:f.length:0},s.prototype.emit=function(u,c,f,d,h,v){var y=r?r+u:u;if(!this._events[y])return!1;var p=this._events[y],b=arguments.length,S,x;if(p.fn){switch(p.once&&this.removeListener(u,p.fn,void 0,!0),b){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,f),!0;case 4:return p.fn.call(p.context,c,f,d),!0;case 5:return p.fn.call(p.context,c,f,d,h),!0;case 6:return p.fn.call(p.context,c,f,d,h,v),!0}for(x=1,S=new Array(b-1);x<b;x++)S[x-1]=arguments[x];p.fn.apply(p.context,S)}else{var T=p.length,m;for(x=0;x<T;x++)switch(p[x].once&&this.removeListener(u,p[x].fn,void 0,!0),b){case 1:p[x].fn.call(p[x].context);break;case 2:p[x].fn.call(p[x].context,c);break;case 3:p[x].fn.call(p[x].context,c,f);break;case 4:p[x].fn.call(p[x].context,c,f,d);break;default:if(!S)for(m=1,S=new Array(b-1);m<b;m++)S[m-1]=arguments[m];p[x].fn.apply(p[x].context,S)}}return!0},s.prototype.on=function(u,c,f){return i(this,u,c,f,!1)},s.prototype.once=function(u,c,f){return i(this,u,c,f,!0)},s.prototype.removeListener=function(u,c,f,d){var h=r?r+u:u;if(!this._events[h])return this;if(!c)return o(this,h),this;var v=this._events[h];if(v.fn)v.fn===c&&(!d||v.once)&&(!f||v.context===f)&&o(this,h);else{for(var y=0,p=[],b=v.length;y<b;y++)(v[y].fn!==c||d&&!v[y].once||f&&v[y].context!==f)&&p.push(v[y]);p.length?this._events[h]=p.length===1?p[0]:p:o(this,h)}return this},s.prototype.removeAllListeners=function(u){var c;return u?(c=r?r+u:u,this._events[c]&&o(this,c)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s})(Jg);var yF=Jg.exports;const mF=Ce(yF);var Qc=new mF,ef="recharts.syncMouseEvents";function yi(e){"@babel/helpers - typeof";return yi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yi(e)}function gF(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bF(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Qg(n.key),n)}}function xF(e,t,r){return t&&bF(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function tf(e,t,r){return t=Qg(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qg(e){var t=wF(e,"string");return yi(t)=="symbol"?t:t+""}function wF(e,t){if(yi(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(yi(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var OF=function(){function e(){gF(this,e),tf(this,"activeIndex",0),tf(this,"coordinateList",[]),tf(this,"layout","horizontal")}return xF(e,[{key:"setDetails",value:function(r){var n,a=r.coordinateList,i=a===void 0?null:a,o=r.container,s=o===void 0?null:o,l=r.layout,u=l===void 0?null:l,c=r.offset,f=c===void 0?null:c,d=r.mouseHandlerCallback,h=d===void 0?null:d;this.coordinateList=(n=i??this.coordinateList)!==null&&n!==void 0?n:[],this.container=s??this.container,this.layout=u??this.layout,this.offset=f??this.offset,this.mouseHandlerCallback=h??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(r){if(this.coordinateList.length!==0)switch(r.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(r){this.activeIndex=r}},{key:"spoofMouse",value:function(){var r,n;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var a=this.container.getBoundingClientRect(),i=a.x,o=a.y,s=a.height,l=this.coordinateList[this.activeIndex].coordinate,u=((r=window)===null||r===void 0?void 0:r.scrollX)||0,c=((n=window)===null||n===void 0?void 0:n.scrollY)||0,f=i+l+u,d=o+this.offset.top+s/2+c;this.mouseHandlerCallback({pageX:f,pageY:d})}}}])}();function SF(e,t,r){if(r==="number"&&t===!0&&Array.isArray(e)){var n=e==null?void 0:e[0],a=e==null?void 0:e[1];if(n&&a&&Z(n)&&Z(a))return!0}return!1}function AF(e,t,r,n){var a=n/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-a:r.left+.5,y:e==="horizontal"?r.top+.5:t.y-a,width:e==="horizontal"?n:r.width-1,height:e==="horizontal"?r.height-1:n}}function eb(e){var t=e.cx,r=e.cy,n=e.radius,a=e.startAngle,i=e.endAngle,o=rt(t,r,n,a),s=rt(t,r,n,i);return{points:[o,s],cx:t,cy:r,radius:n,startAngle:a,endAngle:i}}function TF(e,t,r){var n,a,i,o;if(e==="horizontal")n=t.x,i=n,a=r.top,o=r.top+r.height;else if(e==="vertical")a=t.y,o=a,n=r.left,i=r.left+r.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var s=t.cx,l=t.cy,u=t.innerRadius,c=t.outerRadius,f=t.angle,d=rt(s,l,u,f),h=rt(s,l,c,f);n=d.x,a=d.y,i=h.x,o=h.y}else return eb(t);return[{x:n,y:a},{x:i,y:o}]}function mi(e){"@babel/helpers - typeof";return mi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(e)}function tb(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ts(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?tb(Object(r),!0).forEach(function(n){PF(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tb(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function PF(e,t,r){return t=_F(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _F(e){var t=EF(e,"string");return mi(t)=="symbol"?t:t+""}function EF(e,t){if(mi(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(mi(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jF(e){var t,r,n=e.element,a=e.tooltipEventType,i=e.isActive,o=e.activeCoordinate,s=e.activePayload,l=e.offset,u=e.activeTooltipIndex,c=e.tooltipAxisBandSize,f=e.layout,d=e.chartName,h=(t=n.props.cursor)!==null&&t!==void 0?t:(r=n.type.defaultProps)===null||r===void 0?void 0:r.cursor;if(!n||!h||!i||!o||d!=="ScatterChart"&&a!=="axis")return null;var v,y=Gr;if(d==="ScatterChart")v=o,y=e5;else if(d==="BarChart")v=AF(f,o,l,c),y=yc;else if(f==="radial"){var p=eb(o),b=p.cx,S=p.cy,x=p.radius,T=p.startAngle,m=p.endAngle;v={cx:b,cy:S,startAngle:T,endAngle:m,innerRadius:x,outerRadius:x},y=_y}else v={points:TF(f,o,l)},y=Gr;var w=Ts(Ts(Ts(Ts({stroke:"#ccc",pointerEvents:"none"},l),v),de(h,!1)),{},{payload:s,payloadIndex:u,className:ye("recharts-tooltip-cursor",h.className)});return A.isValidElement(h)?A.cloneElement(h,w):A.createElement(y,w)}var $F=["item"],CF=["children","className","width","height","style","compact","title","desc"];function Jn(e){"@babel/helpers - typeof";return Jn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jn(e)}function Qn(){return Qn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Qn.apply(this,arguments)}function rb(e,t){return NF(e)||MF(e,t)||ib(e,t)||kF()}function kF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
204
204
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MF(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,s=[],l=!0,u=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(l=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(c){u=!0,a=c}finally{try{if(!l&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}function NF(e){if(Array.isArray(e))return e}function nb(e,t){if(e==null)return{};var r=DF(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function DF(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function IF(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function LF(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,sb(n.key),n)}}function RF(e,t,r){return t&&LF(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function BF(e,t,r){return t=Ps(t),FF(e,ab()?Reflect.construct(t,r||[],Ps(e).constructor):t.apply(e,r))}function FF(e,t){if(t&&(Jn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WF(e)}function WF(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ab(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ab=function(){return!!e})()}function Ps(e){return Ps=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ps(e)}function UF(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rf(e,t)}function rf(e,t){return rf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},rf(e,t)}function ea(e){return KF(e)||GF(e)||ib(e)||zF()}function zF(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
205
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ib(e,t){if(e){if(typeof e=="string")return nf(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nf(e,t)}}function GF(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function KF(e){if(Array.isArray(e))return nf(e)}function nf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ob(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function z(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ob(Object(r),!0).forEach(function(n){oe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ob(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function oe(e,t,r){return t=sb(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sb(e){var t=VF(e,"string");return Jn(t)=="symbol"?t:t+""}function VF(e,t){if(Jn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Jn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var qF={xAxis:["bottom","top"],yAxis:["left","right"]},HF={width:"100%",height:"100%"},lb={x:0,y:0};function _s(e){return e}var YF=function(t,r){return r==="horizontal"?t.x:r==="vertical"?t.y:r==="centric"?t.angle:t.radius},XF=function(t,r,n,a){var i=r.find(function(c){return c&&c.index===n});if(i){if(t==="horizontal")return{x:i.coordinate,y:a.y};if(t==="vertical")return{x:a.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,s=a.radius;return z(z(z({},a),rt(a.cx,a.cy,s,o)),{},{angle:o,radius:s})}var l=i.coordinate,u=a.angle;return z(z(z({},a),rt(a.cx,a.cy,l,u)),{},{angle:u,radius:l})}return lb},Es=function(t,r){var n=r.graphicalItems,a=r.dataStartIndex,i=r.dataEndIndex,o=(n??[]).reduce(function(s,l){var u=l.props.data;return u&&u.length?[].concat(ea(s),ea(u)):s},[]);return o.length>0?o:t&&t.length&&Z(a)&&Z(i)?t.slice(a,i+1):[]};function ub(e){return e==="number"?[0,"auto"]:void 0}var af=function(t,r,n,a){var i=t.graphicalItems,o=t.tooltipAxis,s=Es(r,t);return n<0||!i||!i.length||n>=s.length?null:i.reduce(function(l,u){var c,f=(c=u.props.data)!==null&&c!==void 0?c:r;f&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(f=f.slice(t.dataStartIndex,t.dataEndIndex+1));var d;if(o.dataKey&&!o.allowDuplicatedCategory){var h=f===void 0?s:f;d=Ni(h,o.dataKey,a)}else d=f&&f[n]||s[n];return d?[].concat(ea(l),[vy(u,d)]):l},[])},cb=function(t,r,n,a){var i=a||{x:t.chartX,y:t.chartY},o=YF(i,n),s=t.orderedTooltipTicks,l=t.tooltipAxis,u=t.tooltipTicks,c=CI(o,s,u,l);if(c>=0&&u){var f=u[c]&&u[c].value,d=af(t,r,c,f),h=XF(n,s,c,i);return{activeTooltipIndex:c,activeLabel:f,activePayload:d,activeCoordinate:h}}return null},ZF=function(t,r){var n=r.axes,a=r.graphicalItems,i=r.axisType,o=r.axisIdKey,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.layout,f=t.children,d=t.stackOffset,h=sy(c,i);return n.reduce(function(v,y){var p,b=y.type.defaultProps!==void 0?z(z({},y.type.defaultProps),y.props):y.props,S=b.type,x=b.dataKey,T=b.allowDataOverflow,m=b.allowDuplicatedCategory,w=b.scale,O=b.ticks,P=b.includeHidden,j=b[o];if(v[j])return v;var M=Es(t.data,{graphicalItems:a.filter(function(F){var W,K=o in F.props?F.props[o]:(W=F.type.defaultProps)===null||W===void 0?void 0:W[o];return K===j}),dataStartIndex:l,dataEndIndex:u}),_=M.length,$,R,k;SF(b.domain,T,S)&&($=qu(b.domain,null,T),h&&(S==="number"||w!=="auto")&&(k=za(M,x,"category")));var D=ub(S);if(!$||$.length===0){var C,B=(C=b.domain)!==null&&C!==void 0?C:D;if(x){if($=za(M,x,S),S==="category"&&h){var U=mO($);m&&U?(R=$,$=Qo(0,_)):m||($=py(B,$,y).reduce(function(F,W){return F.indexOf(W)>=0?F:[].concat(ea(F),[W])},[]))}else if(S==="category")m?$=$.filter(function(F){return F!==""&&!fe(F)}):$=py(B,$,y).reduce(function(F,W){return F.indexOf(W)>=0||W===""||fe(W)?F:[].concat(ea(F),[W])},[]);else if(S==="number"){var G=II(M,a.filter(function(F){var W,K,X=o in F.props?F.props[o]:(W=F.type.defaultProps)===null||W===void 0?void 0:W[o],Q="hide"in F.props?F.props.hide:(K=F.type.defaultProps)===null||K===void 0?void 0:K.hide;return X===j&&(P||!Q)}),x,i,c);G&&($=G)}h&&(S==="number"||w!=="auto")&&(k=za(M,x,"category"))}else h?$=Qo(0,_):s&&s[j]&&s[j].hasStack&&S==="number"?$=d==="expand"?[0,1]:fy(s[j].stackGroups,l,u):$=oy(M,a.filter(function(F){var W=o in F.props?F.props[o]:F.type.defaultProps[o],K="hide"in F.props?F.props.hide:F.type.defaultProps.hide;return W===j&&(P||!K)}),S,c,!0);if(S==="number")$=Jc(f,$,j,i,O),B&&($=qu(B,$,T));else if(S==="category"&&B){var E=B,L=$.every(function(F){return E.indexOf(F)>=0});L&&($=E)}}return z(z({},v),{},oe({},j,z(z({},b),{},{axisType:i,domain:$,categoricalDomain:k,duplicateDomain:R,originalDomain:(p=b.domain)!==null&&p!==void 0?p:D,isCategorical:h,layout:c})))},{})},JF=function(t,r){var n=r.graphicalItems,a=r.Axis,i=r.axisType,o=r.axisIdKey,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.layout,f=t.children,d=Es(t.data,{graphicalItems:n,dataStartIndex:l,dataEndIndex:u}),h=d.length,v=sy(c,i),y=-1;return n.reduce(function(p,b){var S=b.type.defaultProps!==void 0?z(z({},b.type.defaultProps),b.props):b.props,x=S[o],T=ub("number");if(!p[x]){y++;var m;return v?m=Qo(0,h):s&&s[x]&&s[x].hasStack?(m=fy(s[x].stackGroups,l,u),m=Jc(f,m,x,i)):(m=qu(T,oy(d,n.filter(function(w){var O,P,j=o in w.props?w.props[o]:(O=w.type.defaultProps)===null||O===void 0?void 0:O[o],M="hide"in w.props?w.props.hide:(P=w.type.defaultProps)===null||P===void 0?void 0:P.hide;return j===x&&!M}),"number",c),a.defaultProps.allowDataOverflow),m=Jc(f,m,x,i)),z(z({},p),{},oe({},x,z(z({axisType:i},a.defaultProps),{},{hide:!0,orientation:wt(qF,"".concat(i,".").concat(y%2),null),domain:m,originalDomain:T,isCategorical:v,layout:c})))}return p},{})},QF=function(t,r){var n=r.axisType,a=n===void 0?"xAxis":n,i=r.AxisComp,o=r.graphicalItems,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.children,f="".concat(a,"Id"),d=dt(c,i),h={};return d&&d.length?h=ZF(t,{axes:d,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u}):o&&o.length&&(h=JF(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u})),h},eW=function(t){var r=hr(t),n=ur(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:Fl(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Io(r,n)}},fb=function(t){var r=t.children,n=t.defaultShowTooltip,a=yt(r,Nn),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!n}},tW=function(t){return!t||!t.length?!1:t.some(function(r){var n=Qt(r&&r.type);return n&&n.indexOf("Bar")>=0})},db=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},rW=function(t,r){var n=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,s=t.yAxisMap,l=s===void 0?{}:s,u=n.width,c=n.height,f=n.children,d=n.margin||{},h=yt(f,Nn),v=yt(f,vn),y=Object.keys(l).reduce(function(m,w){var O=l[w],P=O.orientation;return!O.mirror&&!O.hide?z(z({},m),{},oe({},P,m[P]+O.width)):m},{left:d.left||0,right:d.right||0}),p=Object.keys(o).reduce(function(m,w){var O=o[w],P=O.orientation;return!O.mirror&&!O.hide?z(z({},m),{},oe({},P,wt(m,"".concat(P))+O.height)):m},{top:d.top||0,bottom:d.bottom||0}),b=z(z({},p),y),S=b.bottom;h&&(b.bottom+=h.props.height||Nn.defaultProps.height),v&&r&&(b=NI(b,a,n,r));var x=u-b.left-b.right,T=c-b.top-b.bottom;return z(z({brushBottom:S},b),{},{width:Math.max(x,0),height:Math.max(T,0)})},nW=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},aW=function(t){var r=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,s=o===void 0?["axis"]:o,l=t.axisComponents,u=t.legendContent,c=t.formatAxisMap,f=t.defaultProps,d=function(b,S){var x=S.graphicalItems,T=S.stackGroups,m=S.offset,w=S.updateId,O=S.dataStartIndex,P=S.dataEndIndex,j=b.barSize,M=b.layout,_=b.barGap,$=b.barCategoryGap,R=b.maxBarSize,k=db(M),D=k.numericAxisName,C=k.cateAxisName,B=tW(x),U=[];return x.forEach(function(G,E){var L=Es(b.data,{graphicalItems:[G],dataStartIndex:O,dataEndIndex:P}),F=G.type.defaultProps!==void 0?z(z({},G.type.defaultProps),G.props):G.props,W=F.dataKey,K=F.maxBarSize,X=F["".concat(D,"Id")],Q=F["".concat(C,"Id")],ae={},te=l.reduce(function(Ge,lt){var Ai,Ti,aa=S["".concat(lt.axisType,"Map")],Pi=F["".concat(lt.axisType,"Id")];aa&&aa[Pi]||lt.axisType==="zAxis"||(process.env.NODE_ENV!=="production"?pt(!1,"Specifying a(n) ".concat(lt.axisType,"Id requires a corresponding ").concat(lt.axisType,"Id on the targeted graphical component ").concat((Ai=G==null||(Ti=G.type)===null||Ti===void 0?void 0:Ti.displayName)!==null&&Ai!==void 0?Ai:"")):pt());var _i=aa[Pi];return z(z({},Ge),{},oe(oe({},lt.axisType,_i),"".concat(lt.axisType,"Ticks"),ur(_i)))},ae),V=te[C],Y=te["".concat(C,"Ticks")],J=T&&T[X]&&T[X].hasStack&&HI(G,T[X].stackGroups),I=Qt(G.type).indexOf("Bar")>=0,ie=Io(V,Y),q=[],se=B&&kI({barSize:j,stackGroups:T,totalSize:nW(te,C)});if(I){var ee,ve,We=fe(K)?R:K,Re=(ee=(ve=Io(V,Y,!0))!==null&&ve!==void 0?ve:We)!==null&&ee!==void 0?ee:0;q=MI({barGap:_,barCategoryGap:$,bandSize:Re!==ie?Re:ie,sizeList:se[Q],maxBarSize:We}),Re!==ie&&(q=q.map(function(Ge){return z(z({},Ge),{},{position:z(z({},Ge.position),{},{offset:Ge.position.offset-Re/2})})}))}var Be=G&&G.type&&G.type.getComposedData;Be&&U.push({props:z(z({},Be(z(z({},te),{},{displayedData:L,props:b,dataKey:W,item:G,bandSize:ie,barPosition:q,offset:m,stackedData:J,layout:M,dataStartIndex:O,dataEndIndex:P}))),{},oe(oe(oe({key:G.key||"item-".concat(E)},D,te[D]),C,te[C]),"animationId",w)),childIndex:$O(G,b.children),item:G})}),U},h=function(b,S){var x=b.props,T=b.dataStartIndex,m=b.dataEndIndex,w=b.updateId;if(!Qf({props:x}))return null;var O=x.children,P=x.layout,j=x.stackOffset,M=x.data,_=x.reverseStackOrder,$=db(P),R=$.numericAxisName,k=$.cateAxisName,D=dt(O,n),C=KI(M,D,"".concat(R,"Id"),"".concat(k,"Id"),j,_),B=l.reduce(function(F,W){var K="".concat(W.axisType,"Map");return z(z({},F),{},oe({},K,QF(x,z(z({},W),{},{graphicalItems:D,stackGroups:W.axisType===R&&C,dataStartIndex:T,dataEndIndex:m}))))},{}),U=rW(z(z({},B),{},{props:x,graphicalItems:D}),S==null?void 0:S.legendBBox);Object.keys(B).forEach(function(F){B[F]=c(x,B[F],U,F.replace("Map",""),r)});var G=B["".concat(k,"Map")],E=eW(G),L=d(x,z(z({},B),{},{dataStartIndex:T,dataEndIndex:m,updateId:w,graphicalItems:D,stackGroups:C,offset:U}));return z(z({formattedGraphicalItems:L,graphicalItems:D,offset:U,stackGroups:C},E),B)},v=function(p){function b(S){var x,T,m;return IF(this,b),m=BF(this,b,[S]),oe(m,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),oe(m,"accessibilityManager",new OF),oe(m,"handleLegendBBoxUpdate",function(w){if(w){var O=m.state,P=O.dataStartIndex,j=O.dataEndIndex,M=O.updateId;m.setState(z({legendBBox:w},h({props:m.props,dataStartIndex:P,dataEndIndex:j,updateId:M},z(z({},m.state),{},{legendBBox:w}))))}}),oe(m,"handleReceiveSyncEvent",function(w,O,P){if(m.props.syncId===w){if(P===m.eventEmitterSymbol&&typeof m.props.syncMethod!="function")return;m.applySyncEvent(O)}}),oe(m,"handleBrushChange",function(w){var O=w.startIndex,P=w.endIndex;if(O!==m.state.dataStartIndex||P!==m.state.dataEndIndex){var j=m.state.updateId;m.setState(function(){return z({dataStartIndex:O,dataEndIndex:P},h({props:m.props,dataStartIndex:O,dataEndIndex:P,updateId:j},m.state))}),m.triggerSyncEvent({dataStartIndex:O,dataEndIndex:P})}}),oe(m,"handleMouseEnter",function(w){var O=m.getMouseInfo(w);if(O){var P=z(z({},O),{},{isTooltipActive:!0});m.setState(P),m.triggerSyncEvent(P);var j=m.props.onMouseEnter;he(j)&&j(P,w)}}),oe(m,"triggeredAfterMouseMove",function(w){var O=m.getMouseInfo(w),P=O?z(z({},O),{},{isTooltipActive:!0}):{isTooltipActive:!1};m.setState(P),m.triggerSyncEvent(P);var j=m.props.onMouseMove;he(j)&&j(P,w)}),oe(m,"handleItemMouseEnter",function(w){m.setState(function(){return{isTooltipActive:!0,activeItem:w,activePayload:w.tooltipPayload,activeCoordinate:w.tooltipPosition||{x:w.cx,y:w.cy}}})}),oe(m,"handleItemMouseLeave",function(){m.setState(function(){return{isTooltipActive:!1}})}),oe(m,"handleMouseMove",function(w){w.persist(),m.throttleTriggeredAfterMouseMove(w)}),oe(m,"handleMouseLeave",function(w){m.throttleTriggeredAfterMouseMove.cancel();var O={isTooltipActive:!1};m.setState(O),m.triggerSyncEvent(O);var P=m.props.onMouseLeave;he(P)&&P(O,w)}),oe(m,"handleOuterEvent",function(w){var O=jO(w),P=wt(m.props,"".concat(O));if(O&&he(P)){var j,M;/.*touch.*/i.test(O)?M=m.getMouseInfo(w.changedTouches[0]):M=m.getMouseInfo(w),P((j=M)!==null&&j!==void 0?j:{},w)}}),oe(m,"handleClick",function(w){var O=m.getMouseInfo(w);if(O){var P=z(z({},O),{},{isTooltipActive:!0});m.setState(P),m.triggerSyncEvent(P);var j=m.props.onClick;he(j)&&j(P,w)}}),oe(m,"handleMouseDown",function(w){var O=m.props.onMouseDown;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleMouseUp",function(w){var O=m.props.onMouseUp;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleTouchMove",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.throttleTriggeredAfterMouseMove(w.changedTouches[0])}),oe(m,"handleTouchStart",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.handleMouseDown(w.changedTouches[0])}),oe(m,"handleTouchEnd",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.handleMouseUp(w.changedTouches[0])}),oe(m,"handleDoubleClick",function(w){var O=m.props.onDoubleClick;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleContextMenu",function(w){var O=m.props.onContextMenu;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"triggerSyncEvent",function(w){m.props.syncId!==void 0&&Qc.emit(ef,m.props.syncId,w,m.eventEmitterSymbol)}),oe(m,"applySyncEvent",function(w){var O=m.props,P=O.layout,j=O.syncMethod,M=m.state.updateId,_=w.dataStartIndex,$=w.dataEndIndex;if(w.dataStartIndex!==void 0||w.dataEndIndex!==void 0)m.setState(z({dataStartIndex:_,dataEndIndex:$},h({props:m.props,dataStartIndex:_,dataEndIndex:$,updateId:M},m.state)));else if(w.activeTooltipIndex!==void 0){var R=w.chartX,k=w.chartY,D=w.activeTooltipIndex,C=m.state,B=C.offset,U=C.tooltipTicks;if(!B)return;if(typeof j=="function")D=j(U,w);else if(j==="value"){D=-1;for(var G=0;G<U.length;G++)if(U[G].value===w.activeLabel){D=G;break}}var E=z(z({},B),{},{x:B.left,y:B.top}),L=Math.min(R,E.x+E.width),F=Math.min(k,E.y+E.height),W=U[D]&&U[D].value,K=af(m.state,m.props.data,D),X=U[D]?{x:P==="horizontal"?U[D].coordinate:L,y:P==="horizontal"?F:U[D].coordinate}:lb;m.setState(z(z({},w),{},{activeLabel:W,activeCoordinate:X,activePayload:K,activeTooltipIndex:D}))}else m.setState(w)}),oe(m,"renderCursor",function(w){var O,P=m.state,j=P.isTooltipActive,M=P.activeCoordinate,_=P.activePayload,$=P.offset,R=P.activeTooltipIndex,k=P.tooltipAxisBandSize,D=m.getTooltipEventType(),C=(O=w.props.active)!==null&&O!==void 0?O:j,B=m.props.layout,U=w.key||"_recharts-cursor";return A.createElement(jF,{key:U,activeCoordinate:M,activePayload:_,activeTooltipIndex:R,chartName:r,element:w,isActive:C,layout:B,offset:$,tooltipAxisBandSize:k,tooltipEventType:D})}),oe(m,"renderPolarAxis",function(w,O,P){var j=wt(w,"type.axisType"),M=wt(m.state,"".concat(j,"Map")),_=w.type.defaultProps,$=_!==void 0?z(z({},_),w.props):w.props,R=M&&M[$["".concat(j,"Id")]];return A.cloneElement(w,z(z({},R),{},{className:ye(j,R.className),key:w.key||"".concat(O,"-").concat(P),ticks:ur(R,!0)}))}),oe(m,"renderPolarGrid",function(w){var O=w.props,P=O.radialLines,j=O.polarAngles,M=O.polarRadius,_=m.state,$=_.radiusAxisMap,R=_.angleAxisMap,k=hr($),D=hr(R),C=D.cx,B=D.cy,U=D.innerRadius,G=D.outerRadius;return A.cloneElement(w,{polarAngles:Array.isArray(j)?j:ur(D,!0).map(function(E){return E.coordinate}),polarRadius:Array.isArray(M)?M:ur(k,!0).map(function(E){return E.coordinate}),cx:C,cy:B,innerRadius:U,outerRadius:G,key:w.key||"polar-grid",radialLines:P})}),oe(m,"renderLegend",function(){var w=m.state.formattedGraphicalItems,O=m.props,P=O.children,j=O.width,M=O.height,_=m.props.margin||{},$=j-(_.left||0)-(_.right||0),R=ry({children:P,formattedGraphicalItems:w,legendWidth:$,legendContent:u});if(!R)return null;var k=R.item,D=nb(R,$F);return A.cloneElement(k,z(z({},D),{},{chartWidth:j,chartHeight:M,margin:_,onBBoxUpdate:m.handleLegendBBoxUpdate}))}),oe(m,"renderTooltip",function(){var w,O=m.props,P=O.children,j=O.accessibilityLayer,M=yt(P,Wt);if(!M)return null;var _=m.state,$=_.isTooltipActive,R=_.activeCoordinate,k=_.activePayload,D=_.activeLabel,C=_.offset,B=(w=M.props.active)!==null&&w!==void 0?w:$;return A.cloneElement(M,{viewBox:z(z({},C),{},{x:C.left,y:C.top}),active:B,label:D,payload:B?k:[],coordinate:R,accessibilityLayer:j})}),oe(m,"renderBrush",function(w){var O=m.props,P=O.margin,j=O.data,M=m.state,_=M.offset,$=M.dataStartIndex,R=M.dataEndIndex,k=M.updateId;return A.cloneElement(w,{key:w.key||"_recharts-brush",onChange:Do(m.handleBrushChange,w.props.onChange),data:j,x:Z(w.props.x)?w.props.x:_.left,y:Z(w.props.y)?w.props.y:_.top+_.height+_.brushBottom-(P.bottom||0),width:Z(w.props.width)?w.props.width:_.width,startIndex:$,endIndex:R,updateId:"brush-".concat(k)})}),oe(m,"renderReferenceElement",function(w,O,P){if(!w)return null;var j=m,M=j.clipPathId,_=m.state,$=_.xAxisMap,R=_.yAxisMap,k=_.offset,D=w.type.defaultProps||{},C=w.props,B=C.xAxisId,U=B===void 0?D.xAxisId:B,G=C.yAxisId,E=G===void 0?D.yAxisId:G;return A.cloneElement(w,{key:w.key||"".concat(O,"-").concat(P),xAxis:$[U],yAxis:R[E],viewBox:{x:k.left,y:k.top,width:k.width,height:k.height},clipPathId:M})}),oe(m,"renderActivePoints",function(w){var O=w.item,P=w.activePoint,j=w.basePoint,M=w.childIndex,_=w.isRange,$=[],R=O.props.key,k=O.item.type.defaultProps!==void 0?z(z({},O.item.type.defaultProps),O.item.props):O.item.props,D=k.activeDot,C=k.dataKey,B=z(z({index:M,dataKey:C,cx:P.x,cy:P.y,r:4,fill:Ku(O.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},de(D,!1)),Di(D));return $.push(b.renderActiveDot(D,B,"".concat(R,"-activePoint-").concat(M))),j?$.push(b.renderActiveDot(D,z(z({},B),{},{cx:j.x,cy:j.y}),"".concat(R,"-basePoint-").concat(M))):_&&$.push(null),$}),oe(m,"renderGraphicChild",function(w,O,P){var j=m.filterFormatItem(w,O,P);if(!j)return null;var M=m.getTooltipEventType(),_=m.state,$=_.isTooltipActive,R=_.tooltipAxis,k=_.activeTooltipIndex,D=_.activeLabel,C=m.props.children,B=yt(C,Wt),U=j.props,G=U.points,E=U.isRange,L=U.baseLine,F=j.item.type.defaultProps!==void 0?z(z({},j.item.type.defaultProps),j.item.props):j.item.props,W=F.activeDot,K=F.hide,X=F.activeBar,Q=F.activeShape,ae=!!(!K&&$&&B&&(W||X||Q)),te={};M!=="axis"&&B&&B.props.trigger==="click"?te={onClick:Do(m.handleItemMouseEnter,w.props.onClick)}:M!=="axis"&&(te={onMouseLeave:Do(m.handleItemMouseLeave,w.props.onMouseLeave),onMouseEnter:Do(m.handleItemMouseEnter,w.props.onMouseEnter)});var V=A.cloneElement(w,z(z({},j.props),te));function Y(lt){return typeof R.dataKey=="function"?R.dataKey(lt.payload):null}if(ae)if(k>=0){var J,I;if(R.dataKey&&!R.allowDuplicatedCategory){var ie=typeof R.dataKey=="function"?Y:"payload.".concat(R.dataKey.toString());J=Ni(G,ie,D),I=E&&L&&Ni(L,ie,D)}else J=G==null?void 0:G[k],I=E&&L&&L[k];if(Q||X){var q=w.props.activeIndex!==void 0?w.props.activeIndex:k;return[A.cloneElement(w,z(z(z({},j.props),te),{},{activeIndex:q})),null,null]}if(!fe(J))return[V].concat(ea(m.renderActivePoints({item:j,activePoint:J,basePoint:I,childIndex:k,isRange:E})))}else{var se,ee=(se=m.getItemByXY(m.state.activeCoordinate))!==null&&se!==void 0?se:{graphicalItem:V},ve=ee.graphicalItem,We=ve.item,Re=We===void 0?w:We,Be=ve.childIndex,Ge=z(z(z({},j.props),te),{},{activeIndex:Be});return[A.cloneElement(Re,Ge),null,null]}return E?[V,null,null]:[V,null]}),oe(m,"renderCustomized",function(w,O,P){return A.cloneElement(w,z(z({key:"recharts-customized-".concat(P)},m.props),m.state))}),oe(m,"renderMap",{CartesianGrid:{handler:_s,once:!0},ReferenceArea:{handler:m.renderReferenceElement},ReferenceLine:{handler:_s},ReferenceDot:{handler:m.renderReferenceElement},XAxis:{handler:_s},YAxis:{handler:_s},Brush:{handler:m.renderBrush,once:!0},Bar:{handler:m.renderGraphicChild},Line:{handler:m.renderGraphicChild},Area:{handler:m.renderGraphicChild},Radar:{handler:m.renderGraphicChild},RadialBar:{handler:m.renderGraphicChild},Scatter:{handler:m.renderGraphicChild},Pie:{handler:m.renderGraphicChild},Funnel:{handler:m.renderGraphicChild},Tooltip:{handler:m.renderCursor,once:!0},PolarGrid:{handler:m.renderPolarGrid,once:!0},PolarAngleAxis:{handler:m.renderPolarAxis},PolarRadiusAxis:{handler:m.renderPolarAxis},Customized:{handler:m.renderCustomized}}),m.clipPathId="".concat((x=S.id)!==null&&x!==void 0?x:$r("recharts"),"-clip"),m.throttleTriggeredAfterMouseMove=Qh(m.triggeredAfterMouseMove,(T=S.throttleDelay)!==null&&T!==void 0?T:1e3/60),m.state={},m}return UF(b,p),RF(b,[{key:"componentDidMount",value:function(){var x,T;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(x=this.props.margin.left)!==null&&x!==void 0?x:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var x=this.props,T=x.children,m=x.data,w=x.height,O=x.layout,P=yt(T,Wt);if(P){var j=P.props.defaultIndex;if(!(typeof j!="number"||j<0||j>this.state.tooltipTicks.length-1)){var M=this.state.tooltipTicks[j]&&this.state.tooltipTicks[j].value,_=af(this.state,m,j,M),$=this.state.tooltipTicks[j].coordinate,R=(this.state.offset.top+w)/2,k=O==="horizontal",D=k?{x:$,y:R}:{y:$,x:R},C=this.state.formattedGraphicalItems.find(function(U){var G=U.item;return G.type.name==="Scatter"});C&&(D=z(z({},D),C.props.points[j].tooltipPosition),_=C.props.points[j].tooltipPayload);var B={activeTooltipIndex:j,isTooltipActive:!0,activeLabel:M,activePayload:_,activeCoordinate:D};this.setState(B),this.renderCursor(P),this.accessibilityManager.setIndex(j)}}}},{key:"getSnapshotBeforeUpdate",value:function(x,T){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==T.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==x.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==x.margin){var m,w;this.accessibilityManager.setDetails({offset:{left:(m=this.props.margin.left)!==null&&m!==void 0?m:0,top:(w=this.props.margin.top)!==null&&w!==void 0?w:0}})}return null}},{key:"componentDidUpdate",value:function(x){il([yt(x.children,Wt)],[yt(this.props.children,Wt)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var x=yt(this.props.children,Wt);if(x&&typeof x.props.shared=="boolean"){var T=x.props.shared?"axis":"item";return s.indexOf(T)>=0?T:i}return i}},{key:"getMouseInfo",value:function(x){if(!this.container)return null;var T=this.container,m=T.getBoundingClientRect(),w=aM(m),O={chartX:Math.round(x.pageX-w.left),chartY:Math.round(x.pageY-w.top)},P=m.width/T.offsetWidth||1,j=this.inRange(O.chartX,O.chartY,P);if(!j)return null;var M=this.state,_=M.xAxisMap,$=M.yAxisMap,R=this.getTooltipEventType(),k=cb(this.state,this.props.data,this.props.layout,j);if(R!=="axis"&&_&&$){var D=hr(_).scale,C=hr($).scale,B=D&&D.invert?D.invert(O.chartX):null,U=C&&C.invert?C.invert(O.chartY):null;return z(z({},O),{},{xValue:B,yValue:U},k)}return k?z(z({},O),k):null}},{key:"inRange",value:function(x,T){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,w=this.props.layout,O=x/m,P=T/m;if(w==="horizontal"||w==="vertical"){var j=this.state.offset,M=O>=j.left&&O<=j.left+j.width&&P>=j.top&&P<=j.top+j.height;return M?{x:O,y:P}:null}var _=this.state,$=_.angleAxisMap,R=_.radiusAxisMap;if($&&R){var k=hr($);return gy({x:O,y:P},k)}return null}},{key:"parseEventsOfWrapper",value:function(){var x=this.props.children,T=this.getTooltipEventType(),m=yt(x,Wt),w={};m&&T==="axis"&&(m.props.trigger==="click"?w={onClick:this.handleClick}:w={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var O=Di(this.props,this.handleOuterEvent);return z(z({},O),w)}},{key:"addListener",value:function(){Qc.on(ef,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Qc.removeListener(ef,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(x,T,m){for(var w=this.state.formattedGraphicalItems,O=0,P=w.length;O<P;O++){var j=w[O];if(j.item===x||j.props.key===x.key||T===Qt(j.item.type)&&m===j.childIndex)return j}return null}},{key:"renderClipPath",value:function(){var x=this.clipPathId,T=this.state.offset,m=T.left,w=T.top,O=T.height,P=T.width;return A.createElement("defs",null,A.createElement("clipPath",{id:x},A.createElement("rect",{x:m,y:w,height:O,width:P})))}},{key:"getXScales",value:function(){var x=this.state.xAxisMap;return x?Object.entries(x).reduce(function(T,m){var w=rb(m,2),O=w[0],P=w[1];return z(z({},T),{},oe({},O,P.scale))},{}):null}},{key:"getYScales",value:function(){var x=this.state.yAxisMap;return x?Object.entries(x).reduce(function(T,m){var w=rb(m,2),O=w[0],P=w[1];return z(z({},T),{},oe({},O,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(x){var T;return(T=this.state.xAxisMap)===null||T===void 0||(T=T[x])===null||T===void 0?void 0:T.scale}},{key:"getYScaleByAxisId",value:function(x){var T;return(T=this.state.yAxisMap)===null||T===void 0||(T=T[x])===null||T===void 0?void 0:T.scale}},{key:"getItemByXY",value:function(x){var T=this.state,m=T.formattedGraphicalItems,w=T.activeItem;if(m&&m.length)for(var O=0,P=m.length;O<P;O++){var j=m[O],M=j.props,_=j.item,$=_.type.defaultProps!==void 0?z(z({},_.type.defaultProps),_.props):_.props,R=Qt(_.type);if(R==="Bar"){var k=(M.data||[]).find(function(U){return G3(x,U)});if(k)return{graphicalItem:j,payload:k}}else if(R==="RadialBar"){var D=(M.data||[]).find(function(U){return gy(x,U)});if(D)return{graphicalItem:j,payload:D}}else if(Zo(j,w)||Jo(j,w)||si(j,w)){var C=V5({graphicalItem:j,activeTooltipItem:w,itemData:$.data}),B=$.activeIndex===void 0?C:$.activeIndex;return{graphicalItem:z(z({},j),{},{childIndex:B}),payload:si(j,w)?$.data[C]:j.props.data[C]}}}return null}},{key:"render",value:function(){var x=this;if(!Qf(this))return null;var T=this.props,m=T.children,w=T.className,O=T.width,P=T.height,j=T.style,M=T.compact,_=T.title,$=T.desc,R=nb(T,CF),k=de(R,!1);if(M)return A.createElement(eg,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},A.createElement(sl,Qn({},k,{width:O,height:P,title:_,desc:$}),this.renderClipPath(),rd(m,this.renderMap)));if(this.props.accessibilityLayer){var D,C;k.tabIndex=(D=this.props.tabIndex)!==null&&D!==void 0?D:0,k.role=(C=this.props.role)!==null&&C!==void 0?C:"application",k.onKeyDown=function(U){x.accessibilityManager.keyboardEvent(U)},k.onFocus=function(){x.accessibilityManager.focus()}}var B=this.parseEventsOfWrapper();return A.createElement(eg,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},A.createElement("div",Qn({className:ye("recharts-wrapper",w),style:z({position:"relative",cursor:"default",width:O,height:P},j)},B,{ref:function(G){x.container=G}}),A.createElement(sl,Qn({},k,{width:O,height:P,title:_,desc:$,style:HF}),this.renderClipPath(),rd(m,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(A.Component);oe(v,"displayName",r),oe(v,"defaultProps",z({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},f)),oe(v,"getDerivedStateFromProps",function(p,b){var S=p.dataKey,x=p.data,T=p.children,m=p.width,w=p.height,O=p.layout,P=p.stackOffset,j=p.margin,M=b.dataStartIndex,_=b.dataEndIndex;if(b.updateId===void 0){var $=fb(p);return z(z(z({},$),{},{updateId:0},h(z(z({props:p},$),{},{updateId:0}),b)),{},{prevDataKey:S,prevData:x,prevWidth:m,prevHeight:w,prevLayout:O,prevStackOffset:P,prevMargin:j,prevChildren:T})}if(S!==b.prevDataKey||x!==b.prevData||m!==b.prevWidth||w!==b.prevHeight||O!==b.prevLayout||P!==b.prevStackOffset||!ln(j,b.prevMargin)){var R=fb(p),k={chartX:b.chartX,chartY:b.chartY,isTooltipActive:b.isTooltipActive},D=z(z({},cb(b,x,O)),{},{updateId:b.updateId+1}),C=z(z(z({},R),k),D);return z(z(z({},C),h(z({props:p},C),b)),{},{prevDataKey:S,prevData:x,prevWidth:m,prevHeight:w,prevLayout:O,prevStackOffset:P,prevMargin:j,prevChildren:T})}if(!il(T,b.prevChildren)){var B,U,G,E,L=yt(T,Nn),F=L&&(B=(U=L.props)===null||U===void 0?void 0:U.startIndex)!==null&&B!==void 0?B:M,W=L&&(G=(E=L.props)===null||E===void 0?void 0:E.endIndex)!==null&&G!==void 0?G:_,K=F!==M||W!==_,X=!fe(x),Q=X&&!K?b.updateId:b.updateId+1;return z(z({updateId:Q},h(z(z({props:p},b),{},{updateId:Q,dataStartIndex:F,dataEndIndex:W}),b)),{},{prevChildren:T,dataStartIndex:F,dataEndIndex:W})}return null}),oe(v,"renderActiveDot",function(p,b,S){var x;return A.isValidElement(p)?x=A.cloneElement(p,b):he(p)?x=p(b):x=A.createElement(Ho,b),A.createElement(xe,{className:"recharts-active-dot",key:S},x)});var y=A.forwardRef(function(b,S){return A.createElement(v,Qn({},b,{ref:S}))});return y.displayName=v.displayName,y},iW=aW({chartName:"ComposedChart",GraphicalChild:[hi,Ar,Ln,xs],axisComponents:[{axisType:"xAxis",AxisComp:Os},{axisType:"yAxis",AxisComp:As},{axisType:"zAxis",AxisComp:gs}],formatAxisMap:m4});const ta=({className:e,width:t,height:r,rounded:n=!1})=>g.jsx("div",{className:ue("animate-pulse bg-gray-200",n?"rounded-full":"rounded",e),style:{width:typeof t=="number"?`${t}px`:t,height:typeof r=="number"?`${r}px`:r}}),gi=({className:e})=>g.jsxs("div",{className:ue("rounded-lg border border-gray-200 bg-white p-4",e),children:[g.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[g.jsx(ta,{className:"h-4 w-16"}),g.jsx(ta,{className:"h-4 w-4",rounded:!0})]}),g.jsxs("div",{className:"flex items-baseline gap-3",children:[g.jsx(ta,{className:"h-8 w-20"}),g.jsx(ta,{className:"h-6 w-12 rounded-md"})]})]}),hb=({className:e,chartType:t="line",height:r=300})=>{const n=o=>{if(o.length===0)return"";let s=`M ${o[0].x} ${o[0].y}`;for(let l=1;l<o.length;l++){const u=o[l-1],c=o[l],f=u.x+(c.x-u.x)*.4,d=u.y,h=u.x+(c.x-u.x)*.6,v=c.y;s+=` C ${f} ${d} ${h} ${v} ${c.x} ${c.y}`}return s},a=(o=7)=>Array.from({length:o},(c,f)=>({x:f/(o-1)*100,y:80-Math.random()*60})),i=()=>{switch(t){case"bar":return g.jsx("div",{className:"absolute inset-0 flex items-end justify-between px-4 pb-4",children:[...Array(7)].map((p,b)=>g.jsx(ta,{className:"w-8 bg-blue-100",height:`${Math.random()*60+20}%`},b))});case"line":const o=a(12),s=n(o),l=o[o.length-1],u=o[0],c=`${s} L ${l.x} 100 L ${u.x} 100 Z`;return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"skeleton-area-fill",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[g.jsx("stop",{offset:"0%",stopColor:"#8b5cf6",stopOpacity:"0.1",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.1;0.15;0.1",dur:"3s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#8b5cf6",stopOpacity:"0.02",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.02;0.05;0.02",dur:"3s",repeatCount:"indefinite"})})]}),g.jsxs("linearGradient",{id:"skeleton-line-shimmer",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#e2e8f0",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2.5s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"50%",stopColor:"#cbd5e1",stopOpacity:"0.6",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.6;0.3;0.6",dur:"2.5s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#e2e8f0",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2.5s",repeatCount:"indefinite"})})]})]}),g.jsx("path",{d:c,fill:"url(#skeleton-area-fill)"}),g.jsx("path",{d:s,stroke:"url(#skeleton-line-shimmer)",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]})});case"area":const f=a(),d=n(f),h=f[f.length-1],v=f[0],y=`${d} L ${h.x} 90 L ${v.x} 90 Z`;return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"skeleton-area-gradient",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.2",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.2;0.4;0.2",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:"0.05",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.05;0.1;0.05",dur:"2s",repeatCount:"indefinite"})})]}),g.jsxs("linearGradient",{id:"skeleton-area-line",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.4",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.4;0.8;0.4",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"50%",stopColor:"#3b82f6",stopOpacity:"0.8",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.8;0.4;0.8",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:"0.4",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.4;0.8;0.4",dur:"2s",repeatCount:"indefinite"})})]})]}),g.jsx("path",{d:y,fill:"url(#skeleton-area-gradient)"}),g.jsx("path",{d:n(f),stroke:"url(#skeleton-area-line)",strokeWidth:"2.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]})});case"pie":return g.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:g.jsxs("svg",{className:"w-32 h-32",viewBox:"0 0 42 42",children:[g.jsxs("defs",{children:[g.jsx("linearGradient",{id:"skeleton-pie-gradient-1",children:g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-2",children:g.jsx("stop",{offset:"0%",stopColor:"#10b981",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"0.5s"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-3",children:g.jsx("stop",{offset:"0%",stopColor:"#f59e0b",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"1s"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-4",children:g.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"1.5s"})})})]}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"#e5e7eb",strokeWidth:"3"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-1)",strokeWidth:"3",strokeDasharray:"40 60",strokeDashoffset:"25"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-2)",strokeWidth:"3",strokeDasharray:"25 75",strokeDashoffset:"65"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-3)",strokeWidth:"3",strokeDasharray:"20 80",strokeDashoffset:"90"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-4)",strokeWidth:"3",strokeDasharray:"15 85",strokeDashoffset:"110"})]})});default:return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("div",{className:"w-full h-full relative",children:[g.jsx("div",{className:"absolute inset-0 flex items-center",children:g.jsx("div",{className:"w-full h-0.5 bg-gradient-to-r from-transparent via-gray-300 to-transparent opacity-60",children:g.jsx("div",{className:"w-full h-full bg-gradient-to-r from-transparent via-blue-400 to-transparent animate-pulse"})})}),g.jsx("div",{className:"absolute inset-0 flex items-center justify-between px-2",children:[...Array(7)].map((p,b)=>g.jsx("div",{className:"w-2 h-2 bg-blue-300 rounded-full animate-pulse",style:{animationDelay:`${b*.2}s`}},b))})]})})}};return g.jsx("div",{className:ue("w-full",e),children:g.jsxs("div",{className:"relative bg-gray-50/30 py-3",children:[g.jsxs("div",{className:"relative mb-6",style:{height:`${r}px`},children:[g.jsxs("div",{className:"absolute left-0 top-0 h-full flex flex-col justify-between items-end pr-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"})]}),g.jsxs("div",{className:"ml-14 h-full relative overflow-hidden px-0 py-2 flex flex-col justify-between",children:[t!=="pie"&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"})]}),i()]}),t!=="pie"&&g.jsxs("div",{className:"ml-14 flex justify-between items-center mt-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"})]})]}),g.jsxs("div",{className:"flex items-center justify-between px-0 py-3 mt-2",children:[g.jsx("div",{className:"flex-1",children:g.jsx("div",{className:"bg-gray-100 h-3 rounded w-64"})}),g.jsxs("div",{className:"flex items-center gap-2 w-24 justify-center",children:[g.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded flex-1"})]})]})]})})},oW=({active:e,payload:t,label:r,config:n})=>{var o;if(!e||!t||!t.length)return null;const a=t.filter(s=>s.name&&s.name!==""&&s.name!==s.dataKey);if(a.length===0)return null;const i=((o=n.tooltip)==null?void 0:o.style)==="dark";return g.jsxs("div",{className:ue("rounded-lg border px-3 py-2 text-sm shadow-lg",i?"bg-gray-900 border-gray-700 text-white":"bg-white border-gray-200 text-gray-900"),children:[g.jsx("div",{className:ue("font-medium mb-1",i?"text-gray-300":"text-gray-600"),children:new Date(r||"").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),g.jsx("div",{className:"space-y-1",children:a.map((s,l)=>g.jsxs("div",{className:"flex items-center justify-between gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:s.color}}),g.jsx("span",{className:ue("text-sm",i?"text-gray-300":"text-gray-600"),children:s.name})]}),g.jsx("span",{className:ue("font-medium",i?"text-white":"text-gray-900"),children:typeof s.value=="number"?s.value.toLocaleString():s.value})]},l))})]})},pb=({config:e,className:t,isLoading:r,onDataPointClick:n})=>{var m,w;const{data:a,dataKey:i,color:o="#3b82f6",lines:s,dateRange:l,yAxisLabel:u,height:c=300,tooltip:f={show:!0,style:"dark"}}=e,h=(O=>{if(!O||O.length===0)return[];const P=[...O].sort((k,D)=>{const C=new Date(k.date),B=new Date(D.date);return C.getTime()-B.getTime()});let j,M;l!=null&&l.start&&(l!=null&&l.end)?(j=new Date(l.start),M=new Date(l.end)):(j=new Date(P[0].date),M=new Date(P[P.length-1].date));const _=new Map;P.forEach(k=>{_.set(k.date,k)});const $=[],R=new Date(j);for(;R<=M;){const k=R.toISOString().split("T")[0];if(_.has(k))$.push(_.get(k));else{const D={date:k,users:0,sessions:0,messages:0,totalTokens:0,inputTokens:0,outputTokens:0,agentRuns:0,toolRuns:0,modelRuns:0,codeTools:0,workflowTools:0,knowledgeTools:0,mcpTools:0,value:0,count:0};if(P.length>0){const C=P[0];Object.keys(C).forEach(B=>{typeof C[B]=="number"&&!(B in D)&&(D[B]=0)})}$.push(D)}R.setDate(R.getDate()+1)}return $})(a),v=O=>{const P=new Date(O);return isNaN(P.getTime())?O:P.toLocaleDateString("en-US",{month:"short",day:"numeric"})},y=()=>{if(!h||h.length===0)return 0;const O=h.length;return O<=20?0:O<=31?1:O<=61?2:Math.floor(O/7)-1},p=O=>b()&&!Number.isInteger(O)?"":O>=1e3?`${Math.floor(O/1e3)}k`:Math.floor(O).toString(),b=()=>{const O=["users","sessions","messages","runs","agents","tools","models","Number of Users","Number of Sessions","Number of Messages","Number of Agent Runs","Number of Tool Runs","Number of Model Runs","agentRuns","toolRuns","modelRuns"];return!!(u&&O.some(P=>u.toLowerCase().includes(P.toLowerCase()))||i&&O.some(P=>i.toLowerCase().includes(P.toLowerCase()))||e.title&&O.some(P=>e.title.toLowerCase().includes(P.toLowerCase()))||s&&s.some(P=>P.label&&O.some(j=>P.label.toLowerCase().includes(j.toLowerCase()))))},x=s&&s.length>0?s:[{dataKey:i||"value",color:o,label:e.title,strokeWidth:2}];if(r)return console.log("AnalyticsChart: Loading state active"),g.jsx(hb,{className:t,chartType:e.type,height:c});if(!a||a.length===0)return console.log("AnalyticsChart: No data provided",{data:a,config:e}),g.jsx("div",{className:ue("w-full",t),children:g.jsxs("div",{className:"relative bg-gray-50/30 py-6",children:[g.jsxs("div",{className:"relative h-[300px] mb-6",children:[g.jsxs("div",{className:"absolute left-0 top-0 h-full flex flex-col justify-between items-end pr-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"})]}),g.jsxs("div",{className:"ml-14 h-full relative overflow-hidden px-0 py-2 flex flex-col justify-between",children:[g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[g.jsx("div",{className:"bg-white border border-gray-300 rounded-[10px] w-12 h-12 flex items-center justify-center",children:g.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),g.jsxs("div",{className:"text-center max-w-[352px]",children:[g.jsx("h3",{className:"font-semibold text-gray-900 text-base mb-1",children:"There is no data to display for this period"}),g.jsx("p",{className:"font-normal text-gray-600 text-sm leading-5",children:"Try selecting a different date range or ensure your app is deployed and receiving traffic."})]})]})]}),g.jsxs("div",{className:"ml-14 flex justify-between items-center mt-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"})]})]}),g.jsxs("div",{className:"flex items-center justify-between px-0 py-3 mt-2",children:[g.jsx("div",{className:"flex-1",children:g.jsx("div",{className:"bg-gray-100 h-3 rounded w-64"})}),g.jsxs("div",{className:"flex items-center gap-2 w-24 justify-center",children:[g.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded flex-1"})]})]})]})});const T=O=>{var j;if(!n||!O||!O.activePayload)return;const P=(j=O.activePayload[0])==null?void 0:j.payload;P&&P.date&&(console.log("Chart data point clicked:",{date:P.date,data:P}),n(P,P.date))};return console.log("=== ANALYTICS CHART DEBUG ==="),console.log("AnalyticsChart config:",e),console.log("AnalyticsChart original data length:",a==null?void 0:a.length),console.log("AnalyticsChart filled data length:",h.length),console.log("AnalyticsChart date range (config):",l),console.log("AnalyticsChart actual date range:",h.length>0?{first:(m=h[0])==null?void 0:m.date,last:(w=h[h.length-1])==null?void 0:w.date,totalDays:h.length}:"No data"),console.log("AnalyticsChart dataKey:",i),console.log("Chart lines configuration:",x),console.log("Sample filled data points:",h.slice(0,3)),console.log("=== END ANALYTICS CHART DEBUG ==="),g.jsxs("div",{className:ue("w-full",t),children:[g.jsx("div",{className:"relative bg-gray-50/30 py-6",children:g.jsx(Zk,{width:"100%",height:c,children:g.jsxs(iW,{data:h,onClick:T,margin:{top:20,right:30,left:20,bottom:20},children:[g.jsx("defs",{children:x.map((O,P)=>g.jsxs("linearGradient",{id:`gradient-${O.dataKey}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"5%",stopColor:O.color,stopOpacity:.08}),g.jsx("stop",{offset:"95%",stopColor:O.color,stopOpacity:.01})]},`gradient-${P}`))}),g.jsx(Pg,{strokeDasharray:"2 2",className:"opacity-30",stroke:"#d1d5db",horizontal:!0,vertical:!1}),g.jsx(Os,{dataKey:"date",tickFormatter:v,axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#6b7280"},tickMargin:10,interval:y()}),g.jsx(As,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#6b7280"},tickFormatter:p,tickMargin:10,allowDecimals:!b(),domain:b()?["dataMin","dataMax"]:void 0,label:u?{value:u,angle:-90,position:"insideLeft",style:{textAnchor:"middle",fontSize:12,fill:"#6b7280"}}:void 0}),f.show&&g.jsx(Wt,{content:O=>g.jsx(oW,{...O,config:e}),cursor:{stroke:"#d1d5db",strokeWidth:1,strokeDasharray:"4 4"},allowEscapeViewBox:{x:!1,y:!1}}),x.map(O=>g.jsx(Ar,{type:"monotone",dataKey:O.dataKey,stroke:"none",fill:`url(#gradient-${O.dataKey})`,fillOpacity:1,isAnimationActive:!1,name:""},`area-${O.dataKey}`)),x.map(O=>g.jsx(hi,{type:"monotone",dataKey:O.dataKey,stroke:O.color,strokeWidth:2.5,strokeDasharray:O.strokeDasharray,dot:!1,activeDot:{r:5,fill:O.color,stroke:O.color,strokeWidth:2},name:O.label},O.dataKey))]})})}),g.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[g.jsx("div",{children:l&&g.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing data from ",new Date(l.start).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"})," - ",new Date(l.end).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"})]})}),g.jsx("div",{className:"flex items-center gap-4",children:g.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:x.map(O=>g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:O.color}}),g.jsx("span",{children:O.label})]},O.dataKey))})})]})]})},vb=({config:e,className:t})=>{const{title:r,data:n,columns:a,pagination:i={enabled:!0,pageSize:10},sorting:o={enabled:!0},filtering:s={enabled:!0,searchable:!0}}=e,[l,u]=A.useState(o.defaultSort||null),[c,f]=A.useState(""),[d,h]=A.useState(1),v=A.useMemo(()=>{let m=[...n];return s.searchable&&c&&(m=m.filter(w=>a.some(O=>{const P=w[O.key];return P==null?void 0:P.toString().toLowerCase().includes(c.toLowerCase())}))),l&&m.sort((w,O)=>{const P=w[l.key],j=O[l.key];if(typeof P=="number"&&typeof j=="number")return l.order==="asc"?P-j:j-P;const M=(P==null?void 0:P.toString())||"",_=(j==null?void 0:j.toString())||"",$=M.localeCompare(_);return l.order==="asc"?$:-$}),m},[n,a,c,l,s.searchable]),y=i.enabled?Math.ceil(v.length/i.pageSize):1,p=i.enabled?v.slice((d-1)*i.pageSize,d*i.pageSize):v,b=m=>{!o.enabled||!m.sortable||u(w=>(w==null?void 0:w.key)===m.key?w.order==="asc"?{key:m.key,order:"desc"}:null:{key:m.key,order:"asc"})},S=m=>{f(m),h(1)},x=(m,w,O)=>w.render?w.render(m,O):w.formatter?w.formatter(m,O):typeof m=="number"?m.toLocaleString():(m==null?void 0:m.toString())||"-",T=m=>!o.enabled||!m.sortable?null:(l==null?void 0:l.key)===m.key?l.order==="asc"?g.jsx(mf,{className:"w-4 h-4"}):g.jsx(ua,{className:"w-4 h-4"}):g.jsxs("div",{className:"flex flex-col",children:[g.jsx(mf,{className:"w-3 h-3 opacity-30"}),g.jsx(ua,{className:"w-3 h-3 opacity-30 -mt-1"})]});return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("h3",{className:"text-lg font-semibold",children:r}),s.enabled&&s.searchable&&g.jsxs("div",{className:"relative",children:[g.jsx(gf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),g.jsx("input",{type:"text",placeholder:"Search...",value:c,onChange:m=>S(m.target.value),className:"pl-10 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),g.jsx("div",{className:"overflow-x-auto border border-gray-200 rounded-lg",children:g.jsxs("table",{className:"w-full",children:[g.jsx("thead",{className:"bg-gray-50",children:g.jsx("tr",{children:a.map(m=>g.jsx("th",{className:ue("px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",m.sortable&&o.enabled&&"cursor-pointer hover:bg-gray-100",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:{width:m.width},onClick:()=>b(m),children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{children:m.title}),T(m)]})},m.key))})}),g.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:p.map((m,w)=>g.jsx("tr",{className:"hover:bg-gray-50 transition-colors",children:a.map(O=>g.jsx("td",{className:ue("px-4 py-3 text-sm text-gray-900",O.align==="center"&&"text-center",O.align==="right"&&"text-right"),children:x(m[O.key],O,m)},O.key))},w))})]})}),i.enabled&&y>1&&g.jsxs("div",{className:"flex items-center justify-between mt-4",children:[g.jsxs("div",{className:"text-sm text-gray-500",children:["Showing ",(d-1)*i.pageSize+1," to"," ",Math.min(d*i.pageSize,v.length)," of"," ",v.length," results"]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("button",{onClick:()=>h(m=>Math.max(1,m-1)),disabled:d===1,className:"px-3 py-1 text-sm border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),Array.from({length:Math.min(5,y)},(m,w)=>{const O=Math.max(1,Math.min(y-4,d-2))+w;return O>y?null:g.jsx("button",{onClick:()=>h(O),className:ue("px-3 py-1 text-sm border rounded",d===O?"bg-blue-500 text-white border-blue-500":"border-gray-200 hover:bg-gray-50"),children:O},O)}),g.jsx("button",{onClick:()=>h(m=>Math.min(y,m+1)),disabled:d===y,className:"px-3 py-1 text-sm border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]}),p.length===0&&g.jsx("div",{className:"text-center py-8 text-gray-500",children:c?"No results found for your search.":"No data available."})]})},sW=(e,t)=>{switch(e){case"human":return t==="agent"?"agent-avatars":"avatars";case"logo":return"profileLogos";case"icon":case"inlineTool":case"toolLibrary":case"KNOWLEDGE":case"MCP":return"profileIcons";default:return t==="agent"?"agent-avatars":"avatars"}},lW=e=>{if(!e)return null;if(typeof e=="string")try{return JSON.parse(e)}catch{return{name:e,type:"human"}}return e},uW=(e,t)=>{const r=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#06B6D4","#84CC16"],n=e.split("").reduce((a,i)=>a+i.charCodeAt(0),0)%r.length;if(t==="workflowtool"){const a=e.toLowerCase();let i="toolLibrary";return a.includes("code")||a.includes("inline")||a.includes("calculate")?i="inlineTool":a.includes("knowledge")||a.includes("document")||a.includes("fetch")?i="KNOWLEDGE":(a.includes("mcp")||a.includes("protocol"))&&(i="MCP"),{name:"fallback",type:i,color:r[n]}}return t==="model"?{name:"fallback",type:"icon",color:r[n]}:{name:"fallback",type:t==="agent"?"human":"icon",color:r[n]}},cW=(e,t)=>{if(!(e!=null&&e.name))return"";if(t==="url")return e.name;if(t==="model")return"";const r=window.location.origin,n=sW(e.type||"human",t);return`${r}/agenticai/assets/${n}/${e.name}.svg`},yb=e=>{if(!e)return"https://agent-platform.kore.ai/assets/icons/models/custom-api.svg";const t=e.toLowerCase(),r={openai:"Open AI.svg","open ai":"Open AI.svg",chatopenai:"Open AI.svg",gpt:"Open AI.svg",anthropic:"Anthropic.svg",claude:"Anthropic.svg",google:"Google.svg",gemini:"Google.svg",chatgooglegenerativeai:"Google.svg",googlegenerativeai:"Google.svg",palm:"Google.svg",azurechatopenai:"Azure Open AI.svg","azure open ai":"Azure Open AI.svg",azureopenai:"Azure Open AI.svg","azure openai":"Azure Open AI.svg",azure:"Azure Open AI.svg",aws:"AWS Bedrock.svg",bedrock:"AWS Bedrock.svg","aws bedrock":"AWS Bedrock.svg",awsbedrock:"AWS Bedrock.svg",amazon:"AWS Bedrock.svg",cohere:"Cohere.svg",api:"API.svg",custom:"custom-api.svg","custom-api":"custom-api.svg",customapi:"custom-api.svg"};if(r[t])return`https://agent-platform.kore.ai/assets/icons/models/${r[t]}`;for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return`https://agent-platform.kore.ai/assets/icons/models/${a}`;return"https://agent-platform.kore.ai/assets/icons/models/custom-api.svg"},fW={xs:"w-6 h-6 text-xs",small:"w-8 h-8 text-sm",medium:"w-10 h-10 text-base",large:"w-12 h-12 text-lg"},Rt={inlineTool:`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3533_7514)">
205
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ib(e,t){if(e){if(typeof e=="string")return nf(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nf(e,t)}}function GF(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function KF(e){if(Array.isArray(e))return nf(e)}function nf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ob(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function z(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ob(Object(r),!0).forEach(function(n){oe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ob(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function oe(e,t,r){return t=sb(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sb(e){var t=VF(e,"string");return Jn(t)=="symbol"?t:t+""}function VF(e,t){if(Jn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Jn(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var qF={xAxis:["bottom","top"],yAxis:["left","right"]},HF={width:"100%",height:"100%"},lb={x:0,y:0};function _s(e){return e}var YF=function(t,r){return r==="horizontal"?t.x:r==="vertical"?t.y:r==="centric"?t.angle:t.radius},XF=function(t,r,n,a){var i=r.find(function(c){return c&&c.index===n});if(i){if(t==="horizontal")return{x:i.coordinate,y:a.y};if(t==="vertical")return{x:a.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,s=a.radius;return z(z(z({},a),rt(a.cx,a.cy,s,o)),{},{angle:o,radius:s})}var l=i.coordinate,u=a.angle;return z(z(z({},a),rt(a.cx,a.cy,l,u)),{},{angle:u,radius:l})}return lb},Es=function(t,r){var n=r.graphicalItems,a=r.dataStartIndex,i=r.dataEndIndex,o=(n??[]).reduce(function(s,l){var u=l.props.data;return u&&u.length?[].concat(ea(s),ea(u)):s},[]);return o.length>0?o:t&&t.length&&Z(a)&&Z(i)?t.slice(a,i+1):[]};function ub(e){return e==="number"?[0,"auto"]:void 0}var af=function(t,r,n,a){var i=t.graphicalItems,o=t.tooltipAxis,s=Es(r,t);return n<0||!i||!i.length||n>=s.length?null:i.reduce(function(l,u){var c,f=(c=u.props.data)!==null&&c!==void 0?c:r;f&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(f=f.slice(t.dataStartIndex,t.dataEndIndex+1));var d;if(o.dataKey&&!o.allowDuplicatedCategory){var h=f===void 0?s:f;d=Ni(h,o.dataKey,a)}else d=f&&f[n]||s[n];return d?[].concat(ea(l),[vy(u,d)]):l},[])},cb=function(t,r,n,a){var i=a||{x:t.chartX,y:t.chartY},o=YF(i,n),s=t.orderedTooltipTicks,l=t.tooltipAxis,u=t.tooltipTicks,c=CI(o,s,u,l);if(c>=0&&u){var f=u[c]&&u[c].value,d=af(t,r,c,f),h=XF(n,s,c,i);return{activeTooltipIndex:c,activeLabel:f,activePayload:d,activeCoordinate:h}}return null},ZF=function(t,r){var n=r.axes,a=r.graphicalItems,i=r.axisType,o=r.axisIdKey,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.layout,f=t.children,d=t.stackOffset,h=sy(c,i);return n.reduce(function(v,y){var p,b=y.type.defaultProps!==void 0?z(z({},y.type.defaultProps),y.props):y.props,S=b.type,x=b.dataKey,T=b.allowDataOverflow,m=b.allowDuplicatedCategory,w=b.scale,O=b.ticks,P=b.includeHidden,j=b[o];if(v[j])return v;var M=Es(t.data,{graphicalItems:a.filter(function(F){var W,K=o in F.props?F.props[o]:(W=F.type.defaultProps)===null||W===void 0?void 0:W[o];return K===j}),dataStartIndex:l,dataEndIndex:u}),_=M.length,$,R,k;SF(b.domain,T,S)&&($=qu(b.domain,null,T),h&&(S==="number"||w!=="auto")&&(k=za(M,x,"category")));var D=ub(S);if(!$||$.length===0){var C,B=(C=b.domain)!==null&&C!==void 0?C:D;if(x){if($=za(M,x,S),S==="category"&&h){var U=mO($);m&&U?(R=$,$=Qo(0,_)):m||($=py(B,$,y).reduce(function(F,W){return F.indexOf(W)>=0?F:[].concat(ea(F),[W])},[]))}else if(S==="category")m?$=$.filter(function(F){return F!==""&&!fe(F)}):$=py(B,$,y).reduce(function(F,W){return F.indexOf(W)>=0||W===""||fe(W)?F:[].concat(ea(F),[W])},[]);else if(S==="number"){var G=II(M,a.filter(function(F){var W,K,X=o in F.props?F.props[o]:(W=F.type.defaultProps)===null||W===void 0?void 0:W[o],Q="hide"in F.props?F.props.hide:(K=F.type.defaultProps)===null||K===void 0?void 0:K.hide;return X===j&&(P||!Q)}),x,i,c);G&&($=G)}h&&(S==="number"||w!=="auto")&&(k=za(M,x,"category"))}else h?$=Qo(0,_):s&&s[j]&&s[j].hasStack&&S==="number"?$=d==="expand"?[0,1]:fy(s[j].stackGroups,l,u):$=oy(M,a.filter(function(F){var W=o in F.props?F.props[o]:F.type.defaultProps[o],K="hide"in F.props?F.props.hide:F.type.defaultProps.hide;return W===j&&(P||!K)}),S,c,!0);if(S==="number")$=Jc(f,$,j,i,O),B&&($=qu(B,$,T));else if(S==="category"&&B){var E=B,L=$.every(function(F){return E.indexOf(F)>=0});L&&($=E)}}return z(z({},v),{},oe({},j,z(z({},b),{},{axisType:i,domain:$,categoricalDomain:k,duplicateDomain:R,originalDomain:(p=b.domain)!==null&&p!==void 0?p:D,isCategorical:h,layout:c})))},{})},JF=function(t,r){var n=r.graphicalItems,a=r.Axis,i=r.axisType,o=r.axisIdKey,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.layout,f=t.children,d=Es(t.data,{graphicalItems:n,dataStartIndex:l,dataEndIndex:u}),h=d.length,v=sy(c,i),y=-1;return n.reduce(function(p,b){var S=b.type.defaultProps!==void 0?z(z({},b.type.defaultProps),b.props):b.props,x=S[o],T=ub("number");if(!p[x]){y++;var m;return v?m=Qo(0,h):s&&s[x]&&s[x].hasStack?(m=fy(s[x].stackGroups,l,u),m=Jc(f,m,x,i)):(m=qu(T,oy(d,n.filter(function(w){var O,P,j=o in w.props?w.props[o]:(O=w.type.defaultProps)===null||O===void 0?void 0:O[o],M="hide"in w.props?w.props.hide:(P=w.type.defaultProps)===null||P===void 0?void 0:P.hide;return j===x&&!M}),"number",c),a.defaultProps.allowDataOverflow),m=Jc(f,m,x,i)),z(z({},p),{},oe({},x,z(z({axisType:i},a.defaultProps),{},{hide:!0,orientation:wt(qF,"".concat(i,".").concat(y%2),null),domain:m,originalDomain:T,isCategorical:v,layout:c})))}return p},{})},QF=function(t,r){var n=r.axisType,a=n===void 0?"xAxis":n,i=r.AxisComp,o=r.graphicalItems,s=r.stackGroups,l=r.dataStartIndex,u=r.dataEndIndex,c=t.children,f="".concat(a,"Id"),d=dt(c,i),h={};return d&&d.length?h=ZF(t,{axes:d,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u}):o&&o.length&&(h=JF(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u})),h},eW=function(t){var r=hr(t),n=ur(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:Fl(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Io(r,n)}},fb=function(t){var r=t.children,n=t.defaultShowTooltip,a=yt(r,Nn),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!n}},tW=function(t){return!t||!t.length?!1:t.some(function(r){var n=Qt(r&&r.type);return n&&n.indexOf("Bar")>=0})},db=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},rW=function(t,r){var n=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,s=t.yAxisMap,l=s===void 0?{}:s,u=n.width,c=n.height,f=n.children,d=n.margin||{},h=yt(f,Nn),v=yt(f,vn),y=Object.keys(l).reduce(function(m,w){var O=l[w],P=O.orientation;return!O.mirror&&!O.hide?z(z({},m),{},oe({},P,m[P]+O.width)):m},{left:d.left||0,right:d.right||0}),p=Object.keys(o).reduce(function(m,w){var O=o[w],P=O.orientation;return!O.mirror&&!O.hide?z(z({},m),{},oe({},P,wt(m,"".concat(P))+O.height)):m},{top:d.top||0,bottom:d.bottom||0}),b=z(z({},p),y),S=b.bottom;h&&(b.bottom+=h.props.height||Nn.defaultProps.height),v&&r&&(b=NI(b,a,n,r));var x=u-b.left-b.right,T=c-b.top-b.bottom;return z(z({brushBottom:S},b),{},{width:Math.max(x,0),height:Math.max(T,0)})},nW=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},aW=function(t){var r=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,s=o===void 0?["axis"]:o,l=t.axisComponents,u=t.legendContent,c=t.formatAxisMap,f=t.defaultProps,d=function(b,S){var x=S.graphicalItems,T=S.stackGroups,m=S.offset,w=S.updateId,O=S.dataStartIndex,P=S.dataEndIndex,j=b.barSize,M=b.layout,_=b.barGap,$=b.barCategoryGap,R=b.maxBarSize,k=db(M),D=k.numericAxisName,C=k.cateAxisName,B=tW(x),U=[];return x.forEach(function(G,E){var L=Es(b.data,{graphicalItems:[G],dataStartIndex:O,dataEndIndex:P}),F=G.type.defaultProps!==void 0?z(z({},G.type.defaultProps),G.props):G.props,W=F.dataKey,K=F.maxBarSize,X=F["".concat(D,"Id")],Q=F["".concat(C,"Id")],ae={},te=l.reduce(function(Ge,lt){var Ai,Ti,aa=S["".concat(lt.axisType,"Map")],Pi=F["".concat(lt.axisType,"Id")];aa&&aa[Pi]||lt.axisType==="zAxis"||(process.env.NODE_ENV!=="production"?pt(!1,"Specifying a(n) ".concat(lt.axisType,"Id requires a corresponding ").concat(lt.axisType,"Id on the targeted graphical component ").concat((Ai=G==null||(Ti=G.type)===null||Ti===void 0?void 0:Ti.displayName)!==null&&Ai!==void 0?Ai:"")):pt());var _i=aa[Pi];return z(z({},Ge),{},oe(oe({},lt.axisType,_i),"".concat(lt.axisType,"Ticks"),ur(_i)))},ae),V=te[C],Y=te["".concat(C,"Ticks")],J=T&&T[X]&&T[X].hasStack&&HI(G,T[X].stackGroups),I=Qt(G.type).indexOf("Bar")>=0,ie=Io(V,Y),q=[],se=B&&kI({barSize:j,stackGroups:T,totalSize:nW(te,C)});if(I){var ee,ve,We=fe(K)?R:K,Re=(ee=(ve=Io(V,Y,!0))!==null&&ve!==void 0?ve:We)!==null&&ee!==void 0?ee:0;q=MI({barGap:_,barCategoryGap:$,bandSize:Re!==ie?Re:ie,sizeList:se[Q],maxBarSize:We}),Re!==ie&&(q=q.map(function(Ge){return z(z({},Ge),{},{position:z(z({},Ge.position),{},{offset:Ge.position.offset-Re/2})})}))}var Be=G&&G.type&&G.type.getComposedData;Be&&U.push({props:z(z({},Be(z(z({},te),{},{displayedData:L,props:b,dataKey:W,item:G,bandSize:ie,barPosition:q,offset:m,stackedData:J,layout:M,dataStartIndex:O,dataEndIndex:P}))),{},oe(oe(oe({key:G.key||"item-".concat(E)},D,te[D]),C,te[C]),"animationId",w)),childIndex:$O(G,b.children),item:G})}),U},h=function(b,S){var x=b.props,T=b.dataStartIndex,m=b.dataEndIndex,w=b.updateId;if(!Qf({props:x}))return null;var O=x.children,P=x.layout,j=x.stackOffset,M=x.data,_=x.reverseStackOrder,$=db(P),R=$.numericAxisName,k=$.cateAxisName,D=dt(O,n),C=KI(M,D,"".concat(R,"Id"),"".concat(k,"Id"),j,_),B=l.reduce(function(F,W){var K="".concat(W.axisType,"Map");return z(z({},F),{},oe({},K,QF(x,z(z({},W),{},{graphicalItems:D,stackGroups:W.axisType===R&&C,dataStartIndex:T,dataEndIndex:m}))))},{}),U=rW(z(z({},B),{},{props:x,graphicalItems:D}),S==null?void 0:S.legendBBox);Object.keys(B).forEach(function(F){B[F]=c(x,B[F],U,F.replace("Map",""),r)});var G=B["".concat(k,"Map")],E=eW(G),L=d(x,z(z({},B),{},{dataStartIndex:T,dataEndIndex:m,updateId:w,graphicalItems:D,stackGroups:C,offset:U}));return z(z({formattedGraphicalItems:L,graphicalItems:D,offset:U,stackGroups:C},E),B)},v=function(p){function b(S){var x,T,m;return IF(this,b),m=BF(this,b,[S]),oe(m,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),oe(m,"accessibilityManager",new OF),oe(m,"handleLegendBBoxUpdate",function(w){if(w){var O=m.state,P=O.dataStartIndex,j=O.dataEndIndex,M=O.updateId;m.setState(z({legendBBox:w},h({props:m.props,dataStartIndex:P,dataEndIndex:j,updateId:M},z(z({},m.state),{},{legendBBox:w}))))}}),oe(m,"handleReceiveSyncEvent",function(w,O,P){if(m.props.syncId===w){if(P===m.eventEmitterSymbol&&typeof m.props.syncMethod!="function")return;m.applySyncEvent(O)}}),oe(m,"handleBrushChange",function(w){var O=w.startIndex,P=w.endIndex;if(O!==m.state.dataStartIndex||P!==m.state.dataEndIndex){var j=m.state.updateId;m.setState(function(){return z({dataStartIndex:O,dataEndIndex:P},h({props:m.props,dataStartIndex:O,dataEndIndex:P,updateId:j},m.state))}),m.triggerSyncEvent({dataStartIndex:O,dataEndIndex:P})}}),oe(m,"handleMouseEnter",function(w){var O=m.getMouseInfo(w);if(O){var P=z(z({},O),{},{isTooltipActive:!0});m.setState(P),m.triggerSyncEvent(P);var j=m.props.onMouseEnter;he(j)&&j(P,w)}}),oe(m,"triggeredAfterMouseMove",function(w){var O=m.getMouseInfo(w),P=O?z(z({},O),{},{isTooltipActive:!0}):{isTooltipActive:!1};m.setState(P),m.triggerSyncEvent(P);var j=m.props.onMouseMove;he(j)&&j(P,w)}),oe(m,"handleItemMouseEnter",function(w){m.setState(function(){return{isTooltipActive:!0,activeItem:w,activePayload:w.tooltipPayload,activeCoordinate:w.tooltipPosition||{x:w.cx,y:w.cy}}})}),oe(m,"handleItemMouseLeave",function(){m.setState(function(){return{isTooltipActive:!1}})}),oe(m,"handleMouseMove",function(w){w.persist(),m.throttleTriggeredAfterMouseMove(w)}),oe(m,"handleMouseLeave",function(w){m.throttleTriggeredAfterMouseMove.cancel();var O={isTooltipActive:!1};m.setState(O),m.triggerSyncEvent(O);var P=m.props.onMouseLeave;he(P)&&P(O,w)}),oe(m,"handleOuterEvent",function(w){var O=jO(w),P=wt(m.props,"".concat(O));if(O&&he(P)){var j,M;/.*touch.*/i.test(O)?M=m.getMouseInfo(w.changedTouches[0]):M=m.getMouseInfo(w),P((j=M)!==null&&j!==void 0?j:{},w)}}),oe(m,"handleClick",function(w){var O=m.getMouseInfo(w);if(O){var P=z(z({},O),{},{isTooltipActive:!0});m.setState(P),m.triggerSyncEvent(P);var j=m.props.onClick;he(j)&&j(P,w)}}),oe(m,"handleMouseDown",function(w){var O=m.props.onMouseDown;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleMouseUp",function(w){var O=m.props.onMouseUp;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleTouchMove",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.throttleTriggeredAfterMouseMove(w.changedTouches[0])}),oe(m,"handleTouchStart",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.handleMouseDown(w.changedTouches[0])}),oe(m,"handleTouchEnd",function(w){w.changedTouches!=null&&w.changedTouches.length>0&&m.handleMouseUp(w.changedTouches[0])}),oe(m,"handleDoubleClick",function(w){var O=m.props.onDoubleClick;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"handleContextMenu",function(w){var O=m.props.onContextMenu;if(he(O)){var P=m.getMouseInfo(w);O(P,w)}}),oe(m,"triggerSyncEvent",function(w){m.props.syncId!==void 0&&Qc.emit(ef,m.props.syncId,w,m.eventEmitterSymbol)}),oe(m,"applySyncEvent",function(w){var O=m.props,P=O.layout,j=O.syncMethod,M=m.state.updateId,_=w.dataStartIndex,$=w.dataEndIndex;if(w.dataStartIndex!==void 0||w.dataEndIndex!==void 0)m.setState(z({dataStartIndex:_,dataEndIndex:$},h({props:m.props,dataStartIndex:_,dataEndIndex:$,updateId:M},m.state)));else if(w.activeTooltipIndex!==void 0){var R=w.chartX,k=w.chartY,D=w.activeTooltipIndex,C=m.state,B=C.offset,U=C.tooltipTicks;if(!B)return;if(typeof j=="function")D=j(U,w);else if(j==="value"){D=-1;for(var G=0;G<U.length;G++)if(U[G].value===w.activeLabel){D=G;break}}var E=z(z({},B),{},{x:B.left,y:B.top}),L=Math.min(R,E.x+E.width),F=Math.min(k,E.y+E.height),W=U[D]&&U[D].value,K=af(m.state,m.props.data,D),X=U[D]?{x:P==="horizontal"?U[D].coordinate:L,y:P==="horizontal"?F:U[D].coordinate}:lb;m.setState(z(z({},w),{},{activeLabel:W,activeCoordinate:X,activePayload:K,activeTooltipIndex:D}))}else m.setState(w)}),oe(m,"renderCursor",function(w){var O,P=m.state,j=P.isTooltipActive,M=P.activeCoordinate,_=P.activePayload,$=P.offset,R=P.activeTooltipIndex,k=P.tooltipAxisBandSize,D=m.getTooltipEventType(),C=(O=w.props.active)!==null&&O!==void 0?O:j,B=m.props.layout,U=w.key||"_recharts-cursor";return A.createElement(jF,{key:U,activeCoordinate:M,activePayload:_,activeTooltipIndex:R,chartName:r,element:w,isActive:C,layout:B,offset:$,tooltipAxisBandSize:k,tooltipEventType:D})}),oe(m,"renderPolarAxis",function(w,O,P){var j=wt(w,"type.axisType"),M=wt(m.state,"".concat(j,"Map")),_=w.type.defaultProps,$=_!==void 0?z(z({},_),w.props):w.props,R=M&&M[$["".concat(j,"Id")]];return A.cloneElement(w,z(z({},R),{},{className:ye(j,R.className),key:w.key||"".concat(O,"-").concat(P),ticks:ur(R,!0)}))}),oe(m,"renderPolarGrid",function(w){var O=w.props,P=O.radialLines,j=O.polarAngles,M=O.polarRadius,_=m.state,$=_.radiusAxisMap,R=_.angleAxisMap,k=hr($),D=hr(R),C=D.cx,B=D.cy,U=D.innerRadius,G=D.outerRadius;return A.cloneElement(w,{polarAngles:Array.isArray(j)?j:ur(D,!0).map(function(E){return E.coordinate}),polarRadius:Array.isArray(M)?M:ur(k,!0).map(function(E){return E.coordinate}),cx:C,cy:B,innerRadius:U,outerRadius:G,key:w.key||"polar-grid",radialLines:P})}),oe(m,"renderLegend",function(){var w=m.state.formattedGraphicalItems,O=m.props,P=O.children,j=O.width,M=O.height,_=m.props.margin||{},$=j-(_.left||0)-(_.right||0),R=ry({children:P,formattedGraphicalItems:w,legendWidth:$,legendContent:u});if(!R)return null;var k=R.item,D=nb(R,$F);return A.cloneElement(k,z(z({},D),{},{chartWidth:j,chartHeight:M,margin:_,onBBoxUpdate:m.handleLegendBBoxUpdate}))}),oe(m,"renderTooltip",function(){var w,O=m.props,P=O.children,j=O.accessibilityLayer,M=yt(P,Wt);if(!M)return null;var _=m.state,$=_.isTooltipActive,R=_.activeCoordinate,k=_.activePayload,D=_.activeLabel,C=_.offset,B=(w=M.props.active)!==null&&w!==void 0?w:$;return A.cloneElement(M,{viewBox:z(z({},C),{},{x:C.left,y:C.top}),active:B,label:D,payload:B?k:[],coordinate:R,accessibilityLayer:j})}),oe(m,"renderBrush",function(w){var O=m.props,P=O.margin,j=O.data,M=m.state,_=M.offset,$=M.dataStartIndex,R=M.dataEndIndex,k=M.updateId;return A.cloneElement(w,{key:w.key||"_recharts-brush",onChange:Do(m.handleBrushChange,w.props.onChange),data:j,x:Z(w.props.x)?w.props.x:_.left,y:Z(w.props.y)?w.props.y:_.top+_.height+_.brushBottom-(P.bottom||0),width:Z(w.props.width)?w.props.width:_.width,startIndex:$,endIndex:R,updateId:"brush-".concat(k)})}),oe(m,"renderReferenceElement",function(w,O,P){if(!w)return null;var j=m,M=j.clipPathId,_=m.state,$=_.xAxisMap,R=_.yAxisMap,k=_.offset,D=w.type.defaultProps||{},C=w.props,B=C.xAxisId,U=B===void 0?D.xAxisId:B,G=C.yAxisId,E=G===void 0?D.yAxisId:G;return A.cloneElement(w,{key:w.key||"".concat(O,"-").concat(P),xAxis:$[U],yAxis:R[E],viewBox:{x:k.left,y:k.top,width:k.width,height:k.height},clipPathId:M})}),oe(m,"renderActivePoints",function(w){var O=w.item,P=w.activePoint,j=w.basePoint,M=w.childIndex,_=w.isRange,$=[],R=O.props.key,k=O.item.type.defaultProps!==void 0?z(z({},O.item.type.defaultProps),O.item.props):O.item.props,D=k.activeDot,C=k.dataKey,B=z(z({index:M,dataKey:C,cx:P.x,cy:P.y,r:4,fill:Ku(O.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},de(D,!1)),Di(D));return $.push(b.renderActiveDot(D,B,"".concat(R,"-activePoint-").concat(M))),j?$.push(b.renderActiveDot(D,z(z({},B),{},{cx:j.x,cy:j.y}),"".concat(R,"-basePoint-").concat(M))):_&&$.push(null),$}),oe(m,"renderGraphicChild",function(w,O,P){var j=m.filterFormatItem(w,O,P);if(!j)return null;var M=m.getTooltipEventType(),_=m.state,$=_.isTooltipActive,R=_.tooltipAxis,k=_.activeTooltipIndex,D=_.activeLabel,C=m.props.children,B=yt(C,Wt),U=j.props,G=U.points,E=U.isRange,L=U.baseLine,F=j.item.type.defaultProps!==void 0?z(z({},j.item.type.defaultProps),j.item.props):j.item.props,W=F.activeDot,K=F.hide,X=F.activeBar,Q=F.activeShape,ae=!!(!K&&$&&B&&(W||X||Q)),te={};M!=="axis"&&B&&B.props.trigger==="click"?te={onClick:Do(m.handleItemMouseEnter,w.props.onClick)}:M!=="axis"&&(te={onMouseLeave:Do(m.handleItemMouseLeave,w.props.onMouseLeave),onMouseEnter:Do(m.handleItemMouseEnter,w.props.onMouseEnter)});var V=A.cloneElement(w,z(z({},j.props),te));function Y(lt){return typeof R.dataKey=="function"?R.dataKey(lt.payload):null}if(ae)if(k>=0){var J,I;if(R.dataKey&&!R.allowDuplicatedCategory){var ie=typeof R.dataKey=="function"?Y:"payload.".concat(R.dataKey.toString());J=Ni(G,ie,D),I=E&&L&&Ni(L,ie,D)}else J=G==null?void 0:G[k],I=E&&L&&L[k];if(Q||X){var q=w.props.activeIndex!==void 0?w.props.activeIndex:k;return[A.cloneElement(w,z(z(z({},j.props),te),{},{activeIndex:q})),null,null]}if(!fe(J))return[V].concat(ea(m.renderActivePoints({item:j,activePoint:J,basePoint:I,childIndex:k,isRange:E})))}else{var se,ee=(se=m.getItemByXY(m.state.activeCoordinate))!==null&&se!==void 0?se:{graphicalItem:V},ve=ee.graphicalItem,We=ve.item,Re=We===void 0?w:We,Be=ve.childIndex,Ge=z(z(z({},j.props),te),{},{activeIndex:Be});return[A.cloneElement(Re,Ge),null,null]}return E?[V,null,null]:[V,null]}),oe(m,"renderCustomized",function(w,O,P){return A.cloneElement(w,z(z({key:"recharts-customized-".concat(P)},m.props),m.state))}),oe(m,"renderMap",{CartesianGrid:{handler:_s,once:!0},ReferenceArea:{handler:m.renderReferenceElement},ReferenceLine:{handler:_s},ReferenceDot:{handler:m.renderReferenceElement},XAxis:{handler:_s},YAxis:{handler:_s},Brush:{handler:m.renderBrush,once:!0},Bar:{handler:m.renderGraphicChild},Line:{handler:m.renderGraphicChild},Area:{handler:m.renderGraphicChild},Radar:{handler:m.renderGraphicChild},RadialBar:{handler:m.renderGraphicChild},Scatter:{handler:m.renderGraphicChild},Pie:{handler:m.renderGraphicChild},Funnel:{handler:m.renderGraphicChild},Tooltip:{handler:m.renderCursor,once:!0},PolarGrid:{handler:m.renderPolarGrid,once:!0},PolarAngleAxis:{handler:m.renderPolarAxis},PolarRadiusAxis:{handler:m.renderPolarAxis},Customized:{handler:m.renderCustomized}}),m.clipPathId="".concat((x=S.id)!==null&&x!==void 0?x:$r("recharts"),"-clip"),m.throttleTriggeredAfterMouseMove=Qh(m.triggeredAfterMouseMove,(T=S.throttleDelay)!==null&&T!==void 0?T:1e3/60),m.state={},m}return UF(b,p),RF(b,[{key:"componentDidMount",value:function(){var x,T;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(x=this.props.margin.left)!==null&&x!==void 0?x:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var x=this.props,T=x.children,m=x.data,w=x.height,O=x.layout,P=yt(T,Wt);if(P){var j=P.props.defaultIndex;if(!(typeof j!="number"||j<0||j>this.state.tooltipTicks.length-1)){var M=this.state.tooltipTicks[j]&&this.state.tooltipTicks[j].value,_=af(this.state,m,j,M),$=this.state.tooltipTicks[j].coordinate,R=(this.state.offset.top+w)/2,k=O==="horizontal",D=k?{x:$,y:R}:{y:$,x:R},C=this.state.formattedGraphicalItems.find(function(U){var G=U.item;return G.type.name==="Scatter"});C&&(D=z(z({},D),C.props.points[j].tooltipPosition),_=C.props.points[j].tooltipPayload);var B={activeTooltipIndex:j,isTooltipActive:!0,activeLabel:M,activePayload:_,activeCoordinate:D};this.setState(B),this.renderCursor(P),this.accessibilityManager.setIndex(j)}}}},{key:"getSnapshotBeforeUpdate",value:function(x,T){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==T.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==x.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==x.margin){var m,w;this.accessibilityManager.setDetails({offset:{left:(m=this.props.margin.left)!==null&&m!==void 0?m:0,top:(w=this.props.margin.top)!==null&&w!==void 0?w:0}})}return null}},{key:"componentDidUpdate",value:function(x){il([yt(x.children,Wt)],[yt(this.props.children,Wt)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var x=yt(this.props.children,Wt);if(x&&typeof x.props.shared=="boolean"){var T=x.props.shared?"axis":"item";return s.indexOf(T)>=0?T:i}return i}},{key:"getMouseInfo",value:function(x){if(!this.container)return null;var T=this.container,m=T.getBoundingClientRect(),w=aM(m),O={chartX:Math.round(x.pageX-w.left),chartY:Math.round(x.pageY-w.top)},P=m.width/T.offsetWidth||1,j=this.inRange(O.chartX,O.chartY,P);if(!j)return null;var M=this.state,_=M.xAxisMap,$=M.yAxisMap,R=this.getTooltipEventType(),k=cb(this.state,this.props.data,this.props.layout,j);if(R!=="axis"&&_&&$){var D=hr(_).scale,C=hr($).scale,B=D&&D.invert?D.invert(O.chartX):null,U=C&&C.invert?C.invert(O.chartY):null;return z(z({},O),{},{xValue:B,yValue:U},k)}return k?z(z({},O),k):null}},{key:"inRange",value:function(x,T){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,w=this.props.layout,O=x/m,P=T/m;if(w==="horizontal"||w==="vertical"){var j=this.state.offset,M=O>=j.left&&O<=j.left+j.width&&P>=j.top&&P<=j.top+j.height;return M?{x:O,y:P}:null}var _=this.state,$=_.angleAxisMap,R=_.radiusAxisMap;if($&&R){var k=hr($);return gy({x:O,y:P},k)}return null}},{key:"parseEventsOfWrapper",value:function(){var x=this.props.children,T=this.getTooltipEventType(),m=yt(x,Wt),w={};m&&T==="axis"&&(m.props.trigger==="click"?w={onClick:this.handleClick}:w={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var O=Di(this.props,this.handleOuterEvent);return z(z({},O),w)}},{key:"addListener",value:function(){Qc.on(ef,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Qc.removeListener(ef,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(x,T,m){for(var w=this.state.formattedGraphicalItems,O=0,P=w.length;O<P;O++){var j=w[O];if(j.item===x||j.props.key===x.key||T===Qt(j.item.type)&&m===j.childIndex)return j}return null}},{key:"renderClipPath",value:function(){var x=this.clipPathId,T=this.state.offset,m=T.left,w=T.top,O=T.height,P=T.width;return A.createElement("defs",null,A.createElement("clipPath",{id:x},A.createElement("rect",{x:m,y:w,height:O,width:P})))}},{key:"getXScales",value:function(){var x=this.state.xAxisMap;return x?Object.entries(x).reduce(function(T,m){var w=rb(m,2),O=w[0],P=w[1];return z(z({},T),{},oe({},O,P.scale))},{}):null}},{key:"getYScales",value:function(){var x=this.state.yAxisMap;return x?Object.entries(x).reduce(function(T,m){var w=rb(m,2),O=w[0],P=w[1];return z(z({},T),{},oe({},O,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(x){var T;return(T=this.state.xAxisMap)===null||T===void 0||(T=T[x])===null||T===void 0?void 0:T.scale}},{key:"getYScaleByAxisId",value:function(x){var T;return(T=this.state.yAxisMap)===null||T===void 0||(T=T[x])===null||T===void 0?void 0:T.scale}},{key:"getItemByXY",value:function(x){var T=this.state,m=T.formattedGraphicalItems,w=T.activeItem;if(m&&m.length)for(var O=0,P=m.length;O<P;O++){var j=m[O],M=j.props,_=j.item,$=_.type.defaultProps!==void 0?z(z({},_.type.defaultProps),_.props):_.props,R=Qt(_.type);if(R==="Bar"){var k=(M.data||[]).find(function(U){return G3(x,U)});if(k)return{graphicalItem:j,payload:k}}else if(R==="RadialBar"){var D=(M.data||[]).find(function(U){return gy(x,U)});if(D)return{graphicalItem:j,payload:D}}else if(Zo(j,w)||Jo(j,w)||si(j,w)){var C=V5({graphicalItem:j,activeTooltipItem:w,itemData:$.data}),B=$.activeIndex===void 0?C:$.activeIndex;return{graphicalItem:z(z({},j),{},{childIndex:B}),payload:si(j,w)?$.data[C]:j.props.data[C]}}}return null}},{key:"render",value:function(){var x=this;if(!Qf(this))return null;var T=this.props,m=T.children,w=T.className,O=T.width,P=T.height,j=T.style,M=T.compact,_=T.title,$=T.desc,R=nb(T,CF),k=de(R,!1);if(M)return A.createElement(eg,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},A.createElement(sl,Qn({},k,{width:O,height:P,title:_,desc:$}),this.renderClipPath(),rd(m,this.renderMap)));if(this.props.accessibilityLayer){var D,C;k.tabIndex=(D=this.props.tabIndex)!==null&&D!==void 0?D:0,k.role=(C=this.props.role)!==null&&C!==void 0?C:"application",k.onKeyDown=function(U){x.accessibilityManager.keyboardEvent(U)},k.onFocus=function(){x.accessibilityManager.focus()}}var B=this.parseEventsOfWrapper();return A.createElement(eg,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},A.createElement("div",Qn({className:ye("recharts-wrapper",w),style:z({position:"relative",cursor:"default",width:O,height:P},j)},B,{ref:function(G){x.container=G}}),A.createElement(sl,Qn({},k,{width:O,height:P,title:_,desc:$,style:HF}),this.renderClipPath(),rd(m,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(A.Component);oe(v,"displayName",r),oe(v,"defaultProps",z({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},f)),oe(v,"getDerivedStateFromProps",function(p,b){var S=p.dataKey,x=p.data,T=p.children,m=p.width,w=p.height,O=p.layout,P=p.stackOffset,j=p.margin,M=b.dataStartIndex,_=b.dataEndIndex;if(b.updateId===void 0){var $=fb(p);return z(z(z({},$),{},{updateId:0},h(z(z({props:p},$),{},{updateId:0}),b)),{},{prevDataKey:S,prevData:x,prevWidth:m,prevHeight:w,prevLayout:O,prevStackOffset:P,prevMargin:j,prevChildren:T})}if(S!==b.prevDataKey||x!==b.prevData||m!==b.prevWidth||w!==b.prevHeight||O!==b.prevLayout||P!==b.prevStackOffset||!ln(j,b.prevMargin)){var R=fb(p),k={chartX:b.chartX,chartY:b.chartY,isTooltipActive:b.isTooltipActive},D=z(z({},cb(b,x,O)),{},{updateId:b.updateId+1}),C=z(z(z({},R),k),D);return z(z(z({},C),h(z({props:p},C),b)),{},{prevDataKey:S,prevData:x,prevWidth:m,prevHeight:w,prevLayout:O,prevStackOffset:P,prevMargin:j,prevChildren:T})}if(!il(T,b.prevChildren)){var B,U,G,E,L=yt(T,Nn),F=L&&(B=(U=L.props)===null||U===void 0?void 0:U.startIndex)!==null&&B!==void 0?B:M,W=L&&(G=(E=L.props)===null||E===void 0?void 0:E.endIndex)!==null&&G!==void 0?G:_,K=F!==M||W!==_,X=!fe(x),Q=X&&!K?b.updateId:b.updateId+1;return z(z({updateId:Q},h(z(z({props:p},b),{},{updateId:Q,dataStartIndex:F,dataEndIndex:W}),b)),{},{prevChildren:T,dataStartIndex:F,dataEndIndex:W})}return null}),oe(v,"renderActiveDot",function(p,b,S){var x;return A.isValidElement(p)?x=A.cloneElement(p,b):he(p)?x=p(b):x=A.createElement(Ho,b),A.createElement(xe,{className:"recharts-active-dot",key:S},x)});var y=A.forwardRef(function(b,S){return A.createElement(v,Qn({},b,{ref:S}))});return y.displayName=v.displayName,y},iW=aW({chartName:"ComposedChart",GraphicalChild:[hi,Ar,Ln,xs],axisComponents:[{axisType:"xAxis",AxisComp:Os},{axisType:"yAxis",AxisComp:As},{axisType:"zAxis",AxisComp:gs}],formatAxisMap:m4});const ta=({className:e,width:t,height:r,rounded:n=!1})=>g.jsx("div",{className:ue("animate-pulse bg-gray-200",n?"rounded-full":"rounded",e),style:{width:typeof t=="number"?`${t}px`:t,height:typeof r=="number"?`${r}px`:r}}),gi=({className:e})=>g.jsxs("div",{className:ue("rounded-lg border border-gray-200 bg-white p-4",e),children:[g.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[g.jsx(ta,{className:"h-4 w-16"}),g.jsx(ta,{className:"h-4 w-4",rounded:!0})]}),g.jsxs("div",{className:"flex items-baseline gap-3",children:[g.jsx(ta,{className:"h-8 w-20"}),g.jsx(ta,{className:"h-6 w-12 rounded-md"})]})]}),hb=({className:e,chartType:t="line",height:r=300})=>{const n=o=>{if(o.length===0)return"";let s=`M ${o[0].x} ${o[0].y}`;for(let l=1;l<o.length;l++){const u=o[l-1],c=o[l],f=u.x+(c.x-u.x)*.4,d=u.y,h=u.x+(c.x-u.x)*.6,v=c.y;s+=` C ${f} ${d} ${h} ${v} ${c.x} ${c.y}`}return s},a=(o=7)=>Array.from({length:o},(c,f)=>({x:f/(o-1)*100,y:80-Math.random()*60})),i=()=>{switch(t){case"bar":return g.jsx("div",{className:"absolute inset-0 flex items-end justify-between px-4 pb-4",children:[...Array(7)].map((p,b)=>g.jsx(ta,{className:"w-8 bg-blue-100",height:`${Math.random()*60+20}%`},b))});case"line":const o=a(12),s=n(o),l=o[o.length-1],u=o[0],c=`${s} L ${l.x} 100 L ${u.x} 100 Z`;return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"skeleton-area-fill",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[g.jsx("stop",{offset:"0%",stopColor:"#8b5cf6",stopOpacity:"0.1",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.1;0.15;0.1",dur:"3s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#8b5cf6",stopOpacity:"0.02",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.02;0.05;0.02",dur:"3s",repeatCount:"indefinite"})})]}),g.jsxs("linearGradient",{id:"skeleton-line-shimmer",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#e2e8f0",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2.5s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"50%",stopColor:"#cbd5e1",stopOpacity:"0.6",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.6;0.3;0.6",dur:"2.5s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#e2e8f0",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2.5s",repeatCount:"indefinite"})})]})]}),g.jsx("path",{d:c,fill:"url(#skeleton-area-fill)"}),g.jsx("path",{d:s,stroke:"url(#skeleton-line-shimmer)",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]})});case"area":const f=a(),d=n(f),h=f[f.length-1],v=f[0],y=`${d} L ${h.x} 90 L ${v.x} 90 Z`;return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"skeleton-area-gradient",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.2",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.2;0.4;0.2",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:"0.05",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.05;0.1;0.05",dur:"2s",repeatCount:"indefinite"})})]}),g.jsxs("linearGradient",{id:"skeleton-area-line",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.4",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.4;0.8;0.4",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"50%",stopColor:"#3b82f6",stopOpacity:"0.8",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.8;0.4;0.8",dur:"2s",repeatCount:"indefinite"})}),g.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:"0.4",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.4;0.8;0.4",dur:"2s",repeatCount:"indefinite"})})]})]}),g.jsx("path",{d:y,fill:"url(#skeleton-area-gradient)"}),g.jsx("path",{d:n(f),stroke:"url(#skeleton-area-line)",strokeWidth:"2.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]})});case"pie":return g.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:g.jsxs("svg",{className:"w-32 h-32",viewBox:"0 0 42 42",children:[g.jsxs("defs",{children:[g.jsx("linearGradient",{id:"skeleton-pie-gradient-1",children:g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-2",children:g.jsx("stop",{offset:"0%",stopColor:"#10b981",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"0.5s"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-3",children:g.jsx("stop",{offset:"0%",stopColor:"#f59e0b",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"1s"})})}),g.jsx("linearGradient",{id:"skeleton-pie-gradient-4",children:g.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:"0.3",children:g.jsx("animate",{attributeName:"stop-opacity",values:"0.3;0.6;0.3",dur:"2s",repeatCount:"indefinite",begin:"1.5s"})})})]}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"#e5e7eb",strokeWidth:"3"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-1)",strokeWidth:"3",strokeDasharray:"40 60",strokeDashoffset:"25"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-2)",strokeWidth:"3",strokeDasharray:"25 75",strokeDashoffset:"65"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-3)",strokeWidth:"3",strokeDasharray:"20 80",strokeDashoffset:"90"}),g.jsx("circle",{cx:"21",cy:"21",r:"15.915",fill:"transparent",stroke:"url(#skeleton-pie-gradient-4)",strokeWidth:"3",strokeDasharray:"15 85",strokeDashoffset:"110"})]})});default:return g.jsx("div",{className:"absolute inset-0 p-4",children:g.jsxs("div",{className:"w-full h-full relative",children:[g.jsx("div",{className:"absolute inset-0 flex items-center",children:g.jsx("div",{className:"w-full h-0.5 bg-gradient-to-r from-transparent via-gray-300 to-transparent opacity-60",children:g.jsx("div",{className:"w-full h-full bg-gradient-to-r from-transparent via-blue-400 to-transparent animate-pulse"})})}),g.jsx("div",{className:"absolute inset-0 flex items-center justify-between px-2",children:[...Array(7)].map((p,b)=>g.jsx("div",{className:"w-2 h-2 bg-blue-300 rounded-full animate-pulse",style:{animationDelay:`${b*.2}s`}},b))})]})})}};return g.jsx("div",{className:ue("w-full",e),children:g.jsxs("div",{className:"relative bg-gray-50/30 py-3",children:[g.jsxs("div",{className:"relative mb-6",style:{height:`${r}px`},children:[g.jsxs("div",{className:"absolute left-0 top-0 h-full flex flex-col justify-between items-end pr-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"})]}),g.jsxs("div",{className:"ml-14 h-full relative overflow-hidden px-0 py-2 flex flex-col justify-between",children:[t!=="pie"&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"})]}),i()]}),t!=="pie"&&g.jsxs("div",{className:"ml-14 flex justify-between items-center mt-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"})]})]}),g.jsxs("div",{className:"flex items-center justify-between px-0 py-3 mt-2",children:[g.jsx("div",{className:"flex-1",children:g.jsx("div",{className:"bg-gray-100 h-3 rounded w-64"})}),g.jsxs("div",{className:"flex items-center gap-2 w-24 justify-center",children:[g.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded flex-1"})]})]})]})})},oW=({active:e,payload:t,label:r,config:n})=>{var o;if(!e||!t||!t.length)return null;const a=t.filter(s=>s.name&&s.name!==""&&s.name!==s.dataKey);if(a.length===0)return null;const i=((o=n.tooltip)==null?void 0:o.style)==="dark";return g.jsxs("div",{className:ue("rounded-lg border px-3 py-2 text-sm shadow-lg",i?"bg-gray-900 border-gray-700 text-white":"bg-white border-gray-200 text-gray-900"),children:[g.jsx("div",{className:ue("font-medium mb-1",i?"text-gray-300":"text-gray-600"),children:new Date(r||"").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),g.jsx("div",{className:"space-y-1",children:a.map((s,l)=>g.jsxs("div",{className:"flex items-center justify-between gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:s.color}}),g.jsx("span",{className:ue("text-sm",i?"text-gray-300":"text-gray-600"),children:s.name})]}),g.jsx("span",{className:ue("font-medium",i?"text-white":"text-gray-900"),children:typeof s.value=="number"?s.value.toLocaleString():s.value})]},l))})]})},pb=({config:e,className:t,isLoading:r,onDataPointClick:n})=>{var m,w;const{data:a,dataKey:i,color:o="#3b82f6",lines:s,dateRange:l,yAxisLabel:u,height:c=300,tooltip:f={show:!0,style:"dark"}}=e,h=(O=>{if(!O||O.length===0)return[];const P=[...O].sort((k,D)=>{const C=new Date(k.date),B=new Date(D.date);return C.getTime()-B.getTime()});let j,M;l!=null&&l.start&&(l!=null&&l.end)?(j=new Date(l.start),M=new Date(l.end)):(j=new Date(P[0].date),M=new Date(P[P.length-1].date));const _=new Map;P.forEach(k=>{_.set(k.date,k)});const $=[],R=new Date(j);for(;R<=M;){const k=R.toISOString().split("T")[0];if(_.has(k))$.push(_.get(k));else{const D={date:k,users:0,sessions:0,messages:0,totalTokens:0,inputTokens:0,outputTokens:0,agentRuns:0,toolRuns:0,modelRuns:0,codeTools:0,workflowTools:0,knowledgeTools:0,mcpTools:0,value:0,count:0};if(P.length>0){const C=P[0];Object.keys(C).forEach(B=>{typeof C[B]=="number"&&!(B in D)&&(D[B]=0)})}$.push(D)}R.setDate(R.getDate()+1)}return $})(a),v=O=>{const P=new Date(O);return isNaN(P.getTime())?O:P.toLocaleDateString("en-US",{month:"short",day:"numeric"})},y=()=>{if(!h||h.length===0)return 0;const O=h.length;return O<=20?0:O<=31?1:O<=61?2:Math.floor(O/7)-1},p=O=>b()&&!Number.isInteger(O)?"":O>=1e3?`${Math.floor(O/1e3)}k`:Math.floor(O).toString(),b=()=>{const O=["users","sessions","messages","runs","agents","tools","models","Number of Users","Number of Sessions","Number of Messages","Number of Agent Runs","Number of Tool Runs","Number of Model Runs","agentRuns","toolRuns","modelRuns"];return!!(u&&O.some(P=>u.toLowerCase().includes(P.toLowerCase()))||i&&O.some(P=>i.toLowerCase().includes(P.toLowerCase()))||e.title&&O.some(P=>e.title.toLowerCase().includes(P.toLowerCase()))||s&&s.some(P=>P.label&&O.some(j=>P.label.toLowerCase().includes(j.toLowerCase()))))},x=s&&s.length>0?s:[{dataKey:i||"value",color:o,label:e.title,strokeWidth:2}];if(r)return console.log("AnalyticsChart: Loading state active"),g.jsx(hb,{className:t,chartType:e.type,height:c});if(!a||a.length===0)return console.log("AnalyticsChart: No data provided",{data:a,config:e}),g.jsx("div",{className:ue("w-full",t),children:g.jsxs("div",{className:"relative bg-gray-50/30 py-6",children:[g.jsxs("div",{className:"relative h-[300px] mb-6",children:[g.jsxs("div",{className:"absolute left-0 top-0 h-full flex flex-col justify-between items-end pr-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-10"})]}),g.jsxs("div",{className:"ml-14 h-full relative overflow-hidden px-0 py-2 flex flex-col justify-between",children:[g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsx("div",{className:"h-0 w-full border-t border-gray-100"}),g.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[g.jsx("div",{className:"bg-white border border-gray-300 rounded-[10px] w-12 h-12 flex items-center justify-center",children:g.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),g.jsxs("div",{className:"text-center max-w-[352px]",children:[g.jsx("h3",{className:"font-semibold text-gray-900 text-base mb-1",children:"There is no data to display for this period"}),g.jsx("p",{className:"font-normal text-gray-600 text-sm leading-5",children:"Try selecting a different date range or ensure your app is deployed and receiving traffic."})]})]})]}),g.jsxs("div",{className:"ml-14 flex justify-between items-center mt-3",children:[g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded w-4"})]})]}),g.jsxs("div",{className:"flex items-center justify-between px-0 py-3 mt-2",children:[g.jsx("div",{className:"flex-1",children:g.jsx("div",{className:"bg-gray-100 h-3 rounded w-64"})}),g.jsxs("div",{className:"flex items-center gap-2 w-24 justify-center",children:[g.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),g.jsx("div",{className:"bg-gray-100 h-3 rounded flex-1"})]})]})]})});const T=O=>{var j;if(!n||!O||!O.activePayload)return;const P=(j=O.activePayload[0])==null?void 0:j.payload;P&&P.date&&(console.log("Chart data point clicked:",{date:P.date,data:P}),n(P,P.date))};return console.log("=== ANALYTICS CHART DEBUG ==="),console.log("AnalyticsChart config:",e),console.log("AnalyticsChart original data length:",a==null?void 0:a.length),console.log("AnalyticsChart filled data length:",h.length),console.log("AnalyticsChart date range (config):",l),console.log("AnalyticsChart actual date range:",h.length>0?{first:(m=h[0])==null?void 0:m.date,last:(w=h[h.length-1])==null?void 0:w.date,totalDays:h.length}:"No data"),console.log("AnalyticsChart dataKey:",i),console.log("Chart lines configuration:",x),console.log("Sample filled data points:",h.slice(0,3)),console.log("=== END ANALYTICS CHART DEBUG ==="),g.jsxs("div",{className:ue("w-full",t),children:[g.jsx("div",{className:"relative bg-gray-50/30 py-6",children:g.jsx(Zk,{width:"100%",height:c,children:g.jsxs(iW,{data:h,onClick:T,margin:{top:20,right:30,left:20,bottom:20},children:[g.jsx("defs",{children:x.map((O,P)=>g.jsxs("linearGradient",{id:`gradient-${O.dataKey}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"5%",stopColor:O.color,stopOpacity:.08}),g.jsx("stop",{offset:"95%",stopColor:O.color,stopOpacity:.01})]},`gradient-${P}`))}),g.jsx(Pg,{strokeDasharray:"2 2",className:"opacity-30",stroke:"#d1d5db",horizontal:!0,vertical:!1}),g.jsx(Os,{dataKey:"date",tickFormatter:v,axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#6b7280"},tickMargin:10,interval:y()}),g.jsx(As,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#6b7280"},tickFormatter:p,tickMargin:10,allowDecimals:!b(),domain:b()?["dataMin","dataMax"]:void 0,label:u?{value:u,angle:-90,position:"insideLeft",style:{textAnchor:"middle",fontSize:12,fill:"#6b7280"}}:void 0}),f.show&&g.jsx(Wt,{content:O=>g.jsx(oW,{...O,config:e}),cursor:{stroke:"#d1d5db",strokeWidth:1,strokeDasharray:"4 4"},allowEscapeViewBox:{x:!1,y:!1}}),x.map(O=>g.jsx(Ar,{type:"monotone",dataKey:O.dataKey,stroke:"none",fill:`url(#gradient-${O.dataKey})`,fillOpacity:1,isAnimationActive:!1,name:""},`area-${O.dataKey}`)),x.map(O=>g.jsx(hi,{type:"monotone",dataKey:O.dataKey,stroke:O.color,strokeWidth:2.5,strokeDasharray:O.strokeDasharray,dot:!1,activeDot:{r:5,fill:O.color,stroke:O.color,strokeWidth:2},name:O.label},O.dataKey))]})})}),g.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[g.jsx("div",{children:l&&g.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing data from ",new Date(l.start).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"})," - ",new Date(l.end).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"})]})}),g.jsx("div",{className:"flex items-center gap-4",children:g.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:x.map(O=>g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:O.color}}),g.jsx("span",{children:O.label})]},O.dataKey))})})]})]})},vb=({config:e,className:t})=>{const{title:r,data:n,columns:a,pagination:i={enabled:!0,pageSize:10},sorting:o={enabled:!0},filtering:s={enabled:!0,searchable:!0}}=e,[l,u]=A.useState(o.defaultSort||null),[c,f]=A.useState(""),[d,h]=A.useState(1),v=A.useMemo(()=>{let m=[...n];return s.searchable&&c&&(m=m.filter(w=>a.some(O=>{const P=w[O.key];return P==null?void 0:P.toString().toLowerCase().includes(c.toLowerCase())}))),l&&m.sort((w,O)=>{const P=w[l.key],j=O[l.key];if(typeof P=="number"&&typeof j=="number")return l.order==="asc"?P-j:j-P;const M=(P==null?void 0:P.toString())||"",_=(j==null?void 0:j.toString())||"",$=M.localeCompare(_);return l.order==="asc"?$:-$}),m},[n,a,c,l,s.searchable]),y=i.enabled?Math.ceil(v.length/i.pageSize):1,p=i.enabled?v.slice((d-1)*i.pageSize,d*i.pageSize):v,b=m=>{!o.enabled||!m.sortable||u(w=>(w==null?void 0:w.key)===m.key?w.order==="asc"?{key:m.key,order:"desc"}:null:{key:m.key,order:"asc"})},S=m=>{f(m),h(1)},x=(m,w,O)=>w.render?w.render(m,O):w.formatter?w.formatter(m,O):typeof m=="number"?m.toLocaleString():(m==null?void 0:m.toString())||"-",T=m=>!o.enabled||!m.sortable?null:(l==null?void 0:l.key)===m.key?l.order==="asc"?g.jsx(mf,{className:"w-4 h-4"}):g.jsx(ua,{className:"w-4 h-4"}):g.jsxs("div",{className:"flex flex-col",children:[g.jsx(mf,{className:"w-3 h-3 opacity-30"}),g.jsx(ua,{className:"w-3 h-3 opacity-30 -mt-1"})]});return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("h3",{className:"text-lg font-semibold",children:r}),s.enabled&&s.searchable&&g.jsxs("div",{className:"relative",children:[g.jsx(gf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),g.jsx("input",{type:"text",placeholder:"Search...",value:c,onChange:m=>S(m.target.value),className:"pl-10 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),g.jsx("div",{className:"overflow-x-auto border border-gray-200 rounded-lg",children:g.jsxs("table",{className:"w-full",children:[g.jsx("thead",{className:"bg-gray-50",children:g.jsx("tr",{children:a.map(m=>g.jsx("th",{className:ue("px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",m.sortable&&o.enabled&&"cursor-pointer hover:bg-gray-100",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:{width:m.width},onClick:()=>b(m),children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{children:m.title}),T(m)]})},m.key))})}),g.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:p.map((m,w)=>g.jsx("tr",{className:"hover:bg-gray-50 transition-colors",children:a.map(O=>g.jsx("td",{className:ue("px-4 py-3 text-sm text-gray-900",O.align==="center"&&"text-center",O.align==="right"&&"text-right"),children:x(m[O.key],O,m)},O.key))},w))})]})}),i.enabled&&y>1&&g.jsxs("div",{className:"flex items-center justify-between mt-4",children:[g.jsxs("div",{className:"text-sm text-gray-500",children:["Showing ",(d-1)*i.pageSize+1," to"," ",Math.min(d*i.pageSize,v.length)," of"," ",v.length," results"]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("button",{onClick:()=>h(m=>Math.max(1,m-1)),disabled:d===1,className:"px-3 py-1 text-sm border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),Array.from({length:Math.min(5,y)},(m,w)=>{const O=Math.max(1,Math.min(y-4,d-2))+w;return O>y?null:g.jsx("button",{onClick:()=>h(O),className:ue("px-3 py-1 text-sm border rounded",d===O?"bg-blue-500 text-white border-blue-500":"border-gray-200 hover:bg-gray-50"),children:O},O)}),g.jsx("button",{onClick:()=>h(m=>Math.min(y,m+1)),disabled:d===y,className:"px-3 py-1 text-sm border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]}),p.length===0&&g.jsx("div",{className:"text-center py-8 text-gray-500",children:c?"No results found for your search.":"No data available."})]})},sW=(e,t)=>{switch(e){case"human":return t==="agent"?"agent-avatars":"avatars";case"logo":return"profileLogos";case"icon":case"inlineTool":case"toolLibrary":case"KNOWLEDGE":case"MCP":return"profileIcons";default:return t==="agent"?"agent-avatars":"avatars"}},lW=e=>{if(!e)return null;if(typeof e=="string")try{return JSON.parse(e)}catch{return{name:e,type:"human"}}return e},uW=(e,t)=>{const r=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#06B6D4","#84CC16"],n=e.split("").reduce((a,i)=>a+i.charCodeAt(0),0)%r.length;if(t==="workflowtool"){const a=e.toLowerCase();let i="toolLibrary";return a.includes("code")||a.includes("inline")||a.includes("calculate")?i="inlineTool":a.includes("knowledge")||a.includes("document")||a.includes("fetch")?i="KNOWLEDGE":(a.includes("mcp")||a.includes("protocol"))&&(i="MCP"),{name:"fallback",type:i,color:r[n]}}return t==="model"?{name:"fallback",type:"icon",color:r[n]}:{name:"fallback",type:t==="agent"?"human":"icon",color:r[n]}},cW=(e,t)=>{if(!(e!=null&&e.name))return"";if(t==="url")return e.name;if(t==="model")return"";const r=window.location.origin,n=sW(e.type||"human",t);return`${r}/agenticai/assets/${n}/${e.name}.svg`},yb=e=>{if(!e)return"assets/icons/models/custom-api.svg";const t=e.toLowerCase(),r={openai:"Open AI.svg","open ai":"Open AI.svg",chatopenai:"Open AI.svg",gpt:"Open AI.svg",anthropic:"Anthropic.svg",claude:"Anthropic.svg",google:"Google.svg",gemini:"Google.svg",chatgooglegenerativeai:"Google.svg",googlegenerativeai:"Google.svg",palm:"Google.svg",azurechatopenai:"Azure Open AI.svg","azure open ai":"Azure Open AI.svg",azureopenai:"Azure Open AI.svg","azure openai":"Azure Open AI.svg",azure:"Azure Open AI.svg",aws:"AWS Bedrock.svg",bedrock:"AWS Bedrock.svg","aws bedrock":"AWS Bedrock.svg",awsbedrock:"AWS Bedrock.svg",amazon:"AWS Bedrock.svg",cohere:"Cohere.svg",api:"API.svg",custom:"custom-api.svg","custom-api":"custom-api.svg",customapi:"custom-api.svg"};if(r[t])return`assets/icons/models/${r[t]}`;for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return`assets/icons/models/${a}`;return"assets/icons/models/custom-api.svg"},fW={xs:"w-6 h-6 text-xs",small:"w-8 h-8 text-sm",medium:"w-10 h-10 text-base",large:"w-12 h-12 text-lg"},Rt={inlineTool:`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3533_7514)">
206
206
  <path d="M8.5 8.5L11 6L8.5 3.5M3.5 3.5L1 6L3.5 8.5M7 1.5L5 10.5" stroke="#EF6820" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"/></g>
207
207
  <defs><clipPath id="clip0_3533_7514"><rect width="12" height="12" fill="white"/></clipPath></defs>
208
208
  </svg>`,toolLibrary:`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -211,7 +211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
211
211
  <path d="M6 5.5H3M4 7.5H3M7 3.5H3M9 3.4V8.6C9 9.44008 9 9.86012 8.83651 10.181C8.6927 10.4632 8.46323 10.6927 8.18099 10.8365C7.86012 11 7.44008 11 6.6 11H3.4C2.55992 11 2.13988 11 1.81901 10.8365C1.53677 10.6927 1.3073 10.4632 1.16349 10.181C1 9.86012 1 9.44008 1 8.6V3.4C1 2.55992 1 2.13988 1.16349 1.81901C1.3073 1.53677 1.53677 1.3073 1.81901 1.16349C2.13988 1 2.55992 1 3.4 1H6.6C7.44008 1 7.86012 1 8.18099 1.16349C8.46323 1.3073 8.6927 1.53677 8.83651 1.81901C9 2.13988 9 2.55992 9 3.4Z" stroke="#7A5AF8" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"/>
212
212
  </svg>`,MCP:`<svg width="14" height="14" viewBox="0 0 22 23" fill="none" xmlns="http://www.w3.org/2000/svg">
213
213
  <path d="M1.8125 10.7455L10.647 1.91124C11.8411 0.717087 13.7773 0.717087 14.9714 1.91124C16.1655 3.10539 16.1655 5.0415 14.9714 6.23565M14.9714 6.23565L8.29911 12.9077M14.9714 6.23565C16.1655 5.0415 18.1018 5.0415 19.2958 6.23565C20.4899 7.4298 20.4899 9.36593 19.2958 10.56L11.7665 18.0893C11.3443 18.5115 11.3443 19.1961 11.7665 19.6182L13.164 21.0158M16.9479 8.58236L10.2756 15.2547C9.08153 16.4488 7.1453 16.4488 5.95123 15.2547C4.75716 14.0605 4.75716 12.1244 5.95123 10.9303L12.6234 4.25814" stroke="#101828" stroke-width="2.00016" stroke-linecap="round" stroke-linejoin="round"/>
214
- </svg>`},dW=(e,t)=>{const r=e.toLowerCase();if(r.includes("code"))return Rt.inlineTool;if(r.includes("workflow")||r.includes("library"))return Rt.toolLibrary;if(r.includes("knowledge"))return Rt.KNOWLEDGE;if(r.includes("mcp"))return Rt.MCP;if(Rt[e])return Rt[e];const n=t.toLowerCase();return n.includes("code")||n.includes("inline")||n.includes("calculate")?Rt.inlineTool:n.includes("library")||n.includes("workflow")?Rt.toolLibrary:n.includes("knowledge")||n.includes("document")||n.includes("fetch")?Rt.KNOWLEDGE:n.includes("mcp")||n.includes("protocol")?Rt.MCP:Rt.toolLibrary},of=({icon:e,iconSource:t="agent",size:r="small",className:n="",name:a="Unknown",toolType:i,provider:o,modelName:s})=>{const[l,u]=A.useState(!1),[c,f]=A.useState(!1),[d,h]=A.useState(!1),v=lW(e),y=fW[r];if(t==="model"){const S=yb(o),x=()=>{h(!0)};if(d){const T=o?o.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:`${y} rounded-full bg-gray-500 flex items-center justify-center ${n}`,children:g.jsx("span",{className:"text-white text-xs font-bold",children:T})})}return g.jsx("img",{src:S,alt:s||a,className:`${y} rounded ${n}`,onError:x})}if(v!=null&&v.name&&v.name!=="fallback"&&!l){const S=cW(v,t),x=()=>{u(!0)};return g.jsx("img",{src:S,alt:a,className:`${y} rounded-full object-cover ${n}`,onError:x})}if(l&&!c&&t==="agent"){const S=`${window.location.origin}/agenticai/assets/agent-avatars/agent1.svg`,x=()=>{f(!0)};return g.jsx("img",{src:S,alt:a,className:`${y} rounded-full object-cover ${n}`,onError:x})}if(t==="model"){const S=yb(o),x=()=>{h(!0)};if(d){const T=o?o.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:`${y} rounded-full bg-gray-500 flex items-center justify-center ${n}`,children:g.jsx("span",{className:"text-white text-xs font-bold",children:T})})}return g.jsx("img",{src:S,alt:s||a,className:`${y} rounded ${n}`,onError:x})}const p=v||uW(a,t);if(t==="workflowtool"){const S=i||p.type||"toolLibrary",x=dW(S,a);return g.jsx("div",{className:`${y} rounded-full flex items-center justify-center bg-gray-100 ${n}`,children:g.jsx("div",{dangerouslySetInnerHTML:{__html:x}})})}const b=`${window.location.origin}/agenticai/assets/agent-avatars/agent1.svg`;return g.jsx("img",{src:b,alt:a,className:`${y} rounded-full object-cover ${n}`})},mb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Name"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Response Time"}),g.jsx("div",{className:"text-right",children:"Tokens"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:o.icon,iconSource:"agent",size:"small",name:o.name||"Unknown Agent"})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||"Unknown Agent"})})]}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.runs?i(o.runs):"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.tokens?i(o.tokens):"-"})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})};function hW(e){const t=(e==null?void 0:e.toLowerCase())||"";return["inlinetool","inlineTool","code tool","code","tool","event","EVENT"].includes(e)||["inlinetool","inlineTool","code tool","code","tool","event"].includes(t)?"bg-orange-100 text-orange-800 border-orange-200":["toollibrary","toolLibrary","workflow tool"].includes(e)||["toollibrary","toollibrary","workflow tool"].includes(t)?"bg-blue-100 text-blue-800 border-blue-200":["mcp","MCP","mcpTool","mcpTool"].includes(e)||["mcp","mcptool"].includes(t)?"bg-green-100 text-green-800 border-green-200":["knowledge","KNOWLEDGE","knowledge tool"].includes(e)||["knowledge","knowledge tool"].includes(t)?"bg-purple-100 text-purple-800 border-purple-200":"bg-gray-100 text-gray-800 border-gray-200"}function pW(e){const t=(e==null?void 0:e.toLowerCase())||"";return["inlinetool","code tool","code","tool","event","inlineTool"].includes(t)?"Code Tool":["toollibrary","workflow tool"].includes(t)?"Workflow Tool":["mcp","mcptool"].includes(t)?"MCP Tool":["knowledge","knowledge tool","knowledge"].includes(t)||e==="KNOWLEDGE"?"Knowledge":e==="inlineTool"?"Code Tool":e==="toolLibrary"?"Workflow Tool":e==="KNOWLEDGE"?"Knowledge":e==="MCP"||e==="mcpTool"?"MCP Tool":"Code Tool"}const gb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Name"}),g.jsx("div",{className:"text-left",children:"Type"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Response Time"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:o.icon,iconSource:"workflowtool",size:"small",name:o.name||"Unknown Tool",toolType:o.toolType||o.type})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||"Unknown Tool"})})]}),g.jsx("div",{className:"flex items-center",children:g.jsx("span",{className:ue("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium border",hW(o.toolType||o.type||"Default")),children:pW(o.toolType||o.type||"Default")})}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.runs?i(o.runs):"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||"-"})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})},vW=e=>{if(!e)return"/assets/icons/models/custom-api.svg";const t=e.toLowerCase(),r={openai:"Open AI.svg","open ai":"Open AI.svg",chatopenai:"Open AI.svg",gpt:"Open AI.svg",anthropic:"Anthropic.svg",claude:"Anthropic.svg",google:"Google.svg",gemini:"Google.svg",chatgooglegenerativeai:"Google.svg",googlegenerativeai:"Google.svg",palm:"Google.svg",azurechatopenai:"Azure Open AI.svg","azure open ai":"Azure Open AI.svg",azureopenai:"Azure Open AI.svg","azure openai":"Azure Open AI.svg",azure:"Azure Open AI.svg",aws:"AWS Bedrock.svg",bedrock:"AWS Bedrock.svg","aws bedrock":"AWS Bedrock.svg",awsbedrock:"AWS Bedrock.svg",amazon:"AWS Bedrock.svg",cohere:"Cohere.svg",api:"API.svg",custom:"custom-api.svg","custom-api":"custom-api.svg",customapi:"custom-api.svg"};if(r[t])return`https://agent-platform.kore.ai/assets/icons/models/${r[t]}`;for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return`https://agent-platform.kore.ai/assets/icons/models/${a}`;return"https://agent-platform.kore.ai/assets/icons/models/custom-api.svg"},yW=e=>{if(!e)return"";const t=e.toLowerCase(),r={openai:"OpenAI","open ai":"OpenAI",chatopenai:"OpenAI",gpt:"OpenAI",anthropic:"Anthropic",claude:"Anthropic",google:"Google",gemini:"Google Gemini",chatgooglegenerativeai:"Google Gemini",googlegenerativeai:"Google Gemini",palm:"Google PaLM",azurechatopenai:"Azure OpenAI","azure open ai":"Azure OpenAI",azureopenai:"Azure OpenAI","azure openai":"Azure OpenAI",azure:"Azure OpenAI",aws:"AWS Bedrock",bedrock:"AWS Bedrock","aws bedrock":"AWS Bedrock",awsbedrock:"AWS Bedrock",amazon:"AWS Bedrock",cohere:"Cohere",meta:"Meta",llama:"Meta LLaMA",mistral:"Mistral",huggingface:"Hugging Face",together:"Together AI",replicate:"Replicate"};if(r[t])return r[t];for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return a;return e.charAt(0).toUpperCase()+e.slice(1)},mW=({provider:e})=>{const[t,r]=A.useState(!1),n=vW(e),a=()=>{r(!0)};if(t){const i=e?e.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-500 flex items-center justify-center",children:g.jsx("span",{className:"text-white text-xs font-bold",children:i})})}return g.jsx("img",{src:n,alt:e||"Model",className:"w-6 h-6 rounded",onError:a})},bb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Model Name"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Tokens"}),g.jsx("div",{className:"text-right",children:"Response Time"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(mW,{provider:o.provider})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||o.modelName||"Unknown Model"}),o.provider&&g.jsx("div",{className:"text-xs text-gray-500 truncate",children:yW(o.provider)})]})]}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:i(o.runs||0)}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:i(o.tokens||o.totalTokens||0)}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||(o.avgResponseTime?`${o.avgResponseTime}ms`:"N/A")})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})},gW=e=>{switch(e){case"agentRuns":return{title:"Agent Runs",entityName:"Agents"};case"toolRuns":return{title:"Tool Runs",entityName:"Tools"};case"modelRuns":return{title:"Model Runs",entityName:"Models"};default:return{title:"Runs",entityName:"Items"}}},bW=e=>e>=1e3?`${Math.floor(e/1e3)}k`:e.toString(),xb=({isOpen:e,onClose:t,date:r,metricType:n,data:a,totalRuns:i,className:o})=>{var w;const s=gW(n),[l,u]=A.useState(10),[c,f]=A.useState("all"),[d,h]=A.useState(!1),v=[{label:`All ${s.entityName}`,value:"all"},...a.map(O=>({label:O.name,value:O.id}))],y=c==="all"?a:a.filter(O=>O.id===c),p=()=>{f("all"),h(!1),u(10),t()};A.useEffect(()=>{const O=j=>{j.key==="Escape"&&p()},P=j=>{d&&(j.target.closest(".filter-dropdown")||h(!1))};return e&&(document.addEventListener("keydown",O),document.addEventListener("mousedown",P),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",O),document.removeEventListener("mousedown",P),document.body.style.overflow="unset"}},[e,d,p]),A.useEffect(()=>{e&&(f("all"),h(!1),u(10))},[e]);const b=O=>new Date(O).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),S=()=>{u(O=>Math.min(O+10,y.length))},x=O=>{f(O),h(!1),u(10)};if(!e)return null;const T=y.slice(0,l),m=((w=v.find(O=>O.value===c))==null?void 0:w.label)||`All ${s.entityName}`;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300",onClick:p}),g.jsxs("div",{className:ue("fixed right-0 top-0 h-full w-[600px] bg-white shadow-[0px_20px_24px_-4px_rgba(16,24,40,0.08),0px_8px_8px_-4px_rgba(16,24,40,0.03)] z-50 transform transition-transform duration-300 ease-in-out",e?"translate-x-0":"translate-x-full",o),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-[#d0d5dd]",children:[g.jsx("h2",{className:"text-lg font-semibold text-[#101828]",children:s.title}),g.jsx("button",{onClick:p,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:g.jsx(s0,{className:"h-5 w-5 text-[#101828]"})})]}),g.jsxs("div",{className:"flex flex-col h-[calc(100%-64px)] p-6 gap-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"text-sm font-medium text-[#344054]",children:[s.title," (",b(r),")"]}),g.jsxs("div",{className:"w-[210px] relative filter-dropdown",children:[g.jsxs("button",{onClick:()=>h(!d),className:"w-full bg-white border border-[#d0d5dd] rounded-lg px-3.5 py-2.5 flex items-center justify-between text-sm text-[#101828] hover:bg-gray-50 transition-colors",children:[g.jsx("span",{children:m}),g.jsx(ua,{className:"h-4 w-4 text-[#101828]"})]}),d&&g.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white border border-[#d0d5dd] rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto",children:v.map(O=>g.jsx("button",{onClick:()=>x(O.value),className:ue("w-full px-3.5 py-2.5 text-left text-sm hover:bg-gray-50 transition-colors",c===O.value?"bg-blue-50 text-blue-700":"text-[#101828]"),children:O.label},O.value))})]})]}),g.jsxs("div",{className:"flex-1 overflow-hidden",children:[g.jsx("div",{className:"bg-[#f9fafb] border-b border-[#eaecf0] px-2 py-2",children:g.jsxs("div",{className:"grid grid-cols-4 gap-3 items-center",children:[g.jsx("div",{className:"col-span-2 px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Name"})}),g.jsx("div",{className:"flex justify-center px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Runs"})}),g.jsx("div",{className:"flex justify-center px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Response Time"})})]})}),g.jsx("div",{className:"overflow-y-auto max-h-[calc(100%-40px)]",children:T.length===0?g.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[g.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:["No ",s.title.toLowerCase()," for this date"]}),g.jsxs("p",{className:"text-gray-600",children:["There were no ",s.title.toLowerCase()," recorded on ",b(r),"."]})]}):g.jsxs(g.Fragment,{children:[T.map((O,P)=>g.jsxs("div",{className:"grid grid-cols-4 gap-3 items-center px-2 py-3 border-b border-[#eaecf0] hover:bg-gray-50 transition-colors",children:[g.jsxs("div",{className:"col-span-2 flex items-center gap-2",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:O.icon,iconSource:n==="agentRuns"?"agent":n==="toolRuns"?"workflowtool":"model",size:"small",name:O.name,toolType:O.toolType||O.type,provider:O.provider,modelName:O.modelName})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"text-sm font-medium text-[#101828] truncate",children:O.name}),n==="modelRuns"&&O.provider&&g.jsx("div",{className:"text-xs text-[#475467] truncate",children:O.provider})]})]}),g.jsx("div",{className:"flex justify-center",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:bW(O.runs)})}),g.jsx("div",{className:"flex justify-center",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:O.responseTime})})]},O.id||P)),l<y.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:S,className:"bg-white border border-[#d0d5dd] rounded px-3 py-1 text-xs font-medium text-[#344054] hover:bg-gray-50 transition-colors",children:"Load 10 more"})})]})})]})]})]})]})};class wb{constructor(t=""){Bt(this,"API_PATH","/tracing/api/trpc/metrics.getMetrics");Bt(this,"baseUrl","");Bt(this,"endpoints",{});this.baseUrl=t,this.initializeEndpoints()}setBaseUrl(t){this.baseUrl=t,this.initializeEndpoints()}getEndpoint(t){return this.endpoints[t]||{endpoint:"",method:"GET"}}getBaseUrl(){return this.baseUrl}initializeEndpoints(){const t=`${this.baseUrl}${this.API_PATH}`;this.endpoints["usage-analytics.cards"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.sessions.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.messages.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.users.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.tokens.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.cards"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.agent-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.model-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.tool-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH}}getAvailableEndpoints(){return Object.keys(this.endpoints)}hasEndpoint(t){return t in this.endpoints}}class Ob{constructor(t){Bt(this,"endpointsService");Bt(this,"defaultHeaders");Bt(this,"timeout");this.endpointsService=new wb(t.baseUrl),this.defaultHeaders={"Content-Type":"application/json",...t.defaultHeaders},this.timeout=t.timeout||3e4}updateConfig(t){t.baseUrl&&this.endpointsService.setBaseUrl(t.baseUrl),t.defaultHeaders&&(this.defaultHeaders={...this.defaultHeaders,...t.defaultHeaders}),t.timeout&&(this.timeout=t.timeout)}async invoke(t,r,n,a){const i=this.endpointsService.getEndpoint(t);if(!i.endpoint)throw new Error(`Endpoint not found for service: ${t}`);const o=this.prepareRequest(i,r,n);try{const s=new AbortController,l=setTimeout(()=>s.abort(),(a==null?void 0:a.timeout)||this.timeout),u=await fetch(o.url,{method:o.method,headers:o.headers,body:o.body,signal:(a==null?void 0:a.signal)||s.signal});if(clearTimeout(l),!u.ok)throw new Error(`HTTP Error: ${u.status} ${u.statusText}`);return await u.json()}catch(s){throw s instanceof Error?s.name==="AbortError"?new Error("Request timeout"):s:new Error("Unknown error occurred during API call")}}prepareRequest(t,r,n){const a={...this.defaultHeaders,...n},i={};Object.entries(a).forEach(([l,u])=>{u!==void 0&&(i[l]=u)});let o=t.endpoint,s;if(t.method==="GET"&&r){const l=this.buildQueryParams(r);o+=`?${l}`}else r&&(s=JSON.stringify(r));return{url:o,method:t.method,headers:i,body:s}}buildQueryParams(t){const r={json:t},n=new URLSearchParams;return n.append("input",JSON.stringify(r)),n.append("rnd",Math.random().toString(36).substring(7)),n.toString()}getBaseUrl(){return this.endpointsService.getBaseUrl()}hasEndpoint(t){return this.endpointsService.hasEndpoint(t)}getAvailableEndpoints(){return this.endpointsService.getAvailableEndpoints()}}class Ht{constructor(t){Bt(this,"apiInvoker");Bt(this,"projectId");Bt(this,"environment");Bt(this,"defaultTimeRange");const r={baseUrl:t.baseUrl,defaultHeaders:t.headers,timeout:3e4};this.apiInvoker=new Ob(r),this.projectId=t.projectId,this.environment=t.environment,this.defaultTimeRange=t.defaultTimeRange}updateConfig(t){(t.baseUrl||t.headers)&&this.apiInvoker.updateConfig({baseUrl:t.baseUrl,defaultHeaders:t.headers}),t.projectId&&(this.projectId=t.projectId),t.environment&&(this.environment=t.environment),t.defaultTimeRange&&(this.defaultTimeRange=t.defaultTimeRange,console.log("🔄 API Service: Updated defaultTimeRange:",this.defaultTimeRange))}getDefaultTimeRange(){return this.defaultTimeRange||Ht.getDateRange(7)}async fetchEnvironments(){try{const r=`${this.apiInvoker.getBaseUrl()}/aaa/api/v1/apps/${this.projectId}/environments?rnd=${Math.random().toString(36).substring(2,8)}`;console.log("🌍 Fetching environments for project:",this.projectId),console.log("🔗 Environment API URL:",r);const n=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json",...this.apiInvoker.defaultHeaders}});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const a=await n.json();return console.log("✅ Environments fetched successfully:",a.map(i=>({name:i.envName,enabled:i.isEnabled,status:i.status}))),a}catch(t){throw console.error("❌ Error fetching environments:",t),t}}async fetchUsageAnalyticsCards(t,r,n,a=[]){const i=n||Ht.getTimeDimension(t,r);console.log("📊 Fetching usage analytics cards:",{dateRange:{fromTimestamp:t,toTimestamp:r},providedTimeDimension:n,resolvedTimeDimension:i});const o={projectId:this.projectId,type:"cards",category:"usage-analytics",envId:this.environment,fromTimestamp:t,toTimestamp:r,filter:a,includeTrends:!0,timeDimension:i};return(await this.apiInvoker.invoke("usage-analytics.cards",o)).result.data.json}async fetchRunsCards(t,r,n,a=[]){const i=n||Ht.getTimeDimension(t,r);console.log("📊 Fetching runs cards:",{dateRange:{fromTimestamp:t,toTimestamp:r},providedTimeDimension:n,resolvedTimeDimension:i});const o={projectId:this.projectId,type:"cards",category:"runs",envId:this.environment,fromTimestamp:t,toTimestamp:r,filter:a,includeTrends:!0,timeDimension:i};return(await this.apiInvoker.invoke("runs.cards",o)).result.data.json}async fetchTimeSeriesData(t,r,n,a,i,o=[]){const s=i||Ht.getTimeDimension(n,a);console.log("📊 Fetching time series data:",{metric:t,category:r,dateRange:{fromTimestamp:n,toTimestamp:a},providedTimeDimension:i,resolvedTimeDimension:s});const l=`${r}.${t}.timeseries`,u={projectId:this.projectId,type:"time-series",category:r,envId:this.environment,fromTimestamp:n,toTimestamp:a,filter:o,metric:t,timeDimension:s};return(await this.apiInvoker.invoke(l,u)).result.data.json}transformUsageAnalyticsCards(t){const r=t.data.trends;console.log("Transforming usage analytics cards with trends:",r);const n=a=>a>0?"increase":"decrease";return[{title:"Users",value:t.data.users,metricType:"users",icon:"users",info:"Number of unique users who interacted with the app",highlighted:!0,change:r!=null&&r.users?{value:Math.abs(r.users.changePercent),type:n(r.users.changePercent)}:void 0},{title:"Sessions",value:t.data.sessions,metricType:"sessions",icon:"activity",info:"Number of conversations initiated with the app",highlighted:!1,change:r!=null&&r.sessions?{value:Math.abs(r.sessions.changePercent),type:n(r.sessions.changePercent)}:void 0},{title:"Messages",value:t.data.messages.total,metricType:"messages",icon:"message-circle",info:"Total messages exchanged between users and the app",highlighted:!1,change:r!=null&&r.messages?{value:Math.abs(r.messages.changePercent.total),type:n(r.messages.changePercent.total)}:void 0},{title:"Tokens",value:t.data.tokens.total,metricType:"tokens",icon:"coins",info:"Total input and output tokens processed by the app for all interactions",highlighted:!1,change:r!=null&&r.tokens?{value:Math.abs(r.tokens.changePercent.total),type:n(r.tokens.changePercent.total)}:void 0}]}transformRunsCards(t){const r=t.data.trends;console.log("Transforming runs cards with trends:",r);const n=a=>a>0?"increase":"decrease";return[{title:"Agent Runs",value:t.data.agentRuns,metricType:"agentRuns",icon:"bot",info:"Number of times the AI agents were executed to handle user requests",highlighted:!0,change:r!=null&&r.agentRuns?{value:Math.abs(r.agentRuns.changePercent),type:n(r.agentRuns.changePercent)}:void 0},{title:"Tool Runs",value:t.data.toolRuns.total,metricType:"toolRuns",icon:"wrench",info:"Number of times various tools were triggered by the AI agents to complete tasks",highlighted:!1,change:r!=null&&r.toolRuns?{value:Math.abs(r.toolRuns.changePercent.total),type:n(r.toolRuns.changePercent.total)}:void 0},{title:"Model Runs",value:t.data.modelRuns,metricType:"modelRuns",icon:"cpu",info:"Number of times the AI agents called various language models to generate responses",highlighted:!1,change:r!=null&&r.modelRuns?{value:Math.abs(r.modelRuns.changePercent),type:n(r.modelRuns.changePercent)}:void 0}]}transformTimeSeriesDataForMetric(t,r){var a;if(console.log("=== METRIC-SPECIFIC TRANSFORM DEBUG ==="),console.log("Raw TimeSeriesResponse:",JSON.stringify(t,null,2)),console.log("Metric type:",r),!t||!t.data||!Array.isArray(t.data))return console.error("Invalid time series data structure:",t),[];const n=t.data.map((i,o)=>{console.log(`Processing point ${o}:`,i);const s=new Date(i.timestamp),l=s.toISOString().split("T")[0],u=s.toLocaleDateString("en-US",{month:"short",day:"numeric"}),c={date:l,timestamp:u,formattedDate:u,count:i.count||0,value:i.count||0,input_tokens:i.input_tokens||0,output_tokens:i.output_tokens||0,total_tokens:(i.input_tokens||0)+(i.output_tokens||0),inputTokens:i.input_tokens||0,outputTokens:i.output_tokens||0,totalTokens:(i.input_tokens||0)+(i.output_tokens||0),listView:i.listView||[],index:o};switch(r){case"users":c.users=i.count||0;break;case"sessions":c.sessions=i.count||0;break;case"messages":c.messages=i.count||0;break;case"tokens":c.tokens=i.count||0,i.input_tokens||i.output_tokens?c.totalTokens=(i.input_tokens||0)+(i.output_tokens||0):c.totalTokens=i.count||0;break;case"agentRuns":c.agentRuns=i.count||0;break;case"toolRuns":c.toolRuns=i.count||0;break;case"modelRuns":c.modelRuns=i.count||0;break;default:c.users=i.count||0,c.sessions=i.count||0,c.messages=i.count||0,c.tokens=i.count||0,c.agentRuns=i.count||0,c.toolRuns=i.count||0,c.modelRuns=i.count||0}return console.log(`Transformed point ${o} for metric ${r}:`,c),c});return console.log("Final transformed data array:",JSON.stringify(n,null,2)),console.log("Sample transformed point for chart:",n[0]),console.log("Populated metric property:",r,"=",(a=n[0])==null?void 0:a[r||"count"]),console.log("=== END METRIC-SPECIFIC TRANSFORM DEBUG ==="),n}transformTimeSeriesData(t){return this.transformTimeSeriesDataForMetric(t)}transformAgentsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>{var o,s;let a="",i=null;if(r.icon)try{if(i=typeof r.icon=="string"?JSON.parse(r.icon):r.icon,i.name){const l=((o=r.agentName)==null?void 0:o.replace(/\s+/g,""))||`agent${n}`,u=((s=i.color)==null?void 0:s.replace("#",""))||"b6e3f4";a=`https://api.dicebear.com/7.x/avataaars/svg?seed=${l}&backgroundColor=${u}&backgroundType=solid`}}catch{console.warn("Failed to parse icon data:",r.icon)}return{id:`agent-${n+1}`,name:r.agentName||`Agent ${n+1}`,runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",tokens:r.tokens||Math.floor((r.count||0)*150),successRate:r.successRate?`${Math.round(r.successRate)}%`:"95%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),avatar:a||`https://api.dicebear.com/7.x/avataaars/svg?seed=agent${n}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`,icon:r.icon||void 0}}):(console.warn("Invalid listView data for agents:",t),[])}transformToolsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>({id:`tool-${n+1}`,name:r.toolName||r.tool_name||`Tool ${n+1}`,type:r.type||r.toolType||r.tool_type||"Code Tool",runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",tokens:r.tokens||Math.floor((r.count||0)*50),successRate:r.successRate?`${Math.round(r.successRate)}%`:"92%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:r.icon||r.tool_icon||void 0})):(console.warn("Invalid listView data for tools:",t),[])}transformModelsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>({id:`model-${n+1}`,name:r.modelName||`Model ${n+1}`,modelName:r.modelName,provider:r.provider,runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",avgResponseTime:r.avgResponseTime,tokens:r.tokens||r.totalTokens||Math.floor((r.count||0)*300),totalTokens:r.totalTokens||r.tokens,successRate:r.successRate?`${Math.round(r.successRate)}%`:"98%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:r.icon})):(console.warn("Invalid listView data for models:",t),[])}extractAgentControlOptions(t){if(!Array.isArray(t))return[{label:"All Agents",value:"all"}];const r=[{label:"All Agents",value:"all"}];return t.forEach(n=>{var a;if(n.agentName){let i="";try{if(n.icon){const o=typeof n.icon=="string"?JSON.parse(n.icon):n.icon;if(o.name){const s=n.agentName.replace(/\s+/g,""),l=((a=o.color)==null?void 0:a.replace("#",""))||"b6e3f4";i=`https://api.dicebear.com/7.x/avataaars/svg?seed=${s}&backgroundColor=${l}&backgroundType=solid`}}}catch{console.warn("Failed to parse icon data for control:",n.icon)}r.push({label:n.agentName,value:n.agentName.replace(/\s+/g,"").toLowerCase(),avatar:i||`https://api.dicebear.com/7.x/avataaars/svg?seed=${n.agentName.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`})}}),r}extractToolControlOptions(t){if(!Array.isArray(t))return[{label:"All Tools",value:"all"}];const r=[{label:"All Tools",value:"all"}];return t.forEach(n=>{const a=n.toolName||n.tool_name;if(a){let i=function(o){if(!o)return"Code Tool";const s=o.toLowerCase();return["inlinetool","code tool","code","event"].includes(s)?"Code Tool":["toollibrary","workflow tool"].includes(s)?"Workflow Tool":["mcp","mcptool"].includes(s)?"MCP Tool":["knowledge","knowledge tool"].includes(s)||o==="KNOWLEDGE"?"Knowledge":o==="inlineTool"?"Code Tool":o==="toolLibrary"?"Workflow Tool":o==="MCP"||o==="mcpTool"?"MCP Tool":"Code Tool"};r.push({label:a,value:a.replace(/[-]/g,""),icon:n.icon||n.tool_icon||void 0,type:n.type||i(n.toolType||n.tool_type)})}}),r}extractModelControlOptions(t){if(!Array.isArray(t))return[{label:"All Models",value:"all"}];const r=[{label:"All Models",value:"all"}];return t.forEach(n=>{n.modelName&&r.push({label:n.modelName,value:n.modelName.replace(/[-\.]/g,""),icon:n.icon,type:n.provider})}),r}async fetchTimeSeriesDataWithTableData(t,r,n,a,i,o=[]){const s=await this.fetchTimeSeriesData(t,r,n,a,i,o);let l=[];s.data.forEach(d=>{d.listView&&Array.isArray(d.listView)&&(l=[...l,...d.listView])});const u=this.aggregateListViewItems(l);let c=[],f=[];return t==="agent-runs"?(c=this.transformAgentsListViewToTable(u),f=this.extractAgentControlOptions(u)):t==="tool-runs"?(c=this.transformToolsListViewToTable(u),f=this.extractToolControlOptions(u)):t==="model-runs"&&(c=this.transformModelsListViewToTable(u),f=this.extractModelControlOptions(u)),{chartData:this.transformTimeSeriesDataForMetric(s,t.replace("-","")),tableData:c,controlOptions:f}}aggregateListViewItems(t){const r=new Map;return t.forEach(n=>{const a=n.agentName||n.toolName||n.modelName||"unknown";if(r.has(a)){const i=r.get(a);i.count=(i.count||0)+(n.count||0),i.avgResponseTime=i.avgResponseTime&&n.avgResponseTime?(i.avgResponseTime+n.avgResponseTime)/2:i.avgResponseTime||n.avgResponseTime,i.tokens=(i.tokens||0)+(n.tokens||0)}else r.set(a,{...n})}),Array.from(r.values())}async fetchEnhancedMetricsData(t,r,n,a=[]){try{const[i,o,s]=await Promise.all([this.fetchTimeSeriesDataWithTableData("agent-runs","runs",t,r,n,a),this.fetchTimeSeriesDataWithTableData("tool-runs","runs",t,r,n,a),this.fetchTimeSeriesDataWithTableData("model-runs","runs",t,r,n,a)]);return{agents:i,tools:o,models:s}}catch(i){throw console.error("Error fetching enhanced metrics data:",i),i}}async transformRunsCardsWithEnhancedData(t,r,n,a,i=[]){const o=t.data.trends,s=h=>h>0?"increase":"decrease",[l,u,c,f]=await Promise.all([this.fetchTimeSeriesDataWithTableData("agent-runs","runs",r,n,a,i),this.fetchTimeSeriesDataWithTableData("tool-runs","runs",r,n,a,i),this.fetchTimeSeriesDataWithTableData("model-runs","runs",r,n,a,i),this.fetchTimeSeriesData("tool-runs","runs",r,n,a,i)]),d=this.transformTimeSeriesDataForToolRuns(f);return[{title:"Agent Runs",value:t.data.agentRuns,metricType:"agentRuns",icon:"bot",highlighted:!0,info:"Number of times the AI agents were executed to handle user requests",change:o!=null&&o.agentRuns?{value:Math.abs(o.agentRuns.changePercent),type:s(o.agentRuns.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Agent Runs",data:l.chartData,dataKey:"agentRuns",color:"#0BA5EC",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Agent Runs",data:l.tableData,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"},{key:"tokens",title:"Tokens",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`}]}},controls:{dropdown:{label:"All Agents",options:l.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Tool Runs",value:t.data.toolRuns.total,metricType:"toolRuns",icon:"wrench",info:"Number of times various tools were triggered by the AI agents to complete tasks",highlighted:!1,change:o!=null&&o.toolRuns?{value:Math.abs(o.toolRuns.changePercent.total),type:s(o.toolRuns.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Tool Runs",data:d,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#667085",label:"Tool Runs"},{dataKey:"codeTools",color:"#F38744",label:"Code Tools"},{dataKey:"workflowTools",color:"#2970FF",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#7A5AF8",label:"Knowledge"},{dataKey:"mcpTools",color:"#47CD89",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Tool Runs",data:u.tableData,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"type",title:"Type",width:150,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Tools",options:u.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Model Runs",value:t.data.modelRuns,metricType:"modelRuns",icon:"cpu",highlighted:!1,info:"Number of times the AI agents called various language models to generate responses",change:o!=null&&o.modelRuns?{value:Math.abs(o.modelRuns.changePercent),type:s(o.modelRuns.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Model Runs",data:c.chartData,dataKey:"modelRuns",color:"#47CD89",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Model Runs",data:c.tableData,columns:[{key:"name",title:"Model Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"tokens",title:"Tokens",width:120,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Models",options:c.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}}]}async transformUsageAnalyticsCardsWithEnhancedData(t,r,n,a,i=[]){const o=t.data.trends,s=d=>d>0?"increase":"decrease",[l,u,c,f]=await Promise.all([this.fetchTimeSeriesData("users","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("sessions","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("messages","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("tokens","usage-analytics",r,n,a,i)]);return[{title:"Users",value:t.data.users,metricType:"users",icon:"users",highlighted:!0,info:"Number of unique users who interacted with the app",change:o!=null&&o.users?{value:Math.abs(o.users.changePercent),type:s(o.users.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Users",data:this.transformTimeSeriesDataForMetric(l,"users"),dataKey:"users",color:"#4E5BA6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Sessions",value:t.data.sessions,metricType:"sessions",icon:"activity",highlighted:!1,info:"Number of conversations initiated with the app",change:o!=null&&o.sessions?{value:Math.abs(o.sessions.changePercent),type:s(o.sessions.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Sessions",data:this.transformTimeSeriesDataForMetric(u,"sessions"),dataKey:"sessions",color:"#0BA5EC",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Messages",value:t.data.messages.total,metricType:"messages",icon:"message-circle",info:"Total messages exchanged between users and the app",highlighted:!1,change:o!=null&&o.messages?{value:Math.abs(o.messages.changePercent.total),type:s(o.messages.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Messages",data:this.transformTimeSeriesDataForMetric(c,"messages"),dataKey:"messages",color:"#E478FA",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Tokens",value:t.data.tokens.total,metricType:"tokens",icon:"coins",info:"Total input and output tokens processed by the app for all interactions",highlighted:!1,change:o!=null&&o.tokens?{value:Math.abs(o.tokens.changePercent.total),type:s(o.tokens.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Token Usage Breakdown",data:this.transformTimeSeriesDataForMetric(f,"tokens"),yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#FF692E",label:"Total Tokens"},{dataKey:"inputTokens",color:"#5925DC",label:"Input Tokens"},{dataKey:"outputTokens",color:"#E478FA",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}}]}transformTimeSeriesDataForToolRuns(t){if(console.log("=== TOOL RUNS SPECIFIC TRANSFORM DEBUG ==="),console.log("Raw TimeSeriesResponse for tool runs:",JSON.stringify(t,null,2)),!t||!t.data||!Array.isArray(t.data))return console.error("Invalid time series data structure:",t),[];const r=t.data.map((n,a)=>{console.log(`Processing point ${a}:`,n);const i=new Date(n.timestamp),o=i.toISOString().split("T")[0],s=i.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=n.count||0;let u=0,c=0,f=0,d=0;if(n.listView&&Array.isArray(n.listView)){n.listView.forEach(y=>{const p=y.count||0,b=(y.toolType||y.tool_type||"").toLowerCase(),S=(y.toolName||y.tool_name||"").toLowerCase();console.log("Processing listView item:",{toolType:b,toolName:S,count:p});const x=b.toLowerCase();["inlinetool","inlineTool","tool","code","codetool","event","EVENT"].includes(b)||["inlinetool","tool","code","codetool","event"].includes(x)?u+=p:["toollibrary","toolLibrary","workflow","workflowtool"].includes(b)||["toollibrary","workflow","workflowtool"].includes(x)?c+=p:["knowledge","KNOWLEDGE","knowledgetool"].includes(b)||["knowledge","knowledgetool"].includes(x)?f+=p:["mcp","MCP","mcptool","mcpTool"].includes(b)||["mcp","mcptool"].includes(x)?d+=p:(console.log(`Unknown tool type '${b}' for tool '${S}', defaulting to code tools`),u+=p)}),console.log(`Calculated breakdown for point ${a}:`,{codeTools:u,workflowTools:c,knowledgeTools:f,mcpTools:d,total:u+c+f+d,expectedTotal:l});const v=u+c+f+d;if(Math.abs(v-l)>1){console.warn(`Breakdown total (${v}) doesn't match expected total (${l}) for point ${a}`);const y=l-v;u+=y,console.log(`Adjusted codeTools by ${y} to balance total`)}}else console.log(`No listView data for point ${a}, assigning all ${l} to codeTools`),u=l;const h={date:o,timestamp:s,formattedDate:s,toolRuns:l,value:l,count:l,codeTools:u,workflowTools:c,knowledgeTools:f,mcpTools:d,input_tokens:n.input_tokens||0,output_tokens:n.output_tokens||0,total_tokens:(n.input_tokens||0)+(n.output_tokens||0),inputTokens:n.input_tokens||0,outputTokens:n.output_tokens||0,totalTokens:(n.input_tokens||0)+(n.output_tokens||0),listView:n.listView||[],index:a};return console.log(`Transformed tool runs point ${a}:`,h),h});return console.log("Final tool runs transformed data:",JSON.stringify(r,null,2)),console.log("=== END TOOL RUNS SPECIFIC TRANSFORM DEBUG ==="),r}async fetchAllCardsData(t,r,n=[]){try{const[a,i]=await Promise.all([this.fetchUsageAnalyticsCards(t,r,void 0,n),this.fetchRunsCards(t,r,void 0,n)]);return{usageAnalytics:this.transformUsageAnalyticsCards(a),runs:this.transformRunsCards(i)}}catch(a){throw console.error("Error fetching cards data:",a),a}}async fetchAllCardsDataWithEnhancedViews(t,r,n,a=[]){try{const[i,o]=await Promise.all([this.fetchUsageAnalyticsCards(t,r,n,a),this.fetchRunsCards(t,r,n,a)]),[s,l]=await Promise.all([this.transformUsageAnalyticsCardsWithEnhancedData(i,t,r,n,a),this.transformRunsCardsWithEnhancedData(o,t,r,n,a)]);return{usageAnalytics:s,runs:l}}catch(i){throw console.error("Error fetching enhanced cards data:",i),i}}async fetchDefaultTimeSeriesData(t,r,n,a=[]){try{const[i,o]=await Promise.all([this.fetchTimeSeriesData("sessions","usage-analytics",t,r,n,a),this.fetchTimeSeriesData("agent-runs","runs",t,r,n,a)]);return{sessions:this.transformTimeSeriesData(i),agentRuns:this.transformTimeSeriesData(o)}}catch(i){throw console.error("Error fetching default time series data:",i),i}}transformListViewForSlider(t,r){return Array.isArray(t)?t.map((n,a)=>{const i={id:`${r}-${a+1}`,runs:n.count||0,responseTime:n.avgResponseTime?n.avgResponseTime<1e3?`${Math.round(n.avgResponseTime)}ms`:`${(n.avgResponseTime/1e3).toFixed(2)}s`:"0ms",successRate:n.successRate?`${Math.round(n.successRate)}%`:void 0,tokens:n.totalTokens||n.tokens||0,icon:n.icon||n.tool_icon||void 0,aiModel:"gpt-4o"};switch(r){case"agentRuns":return{...i,name:n.agentName||`Agent ${a+1}`,type:"Agent",aiModel:this.extractAIModel(n)||"gpt-4o"};case"toolRuns":return{...i,name:n.toolName||n.tool_name||`Tool ${a+1}`,type:n.type||n.toolType||n.tool_type||"Code Tool",toolType:n.toolType||n.tool_type,aiModel:this.extractAIModel(n)||"gpt-4o"};case"modelRuns":return{...i,name:n.modelName||`Model ${a+1}`,modelName:n.modelName,provider:n.provider,type:n.provider||"Model",aiModel:n.modelName||n.model||"gpt-4o"};default:return{...i,name:`Item ${a+1}`,type:"Unknown",aiModel:"gpt-4o"}}}):(console.warn("Invalid listView data for slider:",t),[])}extractAIModel(t){if(t.modelName)return t.modelName;if(t.model)return t.model;if(t.llmModel)return t.llmModel;if(t.aiModel)return t.aiModel;const r=["gpt-4o","gpt-4o-mini","claude-3-5-haiku"];return r[Math.floor(Math.random()*r.length)]}static getDateRange(t=7){const r=new Date,n=new Date;return n.setDate(r.getDate()-t),{fromTimestamp:n.toISOString(),toTimestamp:r.toISOString()}}static getTimeDimension(t,r){const n=new Date(t),a=new Date(r),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=new Date(a.getFullYear(),a.getMonth(),a.getDate()),s=o.getTime()-i.getTime(),l=s/(1e3*60*60*24),u=i.toISOString().split("T")[0],c=o.toISOString().split("T")[0],f=u===c,d=new Date(n.getFullYear(),n.getMonth(),n.getDate()),h=f&&Math.abs(n.getTime()-d.getTime())<1e3,v=Math.abs(a.getTime()-n.getTime()),y=v<60*1e3;return console.log("🕐 TimeDimension calculation:",{fromTimestamp:t,toTimestamp:r,fromDateStr:u,toDateStr:c,diffInMs:s,diffInDays:l,isSameCalendarDay:f,isTodayPattern:h,timeDiffInMs:v,isVeryClose:y,fromStartOfDay:d.toISOString(),recommended:f||h||y||l<=1?"hour":l<=31?"day":l<=90?"week":"month"}),f||h||y||l<=1?"hour":"day"}getAvailableMetrics(){return{"usage-analytics":["sessions","messages","users","tokens"],runs:["agent-runs","model-runs","tool-runs"]}}}const Sb=({config:e,className:t,isLoading:r,context:n})=>{const{type:a,chart:i,table:o,layout:s="vertical"}=e,[l,u]=A.useState({isOpen:!1,date:"",metricType:"agentRuns",data:[],totalRuns:0}),c=(y,p)=>{console.log("Chart data point clicked in ViewRenderer:",{chartData:y,date:p,context:n});const b=n==null?void 0:n.metricType;if(!b||!["agentRuns","toolRuns","modelRuns"].includes(b)){console.log("Slider not applicable for metric type:",b);return}const S=y.listView||[];console.log("ListView data for clicked date:",S);const T=new Ht({baseUrl:"",projectId:"",environment:""}).transformListViewForSlider(S,b),m=y[b]||y.count||0;console.log("Opening slider with data:",{date:p,metricType:b,sliderData:T,totalRuns:m}),u({isOpen:!0,date:p,metricType:b,data:T,totalRuns:m})},f=()=>{u(y=>({...y,isOpen:!1}))},d=()=>i?(console.log("ViewRenderer - Chart config:",i),console.log("ViewRenderer - Chart data:",i.data),console.log("ViewRenderer - Context:",n),g.jsx("div",{className:"flex-1",children:g.jsx(pb,{config:i,isLoading:r,onDataPointClick:c})})):null,h=()=>o?(n==null?void 0:n.metricType)==="agentRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(mb,{data:o.data})}):(n==null?void 0:n.metricType)==="toolRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(gb,{data:o.data})}):(n==null?void 0:n.metricType)==="modelRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(bb,{data:o.data})}):g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(vb,{config:o})}):null,v=()=>{switch(a){case"chart":return d();case"table":return h();case"mixed":return g.jsxs("div",{className:ue("flex gap-6",s==="horizontal"?"flex-row":"flex-col"),children:[d(),h()]});default:return g.jsxs("div",{className:"p-4 text-center text-gray-500",children:["Unsupported view type: ",a]})}};return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:ue("w-full",t),children:v()}),g.jsx(xb,{isOpen:l.isOpen,onClose:f,date:l.date,metricType:l.metricType,data:l.data,totalRuns:l.totalRuns})]})},js=({options:e,value:t,placeholder:r="Select an option",onChange:n,className:a,disabled:i=!1})=>{const[o,s]=A.useState(!1),[l,u]=A.useState(t||""),c=A.useRef(null),f=e.find(v=>v.value===l);A.useEffect(()=>{const v=y=>{c.current&&!c.current.contains(y.target)&&s(!1)};return o&&document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[o]);const d=v=>{i||(u(v),s(!1),n==null||n(v))},h=()=>{i||s(!o)};return g.jsxs("div",{ref:c,className:ue("relative min-w-[200px]",a),children:[g.jsxs("button",{type:"button",className:ue("flex h-10 w-full min-w-[200px] items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",a),onClick:h,disabled:i,children:[g.jsx("span",{className:ue("truncate",!f&&"text-gray-500"),children:f?f.label:r}),g.jsx(ua,{className:ue("h-4 w-4 text-gray-400 transition-transform duration-200",o&&"rotate-180")})]}),o&&!i&&g.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 min-w-[300px] w-max max-w-lg rounded-md border border-gray-200 bg-white shadow-lg max-h-60 overflow-y-auto",children:e.map(v=>{const y=l===v.value;return g.jsxs("div",{className:"relative group",children:[g.jsx("button",{className:ue("relative flex w-full cursor-pointer select-none items-center px-3 py-2 text-sm text-left outline-none transition-colors",v.disabled?"opacity-50 cursor-not-allowed text-gray-400":y?"bg-blue-50 text-blue-900 font-medium":"text-gray-900 hover:bg-gray-100"),onClick:()=>!v.disabled&&d(v.value),disabled:v.disabled,children:g.jsx("span",{className:"block whitespace-nowrap",children:v.label})}),v.label.length>25&&g.jsx("div",{className:"absolute left-full top-0 ml-2 z-[60] opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",children:g.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-md px-3 py-2 whitespace-nowrap shadow-lg",children:[v.label,g.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-x-full -translate-y-1/2 w-0 h-0 border-t-4 border-b-4 border-r-4 border-transparent border-r-gray-900"})]})})]},v.value)})})]})},xW=({options:e,value:t,defaultValue:r,placeholder:n="Select...",multiSelect:a=!1,searchable:i=!1,onChange:o,className:s,maxItems:l=100,maxLabelLength:u=30})=>{const[c,f]=A.useState(!1),[d,h]=A.useState(""),[v,y]=A.useState(()=>{const M=t||r;return a?Array.isArray(M)?M:M?[M]:[]:M?[Array.isArray(M)?M[0]:M]:[]}),p=A.useRef(null);A.useEffect(()=>{const M=_=>{p.current&&!p.current.contains(_.target)&&f(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const b=(M,_=u)=>M.length<=_?M:M.substring(0,_)+"...",S=i?e.filter(M=>M.label.toLowerCase().includes(d.toLowerCase())):e,x=S.slice(0,l),T=S.length>l,m=M=>{let _;if(a){if(M==="all"){O();return}if(v.includes(M))_=v.filter(R=>R!==M),_=_.filter(R=>R!=="all");else{_=v.filter(D=>D!=="all"),_=[..._,M];const R=S.filter(D=>D.value!=="all").map(D=>D.value),k=_.filter(D=>D!=="all");k.length===R.length&&(_=["all",...k])}}else _=[M],f(!1);y(_);const $=a?_:_[0]||"";o==null||o($)},w=()=>{if(!a)return{checked:!1,indeterminate:!1};const M=S.filter($=>$.value!=="all").map($=>$.value),_=v.filter($=>$!=="all"&&M.includes($));return v.includes("all")&&_.length===0?{checked:!1,indeterminate:!1}:_.length===0?{checked:!1,indeterminate:!1}:_.length===M.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},O=()=>{if(!a)return;const M=w(),_=S.filter($=>$.value!=="all").map($=>$.value);if(M.checked)y(["all"]),o==null||o(["all"]);else{const $=["all",..._];y($),o==null||o($)}},P=()=>{y(["all"]),o==null||o(a?["all"]:"all")},j=()=>{if(!a){if(v.length===0)return n;const R=e.find(k=>k.value===v[0]);return(R==null?void 0:R.label)||n}const M=v.filter(R=>R!=="all"),_=v.includes("all");if(M.length===0)return n;if(M.length===1){const R=e.find(k=>k.value===M[0]);return(R==null?void 0:R.label)||n}const $=e.filter(R=>R.value!=="all").length;return M.length===$?"All selected":`${M.length} selected`};return g.jsxs("div",{className:ue("relative",s),ref:p,children:[g.jsxs("button",{type:"button",onClick:()=>f(!c),className:ue("w-full flex items-center justify-between px-3 py-2 text-left text-sm","border border-gray-300 rounded-md bg-white hover:bg-gray-50","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","transition-colors duration-150"),children:[g.jsx("span",{className:ue("truncate",v.length===0&&"text-gray-500"),children:j()}),g.jsx(ua,{className:ue("w-4 h-4 text-gray-400 transition-transform duration-150",c&&"transform rotate-180")})]}),c&&g.jsxs("div",{className:"absolute z-50 min-w-[300px] w-max max-w-lg mt-1 bg-white border border-gray-200 rounded-md shadow-lg max-h-80 overflow-hidden",children:[i&&g.jsx("div",{className:"p-3 border-b border-gray-100",children:g.jsxs("div",{className:"relative",children:[g.jsx(gf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),g.jsx("input",{type:"text",placeholder:`Search ${n.toLowerCase()}...`,value:d,onChange:M=>h(M.target.value),className:"w-full pl-10 pr-4 py-2 text-sm border border-gray-200 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})}),a&&g.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100 bg-gray-50",children:[g.jsxs("button",{type:"button",onClick:O,className:"flex items-center text-sm font-medium text-gray-700 hover:text-gray-900",children:[g.jsx("div",{className:ue("flex items-center justify-center w-4 h-4 mr-2 border rounded transition-colors duration-150",(()=>{const M=w();return M.indeterminate||M.checked?"bg-blue-600 border-blue-600 text-white":"border-gray-300 bg-white"})()),children:(()=>{const M=w();return M.indeterminate?g.jsx("div",{className:"w-2 h-0.5 bg-white rounded"}):M.checked?g.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:g.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):null})()}),"Select all"]}),g.jsx("button",{type:"button",onClick:P,className:"text-sm font-medium text-blue-600 hover:text-blue-800",children:"Clear"})]}),g.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[x.length===0?g.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No options found"}):x.map(M=>{let _;return M.value==="all"?null:(_=v.includes(M.value),g.jsxs("div",{className:"relative group",children:[g.jsxs("div",{onClick:()=>m(M.value),className:ue("flex items-center px-3 py-2 cursor-pointer hover:bg-gray-50","transition-colors duration-150",_&&"bg-blue-50"),children:[a?g.jsx("div",{className:ue("flex items-center justify-center w-4 h-4 mr-3 border rounded","transition-colors duration-150",_?"bg-blue-600 border-blue-600 text-white":"border-gray-300 bg-white"),children:_&&g.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:g.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}):g.jsx("div",{className:ue("w-4 h-4 mr-3 rounded-full border-2 transition-colors duration-150",_?"border-blue-600 bg-blue-600":"border-gray-300"),children:_&&g.jsx("div",{className:"w-full h-full rounded-full bg-white scale-50"})}),g.jsx("span",{className:ue("flex-1 text-sm whitespace-nowrap",_?"font-medium text-gray-900":"text-gray-700"),children:b(M.label)})]}),M.label.length>u&&g.jsx("div",{className:"absolute left-full top-1/2 transform -translate-y-1/2 ml-2 z-[80] opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",children:g.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-md px-3 py-2 shadow-lg max-w-xs break-words whitespace-normal",children:[M.label,g.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-x-full -translate-y-1/2 w-0 h-0 border-t-4 border-b-4 border-r-4 border-transparent border-r-gray-900"})]})})]},M.value))}),T&&g.jsxs("div",{className:"px-3 py-2 text-xs text-gray-500 bg-gray-50 border-t border-gray-100",children:[g.jsxs("div",{className:"text-center font-medium",children:["+",S.length-l," more items"]}),i&&g.jsx("div",{className:"text-center mt-1 text-gray-400",children:"Use search above to find specific items"})]})]})]})]})},Ab=({config:e,className:t})=>{var s;const{dropdown:r,buttons:n,toggle:a}=e,i=l=>{const u=l.toLowerCase();return u.includes("agent")?"agent":u.includes("tool")?"workflowtool":"app"},o=l=>{const u=l.toLowerCase();return u.includes("agent")?{maxItems:50,maxLabelLength:25}:u.includes("tool")?{maxItems:30,maxLabelLength:20}:{maxItems:40,maxLabelLength:25}};return g.jsxs("div",{className:ue("flex items-center gap-3",t),children:[r&&g.jsx(g.Fragment,{children:r.multiSelect?g.jsx(xW,{options:r.options,value:r.defaultValue,placeholder:r.label,multiSelect:r.multiSelect,searchable:r.searchable,onChange:r.onChange,className:"w-48",iconSource:i(r.label),maxItems:o(r.label).maxItems,maxLabelLength:o(r.label).maxLabelLength}):g.jsx(js,{options:r.options,value:Array.isArray(r.defaultValue)?r.defaultValue[0]:r.defaultValue||((s=r.options[0])==null?void 0:s.value),placeholder:r.label,onChange:l=>{var u;return(u=r.onChange)==null?void 0:u.call(r,l)},className:"w-48"})}),n&&n.length>0&&g.jsx("div",{className:"flex items-center border border-gray-200 rounded-lg overflow-hidden",children:n.map((l,u)=>g.jsxs("button",{onClick:()=>{var c;return(c=l.onClick)==null?void 0:c.call(l,l.value)},className:ue("px-3 py-2 text-sm font-medium transition-colors","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",l.active?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white",u>0&&"border-l border-gray-200"),children:[l.icon&&g.jsx("span",{className:"mr-2",children:l.icon}),l.label]},l.value))}),a&&g.jsxs("div",{className:"flex items-center border border-gray-200 rounded-lg overflow-hidden",children:[g.jsxs("button",{onClick:()=>{var l;return(l=a.onToggle)==null?void 0:l.call(a,"chart")},className:ue("px-3 py-2 text-sm font-medium transition-colors flex items-center gap-2","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",a.chartView?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white"),children:[g.jsx(Jb,{className:"w-4 h-4"}),"Chart"]}),g.jsxs("button",{onClick:()=>{var l;return(l=a.onToggle)==null?void 0:l.call(a,"table")},className:ue("px-3 py-2 text-sm font-medium transition-colors flex items-center gap-2","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset","border-l border-gray-200",a.tableView?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white"),children:[g.jsx(a0,{className:"w-4 h-4"}),"Table"]})]})]})},Tb=({section:e,className:t,isLoading:r,isChartLoading:n,onMetricClick:a})=>{var G;const{id:i,title:o,description:s,metrics:l,view:u,controls:c,layout:f}=e,[d,h]=A.useState(u.type),[v,y]=A.useState("chart"),p=()=>i==="usage-analytics"?"users":i==="runs"?"agentRuns":"users",[b,S]=A.useState(p()),[x,T]=A.useState("all"),m=E=>{var F,W,K,X,Q;const L=P();(F=L==null?void 0:L.controls)!=null&&F.toggle?(y(E),(K=(W=L.controls.toggle).onToggle)==null||K.call(W,E)):(h(E),(Q=(X=c==null?void 0:c.toggle)==null?void 0:X.onToggle)==null||Q.call(X,E))},w=E=>{var W,K;const L=E.metricType||E.title.toLowerCase();S(L);const F=l.find(X=>(X.metricType||X.title.toLowerCase())===L);(K=(W=F==null?void 0:F.controls)==null?void 0:W.dropdown)!=null&&K.multiSelect?T(["all"]):T("all"),a==null||a(E)},O=E=>{var F,W,K;T(E);const L=l.find(X=>(X.metricType||X.title.toLowerCase())===b);(K=(W=(F=L==null?void 0:L.controls)==null?void 0:F.dropdown)==null?void 0:W.onChange)==null||K.call(W,E)},P=()=>l.find(E=>(E.metricType||E.title.toLowerCase())===b)||null,j=E=>Array.isArray(E)?E.filter(F=>F!=="all").length>0:E!=="all",M=E=>Array.isArray(E)?E.filter(L=>L!=="all"):E!=="all"?[E]:[],_=E=>{var K,X,Q,ae,te,V,Y,J,I;const L=((X=(K=E.view)==null?void 0:K.chart)==null?void 0:X.data)||((Q=u.chart)==null?void 0:Q.data)||[];if(!j(x))return L;const F=E.metricType,W=M(x);if(W.length===1){const ie=W[0],q=P(),se=(V=(te=(ae=q==null?void 0:q.controls)==null?void 0:ae.dropdown)==null?void 0:te.options)==null?void 0:V.find(ve=>ve.value===ie),ee=se==null?void 0:se.label;return console.log("🔍 Filtering chart data:",{metricType:F,singleFilter:ie,selectedLabel:ee,baseDataSample:L[0]}),L.map(ve=>{let We=0;return ve.listView&&Array.isArray(ve.listView)&&(We=ve.listView.filter(Ge=>F==="agentRuns"&&Ge.agentName?Ge.agentName===ee||Ge.agentName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):F==="toolRuns"&&Ge.toolName?Ge.toolName===ee||Ge.toolName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):F==="modelRuns"&&Ge.modelName?Ge.modelName===ee||Ge.modelName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):!1).reduce((Ge,lt)=>Ge+(lt.count||0),0)),console.log("📊 Filtered value for",ee,":",We),{...ve,[F]:We}})}if(W.length>1){const ie=P(),se=(((I=(J=(Y=ie==null?void 0:ie.controls)==null?void 0:Y.dropdown)==null?void 0:J.options)==null?void 0:I.filter(ee=>W.includes(ee.value)))||[]).map(ee=>ee.label);return L.map(ee=>{let ve=0;return ee.listView&&Array.isArray(ee.listView)&&(ve=ee.listView.filter(Re=>F==="agentRuns"&&Re.agentName?se.some(Be=>Re.agentName===Be||Re.agentName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):F==="toolRuns"&&Re.toolName?se.some(Be=>Re.toolName===Be||Re.toolName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):F==="modelRuns"&&Re.modelName?se.some(Be=>Re.modelName===Be||Re.modelName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):!1).reduce((Re,Be)=>Re+(Be.count||0),0)),{...ee,[F]:ve}})}return L},$=E=>{var K;if(!((K=E.view)!=null&&K.chart))return null;const L=_(E),F=()=>{var Q,ae,te,V,Y,J;if(!j(x)||!((Q=E.controls)!=null&&Q.dropdown))return((te=(ae=E.view)==null?void 0:ae.chart)==null?void 0:te.title)||E.title;const X=M(x);if(X.length===1){const I=(V=E.controls.dropdown.options)==null?void 0:V.find(ie=>ie.value===X[0]);return I?`${I.label}`:((J=(Y=E.view)==null?void 0:Y.chart)==null?void 0:J.title)||E.title}return`${X.length} selected`},W=M(x);return E.metricType==="toolRuns"&&W.length===1?{...E.view.chart,data:L,title:F(),lines:void 0,dataKey:"toolRuns",color:"#f97316",showLegend:!1}:E.metricType==="modelRuns"&&W.length===1?{...E.view.chart,data:L,title:F(),dataKey:"modelRuns",color:"#10b981",showLegend:!1}:{...E.view.chart,data:L,title:F()}},R=(E,L)=>{if(!j(x))return E;const F=M(x);if(F.length===1){const W=F[0];if(i==="runs"&&L==="agentRuns")return E.map(K=>({...K,agentRuns:K[W]||0}));if(i==="runs"&&L==="toolRuns")return E.map(K=>({...K,toolRuns:K[W.replace(/[-]/g,"")]||0}));if(i==="runs"&&L==="modelRuns")return E.map(K=>({...K,modelRuns:K[W.replace(/[-\.]/g,"")]||0}))}return E},k=E=>{var K;const L=((K=u.chart)==null?void 0:K.data)||[],F=R(L,E),W=X=>{var ae,te;if(!j(x))return X;const Q=M(x);if(Q.length===1){const V=(te=(ae=c==null?void 0:c.dropdown)==null?void 0:ae.options)==null?void 0:te.find(Y=>Y.value===Q[0]);return V?`${V.label}`:X}return`${Q.length} selected`};switch(E){case"users":return{type:"line",title:"Total Users",data:L,dataKey:"users",color:"#8b5cf6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"sessions":return{type:"line",title:"Total Sessions",data:L,dataKey:"sessions",color:"#06b6d4",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"messages":return{type:"line",title:"Total Messages",data:L,dataKey:"messages",color:"#ec4899",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"tokens":return{type:"line",title:"Token Usage Breakdown",data:L,yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#f59e0b",label:"Total Tokens"},{dataKey:"inputTokens",color:"#3b82f6",label:"Input Tokens"},{dataKey:"outputTokens",color:"#ec4899",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"agentRuns":return{type:"line",title:W("Agent Runs"),data:F,dataKey:"agentRuns",color:"#06b6d4",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"toolRuns":return M(x).length===1?{type:"line",title:W("Tool Runs"),data:R(L,"toolRuns"),dataKey:"toolRuns",color:"#f97316",yAxisLabel:"Number of Tool Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}:{type:"line",title:"Tool Runs",data:F,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#06b6d4",label:"Tool Runs"},{dataKey:"codeTools",color:"#f97316",label:"Code Tools"},{dataKey:"workflowTools",color:"#10b981",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#8b5cf6",label:"Knowledge"},{dataKey:"mcpTools",color:"#ef4444",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"modelRuns":return M(x).length===1?{type:"line",title:W("Model Runs"),data:R(L,"modelRuns"),dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}:{type:"line",title:W("Model Runs"),data:F,dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};default:return null}},D=(()=>{const E=P();return E!=null&&E.controls?{...E.controls,dropdown:E.controls.dropdown?{...E.controls.dropdown,onChange:O}:void 0,toggle:E.controls.toggle?{...E.controls.toggle,chartView:v==="chart",tableView:v==="table",onToggle:m}:void 0}:c?{...c,dropdown:c.dropdown?{...c.dropdown,onChange:O}:void 0,toggle:c.toggle?{...c.toggle,chartView:d==="chart",tableView:d==="table",onToggle:m}:void 0}:void 0})(),B=(()=>{var F,W,K,X,Q,ae,te,V,Y,J;const E=P();if(E!=null&&E.view){if((F=E.controls)!=null&&F.toggle){if(v==="table"&&E.view.table){let ie=E.view.table.data;if(E.metricType==="agentRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((X=(K=(W=E.controls)==null?void 0:W.dropdown)==null?void 0:K.options)==null?void 0:X.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}if(E.metricType==="toolRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((te=(ae=(Q=E.controls)==null?void 0:Q.dropdown)==null?void 0:ae.options)==null?void 0:te.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}if(E.metricType==="modelRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((J=(Y=(V=E.controls)==null?void 0:V.dropdown)==null?void 0:Y.options)==null?void 0:J.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}return{type:"table",table:{...E.view.table,data:ie}}}else if(v==="chart"&&E.view.chart)return{type:"chart",chart:$(E)||E.view.chart}}const I=$(E);return I?{...E.view,chart:I}:E.view}const L=k(b);return L?{type:"chart",chart:L}:{...u,type:d}})(),U=()=>l.map(E=>{const L=E.metricType||E.title.toLowerCase();return{...E,highlighted:E.highlighted||L===b}});return g.jsxs("div",{className:ue("bg-white rounded-lg border border-gray-200 p-6",t),style:{gridColumn:f!=null&&f.span?`span ${f.span}`:void 0,order:f==null?void 0:f.order},children:[o&&g.jsxs("div",{className:"mb-6",children:[g.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:o}),s&&g.jsx("p",{className:"text-sm text-gray-600 mt-1",children:s})]}),g.jsx("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:r?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})})]}):U().map((E,L)=>g.jsx("div",{className:"flex-1",children:g.jsx(_f,{data:E,onClick:w,isFirst:L===0})},`${i}-metric-${L}`))}),g.jsxs("div",{className:"flex items-center justify-between mb-6",children:[g.jsx("div",{children:P()&&g.jsx("h3",{className:"text-lg font-medium text-gray-900",children:(G=P())==null?void 0:G.title})}),D&&g.jsx(Ab,{config:D})]}),g.jsx(Sb,{config:B,isLoading:r||n,context:{sectionId:i,metricType:b}})]})},sf=A.forwardRef(({className:e,variant:t="default",size:r="md",children:n,...a},i)=>{const o="inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",s={default:"bg-primary text-primary-foreground hover:bg-primary/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground"},l={sm:"h-9 px-3",md:"h-10 px-4 py-2",lg:"h-11 px-8"};return g.jsx("button",{className:ue(o,s[t],l[r],e),ref:i,...a,children:n})});sf.displayName="Button";function $s(e){"@babel/helpers - typeof";return $s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$s(e)}function jt(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Me(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function ze(e){Me(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||$s(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function wW(e,t){Me(2,arguments);var r=ze(e),n=jt(t);return isNaN(n)?new Date(NaN):(n&&r.setDate(r.getDate()+n),r)}function lf(e,t){Me(2,arguments);var r=ze(e),n=jt(t);if(isNaN(n))return new Date(NaN);if(!n)return r;var a=r.getDate(),i=new Date(r.getTime());i.setMonth(r.getMonth()+n+1,0);var o=i.getDate();return a>=o?i:(r.setFullYear(i.getFullYear(),i.getMonth(),a),r)}function OW(e,t){Me(2,arguments);var r=ze(e).getTime(),n=jt(t);return new Date(r+n)}var SW={};function bi(){return SW}function AW(e,t){var r,n,a,i,o,s;Me(1,arguments);var l=bi(),u=jt((r=(n=(a=(i=void 0)!==null&&i!==void 0?i:void 0)!==null&&a!==void 0?a:l.weekStartsOn)!==null&&n!==void 0?n:(o=l.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&r!==void 0?r:0);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=ze(e),f=c.getDay(),d=(f<u?7:0)+f-u;return c.setDate(c.getDate()-d),c.setHours(0,0,0,0),c}function TW(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function ra(e){Me(1,arguments);var t=ze(e);return t.setHours(0,0,0,0),t}function xi(e,t){Me(2,arguments);var r=ra(e),n=ra(t);return r.getTime()===n.getTime()}function PW(e){return Me(1,arguments),e instanceof Date||$s(e)==="object"&&Object.prototype.toString.call(e)==="[object Date]"}function _W(e){if(Me(1,arguments),!PW(e)&&typeof e!="number")return!1;var t=ze(e);return!isNaN(Number(t))}function EW(e){Me(1,arguments);var t=ze(e);return t.setHours(23,59,59,999),t}function jW(e){Me(1,arguments);var t=ze(e);return t.setDate(1),t.setHours(0,0,0,0),t}function $W(e,t){Me(2,arguments);var r=jt(t);return OW(e,-r)}var CW=864e5;function kW(e){Me(1,arguments);var t=ze(e),r=t.getTime();t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);var n=t.getTime(),a=r-n;return Math.floor(a/CW)+1}function Cs(e){Me(1,arguments);var t=1,r=ze(e),n=r.getUTCDay(),a=(n<t?7:0)+n-t;return r.setUTCDate(r.getUTCDate()-a),r.setUTCHours(0,0,0,0),r}function Pb(e){Me(1,arguments);var t=ze(e),r=t.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(r+1,0,4),n.setUTCHours(0,0,0,0);var a=Cs(n),i=new Date(0);i.setUTCFullYear(r,0,4),i.setUTCHours(0,0,0,0);var o=Cs(i);return t.getTime()>=a.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function MW(e){Me(1,arguments);var t=Pb(e),r=new Date(0);r.setUTCFullYear(t,0,4),r.setUTCHours(0,0,0,0);var n=Cs(r);return n}var NW=6048e5;function DW(e){Me(1,arguments);var t=ze(e),r=Cs(t).getTime()-MW(t).getTime();return Math.round(r/NW)+1}function ks(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=bi(),f=jt((r=(n=(a=(i=t==null?void 0:t.weekStartsOn)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&a!==void 0?a:c.weekStartsOn)!==null&&n!==void 0?n:(l=c.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&r!==void 0?r:0);if(!(f>=0&&f<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var d=ze(e),h=d.getUTCDay(),v=(h<f?7:0)+h-f;return d.setUTCDate(d.getUTCDate()-v),d.setUTCHours(0,0,0,0),d}function _b(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=ze(e),f=c.getUTCFullYear(),d=bi(),h=jt((r=(n=(a=(i=t==null?void 0:t.firstWeekContainsDate)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&a!==void 0?a:d.firstWeekContainsDate)!==null&&n!==void 0?n:(l=d.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var v=new Date(0);v.setUTCFullYear(f+1,0,h),v.setUTCHours(0,0,0,0);var y=ks(v,t),p=new Date(0);p.setUTCFullYear(f,0,h),p.setUTCHours(0,0,0,0);var b=ks(p,t);return c.getTime()>=y.getTime()?f+1:c.getTime()>=b.getTime()?f:f-1}function IW(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=bi(),f=jt((r=(n=(a=(i=t==null?void 0:t.firstWeekContainsDate)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&a!==void 0?a:c.firstWeekContainsDate)!==null&&n!==void 0?n:(l=c.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1),d=_b(e,t),h=new Date(0);h.setUTCFullYear(d,0,f),h.setUTCHours(0,0,0,0);var v=ks(h,t);return v}var LW=6048e5;function RW(e,t){Me(1,arguments);var r=ze(e),n=ks(r,t).getTime()-IW(r,t).getTime();return Math.round(n/LW)+1}function _e(e,t){for(var r=e<0?"-":"",n=Math.abs(e).toString();n.length<t;)n="0"+n;return r+n}var Pr={y:function(t,r){var n=t.getUTCFullYear(),a=n>0?n:1-n;return _e(r==="yy"?a%100:a,r.length)},M:function(t,r){var n=t.getUTCMonth();return r==="M"?String(n+1):_e(n+1,2)},d:function(t,r){return _e(t.getUTCDate(),r.length)},a:function(t,r){var n=t.getUTCHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h:function(t,r){return _e(t.getUTCHours()%12||12,r.length)},H:function(t,r){return _e(t.getUTCHours(),r.length)},m:function(t,r){return _e(t.getUTCMinutes(),r.length)},s:function(t,r){return _e(t.getUTCSeconds(),r.length)},S:function(t,r){var n=r.length,a=t.getUTCMilliseconds(),i=Math.floor(a*Math.pow(10,n-3));return _e(i,r.length)}},na={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},BW={G:function(t,r,n){var a=t.getUTCFullYear()>0?1:0;switch(r){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(t,r,n){if(r==="yo"){var a=t.getUTCFullYear(),i=a>0?a:1-a;return n.ordinalNumber(i,{unit:"year"})}return Pr.y(t,r)},Y:function(t,r,n,a){var i=_b(t,a),o=i>0?i:1-i;if(r==="YY"){var s=o%100;return _e(s,2)}return r==="Yo"?n.ordinalNumber(o,{unit:"year"}):_e(o,r.length)},R:function(t,r){var n=Pb(t);return _e(n,r.length)},u:function(t,r){var n=t.getUTCFullYear();return _e(n,r.length)},Q:function(t,r,n){var a=Math.ceil((t.getUTCMonth()+1)/3);switch(r){case"Q":return String(a);case"QQ":return _e(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,r,n){var a=Math.ceil((t.getUTCMonth()+1)/3);switch(r){case"q":return String(a);case"qq":return _e(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,r,n){var a=t.getUTCMonth();switch(r){case"M":case"MM":return Pr.M(t,r);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,r,n){var a=t.getUTCMonth();switch(r){case"L":return String(a+1);case"LL":return _e(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,r,n,a){var i=RW(t,a);return r==="wo"?n.ordinalNumber(i,{unit:"week"}):_e(i,r.length)},I:function(t,r,n){var a=DW(t);return r==="Io"?n.ordinalNumber(a,{unit:"week"}):_e(a,r.length)},d:function(t,r,n){return r==="do"?n.ordinalNumber(t.getUTCDate(),{unit:"date"}):Pr.d(t,r)},D:function(t,r,n){var a=kW(t);return r==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):_e(a,r.length)},E:function(t,r,n){var a=t.getUTCDay();switch(r){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,r,n,a){var i=t.getUTCDay(),o=(i-a.weekStartsOn+8)%7||7;switch(r){case"e":return String(o);case"ee":return _e(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,r,n,a){var i=t.getUTCDay(),o=(i-a.weekStartsOn+8)%7||7;switch(r){case"c":return String(o);case"cc":return _e(o,r.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,r,n){var a=t.getUTCDay(),i=a===0?7:a;switch(r){case"i":return String(i);case"ii":return _e(i,r.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,r,n){var a=t.getUTCHours(),i=a/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,r,n){var a=t.getUTCHours(),i;switch(a===12?i=na.noon:a===0?i=na.midnight:i=a/12>=1?"pm":"am",r){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,r,n){var a=t.getUTCHours(),i;switch(a>=17?i=na.evening:a>=12?i=na.afternoon:a>=4?i=na.morning:i=na.night,r){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,r,n){if(r==="ho"){var a=t.getUTCHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return Pr.h(t,r)},H:function(t,r,n){return r==="Ho"?n.ordinalNumber(t.getUTCHours(),{unit:"hour"}):Pr.H(t,r)},K:function(t,r,n){var a=t.getUTCHours()%12;return r==="Ko"?n.ordinalNumber(a,{unit:"hour"}):_e(a,r.length)},k:function(t,r,n){var a=t.getUTCHours();return a===0&&(a=24),r==="ko"?n.ordinalNumber(a,{unit:"hour"}):_e(a,r.length)},m:function(t,r,n){return r==="mo"?n.ordinalNumber(t.getUTCMinutes(),{unit:"minute"}):Pr.m(t,r)},s:function(t,r,n){return r==="so"?n.ordinalNumber(t.getUTCSeconds(),{unit:"second"}):Pr.s(t,r)},S:function(t,r){return Pr.S(t,r)},X:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();if(o===0)return"Z";switch(r){case"X":return jb(o);case"XXXX":case"XX":return Yr(o);case"XXXXX":case"XXX":default:return Yr(o,":")}},x:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"x":return jb(o);case"xxxx":case"xx":return Yr(o);case"xxxxx":case"xxx":default:return Yr(o,":")}},O:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"O":case"OO":case"OOO":return"GMT"+Eb(o,":");case"OOOO":default:return"GMT"+Yr(o,":")}},z:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"z":case"zz":case"zzz":return"GMT"+Eb(o,":");case"zzzz":default:return"GMT"+Yr(o,":")}},t:function(t,r,n,a){var i=a._originalDate||t,o=Math.floor(i.getTime()/1e3);return _e(o,r.length)},T:function(t,r,n,a){var i=a._originalDate||t,o=i.getTime();return _e(o,r.length)}};function Eb(e,t){var r=e>0?"-":"+",n=Math.abs(e),a=Math.floor(n/60),i=n%60;if(i===0)return r+String(a);var o=t;return r+String(a)+o+_e(i,2)}function jb(e,t){if(e%60===0){var r=e>0?"-":"+";return r+_e(Math.abs(e)/60,2)}return Yr(e,t)}function Yr(e,t){var r=t||"",n=e>0?"-":"+",a=Math.abs(e),i=_e(Math.floor(a/60),2),o=_e(a%60,2);return n+i+r+o}var $b=function(t,r){switch(t){case"P":return r.date({width:"short"});case"PP":return r.date({width:"medium"});case"PPP":return r.date({width:"long"});case"PPPP":default:return r.date({width:"full"})}},Cb=function(t,r){switch(t){case"p":return r.time({width:"short"});case"pp":return r.time({width:"medium"});case"ppp":return r.time({width:"long"});case"pppp":default:return r.time({width:"full"})}},FW=function(t,r){var n=t.match(/(P+)(p+)?/)||[],a=n[1],i=n[2];if(!i)return $b(t,r);var o;switch(a){case"P":o=r.dateTime({width:"short"});break;case"PP":o=r.dateTime({width:"medium"});break;case"PPP":o=r.dateTime({width:"long"});break;case"PPPP":default:o=r.dateTime({width:"full"});break}return o.replace("{{date}}",$b(a,r)).replace("{{time}}",Cb(i,r))},WW={p:Cb,P:FW},UW=["D","DD"],zW=["YY","YYYY"];function GW(e){return UW.indexOf(e)!==-1}function KW(e){return zW.indexOf(e)!==-1}function kb(e,t,r){if(e==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var VW={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},qW=function(t,r,n){var a,i=VW[t];return typeof i=="string"?a=i:r===1?a=i.one:a=i.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function uf(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=t.width?String(t.width):e.defaultWidth,n=e.formats[r]||e.formats[e.defaultWidth];return n}}var HW={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},YW={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},XW={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ZW={date:uf({formats:HW,defaultWidth:"full"}),time:uf({formats:YW,defaultWidth:"full"}),dateTime:uf({formats:XW,defaultWidth:"full"})},JW={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},QW=function(t,r,n,a){return JW[t]};function wi(e){return function(t,r){var n=r!=null&&r.context?String(r.context):"standalone",a;if(n==="formatting"&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,o=r!=null&&r.width?String(r.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{var s=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[s]}var u=e.argumentCallback?e.argumentCallback(t):t;return a[u]}}var eU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},tU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},rU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},nU={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},aU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},iU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},oU=function(t,r){var n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},sU={ordinalNumber:oU,era:wi({values:eU,defaultWidth:"wide"}),quarter:wi({values:tU,defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:wi({values:rU,defaultWidth:"wide"}),day:wi({values:nU,defaultWidth:"wide"}),dayPeriod:wi({values:aU,defaultWidth:"wide",formattingValues:iU,defaultFormattingWidth:"wide"})};function Oi(e){return function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;var o=i[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?uU(s,function(f){return f.test(o)}):lU(s,function(f){return f.test(o)}),u;u=e.valueCallback?e.valueCallback(l):l,u=r.valueCallback?r.valueCallback(u):u;var c=t.slice(o.length);return{value:u,rest:c}}}function lU(e,t){for(var r in e)if(e.hasOwnProperty(r)&&t(e[r]))return r}function uU(e,t){for(var r=0;r<e.length;r++)if(t(e[r]))return r}function cU(e){return function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.match(e.matchPattern);if(!n)return null;var a=n[0],i=t.match(e.parsePattern);if(!i)return null;var o=e.valueCallback?e.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;var s=t.slice(a.length);return{value:o,rest:s}}}var fU=/^(\d+)(th|st|nd|rd)?/i,dU=/\d+/i,hU={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},pU={any:[/^b/i,/^(a|c)/i]},vU={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},yU={any:[/1/i,/2/i,/3/i,/4/i]},mU={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},gU={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},bU={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},xU={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},wU={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},OU={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},SU={ordinalNumber:cU({matchPattern:fU,parsePattern:dU,valueCallback:function(t){return parseInt(t,10)}}),era:Oi({matchPatterns:hU,defaultMatchWidth:"wide",parsePatterns:pU,defaultParseWidth:"any"}),quarter:Oi({matchPatterns:vU,defaultMatchWidth:"wide",parsePatterns:yU,defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:Oi({matchPatterns:mU,defaultMatchWidth:"wide",parsePatterns:gU,defaultParseWidth:"any"}),day:Oi({matchPatterns:bU,defaultMatchWidth:"wide",parsePatterns:xU,defaultParseWidth:"any"}),dayPeriod:Oi({matchPatterns:wU,defaultMatchWidth:"any",parsePatterns:OU,defaultParseWidth:"any"})},AU={code:"en-US",formatDistance:qW,formatLong:ZW,formatRelative:QW,localize:sU,match:SU,options:{weekStartsOn:0,firstWeekContainsDate:1}},TU=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,PU=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_U=/^'([^]*?)'?$/,EU=/''/g,jU=/[a-zA-Z]/;function Ms(e,t,r){var n,a,i,o,s,l,u,c,f,d,h,v,y,p;Me(2,arguments);var b=String(t),S=bi(),x=(n=(a=void 0)!==null&&a!==void 0?a:S.locale)!==null&&n!==void 0?n:AU,T=jt((i=(o=(s=(l=void 0)!==null&&l!==void 0?l:void 0)!==null&&s!==void 0?s:S.firstWeekContainsDate)!==null&&o!==void 0?o:(u=S.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&i!==void 0?i:1);if(!(T>=1&&T<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var m=jt((f=(d=(h=(v=void 0)!==null&&v!==void 0?v:void 0)!==null&&h!==void 0?h:S.weekStartsOn)!==null&&d!==void 0?d:(y=S.locale)===null||y===void 0||(p=y.options)===null||p===void 0?void 0:p.weekStartsOn)!==null&&f!==void 0?f:0);if(!(m>=0&&m<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!x.localize)throw new RangeError("locale must contain localize property");if(!x.formatLong)throw new RangeError("locale must contain formatLong property");var w=ze(e);if(!_W(w))throw new RangeError("Invalid time value");var O=TW(w),P=$W(w,O),j={firstWeekContainsDate:T,weekStartsOn:m,locale:x,_originalDate:w},M=b.match(PU).map(function(_){var $=_[0];if($==="p"||$==="P"){var R=WW[$];return R(_,x.formatLong)}return _}).join("").match(TU).map(function(_){if(_==="''")return"'";var $=_[0];if($==="'")return $U(_);var R=BW[$];if(R)return KW(_)&&kb(_,t,String(e)),GW(_)&&kb(_,t,String(e)),R(P,_,x.localize,j);if($.match(jU))throw new RangeError("Format string contains an unescaped latin alphabet character `"+$+"`");return _}).join("");return M}function $U(e){var t=e.match(_U);return t?t[1].replace(EU,"'"):e}function Mb(e,t){Me(2,arguments);var r=ze(e),n=ze(t);return r.getTime()<n.getTime()}function CU(e,t){Me(2,arguments);var r=ze(e).getTime(),n=ze(t.start).getTime(),a=ze(t.end).getTime();if(!(n<=a))throw new RangeError("Invalid interval");return r>=n&&r<=a}function Ns(e,t){Me(2,arguments);var r=jt(t);return wW(e,-r)}function kU(e,t){Me(2,arguments);var r=jt(t);return lf(e,-r)}const Nb=({children:e})=>{const[t,r]=A.useState(!1);return A.useEffect(()=>(r(!0),()=>r(!1)),[]),t?Jr.createPortal(e,document.body):null};function Db({className:e,defaultValue:t,onDateRangeChange:r}){console.log("🗓️ DateRangePicker component rendered with props:",{className:e,defaultValue:t,hasCallback:!!r});const n=[{label:"Today",value:"today",dateRange:{from:ra(new Date),to:new Date}},{label:"Yesterday",value:"yesterday",dateRange:{from:ra(Ns(new Date,1)),to:EW(Ns(new Date,1))}},{label:"This week",value:"thisWeek",dateRange:{from:AW(new Date),to:new Date}},{label:"Last 7 days",value:"7d",dateRange:{from:ra(Ns(new Date,6)),to:new Date}},{label:"This month",value:"thisMonth",dateRange:{from:jW(new Date),to:new Date}},{label:"Last 30 days",value:"30d",dateRange:{from:ra(Ns(new Date,29)),to:new Date}}],a=t?n.find(C=>C.value===t):null;console.log("📅 DateRangePicker initialization:",{defaultValue:t,defaultPreset:a==null?void 0:a.label,hasDateRange:!!(a!=null&&a.dateRange),allPresetValues:n.map(C=>C.value),foundPreset:!!a});const[i,o]=A.useState(a==null?void 0:a.dateRange),[s,l]=A.useState(a==null?void 0:a.dateRange),[u,c]=A.useState(!1),[f,d]=A.useState((a==null?void 0:a.label)||null),[h,v]=A.useState((a==null?void 0:a.label)||null),[y,p]=A.useState(new Date),[b,S]=A.useState(null),[x,T]=A.useState({top:0,left:0}),m=A.useRef(null),w=A.useRef(null);A.useEffect(()=>{var C,B;console.log("📅 DateRangePicker useEffect running:",{hasDefaultPreset:!!a,hasOnDateRangeChange:!!r,currentDate:i,currentLabel:f,defaultValue:t,defaultPresetLabel:a==null?void 0:a.label,defaultPresetValue:a==null?void 0:a.value}),a!=null&&a.dateRange&&r?(console.log("📅 DateRangePicker: Setting initial default value:",{label:a.label,dateRange:a.dateRange,from:(C=a.dateRange.from)==null?void 0:C.toLocaleDateString(),to:(B=a.dateRange.to)==null?void 0:B.toLocaleDateString()}),r(a.dateRange)):console.log("📅 DateRangePicker: NOT setting initial value because:",{hasDefaultPreset:!!a,hasDateRange:!!(a!=null&&a.dateRange),hasCallback:!!r,presetLabelsAvailable:n.map(U=>`${U.value}:${U.label}`)})},[]),A.useEffect(()=>{t&&(a!=null&&a.dateRange)&&(console.log("📅 DateRangePicker: DefaultValue changed, updating state:",{defaultValue:t,label:a.label}),o(a.dateRange),d(a.label),l(a.dateRange),v(a.label))},[t]);const O=()=>{if(!w.current)return;const C=w.current.getBoundingClientRect(),B=window.scrollY,U=window.scrollX,G=window.innerWidth,E=window.innerHeight,L=720,F=450;let W=C.bottom+B+8,K=C.left+U;K+L>G&&(K=C.right+U-L),K+L>G&&(K=G-L-20),W+F>E&&(W=C.top+B-F-8),K<20&&(K=20),W<20&&(W=20),T({top:W,left:K})};A.useEffect(()=>{const C=()=>{u&&O()};return u&&(window.addEventListener("resize",C),window.addEventListener("scroll",C)),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C)}},[u]);const P=(C,B)=>{if(l(C),v(B),S(null),C.from){const U=new Date(C.from.getFullYear(),C.from.getMonth(),1);p(U)}},j=C=>{if(!b)S(C),l({from:C,to:C}),v(null);else{const B=Mb(C,b)?C:b,U=Mb(C,b)?b:C;l({from:B,to:U}),S(null),v(null)}},M=()=>{o(s),d(h),r==null||r(s),c(!1),S(null)},_=()=>{l(void 0),v(null),o(void 0),d(null),r==null||r(void 0),c(!1),S(null)},$=C=>{C?(l(i),v(f),S(null),setTimeout(O,0)):(l(i),v(f),S(null)),c(C)},R=(C,B)=>(console.log("📅 formatDateRange called with:",{presetLabel:B,hasDateRange:!!(C!=null&&C.from)}),B||(C!=null&&C.from?!C.to||xi(C.from,C.to)?Ms(C.from,"MMM dd, yyyy"):`${Ms(C.from,"MMM dd, yyyy")} - ${Ms(C.to,"MMM dd, yyyy")}`:"Pick a date range")),k=(C=0)=>{const B=lf(y,C),U=B.getFullYear(),G=B.getMonth(),E=new Date(U,G,1),F=new Date(U,G+1,0).getDate(),W=E.getDay(),K=["January","February","March","April","May","June","July","August","September","October","November","December"],X=["Su","Mo","Tu","We","Th","Fr","Sa"],Q=[],te=new Date(U,G-1,0).getDate();for(let J=W-1;J>=0;J--){const I=te-J,ie=new Date(U,G-1,I);Q.push(g.jsx("button",{onClick:()=>j(ie),className:"h-8 w-8 text-xs text-gray-400 hover:bg-gray-100 rounded flex items-center justify-center",children:I},`prev-${I}`))}for(let J=1;J<=F;J++){const I=new Date(U,G,J),ie=xi(I,new Date),q=(s==null?void 0:s.from)&&(s==null?void 0:s.to)&&CU(I,{start:s.from,end:s.to}),se=(s==null?void 0:s.from)&&xi(I,s.from),ee=(s==null?void 0:s.to)&&xi(I,s.to),ve=b&&xi(I,b);let We="h-8 w-8 text-xs hover:bg-gray-100 rounded flex items-center justify-center transition-colors ";ie&&(We+="font-semibold "),ve||se||ee?We+="bg-blue-500 text-white hover:bg-blue-600 ":q&&(We+="bg-blue-100 text-blue-900 "),Q.push(g.jsx("button",{onClick:()=>j(I),className:We,children:J},`current-${J}`))}const Y=Math.ceil((W+F)/7)*7-W-F;for(let J=1;J<=Y;J++){const I=new Date(U,G+1,J);Q.push(g.jsx("button",{onClick:()=>j(I),className:"h-8 w-8 text-xs text-gray-400 hover:bg-gray-100 rounded flex items-center justify-center",children:J},`next-${J}`))}return g.jsxs("div",{className:"p-3",children:[g.jsxs("div",{className:"flex items-center justify-between mb-3",children:[C===0&&g.jsx("button",{onClick:()=>p(kU(y,1)),className:"p-1 hover:bg-gray-100 rounded",children:g.jsx(Qb,{className:"h-4 w-4"})}),g.jsxs("div",{className:"font-medium text-sm",children:[K[G]," ",U]}),C===1&&g.jsx("button",{onClick:()=>p(lf(y,1)),className:"p-1 hover:bg-gray-100 rounded",children:g.jsx(e0,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:X.map(J=>g.jsx("div",{className:"h-8 flex items-center justify-center text-xs font-medium text-gray-500",children:J},J))}),g.jsx("div",{className:"grid grid-cols-7 gap-1",children:Q})]})},D=()=>"fixed bg-white border border-gray-200 rounded-lg shadow-xl z-[99999]";return g.jsxs("div",{className:`relative ${e}`,children:[g.jsxs("button",{ref:w,onClick:()=>$(!u),className:`min-w-[200px] px-3 py-2 text-left border border-gray-300 rounded-md shadow-sm bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 flex items-center ${i?"text-gray-900":"text-gray-500"}`,children:[g.jsx(yf,{className:"mr-2 h-4 w-4"}),(()=>{const C=R(i,f);return console.log("📅 Button display text:",{displayText:C,date:i,selectedPresetLabel:f}),C})()]}),u&&g.jsxs(Nb,{children:[g.jsx("div",{className:"fixed inset-0 z-[99998] bg-black bg-opacity-10",onClick:()=>$(!1)}),g.jsxs("div",{ref:m,className:D(),style:{top:x.top,left:x.left,width:"720px",minWidth:"720px",maxHeight:"90vh"},onClick:C=>C.stopPropagation(),children:[g.jsxs("div",{className:"flex",children:[g.jsxs("div",{className:"flex flex-col gap-1 p-3 border-r border-gray-200 w-[160px] flex-shrink-0",children:[g.jsx("div",{className:"text-sm font-medium text-gray-500 mb-2",children:"Quick Filters"}),n.map(C=>g.jsx("button",{onClick:()=>P(C.dateRange,C.label),className:`text-left px-2 py-1.5 text-sm rounded hover:bg-gray-100 transition-colors ${h===C.label?"bg-gray-100":""}`,children:C.label},C.label))]}),g.jsxs("div",{className:"flex flex-1",children:[k(0),k(1)]})]}),g.jsxs("div",{className:"border-t border-gray-200 p-3 flex justify-end gap-2",children:[g.jsx("button",{onClick:_,className:"px-3 py-1.5 text-sm border border-gray-300 rounded hover:bg-gray-50 transition-colors",children:"Clear"}),g.jsx("button",{onClick:M,disabled:!(s!=null&&s.from),className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Apply"})]})]})]})]})}const MU=({config:e,appConfig:t,className:r,onExport:n,onDraftChange:a,onTimeRangeChange:i})=>{var R;const{title:o,subtitle:s,sections:l,globalControls:u,layout:c={columns:12,gap:24,responsive:!0}}=e,[f,d]=A.useState(!1),[h,v]=A.useState({}),[y,p]=A.useState(l),[b,S]=A.useState([]),[x,T]=A.useState(!1),m=A.useRef(null);A.useEffect(()=>{if(t)try{m.current=new Ht(t),w(),O()}catch(k){console.error("Failed to initialize API service:",k)}},[t]);const w=async()=>{if(!(!m.current||!t)){T(!0);try{const k=await m.current.fetchEnvironments();S(k),console.log("🌍 Environments loaded:",k.map(D=>D.envName))}catch(k){console.error("Error loading environments:",k)}finally{T(!1)}}},O=async()=>{if(!(!m.current||!t)){d(!0);try{const k=m.current.getDefaultTimeRange();console.log("📊 Loading dashboard data with date range:",{fromTimestamp:k.fromTimestamp,toTimestamp:k.toTimestamp,fromDate:new Date(k.fromTimestamp).toLocaleDateString(),toDate:new Date(k.toTimestamp).toLocaleDateString()});const D=await m.current.fetchAllCardsDataWithEnhancedViews(k.fromTimestamp,k.toTimestamp);console.log("✅ Enhanced cards data loaded successfully:",D),console.log("📈 Data covers period:",{from:new Date(k.fromTimestamp).toLocaleDateString(),to:new Date(k.toTimestamp).toLocaleDateString()});const C=l.map(B=>B.id==="usage-analytics"?(console.log("Updating usage-analytics section with enhanced data"),{...B,metrics:D.usageAnalytics}):B.id==="runs"?(console.log("Updating runs section with enhanced data including table and controls"),{...B,metrics:D.runs}):B);p(C)}catch(k){console.error("Error loading initial data:",k),p(l)}finally{d(!1)}}},P=async(k,D)=>{if(!(!m.current||!t||!D.metricType)){p(C=>C.map(B=>B.id===k?{...B,metrics:B.metrics.map(U=>({...U,highlighted:U.metricType===D.metricType}))}:B)),v(C=>({...C,[k]:!0}));try{const C=t.defaultTimeRange||Ht.getDateRange(7);let B,U;if(["users","sessions","messages","tokens"].includes(D.metricType))B="usage-analytics",U=D.metricType;else if(["agentRuns","toolRuns","modelRuns"].includes(D.metricType))B="runs",U=D.metricType==="agentRuns"?"agent-runs":D.metricType==="toolRuns"?"tool-runs":"model-runs";else return;const G=await m.current.fetchTimeSeriesData(U,B,C.fromTimestamp,C.toTimestamp),E=m.current.transformTimeSeriesDataForMetric(G,D.metricType);console.log("Time series response for",D.title,":",G),console.log("Transformed data for",D.title,":",E),console.log("Metric type used for transformation:",D.metricType);const F=(W=>({users:"users",sessions:"sessions",messages:"messages",tokens:"totalTokens",agentRuns:"agentRuns",toolRuns:"toolRuns",modelRuns:"modelRuns"})[W]||"count")(D.metricType||"count");console.log("Using dataKey for metric",D.metricType,":",F),p(W=>W.map(K=>{if(K.id===k){const X={...K,view:{...K.view,chart:K.view.chart?{...K.view.chart,data:E,dataKey:F,lines:[{dataKey:F,color:K.view.chart.color||"#3b82f6",label:D.title,strokeWidth:2}]}:{type:"line",data:E,dataKey:F,lines:[{dataKey:F,color:"#3b82f6",label:D.title,strokeWidth:2}],yAxisLabel:D.title}}};return console.log("Updated section for",k,":",X),console.log("Chart config set:",X.view.chart),X}return K}))}catch(C){console.error("Error loading metric data:",C)}finally{v(C=>({...C,[k]:!1}))}}},j=k=>{var D,C;if((C=(D=u==null?void 0:u.draft)==null?void 0:D.onChange)==null||C.call(D,k),a==null||a(k),t&&m.current){const B={...t,environment:k};m.current.updateConfig(B),O()}},M=k=>{var D,C;if(console.log("🗓️ Time range change requested:",k),typeof k=="string"&&((C=(D=u==null?void 0:u.timeRange)==null?void 0:D.onChange)==null||C.call(D,k)),i==null||i(k),t&&m.current){let B=null;if(typeof k=="object"&&k.from&&k.to)B={fromTimestamp:k.from.toISOString(),toTimestamp:k.to.toISOString()},console.log("📅 Converting DateRange to API format:",B);else if(typeof k=="string"){const G={"24h":1,"7d":7,"30d":30,"90d":90}[k];G&&(B=Ht.getDateRange(G),console.log(`📅 Converting preset "${k}" (${G} days) to API format:`,B))}if(B){const U={...t,defaultTimeRange:B};console.log("🔄 Updating API configuration with new date range:",U.defaultTimeRange),m.current.updateConfig(U),console.log("🚀 Reloading dashboard data with new date range..."),O()}else console.warn("⚠️ Unable to convert time range value to API format:",k)}},_=(k="csv")=>{var D,C;(C=(D=u==null?void 0:u.export)==null?void 0:D.onExport)==null||C.call(D,k),n==null||n()},$=Object.values(h).some(k=>k);return g.jsxs("div",{className:ue("mx-auto p-6",r),children:[g.jsx("div",{className:"mb-8",children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:o}),s&&g.jsx("p",{className:"text-gray-600 mt-2",children:s})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[(f||$)&&g.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[g.jsx(n0,{className:"h-4 w-4 animate-spin"}),"Loading..."]}),u&&g.jsxs(g.Fragment,{children:[u.draft&&g.jsx(js,{options:b.length>0?b.map(k=>({label:k.envName.charAt(0).toUpperCase()+k.envName.slice(1),value:k.envName})):u.draft.options,value:u.draft.defaultValue,placeholder:x?"Loading environments...":u.draft.label,onChange:j,className:"min-w-[200px]",disabled:f||$||x}),u.timeRange&&(u.timeRange.useDatePicker?(console.log("🗓️ Dashboard: Rendering DateRangePicker with defaultValue:",u.timeRange.defaultValue),g.jsx(Db,{defaultValue:u.timeRange.defaultValue,onDateRangeChange:k=>{console.log("🗓️ Dashboard: DateRangePicker callback received:",k),k&&M(k)}})):g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(yf,{className:"h-4 w-4 text-gray-500"}),g.jsx(js,{options:u.timeRange.options||[],value:u.timeRange.defaultValue,placeholder:u.timeRange.label,onChange:M,className:"min-w-[200px]",disabled:f||$})]})),((R=u.export)==null?void 0:R.enabled)&&g.jsxs(sf,{variant:"outline",onClick:()=>_(),className:"gap-2",disabled:f||$,children:[g.jsx(t0,{className:"h-4 w-4"}),"Export"]})]})]})]})}),g.jsx("div",{className:ue("grid gap-6",c.responsive&&"grid-cols-1 lg:grid-cols-12"),style:{gridTemplateColumns:c.responsive?void 0:`repeat(${c.columns}, minmax(0, 1fr))`,gap:c.gap?`${c.gap}px`:void 0},children:y.map(k=>{var D,C,B,U;return g.jsx(Tb,{section:k,isLoading:f,isChartLoading:h[k.id]||!1,onMetricClick:G=>P(k.id,G),className:ue(c.responsive&&((D=k.layout)==null?void 0:D.span)===12&&"lg:col-span-12",c.responsive&&((C=k.layout)==null?void 0:C.span)===6&&"lg:col-span-6",c.responsive&&((B=k.layout)==null?void 0:B.span)===4&&"lg:col-span-4",c.responsive&&((U=k.layout)==null?void 0:U.span)===3&&"lg:col-span-3")},k.id)})})]})},Ds=["Portfolio Analysis Expert","Mortgage Evaluator","Credit Risk Specialist","Asset Valuation Analyst","Liability Assessment Advisor"],Is=["calculate-creditScore","calculate-risk","calculate-mortgage","analyse-expenses","fetch-statement"],Ls=["gpt-4o","gpt-4o-mini","gpt-3.5-turbo","claude-3-5-sonnet","claude-3-5-haiku","claude-3-opus","gemini-1.5-pro","gemini-1.5-flash","llama-3.1-405b","llama-3.1-70b"],NU=(e=30)=>{const t=[],r=new Date;for(let n=e-1;n>=0;n--){const a=new Date(r);a.setDate(r.getDate()-n);const i=600+Math.sin(n*.1)*100,o=Math.floor(i+Math.random()*100),s=Math.floor(o*3.5+Math.random()*200),l=Math.floor(s*2.9+Math.random()*500),u=Math.floor(l*.9+Math.random()*300),c=Math.floor(u*.6),f=u-c,d=Math.floor(s*.8+Math.random()*100),h=Math.floor(d*12+Math.random()*500),v=Math.floor(d*8+Math.random()*300),y=Math.floor(h*.3+Math.random()*100),p=Math.floor(h*.25+Math.random()*80),b=Math.floor(h*.2+Math.random()*60),S=Math.floor(h*.15+Math.random()*50),x={};Ds.forEach(w=>{const O=w.replace(/\s+/g,"").toLowerCase(),P=Math.floor(d/Ds.length);x[O]=Math.floor(P+Math.random()*(P*.5))});const T={};Is.forEach(w=>{const O=w.replace(/[-]/g,""),P=Math.floor(h/Is.length);T[O]=Math.floor(P+Math.random()*(P*.8))});const m={};Ls.forEach(w=>{const O=w.replace(/[-\.]/g,""),P=Math.floor(v/Ls.length);m[O]=Math.floor(P+Math.random()*(P*.6))}),t.push({date:a.toISOString().split("T")[0],users:o,sessions:s,messages:l,totalTokens:u,inputTokens:c,outputTokens:f,agentRuns:d,toolRuns:h,modelRuns:v,codeTools:y,workflowTools:p,knowledgeTools:b,mcpTools:S,...x,...T,...m,value:o})}return t},DU=()=>{const e=[],t=['{"name":"avatar14","color":"#F6D0FE","type":"human"}','{"name":"avatar2","color":"#3B82F6","type":"human"}','{"name":"avatar7","color":"#EF4444","type":"human"}','{"name":"avatar12","color":"#10B981","type":"human"}','{"name":"avatar8","color":"#F59E0B","type":"human"}'];return Ds.forEach((r,n)=>{e.push({id:`agent-${n+1}`,name:r,runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*120)+15}s`,tokens:Math.floor(Math.random()*4e5)+1e5,successRate:`${Math.floor(Math.random()*20)+80}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),avatar:`https://api.dicebear.com/7.x/avataaars/svg?seed=${r.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`,icon:t[n]||t[0]})}),e},IU=()=>{const e=r=>r.includes("calculate-creditscore")?"Code Tool":r.includes("calculate-risk")?"Workflow Tool":r.includes("calculate-mortgage")?"MCP Tool":r.includes("analyse-expenses")?"Workflow Tool":r.includes("fetch-statement")?"Knowledge":"Code Tool",t=['{"name":"calculator","color":"#EF6820","type":"inlineTool"}','{"name":"workflow","color":"#155EEF","type":"toolLibrary"}','{"name":"mcptool","color":"#101828","type":"MCP"}','{"name":"expenses","color":"#155EEF","type":"toolLibrary"}','{"name":"knowledge","color":"#7A5AF8","type":"KNOWLEDGE"}'];return Is.map((r,n)=>({id:`tool-${n+1}`,name:r,type:e(r),runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*90)+15}s`,tokens:Math.floor(Math.random()*2e4)+5e3,successRate:`${Math.floor(Math.random()*15)+85}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:t[n]||t[0]}))},LU=()=>Ls.map((e,t)=>({id:`model-${t+1}`,name:e,runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*120)+15}s`,tokens:Math.floor(Math.random()*5e5)+1e5,successRate:`${Math.floor(Math.random()*15)+85}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString()})),Xr=NU(),RU=DU(),BU=IU(),FU=LU(),WU={id:"main-dashboard",title:"Dashboard",subtitle:"Monitor and review the usage of your agentic app.",version:"1.0.0",globalControls:{draft:{label:"Draft",options:[{label:"Current Draft",value:"current"},{label:"Previous Draft",value:"previous"},{label:"All Drafts",value:"all"}],defaultValue:"current"},timeRange:{label:"Time Range",options:[{label:"This month",value:"month"},{label:"Last 7 days",value:"week"},{label:"Last 30 days",value:"30days"},{label:"Last 90 days",value:"90days"}],defaultValue:"month"},export:{enabled:!0,formats:["csv","json","pdf"]}},layout:{columns:12,gap:24,responsive:!0},sections:[{id:"sessions",title:"Sessions",description:"User engagement and session analytics",metrics:[{title:"Users",value:3384,change:{value:6,type:"increase"},info:"Total number of unique users",metricType:"users",view:{type:"chart",chart:{type:"line",title:"Total Users",data:Xr,dataKey:"users",color:"#8b5cf6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Sessions",value:11847,change:{value:18,type:"increase"},info:"Total number of user sessions",metricType:"sessions",view:{type:"chart",chart:{type:"line",title:"Total Sessions",data:Xr,dataKey:"sessions",color:"#06b6d4",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Messages",value:34563,change:{value:5,type:"increase"},info:"Total messages exchanged",metricType:"messages",view:{type:"chart",chart:{type:"line",title:"Total Messages",data:Xr,dataKey:"messages",color:"#e879f9",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Tokens",value:32044,change:{value:44,type:"increase"},info:"Total tokens processed",metricType:"tokens",view:{type:"chart",chart:{type:"line",title:"Token Usage Breakdown",data:Xr,yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#f97316",label:"Total Tokens"},{dataKey:"inputTokens",color:"#3b82f6",label:"Input Tokens"},{dataKey:"outputTokens",color:"#e879f9",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}}],view:{type:"chart"},layout:{span:12,order:1}},{id:"runs",title:"Runs",description:"Agent, tool, and model execution analytics",metrics:[{title:"Agent Runs",value:3384,change:{value:6,type:"increase"},info:"Number of agent executions",metricType:"agentRuns",view:{type:"chart",chart:{type:"line",title:"Agent Runs",data:Xr,dataKey:"agentRuns",color:"#06b6d4",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Agent Runs",data:RU,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"},{key:"tokens",title:"Tokens",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`}]}},controls:{dropdown:{label:"All Agents",options:[{label:"All Agents",value:"all"},...Ds.map(e=>({label:e,value:e.replace(/\s+/g,"").toLowerCase(),avatar:`https://api.dicebear.com/7.x/avataaars/svg?seed=${e.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`}))],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Tool Runs",value:34563,change:{value:5,type:"increase"},info:"Number of tool executions",metricType:"toolRuns",view:{type:"chart",chart:{type:"line",title:"Tool Runs",data:Xr,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#06b6d4",label:"Tool Runs"},{dataKey:"codeTools",color:"#f97316",label:"Code Tools"},{dataKey:"workflowTools",color:"#10b981",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#8b5cf6",label:"Knowledge"},{dataKey:"mcpTools",color:"#ef4444",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Tool Runs",data:BU,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"type",title:"Type",width:150,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Tools",options:[{label:"All Tools",value:"all"},...Is.map((e,t)=>{const r=['{"name":"calculator","color":"#EF6820","type":"inlineTool"}','{"name":"workflow","color":"#155EEF","type":"toolLibrary"}','{"name":"mcptool","color":"#101828","type":"MCP"}','{"name":"expenses","color":"#155EEF","type":"toolLibrary"}','{"name":"knowledge","color":"#7A5AF8","type":"KNOWLEDGE"}'],n=a=>a.includes("calculate-creditscore")?"Code Tool":a.includes("calculate-risk")?"Workflow Tool":a.includes("calculate-mortgage")?"MCP Tool":a.includes("analyse-expenses")?"Workflow Tool":a.includes("fetch-statement")?"Knowledge":"Code Tool";return{label:e,value:e.replace(/[-]/g,""),icon:r[t]||r[0],type:n(e)}})],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Model Runs",value:32044,change:{value:44,type:"increase"},info:"Number of model inferences",metricType:"modelRuns",view:{type:"chart",chart:{type:"line",title:"Model Runs",data:Xr,dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Model Runs",data:FU,columns:[{key:"name",title:"Model Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"tokens",title:"Tokens",width:120,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Models",options:[{label:"All Models",value:"all"},...Ls.map(e=>{const t=r=>{const n=r.toLowerCase();return n.includes("gpt")||n.includes("openai")?"⚡":n.includes("claude")||n.includes("anthropic")?"A":n.includes("gemini")||n.includes("google")?"G":n.includes("llama")||n.includes("meta")?"M":"🤖"};return{label:e,value:e.replace(/[-\.]/g,""),icon:t(e)}})],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}}],view:{type:"chart"},layout:{span:12,order:2}}]},Yt={primary:["#8b5cf6","#06b6d4","#f97316","#10b981","#ec4899","#f59e0b","#3b82f6","#ef4444"],secondary:["#a78bfa","#22d3ee","#fb923c","#34d399","#f472b6","#fbbf24","#60a5fa","#f87171"],accent:["#6366f1","#8b5cf6","#d946ef","#06b6d4","#84cc16","#eab308"],semantic:{success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},gradients:{purple:["#8b5cf6","#a78bfa"],cyan:["#06b6d4","#22d3ee"],orange:["#f97316","#fb923c"],green:["#10b981","#34d399"],sunset:["#f97316","#ec4899"],ocean:["#06b6d4","#3b82f6"],forest:["#10b981","#84cc16"]}},UU={primary:["#7c3aed","#0891b2","#ea580c","#059669","#db2777","#d97706","#2563eb","#dc2626"],secondary:["#8b5cf6","#06b6d4","#f97316","#10b981","#ec4899","#f59e0b","#3b82f6","#ef4444"],accent:["#4f46e5","#7c3aed","#c026d3","#0891b2","#65a30d","#ca8a04"],semantic:{success:"#059669",warning:"#d97706",error:"#dc2626",info:"#2563eb"}},zU={primary:["#a78bfa","#22d3ee","#fb923c","#34d399","#f472b6","#fbbf24","#60a5fa","#f87171"],secondary:["#c4b5fd","#67e8f9","#fdba74","#6ee7b7","#f9a8d4","#fcd34d","#93c5fd","#fca5a5"],accent:["#818cf8","#a78bfa","#e879f9","#22d3ee","#a3e635","#facc15"],semantic:{success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#60a5fa"}},GU={primary:["#1f2937","#374151","#6b7280","#9ca3af","#3b82f6","#1d4ed8","#10b981","#f59e0b"],secondary:["#4b5563","#6b7280","#9ca3af","#d1d5db","#60a5fa","#3b82f6","#34d399","#fbbf24"],accent:["#2563eb","#1d4ed8","#059669","#0891b2","#d97706","#b45309"],semantic:{success:"#059669",warning:"#d97706",error:"#dc2626",info:"#1d4ed8"}},Ib=(e,t)=>e.primary[t%e.primary.length],Si=(e,t)=>e.semantic[t],KU=(e,t)=>{var r;return((r=e.gradients)==null?void 0:r[t])||[e.primary[0],e.primary[1]]},Lb=(e,t=Yt)=>e.map((r,n)=>({...r,color:Ib(t,n)})),Rs=((e=30)=>{const t=[],r=new Date;for(let n=e-1;n>=0;n--){const a=new Date(r);a.setDate(r.getDate()-n);const i=600+Math.sin(n*.1)*100,o=Math.floor(i+Math.random()*100),s=Math.floor(o*3.5+Math.random()*200),l=Math.floor(s*2.9+Math.random()*500),u=Math.floor(l*.9+Math.random()*300),c=Math.floor(u*.6),f=u-c,d=Math.floor(s*.8+Math.random()*100),h=Math.floor(d*12+Math.random()*500),v=Math.floor(d*8+Math.random()*300);t.push({date:a.toISOString().split("T")[0],users:o,sessions:s,messages:l,totalTokens:u,inputTokens:c,outputTokens:f,agentRuns:d,toolRuns:h,modelRuns:v,value:o})}return t})(),VU={id:"enhanced-dashboard",title:"Enhanced Color Configuration Dashboard",subtitle:"Demonstrating all color configuration options",version:"1.0.0",globalControls:{draft:{label:"Draft",options:[{label:"Current Draft",value:"current"},{label:"Previous Draft",value:"previous"}],defaultValue:"current"},timeRange:{label:"Time Range",options:[{label:"Last 7 days",value:"week"},{label:"Last 30 days",value:"30days"}],defaultValue:"30days"},export:{enabled:!0,formats:["csv","json"]}},layout:{columns:12,gap:24,responsive:!0},sections:[{id:"manual-colors",title:"Manual Color Assignment",description:"Each line has manually assigned colors",metrics:[{title:"Total Users",value:3384,change:{value:6,type:"increase"},info:"Manually colored chart"}],view:{type:"chart",chart:{type:"line",title:"Manual Color Configuration",data:Rs,lines:[{dataKey:"users",color:"#8b5cf6",label:"Users",strokeWidth:3},{dataKey:"sessions",color:"#06b6d4",label:"Sessions",strokeWidth:2},{dataKey:"messages",color:"#f97316",label:"Messages",strokeWidth:2,strokeDasharray:"5 5"}],dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:6,order:1}},{id:"auto-colors",title:"Auto-Assigned Colors",description:"Colors automatically assigned from palette",metrics:[{title:"Agent Runs",value:3384,change:{value:6,type:"increase"},info:"Auto-colored from palette"}],view:{type:"chart",chart:{type:"line",title:"Auto Color Assignment",data:Rs,lines:Lb([{dataKey:"agentRuns",label:"Agent Runs"},{dataKey:"toolRuns",label:"Tool Runs"},{dataKey:"modelRuns",label:"Model Runs"},{dataKey:"totalTokens",label:"Total Tokens"}],Yt),dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:6,order:2}},{id:"semantic-colors",title:"Semantic Colors",description:"Using semantic colors for different data types",metrics:[{title:"Success Rate",value:"94.2%",change:{value:2,type:"increase"},info:"Using semantic success color"},{title:"Error Rate",value:"5.8%",change:{value:1,type:"decrease"},info:"Using semantic error color"}],view:{type:"chart",chart:{type:"line",title:"Semantic Color Usage",data:Rs,lines:[{dataKey:"users",color:Si(Yt,"success"),label:"Successful Operations",strokeWidth:3},{dataKey:"sessions",color:Si(Yt,"warning"),label:"Warning Events",strokeWidth:2},{dataKey:"messages",color:Si(Yt,"error"),label:"Error Events",strokeWidth:2},{dataKey:"totalTokens",color:Si(Yt,"info"),label:"Info Events",strokeWidth:2}],dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:12,order:3}},{id:"single-custom",title:"Single Line Custom Color",description:"Single line chart with custom color and styling",metrics:[{title:"Total Messages",value:34563,change:{value:5,type:"increase"},info:"Custom styled single line"}],view:{type:"chart",chart:{type:"line",title:"Custom Single Line",data:Rs,dataKey:"messages",color:"#ec4899",dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:250,showGrid:!0,curve:"monotone"}},layout:{span:12,order:4}}]},qU={manualColors:{line1:"#8b5cf6",line2:"#06b6d4",line3:"#f97316",line4:"#10b981"},paletteColors:Yt.primary,semanticColors:Yt.semantic,gradientColors:Yt.gradients},HU={baseUrl:window.location.protocol+"//"+window.location.hostname,dashboardType:"agenticDashboard",projectId:"aa-bdbfa4eb-c7c4-4350-be96-d778188c2c4b",environment:"draft",headers:{authorization:"Bearer 2amvsUbh87obVLVYjbNnXCbXnOr-plekM7-qjKt2EJIZnZuAV2KT9WSTG0L4U33X",accountId:"6290f982fb880154e99bbede","Content-Type":"application/json"},defaultTimeRange:{fromTimestamp:new Date(Date.now()-7*24*60*60*1e3).toISOString(),toTimestamp:new Date().toISOString()},refreshInterval:3e4},YU={id:"agentic-analytics-dashboard",title:"Dashboard",subtitle:"Monitor and review the usage of your agentic app",sections:[{id:"usage-analytics",title:"Sessions",metrics:[{title:"Users",value:0,metricType:"users",highlighted:!0},{title:"Sessions",value:0,metricType:"sessions",highlighted:!1},{title:"Messages",value:0,metricType:"messages",highlighted:!1},{title:"Tokens",value:0,metricType:"tokens",highlighted:!1}],view:{type:"chart",chart:{type:"line",title:"Usage Over Time",data:[],lines:[{dataKey:"count",color:"#3B82F6",label:"Count",strokeWidth:2}],xAxisLabel:"Date",yAxisLabel:"Count",tooltip:{show:!0,formatter:(e,t)=>[`${e}`,t]}}},layout:{span:12}},{id:"runs",title:"Runs",metrics:[{title:"Agent Runs",value:0,metricType:"agentRuns",highlighted:!0},{title:"Tool Runs",value:0,metricType:"toolRuns",highlighted:!1},{title:"Model Runs",value:0,metricType:"modelRuns",highlighted:!1}],view:{type:"chart",chart:{type:"line",title:"Execution Runs Over Time",data:[],lines:[{dataKey:"count",color:"#10B981",label:"Runs",strokeWidth:2}],xAxisLabel:"Date",yAxisLabel:"Count",tooltip:{show:!0,formatter:(e,t)=>[`${e}`,t]}}},layout:{span:12}}],globalControls:{draft:{label:"Environment",options:[{label:"Draft",value:"draft"},{label:"Production",value:"production"},{label:"Staging",value:"staging"}],defaultValue:"draft"},timeRange:{label:"Time Range",useDatePicker:!0,options:[{label:"Last 7 days",value:"7d"},{label:"Last 30 days",value:"30d"}],defaultValue:"7d"},export:{enabled:!1,formats:["csv","json"],onExport:e=>{console.log(`Exporting in ${e} format`)}}},layout:{columns:12,gap:24,responsive:!0}},XU=`
214
+ </svg>`},dW=(e,t)=>{const r=e.toLowerCase();if(r.includes("code"))return Rt.inlineTool;if(r.includes("workflow")||r.includes("library"))return Rt.toolLibrary;if(r.includes("knowledge"))return Rt.KNOWLEDGE;if(r.includes("mcp"))return Rt.MCP;if(Rt[e])return Rt[e];const n=t.toLowerCase();return n.includes("code")||n.includes("inline")||n.includes("calculate")?Rt.inlineTool:n.includes("library")||n.includes("workflow")?Rt.toolLibrary:n.includes("knowledge")||n.includes("document")||n.includes("fetch")?Rt.KNOWLEDGE:n.includes("mcp")||n.includes("protocol")?Rt.MCP:Rt.toolLibrary},of=({icon:e,iconSource:t="agent",size:r="small",className:n="",name:a="Unknown",toolType:i,provider:o,modelName:s})=>{const[l,u]=A.useState(!1),[c,f]=A.useState(!1),[d,h]=A.useState(!1),v=lW(e),y=fW[r];if(t==="model"){const S=yb(o),x=()=>{h(!0)};if(d){const T=o?o.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:`${y} rounded-full bg-gray-500 flex items-center justify-center ${n}`,children:g.jsx("span",{className:"text-white text-xs font-bold",children:T})})}return g.jsx("img",{src:S,alt:s||a,className:`${y} rounded ${n}`,onError:x})}if(v!=null&&v.name&&v.name!=="fallback"&&!l){const S=cW(v,t),x=()=>{u(!0)};return g.jsx("img",{src:S,alt:a,className:`${y} rounded-full object-cover ${n}`,onError:x})}if(l&&!c&&t==="agent"){const S=`${window.location.origin}/agenticai/assets/agent-avatars/agent1.svg`,x=()=>{f(!0)};return g.jsx("img",{src:S,alt:a,className:`${y} rounded-full object-cover ${n}`,onError:x})}if(t==="model"){const S=yb(o),x=()=>{h(!0)};if(d){const T=o?o.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:`${y} rounded-full bg-gray-500 flex items-center justify-center ${n}`,children:g.jsx("span",{className:"text-white text-xs font-bold",children:T})})}return g.jsx("img",{src:S,alt:s||a,className:`${y} rounded ${n}`,onError:x})}const p=v||uW(a,t);if(t==="workflowtool"){const S=i||p.type||"toolLibrary",x=dW(S,a);return g.jsx("div",{className:`${y} rounded-full flex items-center justify-center bg-gray-100 ${n}`,children:g.jsx("div",{dangerouslySetInnerHTML:{__html:x}})})}const b=`${window.location.origin}/agenticai/assets/agent-avatars/agent1.svg`;return g.jsx("img",{src:b,alt:a,className:`${y} rounded-full object-cover ${n}`})},mb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Name"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Response Time"}),g.jsx("div",{className:"text-right",children:"Tokens"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:o.icon,iconSource:"agent",size:"small",name:o.name||"Unknown Agent"})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||"Unknown Agent"})})]}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.runs?i(o.runs):"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.tokens?i(o.tokens):"-"})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})};function hW(e){const t=(e==null?void 0:e.toLowerCase())||"";return["inlinetool","inlineTool","code tool","code","tool","event","EVENT"].includes(e)||["inlinetool","inlineTool","code tool","code","tool","event"].includes(t)?"bg-orange-100 text-orange-800 border-orange-200":["toollibrary","toolLibrary","workflow tool"].includes(e)||["toollibrary","toollibrary","workflow tool"].includes(t)?"bg-blue-100 text-blue-800 border-blue-200":["mcp","MCP","mcpTool","mcpTool"].includes(e)||["mcp","mcptool"].includes(t)?"bg-green-100 text-green-800 border-green-200":["knowledge","KNOWLEDGE","knowledge tool"].includes(e)||["knowledge","knowledge tool"].includes(t)?"bg-purple-100 text-purple-800 border-purple-200":"bg-gray-100 text-gray-800 border-gray-200"}function pW(e){const t=(e==null?void 0:e.toLowerCase())||"";return["inlinetool","code tool","code","tool","event","inlineTool"].includes(t)?"Code Tool":["toollibrary","workflow tool"].includes(t)?"Workflow Tool":["mcp","mcptool"].includes(t)?"MCP Tool":["knowledge","knowledge tool","knowledge"].includes(t)||e==="KNOWLEDGE"?"Knowledge":e==="inlineTool"?"Code Tool":e==="toolLibrary"?"Workflow Tool":e==="KNOWLEDGE"?"Knowledge":e==="MCP"||e==="mcpTool"?"MCP Tool":"Code Tool"}const gb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Name"}),g.jsx("div",{className:"text-left",children:"Type"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Response Time"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:o.icon,iconSource:"workflowtool",size:"small",name:o.name||"Unknown Tool",toolType:o.toolType||o.type})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||"Unknown Tool"})})]}),g.jsx("div",{className:"flex items-center",children:g.jsx("span",{className:ue("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium border",hW(o.toolType||o.type||"Default")),children:pW(o.toolType||o.type||"Default")})}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.runs?i(o.runs):"-"}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||"-"})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})},vW=e=>{if(!e)return"/assets/icons/models/custom-api.svg";const t=e.toLowerCase(),r={openai:"Open AI.svg","open ai":"Open AI.svg",chatopenai:"Open AI.svg",gpt:"Open AI.svg",anthropic:"Anthropic.svg",claude:"Anthropic.svg",google:"Google.svg",gemini:"Google.svg",chatgooglegenerativeai:"Google.svg",googlegenerativeai:"Google.svg",palm:"Google.svg",azurechatopenai:"Azure Open AI.svg","azure open ai":"Azure Open AI.svg",azureopenai:"Azure Open AI.svg","azure openai":"Azure Open AI.svg",azure:"Azure Open AI.svg",aws:"AWS Bedrock.svg",bedrock:"AWS Bedrock.svg","aws bedrock":"AWS Bedrock.svg",awsbedrock:"AWS Bedrock.svg",amazon:"AWS Bedrock.svg",cohere:"Cohere.svg",api:"API.svg",custom:"custom-api.svg","custom-api":"custom-api.svg",customapi:"custom-api.svg"};if(r[t])return`assets/icons/models/${r[t]}`;for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return`assets/icons/models/${a}`;return"assets/icons/models/custom-api.svg"},yW=e=>{if(!e)return"";const t=e.toLowerCase(),r={openai:"OpenAI","open ai":"OpenAI",chatopenai:"OpenAI",gpt:"OpenAI",anthropic:"Anthropic",claude:"Anthropic",google:"Google",gemini:"Google Gemini",chatgooglegenerativeai:"Google Gemini",googlegenerativeai:"Google Gemini",palm:"Google PaLM",azurechatopenai:"Azure OpenAI","azure open ai":"Azure OpenAI",azureopenai:"Azure OpenAI","azure openai":"Azure OpenAI",azure:"Azure OpenAI",aws:"AWS Bedrock",bedrock:"AWS Bedrock","aws bedrock":"AWS Bedrock",awsbedrock:"AWS Bedrock",amazon:"AWS Bedrock",cohere:"Cohere",meta:"Meta",llama:"Meta LLaMA",mistral:"Mistral",huggingface:"Hugging Face",together:"Together AI",replicate:"Replicate"};if(r[t])return r[t];for(const[n,a]of Object.entries(r))if(t.includes(n)||n.includes(t))return a;return e.charAt(0).toUpperCase()+e.slice(1)},mW=({provider:e})=>{const[t,r]=A.useState(!1),n=vW(e),a=()=>{r(!0)};if(t){const i=e?e.charAt(0).toUpperCase():"🤖";return g.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-500 flex items-center justify-center",children:g.jsx("span",{className:"text-white text-xs font-bold",children:i})})}return g.jsx("img",{src:n,alt:e||"Model",className:"w-6 h-6 rounded",onError:a})},bb=({data:e,className:t})=>{const[r,n]=A.useState(5),a=()=>{n(o=>Math.min(o+10,e.length))},i=o=>o>=1e3?`${Math.floor(o/1e3)}k`:o.toString();return g.jsxs("div",{className:ue("w-full",t),children:[g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-3 bg-gray-50 border-b border-gray-200 text-sm font-medium text-gray-700",children:[g.jsx("div",{className:"text-left",children:"Model Name"}),g.jsx("div",{className:"text-right",children:"Runs"}),g.jsx("div",{className:"text-right",children:"Tokens"}),g.jsx("div",{className:"text-right",children:"Response Time"})]}),g.jsx("div",{className:"divide-y divide-gray-100",children:e.slice(0,r).map((o,s)=>g.jsxs("div",{className:"grid grid-cols-4 gap-4 px-4 py-4 hover:bg-gray-50 transition-colors duration-150",children:[g.jsxs("div",{className:"flex items-center space-x-3",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(mW,{provider:o.provider})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"text-sm font-medium text-gray-900 truncate",children:o.name||o.modelName||"Unknown Model"}),o.provider&&g.jsx("div",{className:"text-xs text-gray-500 truncate",children:yW(o.provider)})]})]}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:i(o.runs||0)}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:i(o.tokens||o.totalTokens||0)}),g.jsx("div",{className:"text-right text-sm text-gray-900",children:o.responseTime||(o.avgResponseTime?`${o.avgResponseTime}ms`:"N/A")})]},o.id||s))}),r<e.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-150",children:"Load 10 more"})})]})},gW=e=>{switch(e){case"agentRuns":return{title:"Agent Runs",entityName:"Agents"};case"toolRuns":return{title:"Tool Runs",entityName:"Tools"};case"modelRuns":return{title:"Model Runs",entityName:"Models"};default:return{title:"Runs",entityName:"Items"}}},bW=e=>e>=1e3?`${Math.floor(e/1e3)}k`:e.toString(),xb=({isOpen:e,onClose:t,date:r,metricType:n,data:a,totalRuns:i,className:o})=>{var w;const s=gW(n),[l,u]=A.useState(10),[c,f]=A.useState("all"),[d,h]=A.useState(!1),v=[{label:`All ${s.entityName}`,value:"all"},...a.map(O=>({label:O.name,value:O.id}))],y=c==="all"?a:a.filter(O=>O.id===c),p=()=>{f("all"),h(!1),u(10),t()};A.useEffect(()=>{const O=j=>{j.key==="Escape"&&p()},P=j=>{d&&(j.target.closest(".filter-dropdown")||h(!1))};return e&&(document.addEventListener("keydown",O),document.addEventListener("mousedown",P),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",O),document.removeEventListener("mousedown",P),document.body.style.overflow="unset"}},[e,d,p]),A.useEffect(()=>{e&&(f("all"),h(!1),u(10))},[e]);const b=O=>new Date(O).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),S=()=>{u(O=>Math.min(O+10,y.length))},x=O=>{f(O),h(!1),u(10)};if(!e)return null;const T=y.slice(0,l),m=((w=v.find(O=>O.value===c))==null?void 0:w.label)||`All ${s.entityName}`;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300",onClick:p}),g.jsxs("div",{className:ue("fixed right-0 top-0 h-full w-[600px] bg-white shadow-[0px_20px_24px_-4px_rgba(16,24,40,0.08),0px_8px_8px_-4px_rgba(16,24,40,0.03)] z-50 transform transition-transform duration-300 ease-in-out",e?"translate-x-0":"translate-x-full",o),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-[#d0d5dd]",children:[g.jsx("h2",{className:"text-lg font-semibold text-[#101828]",children:s.title}),g.jsx("button",{onClick:p,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:g.jsx(s0,{className:"h-5 w-5 text-[#101828]"})})]}),g.jsxs("div",{className:"flex flex-col h-[calc(100%-64px)] p-6 gap-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"text-sm font-medium text-[#344054]",children:[s.title," (",b(r),")"]}),g.jsxs("div",{className:"w-[210px] relative filter-dropdown",children:[g.jsxs("button",{onClick:()=>h(!d),className:"w-full bg-white border border-[#d0d5dd] rounded-lg px-3.5 py-2.5 flex items-center justify-between text-sm text-[#101828] hover:bg-gray-50 transition-colors",children:[g.jsx("span",{children:m}),g.jsx(ua,{className:"h-4 w-4 text-[#101828]"})]}),d&&g.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white border border-[#d0d5dd] rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto",children:v.map(O=>g.jsx("button",{onClick:()=>x(O.value),className:ue("w-full px-3.5 py-2.5 text-left text-sm hover:bg-gray-50 transition-colors",c===O.value?"bg-blue-50 text-blue-700":"text-[#101828]"),children:O.label},O.value))})]})]}),g.jsxs("div",{className:"flex-1 overflow-hidden",children:[g.jsx("div",{className:"bg-[#f9fafb] border-b border-[#eaecf0] px-2 py-2",children:g.jsxs("div",{className:"grid grid-cols-4 gap-3 items-center",children:[g.jsx("div",{className:"col-span-2 px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Name"})}),g.jsx("div",{className:"flex justify-center px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Runs"})}),g.jsx("div",{className:"flex justify-center px-0 py-2",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:"Response Time"})})]})}),g.jsx("div",{className:"overflow-y-auto max-h-[calc(100%-40px)]",children:T.length===0?g.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[g.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:["No ",s.title.toLowerCase()," for this date"]}),g.jsxs("p",{className:"text-gray-600",children:["There were no ",s.title.toLowerCase()," recorded on ",b(r),"."]})]}):g.jsxs(g.Fragment,{children:[T.map((O,P)=>g.jsxs("div",{className:"grid grid-cols-4 gap-3 items-center px-2 py-3 border-b border-[#eaecf0] hover:bg-gray-50 transition-colors",children:[g.jsxs("div",{className:"col-span-2 flex items-center gap-2",children:[g.jsx("div",{className:"flex-shrink-0",children:g.jsx(of,{icon:O.icon,iconSource:n==="agentRuns"?"agent":n==="toolRuns"?"workflowtool":"model",size:"small",name:O.name,toolType:O.toolType||O.type,provider:O.provider,modelName:O.modelName})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"text-sm font-medium text-[#101828] truncate",children:O.name}),n==="modelRuns"&&O.provider&&g.jsx("div",{className:"text-xs text-[#475467] truncate",children:O.provider})]})]}),g.jsx("div",{className:"flex justify-center",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:bW(O.runs)})}),g.jsx("div",{className:"flex justify-center",children:g.jsx("div",{className:"text-xs font-medium text-[#475467]",children:O.responseTime})})]},O.id||P)),l<y.length&&g.jsx("div",{className:"flex justify-center py-6",children:g.jsx("button",{onClick:S,className:"bg-white border border-[#d0d5dd] rounded px-3 py-1 text-xs font-medium text-[#344054] hover:bg-gray-50 transition-colors",children:"Load 10 more"})})]})})]})]})]})]})};class wb{constructor(t=""){Bt(this,"API_PATH","/tracing/api/trpc/metrics.getMetrics");Bt(this,"baseUrl","");Bt(this,"endpoints",{});this.baseUrl=t,this.initializeEndpoints()}setBaseUrl(t){this.baseUrl=t,this.initializeEndpoints()}getEndpoint(t){return this.endpoints[t]||{endpoint:"",method:"GET"}}getBaseUrl(){return this.baseUrl}initializeEndpoints(){const t=`${this.baseUrl}${this.API_PATH}`;this.endpoints["usage-analytics.cards"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.sessions.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.messages.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.users.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["usage-analytics.tokens.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.cards"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.agent-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.model-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH},this.endpoints["runs.tool-runs.timeseries"]={endpoint:t,method:"GET",baseEndpoint:this.API_PATH}}getAvailableEndpoints(){return Object.keys(this.endpoints)}hasEndpoint(t){return t in this.endpoints}}class Ob{constructor(t){Bt(this,"endpointsService");Bt(this,"defaultHeaders");Bt(this,"timeout");this.endpointsService=new wb(t.baseUrl),this.defaultHeaders={"Content-Type":"application/json",...t.defaultHeaders},this.timeout=t.timeout||3e4}updateConfig(t){t.baseUrl&&this.endpointsService.setBaseUrl(t.baseUrl),t.defaultHeaders&&(this.defaultHeaders={...this.defaultHeaders,...t.defaultHeaders}),t.timeout&&(this.timeout=t.timeout)}async invoke(t,r,n,a){const i=this.endpointsService.getEndpoint(t);if(!i.endpoint)throw new Error(`Endpoint not found for service: ${t}`);const o=this.prepareRequest(i,r,n);try{const s=new AbortController,l=setTimeout(()=>s.abort(),(a==null?void 0:a.timeout)||this.timeout),u=await fetch(o.url,{method:o.method,headers:o.headers,body:o.body,signal:(a==null?void 0:a.signal)||s.signal});if(clearTimeout(l),!u.ok)throw new Error(`HTTP Error: ${u.status} ${u.statusText}`);return await u.json()}catch(s){throw s instanceof Error?s.name==="AbortError"?new Error("Request timeout"):s:new Error("Unknown error occurred during API call")}}prepareRequest(t,r,n){const a={...this.defaultHeaders,...n},i={};Object.entries(a).forEach(([l,u])=>{u!==void 0&&(i[l]=u)});let o=t.endpoint,s;if(t.method==="GET"&&r){const l=this.buildQueryParams(r);o+=`?${l}`}else r&&(s=JSON.stringify(r));return{url:o,method:t.method,headers:i,body:s}}buildQueryParams(t){const r={json:t},n=new URLSearchParams;return n.append("input",JSON.stringify(r)),n.append("rnd",Math.random().toString(36).substring(7)),n.toString()}getBaseUrl(){return this.endpointsService.getBaseUrl()}hasEndpoint(t){return this.endpointsService.hasEndpoint(t)}getAvailableEndpoints(){return this.endpointsService.getAvailableEndpoints()}}class Ht{constructor(t){Bt(this,"apiInvoker");Bt(this,"projectId");Bt(this,"environment");Bt(this,"defaultTimeRange");const r={baseUrl:t.baseUrl,defaultHeaders:t.headers,timeout:3e4};this.apiInvoker=new Ob(r),this.projectId=t.projectId,this.environment=t.environment,this.defaultTimeRange=t.defaultTimeRange}updateConfig(t){(t.baseUrl||t.headers)&&this.apiInvoker.updateConfig({baseUrl:t.baseUrl,defaultHeaders:t.headers}),t.projectId&&(this.projectId=t.projectId),t.environment&&(this.environment=t.environment),t.defaultTimeRange&&(this.defaultTimeRange=t.defaultTimeRange,console.log("🔄 API Service: Updated defaultTimeRange:",this.defaultTimeRange))}getDefaultTimeRange(){return this.defaultTimeRange||Ht.getDateRange(7)}async fetchEnvironments(){try{const r=`${this.apiInvoker.getBaseUrl()}/aaa/api/v1/apps/${this.projectId}/environments?rnd=${Math.random().toString(36).substring(2,8)}`;console.log("🌍 Fetching environments for project:",this.projectId),console.log("🔗 Environment API URL:",r);const n=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json",...this.apiInvoker.defaultHeaders}});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const a=await n.json();return console.log("✅ Environments fetched successfully:",a.map(i=>({name:i.envName,enabled:i.isEnabled,status:i.status}))),a}catch(t){throw console.error("❌ Error fetching environments:",t),t}}async fetchUsageAnalyticsCards(t,r,n,a=[]){const i=n||Ht.getTimeDimension(t,r);console.log("📊 Fetching usage analytics cards:",{dateRange:{fromTimestamp:t,toTimestamp:r},providedTimeDimension:n,resolvedTimeDimension:i});const o={projectId:this.projectId,type:"cards",category:"usage-analytics",envId:this.environment,fromTimestamp:t,toTimestamp:r,filter:a,includeTrends:!0,timeDimension:i};return(await this.apiInvoker.invoke("usage-analytics.cards",o)).result.data.json}async fetchRunsCards(t,r,n,a=[]){const i=n||Ht.getTimeDimension(t,r);console.log("📊 Fetching runs cards:",{dateRange:{fromTimestamp:t,toTimestamp:r},providedTimeDimension:n,resolvedTimeDimension:i});const o={projectId:this.projectId,type:"cards",category:"runs",envId:this.environment,fromTimestamp:t,toTimestamp:r,filter:a,includeTrends:!0,timeDimension:i};return(await this.apiInvoker.invoke("runs.cards",o)).result.data.json}async fetchTimeSeriesData(t,r,n,a,i,o=[]){const s=i||Ht.getTimeDimension(n,a);console.log("📊 Fetching time series data:",{metric:t,category:r,dateRange:{fromTimestamp:n,toTimestamp:a},providedTimeDimension:i,resolvedTimeDimension:s});const l=`${r}.${t}.timeseries`,u={projectId:this.projectId,type:"time-series",category:r,envId:this.environment,fromTimestamp:n,toTimestamp:a,filter:o,metric:t,timeDimension:s};return(await this.apiInvoker.invoke(l,u)).result.data.json}transformUsageAnalyticsCards(t){const r=t.data.trends;console.log("Transforming usage analytics cards with trends:",r);const n=a=>a>0?"increase":"decrease";return[{title:"Users",value:t.data.users,metricType:"users",icon:"users",info:"Number of unique users who interacted with the app",highlighted:!0,change:r!=null&&r.users?{value:Math.abs(r.users.changePercent),type:n(r.users.changePercent)}:void 0},{title:"Sessions",value:t.data.sessions,metricType:"sessions",icon:"activity",info:"Number of conversations initiated with the app",highlighted:!1,change:r!=null&&r.sessions?{value:Math.abs(r.sessions.changePercent),type:n(r.sessions.changePercent)}:void 0},{title:"Messages",value:t.data.messages.total,metricType:"messages",icon:"message-circle",info:"Total messages exchanged between users and the app",highlighted:!1,change:r!=null&&r.messages?{value:Math.abs(r.messages.changePercent.total),type:n(r.messages.changePercent.total)}:void 0},{title:"Tokens",value:t.data.tokens.total,metricType:"tokens",icon:"coins",info:"Total input and output tokens processed by the app for all interactions",highlighted:!1,change:r!=null&&r.tokens?{value:Math.abs(r.tokens.changePercent.total),type:n(r.tokens.changePercent.total)}:void 0}]}transformRunsCards(t){const r=t.data.trends;console.log("Transforming runs cards with trends:",r);const n=a=>a>0?"increase":"decrease";return[{title:"Agent Runs",value:t.data.agentRuns,metricType:"agentRuns",icon:"bot",info:"Number of times the AI agents were executed to handle user requests",highlighted:!0,change:r!=null&&r.agentRuns?{value:Math.abs(r.agentRuns.changePercent),type:n(r.agentRuns.changePercent)}:void 0},{title:"Tool Runs",value:t.data.toolRuns.total,metricType:"toolRuns",icon:"wrench",info:"Number of times various tools were triggered by the AI agents to complete tasks",highlighted:!1,change:r!=null&&r.toolRuns?{value:Math.abs(r.toolRuns.changePercent.total),type:n(r.toolRuns.changePercent.total)}:void 0},{title:"Model Runs",value:t.data.modelRuns,metricType:"modelRuns",icon:"cpu",info:"Number of times the AI agents called various language models to generate responses",highlighted:!1,change:r!=null&&r.modelRuns?{value:Math.abs(r.modelRuns.changePercent),type:n(r.modelRuns.changePercent)}:void 0}]}transformTimeSeriesDataForMetric(t,r){var a;if(console.log("=== METRIC-SPECIFIC TRANSFORM DEBUG ==="),console.log("Raw TimeSeriesResponse:",JSON.stringify(t,null,2)),console.log("Metric type:",r),!t||!t.data||!Array.isArray(t.data))return console.error("Invalid time series data structure:",t),[];const n=t.data.map((i,o)=>{console.log(`Processing point ${o}:`,i);const s=new Date(i.timestamp),l=s.toISOString().split("T")[0],u=s.toLocaleDateString("en-US",{month:"short",day:"numeric"}),c={date:l,timestamp:u,formattedDate:u,count:i.count||0,value:i.count||0,input_tokens:i.input_tokens||0,output_tokens:i.output_tokens||0,total_tokens:(i.input_tokens||0)+(i.output_tokens||0),inputTokens:i.input_tokens||0,outputTokens:i.output_tokens||0,totalTokens:(i.input_tokens||0)+(i.output_tokens||0),listView:i.listView||[],index:o};switch(r){case"users":c.users=i.count||0;break;case"sessions":c.sessions=i.count||0;break;case"messages":c.messages=i.count||0;break;case"tokens":c.tokens=i.count||0,i.input_tokens||i.output_tokens?c.totalTokens=(i.input_tokens||0)+(i.output_tokens||0):c.totalTokens=i.count||0;break;case"agentRuns":c.agentRuns=i.count||0;break;case"toolRuns":c.toolRuns=i.count||0;break;case"modelRuns":c.modelRuns=i.count||0;break;default:c.users=i.count||0,c.sessions=i.count||0,c.messages=i.count||0,c.tokens=i.count||0,c.agentRuns=i.count||0,c.toolRuns=i.count||0,c.modelRuns=i.count||0}return console.log(`Transformed point ${o} for metric ${r}:`,c),c});return console.log("Final transformed data array:",JSON.stringify(n,null,2)),console.log("Sample transformed point for chart:",n[0]),console.log("Populated metric property:",r,"=",(a=n[0])==null?void 0:a[r||"count"]),console.log("=== END METRIC-SPECIFIC TRANSFORM DEBUG ==="),n}transformTimeSeriesData(t){return this.transformTimeSeriesDataForMetric(t)}transformAgentsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>{var o,s;let a="",i=null;if(r.icon)try{if(i=typeof r.icon=="string"?JSON.parse(r.icon):r.icon,i.name){const l=((o=r.agentName)==null?void 0:o.replace(/\s+/g,""))||`agent${n}`,u=((s=i.color)==null?void 0:s.replace("#",""))||"b6e3f4";a=`https://api.dicebear.com/7.x/avataaars/svg?seed=${l}&backgroundColor=${u}&backgroundType=solid`}}catch{console.warn("Failed to parse icon data:",r.icon)}return{id:`agent-${n+1}`,name:r.agentName||`Agent ${n+1}`,runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",tokens:r.tokens||Math.floor((r.count||0)*150),successRate:r.successRate?`${Math.round(r.successRate)}%`:"95%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),avatar:a||`https://api.dicebear.com/7.x/avataaars/svg?seed=agent${n}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`,icon:r.icon||void 0}}):(console.warn("Invalid listView data for agents:",t),[])}transformToolsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>({id:`tool-${n+1}`,name:r.toolName||r.tool_name||`Tool ${n+1}`,type:r.type||r.toolType||r.tool_type||"Code Tool",runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",tokens:r.tokens||Math.floor((r.count||0)*50),successRate:r.successRate?`${Math.round(r.successRate)}%`:"92%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:r.icon||r.tool_icon||void 0})):(console.warn("Invalid listView data for tools:",t),[])}transformModelsListViewToTable(t){return Array.isArray(t)?t.map((r,n)=>({id:`model-${n+1}`,name:r.modelName||`Model ${n+1}`,modelName:r.modelName,provider:r.provider,runs:r.count||0,responseTime:r.avgResponseTime?r.avgResponseTime<1e3?`${Math.round(r.avgResponseTime)}ms`:`${(r.avgResponseTime/1e3).toFixed(2)}s`:"0ms",avgResponseTime:r.avgResponseTime,tokens:r.tokens||r.totalTokens||Math.floor((r.count||0)*300),totalTokens:r.totalTokens||r.tokens,successRate:r.successRate?`${Math.round(r.successRate)}%`:"98%",lastRun:r.lastRun||new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:r.icon})):(console.warn("Invalid listView data for models:",t),[])}extractAgentControlOptions(t){if(!Array.isArray(t))return[{label:"All Agents",value:"all"}];const r=[{label:"All Agents",value:"all"}];return t.forEach(n=>{var a;if(n.agentName){let i="";try{if(n.icon){const o=typeof n.icon=="string"?JSON.parse(n.icon):n.icon;if(o.name){const s=n.agentName.replace(/\s+/g,""),l=((a=o.color)==null?void 0:a.replace("#",""))||"b6e3f4";i=`https://api.dicebear.com/7.x/avataaars/svg?seed=${s}&backgroundColor=${l}&backgroundType=solid`}}}catch{console.warn("Failed to parse icon data for control:",n.icon)}r.push({label:n.agentName,value:n.agentName.replace(/\s+/g,"").toLowerCase(),avatar:i||`https://api.dicebear.com/7.x/avataaars/svg?seed=${n.agentName.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`})}}),r}extractToolControlOptions(t){if(!Array.isArray(t))return[{label:"All Tools",value:"all"}];const r=[{label:"All Tools",value:"all"}];return t.forEach(n=>{const a=n.toolName||n.tool_name;if(a){let i=function(o){if(!o)return"Code Tool";const s=o.toLowerCase();return["inlinetool","code tool","code","event"].includes(s)?"Code Tool":["toollibrary","workflow tool"].includes(s)?"Workflow Tool":["mcp","mcptool"].includes(s)?"MCP Tool":["knowledge","knowledge tool"].includes(s)||o==="KNOWLEDGE"?"Knowledge":o==="inlineTool"?"Code Tool":o==="toolLibrary"?"Workflow Tool":o==="MCP"||o==="mcpTool"?"MCP Tool":"Code Tool"};r.push({label:a,value:a.replace(/[-]/g,""),icon:n.icon||n.tool_icon||void 0,type:n.type||i(n.toolType||n.tool_type)})}}),r}extractModelControlOptions(t){if(!Array.isArray(t))return[{label:"All Models",value:"all"}];const r=[{label:"All Models",value:"all"}];return t.forEach(n=>{n.modelName&&r.push({label:n.modelName,value:n.modelName.replace(/[-\.]/g,""),icon:n.icon,type:n.provider})}),r}async fetchTimeSeriesDataWithTableData(t,r,n,a,i,o=[]){const s=await this.fetchTimeSeriesData(t,r,n,a,i,o);let l=[];s.data.forEach(d=>{d.listView&&Array.isArray(d.listView)&&(l=[...l,...d.listView])});const u=this.aggregateListViewItems(l);let c=[],f=[];return t==="agent-runs"?(c=this.transformAgentsListViewToTable(u),f=this.extractAgentControlOptions(u)):t==="tool-runs"?(c=this.transformToolsListViewToTable(u),f=this.extractToolControlOptions(u)):t==="model-runs"&&(c=this.transformModelsListViewToTable(u),f=this.extractModelControlOptions(u)),{chartData:this.transformTimeSeriesDataForMetric(s,t.replace("-","")),tableData:c,controlOptions:f}}aggregateListViewItems(t){const r=new Map;return t.forEach(n=>{const a=n.agentName||n.toolName||n.modelName||"unknown";if(r.has(a)){const i=r.get(a);i.count=(i.count||0)+(n.count||0),i.avgResponseTime=i.avgResponseTime&&n.avgResponseTime?(i.avgResponseTime+n.avgResponseTime)/2:i.avgResponseTime||n.avgResponseTime,i.tokens=(i.tokens||0)+(n.tokens||0)}else r.set(a,{...n})}),Array.from(r.values())}async fetchEnhancedMetricsData(t,r,n,a=[]){try{const[i,o,s]=await Promise.all([this.fetchTimeSeriesDataWithTableData("agent-runs","runs",t,r,n,a),this.fetchTimeSeriesDataWithTableData("tool-runs","runs",t,r,n,a),this.fetchTimeSeriesDataWithTableData("model-runs","runs",t,r,n,a)]);return{agents:i,tools:o,models:s}}catch(i){throw console.error("Error fetching enhanced metrics data:",i),i}}async transformRunsCardsWithEnhancedData(t,r,n,a,i=[]){const o=t.data.trends,s=h=>h>0?"increase":"decrease",[l,u,c,f]=await Promise.all([this.fetchTimeSeriesDataWithTableData("agent-runs","runs",r,n,a,i),this.fetchTimeSeriesDataWithTableData("tool-runs","runs",r,n,a,i),this.fetchTimeSeriesDataWithTableData("model-runs","runs",r,n,a,i),this.fetchTimeSeriesData("tool-runs","runs",r,n,a,i)]),d=this.transformTimeSeriesDataForToolRuns(f);return[{title:"Agent Runs",value:t.data.agentRuns,metricType:"agentRuns",icon:"bot",highlighted:!0,info:"Number of times the AI agents were executed to handle user requests",change:o!=null&&o.agentRuns?{value:Math.abs(o.agentRuns.changePercent),type:s(o.agentRuns.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Agent Runs",data:l.chartData,dataKey:"agentRuns",color:"#0BA5EC",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Agent Runs",data:l.tableData,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"},{key:"tokens",title:"Tokens",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`}]}},controls:{dropdown:{label:"All Agents",options:l.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Tool Runs",value:t.data.toolRuns.total,metricType:"toolRuns",icon:"wrench",info:"Number of times various tools were triggered by the AI agents to complete tasks",highlighted:!1,change:o!=null&&o.toolRuns?{value:Math.abs(o.toolRuns.changePercent.total),type:s(o.toolRuns.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Tool Runs",data:d,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#667085",label:"Tool Runs"},{dataKey:"codeTools",color:"#F38744",label:"Code Tools"},{dataKey:"workflowTools",color:"#2970FF",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#7A5AF8",label:"Knowledge"},{dataKey:"mcpTools",color:"#47CD89",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Tool Runs",data:u.tableData,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"type",title:"Type",width:150,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Tools",options:u.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Model Runs",value:t.data.modelRuns,metricType:"modelRuns",icon:"cpu",highlighted:!1,info:"Number of times the AI agents called various language models to generate responses",change:o!=null&&o.modelRuns?{value:Math.abs(o.modelRuns.changePercent),type:s(o.modelRuns.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Model Runs",data:c.chartData,dataKey:"modelRuns",color:"#47CD89",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}},table:{title:"Model Runs",data:c.tableData,columns:[{key:"name",title:"Model Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"tokens",title:"Tokens",width:120,align:"right",formatter:h=>`${Math.floor(h/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Models",options:c.controlOptions,defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}}]}async transformUsageAnalyticsCardsWithEnhancedData(t,r,n,a,i=[]){const o=t.data.trends,s=d=>d>0?"increase":"decrease",[l,u,c,f]=await Promise.all([this.fetchTimeSeriesData("users","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("sessions","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("messages","usage-analytics",r,n,a,i),this.fetchTimeSeriesData("tokens","usage-analytics",r,n,a,i)]);return[{title:"Users",value:t.data.users,metricType:"users",icon:"users",highlighted:!0,info:"Number of unique users who interacted with the app",change:o!=null&&o.users?{value:Math.abs(o.users.changePercent),type:s(o.users.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Users",data:this.transformTimeSeriesDataForMetric(l,"users"),dataKey:"users",color:"#4E5BA6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Sessions",value:t.data.sessions,metricType:"sessions",icon:"activity",highlighted:!1,info:"Number of conversations initiated with the app",change:o!=null&&o.sessions?{value:Math.abs(o.sessions.changePercent),type:s(o.sessions.changePercent)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Sessions",data:this.transformTimeSeriesDataForMetric(u,"sessions"),dataKey:"sessions",color:"#0BA5EC",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Messages",value:t.data.messages.total,metricType:"messages",icon:"message-circle",info:"Total messages exchanged between users and the app",highlighted:!1,change:o!=null&&o.messages?{value:Math.abs(o.messages.changePercent.total),type:s(o.messages.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Total Messages",data:this.transformTimeSeriesDataForMetric(c,"messages"),dataKey:"messages",color:"#E478FA",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}},{title:"Tokens",value:t.data.tokens.total,metricType:"tokens",icon:"coins",info:"Total input and output tokens processed by the app for all interactions",highlighted:!1,change:o!=null&&o.tokens?{value:Math.abs(o.tokens.changePercent.total),type:s(o.tokens.changePercent.total)}:void 0,view:{type:"chart",chart:{type:"line",title:"Token Usage Breakdown",data:this.transformTimeSeriesDataForMetric(f,"tokens"),yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#FF692E",label:"Total Tokens"},{dataKey:"inputTokens",color:"#5925DC",label:"Input Tokens"},{dataKey:"outputTokens",color:"#E478FA",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:r.split("T")[0],end:n.split("T")[0]}}}}]}transformTimeSeriesDataForToolRuns(t){if(console.log("=== TOOL RUNS SPECIFIC TRANSFORM DEBUG ==="),console.log("Raw TimeSeriesResponse for tool runs:",JSON.stringify(t,null,2)),!t||!t.data||!Array.isArray(t.data))return console.error("Invalid time series data structure:",t),[];const r=t.data.map((n,a)=>{console.log(`Processing point ${a}:`,n);const i=new Date(n.timestamp),o=i.toISOString().split("T")[0],s=i.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=n.count||0;let u=0,c=0,f=0,d=0;if(n.listView&&Array.isArray(n.listView)){n.listView.forEach(y=>{const p=y.count||0,b=(y.toolType||y.tool_type||"").toLowerCase(),S=(y.toolName||y.tool_name||"").toLowerCase();console.log("Processing listView item:",{toolType:b,toolName:S,count:p});const x=b.toLowerCase();["inlinetool","inlineTool","tool","code","codetool","event","EVENT"].includes(b)||["inlinetool","tool","code","codetool","event"].includes(x)?u+=p:["toollibrary","toolLibrary","workflow","workflowtool"].includes(b)||["toollibrary","workflow","workflowtool"].includes(x)?c+=p:["knowledge","KNOWLEDGE","knowledgetool"].includes(b)||["knowledge","knowledgetool"].includes(x)?f+=p:["mcp","MCP","mcptool","mcpTool"].includes(b)||["mcp","mcptool"].includes(x)?d+=p:(console.log(`Unknown tool type '${b}' for tool '${S}', defaulting to code tools`),u+=p)}),console.log(`Calculated breakdown for point ${a}:`,{codeTools:u,workflowTools:c,knowledgeTools:f,mcpTools:d,total:u+c+f+d,expectedTotal:l});const v=u+c+f+d;if(Math.abs(v-l)>1){console.warn(`Breakdown total (${v}) doesn't match expected total (${l}) for point ${a}`);const y=l-v;u+=y,console.log(`Adjusted codeTools by ${y} to balance total`)}}else console.log(`No listView data for point ${a}, assigning all ${l} to codeTools`),u=l;const h={date:o,timestamp:s,formattedDate:s,toolRuns:l,value:l,count:l,codeTools:u,workflowTools:c,knowledgeTools:f,mcpTools:d,input_tokens:n.input_tokens||0,output_tokens:n.output_tokens||0,total_tokens:(n.input_tokens||0)+(n.output_tokens||0),inputTokens:n.input_tokens||0,outputTokens:n.output_tokens||0,totalTokens:(n.input_tokens||0)+(n.output_tokens||0),listView:n.listView||[],index:a};return console.log(`Transformed tool runs point ${a}:`,h),h});return console.log("Final tool runs transformed data:",JSON.stringify(r,null,2)),console.log("=== END TOOL RUNS SPECIFIC TRANSFORM DEBUG ==="),r}async fetchAllCardsData(t,r,n=[]){try{const[a,i]=await Promise.all([this.fetchUsageAnalyticsCards(t,r,void 0,n),this.fetchRunsCards(t,r,void 0,n)]);return{usageAnalytics:this.transformUsageAnalyticsCards(a),runs:this.transformRunsCards(i)}}catch(a){throw console.error("Error fetching cards data:",a),a}}async fetchAllCardsDataWithEnhancedViews(t,r,n,a=[]){try{const[i,o]=await Promise.all([this.fetchUsageAnalyticsCards(t,r,n,a),this.fetchRunsCards(t,r,n,a)]),[s,l]=await Promise.all([this.transformUsageAnalyticsCardsWithEnhancedData(i,t,r,n,a),this.transformRunsCardsWithEnhancedData(o,t,r,n,a)]);return{usageAnalytics:s,runs:l}}catch(i){throw console.error("Error fetching enhanced cards data:",i),i}}async fetchDefaultTimeSeriesData(t,r,n,a=[]){try{const[i,o]=await Promise.all([this.fetchTimeSeriesData("sessions","usage-analytics",t,r,n,a),this.fetchTimeSeriesData("agent-runs","runs",t,r,n,a)]);return{sessions:this.transformTimeSeriesData(i),agentRuns:this.transformTimeSeriesData(o)}}catch(i){throw console.error("Error fetching default time series data:",i),i}}transformListViewForSlider(t,r){return Array.isArray(t)?t.map((n,a)=>{const i={id:`${r}-${a+1}`,runs:n.count||0,responseTime:n.avgResponseTime?n.avgResponseTime<1e3?`${Math.round(n.avgResponseTime)}ms`:`${(n.avgResponseTime/1e3).toFixed(2)}s`:"0ms",successRate:n.successRate?`${Math.round(n.successRate)}%`:void 0,tokens:n.totalTokens||n.tokens||0,icon:n.icon||n.tool_icon||void 0,aiModel:"gpt-4o"};switch(r){case"agentRuns":return{...i,name:n.agentName||`Agent ${a+1}`,type:"Agent",aiModel:this.extractAIModel(n)||"gpt-4o"};case"toolRuns":return{...i,name:n.toolName||n.tool_name||`Tool ${a+1}`,type:n.type||n.toolType||n.tool_type||"Code Tool",toolType:n.toolType||n.tool_type,aiModel:this.extractAIModel(n)||"gpt-4o"};case"modelRuns":return{...i,name:n.modelName||`Model ${a+1}`,modelName:n.modelName,provider:n.provider,type:n.provider||"Model",aiModel:n.modelName||n.model||"gpt-4o"};default:return{...i,name:`Item ${a+1}`,type:"Unknown",aiModel:"gpt-4o"}}}):(console.warn("Invalid listView data for slider:",t),[])}extractAIModel(t){if(t.modelName)return t.modelName;if(t.model)return t.model;if(t.llmModel)return t.llmModel;if(t.aiModel)return t.aiModel;const r=["gpt-4o","gpt-4o-mini","claude-3-5-haiku"];return r[Math.floor(Math.random()*r.length)]}static getDateRange(t=7){const r=new Date,n=new Date;return n.setDate(r.getDate()-t),{fromTimestamp:n.toISOString(),toTimestamp:r.toISOString()}}static getTimeDimension(t,r){const n=new Date(t),a=new Date(r),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=new Date(a.getFullYear(),a.getMonth(),a.getDate()),s=o.getTime()-i.getTime(),l=s/(1e3*60*60*24),u=i.toISOString().split("T")[0],c=o.toISOString().split("T")[0],f=u===c,d=new Date(n.getFullYear(),n.getMonth(),n.getDate()),h=f&&Math.abs(n.getTime()-d.getTime())<1e3,v=Math.abs(a.getTime()-n.getTime()),y=v<60*1e3;return console.log("🕐 TimeDimension calculation:",{fromTimestamp:t,toTimestamp:r,fromDateStr:u,toDateStr:c,diffInMs:s,diffInDays:l,isSameCalendarDay:f,isTodayPattern:h,timeDiffInMs:v,isVeryClose:y,fromStartOfDay:d.toISOString(),recommended:f||h||y||l<=1?"hour":l<=31?"day":l<=90?"week":"month"}),f||h||y||l<=1?"hour":"day"}getAvailableMetrics(){return{"usage-analytics":["sessions","messages","users","tokens"],runs:["agent-runs","model-runs","tool-runs"]}}}const Sb=({config:e,className:t,isLoading:r,context:n})=>{const{type:a,chart:i,table:o,layout:s="vertical"}=e,[l,u]=A.useState({isOpen:!1,date:"",metricType:"agentRuns",data:[],totalRuns:0}),c=(y,p)=>{console.log("Chart data point clicked in ViewRenderer:",{chartData:y,date:p,context:n});const b=n==null?void 0:n.metricType;if(!b||!["agentRuns","toolRuns","modelRuns"].includes(b)){console.log("Slider not applicable for metric type:",b);return}const S=y.listView||[];console.log("ListView data for clicked date:",S);const T=new Ht({baseUrl:"",projectId:"",environment:""}).transformListViewForSlider(S,b),m=y[b]||y.count||0;console.log("Opening slider with data:",{date:p,metricType:b,sliderData:T,totalRuns:m}),u({isOpen:!0,date:p,metricType:b,data:T,totalRuns:m})},f=()=>{u(y=>({...y,isOpen:!1}))},d=()=>i?(console.log("ViewRenderer - Chart config:",i),console.log("ViewRenderer - Chart data:",i.data),console.log("ViewRenderer - Context:",n),g.jsx("div",{className:"flex-1",children:g.jsx(pb,{config:i,isLoading:r,onDataPointClick:c})})):null,h=()=>o?(n==null?void 0:n.metricType)==="agentRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(mb,{data:o.data})}):(n==null?void 0:n.metricType)==="toolRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(gb,{data:o.data})}):(n==null?void 0:n.metricType)==="modelRuns"?g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(bb,{data:o.data})}):g.jsx("div",{className:"flex-1 min-h-[380px]",children:g.jsx(vb,{config:o})}):null,v=()=>{switch(a){case"chart":return d();case"table":return h();case"mixed":return g.jsxs("div",{className:ue("flex gap-6",s==="horizontal"?"flex-row":"flex-col"),children:[d(),h()]});default:return g.jsxs("div",{className:"p-4 text-center text-gray-500",children:["Unsupported view type: ",a]})}};return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:ue("w-full",t),children:v()}),g.jsx(xb,{isOpen:l.isOpen,onClose:f,date:l.date,metricType:l.metricType,data:l.data,totalRuns:l.totalRuns})]})},js=({options:e,value:t,placeholder:r="Select an option",onChange:n,className:a,disabled:i=!1})=>{const[o,s]=A.useState(!1),[l,u]=A.useState(t||""),c=A.useRef(null),f=e.find(v=>v.value===l);A.useEffect(()=>{const v=y=>{c.current&&!c.current.contains(y.target)&&s(!1)};return o&&document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[o]);const d=v=>{i||(u(v),s(!1),n==null||n(v))},h=()=>{i||s(!o)};return g.jsxs("div",{ref:c,className:ue("relative min-w-[200px]",a),children:[g.jsxs("button",{type:"button",className:ue("flex h-10 w-full min-w-[200px] items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",a),onClick:h,disabled:i,children:[g.jsx("span",{className:ue("truncate",!f&&"text-gray-500"),children:f?f.label:r}),g.jsx(ua,{className:ue("h-4 w-4 text-gray-400 transition-transform duration-200",o&&"rotate-180")})]}),o&&!i&&g.jsx("div",{className:"absolute top-full left-0 z-50 mt-1 min-w-[300px] w-max max-w-lg rounded-md border border-gray-200 bg-white shadow-lg max-h-60 overflow-y-auto",children:e.map(v=>{const y=l===v.value;return g.jsxs("div",{className:"relative group",children:[g.jsx("button",{className:ue("relative flex w-full cursor-pointer select-none items-center px-3 py-2 text-sm text-left outline-none transition-colors",v.disabled?"opacity-50 cursor-not-allowed text-gray-400":y?"bg-blue-50 text-blue-900 font-medium":"text-gray-900 hover:bg-gray-100"),onClick:()=>!v.disabled&&d(v.value),disabled:v.disabled,children:g.jsx("span",{className:"block whitespace-nowrap",children:v.label})}),v.label.length>25&&g.jsx("div",{className:"absolute left-full top-0 ml-2 z-[60] opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",children:g.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-md px-3 py-2 whitespace-nowrap shadow-lg",children:[v.label,g.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-x-full -translate-y-1/2 w-0 h-0 border-t-4 border-b-4 border-r-4 border-transparent border-r-gray-900"})]})})]},v.value)})})]})},xW=({options:e,value:t,defaultValue:r,placeholder:n="Select...",multiSelect:a=!1,searchable:i=!1,onChange:o,className:s,maxItems:l=100,maxLabelLength:u=30})=>{const[c,f]=A.useState(!1),[d,h]=A.useState(""),[v,y]=A.useState(()=>{const M=t||r;return a?Array.isArray(M)?M:M?[M]:[]:M?[Array.isArray(M)?M[0]:M]:[]}),p=A.useRef(null);A.useEffect(()=>{const M=_=>{p.current&&!p.current.contains(_.target)&&f(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const b=(M,_=u)=>M.length<=_?M:M.substring(0,_)+"...",S=i?e.filter(M=>M.label.toLowerCase().includes(d.toLowerCase())):e,x=S.slice(0,l),T=S.length>l,m=M=>{let _;if(a){if(M==="all"){O();return}if(v.includes(M))_=v.filter(R=>R!==M),_=_.filter(R=>R!=="all");else{_=v.filter(D=>D!=="all"),_=[..._,M];const R=S.filter(D=>D.value!=="all").map(D=>D.value),k=_.filter(D=>D!=="all");k.length===R.length&&(_=["all",...k])}}else _=[M],f(!1);y(_);const $=a?_:_[0]||"";o==null||o($)},w=()=>{if(!a)return{checked:!1,indeterminate:!1};const M=S.filter($=>$.value!=="all").map($=>$.value),_=v.filter($=>$!=="all"&&M.includes($));return v.includes("all")&&_.length===0?{checked:!1,indeterminate:!1}:_.length===0?{checked:!1,indeterminate:!1}:_.length===M.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},O=()=>{if(!a)return;const M=w(),_=S.filter($=>$.value!=="all").map($=>$.value);if(M.checked)y(["all"]),o==null||o(["all"]);else{const $=["all",..._];y($),o==null||o($)}},P=()=>{y(["all"]),o==null||o(a?["all"]:"all")},j=()=>{if(!a){if(v.length===0)return n;const R=e.find(k=>k.value===v[0]);return(R==null?void 0:R.label)||n}const M=v.filter(R=>R!=="all"),_=v.includes("all");if(M.length===0)return n;if(M.length===1){const R=e.find(k=>k.value===M[0]);return(R==null?void 0:R.label)||n}const $=e.filter(R=>R.value!=="all").length;return M.length===$?"All selected":`${M.length} selected`};return g.jsxs("div",{className:ue("relative",s),ref:p,children:[g.jsxs("button",{type:"button",onClick:()=>f(!c),className:ue("w-full flex items-center justify-between px-3 py-2 text-left text-sm","border border-gray-300 rounded-md bg-white hover:bg-gray-50","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","transition-colors duration-150"),children:[g.jsx("span",{className:ue("truncate",v.length===0&&"text-gray-500"),children:j()}),g.jsx(ua,{className:ue("w-4 h-4 text-gray-400 transition-transform duration-150",c&&"transform rotate-180")})]}),c&&g.jsxs("div",{className:"absolute z-50 min-w-[300px] w-max max-w-lg mt-1 bg-white border border-gray-200 rounded-md shadow-lg max-h-80 overflow-hidden",children:[i&&g.jsx("div",{className:"p-3 border-b border-gray-100",children:g.jsxs("div",{className:"relative",children:[g.jsx(gf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),g.jsx("input",{type:"text",placeholder:`Search ${n.toLowerCase()}...`,value:d,onChange:M=>h(M.target.value),className:"w-full pl-10 pr-4 py-2 text-sm border border-gray-200 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})}),a&&g.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100 bg-gray-50",children:[g.jsxs("button",{type:"button",onClick:O,className:"flex items-center text-sm font-medium text-gray-700 hover:text-gray-900",children:[g.jsx("div",{className:ue("flex items-center justify-center w-4 h-4 mr-2 border rounded transition-colors duration-150",(()=>{const M=w();return M.indeterminate||M.checked?"bg-blue-600 border-blue-600 text-white":"border-gray-300 bg-white"})()),children:(()=>{const M=w();return M.indeterminate?g.jsx("div",{className:"w-2 h-0.5 bg-white rounded"}):M.checked?g.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:g.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):null})()}),"Select all"]}),g.jsx("button",{type:"button",onClick:P,className:"text-sm font-medium text-blue-600 hover:text-blue-800",children:"Clear"})]}),g.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[x.length===0?g.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No options found"}):x.map(M=>{let _;return M.value==="all"?null:(_=v.includes(M.value),g.jsxs("div",{className:"relative group",children:[g.jsxs("div",{onClick:()=>m(M.value),className:ue("flex items-center px-3 py-2 cursor-pointer hover:bg-gray-50","transition-colors duration-150",_&&"bg-blue-50"),children:[a?g.jsx("div",{className:ue("flex items-center justify-center w-4 h-4 mr-3 border rounded","transition-colors duration-150",_?"bg-blue-600 border-blue-600 text-white":"border-gray-300 bg-white"),children:_&&g.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:g.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}):g.jsx("div",{className:ue("w-4 h-4 mr-3 rounded-full border-2 transition-colors duration-150",_?"border-blue-600 bg-blue-600":"border-gray-300"),children:_&&g.jsx("div",{className:"w-full h-full rounded-full bg-white scale-50"})}),g.jsx("span",{className:ue("flex-1 text-sm whitespace-nowrap",_?"font-medium text-gray-900":"text-gray-700"),children:b(M.label)})]}),M.label.length>u&&g.jsx("div",{className:"absolute left-full top-1/2 transform -translate-y-1/2 ml-2 z-[80] opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",children:g.jsxs("div",{className:"bg-gray-900 text-white text-xs rounded-md px-3 py-2 shadow-lg max-w-xs break-words whitespace-normal",children:[M.label,g.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-x-full -translate-y-1/2 w-0 h-0 border-t-4 border-b-4 border-r-4 border-transparent border-r-gray-900"})]})})]},M.value))}),T&&g.jsxs("div",{className:"px-3 py-2 text-xs text-gray-500 bg-gray-50 border-t border-gray-100",children:[g.jsxs("div",{className:"text-center font-medium",children:["+",S.length-l," more items"]}),i&&g.jsx("div",{className:"text-center mt-1 text-gray-400",children:"Use search above to find specific items"})]})]})]})]})},Ab=({config:e,className:t})=>{var s;const{dropdown:r,buttons:n,toggle:a}=e,i=l=>{const u=l.toLowerCase();return u.includes("agent")?"agent":u.includes("tool")?"workflowtool":"app"},o=l=>{const u=l.toLowerCase();return u.includes("agent")?{maxItems:50,maxLabelLength:25}:u.includes("tool")?{maxItems:30,maxLabelLength:20}:{maxItems:40,maxLabelLength:25}};return g.jsxs("div",{className:ue("flex items-center gap-3",t),children:[r&&g.jsx(g.Fragment,{children:r.multiSelect?g.jsx(xW,{options:r.options,value:r.defaultValue,placeholder:r.label,multiSelect:r.multiSelect,searchable:r.searchable,onChange:r.onChange,className:"w-48",iconSource:i(r.label),maxItems:o(r.label).maxItems,maxLabelLength:o(r.label).maxLabelLength}):g.jsx(js,{options:r.options,value:Array.isArray(r.defaultValue)?r.defaultValue[0]:r.defaultValue||((s=r.options[0])==null?void 0:s.value),placeholder:r.label,onChange:l=>{var u;return(u=r.onChange)==null?void 0:u.call(r,l)},className:"w-48"})}),n&&n.length>0&&g.jsx("div",{className:"flex items-center border border-gray-200 rounded-lg overflow-hidden",children:n.map((l,u)=>g.jsxs("button",{onClick:()=>{var c;return(c=l.onClick)==null?void 0:c.call(l,l.value)},className:ue("px-3 py-2 text-sm font-medium transition-colors","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",l.active?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white",u>0&&"border-l border-gray-200"),children:[l.icon&&g.jsx("span",{className:"mr-2",children:l.icon}),l.label]},l.value))}),a&&g.jsxs("div",{className:"flex items-center border border-gray-200 rounded-lg overflow-hidden",children:[g.jsxs("button",{onClick:()=>{var l;return(l=a.onToggle)==null?void 0:l.call(a,"chart")},className:ue("px-3 py-2 text-sm font-medium transition-colors flex items-center gap-2","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",a.chartView?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white"),children:[g.jsx(Jb,{className:"w-4 h-4"}),"Chart"]}),g.jsxs("button",{onClick:()=>{var l;return(l=a.onToggle)==null?void 0:l.call(a,"table")},className:ue("px-3 py-2 text-sm font-medium transition-colors flex items-center gap-2","hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset","border-l border-gray-200",a.tableView?"bg-blue-50 text-blue-700 border-blue-200":"text-gray-700 bg-white"),children:[g.jsx(a0,{className:"w-4 h-4"}),"Table"]})]})]})},Tb=({section:e,className:t,isLoading:r,isChartLoading:n,onMetricClick:a})=>{var G;const{id:i,title:o,description:s,metrics:l,view:u,controls:c,layout:f}=e,[d,h]=A.useState(u.type),[v,y]=A.useState("chart"),p=()=>i==="usage-analytics"?"users":i==="runs"?"agentRuns":"users",[b,S]=A.useState(p()),[x,T]=A.useState("all"),m=E=>{var F,W,K,X,Q;const L=P();(F=L==null?void 0:L.controls)!=null&&F.toggle?(y(E),(K=(W=L.controls.toggle).onToggle)==null||K.call(W,E)):(h(E),(Q=(X=c==null?void 0:c.toggle)==null?void 0:X.onToggle)==null||Q.call(X,E))},w=E=>{var W,K;const L=E.metricType||E.title.toLowerCase();S(L);const F=l.find(X=>(X.metricType||X.title.toLowerCase())===L);(K=(W=F==null?void 0:F.controls)==null?void 0:W.dropdown)!=null&&K.multiSelect?T(["all"]):T("all"),a==null||a(E)},O=E=>{var F,W,K;T(E);const L=l.find(X=>(X.metricType||X.title.toLowerCase())===b);(K=(W=(F=L==null?void 0:L.controls)==null?void 0:F.dropdown)==null?void 0:W.onChange)==null||K.call(W,E)},P=()=>l.find(E=>(E.metricType||E.title.toLowerCase())===b)||null,j=E=>Array.isArray(E)?E.filter(F=>F!=="all").length>0:E!=="all",M=E=>Array.isArray(E)?E.filter(L=>L!=="all"):E!=="all"?[E]:[],_=E=>{var K,X,Q,ae,te,V,Y,J,I;const L=((X=(K=E.view)==null?void 0:K.chart)==null?void 0:X.data)||((Q=u.chart)==null?void 0:Q.data)||[];if(!j(x))return L;const F=E.metricType,W=M(x);if(W.length===1){const ie=W[0],q=P(),se=(V=(te=(ae=q==null?void 0:q.controls)==null?void 0:ae.dropdown)==null?void 0:te.options)==null?void 0:V.find(ve=>ve.value===ie),ee=se==null?void 0:se.label;return console.log("🔍 Filtering chart data:",{metricType:F,singleFilter:ie,selectedLabel:ee,baseDataSample:L[0]}),L.map(ve=>{let We=0;return ve.listView&&Array.isArray(ve.listView)&&(We=ve.listView.filter(Ge=>F==="agentRuns"&&Ge.agentName?Ge.agentName===ee||Ge.agentName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):F==="toolRuns"&&Ge.toolName?Ge.toolName===ee||Ge.toolName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):F==="modelRuns"&&Ge.modelName?Ge.modelName===ee||Ge.modelName.toLowerCase()===(ee==null?void 0:ee.toLowerCase()):!1).reduce((Ge,lt)=>Ge+(lt.count||0),0)),console.log("📊 Filtered value for",ee,":",We),{...ve,[F]:We}})}if(W.length>1){const ie=P(),se=(((I=(J=(Y=ie==null?void 0:ie.controls)==null?void 0:Y.dropdown)==null?void 0:J.options)==null?void 0:I.filter(ee=>W.includes(ee.value)))||[]).map(ee=>ee.label);return L.map(ee=>{let ve=0;return ee.listView&&Array.isArray(ee.listView)&&(ve=ee.listView.filter(Re=>F==="agentRuns"&&Re.agentName?se.some(Be=>Re.agentName===Be||Re.agentName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):F==="toolRuns"&&Re.toolName?se.some(Be=>Re.toolName===Be||Re.toolName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):F==="modelRuns"&&Re.modelName?se.some(Be=>Re.modelName===Be||Re.modelName.toLowerCase()===(Be==null?void 0:Be.toLowerCase())):!1).reduce((Re,Be)=>Re+(Be.count||0),0)),{...ee,[F]:ve}})}return L},$=E=>{var K;if(!((K=E.view)!=null&&K.chart))return null;const L=_(E),F=()=>{var Q,ae,te,V,Y,J;if(!j(x)||!((Q=E.controls)!=null&&Q.dropdown))return((te=(ae=E.view)==null?void 0:ae.chart)==null?void 0:te.title)||E.title;const X=M(x);if(X.length===1){const I=(V=E.controls.dropdown.options)==null?void 0:V.find(ie=>ie.value===X[0]);return I?`${I.label}`:((J=(Y=E.view)==null?void 0:Y.chart)==null?void 0:J.title)||E.title}return`${X.length} selected`},W=M(x);return E.metricType==="toolRuns"&&W.length===1?{...E.view.chart,data:L,title:F(),lines:void 0,dataKey:"toolRuns",color:"#f97316",showLegend:!1}:E.metricType==="modelRuns"&&W.length===1?{...E.view.chart,data:L,title:F(),dataKey:"modelRuns",color:"#10b981",showLegend:!1}:{...E.view.chart,data:L,title:F()}},R=(E,L)=>{if(!j(x))return E;const F=M(x);if(F.length===1){const W=F[0];if(i==="runs"&&L==="agentRuns")return E.map(K=>({...K,agentRuns:K[W]||0}));if(i==="runs"&&L==="toolRuns")return E.map(K=>({...K,toolRuns:K[W.replace(/[-]/g,"")]||0}));if(i==="runs"&&L==="modelRuns")return E.map(K=>({...K,modelRuns:K[W.replace(/[-\.]/g,"")]||0}))}return E},k=E=>{var K;const L=((K=u.chart)==null?void 0:K.data)||[],F=R(L,E),W=X=>{var ae,te;if(!j(x))return X;const Q=M(x);if(Q.length===1){const V=(te=(ae=c==null?void 0:c.dropdown)==null?void 0:ae.options)==null?void 0:te.find(Y=>Y.value===Q[0]);return V?`${V.label}`:X}return`${Q.length} selected`};switch(E){case"users":return{type:"line",title:"Total Users",data:L,dataKey:"users",color:"#8b5cf6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"sessions":return{type:"line",title:"Total Sessions",data:L,dataKey:"sessions",color:"#06b6d4",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"messages":return{type:"line",title:"Total Messages",data:L,dataKey:"messages",color:"#ec4899",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"tokens":return{type:"line",title:"Token Usage Breakdown",data:L,yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#f59e0b",label:"Total Tokens"},{dataKey:"inputTokens",color:"#3b82f6",label:"Input Tokens"},{dataKey:"outputTokens",color:"#ec4899",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"agentRuns":return{type:"line",title:W("Agent Runs"),data:F,dataKey:"agentRuns",color:"#06b6d4",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"toolRuns":return M(x).length===1?{type:"line",title:W("Tool Runs"),data:R(L,"toolRuns"),dataKey:"toolRuns",color:"#f97316",yAxisLabel:"Number of Tool Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}:{type:"line",title:"Tool Runs",data:F,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#06b6d4",label:"Tool Runs"},{dataKey:"codeTools",color:"#f97316",label:"Code Tools"},{dataKey:"workflowTools",color:"#10b981",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#8b5cf6",label:"Knowledge"},{dataKey:"mcpTools",color:"#ef4444",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};case"modelRuns":return M(x).length===1?{type:"line",title:W("Model Runs"),data:R(L,"modelRuns"),dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}:{type:"line",title:W("Model Runs"),data:F,dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}};default:return null}},D=(()=>{const E=P();return E!=null&&E.controls?{...E.controls,dropdown:E.controls.dropdown?{...E.controls.dropdown,onChange:O}:void 0,toggle:E.controls.toggle?{...E.controls.toggle,chartView:v==="chart",tableView:v==="table",onToggle:m}:void 0}:c?{...c,dropdown:c.dropdown?{...c.dropdown,onChange:O}:void 0,toggle:c.toggle?{...c.toggle,chartView:d==="chart",tableView:d==="table",onToggle:m}:void 0}:void 0})(),B=(()=>{var F,W,K,X,Q,ae,te,V,Y,J;const E=P();if(E!=null&&E.view){if((F=E.controls)!=null&&F.toggle){if(v==="table"&&E.view.table){let ie=E.view.table.data;if(E.metricType==="agentRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((X=(K=(W=E.controls)==null?void 0:W.dropdown)==null?void 0:K.options)==null?void 0:X.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}if(E.metricType==="toolRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((te=(ae=(Q=E.controls)==null?void 0:Q.dropdown)==null?void 0:ae.options)==null?void 0:te.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}if(E.metricType==="modelRuns"&&j(x)){const q=M(x);if(q.length>0){const se=((J=(Y=(V=E.controls)==null?void 0:V.dropdown)==null?void 0:Y.options)==null?void 0:J.filter(ee=>q.includes(ee.value)))||[];se.length>0&&(ie=ie.filter(ee=>se.some(ve=>ee.name===ve.label||ee.name&&ee.name.toLowerCase().includes(ve.label.toLowerCase()))))}}return{type:"table",table:{...E.view.table,data:ie}}}else if(v==="chart"&&E.view.chart)return{type:"chart",chart:$(E)||E.view.chart}}const I=$(E);return I?{...E.view,chart:I}:E.view}const L=k(b);return L?{type:"chart",chart:L}:{...u,type:d}})(),U=()=>l.map(E=>{const L=E.metricType||E.title.toLowerCase();return{...E,highlighted:E.highlighted||L===b}});return g.jsxs("div",{className:ue("bg-white rounded-lg border border-gray-200 p-6",t),style:{gridColumn:f!=null&&f.span?`span ${f.span}`:void 0,order:f==null?void 0:f.order},children:[o&&g.jsxs("div",{className:"mb-6",children:[g.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:o}),s&&g.jsx("p",{className:"text-sm text-gray-600 mt-1",children:s})]}),g.jsx("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:r?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})}),g.jsx("div",{className:"flex-1",children:g.jsx(gi,{})})]}):U().map((E,L)=>g.jsx("div",{className:"flex-1",children:g.jsx(_f,{data:E,onClick:w,isFirst:L===0})},`${i}-metric-${L}`))}),g.jsxs("div",{className:"flex items-center justify-between mb-6",children:[g.jsx("div",{children:P()&&g.jsx("h3",{className:"text-lg font-medium text-gray-900",children:(G=P())==null?void 0:G.title})}),D&&g.jsx(Ab,{config:D})]}),g.jsx(Sb,{config:B,isLoading:r||n,context:{sectionId:i,metricType:b}})]})},sf=A.forwardRef(({className:e,variant:t="default",size:r="md",children:n,...a},i)=>{const o="inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",s={default:"bg-primary text-primary-foreground hover:bg-primary/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground"},l={sm:"h-9 px-3",md:"h-10 px-4 py-2",lg:"h-11 px-8"};return g.jsx("button",{className:ue(o,s[t],l[r],e),ref:i,...a,children:n})});sf.displayName="Button";function $s(e){"@babel/helpers - typeof";return $s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$s(e)}function jt(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Me(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function ze(e){Me(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||$s(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function wW(e,t){Me(2,arguments);var r=ze(e),n=jt(t);return isNaN(n)?new Date(NaN):(n&&r.setDate(r.getDate()+n),r)}function lf(e,t){Me(2,arguments);var r=ze(e),n=jt(t);if(isNaN(n))return new Date(NaN);if(!n)return r;var a=r.getDate(),i=new Date(r.getTime());i.setMonth(r.getMonth()+n+1,0);var o=i.getDate();return a>=o?i:(r.setFullYear(i.getFullYear(),i.getMonth(),a),r)}function OW(e,t){Me(2,arguments);var r=ze(e).getTime(),n=jt(t);return new Date(r+n)}var SW={};function bi(){return SW}function AW(e,t){var r,n,a,i,o,s;Me(1,arguments);var l=bi(),u=jt((r=(n=(a=(i=void 0)!==null&&i!==void 0?i:void 0)!==null&&a!==void 0?a:l.weekStartsOn)!==null&&n!==void 0?n:(o=l.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&r!==void 0?r:0);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=ze(e),f=c.getDay(),d=(f<u?7:0)+f-u;return c.setDate(c.getDate()-d),c.setHours(0,0,0,0),c}function TW(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function ra(e){Me(1,arguments);var t=ze(e);return t.setHours(0,0,0,0),t}function xi(e,t){Me(2,arguments);var r=ra(e),n=ra(t);return r.getTime()===n.getTime()}function PW(e){return Me(1,arguments),e instanceof Date||$s(e)==="object"&&Object.prototype.toString.call(e)==="[object Date]"}function _W(e){if(Me(1,arguments),!PW(e)&&typeof e!="number")return!1;var t=ze(e);return!isNaN(Number(t))}function EW(e){Me(1,arguments);var t=ze(e);return t.setHours(23,59,59,999),t}function jW(e){Me(1,arguments);var t=ze(e);return t.setDate(1),t.setHours(0,0,0,0),t}function $W(e,t){Me(2,arguments);var r=jt(t);return OW(e,-r)}var CW=864e5;function kW(e){Me(1,arguments);var t=ze(e),r=t.getTime();t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);var n=t.getTime(),a=r-n;return Math.floor(a/CW)+1}function Cs(e){Me(1,arguments);var t=1,r=ze(e),n=r.getUTCDay(),a=(n<t?7:0)+n-t;return r.setUTCDate(r.getUTCDate()-a),r.setUTCHours(0,0,0,0),r}function Pb(e){Me(1,arguments);var t=ze(e),r=t.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(r+1,0,4),n.setUTCHours(0,0,0,0);var a=Cs(n),i=new Date(0);i.setUTCFullYear(r,0,4),i.setUTCHours(0,0,0,0);var o=Cs(i);return t.getTime()>=a.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function MW(e){Me(1,arguments);var t=Pb(e),r=new Date(0);r.setUTCFullYear(t,0,4),r.setUTCHours(0,0,0,0);var n=Cs(r);return n}var NW=6048e5;function DW(e){Me(1,arguments);var t=ze(e),r=Cs(t).getTime()-MW(t).getTime();return Math.round(r/NW)+1}function ks(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=bi(),f=jt((r=(n=(a=(i=t==null?void 0:t.weekStartsOn)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&a!==void 0?a:c.weekStartsOn)!==null&&n!==void 0?n:(l=c.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&r!==void 0?r:0);if(!(f>=0&&f<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var d=ze(e),h=d.getUTCDay(),v=(h<f?7:0)+h-f;return d.setUTCDate(d.getUTCDate()-v),d.setUTCHours(0,0,0,0),d}function _b(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=ze(e),f=c.getUTCFullYear(),d=bi(),h=jt((r=(n=(a=(i=t==null?void 0:t.firstWeekContainsDate)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&a!==void 0?a:d.firstWeekContainsDate)!==null&&n!==void 0?n:(l=d.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var v=new Date(0);v.setUTCFullYear(f+1,0,h),v.setUTCHours(0,0,0,0);var y=ks(v,t),p=new Date(0);p.setUTCFullYear(f,0,h),p.setUTCHours(0,0,0,0);var b=ks(p,t);return c.getTime()>=y.getTime()?f+1:c.getTime()>=b.getTime()?f:f-1}function IW(e,t){var r,n,a,i,o,s,l,u;Me(1,arguments);var c=bi(),f=jt((r=(n=(a=(i=t==null?void 0:t.firstWeekContainsDate)!==null&&i!==void 0?i:t==null||(o=t.locale)===null||o===void 0||(s=o.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&a!==void 0?a:c.firstWeekContainsDate)!==null&&n!==void 0?n:(l=c.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1),d=_b(e,t),h=new Date(0);h.setUTCFullYear(d,0,f),h.setUTCHours(0,0,0,0);var v=ks(h,t);return v}var LW=6048e5;function RW(e,t){Me(1,arguments);var r=ze(e),n=ks(r,t).getTime()-IW(r,t).getTime();return Math.round(n/LW)+1}function _e(e,t){for(var r=e<0?"-":"",n=Math.abs(e).toString();n.length<t;)n="0"+n;return r+n}var Pr={y:function(t,r){var n=t.getUTCFullYear(),a=n>0?n:1-n;return _e(r==="yy"?a%100:a,r.length)},M:function(t,r){var n=t.getUTCMonth();return r==="M"?String(n+1):_e(n+1,2)},d:function(t,r){return _e(t.getUTCDate(),r.length)},a:function(t,r){var n=t.getUTCHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h:function(t,r){return _e(t.getUTCHours()%12||12,r.length)},H:function(t,r){return _e(t.getUTCHours(),r.length)},m:function(t,r){return _e(t.getUTCMinutes(),r.length)},s:function(t,r){return _e(t.getUTCSeconds(),r.length)},S:function(t,r){var n=r.length,a=t.getUTCMilliseconds(),i=Math.floor(a*Math.pow(10,n-3));return _e(i,r.length)}},na={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},BW={G:function(t,r,n){var a=t.getUTCFullYear()>0?1:0;switch(r){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});case"GGGG":default:return n.era(a,{width:"wide"})}},y:function(t,r,n){if(r==="yo"){var a=t.getUTCFullYear(),i=a>0?a:1-a;return n.ordinalNumber(i,{unit:"year"})}return Pr.y(t,r)},Y:function(t,r,n,a){var i=_b(t,a),o=i>0?i:1-i;if(r==="YY"){var s=o%100;return _e(s,2)}return r==="Yo"?n.ordinalNumber(o,{unit:"year"}):_e(o,r.length)},R:function(t,r){var n=Pb(t);return _e(n,r.length)},u:function(t,r){var n=t.getUTCFullYear();return _e(n,r.length)},Q:function(t,r,n){var a=Math.ceil((t.getUTCMonth()+1)/3);switch(r){case"Q":return String(a);case"QQ":return _e(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(t,r,n){var a=Math.ceil((t.getUTCMonth()+1)/3);switch(r){case"q":return String(a);case"qq":return _e(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(t,r,n){var a=t.getUTCMonth();switch(r){case"M":case"MM":return Pr.M(t,r);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(t,r,n){var a=t.getUTCMonth();switch(r){case"L":return String(a+1);case"LL":return _e(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(t,r,n,a){var i=RW(t,a);return r==="wo"?n.ordinalNumber(i,{unit:"week"}):_e(i,r.length)},I:function(t,r,n){var a=DW(t);return r==="Io"?n.ordinalNumber(a,{unit:"week"}):_e(a,r.length)},d:function(t,r,n){return r==="do"?n.ordinalNumber(t.getUTCDate(),{unit:"date"}):Pr.d(t,r)},D:function(t,r,n){var a=kW(t);return r==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):_e(a,r.length)},E:function(t,r,n){var a=t.getUTCDay();switch(r){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});case"EEEE":default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(t,r,n,a){var i=t.getUTCDay(),o=(i-a.weekStartsOn+8)%7||7;switch(r){case"e":return String(o);case"ee":return _e(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,r,n,a){var i=t.getUTCDay(),o=(i-a.weekStartsOn+8)%7||7;switch(r){case"c":return String(o);case"cc":return _e(o,r.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,r,n){var a=t.getUTCDay(),i=a===0?7:a;switch(r){case"i":return String(i);case"ii":return _e(i,r.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});case"iiii":default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(t,r,n){var a=t.getUTCHours(),i=a/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,r,n){var a=t.getUTCHours(),i;switch(a===12?i=na.noon:a===0?i=na.midnight:i=a/12>=1?"pm":"am",r){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,r,n){var a=t.getUTCHours(),i;switch(a>=17?i=na.evening:a>=12?i=na.afternoon:a>=4?i=na.morning:i=na.night,r){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,r,n){if(r==="ho"){var a=t.getUTCHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return Pr.h(t,r)},H:function(t,r,n){return r==="Ho"?n.ordinalNumber(t.getUTCHours(),{unit:"hour"}):Pr.H(t,r)},K:function(t,r,n){var a=t.getUTCHours()%12;return r==="Ko"?n.ordinalNumber(a,{unit:"hour"}):_e(a,r.length)},k:function(t,r,n){var a=t.getUTCHours();return a===0&&(a=24),r==="ko"?n.ordinalNumber(a,{unit:"hour"}):_e(a,r.length)},m:function(t,r,n){return r==="mo"?n.ordinalNumber(t.getUTCMinutes(),{unit:"minute"}):Pr.m(t,r)},s:function(t,r,n){return r==="so"?n.ordinalNumber(t.getUTCSeconds(),{unit:"second"}):Pr.s(t,r)},S:function(t,r){return Pr.S(t,r)},X:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();if(o===0)return"Z";switch(r){case"X":return jb(o);case"XXXX":case"XX":return Yr(o);case"XXXXX":case"XXX":default:return Yr(o,":")}},x:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"x":return jb(o);case"xxxx":case"xx":return Yr(o);case"xxxxx":case"xxx":default:return Yr(o,":")}},O:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"O":case"OO":case"OOO":return"GMT"+Eb(o,":");case"OOOO":default:return"GMT"+Yr(o,":")}},z:function(t,r,n,a){var i=a._originalDate||t,o=i.getTimezoneOffset();switch(r){case"z":case"zz":case"zzz":return"GMT"+Eb(o,":");case"zzzz":default:return"GMT"+Yr(o,":")}},t:function(t,r,n,a){var i=a._originalDate||t,o=Math.floor(i.getTime()/1e3);return _e(o,r.length)},T:function(t,r,n,a){var i=a._originalDate||t,o=i.getTime();return _e(o,r.length)}};function Eb(e,t){var r=e>0?"-":"+",n=Math.abs(e),a=Math.floor(n/60),i=n%60;if(i===0)return r+String(a);var o=t;return r+String(a)+o+_e(i,2)}function jb(e,t){if(e%60===0){var r=e>0?"-":"+";return r+_e(Math.abs(e)/60,2)}return Yr(e,t)}function Yr(e,t){var r=t||"",n=e>0?"-":"+",a=Math.abs(e),i=_e(Math.floor(a/60),2),o=_e(a%60,2);return n+i+r+o}var $b=function(t,r){switch(t){case"P":return r.date({width:"short"});case"PP":return r.date({width:"medium"});case"PPP":return r.date({width:"long"});case"PPPP":default:return r.date({width:"full"})}},Cb=function(t,r){switch(t){case"p":return r.time({width:"short"});case"pp":return r.time({width:"medium"});case"ppp":return r.time({width:"long"});case"pppp":default:return r.time({width:"full"})}},FW=function(t,r){var n=t.match(/(P+)(p+)?/)||[],a=n[1],i=n[2];if(!i)return $b(t,r);var o;switch(a){case"P":o=r.dateTime({width:"short"});break;case"PP":o=r.dateTime({width:"medium"});break;case"PPP":o=r.dateTime({width:"long"});break;case"PPPP":default:o=r.dateTime({width:"full"});break}return o.replace("{{date}}",$b(a,r)).replace("{{time}}",Cb(i,r))},WW={p:Cb,P:FW},UW=["D","DD"],zW=["YY","YYYY"];function GW(e){return UW.indexOf(e)!==-1}function KW(e){return zW.indexOf(e)!==-1}function kb(e,t,r){if(e==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var VW={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},qW=function(t,r,n){var a,i=VW[t];return typeof i=="string"?a=i:r===1?a=i.one:a=i.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function uf(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=t.width?String(t.width):e.defaultWidth,n=e.formats[r]||e.formats[e.defaultWidth];return n}}var HW={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},YW={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},XW={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ZW={date:uf({formats:HW,defaultWidth:"full"}),time:uf({formats:YW,defaultWidth:"full"}),dateTime:uf({formats:XW,defaultWidth:"full"})},JW={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},QW=function(t,r,n,a){return JW[t]};function wi(e){return function(t,r){var n=r!=null&&r.context?String(r.context):"standalone",a;if(n==="formatting"&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,o=r!=null&&r.width?String(r.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{var s=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[s]}var u=e.argumentCallback?e.argumentCallback(t):t;return a[u]}}var eU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},tU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},rU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},nU={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},aU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},iU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},oU=function(t,r){var n=Number(t),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},sU={ordinalNumber:oU,era:wi({values:eU,defaultWidth:"wide"}),quarter:wi({values:tU,defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:wi({values:rU,defaultWidth:"wide"}),day:wi({values:nU,defaultWidth:"wide"}),dayPeriod:wi({values:aU,defaultWidth:"wide",formattingValues:iU,defaultFormattingWidth:"wide"})};function Oi(e){return function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;var o=i[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?uU(s,function(f){return f.test(o)}):lU(s,function(f){return f.test(o)}),u;u=e.valueCallback?e.valueCallback(l):l,u=r.valueCallback?r.valueCallback(u):u;var c=t.slice(o.length);return{value:u,rest:c}}}function lU(e,t){for(var r in e)if(e.hasOwnProperty(r)&&t(e[r]))return r}function uU(e,t){for(var r=0;r<e.length;r++)if(t(e[r]))return r}function cU(e){return function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.match(e.matchPattern);if(!n)return null;var a=n[0],i=t.match(e.parsePattern);if(!i)return null;var o=e.valueCallback?e.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;var s=t.slice(a.length);return{value:o,rest:s}}}var fU=/^(\d+)(th|st|nd|rd)?/i,dU=/\d+/i,hU={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},pU={any:[/^b/i,/^(a|c)/i]},vU={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},yU={any:[/1/i,/2/i,/3/i,/4/i]},mU={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},gU={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},bU={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},xU={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},wU={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},OU={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},SU={ordinalNumber:cU({matchPattern:fU,parsePattern:dU,valueCallback:function(t){return parseInt(t,10)}}),era:Oi({matchPatterns:hU,defaultMatchWidth:"wide",parsePatterns:pU,defaultParseWidth:"any"}),quarter:Oi({matchPatterns:vU,defaultMatchWidth:"wide",parsePatterns:yU,defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:Oi({matchPatterns:mU,defaultMatchWidth:"wide",parsePatterns:gU,defaultParseWidth:"any"}),day:Oi({matchPatterns:bU,defaultMatchWidth:"wide",parsePatterns:xU,defaultParseWidth:"any"}),dayPeriod:Oi({matchPatterns:wU,defaultMatchWidth:"any",parsePatterns:OU,defaultParseWidth:"any"})},AU={code:"en-US",formatDistance:qW,formatLong:ZW,formatRelative:QW,localize:sU,match:SU,options:{weekStartsOn:0,firstWeekContainsDate:1}},TU=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,PU=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_U=/^'([^]*?)'?$/,EU=/''/g,jU=/[a-zA-Z]/;function Ms(e,t,r){var n,a,i,o,s,l,u,c,f,d,h,v,y,p;Me(2,arguments);var b=String(t),S=bi(),x=(n=(a=void 0)!==null&&a!==void 0?a:S.locale)!==null&&n!==void 0?n:AU,T=jt((i=(o=(s=(l=void 0)!==null&&l!==void 0?l:void 0)!==null&&s!==void 0?s:S.firstWeekContainsDate)!==null&&o!==void 0?o:(u=S.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&i!==void 0?i:1);if(!(T>=1&&T<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var m=jt((f=(d=(h=(v=void 0)!==null&&v!==void 0?v:void 0)!==null&&h!==void 0?h:S.weekStartsOn)!==null&&d!==void 0?d:(y=S.locale)===null||y===void 0||(p=y.options)===null||p===void 0?void 0:p.weekStartsOn)!==null&&f!==void 0?f:0);if(!(m>=0&&m<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!x.localize)throw new RangeError("locale must contain localize property");if(!x.formatLong)throw new RangeError("locale must contain formatLong property");var w=ze(e);if(!_W(w))throw new RangeError("Invalid time value");var O=TW(w),P=$W(w,O),j={firstWeekContainsDate:T,weekStartsOn:m,locale:x,_originalDate:w},M=b.match(PU).map(function(_){var $=_[0];if($==="p"||$==="P"){var R=WW[$];return R(_,x.formatLong)}return _}).join("").match(TU).map(function(_){if(_==="''")return"'";var $=_[0];if($==="'")return $U(_);var R=BW[$];if(R)return KW(_)&&kb(_,t,String(e)),GW(_)&&kb(_,t,String(e)),R(P,_,x.localize,j);if($.match(jU))throw new RangeError("Format string contains an unescaped latin alphabet character `"+$+"`");return _}).join("");return M}function $U(e){var t=e.match(_U);return t?t[1].replace(EU,"'"):e}function Mb(e,t){Me(2,arguments);var r=ze(e),n=ze(t);return r.getTime()<n.getTime()}function CU(e,t){Me(2,arguments);var r=ze(e).getTime(),n=ze(t.start).getTime(),a=ze(t.end).getTime();if(!(n<=a))throw new RangeError("Invalid interval");return r>=n&&r<=a}function Ns(e,t){Me(2,arguments);var r=jt(t);return wW(e,-r)}function kU(e,t){Me(2,arguments);var r=jt(t);return lf(e,-r)}const Nb=({children:e})=>{const[t,r]=A.useState(!1);return A.useEffect(()=>(r(!0),()=>r(!1)),[]),t?Jr.createPortal(e,document.body):null};function Db({className:e,defaultValue:t,onDateRangeChange:r}){console.log("🗓️ DateRangePicker component rendered with props:",{className:e,defaultValue:t,hasCallback:!!r});const n=[{label:"Today",value:"today",dateRange:{from:ra(new Date),to:new Date}},{label:"Yesterday",value:"yesterday",dateRange:{from:ra(Ns(new Date,1)),to:EW(Ns(new Date,1))}},{label:"This week",value:"thisWeek",dateRange:{from:AW(new Date),to:new Date}},{label:"Last 7 days",value:"7d",dateRange:{from:ra(Ns(new Date,6)),to:new Date}},{label:"This month",value:"thisMonth",dateRange:{from:jW(new Date),to:new Date}},{label:"Last 30 days",value:"30d",dateRange:{from:ra(Ns(new Date,29)),to:new Date}}],a=t?n.find(C=>C.value===t):null;console.log("📅 DateRangePicker initialization:",{defaultValue:t,defaultPreset:a==null?void 0:a.label,hasDateRange:!!(a!=null&&a.dateRange),allPresetValues:n.map(C=>C.value),foundPreset:!!a});const[i,o]=A.useState(a==null?void 0:a.dateRange),[s,l]=A.useState(a==null?void 0:a.dateRange),[u,c]=A.useState(!1),[f,d]=A.useState((a==null?void 0:a.label)||null),[h,v]=A.useState((a==null?void 0:a.label)||null),[y,p]=A.useState(new Date),[b,S]=A.useState(null),[x,T]=A.useState({top:0,left:0}),m=A.useRef(null),w=A.useRef(null);A.useEffect(()=>{var C,B;console.log("📅 DateRangePicker useEffect running:",{hasDefaultPreset:!!a,hasOnDateRangeChange:!!r,currentDate:i,currentLabel:f,defaultValue:t,defaultPresetLabel:a==null?void 0:a.label,defaultPresetValue:a==null?void 0:a.value}),a!=null&&a.dateRange&&r?(console.log("📅 DateRangePicker: Setting initial default value:",{label:a.label,dateRange:a.dateRange,from:(C=a.dateRange.from)==null?void 0:C.toLocaleDateString(),to:(B=a.dateRange.to)==null?void 0:B.toLocaleDateString()}),r(a.dateRange)):console.log("📅 DateRangePicker: NOT setting initial value because:",{hasDefaultPreset:!!a,hasDateRange:!!(a!=null&&a.dateRange),hasCallback:!!r,presetLabelsAvailable:n.map(U=>`${U.value}:${U.label}`)})},[]),A.useEffect(()=>{t&&(a!=null&&a.dateRange)&&(console.log("📅 DateRangePicker: DefaultValue changed, updating state:",{defaultValue:t,label:a.label}),o(a.dateRange),d(a.label),l(a.dateRange),v(a.label))},[t]);const O=()=>{if(!w.current)return;const C=w.current.getBoundingClientRect(),B=window.scrollY,U=window.scrollX,G=window.innerWidth,E=window.innerHeight,L=720,F=450;let W=C.bottom+B+8,K=C.left+U;K+L>G&&(K=C.right+U-L),K+L>G&&(K=G-L-20),W+F>E&&(W=C.top+B-F-8),K<20&&(K=20),W<20&&(W=20),T({top:W,left:K})};A.useEffect(()=>{const C=()=>{u&&O()};return u&&(window.addEventListener("resize",C),window.addEventListener("scroll",C)),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C)}},[u]);const P=(C,B)=>{if(l(C),v(B),S(null),C.from){const U=new Date(C.from.getFullYear(),C.from.getMonth(),1);p(U)}},j=C=>{if(!b)S(C),l({from:C,to:C}),v(null);else{const B=Mb(C,b)?C:b,U=Mb(C,b)?b:C;l({from:B,to:U}),S(null),v(null)}},M=()=>{o(s),d(h),r==null||r(s),c(!1),S(null)},_=()=>{l(void 0),v(null),o(void 0),d(null),r==null||r(void 0),c(!1),S(null)},$=C=>{C?(l(i),v(f),S(null),setTimeout(O,0)):(l(i),v(f),S(null)),c(C)},R=(C,B)=>(console.log("📅 formatDateRange called with:",{presetLabel:B,hasDateRange:!!(C!=null&&C.from)}),B||(C!=null&&C.from?!C.to||xi(C.from,C.to)?Ms(C.from,"MMM dd, yyyy"):`${Ms(C.from,"MMM dd, yyyy")} - ${Ms(C.to,"MMM dd, yyyy")}`:"Pick a date range")),k=(C=0)=>{const B=lf(y,C),U=B.getFullYear(),G=B.getMonth(),E=new Date(U,G,1),F=new Date(U,G+1,0).getDate(),W=E.getDay(),K=["January","February","March","April","May","June","July","August","September","October","November","December"],X=["Su","Mo","Tu","We","Th","Fr","Sa"],Q=[],te=new Date(U,G-1,0).getDate();for(let J=W-1;J>=0;J--){const I=te-J,ie=new Date(U,G-1,I);Q.push(g.jsx("button",{onClick:()=>j(ie),className:"h-8 w-8 text-xs text-gray-400 hover:bg-gray-100 rounded flex items-center justify-center",children:I},`prev-${I}`))}for(let J=1;J<=F;J++){const I=new Date(U,G,J),ie=xi(I,new Date),q=(s==null?void 0:s.from)&&(s==null?void 0:s.to)&&CU(I,{start:s.from,end:s.to}),se=(s==null?void 0:s.from)&&xi(I,s.from),ee=(s==null?void 0:s.to)&&xi(I,s.to),ve=b&&xi(I,b);let We="h-8 w-8 text-xs hover:bg-gray-100 rounded flex items-center justify-center transition-colors ";ie&&(We+="font-semibold "),ve||se||ee?We+="bg-blue-500 text-white hover:bg-blue-600 ":q&&(We+="bg-blue-100 text-blue-900 "),Q.push(g.jsx("button",{onClick:()=>j(I),className:We,children:J},`current-${J}`))}const Y=Math.ceil((W+F)/7)*7-W-F;for(let J=1;J<=Y;J++){const I=new Date(U,G+1,J);Q.push(g.jsx("button",{onClick:()=>j(I),className:"h-8 w-8 text-xs text-gray-400 hover:bg-gray-100 rounded flex items-center justify-center",children:J},`next-${J}`))}return g.jsxs("div",{className:"p-3",children:[g.jsxs("div",{className:"flex items-center justify-between mb-3",children:[C===0&&g.jsx("button",{onClick:()=>p(kU(y,1)),className:"p-1 hover:bg-gray-100 rounded",children:g.jsx(Qb,{className:"h-4 w-4"})}),g.jsxs("div",{className:"font-medium text-sm",children:[K[G]," ",U]}),C===1&&g.jsx("button",{onClick:()=>p(lf(y,1)),className:"p-1 hover:bg-gray-100 rounded",children:g.jsx(e0,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:X.map(J=>g.jsx("div",{className:"h-8 flex items-center justify-center text-xs font-medium text-gray-500",children:J},J))}),g.jsx("div",{className:"grid grid-cols-7 gap-1",children:Q})]})},D=()=>"fixed bg-white border border-gray-200 rounded-lg shadow-xl z-[99999]";return g.jsxs("div",{className:`relative ${e}`,children:[g.jsxs("button",{ref:w,onClick:()=>$(!u),className:`min-w-[200px] px-3 py-2 text-left border border-gray-300 rounded-md shadow-sm bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 flex items-center ${i?"text-gray-900":"text-gray-500"}`,children:[g.jsx(yf,{className:"mr-2 h-4 w-4"}),(()=>{const C=R(i,f);return console.log("📅 Button display text:",{displayText:C,date:i,selectedPresetLabel:f}),C})()]}),u&&g.jsxs(Nb,{children:[g.jsx("div",{className:"fixed inset-0 z-[99998] bg-black bg-opacity-10",onClick:()=>$(!1)}),g.jsxs("div",{ref:m,className:D(),style:{top:x.top,left:x.left,width:"720px",minWidth:"720px",maxHeight:"90vh"},onClick:C=>C.stopPropagation(),children:[g.jsxs("div",{className:"flex",children:[g.jsxs("div",{className:"flex flex-col gap-1 p-3 border-r border-gray-200 w-[160px] flex-shrink-0",children:[g.jsx("div",{className:"text-sm font-medium text-gray-500 mb-2",children:"Quick Filters"}),n.map(C=>g.jsx("button",{onClick:()=>P(C.dateRange,C.label),className:`text-left px-2 py-1.5 text-sm rounded hover:bg-gray-100 transition-colors ${h===C.label?"bg-gray-100":""}`,children:C.label},C.label))]}),g.jsxs("div",{className:"flex flex-1",children:[k(0),k(1)]})]}),g.jsxs("div",{className:"border-t border-gray-200 p-3 flex justify-end gap-2",children:[g.jsx("button",{onClick:_,className:"px-3 py-1.5 text-sm border border-gray-300 rounded hover:bg-gray-50 transition-colors",children:"Clear"}),g.jsx("button",{onClick:M,disabled:!(s!=null&&s.from),className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Apply"})]})]})]})]})}const MU=({config:e,appConfig:t,className:r,onExport:n,onDraftChange:a,onTimeRangeChange:i})=>{var R;const{title:o,subtitle:s,sections:l,globalControls:u,layout:c={columns:12,gap:24,responsive:!0}}=e,[f,d]=A.useState(!1),[h,v]=A.useState({}),[y,p]=A.useState(l),[b,S]=A.useState([]),[x,T]=A.useState(!1),m=A.useRef(null);A.useEffect(()=>{if(t)try{m.current=new Ht(t),w(),O()}catch(k){console.error("Failed to initialize API service:",k)}},[t]);const w=async()=>{if(!(!m.current||!t)){T(!0);try{const k=await m.current.fetchEnvironments();S(k),console.log("🌍 Environments loaded:",k.map(D=>D.envName))}catch(k){console.error("Error loading environments:",k)}finally{T(!1)}}},O=async()=>{if(!(!m.current||!t)){d(!0);try{const k=m.current.getDefaultTimeRange();console.log("📊 Loading dashboard data with date range:",{fromTimestamp:k.fromTimestamp,toTimestamp:k.toTimestamp,fromDate:new Date(k.fromTimestamp).toLocaleDateString(),toDate:new Date(k.toTimestamp).toLocaleDateString()});const D=await m.current.fetchAllCardsDataWithEnhancedViews(k.fromTimestamp,k.toTimestamp);console.log("✅ Enhanced cards data loaded successfully:",D),console.log("📈 Data covers period:",{from:new Date(k.fromTimestamp).toLocaleDateString(),to:new Date(k.toTimestamp).toLocaleDateString()});const C=l.map(B=>B.id==="usage-analytics"?(console.log("Updating usage-analytics section with enhanced data"),{...B,metrics:D.usageAnalytics}):B.id==="runs"?(console.log("Updating runs section with enhanced data including table and controls"),{...B,metrics:D.runs}):B);p(C)}catch(k){console.error("Error loading initial data:",k),p(l)}finally{d(!1)}}},P=async(k,D)=>{if(!(!m.current||!t||!D.metricType)){p(C=>C.map(B=>B.id===k?{...B,metrics:B.metrics.map(U=>({...U,highlighted:U.metricType===D.metricType}))}:B)),v(C=>({...C,[k]:!0}));try{const C=t.defaultTimeRange||Ht.getDateRange(7);let B,U;if(["users","sessions","messages","tokens"].includes(D.metricType))B="usage-analytics",U=D.metricType;else if(["agentRuns","toolRuns","modelRuns"].includes(D.metricType))B="runs",U=D.metricType==="agentRuns"?"agent-runs":D.metricType==="toolRuns"?"tool-runs":"model-runs";else return;const G=await m.current.fetchTimeSeriesData(U,B,C.fromTimestamp,C.toTimestamp),E=m.current.transformTimeSeriesDataForMetric(G,D.metricType);console.log("Time series response for",D.title,":",G),console.log("Transformed data for",D.title,":",E),console.log("Metric type used for transformation:",D.metricType);const F=(W=>({users:"users",sessions:"sessions",messages:"messages",tokens:"totalTokens",agentRuns:"agentRuns",toolRuns:"toolRuns",modelRuns:"modelRuns"})[W]||"count")(D.metricType||"count");console.log("Using dataKey for metric",D.metricType,":",F),p(W=>W.map(K=>{if(K.id===k){const X={...K,view:{...K.view,chart:K.view.chart?{...K.view.chart,data:E,dataKey:F,lines:[{dataKey:F,color:K.view.chart.color||"#3b82f6",label:D.title,strokeWidth:2}]}:{type:"line",data:E,dataKey:F,lines:[{dataKey:F,color:"#3b82f6",label:D.title,strokeWidth:2}],yAxisLabel:D.title}}};return console.log("Updated section for",k,":",X),console.log("Chart config set:",X.view.chart),X}return K}))}catch(C){console.error("Error loading metric data:",C)}finally{v(C=>({...C,[k]:!1}))}}},j=k=>{var D,C;if((C=(D=u==null?void 0:u.draft)==null?void 0:D.onChange)==null||C.call(D,k),a==null||a(k),t&&m.current){const B={...t,environment:k};m.current.updateConfig(B),O()}},M=k=>{var D,C;if(console.log("🗓️ Time range change requested:",k),typeof k=="string"&&((C=(D=u==null?void 0:u.timeRange)==null?void 0:D.onChange)==null||C.call(D,k)),i==null||i(k),t&&m.current){let B=null;if(typeof k=="object"&&k.from&&k.to)B={fromTimestamp:k.from.toISOString(),toTimestamp:k.to.toISOString()},console.log("📅 Converting DateRange to API format:",B);else if(typeof k=="string"){const G={"24h":1,"7d":7,"30d":30,"90d":90}[k];G&&(B=Ht.getDateRange(G),console.log(`📅 Converting preset "${k}" (${G} days) to API format:`,B))}if(B){const U={...t,defaultTimeRange:B};console.log("🔄 Updating API configuration with new date range:",U.defaultTimeRange),m.current.updateConfig(U),console.log("🚀 Reloading dashboard data with new date range..."),O()}else console.warn("⚠️ Unable to convert time range value to API format:",k)}},_=(k="csv")=>{var D,C;(C=(D=u==null?void 0:u.export)==null?void 0:D.onExport)==null||C.call(D,k),n==null||n()},$=Object.values(h).some(k=>k);return g.jsxs("div",{className:ue("mx-auto p-6",r),children:[g.jsx("div",{className:"mb-8",children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:o}),s&&g.jsx("p",{className:"text-gray-600 mt-2",children:s})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[(f||$)&&g.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[g.jsx(n0,{className:"h-4 w-4 animate-spin"}),"Loading..."]}),u&&g.jsxs(g.Fragment,{children:[u.draft&&g.jsx(js,{options:b.length>0?b.map(k=>({label:k.envName.charAt(0).toUpperCase()+k.envName.slice(1),value:k.envName})):u.draft.options,value:u.draft.defaultValue,placeholder:x?"Loading environments...":u.draft.label,onChange:j,className:"min-w-[200px]",disabled:f||$||x}),u.timeRange&&(u.timeRange.useDatePicker?(console.log("🗓️ Dashboard: Rendering DateRangePicker with defaultValue:",u.timeRange.defaultValue),g.jsx(Db,{defaultValue:u.timeRange.defaultValue,onDateRangeChange:k=>{console.log("🗓️ Dashboard: DateRangePicker callback received:",k),k&&M(k)}})):g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(yf,{className:"h-4 w-4 text-gray-500"}),g.jsx(js,{options:u.timeRange.options||[],value:u.timeRange.defaultValue,placeholder:u.timeRange.label,onChange:M,className:"min-w-[200px]",disabled:f||$})]})),((R=u.export)==null?void 0:R.enabled)&&g.jsxs(sf,{variant:"outline",onClick:()=>_(),className:"gap-2",disabled:f||$,children:[g.jsx(t0,{className:"h-4 w-4"}),"Export"]})]})]})]})}),g.jsx("div",{className:ue("grid gap-6",c.responsive&&"grid-cols-1 lg:grid-cols-12"),style:{gridTemplateColumns:c.responsive?void 0:`repeat(${c.columns}, minmax(0, 1fr))`,gap:c.gap?`${c.gap}px`:void 0},children:y.map(k=>{var D,C,B,U;return g.jsx(Tb,{section:k,isLoading:f,isChartLoading:h[k.id]||!1,onMetricClick:G=>P(k.id,G),className:ue(c.responsive&&((D=k.layout)==null?void 0:D.span)===12&&"lg:col-span-12",c.responsive&&((C=k.layout)==null?void 0:C.span)===6&&"lg:col-span-6",c.responsive&&((B=k.layout)==null?void 0:B.span)===4&&"lg:col-span-4",c.responsive&&((U=k.layout)==null?void 0:U.span)===3&&"lg:col-span-3")},k.id)})})]})},Ds=["Portfolio Analysis Expert","Mortgage Evaluator","Credit Risk Specialist","Asset Valuation Analyst","Liability Assessment Advisor"],Is=["calculate-creditScore","calculate-risk","calculate-mortgage","analyse-expenses","fetch-statement"],Ls=["gpt-4o","gpt-4o-mini","gpt-3.5-turbo","claude-3-5-sonnet","claude-3-5-haiku","claude-3-opus","gemini-1.5-pro","gemini-1.5-flash","llama-3.1-405b","llama-3.1-70b"],NU=(e=30)=>{const t=[],r=new Date;for(let n=e-1;n>=0;n--){const a=new Date(r);a.setDate(r.getDate()-n);const i=600+Math.sin(n*.1)*100,o=Math.floor(i+Math.random()*100),s=Math.floor(o*3.5+Math.random()*200),l=Math.floor(s*2.9+Math.random()*500),u=Math.floor(l*.9+Math.random()*300),c=Math.floor(u*.6),f=u-c,d=Math.floor(s*.8+Math.random()*100),h=Math.floor(d*12+Math.random()*500),v=Math.floor(d*8+Math.random()*300),y=Math.floor(h*.3+Math.random()*100),p=Math.floor(h*.25+Math.random()*80),b=Math.floor(h*.2+Math.random()*60),S=Math.floor(h*.15+Math.random()*50),x={};Ds.forEach(w=>{const O=w.replace(/\s+/g,"").toLowerCase(),P=Math.floor(d/Ds.length);x[O]=Math.floor(P+Math.random()*(P*.5))});const T={};Is.forEach(w=>{const O=w.replace(/[-]/g,""),P=Math.floor(h/Is.length);T[O]=Math.floor(P+Math.random()*(P*.8))});const m={};Ls.forEach(w=>{const O=w.replace(/[-\.]/g,""),P=Math.floor(v/Ls.length);m[O]=Math.floor(P+Math.random()*(P*.6))}),t.push({date:a.toISOString().split("T")[0],users:o,sessions:s,messages:l,totalTokens:u,inputTokens:c,outputTokens:f,agentRuns:d,toolRuns:h,modelRuns:v,codeTools:y,workflowTools:p,knowledgeTools:b,mcpTools:S,...x,...T,...m,value:o})}return t},DU=()=>{const e=[],t=['{"name":"avatar14","color":"#F6D0FE","type":"human"}','{"name":"avatar2","color":"#3B82F6","type":"human"}','{"name":"avatar7","color":"#EF4444","type":"human"}','{"name":"avatar12","color":"#10B981","type":"human"}','{"name":"avatar8","color":"#F59E0B","type":"human"}'];return Ds.forEach((r,n)=>{e.push({id:`agent-${n+1}`,name:r,runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*120)+15}s`,tokens:Math.floor(Math.random()*4e5)+1e5,successRate:`${Math.floor(Math.random()*20)+80}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),avatar:`https://api.dicebear.com/7.x/avataaars/svg?seed=${r.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`,icon:t[n]||t[0]})}),e},IU=()=>{const e=r=>r.includes("calculate-creditscore")?"Code Tool":r.includes("calculate-risk")?"Workflow Tool":r.includes("calculate-mortgage")?"MCP Tool":r.includes("analyse-expenses")?"Workflow Tool":r.includes("fetch-statement")?"Knowledge":"Code Tool",t=['{"name":"calculator","color":"#EF6820","type":"inlineTool"}','{"name":"workflow","color":"#155EEF","type":"toolLibrary"}','{"name":"mcptool","color":"#101828","type":"MCP"}','{"name":"expenses","color":"#155EEF","type":"toolLibrary"}','{"name":"knowledge","color":"#7A5AF8","type":"KNOWLEDGE"}'];return Is.map((r,n)=>({id:`tool-${n+1}`,name:r,type:e(r),runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*90)+15}s`,tokens:Math.floor(Math.random()*2e4)+5e3,successRate:`${Math.floor(Math.random()*15)+85}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString(),icon:t[n]||t[0]}))},LU=()=>Ls.map((e,t)=>({id:`model-${t+1}`,name:e,runs:Math.floor(Math.random()*8e3)+4e3,responseTime:`${Math.floor(Math.random()*120)+15}s`,tokens:Math.floor(Math.random()*5e5)+1e5,successRate:`${Math.floor(Math.random()*15)+85}%`,lastRun:new Date(Date.now()-Math.random()*7*24*60*60*1e3).toLocaleDateString()})),Xr=NU(),RU=DU(),BU=IU(),FU=LU(),WU={id:"main-dashboard",title:"Dashboard",subtitle:"Monitor and review the usage of your agentic app.",version:"1.0.0",globalControls:{draft:{label:"Draft",options:[{label:"Current Draft",value:"current"},{label:"Previous Draft",value:"previous"},{label:"All Drafts",value:"all"}],defaultValue:"current"},timeRange:{label:"Time Range",options:[{label:"This month",value:"month"},{label:"Last 7 days",value:"week"},{label:"Last 30 days",value:"30days"},{label:"Last 90 days",value:"90days"}],defaultValue:"month"},export:{enabled:!0,formats:["csv","json","pdf"]}},layout:{columns:12,gap:24,responsive:!0},sections:[{id:"sessions",title:"Sessions",description:"User engagement and session analytics",metrics:[{title:"Users",value:3384,change:{value:6,type:"increase"},info:"Total number of unique users",metricType:"users",view:{type:"chart",chart:{type:"line",title:"Total Users",data:Xr,dataKey:"users",color:"#8b5cf6",yAxisLabel:"Number of Users",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Sessions",value:11847,change:{value:18,type:"increase"},info:"Total number of user sessions",metricType:"sessions",view:{type:"chart",chart:{type:"line",title:"Total Sessions",data:Xr,dataKey:"sessions",color:"#06b6d4",yAxisLabel:"Number of Sessions",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Messages",value:34563,change:{value:5,type:"increase"},info:"Total messages exchanged",metricType:"messages",view:{type:"chart",chart:{type:"line",title:"Total Messages",data:Xr,dataKey:"messages",color:"#e879f9",yAxisLabel:"Number of Messages",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}},{title:"Tokens",value:32044,change:{value:44,type:"increase"},info:"Total tokens processed",metricType:"tokens",view:{type:"chart",chart:{type:"line",title:"Token Usage Breakdown",data:Xr,yAxisLabel:"Number of Tokens",lines:[{dataKey:"totalTokens",color:"#f97316",label:"Total Tokens"},{dataKey:"inputTokens",color:"#3b82f6",label:"Input Tokens"},{dataKey:"outputTokens",color:"#e879f9",label:"Output Tokens"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}}}}],view:{type:"chart"},layout:{span:12,order:1}},{id:"runs",title:"Runs",description:"Agent, tool, and model execution analytics",metrics:[{title:"Agent Runs",value:3384,change:{value:6,type:"increase"},info:"Number of agent executions",metricType:"agentRuns",view:{type:"chart",chart:{type:"line",title:"Agent Runs",data:Xr,dataKey:"agentRuns",color:"#06b6d4",yAxisLabel:"Number of Agent Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Agent Runs",data:RU,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"},{key:"tokens",title:"Tokens",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`}]}},controls:{dropdown:{label:"All Agents",options:[{label:"All Agents",value:"all"},...Ds.map(e=>({label:e,value:e.replace(/\s+/g,"").toLowerCase(),avatar:`https://api.dicebear.com/7.x/avataaars/svg?seed=${e.replace(/\s+/g,"")}&backgroundColor=b6e3f4,c0aede,d1d4f9&backgroundType=solid`}))],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Tool Runs",value:34563,change:{value:5,type:"increase"},info:"Number of tool executions",metricType:"toolRuns",view:{type:"chart",chart:{type:"line",title:"Tool Runs",data:Xr,yAxisLabel:"Number of Tool Runs",lines:[{dataKey:"toolRuns",color:"#06b6d4",label:"Tool Runs"},{dataKey:"codeTools",color:"#f97316",label:"Code Tools"},{dataKey:"workflowTools",color:"#10b981",label:"Workflow Tools"},{dataKey:"knowledgeTools",color:"#8b5cf6",label:"Knowledge"},{dataKey:"mcpTools",color:"#ef4444",label:"MCP Tools"}],height:300,showGrid:!0,showLegend:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Tool Runs",data:BU,columns:[{key:"name",title:"Name",width:200,align:"left"},{key:"type",title:"Type",width:150,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Tools",options:[{label:"All Tools",value:"all"},...Is.map((e,t)=>{const r=['{"name":"calculator","color":"#EF6820","type":"inlineTool"}','{"name":"workflow","color":"#155EEF","type":"toolLibrary"}','{"name":"mcptool","color":"#101828","type":"MCP"}','{"name":"expenses","color":"#155EEF","type":"toolLibrary"}','{"name":"knowledge","color":"#7A5AF8","type":"KNOWLEDGE"}'],n=a=>a.includes("calculate-creditscore")?"Code Tool":a.includes("calculate-risk")?"Workflow Tool":a.includes("calculate-mortgage")?"MCP Tool":a.includes("analyse-expenses")?"Workflow Tool":a.includes("fetch-statement")?"Knowledge":"Code Tool";return{label:e,value:e.replace(/[-]/g,""),icon:r[t]||r[0],type:n(e)}})],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}},{title:"Model Runs",value:32044,change:{value:44,type:"increase"},info:"Number of model inferences",metricType:"modelRuns",view:{type:"chart",chart:{type:"line",title:"Model Runs",data:Xr,dataKey:"modelRuns",color:"#10b981",yAxisLabel:"Number of Model Runs",height:300,showGrid:!0,curve:"monotone",tooltip:{show:!0,style:"dark"},dateRange:{start:"2025-05-06",end:"2025-06-05"}},table:{title:"Model Runs",data:FU,columns:[{key:"name",title:"Model Name",width:200,align:"left"},{key:"runs",title:"Runs",width:100,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"tokens",title:"Tokens",width:120,align:"right",formatter:e=>`${Math.floor(e/1e3)}k`},{key:"responseTime",title:"Response Time",width:120,align:"right"}]}},controls:{dropdown:{label:"All Models",options:[{label:"All Models",value:"all"},...Ls.map(e=>{const t=r=>{const n=r.toLowerCase();return n.includes("gpt")||n.includes("openai")?"⚡":n.includes("claude")||n.includes("anthropic")?"A":n.includes("gemini")||n.includes("google")?"G":n.includes("llama")||n.includes("meta")?"M":"🤖"};return{label:e,value:e.replace(/[-\.]/g,""),icon:t(e)}})],defaultValue:["all"],multiSelect:!0,searchable:!0},toggle:{chartView:!0,tableView:!0}}}],view:{type:"chart"},layout:{span:12,order:2}}]},Yt={primary:["#8b5cf6","#06b6d4","#f97316","#10b981","#ec4899","#f59e0b","#3b82f6","#ef4444"],secondary:["#a78bfa","#22d3ee","#fb923c","#34d399","#f472b6","#fbbf24","#60a5fa","#f87171"],accent:["#6366f1","#8b5cf6","#d946ef","#06b6d4","#84cc16","#eab308"],semantic:{success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},gradients:{purple:["#8b5cf6","#a78bfa"],cyan:["#06b6d4","#22d3ee"],orange:["#f97316","#fb923c"],green:["#10b981","#34d399"],sunset:["#f97316","#ec4899"],ocean:["#06b6d4","#3b82f6"],forest:["#10b981","#84cc16"]}},UU={primary:["#7c3aed","#0891b2","#ea580c","#059669","#db2777","#d97706","#2563eb","#dc2626"],secondary:["#8b5cf6","#06b6d4","#f97316","#10b981","#ec4899","#f59e0b","#3b82f6","#ef4444"],accent:["#4f46e5","#7c3aed","#c026d3","#0891b2","#65a30d","#ca8a04"],semantic:{success:"#059669",warning:"#d97706",error:"#dc2626",info:"#2563eb"}},zU={primary:["#a78bfa","#22d3ee","#fb923c","#34d399","#f472b6","#fbbf24","#60a5fa","#f87171"],secondary:["#c4b5fd","#67e8f9","#fdba74","#6ee7b7","#f9a8d4","#fcd34d","#93c5fd","#fca5a5"],accent:["#818cf8","#a78bfa","#e879f9","#22d3ee","#a3e635","#facc15"],semantic:{success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#60a5fa"}},GU={primary:["#1f2937","#374151","#6b7280","#9ca3af","#3b82f6","#1d4ed8","#10b981","#f59e0b"],secondary:["#4b5563","#6b7280","#9ca3af","#d1d5db","#60a5fa","#3b82f6","#34d399","#fbbf24"],accent:["#2563eb","#1d4ed8","#059669","#0891b2","#d97706","#b45309"],semantic:{success:"#059669",warning:"#d97706",error:"#dc2626",info:"#1d4ed8"}},Ib=(e,t)=>e.primary[t%e.primary.length],Si=(e,t)=>e.semantic[t],KU=(e,t)=>{var r;return((r=e.gradients)==null?void 0:r[t])||[e.primary[0],e.primary[1]]},Lb=(e,t=Yt)=>e.map((r,n)=>({...r,color:Ib(t,n)})),Rs=((e=30)=>{const t=[],r=new Date;for(let n=e-1;n>=0;n--){const a=new Date(r);a.setDate(r.getDate()-n);const i=600+Math.sin(n*.1)*100,o=Math.floor(i+Math.random()*100),s=Math.floor(o*3.5+Math.random()*200),l=Math.floor(s*2.9+Math.random()*500),u=Math.floor(l*.9+Math.random()*300),c=Math.floor(u*.6),f=u-c,d=Math.floor(s*.8+Math.random()*100),h=Math.floor(d*12+Math.random()*500),v=Math.floor(d*8+Math.random()*300);t.push({date:a.toISOString().split("T")[0],users:o,sessions:s,messages:l,totalTokens:u,inputTokens:c,outputTokens:f,agentRuns:d,toolRuns:h,modelRuns:v,value:o})}return t})(),VU={id:"enhanced-dashboard",title:"Enhanced Color Configuration Dashboard",subtitle:"Demonstrating all color configuration options",version:"1.0.0",globalControls:{draft:{label:"Draft",options:[{label:"Current Draft",value:"current"},{label:"Previous Draft",value:"previous"}],defaultValue:"current"},timeRange:{label:"Time Range",options:[{label:"Last 7 days",value:"week"},{label:"Last 30 days",value:"30days"}],defaultValue:"30days"},export:{enabled:!0,formats:["csv","json"]}},layout:{columns:12,gap:24,responsive:!0},sections:[{id:"manual-colors",title:"Manual Color Assignment",description:"Each line has manually assigned colors",metrics:[{title:"Total Users",value:3384,change:{value:6,type:"increase"},info:"Manually colored chart"}],view:{type:"chart",chart:{type:"line",title:"Manual Color Configuration",data:Rs,lines:[{dataKey:"users",color:"#8b5cf6",label:"Users",strokeWidth:3},{dataKey:"sessions",color:"#06b6d4",label:"Sessions",strokeWidth:2},{dataKey:"messages",color:"#f97316",label:"Messages",strokeWidth:2,strokeDasharray:"5 5"}],dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:6,order:1}},{id:"auto-colors",title:"Auto-Assigned Colors",description:"Colors automatically assigned from palette",metrics:[{title:"Agent Runs",value:3384,change:{value:6,type:"increase"},info:"Auto-colored from palette"}],view:{type:"chart",chart:{type:"line",title:"Auto Color Assignment",data:Rs,lines:Lb([{dataKey:"agentRuns",label:"Agent Runs"},{dataKey:"toolRuns",label:"Tool Runs"},{dataKey:"modelRuns",label:"Model Runs"},{dataKey:"totalTokens",label:"Total Tokens"}],Yt),dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:6,order:2}},{id:"semantic-colors",title:"Semantic Colors",description:"Using semantic colors for different data types",metrics:[{title:"Success Rate",value:"94.2%",change:{value:2,type:"increase"},info:"Using semantic success color"},{title:"Error Rate",value:"5.8%",change:{value:1,type:"decrease"},info:"Using semantic error color"}],view:{type:"chart",chart:{type:"line",title:"Semantic Color Usage",data:Rs,lines:[{dataKey:"users",color:Si(Yt,"success"),label:"Successful Operations",strokeWidth:3},{dataKey:"sessions",color:Si(Yt,"warning"),label:"Warning Events",strokeWidth:2},{dataKey:"messages",color:Si(Yt,"error"),label:"Error Events",strokeWidth:2},{dataKey:"totalTokens",color:Si(Yt,"info"),label:"Info Events",strokeWidth:2}],dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:300,showLegend:!1}},layout:{span:12,order:3}},{id:"single-custom",title:"Single Line Custom Color",description:"Single line chart with custom color and styling",metrics:[{title:"Total Messages",value:34563,change:{value:5,type:"increase"},info:"Custom styled single line"}],view:{type:"chart",chart:{type:"line",title:"Custom Single Line",data:Rs,dataKey:"messages",color:"#ec4899",dateRange:{start:"2025-05-06",end:"2025-06-05"},tooltip:{show:!0,style:"dark"},height:250,showGrid:!0,curve:"monotone"}},layout:{span:12,order:4}}]},qU={manualColors:{line1:"#8b5cf6",line2:"#06b6d4",line3:"#f97316",line4:"#10b981"},paletteColors:Yt.primary,semanticColors:Yt.semantic,gradientColors:Yt.gradients},HU={baseUrl:window.location.protocol+"//"+window.location.hostname,dashboardType:"agenticDashboard",projectId:"aa-bdbfa4eb-c7c4-4350-be96-d778188c2c4b",environment:"draft",headers:{authorization:"Bearer 2amvsUbh87obVLVYjbNnXCbXnOr-plekM7-qjKt2EJIZnZuAV2KT9WSTG0L4U33X",accountId:"6290f982fb880154e99bbede","Content-Type":"application/json"},defaultTimeRange:{fromTimestamp:new Date(Date.now()-7*24*60*60*1e3).toISOString(),toTimestamp:new Date().toISOString()},refreshInterval:3e4},YU={id:"agentic-analytics-dashboard",title:"Dashboard",subtitle:"Monitor and review the usage of your agentic app",sections:[{id:"usage-analytics",title:"Sessions",metrics:[{title:"Users",value:0,metricType:"users",highlighted:!0},{title:"Sessions",value:0,metricType:"sessions",highlighted:!1},{title:"Messages",value:0,metricType:"messages",highlighted:!1},{title:"Tokens",value:0,metricType:"tokens",highlighted:!1}],view:{type:"chart",chart:{type:"line",title:"Usage Over Time",data:[],lines:[{dataKey:"count",color:"#3B82F6",label:"Count",strokeWidth:2}],xAxisLabel:"Date",yAxisLabel:"Count",tooltip:{show:!0,formatter:(e,t)=>[`${e}`,t]}}},layout:{span:12}},{id:"runs",title:"Runs",metrics:[{title:"Agent Runs",value:0,metricType:"agentRuns",highlighted:!0},{title:"Tool Runs",value:0,metricType:"toolRuns",highlighted:!1},{title:"Model Runs",value:0,metricType:"modelRuns",highlighted:!1}],view:{type:"chart",chart:{type:"line",title:"Execution Runs Over Time",data:[],lines:[{dataKey:"count",color:"#10B981",label:"Runs",strokeWidth:2}],xAxisLabel:"Date",yAxisLabel:"Count",tooltip:{show:!0,formatter:(e,t)=>[`${e}`,t]}}},layout:{span:12}}],globalControls:{draft:{label:"Environment",options:[{label:"Draft",value:"draft"},{label:"Production",value:"production"},{label:"Staging",value:"staging"}],defaultValue:"draft"},timeRange:{label:"Time Range",useDatePicker:!0,options:[{label:"Last 7 days",value:"7d"},{label:"Last 30 days",value:"30d"}],defaultValue:"7d"},export:{enabled:!1,formats:["csv","json"],onExport:e=>{console.log(`Exporting in ${e} format`)}}},layout:{columns:12,gap:24,responsive:!0}},XU=`
215
215
  // In your Angular component (usage-analytics.component.ts)
216
216
  import { Dashboard, apiEnabledDashboardConfig, agenticAppConfig } from '@agentic/ui-libs';
217
217