fastapi-radar 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

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.

Potentially problematic release.


This version of fastapi-radar might be problematic. Click here for more details.

fastapi_radar/__init__.py CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  from .radar import Radar
4
4
 
5
- __version__ = "0.1.7"
5
+ __version__ = "0.1.9"
6
6
  __all__ = ["Radar"]
fastapi_radar/api.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """API endpoints for FastAPI Radar dashboard."""
2
2
 
3
- from datetime import datetime, timedelta
3
+ from datetime import datetime, timedelta, timezone
4
4
  from typing import Any, Dict, List, Optional, Union
5
5
 
6
6
  from fastapi import APIRouter, Depends, HTTPException, Query
@@ -302,7 +302,7 @@ def create_api_router(get_session_context) -> APIRouter:
302
302
  slow_threshold: int = Query(100),
303
303
  session: Session = Depends(get_db),
304
304
  ):
305
- since = datetime.utcnow() - timedelta(hours=hours)
305
+ since = datetime.now(timezone.utc) - timedelta(hours=hours)
306
306
 
307
307
  requests = (
308
308
  session.query(CapturedRequest)
@@ -359,7 +359,7 @@ def create_api_router(get_session_context) -> APIRouter:
359
359
  older_than_hours: Optional[int] = None, session: Session = Depends(get_db)
360
360
  ):
361
361
  if older_than_hours:
362
- cutoff = datetime.utcnow() - timedelta(hours=older_than_hours)
362
+ cutoff = datetime.now(timezone.utc) - timedelta(hours=older_than_hours)
363
363
  session.query(CapturedRequest).filter(
364
364
  CapturedRequest.created_at < cutoff
365
365
  ).delete()
@@ -382,7 +382,7 @@ def create_api_router(get_session_context) -> APIRouter:
382
382
  session: Session = Depends(get_db),
383
383
  ):
384
384
  """List traces."""
385
- since = datetime.utcnow() - timedelta(hours=hours)
385
+ since = datetime.now(timezone.utc) - timedelta(hours=hours)
386
386
  query = session.query(Trace).filter(Trace.created_at >= since)
387
387
 
388
388
  if status:
@@ -311,7 +311,7 @@ Defaulting to \`null\`.`}var rA=ZN,SW=eA;const Ng=p.forwardRef(({className:e,val
311
311
  *
312
312
  * This source code is licensed under the MIT license found in the
313
313
  * LICENSE file in the root directory of this source tree.
314
- */var wu=p;function Pte(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jte=typeof Object.is=="function"?Object.is:Pte,Ete=wu.useSyncExternalStore,Cte=wu.useRef,Ote=wu.useEffect,kte=wu.useMemo,Nte=wu.useDebugValue;Ste.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=Cte(null);if(a.current===null){var o={hasValue:!1,value:null};a.current=o}else o=a.current;a=kte(function(){function l(m){if(!c){if(c=!0,u=m,m=n(m),i!==void 0&&o.hasValue){var y=o.value;if(i(y,m))return d=y}return d=m}if(y=d,jte(u,m))return y;var v=n(m);return i!==void 0&&i(y,v)?(u=m,y):(u=m,d=v)}var c=!1,u,d,h=r===void 0?null:r;return[function(){return l(t())},h===null?void 0:function(){return l(h())}]},[t,r,n,i]);var s=Ete(e,a[0],a[1]);return Ote(function(){o.hasValue=!0,o.value=s},[s]),Nte(s),s};function Ate(e){e()}function Tte(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Ate(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const i=t={callback:r,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!n||e===null||(n=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var iE={notify(){},get:()=>[]};function _te(e,t){let r,n=iE,i=0,a=!1;function o(v){u();const x=n.subscribe(v);let g=!1;return()=>{g||(g=!0,x(),d())}}function s(){n.notify()}function l(){y.onStateChange&&y.onStateChange()}function c(){return a}function u(){i++,r||(r=e.subscribe(l),n=Tte())}function d(){i--,r&&i===0&&(r(),r=void 0,n.clear(),n=iE)}function h(){a||(a=!0,u())}function m(){a&&(a=!1,d())}const y={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:l,isSubscribed:c,trySubscribe:h,tryUnsubscribe:m,getListeners:()=>n};return y}var Mte=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Rte=Mte(),Dte=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Ite=Dte(),Lte=()=>Rte||Ite?p.useLayoutEffect:p.useEffect,$te=Lte(),av=Symbol.for("react-redux-context"),ov=typeof globalThis<"u"?globalThis:{};function Fte(){if(!p.createContext)return{};const e=ov[av]??(ov[av]=new Map);let t=e.get(p.createContext);return t||(t=p.createContext(null),e.set(p.createContext,t)),t}var zte=Fte();function Bte(e){const{children:t,context:r,serverState:n,store:i}=e,a=p.useMemo(()=>{const l=_te(i);return{store:i,subscription:l,getServerState:n?()=>n:void 0}},[i,n]),o=p.useMemo(()=>i.getState(),[i]);$te(()=>{const{subscription:l}=a;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),o!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[a,o]);const s=r||zte;return p.createElement(s.Provider,{value:a},t)}var Wte=Bte,Ute=(e,t)=>t,Vw=_([Ute,de,Y_,ut,q2,Ni,yQ,yt],PQ),qw=e=>{var t=e.currentTarget.getBoundingClientRect(),r=t.width/e.currentTarget.offsetWidth,n=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/r),chartY:Math.round((e.clientY-t.top)/n)}},nR=Br("mouseClick"),iR=ru();iR.startListening({actionCreator:nR,effect:(e,t)=>{var r=e.payload,n=Vw(t.getState(),qw(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(OY({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var wy=Br("mouseMove"),aR=ru();aR.startListening({actionCreator:wy,effect:(e,t)=>{var r=e.payload,n=t.getState(),i=yw(n,n.tooltip.settings.shared),a=Vw(n,qw(r));i==="axis"&&((a==null?void 0:a.activeIndex)!=null?t.dispatch(z2({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):t.dispatch(F2()))}});var aE={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index"},oR=Cr({name:"rootProps",initialState:aE,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:aE.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className}}}),Hte=oR.reducer,{updateOptions:Kte}=oR.actions,sR=Cr({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:Vie}=sR.actions,Vte=sR.reducer,lR=Br("keyDown"),cR=Br("focus"),Yw=ru();Yw.startListening({actionCreator:lR,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip,a=e.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=Number(xw(i,ul(r))),s=Ni(r);if(a==="Enter"){var l=Xf(r,"axis","hover",String(i.index));t.dispatch(uy({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:l}));return}var c=yY(r),u=c==="left-to-right"?1:-1,d=a==="ArrowRight"?1:-1,h=o+d*u;if(!(s==null||h>=s.length||h<0)){var m=Xf(r,"axis","hover",String(h));t.dispatch(uy({active:!0,activeIndex:h.toString(),activeDataKey:void 0,activeCoordinate:m}))}}}}});Yw.startListening({actionCreator:cR,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;if(!i.active&&i.index==null){var a="0",o=Xf(r,"axis","hover",String(a));t.dispatch(uy({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Ar=Br("externalEvent"),uR=ru();uR.startListening({actionCreator:Ar,effect:(e,t)=>{if(e.payload.handler!=null){var r=t.getState(),n={activeCoordinate:cQ(r),activeDataKey:X2(r),activeIndex:bo(r),activeLabel:G2(r),activeTooltipIndex:bo(r),isTooltipActive:uQ(r)};e.payload.handler(n,e.payload.reactEvent)}}});var qte=_([cl],e=>e.tooltipItemPayloads),Yte=_([qte,gu,(e,t,r)=>t,(e,t,r)=>r],(e,t,r,n)=>{var i=e.find(s=>s.settings.dataKey===n);if(i!=null){var{positions:a}=i;if(a!=null){var o=t(a,r);return o}}}),dR=Br("touchMove"),fR=ru();fR.startListening({actionCreator:dR,effect:(e,t)=>{var r=e.payload,n=t.getState(),i=yw(n,n.tooltip.settings.shared);if(i==="axis"){var a=Vw(n,qw({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY,currentTarget:r.currentTarget}));(a==null?void 0:a.activeIndex)!=null&&t.dispatch(z2({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,s=r.touches[0],l=document.elementFromPoint(s.clientX,s.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(q9),u=(o=l.getAttribute(Y9))!==null&&o!==void 0?o:void 0,d=Yte(t.getState(),c,u);t.dispatch($2({activeDataKey:u,activeIndex:c,activeCoordinate:d}))}}});var Qte=iT({brush:aJ,cartesianAxis:$X,chartData:$Q,errorBars:nZ,graphicalItems:kX,layout:g9,legend:dH,options:MQ,polarAxis:tX,polarOptions:Vte,referenceElements:fJ,rootProps:Hte,tooltip:kY}),Gte=function(t){return WU({reducer:Qte,preloadedState:t,middleware:r=>r({serializableCheck:!1}).concat([iR.middleware,aR.middleware,Yw.middleware,uR.middleware,fR.middleware]),devTools:Pa.devToolsEnabled})};function Xte(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,i=$t(),a=p.useRef(null);if(i)return r;a.current==null&&(a.current=Gte(t));var o=w0;return p.createElement(Wte,{context:o,store:a.current},r)}function Zte(e){var{layout:t,width:r,height:n,margin:i}=e,a=tt(),o=$t();return p.useEffect(()=>{o||(a(p9(t)),a(m9({width:r,height:n})),a(h9(i)))},[a,o,t,r,n,i]),null}function Jte(e){var t=tt();return p.useEffect(()=>{t(Kte(e))},[t,e]),null}var ere=["children"];function tre(e,t){if(e==null)return{};var r,n,i=rre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function rre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function sh(){return sh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sh.apply(null,arguments)}var nre={width:"100%",height:"100%"},ire=p.forwardRef((e,t)=>{var r=A0(),n=T0(),i=RT();if(!Df(r)||!Df(n))return null;var{children:a,otherAttributes:o,title:s,desc:l}=e,c,u;return typeof o.tabIndex=="number"?c=o.tabIndex:c=i?0:void 0,typeof o.role=="string"?u=o.role:u=i?"application":void 0,p.createElement(i0,sh({},o,{title:s,desc:l,role:u,tabIndex:c,width:r,height:n,style:nre,ref:t}),a)}),are=e=>{var{children:t}=e,r=Z(xp);if(!r)return null;var{width:n,height:i,y:a,x:o}=r;return p.createElement(i0,{width:n,height:i,x:o,y:a},t)},oE=p.forwardRef((e,t)=>{var{children:r}=e,n=tre(e,ere),i=$t();return i?p.createElement(are,null,r):p.createElement(ire,sh({ref:t},n),r)});function ore(){var e=tt(),[t,r]=p.useState(null),n=Z(V9);return p.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),a=i.width/t.offsetWidth;At(a)&&a!==n&&e(v9(a))}},[t,e,n]),r}function sE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function sre(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sE(Object(r),!0).forEach(function(n){lre(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sE(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function lre(e,t,r){return(t=cre(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cre(e){var t=ure(e,"string");return typeof t=="symbol"?t:t+""}function ure(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var dre=p.forwardRef((e,t)=>{var{children:r,className:n,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:d,onMouseUp:h,onTouchEnd:m,onTouchMove:y,onTouchStart:v,style:x,width:g}=e,w=tt(),[b,S]=p.useState(null),[P,j]=p.useState(null);qQ();var E=ore(),C=p.useCallback(Y=>{E(Y),typeof t=="function"&&t(Y),S(Y),j(Y)},[E,t,S,j]),N=p.useCallback(Y=>{w(nR(Y)),w(Ar({handler:a,reactEvent:Y}))},[w,a]),k=p.useCallback(Y=>{w(wy(Y)),w(Ar({handler:c,reactEvent:Y}))},[w,c]),A=p.useCallback(Y=>{w(F2()),w(Ar({handler:u,reactEvent:Y}))},[w,u]),T=p.useCallback(Y=>{w(wy(Y)),w(Ar({handler:d,reactEvent:Y}))},[w,d]),D=p.useCallback(()=>{w(cR())},[w]),L=p.useCallback(Y=>{w(lR(Y.key))},[w]),q=p.useCallback(Y=>{w(Ar({handler:o,reactEvent:Y}))},[w,o]),F=p.useCallback(Y=>{w(Ar({handler:s,reactEvent:Y}))},[w,s]),B=p.useCallback(Y=>{w(Ar({handler:l,reactEvent:Y}))},[w,l]),M=p.useCallback(Y=>{w(Ar({handler:h,reactEvent:Y}))},[w,h]),I=p.useCallback(Y=>{w(Ar({handler:v,reactEvent:Y}))},[w,v]),W=p.useCallback(Y=>{w(dR(Y)),w(Ar({handler:y,reactEvent:Y}))},[w,y]),te=p.useCallback(Y=>{w(Ar({handler:m,reactEvent:Y}))},[w,m]);return p.createElement(iM.Provider,{value:b},p.createElement(uA.Provider,{value:P},p.createElement("div",{className:he("recharts-wrapper",n),style:sre({position:"relative",cursor:"default",width:g,height:i},x),onClick:N,onContextMenu:q,onDoubleClick:F,onFocus:D,onKeyDown:L,onMouseDown:B,onMouseEnter:k,onMouseLeave:A,onMouseMove:T,onMouseUp:M,onTouchEnd:te,onTouchMove:W,onTouchStart:I,ref:C},r)))}),fre=["children","className","width","height","style","compact","title","desc"];function hre(e,t){if(e==null)return{};var r,n,i=pre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function pre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var mre=p.forwardRef((e,t)=>{var{children:r,className:n,width:i,height:a,style:o,compact:s,title:l,desc:c}=e,u=hre(e,fre),d=Fn(u);return s?p.createElement(oE,{otherAttributes:d,title:l,desc:c},r):p.createElement(dre,{className:n,style:o,width:i,height:a,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},p.createElement(oE,{otherAttributes:d,title:l,desc:c,ref:t},p.createElement(pJ,null,r)))}),vre=["width","height"];function by(){return by=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},by.apply(null,arguments)}function gre(e,t){if(e==null)return{};var r,n,i=yre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function yre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var xre={top:5,right:5,bottom:5,left:5},wre={accessibilityLayer:!0,layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:xre,reverseStackOrder:!1,syncMethod:"index"},Qw=p.forwardRef(function(t,r){var n,i=Ft(t.categoricalChartProps,wre),{width:a,height:o}=i,s=gre(i,vre);if(!Df(a)||!Df(o))return null;var{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,categoricalChartProps:h}=t,m={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return p.createElement(Xte,{preloadedState:{options:m},reduxStoreName:(n=h.id)!==null&&n!==void 0?n:l},p.createElement(iJ,{chartData:h.data}),p.createElement(Zte,{width:a,height:o,layout:i.layout,margin:i.margin}),p.createElement(Jte,{accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className}),p.createElement(mre,by({},s,{width:a,height:o,ref:r})))}),bre=["axis"],Sre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:bre,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t})),Pre=["axis","item"],jre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Pre,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t})),Ere=["axis"],Cre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Ere,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t}));function Ore({title:e,description:t,data:r,lines:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u}){const{theme:d}=Xc(),h=d==="dark"?Ts.dark:Ts.light,m=Xx[c],y=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(Sre,{data:r,margin:{top:5,right:5,left:0,bottom:5},children:[s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:h.grid,vertical:!1,strokeOpacity:.5}),f.jsx(Mc,{dataKey:i,stroke:h.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:h.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:m,width:45}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"line",wrapperStyle:{fontSize:11}}),n.map((v,x)=>f.jsx(YM,{type:"monotone",dataKey:v.dataKey,name:v.name||v.dataKey,stroke:v.color||(x===0?h.primary:h.secondary),strokeWidth:v.strokeWidth||2,strokeDasharray:v.strokeDasharray,dot:v.dot===!0?{r:3}:!1,activeDot:v.dot!==!1?{r:4}:!1},v.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:y})}function kre({title:e,description:t,data:r,areas:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u,stacked:d=!1}){const{theme:h}=Xc(),m=h==="dark"?Ts.dark:Ts.light,y=Xx[c],v=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(Cre,{data:r,margin:{top:5,right:5,left:0,bottom:5},children:[f.jsx("defs",{children:n.map((x,g)=>f.jsxs("linearGradient",{id:`gradient-${x.dataKey}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"5%",stopColor:x.color||(g===0?m.primary:m.secondary),stopOpacity:.3}),f.jsx("stop",{offset:"95%",stopColor:x.color||(g===0?m.primary:m.secondary),stopOpacity:0})]},`gradient-${x.dataKey}`))}),s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:m.grid,vertical:!1,strokeOpacity:.5}),f.jsx(Mc,{dataKey:i,stroke:m.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:m.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:y,width:45}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"line",wrapperStyle:{fontSize:11}}),n.map((x,g)=>f.jsx(rR,{type:"monotone",dataKey:x.dataKey,name:x.name||x.dataKey,stackId:d?"1":x.stackId,stroke:x.color||(g===0?m.primary:m.secondary),strokeWidth:2,fill:`url(#gradient-${x.dataKey})`,fillOpacity:x.fillOpacity||1},x.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:v})}function Nre({title:e,description:t,data:r,bars:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u,stacked:d=!1,horizontal:h=!1}){const{theme:m}=Xc(),y=m==="dark"?Ts.dark:Ts.light,v=EW(m==="dark"),x=Xx[c],g=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(jre,{data:r,layout:h?"horizontal":"vertical",margin:{top:5,right:5,left:h?50:0,bottom:5},children:[s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:y.grid,vertical:!h,horizontal:h,strokeOpacity:.5}),h?f.jsxs(f.Fragment,{children:[f.jsx(Mc,{type:"number",stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:x}),f.jsx(Rc,{type:"category",dataKey:i,stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1})]}):f.jsxs(f.Fragment,{children:[f.jsx(Mc,{dataKey:i,stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:x,width:45})]}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"rect",wrapperStyle:{fontSize:11}}),n.map((w,b)=>f.jsx(IM,{dataKey:w.dataKey,name:w.name||w.dataKey,stackId:d?"1":w.stackId,fill:w.color||v[b%v.length],radius:d?[0,0,0,0]:[4,4,0,0],maxBarSize:40},w.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:g})}function Are({data:e,maxValue:t,showValues:r=!0,className:n}){const i=t||Math.max(...e.map(a=>a.value));return f.jsx("div",{className:n,children:f.jsx("div",{className:"space-y-2",children:e.map(a=>f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-xs",children:[f.jsx("span",{className:"text-muted-foreground truncate",children:a.name}),r&&f.jsx("span",{className:"font-medium tabular-nums ml-2",children:a.value})]}),f.jsx("div",{className:"h-2 bg-muted rounded-sm overflow-hidden",children:f.jsx("div",{className:"h-full bg-foreground transition-all duration-500 ease-out rounded-sm",style:{width:`${a.value/i*100}%`,backgroundColor:a.color}})})]},a.name))})})}function hR({data:e,className:t}){const r=e.reduce((n,i)=>n+i.count,0);return f.jsx("div",{className:H("space-y-3",t),children:e.map(n=>{const i=n.percentage||n.count/r*100;return f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:n.category}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-medium tabular-nums",children:n.count}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.toFixed(1),"%)"]})]})]}),f.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-foreground rounded-full transition-all duration-500 ease-out",style:{width:`${i}%`}})})]},n.category)})})}function Tre(){const[e,t]=p.useState(1),[r]=p.useState(!0),{openDetail:n}=ko(),i=Pi(),{data:a,refetch:o}=mt({queryKey:["stats",e],queryFn:()=>Ge.getStats(e),refetchInterval:r?5e3:!1}),{data:s,refetch:l}=mt({queryKey:["recent-requests"],queryFn:()=>Ge.getRequests({limit:100}),refetchInterval:r?5e3:!1}),{data:c,refetch:u}=mt({queryKey:["slow-queries"],queryFn:()=>Ge.getQueries({slow_only:!0,limit:10,slow_threshold:100}),refetchInterval:r?1e4:!1}),{data:d,refetch:h}=mt({queryKey:["recent-exceptions"],queryFn:()=>Ge.getExceptions({limit:5}),refetchInterval:r?1e4:!1}),m=XN({requests:s,queries:null,exceptions:d,stats:a}),y=async()=>{await Promise.all([o(),l(),u(),h()])},v=(s==null?void 0:s.slice(0,20).reverse().map(w=>({name:Go(new Date(w.created_at),"HH:mm"),response:w.duration_ms||0,queries:w.query_count||0})))||[],x=[{category:"Success",count:m.successfulRequests,percentage:m.successRate},{category:"Errors",count:m.failedRequests,percentage:m.errorRate}],g=m.endpointMetrics.slice(0,5).map(w=>({name:w.name,value:w.avgResponseTime}));return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:i("pages.dashboard.title")}),f.jsx("p",{className:"text-muted-foreground",children:i("pages.dashboard.description")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(mo,{value:e.toString(),onValueChange:w=>t(parseInt(w)),children:[f.jsx(pa,{className:"w-32",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1",children:i("timeRange.lastHour")}),f.jsx(be,{value:"24",children:i("timeRange.last24Hours")}),f.jsx(be,{value:"168",children:i("timeRange.last7Days")})]})]}),f.jsx(pe,{variant:"outline",size:"icon",onClick:y,children:f.jsx(yc,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[f.jsx(Zr,{label:i("metrics.totalRequests"),value:(a==null?void 0:a.total_requests)||0,change:void 0,changeLabel:`${m.requestsPerMinute.toFixed(1)} ${i("metrics.requestsPerMinute").toLowerCase()}`,icon:f.jsx(Qc,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.avgResponseTime"),value:Jt(m.avgResponseTime),trend:m.avgResponseTime<100?"down":"up",changeLabel:m.avgResponseTime<100?i("performance.excellent"):i("performance.needsAttention"),icon:f.jsx(Xs,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.databaseQueries"),value:(a==null?void 0:a.total_queries)||0,changeLabel:a!=null&&a.slow_queries?`${a.slow_queries} ${i("metrics.slowQueries").toLowerCase()}`:i("database.noSlowQueriesShort"),trend:a!=null&&a.slow_queries?"up":"neutral",icon:f.jsx(Gc,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.exceptions"),value:(a==null?void 0:a.total_exceptions)||0,trend:(a==null?void 0:a.total_exceptions)===0?"neutral":"up",changeLabel:(a==null?void 0:a.total_exceptions)===0?i("common.all"):i("common.error"),icon:f.jsx(Oo,{className:"h-8 w-8"})})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("performance.overview")})}),f.jsxs(le,{className:"space-y-4",children:[f.jsx(nA,{value:m.successRate,max:100,size:"md",label:i("metrics.successRate")}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(at,{label:i("metrics.totalRequests"),value:m.totalRequests}),f.jsx(at,{label:i("requests.tabs.errors"),value:m.failedRequests}),f.jsx(at,{label:i("metrics.errorRate"),value:`${m.errorRate.toFixed(1)}%`})]})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("metrics.responseTime")})}),f.jsxs(le,{className:"space-y-2",children:[f.jsx(at,{label:"P50 (Median)",value:Jt(m.responseTimePercentiles.p50)}),f.jsx(at,{label:"P95",value:Jt(m.responseTimePercentiles.p95)}),f.jsx(at,{label:"P99",value:Jt(m.responseTimePercentiles.p99)}),f.jsx("div",{className:"pt-2",children:f.jsx(Id,{label:i("performance.queryPerformance"),value:a!=null&&a.avg_query_time?100-Math.min(a.avg_query_time/200*100,100):100,compact:!0,status:!(a!=null&&a.avg_query_time)||a.avg_query_time<50?"success":a.avg_query_time<100?"warning":"danger"})})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("performance.requestDistribution")})}),f.jsxs(le,{children:[f.jsx(hR,{data:x}),f.jsx("div",{className:"mt-4 space-y-2",children:f.jsx(xf,{status:m.successRate>=95?"success":m.successRate>=90?"warning":"error",label:i("performance.systemStatus"),description:`${m.requestsPerSecond.toFixed(1)} ${i("performance.requestsPerSec")}`,compact:!0})})]})]})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsx(kre,{title:i("performance.responseTimeChart"),description:i("performance.responseTimeDescription"),data:v,areas:[{dataKey:"response",name:i("metrics.responseTime")+" (ms)"}],height:200,formatter:"duration"}),f.jsx(Ore,{title:i("performance.queryActivity"),description:i("performance.queryActivityDescription"),data:v,lines:[{dataKey:"queries",name:i("database.queries")}],height:200,showGrid:!0})]}),g.length>0&&f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("performance.topEndpoints")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/performance",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]}),f.jsx(pt,{children:i("performance.avgResponseByEndpoint")})]}),f.jsx(le,{children:f.jsx(Are,{data:g})})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("performance.recentRequests")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/requests",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[s==null?void 0:s.slice(0,5).map(w=>f.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id),children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(mW,{status:w.status_code&&w.status_code<400?"online":"offline",size:"sm"}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:"text-sm font-medium truncate",children:[w.method," ",w.path]}),f.jsx("p",{className:"text-xs text-muted-foreground",children:Go(new Date(w.created_at),"HH:mm:ss")})]})]}),f.jsxs("div",{className:"text-right",children:[f.jsx(Oe,{variant:pW(w.status_code),children:w.status_code}),f.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Jt(w.duration_ms)})]})]},w.id)),(!s||s.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:i("requests.empty.all")})]})})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("database.slowQueries")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/database",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[c==null?void 0:c.slice(0,5).map(w=>f.jsxs("div",{className:"space-y-1 cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id),children:[f.jsxs("code",{className:"text-xs bg-muted px-2 py-1 rounded block truncate",children:[w.sql.substring(0,50),"..."]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:Go(new Date(w.created_at),"HH:mm:ss")}),f.jsx(Oe,{variant:"outline",className:"text-xs",children:Jt(w.duration_ms)})]})]},w.id)),(!c||c.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:i("database.noSlowQueries")})]})})]})]}),d&&d.length>0&&f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("exceptions.recentExceptions")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/exceptions",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsx("div",{className:"space-y-2",children:d.slice(0,3).map(w=>f.jsx(xf,{status:"error",label:w.exception_type,description:w.exception_value||i("exceptions.clickToView"),value:Go(new Date(w.created_at),"HH:mm"),className:"cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id)},w.id))})})]})]})}var _re="Label",pR=p.forwardRef((e,t)=>f.jsx(ne.label,{...e,ref:t,onMouseDown:r=>{var i;r.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));pR.displayName=_re;var mR=pR;const Mre=Nh("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),nn=p.forwardRef(({className:e,...t},r)=>f.jsx(mR,{ref:r,className:H(Mre(),e),...t}));nn.displayName=mR.displayName;var sv="rovingFocusGroup.onEntryFocus",Rre={bubbles:!1,cancelable:!0},bu="RovingFocusGroup",[Sy,vR,Dre]=yk(bu),[Ire,gR]=Ln(bu,[Dre]),[Lre,$re]=Ire(bu),yR=p.forwardRef((e,t)=>f.jsx(Sy.Provider,{scope:e.__scopeRovingFocusGroup,children:f.jsx(Sy.Slot,{scope:e.__scopeRovingFocusGroup,children:f.jsx(Fre,{...e,ref:t})})}));yR.displayName=bu;var Fre=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=p.useRef(null),m=me(t,h),y=Th(a),[v,x]=fo({prop:o,defaultProp:s??null,onChange:l,caller:bu}),[g,w]=p.useState(!1),b=Ht(c),S=vR(r),P=p.useRef(!1),[j,E]=p.useState(0);return p.useEffect(()=>{const C=h.current;if(C)return C.addEventListener(sv,b),()=>C.removeEventListener(sv,b)},[b]),f.jsx(Lre,{scope:r,orientation:n,dir:y,loop:i,currentTabStopId:v,onItemFocus:p.useCallback(C=>x(C),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(C=>C+1),[]),onFocusableItemRemove:p.useCallback(()=>E(C=>C-1),[]),children:f.jsx(ne.div,{tabIndex:g||j===0?-1:0,"data-orientation":n,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:re(e.onMouseDown,()=>{P.current=!0}),onFocus:re(e.onFocus,C=>{const N=!P.current;if(C.target===C.currentTarget&&N&&!g){const k=new CustomEvent(sv,Rre);if(C.currentTarget.dispatchEvent(k),!k.defaultPrevented){const A=S().filter(F=>F.focusable),T=A.find(F=>F.active),D=A.find(F=>F.id===v),q=[T,D,...A].filter(Boolean).map(F=>F.ref.current);bR(q,u)}}P.current=!1}),onBlur:re(e.onBlur,()=>w(!1))})})}),xR="RovingFocusGroupItem",wR=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:i=!1,tabStopId:a,children:o,...s}=e,l=ai(),c=a||l,u=$re(xR,r),d=u.currentTabStopId===c,h=vR(r),{onFocusableItemAdd:m,onFocusableItemRemove:y,currentTabStopId:v}=u;return p.useEffect(()=>{if(n)return m(),()=>y()},[n,m,y]),f.jsx(Sy.ItemSlot,{scope:r,id:c,focusable:n,active:i,children:f.jsx(ne.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:re(e.onMouseDown,x=>{n?u.onItemFocus(c):x.preventDefault()}),onFocus:re(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:re(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const g=Wre(x,u.orientation,u.dir);if(g!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let b=h().filter(S=>S.focusable).map(S=>S.ref.current);if(g==="last")b.reverse();else if(g==="prev"||g==="next"){g==="prev"&&b.reverse();const S=b.indexOf(x.currentTarget);b=u.loop?Ure(b,S+1):b.slice(S+1)}setTimeout(()=>bR(b))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});wR.displayName=xR;var zre={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bre(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Wre(e,t,r){const n=Bre(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return zre[n]}function bR(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function Ure(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hre=yR,Kre=wR;function Vre(e,t){return p.useReducer((r,n)=>t[r][n]??r,e)}var mn=e=>{const{present:t,children:r}=e,n=qre(t),i=typeof r=="function"?r({present:n.isPresent}):p.Children.only(r),a=me(n.ref,Yre(i));return typeof r=="function"||n.isPresent?p.cloneElement(i,{ref:a}):null};mn.displayName="Presence";function qre(e){const[t,r]=p.useState(),n=p.useRef(null),i=p.useRef(e),a=p.useRef("none"),o=e?"mounted":"unmounted",[s,l]=Vre(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=vd(n.current);a.current=s==="mounted"?c:"none"},[s]),Nt(()=>{const c=n.current,u=i.current;if(u!==e){const h=a.current,m=vd(c);e?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Nt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=m=>{const v=vd(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(l("ANIMATION_END"),!i.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},h=m=>{m.target===t&&(a.current=vd(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:p.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function vd(e){return(e==null?void 0:e.animationName)||"none"}function Yre(e){var n,i;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Bp="Tabs",[Qre]=Ln(Bp,[gR]),SR=gR(),[Gre,Gw]=Qre(Bp),PR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:s,activationMode:l="automatic",...c}=e,u=Th(s),[d,h]=fo({prop:n,onChange:i,defaultProp:a??"",caller:Bp});return f.jsx(Gre,{scope:r,baseId:ai(),value:d,onValueChange:h,orientation:o,dir:u,activationMode:l,children:f.jsx(ne.div,{dir:u,"data-orientation":o,...c,ref:t})})});PR.displayName=Bp;var jR="TabsList",ER=p.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...i}=e,a=Gw(jR,r),o=SR(r);return f.jsx(Hre,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:n,children:f.jsx(ne.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:t})})});ER.displayName=jR;var CR="TabsTrigger",OR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:i=!1,...a}=e,o=Gw(CR,r),s=SR(r),l=AR(o.baseId,n),c=TR(o.baseId,n),u=n===o.value;return f.jsx(Kre,{asChild:!0,...s,focusable:!i,active:u,children:f.jsx(ne.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...a,ref:t,onMouseDown:re(e.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?o.onValueChange(n):d.preventDefault()}),onKeyDown:re(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(n)}),onFocus:re(e.onFocus,()=>{const d=o.activationMode!=="manual";!u&&!i&&d&&o.onValueChange(n)})})})});OR.displayName=CR;var kR="TabsContent",NR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:i,children:a,...o}=e,s=Gw(kR,r),l=AR(s.baseId,n),c=TR(s.baseId,n),u=n===s.value,d=p.useRef(u);return p.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),f.jsx(mn,{present:i||u,children:({present:h})=>f.jsx(ne.div,{"data-state":u?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:h&&a})})});NR.displayName=kR;function AR(e,t){return`${e}-trigger-${t}`}function TR(e,t){return`${e}-content-${t}`}var Xre=PR,_R=ER,MR=OR,RR=NR;const Xw=Xre,Wp=p.forwardRef(({className:e,...t},r)=>f.jsx(_R,{ref:r,className:H("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Wp.displayName=_R.displayName;const tr=p.forwardRef(({className:e,...t},r)=>f.jsx(MR,{ref:r,className:H("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));tr.displayName=MR.displayName;const rn=p.forwardRef(({className:e,...t},r)=>f.jsx(RR,{ref:r,className:H("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));rn.displayName=RR.displayName;const Up=p.forwardRef(({className:e,type:t,...r},n)=>f.jsx("input",{type:t,className:H("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...r}));Up.displayName="Input";function DR({value:e,onValueChange:t,debounceMs:r=300,className:n,placeholder:i="Search...",...a}){const[o,s]=p.useState(e),l=p.useRef();p.useEffect(()=>{s(e)},[e]);const c=p.useCallback(u=>{const d=u.target.value;s(d),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{t(d)},r)},[t,r]);return p.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),f.jsxs("div",{className:"relative",children:[f.jsx(hk,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4 pointer-events-none"}),f.jsx(Up,{...a,value:o,onChange:c,placeholder:i,className:H("pl-10",n)})]})}function Zw(e){const t=typeof e=="string"?new Date(e):e,n=new Date().getTime()-t.getTime(),i=Math.floor(n/1e3),a=Math.floor(i/60),o=Math.floor(a/60);return i<60?`${i}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:t.toLocaleDateString()+" "+t.toLocaleTimeString()}function Zre({request:e,onClick:t,className:r}){const n=a=>a?a>=200&&a<300?"success":a>=300&&a<400?"secondary":a>=400&&a<500?"warning":a>=500?"destructive":"outline":"outline",i=a=>({GET:"secondary",POST:"default",PUT:"default",PATCH:"default",DELETE:"destructive"})[a]||"outline";return f.jsxs("div",{className:H("flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",r),onClick:t,children:[f.jsxs("div",{className:"flex items-center space-x-4",children:[f.jsx(Oe,{variant:i(e.method),children:e.method}),f.jsxs("div",{className:"flex flex-col",children:[f.jsx("span",{className:"font-mono text-sm",children:e.path}),f.jsxs("div",{className:"flex items-center space-x-2 text-xs text-muted-foreground",children:[f.jsx(Xs,{className:"h-3 w-3"}),f.jsx("span",{children:Zw(e.created_at)}),e.query_count>0&&f.jsxs(f.Fragment,{children:[f.jsx(Gc,{className:"h-3 w-3 ml-2"}),f.jsxs("span",{children:[e.query_count," queries"]})]}),e.has_exception&&f.jsxs(f.Fragment,{children:[f.jsx(Ah,{className:"h-3 w-3 ml-2 text-destructive"}),f.jsx("span",{className:"text-destructive",children:"Exception"})]})]})]})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[e.status_code&&f.jsx(Oe,{variant:n(e.status_code),children:e.status_code}),e.duration_ms&&f.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.duration_ms.toFixed(0),"ms"]}),f.jsx(dk,{className:"h-4 w-4"})]})]})}function IR(e,t=300){const[r,n]=p.useState(e);return p.useEffect(()=>{const i=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(i)}},[e,t]),r}function Jre(){const[e,t]=p.useState("all"),[r,n]=p.useState("all"),[i,a]=p.useState(""),[o,s]=p.useState("all"),{openDetail:l}=ko(),c=Pi(),u=IR(i,300),{data:d,refetch:h}=mt({queryKey:["all-requests",e,r,u],queryFn:()=>Ge.getRequests({limit:200,status_code:e!=="all"?g(e):void 0,method:r!=="all"?r:void 0,search:u||void 0}),refetchInterval:5e3}),m=(d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=200&&S.status_code<300).length)||0,y=(d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=400).length)||0,v=(d==null?void 0:d.filter(S=>S.duration_ms&&S.duration_ms>500).length)||0,x=o==="all"?d:o==="successful"?d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=200&&S.status_code<300):o==="failed"?d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=400):o==="slow"?d==null?void 0:d.filter(S=>S.duration_ms&&S.duration_ms>500):d,g=S=>{switch(S){case"2xx":return 200;case"3xx":return 300;case"4xx":return 400;case"5xx":return 500;default:return}},w=()=>{h()},b=()=>{if(x){const S=JSON.stringify(x,null,2),P=new Blob([S],{type:"application/json"}),j=URL.createObjectURL(P),E=document.createElement("a");E.href=j,E.download=`requests-${new Date().toISOString()}.json`,E.click()}};return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:c("pages.requests.title")}),f.jsx("p",{className:"text-muted-foreground",children:c("pages.requests.description")})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:c("common.filter")}),f.jsx(pt,{children:c("requests.filters.description")})]}),f.jsx(le,{children:f.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"search",children:c("common.search")}),f.jsx(DR,{id:"search",placeholder:c("requests.filters.searchPlaceholder"),value:i,onValueChange:a})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"status",children:c("requests.filters.status")}),f.jsxs(mo,{value:e,onValueChange:t,children:[f.jsx(pa,{id:"status",children:f.jsx(vo,{placeholder:c("requests.statusFilters.all")})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:c("requests.statusFilters.all")}),f.jsx(be,{value:"2xx",children:c("requests.statusFilters.success")}),f.jsx(be,{value:"3xx",children:c("requests.statusFilters.redirect")}),f.jsx(be,{value:"4xx",children:c("requests.statusFilters.clientErrors")}),f.jsx(be,{value:"5xx",children:c("requests.statusFilters.serverErrors")})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"method",children:c("requests.filters.method")}),f.jsxs(mo,{value:r,onValueChange:n,children:[f.jsx(pa,{id:"method",children:f.jsx(vo,{placeholder:c("requests.methodFilters.all")})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:c("requests.methodFilters.all")}),f.jsx(be,{value:"GET",children:c("requests.methodFilters.get")}),f.jsx(be,{value:"POST",children:c("requests.methodFilters.post")}),f.jsx(be,{value:"PUT",children:c("requests.methodFilters.put")}),f.jsx(be,{value:"PATCH",children:c("requests.methodFilters.patch")}),f.jsx(be,{value:"DELETE",children:c("requests.methodFilters.delete")})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:" "}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(pe,{variant:"outline",size:"icon",onClick:()=>h(),children:f.jsx(yc,{className:"h-4 w-4"})}),f.jsx(pe,{variant:"outline",size:"icon",onClick:b,children:f.jsx(mF,{className:"h-4 w-4"})}),f.jsxs(pe,{onClick:w,children:[f.jsx(vF,{className:"mr-2 h-4 w-4"}),"Apply Filters"]})]})]})]})})]}),f.jsxs(Xw,{value:o,onValueChange:s,className:"space-y-4",children:[f.jsxs(Wp,{children:[f.jsxs(tr,{value:"all",children:[c("requests.tabs.all"),d&&d.length>0&&f.jsx(Oe,{variant:"outline",className:"ml-2",children:d.length})]}),f.jsxs(tr,{value:"successful",children:[c("requests.tabs.successful"),m>0&&f.jsx(Oe,{variant:"outline",className:"ml-2",children:m})]}),f.jsxs(tr,{value:"failed",children:[c("requests.tabs.failed"),y>0&&f.jsx(Oe,{variant:"destructive",className:"ml-2",children:y})]}),f.jsxs(tr,{value:"slow",children:[c("requests.tabs.slow"),v>0&&f.jsx(Oe,{variant:"secondary",className:"ml-2",children:v})]})]}),f.jsx(rn,{value:o,className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsxs(ye,{children:[o==="all"&&c("requests.tabs.all"),o==="successful"&&c("requests.tabs.successful"),o==="failed"&&c("requests.tabs.failed"),o==="slow"&&c("requests.tabs.slow")]}),f.jsxs(pt,{children:[o==="all"&&c("requests.descriptions.all"),o==="successful"&&c("requests.descriptions.successful"),o==="failed"&&c("requests.descriptions.failed"),o==="slow"&&c("requests.descriptions.slow")]})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-2",children:[x==null?void 0:x.map(S=>f.jsx(Zre,{request:S,onClick:()=>l("request",S.request_id)},S.id)),(!x||x.length===0)&&f.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[o==="all"&&c("requests.empty.all"),o==="successful"&&c("requests.empty.successful"),o==="failed"&&c("requests.empty.failed"),o==="slow"&&c("requests.empty.slow")]})]})})]})})]})]})}function ene(e){return e?e<1e3?`${e.toFixed(0)}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`:"N/A"}function tne(e){switch(e.toLowerCase()){case"ok":case"success":return f.jsx(Mx,{className:"h-4 w-4 text-green-500"});case"error":case"failure":return f.jsx(Oo,{className:"h-4 w-4 text-red-500"});default:return f.jsx(Qc,{className:"h-4 w-4 text-blue-500"})}}function rne(e){switch(e.toLowerCase()){case"ok":case"success":return"default";case"error":case"failure":return"destructive";default:return"secondary"}}function nne({className:e}){const{openDetail:t}=ko(),[r,n]=p.useState({search:"",status:"all",service:"",hours:24,minDuration:0}),[i,a]=p.useState(0),o=50,{data:s=[],isLoading:l,error:c,refetch:u}=mt({queryKey:["traces",r,i],queryFn:()=>Ge.getTraces({limit:o,offset:i*o,status:r.status==="all"?void 0:r.status,service_name:r.service||void 0,min_duration_ms:r.minDuration||void 0,hours:r.hours}),refetchInterval:3e4}),d=h=>{t("trace",h.trace_id)};return c?f.jsx(se,{className:e,children:f.jsx(le,{className:"p-6",children:f.jsxs("div",{className:"text-center",children:[f.jsx(Oo,{className:"h-12 w-12 text-destructive mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Failed to load traces"}),f.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"There was an error loading the trace data."}),f.jsxs(pe,{onClick:()=>u(),children:[f.jsx(yc,{className:"h-4 w-4 mr-2"}),"Try again"]})]})})}):f.jsxs("div",{className:e,children:[f.jsx(se,{className:"mb-6",children:f.jsx(le,{className:"p-4",children:f.jsxs("div",{className:"flex flex-wrap gap-4",children:[f.jsx("div",{className:"flex-1 min-w-[200px]",children:f.jsxs("div",{className:"relative",children:[f.jsx(hk,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),f.jsx(Up,{placeholder:"Search by operation name...",value:r.search,onChange:h=>n({...r,search:h.target.value}),className:"pl-9"})]})}),f.jsxs(mo,{value:r.status,onValueChange:h=>n({...r,status:h}),children:[f.jsx(pa,{className:"w-[150px]",children:f.jsx(vo,{placeholder:"All statuses"})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:"All statuses"}),f.jsx(be,{value:"ok",children:"Success"}),f.jsx(be,{value:"error",children:"Error"})]})]}),f.jsxs(mo,{value:r.hours.toString(),onValueChange:h=>n({...r,hours:parseInt(h)}),children:[f.jsx(pa,{className:"w-[150px]",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1",children:"Last hour"}),f.jsx(be,{value:"6",children:"Last 6 hours"}),f.jsx(be,{value:"24",children:"Last 24 hours"}),f.jsx(be,{value:"168",children:"Last week"})]})]}),f.jsxs(pe,{onClick:()=>u(),size:"sm",variant:"outline",children:[f.jsx(yc,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})})}),f.jsx(se,{children:f.jsxs(le,{className:"p-0",children:[l?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"space-y-4",children:[...Array(5)].map((h,m)=>f.jsx("div",{className:"animate-pulse",children:f.jsx("div",{className:"h-16 bg-muted rounded"})},m))})}):s.length===0?f.jsxs("div",{className:"p-6 text-center text-muted-foreground",children:[f.jsx(Qc,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),f.jsx("p",{children:"No traces found matching your criteria."})]}):f.jsx("div",{className:"divide-y",children:s.map(h=>f.jsx("div",{className:"p-4 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>d(h),children:f.jsx("div",{className:"flex items-start justify-between",children:f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[tne(h.status),f.jsx("h3",{className:"font-medium truncate",children:h.operation_name||"Unknown Operation"}),f.jsx(Oe,{variant:rne(h.status),className:"text-xs",children:h.status})]}),f.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[f.jsxs("span",{children:["Service: ",h.service_name||"Unknown"]}),f.jsxs("span",{children:["Spans: ",h.span_count]}),f.jsxs("span",{children:["Duration: ",ene(h.duration_ms)]})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[f.jsx(Xs,{className:"h-3 w-3"}),f.jsx("span",{children:uW(new Date(h.start_time),{addSuffix:!0})}),f.jsx("span",{className:"text-muted-foreground/60",children:"•"}),f.jsxs("span",{children:[h.trace_id.slice(0,8),"..."]})]})]})})},h.trace_id))}),s.length===o&&f.jsx("div",{className:"p-4 border-t flex justify-center",children:f.jsx(pe,{variant:"outline",onClick:()=>a(i+1),children:"Load more"})})]})})]})}function ine(){const e=Pi();return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:e("pages.tracing.title")}),f.jsx("p",{className:"text-muted-foreground",children:e("pages.tracing.description")})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:e("pages.tracing.tracesCardTitle")}),f.jsx(pt,{children:e("pages.tracing.tracesCardDescription")})]}),f.jsx(le,{children:f.jsx(nne,{})})]})]})}function ane(){const[e,t]=p.useState("1h"),[r,n]=p.useState(5e3),{openDetail:i}=ko(),a=Pi(),o=e==="1h"?1:e==="24h"?24:168,{data:s}=mt({queryKey:["performance-stats",e],queryFn:()=>Ge.getStats(o),refetchInterval:r}),{data:l}=mt({queryKey:["performance-requests",e],queryFn:()=>Ge.getRequests({limit:100}),refetchInterval:r}),{data:c}=mt({queryKey:["performance-queries",e],queryFn:()=>Ge.getQueries({limit:100}),refetchInterval:r}),{data:u}=mt({queryKey:["performance-exceptions",e],queryFn:()=>Ge.getExceptions({limit:100}),refetchInterval:r}),d=XN({requests:l,queries:c,exceptions:u,stats:s}),h=[{type:"successRate",label:a("metrics.successRate"),value:d.successRate,status:d.successRate>=99?"success":d.successRate>=95?"warning":"error",description:`${a("common.all")} ${d.totalRequests} ${a("metrics.totalRequests").toLowerCase()}`},{type:"avgResponseTime",label:a("metrics.avgResponseTime"),value:Jt(d.avgResponseTime),rawValue:d.avgResponseTime,status:!d.avgResponseTime||d.avgResponseTime<100?"success":d.avgResponseTime<300?"warning":"error"},{type:"errorRate",label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`,rawValue:d.errorRate,status:d.errorRate<=1?"success":d.errorRate<=2?"warning":"error"},{type:"queryPerformance",label:a("performance.queryPerformance"),value:Jt(d.avgQueryTime),rawValue:d.avgQueryTime,status:!d.avgQueryTime||d.avgQueryTime<50?"success":d.avgQueryTime<100?"warning":"error"}],m=d.endpointMetrics.slice(0,10).map(v=>({name:v.name,responseTime:v.avgResponseTime,calls:v.calls})),y=[{category:a("requests.statusFilters.clientErrors"),count:(l==null?void 0:l.filter(v=>v.status_code&&v.status_code>=400&&v.status_code<500).length)||0},{category:a("requests.statusFilters.serverErrors"),count:(l==null?void 0:l.filter(v=>v.status_code&&v.status_code>=500).length)||0},{category:a("metrics.exceptions"),count:d.totalExceptions}];return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:a("pages.performance.title")}),f.jsx("p",{className:"text-muted-foreground",children:a("pages.performance.description")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(mo,{value:e,onValueChange:t,children:[f.jsx(pa,{className:"w-32",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1h",children:a("timeRange.lastHour")}),f.jsx(be,{value:"24h",children:a("timeRange.last24Hours")}),f.jsx(be,{value:"7d",children:a("timeRange.last7Days")})]})]}),f.jsxs(mo,{value:r.toString(),onValueChange:v=>n(parseInt(v)),children:[f.jsx(pa,{className:"w-40",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsxs(be,{value:"5000",children:[a("common.refresh"),": 5s"]}),f.jsxs(be,{value:"10000",children:[a("common.refresh"),": 10s"]}),f.jsxs(be,{value:"30000",children:[a("common.refresh"),": 30s"]}),f.jsxs(be,{value:"0",children:[a("common.refresh"),": ",a("common.no")]})]})]})]})]}),f.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:h.map(v=>f.jsxs(se,{children:[f.jsxs(ge,{className:"pb-2",children:[f.jsx(ye,{className:"text-sm font-medium",children:v.label}),v.description&&f.jsx(pt,{className:"text-xs",children:v.description})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[f.jsx("div",{className:"text-2xl font-bold tabular-nums",children:v.value}),f.jsx(xf,{status:v.status,label:v.status==="success"?a("performance.excellent"):v.status==="warning"?a("performance.acceptable"):a("performance.needsAttention"),compact:!0}),v.rawValue!==void 0&&f.jsx(Id,{label:"",value:v.type==="successRate"||v.type==="errorRate"?v.rawValue:v.type==="avgResponseTime"?Math.min(v.rawValue/1e3*100,100):v.type==="queryPerformance"?Math.min(v.rawValue/200*100,100):0,max:100,showPercentage:!1,compact:!0,status:v.status==="success"?"success":v.status==="warning"?"warning":"danger"})]})})]},v.label))}),f.jsxs(Xw,{defaultValue:"overview",className:"space-y-4",children:[f.jsxs(Wp,{children:[f.jsx(tr,{value:"overview",children:a("performance.overview")}),f.jsx(tr,{value:"endpoints",children:a("performance.endpointPerformance")}),f.jsx(tr,{value:"queries",children:a("nav.database")}),f.jsx(tr,{value:"errors",children:a("performance.errorAnalysis")})]}),f.jsxs(rn,{value:"overview",className:"space-y-4",children:[f.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("metrics.responseTime")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.p50Median"),value:Jt(d.responseTimePercentiles.p50)}),f.jsx(at,{label:a("performance.p95"),value:Jt(d.responseTimePercentiles.p95)}),f.jsx(at,{label:a("performance.p99"),value:Jt(d.responseTimePercentiles.p99)}),f.jsx(PW,{value:d.avgResponseTime||0,max:1e3,label:a("performance.average"),thresholds:[{value:100,label:"100ms"},{value:300,label:"300ms"},{value:1e3,label:"1s"}]})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("performance.throughput")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.requestsPerSec"),value:d.requestsPerSecond.toFixed(1)}),f.jsx(at,{label:a("metrics.totalRequests"),value:gS(s==null?void 0:s.total_requests)}),f.jsx(at,{label:a("performance.totalQueries"),value:gS(s==null?void 0:s.total_queries)}),f.jsx(at,{label:a("performance.queriesPerRequest"),value:s!=null&&s.total_queries&&(s!=null&&s.total_requests)?(s.total_queries/s.total_requests).toFixed(1):"0"})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("performance.errorAnalysis")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(nA,{value:100-d.errorRate,size:"sm",label:a("performance.healthScore")}),f.jsx(at,{label:a("requests.tabs.failed"),value:d.failedRequests}),f.jsx(at,{label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`}),f.jsx(at,{label:a("metrics.exceptions"),value:d.totalExceptions})]})]})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.performanceSummary")}),f.jsxs(pt,{children:[a("performance.realTimeMetrics")," ",d.totalRequests," ",a("performance.recentRequests")]})]}),f.jsx(le,{children:f.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:[f.jsx(Zr,{label:a("metrics.successRate"),value:`${d.successRate.toFixed(1)}%`,minimal:!0}),f.jsx(Zr,{label:a("performance.avgResponse"),value:Jt(d.avgResponseTime),minimal:!0}),f.jsx(Zr,{label:a("performance.slowRequests"),value:d.slowRequests,minimal:!0}),f.jsx(Zr,{label:a("performance.activeEndpoints"),value:d.endpointMetrics.length,minimal:!0})]})})]})]}),f.jsx(rn,{value:"endpoints",className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.endpointPerformance")}),f.jsx(pt,{children:a("performance.performanceBreakdown")})]}),f.jsxs(le,{className:"space-y-6",children:[m.length>0&&f.jsx(Nre,{title:a("performance.responseTimesByEndpoint"),data:m,bars:[{dataKey:"responseTime",name:a("metrics.avgResponseTime")}],height:300,formatter:"duration",minimal:!0,horizontal:!0}),f.jsxs("div",{className:"space-y-4",children:[f.jsx("h4",{className:"text-sm font-medium",children:a("performance.detailedMetrics")}),d.endpointMetrics.map(v=>f.jsxs("div",{className:"space-y-2 p-3 border rounded-lg",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("code",{className:"text-sm font-mono",children:v.name}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Oe,{variant:"outline",children:[v.calls," ",a("performance.calls")]}),v.errors>0&&f.jsxs(Oe,{variant:"destructive",children:[v.errors," ",a("performance.errors")]})]})]}),f.jsx(Id,{label:`${v.avgResponseTime}ms average`,value:Math.min(v.avgResponseTime/500*100,100),showPercentage:!1,sublabel:`${a("performance.successRate")}: ${v.successRate}%`,compact:!0})]},v.name)),d.endpointMetrics.length===0&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:a("performance.noEndpointData")})]})]})]})}),f.jsx(rn,{value:"queries",className:"space-y-4",children:f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsx(ge,{children:f.jsx(ye,{children:a("performance.queryStatistics")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.totalQueries"),value:d.totalQueries}),f.jsx(at,{label:a("performance.slowQueries"),value:d.slowQueries}),f.jsx(at,{label:a("performance.avgQueryTime"),value:Jt(d.avgQueryTime)}),f.jsx(Id,{label:"Query Performance Score",value:d.avgQueryTime?100-Math.min(d.avgQueryTime/200*100,100):100,status:!d.avgQueryTime||d.avgQueryTime<50?"success":d.avgQueryTime<100?"warning":"danger"})]})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.slowQueriesTitle")}),f.jsxs(pt,{children:[a("database.slowThreshold"),": 100ms"]})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.filter(v=>v.duration_ms&&v.duration_ms>100).slice(0,5).map(v=>f.jsxs("div",{className:"text-xs cursor-pointer hover:bg-muted/50 p-2 rounded transition-colors",onClick:()=>i("request",v.request_id),children:[f.jsx("code",{className:"block truncate",children:v.sql}),f.jsxs("div",{className:"flex items-center justify-between mt-1",children:[f.jsx("span",{className:"text-muted-foreground",children:new Date(v.created_at).toLocaleTimeString()}),f.jsx(Oe,{variant:"outline",className:"text-xs",children:Jt(v.duration_ms)})]})]},v.id)),(!c||c.filter(v=>v.duration_ms&&v.duration_ms>100).length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No slow queries detected"})]})})]})]})}),f.jsx(rn,{value:"errors",className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.errorAnalysisTitle")}),f.jsx(pt,{children:a("performance.errorAnalysis")})]}),f.jsxs(le,{className:"space-y-6",children:[f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsx(Zr,{label:a("requests.tabs.failed"),value:d.failedRequests,minimal:!0}),f.jsx(Zr,{label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`,minimal:!0}),f.jsx(Zr,{label:a("metrics.exceptions"),value:d.totalExceptions,minimal:!0})]}),f.jsx(hR,{data:y}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("h4",{className:"text-sm font-medium",children:"Recent Exceptions"}),u==null?void 0:u.slice(0,10).map(v=>f.jsx(xf,{status:"error",label:v.exception_type,description:v.exception_value||void 0,value:new Date(v.created_at).toLocaleTimeString(),className:"cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>i("request",v.request_id)},v.id)),(!u||u.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:a("performance.noExceptionsCaptured")})]})]})]})})]})]})}var one="Separator",lE="horizontal",sne=["horizontal","vertical"],LR=p.forwardRef((e,t)=>{const{decorative:r,orientation:n=lE,...i}=e,a=lne(n)?n:lE,s=r?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return f.jsx(ne.div,{"data-orientation":a,...s,...i,ref:t})});LR.displayName=one;function lne(e){return sne.includes(e)}var $R=LR;const cs=p.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},i)=>f.jsx($R,{ref:i,decorative:r,orientation:t,className:H("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));cs.displayName=$R.displayName;function cne(){const{theme:e,setTheme:t}=Xc(),{t:r}=Dx(),{language:n,setLanguage:i}=TF(),{data:a,isLoading:o}=mt({queryKey:["settings-stats"],queryFn:()=>Ge.getStats(24*7),refetchInterval:3e4}),s=async()=>{confirm("Are you sure you want to clear all captured data?")&&(await Ge.clearData(),window.location.reload())},l=async c=>{const u=c/24,d=u===1?"1 day":`${u} days`;confirm(`Are you sure you want to clear data older than ${d}?`)&&(await Ge.clearData(c),window.location.reload())};return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("pages.settings.title")}),f.jsx("p",{className:"text-muted-foreground",children:r("pages.settings.description")})]}),f.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.appearance.title")}),f.jsx(pt,{children:r("settings.appearance.description")})]}),f.jsx(le,{className:"space-y-4",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.appearance.theme")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.appearance.themeDescription")}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(pe,{variant:e==="light"?"default":"outline",size:"sm",onClick:()=>t("light"),children:[f.jsx(pk,{className:"mr-2 h-4 w-4"}),r("settings.appearance.light")]}),f.jsxs(pe,{variant:e==="dark"?"default":"outline",size:"sm",onClick:()=>t("dark"),children:[f.jsx(fk,{className:"mr-2 h-4 w-4"}),r("settings.appearance.dark")]})]})]})})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.language.title")}),f.jsx(pt,{children:r("settings.language.description")})]}),f.jsx(le,{className:"space-y-4",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.language.current")}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(pe,{variant:n==="en"?"default":"outline",size:"sm",onClick:()=>i("en"),children:[f.jsx($1,{className:"mr-2 h-4 w-4"}),r("settings.language.english")]}),f.jsxs(pe,{variant:n==="zh"?"default":"outline",size:"sm",onClick:()=>i("zh"),children:[f.jsx($1,{className:"mr-2 h-4 w-4"}),r("settings.language.chinese")]})]})]})})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.database.title")}),f.jsx(pt,{children:r("settings.database.description")})]}),f.jsx(le,{className:"space-y-3",children:o?f.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:r("settings.database.loading")}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalRequests")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_requests)!==void 0?a.total_requests.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalQueries")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_queries)!==void 0?a.total_queries.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalExceptions")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_exceptions)!==void 0?a.total_exceptions.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.slowQueries")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.slow_queries)!==void 0?a.slow_queries.toLocaleString():"—"})]}),f.jsx(cs,{}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.avgResponseTime")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.avg_response_time)!==null&&(a==null?void 0:a.avg_response_time)!==void 0?`${Math.round(a.avg_response_time)}ms`:"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.requestsPerMinute")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.requests_per_minute)!==void 0?a.requests_per_minute.toFixed(1):"—"})]})]})})]}),f.jsxs(se,{className:"md:col-span-2",children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.dataManagement.title")}),f.jsx(pt,{children:r("settings.dataManagement.description")})]}),f.jsxs(le,{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.dataManagement.quickActions")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.dataManagement.quickActionsDescription")}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear1Day")]}),f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24*7),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear7Days")]}),f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24*30),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear30Days")]})]})]}),f.jsx(cs,{}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.dataManagement.dangerZone")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.dataManagement.dangerZoneDescription")}),f.jsxs(pe,{variant:"destructive",onClick:s,children:[f.jsx(Oo,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clearAll")]})]})]})]}),f.jsxs(se,{className:"md:col-span-2",children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.about.title")}),f.jsx(pt,{children:r("settings.about.description")})]}),f.jsxs(le,{className:"space-y-4",children:[f.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.jsx("p",{className:"mb-2",children:r("settings.about.content")}),f.jsx("p",{children:f.jsxs("strong",{children:[r("settings.about.features"),":"]})}),f.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-1",children:[f.jsx("li",{children:r("settings.about.feature1")}),f.jsx("li",{children:r("settings.about.feature2")}),f.jsx("li",{children:r("settings.about.feature3")}),f.jsx("li",{children:r("settings.about.feature4")}),f.jsx("li",{children:r("settings.about.feature5")})]})]}),f.jsx(cs,{}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:r("settings.about.version")}),f.jsx("span",{className:"font-medium",children:"0.1.7"})]}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:r("settings.about.dashboard")}),f.jsxs("span",{className:"font-medium",children:[f.jsx(Gc,{className:"inline h-3 w-3 mr-1"}),r("settings.about.connected")]})]})]})]})]})]})}var Hp="Dialog",[FR]=Ln(Hp),[une,vn]=FR(Hp),zR=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=p.useRef(null),l=p.useRef(null),[c,u]=fo({prop:n,defaultProp:i??!1,onChange:a,caller:Hp});return f.jsx(une,{scope:t,triggerRef:s,contentRef:l,contentId:ai(),titleId:ai(),descriptionId:ai(),open:c,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),modal:o,children:r})};zR.displayName=Hp;var BR="DialogTrigger",dne=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(BR,r),a=me(t,i.triggerRef);return f.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":tb(i.open),...n,ref:a,onClick:re(e.onClick,i.onOpenToggle)})});dne.displayName=BR;var Jw="DialogPortal",[fne,WR]=FR(Jw,{forceMount:void 0}),UR=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:i}=e,a=vn(Jw,t);return f.jsx(fne,{scope:t,forceMount:r,children:p.Children.map(n,o=>f.jsx(mn,{present:r||a.open,children:f.jsx($h,{asChild:!0,container:i,children:o})}))})};UR.displayName=Jw;var lh="DialogOverlay",HR=p.forwardRef((e,t)=>{const r=WR(lh,e.__scopeDialog),{forceMount:n=r.forceMount,...i}=e,a=vn(lh,e.__scopeDialog);return a.modal?f.jsx(mn,{present:n||a.open,children:f.jsx(pne,{...i,ref:t})}):null});HR.displayName=lh;var hne=Ns("DialogOverlay.RemoveScroll"),pne=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(lh,r);return f.jsx(Kx,{as:hne,allowPinchZoom:!0,shards:[i.contentRef],children:f.jsx(ne.div,{"data-state":tb(i.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),jo="DialogContent",KR=p.forwardRef((e,t)=>{const r=WR(jo,e.__scopeDialog),{forceMount:n=r.forceMount,...i}=e,a=vn(jo,e.__scopeDialog);return f.jsx(mn,{present:n||a.open,children:a.modal?f.jsx(mne,{...i,ref:t}):f.jsx(vne,{...i,ref:t})})});KR.displayName=jo;var mne=p.forwardRef((e,t)=>{const r=vn(jo,e.__scopeDialog),n=p.useRef(null),i=me(t,r.contentRef,n);return p.useEffect(()=>{const a=n.current;if(a)return Jk(a)},[]),f.jsx(VR,{...e,ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:re(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:re(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:re(e.onFocusOutside,a=>a.preventDefault())})}),vne=p.forwardRef((e,t)=>{const r=vn(jo,e.__scopeDialog),n=p.useRef(!1),i=p.useRef(!1);return f.jsx(VR,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=e.onCloseAutoFocus)==null||o.call(e,a),a.defaultPrevented||(n.current||(s=r.triggerRef.current)==null||s.focus(),a.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:a=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),VR=p.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=vn(jo,r),l=p.useRef(null),c=me(t,l);return bk(),f.jsxs(f.Fragment,{children:[f.jsx(Ix,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:a,children:f.jsx(_h,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":tb(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(gne,{titleId:s.titleId}),f.jsx(xne,{contentRef:l,descriptionId:s.descriptionId})]})]})}),eb="DialogTitle",qR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(eb,r);return f.jsx(ne.h2,{id:i.titleId,...n,ref:t})});qR.displayName=eb;var YR="DialogDescription",QR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(YR,r);return f.jsx(ne.p,{id:i.descriptionId,...n,ref:t})});QR.displayName=YR;var GR="DialogClose",XR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(GR,r);return f.jsx(ne.button,{type:"button",...n,ref:t,onClick:re(e.onClick,()=>i.onOpenChange(!1))})});XR.displayName=GR;function tb(e){return e?"open":"closed"}var ZR="DialogTitleWarning",[qie,JR]=IF(ZR,{contentName:jo,titleName:eb,docsSlug:"dialog"}),gne=({titleId:e})=>{const t=JR(ZR),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
314
+ */var wu=p;function Pte(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jte=typeof Object.is=="function"?Object.is:Pte,Ete=wu.useSyncExternalStore,Cte=wu.useRef,Ote=wu.useEffect,kte=wu.useMemo,Nte=wu.useDebugValue;Ste.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=Cte(null);if(a.current===null){var o={hasValue:!1,value:null};a.current=o}else o=a.current;a=kte(function(){function l(m){if(!c){if(c=!0,u=m,m=n(m),i!==void 0&&o.hasValue){var y=o.value;if(i(y,m))return d=y}return d=m}if(y=d,jte(u,m))return y;var v=n(m);return i!==void 0&&i(y,v)?(u=m,y):(u=m,d=v)}var c=!1,u,d,h=r===void 0?null:r;return[function(){return l(t())},h===null?void 0:function(){return l(h())}]},[t,r,n,i]);var s=Ete(e,a[0],a[1]);return Ote(function(){o.hasValue=!0,o.value=s},[s]),Nte(s),s};function Ate(e){e()}function Tte(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Ate(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const i=t={callback:r,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!n||e===null||(n=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var iE={notify(){},get:()=>[]};function _te(e,t){let r,n=iE,i=0,a=!1;function o(v){u();const x=n.subscribe(v);let g=!1;return()=>{g||(g=!0,x(),d())}}function s(){n.notify()}function l(){y.onStateChange&&y.onStateChange()}function c(){return a}function u(){i++,r||(r=e.subscribe(l),n=Tte())}function d(){i--,r&&i===0&&(r(),r=void 0,n.clear(),n=iE)}function h(){a||(a=!0,u())}function m(){a&&(a=!1,d())}const y={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:l,isSubscribed:c,trySubscribe:h,tryUnsubscribe:m,getListeners:()=>n};return y}var Mte=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Rte=Mte(),Dte=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Ite=Dte(),Lte=()=>Rte||Ite?p.useLayoutEffect:p.useEffect,$te=Lte(),av=Symbol.for("react-redux-context"),ov=typeof globalThis<"u"?globalThis:{};function Fte(){if(!p.createContext)return{};const e=ov[av]??(ov[av]=new Map);let t=e.get(p.createContext);return t||(t=p.createContext(null),e.set(p.createContext,t)),t}var zte=Fte();function Bte(e){const{children:t,context:r,serverState:n,store:i}=e,a=p.useMemo(()=>{const l=_te(i);return{store:i,subscription:l,getServerState:n?()=>n:void 0}},[i,n]),o=p.useMemo(()=>i.getState(),[i]);$te(()=>{const{subscription:l}=a;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),o!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[a,o]);const s=r||zte;return p.createElement(s.Provider,{value:a},t)}var Wte=Bte,Ute=(e,t)=>t,Vw=_([Ute,de,Y_,ut,q2,Ni,yQ,yt],PQ),qw=e=>{var t=e.currentTarget.getBoundingClientRect(),r=t.width/e.currentTarget.offsetWidth,n=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/r),chartY:Math.round((e.clientY-t.top)/n)}},nR=Br("mouseClick"),iR=ru();iR.startListening({actionCreator:nR,effect:(e,t)=>{var r=e.payload,n=Vw(t.getState(),qw(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(OY({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var wy=Br("mouseMove"),aR=ru();aR.startListening({actionCreator:wy,effect:(e,t)=>{var r=e.payload,n=t.getState(),i=yw(n,n.tooltip.settings.shared),a=Vw(n,qw(r));i==="axis"&&((a==null?void 0:a.activeIndex)!=null?t.dispatch(z2({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):t.dispatch(F2()))}});var aE={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index"},oR=Cr({name:"rootProps",initialState:aE,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:aE.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className}}}),Hte=oR.reducer,{updateOptions:Kte}=oR.actions,sR=Cr({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:Vie}=sR.actions,Vte=sR.reducer,lR=Br("keyDown"),cR=Br("focus"),Yw=ru();Yw.startListening({actionCreator:lR,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip,a=e.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=Number(xw(i,ul(r))),s=Ni(r);if(a==="Enter"){var l=Xf(r,"axis","hover",String(i.index));t.dispatch(uy({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:l}));return}var c=yY(r),u=c==="left-to-right"?1:-1,d=a==="ArrowRight"?1:-1,h=o+d*u;if(!(s==null||h>=s.length||h<0)){var m=Xf(r,"axis","hover",String(h));t.dispatch(uy({active:!0,activeIndex:h.toString(),activeDataKey:void 0,activeCoordinate:m}))}}}}});Yw.startListening({actionCreator:cR,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;if(!i.active&&i.index==null){var a="0",o=Xf(r,"axis","hover",String(a));t.dispatch(uy({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Ar=Br("externalEvent"),uR=ru();uR.startListening({actionCreator:Ar,effect:(e,t)=>{if(e.payload.handler!=null){var r=t.getState(),n={activeCoordinate:cQ(r),activeDataKey:X2(r),activeIndex:bo(r),activeLabel:G2(r),activeTooltipIndex:bo(r),isTooltipActive:uQ(r)};e.payload.handler(n,e.payload.reactEvent)}}});var qte=_([cl],e=>e.tooltipItemPayloads),Yte=_([qte,gu,(e,t,r)=>t,(e,t,r)=>r],(e,t,r,n)=>{var i=e.find(s=>s.settings.dataKey===n);if(i!=null){var{positions:a}=i;if(a!=null){var o=t(a,r);return o}}}),dR=Br("touchMove"),fR=ru();fR.startListening({actionCreator:dR,effect:(e,t)=>{var r=e.payload,n=t.getState(),i=yw(n,n.tooltip.settings.shared);if(i==="axis"){var a=Vw(n,qw({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY,currentTarget:r.currentTarget}));(a==null?void 0:a.activeIndex)!=null&&t.dispatch(z2({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,s=r.touches[0],l=document.elementFromPoint(s.clientX,s.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(q9),u=(o=l.getAttribute(Y9))!==null&&o!==void 0?o:void 0,d=Yte(t.getState(),c,u);t.dispatch($2({activeDataKey:u,activeIndex:c,activeCoordinate:d}))}}});var Qte=iT({brush:aJ,cartesianAxis:$X,chartData:$Q,errorBars:nZ,graphicalItems:kX,layout:g9,legend:dH,options:MQ,polarAxis:tX,polarOptions:Vte,referenceElements:fJ,rootProps:Hte,tooltip:kY}),Gte=function(t){return WU({reducer:Qte,preloadedState:t,middleware:r=>r({serializableCheck:!1}).concat([iR.middleware,aR.middleware,Yw.middleware,uR.middleware,fR.middleware]),devTools:Pa.devToolsEnabled})};function Xte(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,i=$t(),a=p.useRef(null);if(i)return r;a.current==null&&(a.current=Gte(t));var o=w0;return p.createElement(Wte,{context:o,store:a.current},r)}function Zte(e){var{layout:t,width:r,height:n,margin:i}=e,a=tt(),o=$t();return p.useEffect(()=>{o||(a(p9(t)),a(m9({width:r,height:n})),a(h9(i)))},[a,o,t,r,n,i]),null}function Jte(e){var t=tt();return p.useEffect(()=>{t(Kte(e))},[t,e]),null}var ere=["children"];function tre(e,t){if(e==null)return{};var r,n,i=rre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function rre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function sh(){return sh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sh.apply(null,arguments)}var nre={width:"100%",height:"100%"},ire=p.forwardRef((e,t)=>{var r=A0(),n=T0(),i=RT();if(!Df(r)||!Df(n))return null;var{children:a,otherAttributes:o,title:s,desc:l}=e,c,u;return typeof o.tabIndex=="number"?c=o.tabIndex:c=i?0:void 0,typeof o.role=="string"?u=o.role:u=i?"application":void 0,p.createElement(i0,sh({},o,{title:s,desc:l,role:u,tabIndex:c,width:r,height:n,style:nre,ref:t}),a)}),are=e=>{var{children:t}=e,r=Z(xp);if(!r)return null;var{width:n,height:i,y:a,x:o}=r;return p.createElement(i0,{width:n,height:i,x:o,y:a},t)},oE=p.forwardRef((e,t)=>{var{children:r}=e,n=tre(e,ere),i=$t();return i?p.createElement(are,null,r):p.createElement(ire,sh({ref:t},n),r)});function ore(){var e=tt(),[t,r]=p.useState(null),n=Z(V9);return p.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),a=i.width/t.offsetWidth;At(a)&&a!==n&&e(v9(a))}},[t,e,n]),r}function sE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function sre(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sE(Object(r),!0).forEach(function(n){lre(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sE(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function lre(e,t,r){return(t=cre(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cre(e){var t=ure(e,"string");return typeof t=="symbol"?t:t+""}function ure(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var dre=p.forwardRef((e,t)=>{var{children:r,className:n,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:d,onMouseUp:h,onTouchEnd:m,onTouchMove:y,onTouchStart:v,style:x,width:g}=e,w=tt(),[b,S]=p.useState(null),[P,j]=p.useState(null);qQ();var E=ore(),C=p.useCallback(Y=>{E(Y),typeof t=="function"&&t(Y),S(Y),j(Y)},[E,t,S,j]),N=p.useCallback(Y=>{w(nR(Y)),w(Ar({handler:a,reactEvent:Y}))},[w,a]),k=p.useCallback(Y=>{w(wy(Y)),w(Ar({handler:c,reactEvent:Y}))},[w,c]),A=p.useCallback(Y=>{w(F2()),w(Ar({handler:u,reactEvent:Y}))},[w,u]),T=p.useCallback(Y=>{w(wy(Y)),w(Ar({handler:d,reactEvent:Y}))},[w,d]),D=p.useCallback(()=>{w(cR())},[w]),L=p.useCallback(Y=>{w(lR(Y.key))},[w]),q=p.useCallback(Y=>{w(Ar({handler:o,reactEvent:Y}))},[w,o]),F=p.useCallback(Y=>{w(Ar({handler:s,reactEvent:Y}))},[w,s]),B=p.useCallback(Y=>{w(Ar({handler:l,reactEvent:Y}))},[w,l]),M=p.useCallback(Y=>{w(Ar({handler:h,reactEvent:Y}))},[w,h]),I=p.useCallback(Y=>{w(Ar({handler:v,reactEvent:Y}))},[w,v]),W=p.useCallback(Y=>{w(dR(Y)),w(Ar({handler:y,reactEvent:Y}))},[w,y]),te=p.useCallback(Y=>{w(Ar({handler:m,reactEvent:Y}))},[w,m]);return p.createElement(iM.Provider,{value:b},p.createElement(uA.Provider,{value:P},p.createElement("div",{className:he("recharts-wrapper",n),style:sre({position:"relative",cursor:"default",width:g,height:i},x),onClick:N,onContextMenu:q,onDoubleClick:F,onFocus:D,onKeyDown:L,onMouseDown:B,onMouseEnter:k,onMouseLeave:A,onMouseMove:T,onMouseUp:M,onTouchEnd:te,onTouchMove:W,onTouchStart:I,ref:C},r)))}),fre=["children","className","width","height","style","compact","title","desc"];function hre(e,t){if(e==null)return{};var r,n,i=pre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function pre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var mre=p.forwardRef((e,t)=>{var{children:r,className:n,width:i,height:a,style:o,compact:s,title:l,desc:c}=e,u=hre(e,fre),d=Fn(u);return s?p.createElement(oE,{otherAttributes:d,title:l,desc:c},r):p.createElement(dre,{className:n,style:o,width:i,height:a,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},p.createElement(oE,{otherAttributes:d,title:l,desc:c,ref:t},p.createElement(pJ,null,r)))}),vre=["width","height"];function by(){return by=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},by.apply(null,arguments)}function gre(e,t){if(e==null)return{};var r,n,i=yre(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function yre(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var xre={top:5,right:5,bottom:5,left:5},wre={accessibilityLayer:!0,layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:xre,reverseStackOrder:!1,syncMethod:"index"},Qw=p.forwardRef(function(t,r){var n,i=Ft(t.categoricalChartProps,wre),{width:a,height:o}=i,s=gre(i,vre);if(!Df(a)||!Df(o))return null;var{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,categoricalChartProps:h}=t,m={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return p.createElement(Xte,{preloadedState:{options:m},reduxStoreName:(n=h.id)!==null&&n!==void 0?n:l},p.createElement(iJ,{chartData:h.data}),p.createElement(Zte,{width:a,height:o,layout:i.layout,margin:i.margin}),p.createElement(Jte,{accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className}),p.createElement(mre,by({},s,{width:a,height:o,ref:r})))}),bre=["axis"],Sre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:bre,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t})),Pre=["axis","item"],jre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Pre,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t})),Ere=["axis"],Cre=p.forwardRef((e,t)=>p.createElement(Qw,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Ere,tooltipPayloadSearcher:Ow,categoricalChartProps:e,ref:t}));function Ore({title:e,description:t,data:r,lines:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u}){const{theme:d}=Xc(),h=d==="dark"?Ts.dark:Ts.light,m=Xx[c],y=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(Sre,{data:r,margin:{top:5,right:5,left:0,bottom:5},children:[s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:h.grid,vertical:!1,strokeOpacity:.5}),f.jsx(Mc,{dataKey:i,stroke:h.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:h.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:m,width:45}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"line",wrapperStyle:{fontSize:11}}),n.map((v,x)=>f.jsx(YM,{type:"monotone",dataKey:v.dataKey,name:v.name||v.dataKey,stroke:v.color||(x===0?h.primary:h.secondary),strokeWidth:v.strokeWidth||2,strokeDasharray:v.strokeDasharray,dot:v.dot===!0?{r:3}:!1,activeDot:v.dot!==!1?{r:4}:!1},v.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:y})}function kre({title:e,description:t,data:r,areas:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u,stacked:d=!1}){const{theme:h}=Xc(),m=h==="dark"?Ts.dark:Ts.light,y=Xx[c],v=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(Cre,{data:r,margin:{top:5,right:5,left:0,bottom:5},children:[f.jsx("defs",{children:n.map((x,g)=>f.jsxs("linearGradient",{id:`gradient-${x.dataKey}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"5%",stopColor:x.color||(g===0?m.primary:m.secondary),stopOpacity:.3}),f.jsx("stop",{offset:"95%",stopColor:x.color||(g===0?m.primary:m.secondary),stopOpacity:0})]},`gradient-${x.dataKey}`))}),s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:m.grid,vertical:!1,strokeOpacity:.5}),f.jsx(Mc,{dataKey:i,stroke:m.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:m.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:y,width:45}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"line",wrapperStyle:{fontSize:11}}),n.map((x,g)=>f.jsx(rR,{type:"monotone",dataKey:x.dataKey,name:x.name||x.dataKey,stackId:d?"1":x.stackId,stroke:x.color||(g===0?m.primary:m.secondary),strokeWidth:2,fill:`url(#gradient-${x.dataKey})`,fillOpacity:x.fillOpacity||1},x.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:v})}function Nre({title:e,description:t,data:r,bars:n,xDataKey:i="name",height:a=250,minimal:o=!1,showGrid:s=!0,showLegend:l=!1,formatter:c="number",className:u,stacked:d=!1,horizontal:h=!1}){const{theme:m}=Xc(),y=m==="dark"?Ts.dark:Ts.light,v=EW(m==="dark"),x=Xx[c],g=f.jsx(Nw,{width:"100%",height:a,children:f.jsxs(jre,{data:r,layout:h?"horizontal":"vertical",margin:{top:5,right:5,left:h?50:0,bottom:5},children:[s&&f.jsx(zp,{strokeDasharray:"3 3",stroke:y.grid,vertical:!h,horizontal:h,strokeOpacity:.5}),h?f.jsxs(f.Fragment,{children:[f.jsx(Mc,{type:"number",stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:x}),f.jsx(Rc,{type:"category",dataKey:i,stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1})]}):f.jsxs(f.Fragment,{children:[f.jsx(Mc,{dataKey:i,stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1}),f.jsx(Rc,{stroke:y.text,fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:x,width:45})]}),f.jsx(kw,{content:f.jsx(Gx,{})}),l&&f.jsx(rl,{iconType:"rect",wrapperStyle:{fontSize:11}}),n.map((w,b)=>f.jsx(IM,{dataKey:w.dataKey,name:w.name||w.dataKey,stackId:d?"1":w.stackId,fill:w.color||v[b%v.length],radius:d?[0,0,0,0]:[4,4,0,0],maxBarSize:40},w.dataKey))]})});return f.jsx(Qx,{title:e,description:t,minimal:o,className:u,children:g})}function Are({data:e,maxValue:t,showValues:r=!0,className:n}){const i=t||Math.max(...e.map(a=>a.value));return f.jsx("div",{className:n,children:f.jsx("div",{className:"space-y-2",children:e.map(a=>f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-xs",children:[f.jsx("span",{className:"text-muted-foreground truncate",children:a.name}),r&&f.jsx("span",{className:"font-medium tabular-nums ml-2",children:a.value})]}),f.jsx("div",{className:"h-2 bg-muted rounded-sm overflow-hidden",children:f.jsx("div",{className:"h-full bg-foreground transition-all duration-500 ease-out rounded-sm",style:{width:`${a.value/i*100}%`,backgroundColor:a.color}})})]},a.name))})})}function hR({data:e,className:t}){const r=e.reduce((n,i)=>n+i.count,0);return f.jsx("div",{className:H("space-y-3",t),children:e.map(n=>{const i=n.percentage||n.count/r*100;return f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:n.category}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-medium tabular-nums",children:n.count}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.toFixed(1),"%)"]})]})]}),f.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-foreground rounded-full transition-all duration-500 ease-out",style:{width:`${i}%`}})})]},n.category)})})}function Tre(){const[e,t]=p.useState(1),[r]=p.useState(!0),{openDetail:n}=ko(),i=Pi(),{data:a,refetch:o}=mt({queryKey:["stats",e],queryFn:()=>Ge.getStats(e),refetchInterval:r?5e3:!1}),{data:s,refetch:l}=mt({queryKey:["recent-requests"],queryFn:()=>Ge.getRequests({limit:100}),refetchInterval:r?5e3:!1}),{data:c,refetch:u}=mt({queryKey:["slow-queries"],queryFn:()=>Ge.getQueries({slow_only:!0,limit:10,slow_threshold:100}),refetchInterval:r?1e4:!1}),{data:d,refetch:h}=mt({queryKey:["recent-exceptions"],queryFn:()=>Ge.getExceptions({limit:5}),refetchInterval:r?1e4:!1}),m=XN({requests:s,queries:null,exceptions:d,stats:a}),y=async()=>{await Promise.all([o(),l(),u(),h()])},v=(s==null?void 0:s.slice(0,20).reverse().map(w=>({name:Go(new Date(w.created_at),"HH:mm"),response:w.duration_ms||0,queries:w.query_count||0})))||[],x=[{category:"Success",count:m.successfulRequests,percentage:m.successRate},{category:"Errors",count:m.failedRequests,percentage:m.errorRate}],g=m.endpointMetrics.slice(0,5).map(w=>({name:w.name,value:w.avgResponseTime}));return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:i("pages.dashboard.title")}),f.jsx("p",{className:"text-muted-foreground",children:i("pages.dashboard.description")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(mo,{value:e.toString(),onValueChange:w=>t(parseInt(w)),children:[f.jsx(pa,{className:"w-32",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1",children:i("timeRange.lastHour")}),f.jsx(be,{value:"24",children:i("timeRange.last24Hours")}),f.jsx(be,{value:"168",children:i("timeRange.last7Days")})]})]}),f.jsx(pe,{variant:"outline",size:"icon",onClick:y,children:f.jsx(yc,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[f.jsx(Zr,{label:i("metrics.totalRequests"),value:(a==null?void 0:a.total_requests)||0,change:void 0,changeLabel:`${m.requestsPerMinute.toFixed(1)} ${i("metrics.requestsPerMinute").toLowerCase()}`,icon:f.jsx(Qc,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.avgResponseTime"),value:Jt(m.avgResponseTime),trend:m.avgResponseTime<100?"down":"up",changeLabel:m.avgResponseTime<100?i("performance.excellent"):i("performance.needsAttention"),icon:f.jsx(Xs,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.databaseQueries"),value:(a==null?void 0:a.total_queries)||0,changeLabel:a!=null&&a.slow_queries?`${a.slow_queries} ${i("metrics.slowQueries").toLowerCase()}`:i("database.noSlowQueriesShort"),trend:a!=null&&a.slow_queries?"up":"neutral",icon:f.jsx(Gc,{className:"h-8 w-8"})}),f.jsx(Zr,{label:i("metrics.exceptions"),value:(a==null?void 0:a.total_exceptions)||0,trend:(a==null?void 0:a.total_exceptions)===0?"neutral":"up",changeLabel:(a==null?void 0:a.total_exceptions)===0?i("common.all"):i("common.error"),icon:f.jsx(Oo,{className:"h-8 w-8"})})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("performance.overview")})}),f.jsxs(le,{className:"space-y-4",children:[f.jsx(nA,{value:m.successRate,max:100,size:"md",label:i("metrics.successRate")}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(at,{label:i("metrics.totalRequests"),value:m.totalRequests}),f.jsx(at,{label:i("requests.tabs.errors"),value:m.failedRequests}),f.jsx(at,{label:i("metrics.errorRate"),value:`${m.errorRate.toFixed(1)}%`})]})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("metrics.responseTime")})}),f.jsxs(le,{className:"space-y-2",children:[f.jsx(at,{label:"P50 (Median)",value:Jt(m.responseTimePercentiles.p50)}),f.jsx(at,{label:"P95",value:Jt(m.responseTimePercentiles.p95)}),f.jsx(at,{label:"P99",value:Jt(m.responseTimePercentiles.p99)}),f.jsx("div",{className:"pt-2",children:f.jsx(Id,{label:i("performance.queryPerformance"),value:a!=null&&a.avg_query_time?100-Math.min(a.avg_query_time/200*100,100):100,compact:!0,status:!(a!=null&&a.avg_query_time)||a.avg_query_time<50?"success":a.avg_query_time<100?"warning":"danger"})})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:i("performance.requestDistribution")})}),f.jsxs(le,{children:[f.jsx(hR,{data:x}),f.jsx("div",{className:"mt-4 space-y-2",children:f.jsx(xf,{status:m.successRate>=95?"success":m.successRate>=90?"warning":"error",label:i("performance.systemStatus"),description:`${m.requestsPerSecond.toFixed(1)} ${i("performance.requestsPerSec")}`,compact:!0})})]})]})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsx(kre,{title:i("performance.responseTimeChart"),description:i("performance.responseTimeDescription"),data:v,areas:[{dataKey:"response",name:i("metrics.responseTime")+" (ms)"}],height:200,formatter:"duration"}),f.jsx(Ore,{title:i("performance.queryActivity"),description:i("performance.queryActivityDescription"),data:v,lines:[{dataKey:"queries",name:i("database.queries")}],height:200,showGrid:!0})]}),g.length>0&&f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("performance.topEndpoints")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/performance",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]}),f.jsx(pt,{children:i("performance.avgResponseByEndpoint")})]}),f.jsx(le,{children:f.jsx(Are,{data:g})})]}),f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("performance.recentRequests")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/requests",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[s==null?void 0:s.slice(0,5).map(w=>f.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id),children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(mW,{status:w.status_code&&w.status_code<400?"online":"offline",size:"sm"}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:"text-sm font-medium truncate",children:[w.method," ",w.path]}),f.jsx("p",{className:"text-xs text-muted-foreground",children:Go(new Date(w.created_at),"HH:mm:ss")})]})]}),f.jsxs("div",{className:"text-right",children:[f.jsx(Oe,{variant:pW(w.status_code),children:w.status_code}),f.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Jt(w.duration_ms)})]})]},w.id)),(!s||s.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:i("requests.empty.all")})]})})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("database.slowQueries")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/database",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[c==null?void 0:c.slice(0,5).map(w=>f.jsxs("div",{className:"space-y-1 cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id),children:[f.jsxs("code",{className:"text-xs bg-muted px-2 py-1 rounded block truncate",children:[w.sql.substring(0,50),"..."]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:Go(new Date(w.created_at),"HH:mm:ss")}),f.jsx(Oe,{variant:"outline",className:"text-xs",children:Jt(w.duration_ms)})]})]},w.id)),(!c||c.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:i("database.noSlowQueries")})]})})]})]}),d&&d.length>0&&f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(ye,{className:"text-base",children:i("exceptions.recentExceptions")}),f.jsx(pe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs(Ji,{to:"/exceptions",children:[i("common.viewAll"),f.jsx(Vu,{className:"ml-1 h-3 w-3"})]})})]})}),f.jsx(le,{children:f.jsx("div",{className:"space-y-2",children:d.slice(0,3).map(w=>f.jsx(xf,{status:"error",label:w.exception_type,description:w.exception_value||i("exceptions.clickToView"),value:Go(new Date(w.created_at),"HH:mm"),className:"cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>n("request",w.request_id)},w.id))})})]})]})}var _re="Label",pR=p.forwardRef((e,t)=>f.jsx(ne.label,{...e,ref:t,onMouseDown:r=>{var i;r.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));pR.displayName=_re;var mR=pR;const Mre=Nh("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),nn=p.forwardRef(({className:e,...t},r)=>f.jsx(mR,{ref:r,className:H(Mre(),e),...t}));nn.displayName=mR.displayName;var sv="rovingFocusGroup.onEntryFocus",Rre={bubbles:!1,cancelable:!0},bu="RovingFocusGroup",[Sy,vR,Dre]=yk(bu),[Ire,gR]=Ln(bu,[Dre]),[Lre,$re]=Ire(bu),yR=p.forwardRef((e,t)=>f.jsx(Sy.Provider,{scope:e.__scopeRovingFocusGroup,children:f.jsx(Sy.Slot,{scope:e.__scopeRovingFocusGroup,children:f.jsx(Fre,{...e,ref:t})})}));yR.displayName=bu;var Fre=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=p.useRef(null),m=me(t,h),y=Th(a),[v,x]=fo({prop:o,defaultProp:s??null,onChange:l,caller:bu}),[g,w]=p.useState(!1),b=Ht(c),S=vR(r),P=p.useRef(!1),[j,E]=p.useState(0);return p.useEffect(()=>{const C=h.current;if(C)return C.addEventListener(sv,b),()=>C.removeEventListener(sv,b)},[b]),f.jsx(Lre,{scope:r,orientation:n,dir:y,loop:i,currentTabStopId:v,onItemFocus:p.useCallback(C=>x(C),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(C=>C+1),[]),onFocusableItemRemove:p.useCallback(()=>E(C=>C-1),[]),children:f.jsx(ne.div,{tabIndex:g||j===0?-1:0,"data-orientation":n,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:re(e.onMouseDown,()=>{P.current=!0}),onFocus:re(e.onFocus,C=>{const N=!P.current;if(C.target===C.currentTarget&&N&&!g){const k=new CustomEvent(sv,Rre);if(C.currentTarget.dispatchEvent(k),!k.defaultPrevented){const A=S().filter(F=>F.focusable),T=A.find(F=>F.active),D=A.find(F=>F.id===v),q=[T,D,...A].filter(Boolean).map(F=>F.ref.current);bR(q,u)}}P.current=!1}),onBlur:re(e.onBlur,()=>w(!1))})})}),xR="RovingFocusGroupItem",wR=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:i=!1,tabStopId:a,children:o,...s}=e,l=ai(),c=a||l,u=$re(xR,r),d=u.currentTabStopId===c,h=vR(r),{onFocusableItemAdd:m,onFocusableItemRemove:y,currentTabStopId:v}=u;return p.useEffect(()=>{if(n)return m(),()=>y()},[n,m,y]),f.jsx(Sy.ItemSlot,{scope:r,id:c,focusable:n,active:i,children:f.jsx(ne.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:re(e.onMouseDown,x=>{n?u.onItemFocus(c):x.preventDefault()}),onFocus:re(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:re(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const g=Wre(x,u.orientation,u.dir);if(g!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let b=h().filter(S=>S.focusable).map(S=>S.ref.current);if(g==="last")b.reverse();else if(g==="prev"||g==="next"){g==="prev"&&b.reverse();const S=b.indexOf(x.currentTarget);b=u.loop?Ure(b,S+1):b.slice(S+1)}setTimeout(()=>bR(b))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});wR.displayName=xR;var zre={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bre(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Wre(e,t,r){const n=Bre(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return zre[n]}function bR(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function Ure(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hre=yR,Kre=wR;function Vre(e,t){return p.useReducer((r,n)=>t[r][n]??r,e)}var mn=e=>{const{present:t,children:r}=e,n=qre(t),i=typeof r=="function"?r({present:n.isPresent}):p.Children.only(r),a=me(n.ref,Yre(i));return typeof r=="function"||n.isPresent?p.cloneElement(i,{ref:a}):null};mn.displayName="Presence";function qre(e){const[t,r]=p.useState(),n=p.useRef(null),i=p.useRef(e),a=p.useRef("none"),o=e?"mounted":"unmounted",[s,l]=Vre(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=vd(n.current);a.current=s==="mounted"?c:"none"},[s]),Nt(()=>{const c=n.current,u=i.current;if(u!==e){const h=a.current,m=vd(c);e?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Nt(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=m=>{const v=vd(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(l("ANIMATION_END"),!i.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},h=m=>{m.target===t&&(a.current=vd(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:p.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function vd(e){return(e==null?void 0:e.animationName)||"none"}function Yre(e){var n,i;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Bp="Tabs",[Qre]=Ln(Bp,[gR]),SR=gR(),[Gre,Gw]=Qre(Bp),PR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:s,activationMode:l="automatic",...c}=e,u=Th(s),[d,h]=fo({prop:n,onChange:i,defaultProp:a??"",caller:Bp});return f.jsx(Gre,{scope:r,baseId:ai(),value:d,onValueChange:h,orientation:o,dir:u,activationMode:l,children:f.jsx(ne.div,{dir:u,"data-orientation":o,...c,ref:t})})});PR.displayName=Bp;var jR="TabsList",ER=p.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...i}=e,a=Gw(jR,r),o=SR(r);return f.jsx(Hre,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:n,children:f.jsx(ne.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:t})})});ER.displayName=jR;var CR="TabsTrigger",OR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:i=!1,...a}=e,o=Gw(CR,r),s=SR(r),l=AR(o.baseId,n),c=TR(o.baseId,n),u=n===o.value;return f.jsx(Kre,{asChild:!0,...s,focusable:!i,active:u,children:f.jsx(ne.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...a,ref:t,onMouseDown:re(e.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?o.onValueChange(n):d.preventDefault()}),onKeyDown:re(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(n)}),onFocus:re(e.onFocus,()=>{const d=o.activationMode!=="manual";!u&&!i&&d&&o.onValueChange(n)})})})});OR.displayName=CR;var kR="TabsContent",NR=p.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:i,children:a,...o}=e,s=Gw(kR,r),l=AR(s.baseId,n),c=TR(s.baseId,n),u=n===s.value,d=p.useRef(u);return p.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),f.jsx(mn,{present:i||u,children:({present:h})=>f.jsx(ne.div,{"data-state":u?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:h&&a})})});NR.displayName=kR;function AR(e,t){return`${e}-trigger-${t}`}function TR(e,t){return`${e}-content-${t}`}var Xre=PR,_R=ER,MR=OR,RR=NR;const Xw=Xre,Wp=p.forwardRef(({className:e,...t},r)=>f.jsx(_R,{ref:r,className:H("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Wp.displayName=_R.displayName;const tr=p.forwardRef(({className:e,...t},r)=>f.jsx(MR,{ref:r,className:H("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));tr.displayName=MR.displayName;const rn=p.forwardRef(({className:e,...t},r)=>f.jsx(RR,{ref:r,className:H("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));rn.displayName=RR.displayName;const Up=p.forwardRef(({className:e,type:t,...r},n)=>f.jsx("input",{type:t,className:H("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...r}));Up.displayName="Input";function DR({value:e,onValueChange:t,debounceMs:r=300,className:n,placeholder:i="Search...",...a}){const[o,s]=p.useState(e),l=p.useRef();p.useEffect(()=>{s(e)},[e]);const c=p.useCallback(u=>{const d=u.target.value;s(d),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{t(d)},r)},[t,r]);return p.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),f.jsxs("div",{className:"relative",children:[f.jsx(hk,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4 pointer-events-none"}),f.jsx(Up,{...a,value:o,onChange:c,placeholder:i,className:H("pl-10",n)})]})}function Zw(e){const t=typeof e=="string"?new Date(e):e,n=new Date().getTime()-t.getTime(),i=Math.floor(n/1e3),a=Math.floor(i/60),o=Math.floor(a/60);return i<60?`${i}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:t.toLocaleDateString()+" "+t.toLocaleTimeString()}function Zre({request:e,onClick:t,className:r}){const n=a=>a?a>=200&&a<300?"success":a>=300&&a<400?"secondary":a>=400&&a<500?"warning":a>=500?"destructive":"outline":"outline",i=a=>({GET:"secondary",POST:"default",PUT:"default",PATCH:"default",DELETE:"destructive"})[a]||"outline";return f.jsxs("div",{className:H("flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",r),onClick:t,children:[f.jsxs("div",{className:"flex items-center space-x-4",children:[f.jsx(Oe,{variant:i(e.method),children:e.method}),f.jsxs("div",{className:"flex flex-col",children:[f.jsx("span",{className:"font-mono text-sm",children:e.path}),f.jsxs("div",{className:"flex items-center space-x-2 text-xs text-muted-foreground",children:[f.jsx(Xs,{className:"h-3 w-3"}),f.jsx("span",{children:Zw(e.created_at)}),e.query_count>0&&f.jsxs(f.Fragment,{children:[f.jsx(Gc,{className:"h-3 w-3 ml-2"}),f.jsxs("span",{children:[e.query_count," queries"]})]}),e.has_exception&&f.jsxs(f.Fragment,{children:[f.jsx(Ah,{className:"h-3 w-3 ml-2 text-destructive"}),f.jsx("span",{className:"text-destructive",children:"Exception"})]})]})]})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[e.status_code&&f.jsx(Oe,{variant:n(e.status_code),children:e.status_code}),e.duration_ms&&f.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.duration_ms.toFixed(0),"ms"]}),f.jsx(dk,{className:"h-4 w-4"})]})]})}function IR(e,t=300){const[r,n]=p.useState(e);return p.useEffect(()=>{const i=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(i)}},[e,t]),r}function Jre(){const[e,t]=p.useState("all"),[r,n]=p.useState("all"),[i,a]=p.useState(""),[o,s]=p.useState("all"),{openDetail:l}=ko(),c=Pi(),u=IR(i,300),{data:d,refetch:h}=mt({queryKey:["all-requests",e,r,u],queryFn:()=>Ge.getRequests({limit:200,status_code:e!=="all"?g(e):void 0,method:r!=="all"?r:void 0,search:u||void 0}),refetchInterval:5e3}),m=(d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=200&&S.status_code<300).length)||0,y=(d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=400).length)||0,v=(d==null?void 0:d.filter(S=>S.duration_ms&&S.duration_ms>500).length)||0,x=o==="all"?d:o==="successful"?d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=200&&S.status_code<300):o==="failed"?d==null?void 0:d.filter(S=>S.status_code&&S.status_code>=400):o==="slow"?d==null?void 0:d.filter(S=>S.duration_ms&&S.duration_ms>500):d,g=S=>{switch(S){case"2xx":return 200;case"3xx":return 300;case"4xx":return 400;case"5xx":return 500;default:return}},w=()=>{h()},b=()=>{if(x){const S=JSON.stringify(x,null,2),P=new Blob([S],{type:"application/json"}),j=URL.createObjectURL(P),E=document.createElement("a");E.href=j,E.download=`requests-${new Date().toISOString()}.json`,E.click()}};return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:c("pages.requests.title")}),f.jsx("p",{className:"text-muted-foreground",children:c("pages.requests.description")})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:c("common.filter")}),f.jsx(pt,{children:c("requests.filters.description")})]}),f.jsx(le,{children:f.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"search",children:c("common.search")}),f.jsx(DR,{id:"search",placeholder:c("requests.filters.searchPlaceholder"),value:i,onValueChange:a})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"status",children:c("requests.filters.status")}),f.jsxs(mo,{value:e,onValueChange:t,children:[f.jsx(pa,{id:"status",children:f.jsx(vo,{placeholder:c("requests.statusFilters.all")})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:c("requests.statusFilters.all")}),f.jsx(be,{value:"2xx",children:c("requests.statusFilters.success")}),f.jsx(be,{value:"3xx",children:c("requests.statusFilters.redirect")}),f.jsx(be,{value:"4xx",children:c("requests.statusFilters.clientErrors")}),f.jsx(be,{value:"5xx",children:c("requests.statusFilters.serverErrors")})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{htmlFor:"method",children:c("requests.filters.method")}),f.jsxs(mo,{value:r,onValueChange:n,children:[f.jsx(pa,{id:"method",children:f.jsx(vo,{placeholder:c("requests.methodFilters.all")})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:c("requests.methodFilters.all")}),f.jsx(be,{value:"GET",children:c("requests.methodFilters.get")}),f.jsx(be,{value:"POST",children:c("requests.methodFilters.post")}),f.jsx(be,{value:"PUT",children:c("requests.methodFilters.put")}),f.jsx(be,{value:"PATCH",children:c("requests.methodFilters.patch")}),f.jsx(be,{value:"DELETE",children:c("requests.methodFilters.delete")})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:" "}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(pe,{variant:"outline",size:"icon",onClick:()=>h(),children:f.jsx(yc,{className:"h-4 w-4"})}),f.jsx(pe,{variant:"outline",size:"icon",onClick:b,children:f.jsx(mF,{className:"h-4 w-4"})}),f.jsxs(pe,{onClick:w,children:[f.jsx(vF,{className:"mr-2 h-4 w-4"}),"Apply Filters"]})]})]})]})})]}),f.jsxs(Xw,{value:o,onValueChange:s,className:"space-y-4",children:[f.jsxs(Wp,{children:[f.jsxs(tr,{value:"all",children:[c("requests.tabs.all"),d&&d.length>0&&f.jsx(Oe,{variant:"outline",className:"ml-2",children:d.length})]}),f.jsxs(tr,{value:"successful",children:[c("requests.tabs.successful"),m>0&&f.jsx(Oe,{variant:"outline",className:"ml-2",children:m})]}),f.jsxs(tr,{value:"failed",children:[c("requests.tabs.failed"),y>0&&f.jsx(Oe,{variant:"destructive",className:"ml-2",children:y})]}),f.jsxs(tr,{value:"slow",children:[c("requests.tabs.slow"),v>0&&f.jsx(Oe,{variant:"secondary",className:"ml-2",children:v})]})]}),f.jsx(rn,{value:o,className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsxs(ye,{children:[o==="all"&&c("requests.tabs.all"),o==="successful"&&c("requests.tabs.successful"),o==="failed"&&c("requests.tabs.failed"),o==="slow"&&c("requests.tabs.slow")]}),f.jsxs(pt,{children:[o==="all"&&c("requests.descriptions.all"),o==="successful"&&c("requests.descriptions.successful"),o==="failed"&&c("requests.descriptions.failed"),o==="slow"&&c("requests.descriptions.slow")]})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-2",children:[x==null?void 0:x.map(S=>f.jsx(Zre,{request:S,onClick:()=>l("request",S.request_id)},S.id)),(!x||x.length===0)&&f.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[o==="all"&&c("requests.empty.all"),o==="successful"&&c("requests.empty.successful"),o==="failed"&&c("requests.empty.failed"),o==="slow"&&c("requests.empty.slow")]})]})})]})})]})]})}function ene(e){return e?e<1e3?`${e.toFixed(0)}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`:"N/A"}function tne(e){switch(e.toLowerCase()){case"ok":case"success":return f.jsx(Mx,{className:"h-4 w-4 text-green-500"});case"error":case"failure":return f.jsx(Oo,{className:"h-4 w-4 text-red-500"});default:return f.jsx(Qc,{className:"h-4 w-4 text-blue-500"})}}function rne(e){switch(e.toLowerCase()){case"ok":case"success":return"default";case"error":case"failure":return"destructive";default:return"secondary"}}function nne({className:e}){const{openDetail:t}=ko(),[r,n]=p.useState({search:"",status:"all",service:"",hours:24,minDuration:0}),[i,a]=p.useState(0),o=50,{data:s=[],isLoading:l,error:c,refetch:u}=mt({queryKey:["traces",r,i],queryFn:()=>Ge.getTraces({limit:o,offset:i*o,status:r.status==="all"?void 0:r.status,service_name:r.service||void 0,min_duration_ms:r.minDuration||void 0,hours:r.hours}),refetchInterval:3e4}),d=h=>{t("trace",h.trace_id)};return c?f.jsx(se,{className:e,children:f.jsx(le,{className:"p-6",children:f.jsxs("div",{className:"text-center",children:[f.jsx(Oo,{className:"h-12 w-12 text-destructive mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Failed to load traces"}),f.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"There was an error loading the trace data."}),f.jsxs(pe,{onClick:()=>u(),children:[f.jsx(yc,{className:"h-4 w-4 mr-2"}),"Try again"]})]})})}):f.jsxs("div",{className:e,children:[f.jsx(se,{className:"mb-6",children:f.jsx(le,{className:"p-4",children:f.jsxs("div",{className:"flex flex-wrap gap-4",children:[f.jsx("div",{className:"flex-1 min-w-[200px]",children:f.jsxs("div",{className:"relative",children:[f.jsx(hk,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),f.jsx(Up,{placeholder:"Search by operation name...",value:r.search,onChange:h=>n({...r,search:h.target.value}),className:"pl-9"})]})}),f.jsxs(mo,{value:r.status,onValueChange:h=>n({...r,status:h}),children:[f.jsx(pa,{className:"w-[150px]",children:f.jsx(vo,{placeholder:"All statuses"})}),f.jsxs(ma,{children:[f.jsx(be,{value:"all",children:"All statuses"}),f.jsx(be,{value:"ok",children:"Success"}),f.jsx(be,{value:"error",children:"Error"})]})]}),f.jsxs(mo,{value:r.hours.toString(),onValueChange:h=>n({...r,hours:parseInt(h)}),children:[f.jsx(pa,{className:"w-[150px]",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1",children:"Last hour"}),f.jsx(be,{value:"6",children:"Last 6 hours"}),f.jsx(be,{value:"24",children:"Last 24 hours"}),f.jsx(be,{value:"168",children:"Last week"})]})]}),f.jsxs(pe,{onClick:()=>u(),size:"sm",variant:"outline",children:[f.jsx(yc,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})})}),f.jsx(se,{children:f.jsxs(le,{className:"p-0",children:[l?f.jsx("div",{className:"p-6",children:f.jsx("div",{className:"space-y-4",children:[...Array(5)].map((h,m)=>f.jsx("div",{className:"animate-pulse",children:f.jsx("div",{className:"h-16 bg-muted rounded"})},m))})}):s.length===0?f.jsxs("div",{className:"p-6 text-center text-muted-foreground",children:[f.jsx(Qc,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),f.jsx("p",{children:"No traces found matching your criteria."})]}):f.jsx("div",{className:"divide-y",children:s.map(h=>f.jsx("div",{className:"p-4 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>d(h),children:f.jsx("div",{className:"flex items-start justify-between",children:f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[tne(h.status),f.jsx("h3",{className:"font-medium truncate",children:h.operation_name||"Unknown Operation"}),f.jsx(Oe,{variant:rne(h.status),className:"text-xs",children:h.status})]}),f.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[f.jsxs("span",{children:["Service: ",h.service_name||"Unknown"]}),f.jsxs("span",{children:["Spans: ",h.span_count]}),f.jsxs("span",{children:["Duration: ",ene(h.duration_ms)]})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[f.jsx(Xs,{className:"h-3 w-3"}),f.jsx("span",{children:uW(new Date(h.start_time),{addSuffix:!0})}),f.jsx("span",{className:"text-muted-foreground/60",children:"•"}),f.jsxs("span",{children:[h.trace_id.slice(0,8),"..."]})]})]})})},h.trace_id))}),s.length===o&&f.jsx("div",{className:"p-4 border-t flex justify-center",children:f.jsx(pe,{variant:"outline",onClick:()=>a(i+1),children:"Load more"})})]})})]})}function ine(){const e=Pi();return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:e("pages.tracing.title")}),f.jsx("p",{className:"text-muted-foreground",children:e("pages.tracing.description")})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:e("pages.tracing.tracesCardTitle")}),f.jsx(pt,{children:e("pages.tracing.tracesCardDescription")})]}),f.jsx(le,{children:f.jsx(nne,{})})]})]})}function ane(){const[e,t]=p.useState("1h"),[r,n]=p.useState(5e3),{openDetail:i}=ko(),a=Pi(),o=e==="1h"?1:e==="24h"?24:168,{data:s}=mt({queryKey:["performance-stats",e],queryFn:()=>Ge.getStats(o),refetchInterval:r}),{data:l}=mt({queryKey:["performance-requests",e],queryFn:()=>Ge.getRequests({limit:100}),refetchInterval:r}),{data:c}=mt({queryKey:["performance-queries",e],queryFn:()=>Ge.getQueries({limit:100}),refetchInterval:r}),{data:u}=mt({queryKey:["performance-exceptions",e],queryFn:()=>Ge.getExceptions({limit:100}),refetchInterval:r}),d=XN({requests:l,queries:c,exceptions:u,stats:s}),h=[{type:"successRate",label:a("metrics.successRate"),value:d.successRate,status:d.successRate>=99?"success":d.successRate>=95?"warning":"error",description:`${a("common.all")} ${d.totalRequests} ${a("metrics.totalRequests").toLowerCase()}`},{type:"avgResponseTime",label:a("metrics.avgResponseTime"),value:Jt(d.avgResponseTime),rawValue:d.avgResponseTime,status:!d.avgResponseTime||d.avgResponseTime<100?"success":d.avgResponseTime<300?"warning":"error"},{type:"errorRate",label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`,rawValue:d.errorRate,status:d.errorRate<=1?"success":d.errorRate<=2?"warning":"error"},{type:"queryPerformance",label:a("performance.queryPerformance"),value:Jt(d.avgQueryTime),rawValue:d.avgQueryTime,status:!d.avgQueryTime||d.avgQueryTime<50?"success":d.avgQueryTime<100?"warning":"error"}],m=d.endpointMetrics.slice(0,10).map(v=>({name:v.name,responseTime:v.avgResponseTime,calls:v.calls})),y=[{category:a("requests.statusFilters.clientErrors"),count:(l==null?void 0:l.filter(v=>v.status_code&&v.status_code>=400&&v.status_code<500).length)||0},{category:a("requests.statusFilters.serverErrors"),count:(l==null?void 0:l.filter(v=>v.status_code&&v.status_code>=500).length)||0},{category:a("metrics.exceptions"),count:d.totalExceptions}];return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:a("pages.performance.title")}),f.jsx("p",{className:"text-muted-foreground",children:a("pages.performance.description")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(mo,{value:e,onValueChange:t,children:[f.jsx(pa,{className:"w-32",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsx(be,{value:"1h",children:a("timeRange.lastHour")}),f.jsx(be,{value:"24h",children:a("timeRange.last24Hours")}),f.jsx(be,{value:"7d",children:a("timeRange.last7Days")})]})]}),f.jsxs(mo,{value:r.toString(),onValueChange:v=>n(parseInt(v)),children:[f.jsx(pa,{className:"w-40",children:f.jsx(vo,{})}),f.jsxs(ma,{children:[f.jsxs(be,{value:"5000",children:[a("common.refresh"),": 5s"]}),f.jsxs(be,{value:"10000",children:[a("common.refresh"),": 10s"]}),f.jsxs(be,{value:"30000",children:[a("common.refresh"),": 30s"]}),f.jsxs(be,{value:"0",children:[a("common.refresh"),": ",a("common.no")]})]})]})]})]}),f.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:h.map(v=>f.jsxs(se,{children:[f.jsxs(ge,{className:"pb-2",children:[f.jsx(ye,{className:"text-sm font-medium",children:v.label}),v.description&&f.jsx(pt,{className:"text-xs",children:v.description})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-3",children:[f.jsx("div",{className:"text-2xl font-bold tabular-nums",children:v.value}),f.jsx(xf,{status:v.status,label:v.status==="success"?a("performance.excellent"):v.status==="warning"?a("performance.acceptable"):a("performance.needsAttention"),compact:!0}),v.rawValue!==void 0&&f.jsx(Id,{label:"",value:v.type==="successRate"||v.type==="errorRate"?v.rawValue:v.type==="avgResponseTime"?Math.min(v.rawValue/1e3*100,100):v.type==="queryPerformance"?Math.min(v.rawValue/200*100,100):0,max:100,showPercentage:!1,compact:!0,status:v.status==="success"?"success":v.status==="warning"?"warning":"danger"})]})})]},v.label))}),f.jsxs(Xw,{defaultValue:"overview",className:"space-y-4",children:[f.jsxs(Wp,{children:[f.jsx(tr,{value:"overview",children:a("performance.overview")}),f.jsx(tr,{value:"endpoints",children:a("performance.endpointPerformance")}),f.jsx(tr,{value:"queries",children:a("nav.database")}),f.jsx(tr,{value:"errors",children:a("performance.errorAnalysis")})]}),f.jsxs(rn,{value:"overview",className:"space-y-4",children:[f.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("metrics.responseTime")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.p50Median"),value:Jt(d.responseTimePercentiles.p50)}),f.jsx(at,{label:a("performance.p95"),value:Jt(d.responseTimePercentiles.p95)}),f.jsx(at,{label:a("performance.p99"),value:Jt(d.responseTimePercentiles.p99)}),f.jsx(PW,{value:d.avgResponseTime||0,max:1e3,label:a("performance.average"),thresholds:[{value:100,label:"100ms"},{value:300,label:"300ms"},{value:1e3,label:"1s"}]})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("performance.throughput")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.requestsPerSec"),value:d.requestsPerSecond.toFixed(1)}),f.jsx(at,{label:a("metrics.totalRequests"),value:gS(s==null?void 0:s.total_requests)}),f.jsx(at,{label:a("performance.totalQueries"),value:gS(s==null?void 0:s.total_queries)}),f.jsx(at,{label:a("performance.queriesPerRequest"),value:s!=null&&s.total_queries&&(s!=null&&s.total_requests)?(s.total_queries/s.total_requests).toFixed(1):"0"})]})]}),f.jsxs(se,{children:[f.jsx(ge,{className:"pb-3",children:f.jsx(ye,{className:"text-base",children:a("performance.errorAnalysis")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(nA,{value:100-d.errorRate,size:"sm",label:a("performance.healthScore")}),f.jsx(at,{label:a("requests.tabs.failed"),value:d.failedRequests}),f.jsx(at,{label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`}),f.jsx(at,{label:a("metrics.exceptions"),value:d.totalExceptions})]})]})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.performanceSummary")}),f.jsxs(pt,{children:[a("performance.realTimeMetrics")," ",d.totalRequests," ",a("performance.recentRequests")]})]}),f.jsx(le,{children:f.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:[f.jsx(Zr,{label:a("metrics.successRate"),value:`${d.successRate.toFixed(1)}%`,minimal:!0}),f.jsx(Zr,{label:a("performance.avgResponse"),value:Jt(d.avgResponseTime),minimal:!0}),f.jsx(Zr,{label:a("performance.slowRequests"),value:d.slowRequests,minimal:!0}),f.jsx(Zr,{label:a("performance.activeEndpoints"),value:d.endpointMetrics.length,minimal:!0})]})})]})]}),f.jsx(rn,{value:"endpoints",className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.endpointPerformance")}),f.jsx(pt,{children:a("performance.performanceBreakdown")})]}),f.jsxs(le,{className:"space-y-6",children:[m.length>0&&f.jsx(Nre,{title:a("performance.responseTimesByEndpoint"),data:m,bars:[{dataKey:"responseTime",name:a("metrics.avgResponseTime")}],height:300,formatter:"duration",minimal:!0,horizontal:!0}),f.jsxs("div",{className:"space-y-4",children:[f.jsx("h4",{className:"text-sm font-medium",children:a("performance.detailedMetrics")}),d.endpointMetrics.map(v=>f.jsxs("div",{className:"space-y-2 p-3 border rounded-lg",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("code",{className:"text-sm font-mono",children:v.name}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Oe,{variant:"outline",children:[v.calls," ",a("performance.calls")]}),v.errors>0&&f.jsxs(Oe,{variant:"destructive",children:[v.errors," ",a("performance.errors")]})]})]}),f.jsx(Id,{label:`${v.avgResponseTime}ms average`,value:Math.min(v.avgResponseTime/500*100,100),showPercentage:!1,sublabel:`${a("performance.successRate")}: ${v.successRate}%`,compact:!0})]},v.name)),d.endpointMetrics.length===0&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:a("performance.noEndpointData")})]})]})]})}),f.jsx(rn,{value:"queries",className:"space-y-4",children:f.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsx(ge,{children:f.jsx(ye,{children:a("performance.queryStatistics")})}),f.jsxs(le,{className:"space-y-3",children:[f.jsx(at,{label:a("performance.totalQueries"),value:d.totalQueries}),f.jsx(at,{label:a("performance.slowQueries"),value:d.slowQueries}),f.jsx(at,{label:a("performance.avgQueryTime"),value:Jt(d.avgQueryTime)}),f.jsx(Id,{label:"Query Performance Score",value:d.avgQueryTime?100-Math.min(d.avgQueryTime/200*100,100):100,status:!d.avgQueryTime||d.avgQueryTime<50?"success":d.avgQueryTime<100?"warning":"danger"})]})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.slowQueriesTitle")}),f.jsxs(pt,{children:[a("database.slowThreshold"),": 100ms"]})]}),f.jsx(le,{children:f.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.filter(v=>v.duration_ms&&v.duration_ms>100).slice(0,5).map(v=>f.jsxs("div",{className:"text-xs cursor-pointer hover:bg-muted/50 p-2 rounded transition-colors",onClick:()=>i("request",v.request_id),children:[f.jsx("code",{className:"block truncate",children:v.sql}),f.jsxs("div",{className:"flex items-center justify-between mt-1",children:[f.jsx("span",{className:"text-muted-foreground",children:new Date(v.created_at).toLocaleTimeString()}),f.jsx(Oe,{variant:"outline",className:"text-xs",children:Jt(v.duration_ms)})]})]},v.id)),(!c||c.filter(v=>v.duration_ms&&v.duration_ms>100).length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No slow queries detected"})]})})]})]})}),f.jsx(rn,{value:"errors",className:"space-y-4",children:f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:a("performance.errorAnalysisTitle")}),f.jsx(pt,{children:a("performance.errorAnalysis")})]}),f.jsxs(le,{className:"space-y-6",children:[f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsx(Zr,{label:a("requests.tabs.failed"),value:d.failedRequests,minimal:!0}),f.jsx(Zr,{label:a("metrics.errorRate"),value:`${d.errorRate.toFixed(1)}%`,minimal:!0}),f.jsx(Zr,{label:a("metrics.exceptions"),value:d.totalExceptions,minimal:!0})]}),f.jsx(hR,{data:y}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("h4",{className:"text-sm font-medium",children:"Recent Exceptions"}),u==null?void 0:u.slice(0,10).map(v=>f.jsx(xf,{status:"error",label:v.exception_type,description:v.exception_value||void 0,value:new Date(v.created_at).toLocaleTimeString(),className:"cursor-pointer hover:bg-muted/50 p-2 -mx-2 rounded transition-colors",onClick:()=>i("request",v.request_id)},v.id)),(!u||u.length===0)&&f.jsx("p",{className:"text-center text-muted-foreground py-4",children:a("performance.noExceptionsCaptured")})]})]})]})})]})]})}var one="Separator",lE="horizontal",sne=["horizontal","vertical"],LR=p.forwardRef((e,t)=>{const{decorative:r,orientation:n=lE,...i}=e,a=lne(n)?n:lE,s=r?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return f.jsx(ne.div,{"data-orientation":a,...s,...i,ref:t})});LR.displayName=one;function lne(e){return sne.includes(e)}var $R=LR;const cs=p.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},i)=>f.jsx($R,{ref:i,decorative:r,orientation:t,className:H("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));cs.displayName=$R.displayName;function cne(){const{theme:e,setTheme:t}=Xc(),{t:r}=Dx(),{language:n,setLanguage:i}=TF(),{data:a,isLoading:o}=mt({queryKey:["settings-stats"],queryFn:()=>Ge.getStats(24*7),refetchInterval:3e4}),s=async()=>{confirm("Are you sure you want to clear all captured data?")&&(await Ge.clearData(),window.location.reload())},l=async c=>{const u=c/24,d=u===1?"1 day":`${u} days`;confirm(`Are you sure you want to clear data older than ${d}?`)&&(await Ge.clearData(c),window.location.reload())};return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("pages.settings.title")}),f.jsx("p",{className:"text-muted-foreground",children:r("pages.settings.description")})]}),f.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.appearance.title")}),f.jsx(pt,{children:r("settings.appearance.description")})]}),f.jsx(le,{className:"space-y-4",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.appearance.theme")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.appearance.themeDescription")}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(pe,{variant:e==="light"?"default":"outline",size:"sm",onClick:()=>t("light"),children:[f.jsx(pk,{className:"mr-2 h-4 w-4"}),r("settings.appearance.light")]}),f.jsxs(pe,{variant:e==="dark"?"default":"outline",size:"sm",onClick:()=>t("dark"),children:[f.jsx(fk,{className:"mr-2 h-4 w-4"}),r("settings.appearance.dark")]})]})]})})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.language.title")}),f.jsx(pt,{children:r("settings.language.description")})]}),f.jsx(le,{className:"space-y-4",children:f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.language.current")}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(pe,{variant:n==="en"?"default":"outline",size:"sm",onClick:()=>i("en"),children:[f.jsx($1,{className:"mr-2 h-4 w-4"}),r("settings.language.english")]}),f.jsxs(pe,{variant:n==="zh"?"default":"outline",size:"sm",onClick:()=>i("zh"),children:[f.jsx($1,{className:"mr-2 h-4 w-4"}),r("settings.language.chinese")]})]})]})})]}),f.jsxs(se,{children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.database.title")}),f.jsx(pt,{children:r("settings.database.description")})]}),f.jsx(le,{className:"space-y-3",children:o?f.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:r("settings.database.loading")}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalRequests")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_requests)!==void 0?a.total_requests.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalQueries")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_queries)!==void 0?a.total_queries.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.totalExceptions")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.total_exceptions)!==void 0?a.total_exceptions.toLocaleString():"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.slowQueries")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.slow_queries)!==void 0?a.slow_queries.toLocaleString():"—"})]}),f.jsx(cs,{}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.avgResponseTime")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.avg_response_time)!==null&&(a==null?void 0:a.avg_response_time)!==void 0?`${Math.round(a.avg_response_time)}ms`:"—"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-muted-foreground",children:r("settings.database.requestsPerMinute")}),f.jsx("span",{className:"font-medium",children:(a==null?void 0:a.requests_per_minute)!==void 0?a.requests_per_minute.toFixed(1):"—"})]})]})})]}),f.jsxs(se,{className:"md:col-span-2",children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.dataManagement.title")}),f.jsx(pt,{children:r("settings.dataManagement.description")})]}),f.jsxs(le,{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.dataManagement.quickActions")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.dataManagement.quickActionsDescription")}),f.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear1Day")]}),f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24*7),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear7Days")]}),f.jsxs(pe,{variant:"outline",className:"justify-start",onClick:()=>l(24*30),children:[f.jsx(Td,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clear30Days")]})]})]}),f.jsx(cs,{}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(nn,{children:r("settings.dataManagement.dangerZone")}),f.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("settings.dataManagement.dangerZoneDescription")}),f.jsxs(pe,{variant:"destructive",onClick:s,children:[f.jsx(Oo,{className:"mr-2 h-4 w-4"}),r("settings.dataManagement.clearAll")]})]})]})]}),f.jsxs(se,{className:"md:col-span-2",children:[f.jsxs(ge,{children:[f.jsx(ye,{children:r("settings.about.title")}),f.jsx(pt,{children:r("settings.about.description")})]}),f.jsxs(le,{className:"space-y-4",children:[f.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.jsx("p",{className:"mb-2",children:r("settings.about.content")}),f.jsx("p",{children:f.jsxs("strong",{children:[r("settings.about.features"),":"]})}),f.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-1",children:[f.jsx("li",{children:r("settings.about.feature1")}),f.jsx("li",{children:r("settings.about.feature2")}),f.jsx("li",{children:r("settings.about.feature3")}),f.jsx("li",{children:r("settings.about.feature4")}),f.jsx("li",{children:r("settings.about.feature5")})]})]}),f.jsx(cs,{}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:r("settings.about.version")}),f.jsx("span",{className:"font-medium",children:"0.1.9"})]}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("span",{className:"text-muted-foreground",children:r("settings.about.dashboard")}),f.jsxs("span",{className:"font-medium",children:[f.jsx(Gc,{className:"inline h-3 w-3 mr-1"}),r("settings.about.connected")]})]})]})]})]})]})}var Hp="Dialog",[FR]=Ln(Hp),[une,vn]=FR(Hp),zR=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=p.useRef(null),l=p.useRef(null),[c,u]=fo({prop:n,defaultProp:i??!1,onChange:a,caller:Hp});return f.jsx(une,{scope:t,triggerRef:s,contentRef:l,contentId:ai(),titleId:ai(),descriptionId:ai(),open:c,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),modal:o,children:r})};zR.displayName=Hp;var BR="DialogTrigger",dne=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(BR,r),a=me(t,i.triggerRef);return f.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":tb(i.open),...n,ref:a,onClick:re(e.onClick,i.onOpenToggle)})});dne.displayName=BR;var Jw="DialogPortal",[fne,WR]=FR(Jw,{forceMount:void 0}),UR=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:i}=e,a=vn(Jw,t);return f.jsx(fne,{scope:t,forceMount:r,children:p.Children.map(n,o=>f.jsx(mn,{present:r||a.open,children:f.jsx($h,{asChild:!0,container:i,children:o})}))})};UR.displayName=Jw;var lh="DialogOverlay",HR=p.forwardRef((e,t)=>{const r=WR(lh,e.__scopeDialog),{forceMount:n=r.forceMount,...i}=e,a=vn(lh,e.__scopeDialog);return a.modal?f.jsx(mn,{present:n||a.open,children:f.jsx(pne,{...i,ref:t})}):null});HR.displayName=lh;var hne=Ns("DialogOverlay.RemoveScroll"),pne=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(lh,r);return f.jsx(Kx,{as:hne,allowPinchZoom:!0,shards:[i.contentRef],children:f.jsx(ne.div,{"data-state":tb(i.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),jo="DialogContent",KR=p.forwardRef((e,t)=>{const r=WR(jo,e.__scopeDialog),{forceMount:n=r.forceMount,...i}=e,a=vn(jo,e.__scopeDialog);return f.jsx(mn,{present:n||a.open,children:a.modal?f.jsx(mne,{...i,ref:t}):f.jsx(vne,{...i,ref:t})})});KR.displayName=jo;var mne=p.forwardRef((e,t)=>{const r=vn(jo,e.__scopeDialog),n=p.useRef(null),i=me(t,r.contentRef,n);return p.useEffect(()=>{const a=n.current;if(a)return Jk(a)},[]),f.jsx(VR,{...e,ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:re(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:re(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&a.preventDefault()}),onFocusOutside:re(e.onFocusOutside,a=>a.preventDefault())})}),vne=p.forwardRef((e,t)=>{const r=vn(jo,e.__scopeDialog),n=p.useRef(!1),i=p.useRef(!1);return f.jsx(VR,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,s;(o=e.onCloseAutoFocus)==null||o.call(e,a),a.defaultPrevented||(n.current||(s=r.triggerRef.current)==null||s.focus(),a.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:a=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),VR=p.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=vn(jo,r),l=p.useRef(null),c=me(t,l);return bk(),f.jsxs(f.Fragment,{children:[f.jsx(Ix,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:a,children:f.jsx(_h,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":tb(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(gne,{titleId:s.titleId}),f.jsx(xne,{contentRef:l,descriptionId:s.descriptionId})]})]})}),eb="DialogTitle",qR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(eb,r);return f.jsx(ne.h2,{id:i.titleId,...n,ref:t})});qR.displayName=eb;var YR="DialogDescription",QR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(YR,r);return f.jsx(ne.p,{id:i.descriptionId,...n,ref:t})});QR.displayName=YR;var GR="DialogClose",XR=p.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,i=vn(GR,r);return f.jsx(ne.button,{type:"button",...n,ref:t,onClick:re(e.onClick,()=>i.onOpenChange(!1))})});XR.displayName=GR;function tb(e){return e?"open":"closed"}var ZR="DialogTitleWarning",[qie,JR]=IF(ZR,{contentName:jo,titleName:eb,docsSlug:"dialog"}),gne=({titleId:e})=>{const t=JR(ZR),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
315
315
 
316
316
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
317
317
 
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>FastAPI Radar - Debugging Dashboard</title>
7
- <script type="module" crossorigin src="/__radar/assets/index-By5DXl8Z.js"></script>
7
+ <script type="module" crossorigin src="/__radar/assets/index-Dj9HCQum.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/__radar/assets/index-XlGcZj49.css">
9
9
  </head>
10
10
  <body>
@@ -109,24 +109,28 @@ class RadarMiddleware(BaseHTTPMiddleware):
109
109
  exception_occurred = False
110
110
 
111
111
  try:
112
- response = await call_next(request)
112
+ response = original_response = await call_next(request)
113
113
 
114
114
  captured_request.status_code = response.status_code
115
115
  captured_request.response_headers = serialize_headers(response.headers)
116
116
 
117
- if self.capture_response_body and not isinstance(
118
- response, StreamingResponse
119
- ):
120
- response_body = b""
121
- async for chunk in response.body_iterator:
122
- response_body += chunk
123
-
124
- captured_request.response_body = truncate_body(
125
- response_body.decode("utf-8", errors="ignore"), self.max_body_size
126
- )
127
-
128
- response = Response(
129
- content=response_body,
117
+ if self.capture_response_body:
118
+
119
+ async def capture_response():
120
+ response_body = ""
121
+ async for chunk in original_response.body_iterator:
122
+ yield chunk
123
+ if len(response_body) < self.max_body_size:
124
+ response_body += chunk.decode("utf-8", errors="ignore")
125
+ with self.get_session() as session:
126
+ captured_request.response_body = truncate_body(
127
+ response_body, self.max_body_size
128
+ )
129
+ session.add(captured_request)
130
+ session.commit()
131
+
132
+ response = StreamingResponse(
133
+ content=capture_response(),
130
134
  status_code=response.status_code,
131
135
  headers=dict(response.headers),
132
136
  media_type=response.media_type,
fastapi_radar/models.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Storage models for FastAPI Radar."""
2
2
 
3
- from datetime import datetime
3
+ from datetime import datetime, timezone
4
4
 
5
5
  from sqlalchemy import (
6
6
  Column,
@@ -40,7 +40,9 @@ class CapturedRequest(Base):
40
40
  response_headers = Column(JSON)
41
41
  duration_ms = Column(Float)
42
42
  client_ip = Column(String(50))
43
- created_at = Column(DateTime, default=datetime.utcnow, index=True)
43
+ created_at = Column(
44
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
45
+ )
44
46
 
45
47
  queries = relationship(
46
48
  "CapturedQuery",
@@ -68,7 +70,9 @@ class CapturedQuery(Base):
68
70
  duration_ms = Column(Float)
69
71
  rows_affected = Column(Integer)
70
72
  connection_name = Column(String(100))
71
- created_at = Column(DateTime, default=datetime.utcnow, index=True)
73
+ created_at = Column(
74
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
75
+ )
72
76
 
73
77
  request = relationship(
74
78
  "CapturedRequest",
@@ -87,7 +91,9 @@ class CapturedException(Base):
87
91
  exception_type = Column(String(100), nullable=False)
88
92
  exception_value = Column(Text)
89
93
  traceback = Column(Text, nullable=False)
90
- created_at = Column(DateTime, default=datetime.utcnow, index=True)
94
+ created_at = Column(
95
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
96
+ )
91
97
 
92
98
  request = relationship(
93
99
  "CapturedRequest",
@@ -104,13 +110,17 @@ class Trace(Base):
104
110
  trace_id = Column(String(32), primary_key=True, index=True)
105
111
  service_name = Column(String(100), index=True)
106
112
  operation_name = Column(String(200))
107
- start_time = Column(DateTime, default=datetime.utcnow, index=True)
113
+ start_time = Column(
114
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
115
+ )
108
116
  end_time = Column(DateTime)
109
117
  duration_ms = Column(Float)
110
118
  span_count = Column(Integer, default=0)
111
119
  status = Column(String(20), default="ok")
112
120
  tags = Column(JSON)
113
- created_at = Column(DateTime, default=datetime.utcnow, index=True)
121
+ created_at = Column(
122
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
123
+ )
114
124
 
115
125
  spans = relationship(
116
126
  "Span",
@@ -135,7 +145,9 @@ class Span(Base):
135
145
  status = Column(String(20), default="ok")
136
146
  tags = Column(JSON)
137
147
  logs = Column(JSON)
138
- created_at = Column(DateTime, default=datetime.utcnow, index=True)
148
+ created_at = Column(
149
+ DateTime, default=lambda: datetime.now(timezone.utc), index=True
150
+ )
139
151
 
140
152
  trace = relationship(
141
153
  "Trace",
@@ -154,4 +166,4 @@ class SpanRelation(Base):
154
166
  parent_span_id = Column(String(16), index=True)
155
167
  child_span_id = Column(String(16), index=True)
156
168
  depth = Column(Integer, default=0)
157
- created_at = Column(DateTime, default=datetime.utcnow)
169
+ created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
fastapi_radar/radar.py CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  from contextlib import contextmanager
4
4
  import os
5
+ import sys
6
+ import multiprocessing
5
7
  from pathlib import Path
6
8
  from typing import List, Optional
7
9
 
@@ -16,6 +18,31 @@ from .middleware import RadarMiddleware
16
18
  from .models import Base
17
19
 
18
20
 
21
+ def is_reload_worker() -> bool:
22
+ """Check if we're running in a reload worker process (used by fastapi dev)."""
23
+ # Check for uvicorn reload worker
24
+ if os.environ.get("UVICORN_RELOAD"):
25
+ return True
26
+
27
+ # Check for Werkzeug reloader (used by some dev servers)
28
+ if os.environ.get("WERKZEUG_RUN_MAIN"):
29
+ return True
30
+
31
+ # Check if we're not the main process (common in reload scenarios)
32
+ # On Windows, the main process name is often "MainProcess"
33
+ if hasattr(multiprocessing.current_process(), "name"):
34
+ process_name = multiprocessing.current_process().name
35
+ if process_name != "MainProcess" and "SpawnProcess" in process_name:
36
+ return True
37
+
38
+ return False
39
+
40
+
41
+ def is_windows() -> bool:
42
+ """Check if we're running on Windows."""
43
+ return sys.platform.startswith("win")
44
+
45
+
19
46
  class Radar:
20
47
  query_capture: Optional[QueryCapture]
21
48
 
@@ -34,6 +61,7 @@ class Radar:
34
61
  enable_tracing: bool = True,
35
62
  service_name: str = "fastapi-app",
36
63
  include_in_schema: bool = True,
64
+ db_path: Optional[str] = None,
37
65
  ):
38
66
  self.app = app
39
67
  self.db_engine = db_engine
@@ -46,6 +74,7 @@ class Radar:
46
74
  self.theme = theme
47
75
  self.enable_tracing = enable_tracing
48
76
  self.service_name = service_name
77
+ self.db_path = db_path
49
78
  self.query_capture = None
50
79
 
51
80
  # Exclude radar dashboard paths
@@ -65,14 +94,62 @@ class Radar:
65
94
  # Import duckdb_engine to register the dialect
66
95
  import duckdb_engine # noqa: F401
67
96
 
68
- radar_db_path = Path.cwd() / "radar.duckdb"
69
- self.storage_engine = create_engine(
70
- f"duckdb:///{radar_db_path}",
71
- connect_args={
72
- "read_only": False,
73
- "config": {"memory_limit": "500mb"},
74
- },
75
- )
97
+ if self.db_path:
98
+ try:
99
+ # Avoid shadowing the attribute name by using a different variable name
100
+ provided_path = Path(self.db_path).resolve()
101
+ if provided_path.suffix.lower() == ".duckdb":
102
+ radar_db_path = provided_path
103
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
104
+ else:
105
+ radar_db_path = provided_path / "radar.duckdb"
106
+ provided_path.mkdir(parents=True, exist_ok=True)
107
+
108
+ except Exception as e:
109
+ # Fallback to current directory if path creation fails
110
+ import warnings
111
+
112
+ warnings.warn(
113
+ (
114
+ f"Failed to create database path '{self.db_path}': {e}. "
115
+ f"Using current directory."
116
+ ),
117
+ UserWarning,
118
+ )
119
+
120
+ radar_db_path = Path.cwd() / "radar.duckdb"
121
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
122
+ else:
123
+ radar_db_path = Path.cwd() / "radar.duckdb"
124
+ radar_db_path.parent.mkdir(parents=True, exist_ok=True)
125
+
126
+ # Handle reload worker scenario (fastapi dev) on all platforms
127
+ if is_reload_worker():
128
+ import warnings
129
+
130
+ warnings.warn(
131
+ "FastAPI Radar: Detected development mode with auto-reload. "
132
+ "Using in-memory database to avoid file locking issues. "
133
+ "Data will not persist between reloads.",
134
+ UserWarning,
135
+ )
136
+ # Use in-memory database for dev mode with reload
137
+ self.storage_engine = create_engine(
138
+ "duckdb:///:memory:",
139
+ connect_args={
140
+ "read_only": False,
141
+ "config": {"memory_limit": "500mb"},
142
+ },
143
+ )
144
+ else:
145
+ # Normal file-based database for production
146
+ self.storage_engine = create_engine(
147
+ f"duckdb:///{radar_db_path}",
148
+ connect_args={
149
+ "read_only": False,
150
+ "config": {"memory_limit": "500mb"},
151
+ },
152
+ )
76
153
 
77
154
  self.SessionLocal = sessionmaker(
78
155
  autocommit=False, autoflush=False, bind=self.storage_engine
@@ -304,19 +381,34 @@ class Radar:
304
381
  )
305
382
 
306
383
  def create_tables(self) -> None:
307
- Base.metadata.create_all(bind=self.storage_engine)
384
+ """Create database tables.
385
+
386
+ With dev mode (fastapi dev), this will safely handle
387
+ multiple process attempts to create tables.
388
+ """
389
+ try:
390
+ Base.metadata.create_all(bind=self.storage_engine)
391
+ except Exception as e:
392
+ # With reload workers, table creation might fail
393
+ # if another process already created them or has a lock
394
+ error_msg = str(e).lower()
395
+ if "already exists" in error_msg or "lock" in error_msg:
396
+ pass # Tables already exist or locked, that's fine in dev mode
397
+ else:
398
+ # Re-raise other exceptions
399
+ raise
308
400
 
309
401
  def drop_tables(self) -> None:
310
402
  Base.metadata.drop_all(bind=self.storage_engine)
311
403
 
312
404
  def cleanup(self, older_than_hours: Optional[int] = None) -> None:
313
- from datetime import datetime, timedelta
405
+ from datetime import datetime, timedelta, timezone
314
406
 
315
407
  from .models import CapturedRequest
316
408
 
317
409
  with self.get_session() as session:
318
410
  hours = older_than_hours or self.retention_hours
319
- cutoff = datetime.utcnow() - timedelta(hours=hours)
411
+ cutoff = datetime.now(timezone.utc) - timedelta(hours=hours)
320
412
 
321
413
  deleted = (
322
414
  session.query(CapturedRequest)
fastapi_radar/tracing.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Tracing core functionality module."""
2
2
 
3
3
  import uuid
4
- from datetime import datetime
4
+ from datetime import datetime, timezone
5
5
  from typing import Optional, Dict, Any, List
6
6
  from contextvars import ContextVar
7
7
  from sqlalchemy.orm import Session
@@ -23,7 +23,7 @@ class TraceContext:
23
23
  self.root_span_id: Optional[str] = None
24
24
  self.current_span_id: Optional[str] = None
25
25
  self.spans: Dict[str, Dict[str, Any]] = {}
26
- self.start_time = datetime.utcnow()
26
+ self.start_time = datetime.now(timezone.utc)
27
27
 
28
28
  def create_span(
29
29
  self,
@@ -42,7 +42,7 @@ class TraceContext:
42
42
  "operation_name": operation_name,
43
43
  "service_name": self.service_name,
44
44
  "span_kind": span_kind,
45
- "start_time": datetime.utcnow(),
45
+ "start_time": datetime.now(timezone.utc),
46
46
  "tags": tags or {},
47
47
  "logs": [],
48
48
  "status": "ok",
@@ -64,7 +64,7 @@ class TraceContext:
64
64
  return
65
65
 
66
66
  span_data = self.spans[span_id]
67
- span_data["end_time"] = datetime.utcnow()
67
+ span_data["end_time"] = datetime.now(timezone.utc)
68
68
  span_data["duration_ms"] = (
69
69
  span_data["end_time"] - span_data["start_time"]
70
70
  ).total_seconds() * 1000
@@ -79,7 +79,7 @@ class TraceContext:
79
79
  return
80
80
 
81
81
  log_entry = {
82
- "timestamp": datetime.utcnow().isoformat(),
82
+ "timestamp": datetime.now(timezone.utc).isoformat(),
83
83
  "level": level,
84
84
  "message": message,
85
85
  **fields,
@@ -108,7 +108,7 @@ class TraceContext:
108
108
  error_count += 1
109
109
 
110
110
  start_time = min(all_times) if all_times else self.start_time
111
- end_time = max(all_times) if all_times else datetime.utcnow()
111
+ end_time = max(all_times) if all_times else datetime.now(timezone.utc)
112
112
 
113
113
  return {
114
114
  "trace_id": self.trace_id,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-radar
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: A debugging dashboard for FastAPI applications with real-time monitoring
5
5
  Home-page: https://github.com/doganarif/fastapi-radar
6
6
  Author: Arif Dogan
@@ -139,9 +139,47 @@ radar = Radar(
139
139
  capture_sql_bindings=True, # Capture SQL query parameters
140
140
  exclude_paths=["/health"], # Paths to exclude from monitoring
141
141
  theme="auto", # Dashboard theme: "light", "dark", or "auto"
142
+ db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
142
143
  )
143
144
  ```
144
145
 
146
+ ### Custom Database Location
147
+
148
+ By default, FastAPI Radar stores its monitoring data in a `radar.duckdb` file in your current working directory. You can customize this location using the `db_path` parameter:
149
+
150
+ ```python
151
+ # Store in a specific directory
152
+ radar = Radar(app, db_path="/var/data/monitoring")
153
+ # Creates: /var/data/monitoring/radar.duckdb
154
+
155
+ # Store with a specific filename
156
+ radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
157
+ # Creates: /var/data/my_app_monitoring.duckdb
158
+
159
+ # Use a relative path
160
+ radar = Radar(app, db_path="./data")
161
+ # Creates: ./data/radar.duckdb
162
+ ```
163
+
164
+ If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
165
+
166
+ ### Development Mode with Auto-Reload
167
+
168
+ When running your FastAPI application with `fastapi dev` (which uses auto-reload), FastAPI Radar automatically switches to an in-memory database to avoid file locking issues. This means:
169
+
170
+ - **No file locking errors** - The dashboard will work seamlessly in development
171
+ - **Data doesn't persist between reloads** - Each reload starts with a fresh database
172
+ - **Production behavior unchanged** - When using `fastapi run` or deploying, the normal file-based database is used
173
+
174
+ ```python
175
+ # With fastapi dev (auto-reload enabled):
176
+ # Automatically uses in-memory database - no configuration needed!
177
+ radar = Radar(app)
178
+ radar.create_tables() # Safe to call - handles multiple processes gracefully
179
+ ```
180
+
181
+ This behavior only applies when using the development server with auto-reload (`fastapi dev`). In production or when using `fastapi run`, the standard file-based DuckDB storage is used.
182
+
145
183
  ## What Gets Captured?
146
184
 
147
185
  - ✅ HTTP requests and responses
@@ -0,0 +1,18 @@
1
+ fastapi_radar/__init__.py,sha256=Os2-UyRE7P9eMawgWenw_V4aa_08wp36xQ14G4fec_o,137
2
+ fastapi_radar/api.py,sha256=uuUQp-E8MBZf9bEklrRLfgXv2c0AYiE9yCI8FBIR8Fk,16136
3
+ fastapi_radar/capture.py,sha256=butzGPmjR8f3gdrNqh4iOlXD2WBD8Zh6CcSTDlnYR5o,5186
4
+ fastapi_radar/middleware.py,sha256=6FRlZa3XJwOA8UF5NkZ3pOXyK7F9P_ksvixf1CbFllk,8037
5
+ fastapi_radar/models.py,sha256=aOxShW8DeYKhehGL9tvBTSWkqqJSgDMKJKNQ1w_OKdE,5092
6
+ fastapi_radar/radar.py,sha256=sBmniNedkd_IWWBOqdgYBLmys2YE9MbGmz8kacDcGcg,15104
7
+ fastapi_radar/tracing.py,sha256=GNayJJaxZR68ZiT3Io9GUyd9SnbFrfXGnRRpQigLDL0,8798
8
+ fastapi_radar/utils.py,sha256=82cNXjbtm7oTaNRwrSy2fPWDVGi8XSk56C_8o7N7oRQ,1516
9
+ fastapi_radar/dashboard/dist/index.html,sha256=EaysaD1uPZhQplljsV-ytNhrXG-fgc1i9GHzn2i2PzM,436
10
+ fastapi_radar/dashboard/dist/assets/index-Dj9HCQum.js,sha256=HNTPaHPyqsprjI_hJpxnfJddpaBFtGylfdmnqSFw470,833887
11
+ fastapi_radar/dashboard/dist/assets/index-XlGcZj49.css,sha256=z2yLr4jYQoOM7KQ2aw5zrPpMlkr9dRvwBSGaxjzZNnc,35552
12
+ fastapi_radar-0.1.9.dist-info/licenses/LICENSE,sha256=0ga4BB6q-nqx6xlDRhtrgKrYs0HgX02PQyIzNFRK09Q,1067
13
+ tests/__init__.py,sha256=kAWaI50iJRZ4JlAdyt7FICgm8MsloZz0ZlsmhgLXBas,31
14
+ tests/test_radar.py,sha256=3F-_zdemPcgQnjP4kzCa7GhMxNJNYU0SgSWprctyXiA,2374
15
+ fastapi_radar-0.1.9.dist-info/METADATA,sha256=AZQMX_iDB8P989LFgDglUAeWhgAgDMls5LjRA93IvwU,7604
16
+ fastapi_radar-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ fastapi_radar-0.1.9.dist-info/top_level.txt,sha256=M-bALM-KDkiLcATq2aAx-BnG59Nv-GdFBzuzkUhiCa0,20
18
+ fastapi_radar-0.1.9.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- fastapi_radar/__init__.py,sha256=RsHUtOtkoaufEyEeY9NyVFNLVyPhUppP2RR6iz9mTyY,137
2
- fastapi_radar/api.py,sha256=JYXYocgWdmjHbrfthpBuqXmIWH8ZNct4qA3WCbinL2o,16099
3
- fastapi_radar/capture.py,sha256=butzGPmjR8f3gdrNqh4iOlXD2WBD8Zh6CcSTDlnYR5o,5186
4
- fastapi_radar/middleware.py,sha256=v36cdUWRozkFs1MxG8piRzuazQZG5CHRVp_e7AWobbk,7684
5
- fastapi_radar/models.py,sha256=jsYakaDd3HRDdAI7SfXLL5fI_fAfVBBhcYq8ktDPfmk,4865
6
- fastapi_radar/radar.py,sha256=8bVoEY9zekgp4bU50fAftgFYc4CP_3t42J8dS4zduvQ,11218
7
- fastapi_radar/tracing.py,sha256=m0AEX4sa-VUu5STezhpa51BZQ7R8Ax9u2zry2JSF3hQ,8743
8
- fastapi_radar/utils.py,sha256=82cNXjbtm7oTaNRwrSy2fPWDVGi8XSk56C_8o7N7oRQ,1516
9
- fastapi_radar/dashboard/dist/index.html,sha256=-Dx0Jw0WDyD29adrACqarkIq_XlUDo7BzqHmt3_mAkc,436
10
- fastapi_radar/dashboard/dist/assets/index-By5DXl8Z.js,sha256=D4jEA0Ep4L7PXXo8rZ_saAQIWhl43aAfIdjI6b4eotQ,833887
11
- fastapi_radar/dashboard/dist/assets/index-XlGcZj49.css,sha256=z2yLr4jYQoOM7KQ2aw5zrPpMlkr9dRvwBSGaxjzZNnc,35552
12
- fastapi_radar-0.1.7.dist-info/licenses/LICENSE,sha256=0ga4BB6q-nqx6xlDRhtrgKrYs0HgX02PQyIzNFRK09Q,1067
13
- tests/__init__.py,sha256=kAWaI50iJRZ4JlAdyt7FICgm8MsloZz0ZlsmhgLXBas,31
14
- tests/test_radar.py,sha256=3F-_zdemPcgQnjP4kzCa7GhMxNJNYU0SgSWprctyXiA,2374
15
- fastapi_radar-0.1.7.dist-info/METADATA,sha256=fdCi6WDOrkSyPoxQmH0OgWdFdDNjUUJ_q0E7hb7GLLc,5884
16
- fastapi_radar-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- fastapi_radar-0.1.7.dist-info/top_level.txt,sha256=M-bALM-KDkiLcATq2aAx-BnG59Nv-GdFBzuzkUhiCa0,20
18
- fastapi_radar-0.1.7.dist-info/RECORD,,