import{c as fe,r as g,h as ka,i as Sa,t as se,q as $e,s as qt,g as _a,j as r,A as ce,k as O,S as qe,B as R,y as Ta,T as Vt,f as U,z as gt,D as vt,G as yt,p as ke,H as bt,J as wt,K as jt,M as Pa,I as Nt,N as Oa,O as Fa,Q as Wa,U as Ea}from"./index-DszW2bOJ.js";import{C as Ia,e as _e,f as zt,u as Ya,a as Ra,P as La,b as Aa,c as Ha,d as Ba,Q as $a}from"./QuickAccessCards-CrUYLHb-.js";import{F as qa,D as Va,T as za,a as Qa,b as pe,c as Xa,f as We,d as Ga,e as Ee,C as Qt,g as Ve,S as Xt,u as Ka,h as Ua,i as Ja,j as Za,k as en}from"./scroll-area-BmGhP1SC.js";import{C as ze,a as pt,b as Dt,d as Mt}from"./card-Bxc0HrZ8.js";import{R as Gt}from"./switch-CgfzYKbb.js";import{I as Qe,L as G}from"./label-DLEWKwVs.js";import{S as tn}from"./search-BTc9gkmb.js";import{S as an}from"./skeleton-C_D7SMTX.js";import{D as Xe,a as Kt,b as Ut,c as Jt,d as nn,e as rn,f as Ct,P as sn,C as kt}from"./ConfirmDialog-CYD3yS9a.js";import{C as on}from"./circle-x-DqiJ4qlx.js";import{Z as ln}from"./zap-C6fD-luB.js";import"./index-CdIMhveG.js";/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const cn=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],dn=fe("CircleCheckBig",cn);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const un=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],St=fe("CircleCheck",un);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mn=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ge=fe("Database",mn);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],hn=fe("Eye",fn);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xn=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ke=fe("Hash",xn);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gn=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],vn=fe("Timer",gn);function yn(e,a=500){const[t,n]=g.useState(e);return g.useEffect(()=>{const s=setTimeout(()=>{n(e)},a);return()=>{clearTimeout(s)}},[e,a]),t}function bn(){const e=ka();return Sa({mutationFn:a=>qt.traces.clearByProjectId(a),onSuccess:(a,t)=>{e.invalidateQueries({queryKey:$e.traces.byProject(t)}),e.invalidateQueries({queryKey:$e.projects.metrics(t)}),se.success("Project traces cleared",{description:"All traces for this project have been successfully cleared"})},onError:a=>{console.error("Failed to clear project traces:",a),se.error("Error clearing project traces",{description:"Could not clear the project traces"})}})}function wn(e,a){return{..._a({queryKey:$e.traces.byProjectWithOptions(e,a),queryFn:()=>qt.traces.getByProjectId(e,a),enabled:!!e,refetchInterval:5e3})}}function jn({debounceTimeout:e=500}={}){const[a,t]=g.useState(""),[n,s]=g.useState(!1),[o,i]=g.useState({status:[]}),l=yn(a,e),c=g.useMemo(()=>o.status.length>0||!!o.fromDate||!!o.toDate||o.minDuration!==void 0||o.maxDuration!==void 0,[o]),u=g.useCallback(()=>{s(!0)},[]),d=g.useCallback(m=>{i(m),s(!1)},[]),f=g.useCallback(()=>{i({status:[]}),t(""),s(!1)},[]);return{searchQuery:l,inputValue:a,setSearchQuery:t,filterModalOpen:n,openFilterModal:u,setFilterModalOpen:s,filters:o,handleApplyFilters:d,handleResetFilters:f,filtersActive:c}}function Nn(e){const[a,t]=g.useState({}),n=g.useMemo(()=>Object.values(a).filter(Boolean).length,[a]),s=g.useCallback(l=>{if(l){const c={};e.forEach(u=>{c[u.id]=!0}),t(c)}else t({})},[e]),o=g.useCallback((l,c)=>{t(u=>({...u,[l]:c}))},[]),i=g.useCallback(()=>{t({})},[]);return{selectedTraces:a,selectedCount:n,handleSelectAll:s,handleSelectRow:o,resetSelection:i}}function pn(e="desc"){const[a,t]=g.useState(e),[n,s]=g.useState([{id:"startTime",desc:e==="desc"}]),o=g.useCallback(()=>{const l=a==="desc"?"asc":"desc";t(l),s([{id:"startTime",desc:l==="desc"}])},[a]),i=g.useCallback(()=>{t(e),s([{id:"startTime",desc:e==="desc"}])},[e]);return{sortDirection:a,sorting:n,handleToggleSortDirection:o,setSorting:s,resetSort:i}}function Dn(){const[e,a]=g.useState(!1),[t,n]=g.useState(null),s=g.useCallback(i=>{n(i),a(!0)},[]),o=g.useCallback(()=>{a(!1),n(null)},[]);return{isDetailSheetOpen:e,currentTraceDetail:t,openDetailSheet:s,closeDetailSheet:o,setIsDetailSheetOpen:a}}const Ze=6048e5,Mn=864e5,De=43200,_t=1440,Tt=Symbol.for("constructDateFrom");function P(e,a){return typeof e=="function"?e(a):e&&typeof e=="object"&&Tt in e?e[Tt](a):e instanceof Date?new e.constructor(a):new Date(a)}function D(e,a){return P(a||e,e)}function F(e,a,t){const n=D(e,t==null?void 0:t.in);return isNaN(a)?P((t==null?void 0:t.in)||e,NaN):(a&&n.setDate(n.getDate()+a),n)}function H(e,a,t){const n=D(e,t==null?void 0:t.in);if(isNaN(a))return P((t==null?void 0:t.in)||e,NaN);if(!a)return n;const s=n.getDate(),o=P((t==null?void 0:t.in)||e,n.getTime());o.setMonth(n.getMonth()+a+1,0);const i=o.getDate();return s>=i?o:(n.setFullYear(o.getFullYear(),o.getMonth(),s),n)}let Cn={};function he(){return Cn}function q(e,a){var l,c,u,d;const t=he(),n=(a==null?void 0:a.weekStartsOn)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=D(e,a==null?void 0:a.in),o=s.getDay(),i=(o<n?7:0)+o-n;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function oe(e,a){return q(e,{...a,weekStartsOn:1})}function Zt(e,a){const t=D(e,a==null?void 0:a.in),n=t.getFullYear(),s=P(t,0);s.setFullYear(n+1,0,4),s.setHours(0,0,0,0);const o=oe(s),i=P(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const l=oe(i);return t.getTime()>=o.getTime()?n+1:t.getTime()>=l.getTime()?n:n-1}function de(e){const a=D(e),t=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return t.setUTCFullYear(a.getFullYear()),+e-+t}function J(e,...a){const t=P.bind(null,e||a.find(n=>typeof n=="object"));return a.map(t)}function ue(e,a){const t=D(e,a==null?void 0:a.in);return t.setHours(0,0,0,0),t}function $(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a),o=ue(n),i=ue(s),l=+o-de(o),c=+i-de(i);return Math.round((l-c)/Mn)}function kn(e,a){const t=Zt(e,a),n=P(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),oe(n)}function Ue(e,a,t){return F(e,a*7,t)}function Sn(e,a,t){return H(e,a*12,t)}function _n(e,a){let t,n=a==null?void 0:a.in;return e.forEach(s=>{!n&&typeof s=="object"&&(n=P.bind(null,s));const o=D(s,n);(!t||t<o||isNaN(+o))&&(t=o)}),P(n,t||NaN)}function Tn(e,a){let t,n=a==null?void 0:a.in;return e.forEach(s=>{!n&&typeof s=="object"&&(n=P.bind(null,s));const o=D(s,n);(!t||t>o||isNaN(+o))&&(t=o)}),P(n,t||NaN)}function Me(e,a){const t=+D(e)-+D(a);return t<0?-1:t>0?1:t}function Pn(e){return P(e,Date.now())}function E(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a);return+ue(n)==+ue(s)}function et(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function On(e){return!(!et(e)&&typeof e!="number"||isNaN(+D(e)))}function me(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a),o=n.getFullYear()-s.getFullYear(),i=n.getMonth()-s.getMonth();return o*12+i}function Fn(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a),o=q(n,t),i=q(s,t),l=+o-de(o),c=+i-de(i);return Math.round((l-c)/Ze)}function Wn(e){return a=>{const n=(e?Math[e]:Math.trunc)(a);return n===0?0:n}}function En(e,a){return+D(e)-+D(a)}function In(e,a){const t=D(e,a==null?void 0:a.in);return t.setHours(23,59,59,999),t}function Te(e,a){const t=D(e,a==null?void 0:a.in),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Yn(e,a){const t=D(e,a==null?void 0:a.in);return+In(t,a)==+Te(t,a)}function Rn(e,a,t){const[n,s,o]=J(t==null?void 0:t.in,e,e,a),i=Me(s,o),l=Math.abs(me(s,o));if(l<1)return 0;s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-i*l);let c=Me(s,o)===-i;Yn(n)&&l===1&&Me(n,o)===1&&(c=!1);const u=i*(l-+c);return u===0?0:u}function Ln(e,a,t){const n=En(e,a)/1e3;return Wn(t==null?void 0:t.roundingMethod)(n)}function I(e,a){const t=D(e,a==null?void 0:a.in);return t.setDate(1),t.setHours(0,0,0,0),t}function ea(e,a){const t=D(e,a==null?void 0:a.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}function tt(e,a){var l,c,u,d;const t=he(),n=(a==null?void 0:a.weekStartsOn)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=D(e,a==null?void 0:a.in),o=s.getDay(),i=(o<n?-7:0)+6-(o-n);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}function ta(e,a){return tt(e,{...a,weekStartsOn:1})}const An={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Hn=(e,a,t)=>{let n;const s=An[e];return typeof s=="string"?n=s:a===1?n=s.one:n=s.other.replace("{{count}}",a.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function Ie(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Bn={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$n={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Vn={date:Ie({formats:Bn,defaultWidth:"full"}),time:Ie({formats:$n,defaultWidth:"full"}),dateTime:Ie({formats:qn,defaultWidth:"full"})},zn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Qn=(e,a,t,n)=>zn[e];function ve(e){return(a,t)=>{const n=t!=null&&t.context?String(t.context):"standalone";let s;if(n==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,l=t!=null&&t.width?String(t.width):i;s=e.formattingValues[l]||e.formattingValues[i]}else{const i=e.defaultWidth,l=t!=null&&t.width?String(t.width):e.defaultWidth;s=e.values[l]||e.values[i]}const o=e.argumentCallback?e.argumentCallback(a):a;return s[o]}}const Xn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Gn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Kn={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Un={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Jn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Zn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},er=(e,a)=>{const t=Number(e),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},tr={ordinalNumber:er,era:ve({values:Xn,defaultWidth:"wide"}),quarter:ve({values:Gn,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ve({values:Kn,defaultWidth:"wide"}),day:ve({values:Un,defaultWidth:"wide"}),dayPeriod:ve({values:Jn,defaultWidth:"wide",formattingValues:Zn,defaultFormattingWidth:"wide"})};function ye(e){return(a,t={})=>{const n=t.width,s=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],o=a.match(s);if(!o)return null;const i=o[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?nr(l,f=>f.test(i)):ar(l,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=t.valueCallback?t.valueCallback(u):u;const d=a.slice(i.length);return{value:u,rest:d}}}function ar(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t}function nr(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t}function rr(e){return(a,t={})=>{const n=a.match(e.matchPattern);if(!n)return null;const s=n[0],o=a.match(e.parsePattern);if(!o)return null;let i=e.valueCallback?e.valueCallback(o[0]):o[0];i=t.valueCallback?t.valueCallback(i):i;const l=a.slice(s.length);return{value:i,rest:l}}}const sr=/^(\d+)(th|st|nd|rd)?/i,or=/\d+/i,ir={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},lr={any:[/^b/i,/^(a|c)/i]},cr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},dr={any:[/1/i,/2/i,/3/i,/4/i]},ur={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},mr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},fr={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},hr={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},xr={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},gr={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},vr={ordinalNumber:rr({matchPattern:sr,parsePattern:or,valueCallback:e=>parseInt(e,10)}),era:ye({matchPatterns:ir,defaultMatchWidth:"wide",parsePatterns:lr,defaultParseWidth:"any"}),quarter:ye({matchPatterns:cr,defaultMatchWidth:"wide",parsePatterns:dr,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ye({matchPatterns:ur,defaultMatchWidth:"wide",parsePatterns:mr,defaultParseWidth:"any"}),day:ye({matchPatterns:fr,defaultMatchWidth:"wide",parsePatterns:hr,defaultParseWidth:"any"}),dayPeriod:ye({matchPatterns:xr,defaultMatchWidth:"any",parsePatterns:gr,defaultParseWidth:"any"})},at={code:"en-US",formatDistance:Hn,formatLong:Vn,formatRelative:Qn,localize:tr,match:vr,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yr(e,a){const t=D(e,a==null?void 0:a.in);return $(t,ea(t))+1}function aa(e,a){const t=D(e,a==null?void 0:a.in),n=+oe(t)-+kn(t);return Math.round(n/Ze)+1}function na(e,a){var d,f,m,h;const t=D(e,a==null?void 0:a.in),n=t.getFullYear(),s=he(),o=(a==null?void 0:a.firstWeekContainsDate)??((f=(d=a==null?void 0:a.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((h=(m=s.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??1,i=P((a==null?void 0:a.in)||e,0);i.setFullYear(n+1,0,o),i.setHours(0,0,0,0);const l=q(i,a),c=P((a==null?void 0:a.in)||e,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=q(c,a);return+t>=+l?n+1:+t>=+u?n:n-1}function br(e,a){var l,c,u,d;const t=he(),n=(a==null?void 0:a.firstWeekContainsDate)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??t.firstWeekContainsDate??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=na(e,a),o=P((a==null?void 0:a.in)||e,0);return o.setFullYear(s,0,n),o.setHours(0,0,0,0),q(o,a)}function ra(e,a){const t=D(e,a==null?void 0:a.in),n=+q(t,a)-+br(t,a);return Math.round(n/Ze)+1}function C(e,a){const t=e<0?"-":"",n=Math.abs(e).toString().padStart(a,"0");return t+n}const K={y(e,a){const t=e.getFullYear(),n=t>0?t:1-t;return C(a==="yy"?n%100:n,a.length)},M(e,a){const t=e.getMonth();return a==="M"?String(t+1):C(t+1,2)},d(e,a){return C(e.getDate(),a.length)},a(e,a){const t=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(e,a){return C(e.getHours()%12||12,a.length)},H(e,a){return C(e.getHours(),a.length)},m(e,a){return C(e.getMinutes(),a.length)},s(e,a){return C(e.getSeconds(),a.length)},S(e,a){const t=a.length,n=e.getMilliseconds(),s=Math.trunc(n*Math.pow(10,t-3));return C(s,a.length)}},le={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Pt={G:function(e,a,t){const n=e.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});case"GGGG":default:return t.era(n,{width:"wide"})}},y:function(e,a,t){if(a==="yo"){const n=e.getFullYear(),s=n>0?n:1-n;return t.ordinalNumber(s,{unit:"year"})}return K.y(e,a)},Y:function(e,a,t,n){const s=na(e,n),o=s>0?s:1-s;if(a==="YY"){const i=o%100;return C(i,2)}return a==="Yo"?t.ordinalNumber(o,{unit:"year"}):C(o,a.length)},R:function(e,a){const t=Zt(e);return C(t,a.length)},u:function(e,a){const t=e.getFullYear();return C(t,a.length)},Q:function(e,a,t){const n=Math.ceil((e.getMonth()+1)/3);switch(a){case"Q":return String(n);case"QQ":return C(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,a,t){const n=Math.ceil((e.getMonth()+1)/3);switch(a){case"q":return String(n);case"qq":return C(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,a,t){const n=e.getMonth();switch(a){case"M":case"MM":return K.M(e,a);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(e,a,t){const n=e.getMonth();switch(a){case"L":return String(n+1);case"LL":return C(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(e,a,t,n){const s=ra(e,n);return a==="wo"?t.ordinalNumber(s,{unit:"week"}):C(s,a.length)},I:function(e,a,t){const n=aa(e);return a==="Io"?t.ordinalNumber(n,{unit:"week"}):C(n,a.length)},d:function(e,a,t){return a==="do"?t.ordinalNumber(e.getDate(),{unit:"date"}):K.d(e,a)},D:function(e,a,t){const n=yr(e);return a==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):C(n,a.length)},E:function(e,a,t){const n=e.getDay();switch(a){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});case"EEEE":default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(e,a,t,n){const s=e.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(a){case"e":return String(o);case"ee":return C(o,2);case"eo":return t.ordinalNumber(o,{unit:"day"});case"eee":return t.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(s,{width:"short",context:"formatting"});case"eeee":default:return t.day(s,{width:"wide",context:"formatting"})}},c:function(e,a,t,n){const s=e.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(a){case"c":return String(o);case"cc":return C(o,a.length);case"co":return t.ordinalNumber(o,{unit:"day"});case"ccc":return t.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(s,{width:"narrow",context:"standalone"});case"cccccc":return t.day(s,{width:"short",context:"standalone"});case"cccc":default:return t.day(s,{width:"wide",context:"standalone"})}},i:function(e,a,t){const n=e.getDay(),s=n===0?7:n;switch(a){case"i":return String(s);case"ii":return C(s,a.length);case"io":return t.ordinalNumber(s,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});case"iiii":default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(e,a,t){const s=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,a,t){const n=e.getHours();let s;switch(n===12?s=le.noon:n===0?s=le.midnight:s=n/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,a,t){const n=e.getHours();let s;switch(n>=17?s=le.evening:n>=12?s=le.afternoon:n>=4?s=le.morning:s=le.night,a){case"B":case"BB":case"BBB":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,a,t){if(a==="ho"){let n=e.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return K.h(e,a)},H:function(e,a,t){return a==="Ho"?t.ordinalNumber(e.getHours(),{unit:"hour"}):K.H(e,a)},K:function(e,a,t){const n=e.getHours()%12;return a==="Ko"?t.ordinalNumber(n,{unit:"hour"}):C(n,a.length)},k:function(e,a,t){let n=e.getHours();return n===0&&(n=24),a==="ko"?t.ordinalNumber(n,{unit:"hour"}):C(n,a.length)},m:function(e,a,t){return a==="mo"?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):K.m(e,a)},s:function(e,a,t){return a==="so"?t.ordinalNumber(e.getSeconds(),{unit:"second"}):K.s(e,a)},S:function(e,a){return K.S(e,a)},X:function(e,a,t){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(a){case"X":return Ft(n);case"XXXX":case"XX":return re(n);case"XXXXX":case"XXX":default:return re(n,":")}},x:function(e,a,t){const n=e.getTimezoneOffset();switch(a){case"x":return Ft(n);case"xxxx":case"xx":return re(n);case"xxxxx":case"xxx":default:return re(n,":")}},O:function(e,a,t){const n=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ot(n,":");case"OOOO":default:return"GMT"+re(n,":")}},z:function(e,a,t){const n=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ot(n,":");case"zzzz":default:return"GMT"+re(n,":")}},t:function(e,a,t){const n=Math.trunc(+e/1e3);return C(n,a.length)},T:function(e,a,t){return C(+e,a.length)}};function Ot(e,a=""){const t=e>0?"-":"+",n=Math.abs(e),s=Math.trunc(n/60),o=n%60;return o===0?t+String(s):t+String(s)+a+C(o,2)}function Ft(e,a){return e%60===0?(e>0?"-":"+")+C(Math.abs(e)/60,2):re(e,a)}function re(e,a=""){const t=e>0?"-":"+",n=Math.abs(e),s=C(Math.trunc(n/60),2),o=C(n%60,2);return t+s+a+o}const Wt=(e,a)=>{switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});case"PPPP":default:return a.date({width:"full"})}},sa=(e,a)=>{switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});case"pppp":default:return a.time({width:"full"})}},wr=(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],n=t[1],s=t[2];if(!s)return Wt(e,a);let o;switch(n){case"P":o=a.dateTime({width:"short"});break;case"PP":o=a.dateTime({width:"medium"});break;case"PPP":o=a.dateTime({width:"long"});break;case"PPPP":default:o=a.dateTime({width:"full"});break}return o.replace("{{date}}",Wt(n,a)).replace("{{time}}",sa(s,a))},jr={p:sa,P:wr},Nr=/^D+$/,pr=/^Y+$/,Dr=["D","DD","YY","YYYY"];function Mr(e){return Nr.test(e)}function Cr(e){return pr.test(e)}function kr(e,a,t){const n=Sr(e,a,t);if(console.warn(n),Dr.includes(e))throw new RangeError(n)}function Sr(e,a,t){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${a}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const _r=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Tr=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pr=/^'([^]*?)'?$/,Or=/''/g,Fr=/[a-zA-Z]/;function T(e,a,t){var d,f,m,h,x,v,y,p;const n=he(),s=(t==null?void 0:t.locale)??n.locale??at,o=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((h=(m=n.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??1,i=(t==null?void 0:t.weekStartsOn)??((v=(x=t==null?void 0:t.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??n.weekStartsOn??((p=(y=n.locale)==null?void 0:y.options)==null?void 0:p.weekStartsOn)??0,l=D(e,t==null?void 0:t.in);if(!On(l))throw new RangeError("Invalid time value");let c=a.match(Tr).map(b=>{const M=b[0];if(M==="p"||M==="P"){const k=jr[M];return k(b,s.formatLong)}return b}).join("").match(_r).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const M=b[0];if(M==="'")return{isToken:!1,value:Wr(b)};if(Pt[M])return{isToken:!0,value:b};if(M.match(Fr))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:b}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,c));const u={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return c.map(b=>{if(!b.isToken)return b.value;const M=b.value;(!(t!=null&&t.useAdditionalWeekYearTokens)&&Cr(M)||!(t!=null&&t.useAdditionalDayOfYearTokens)&&Mr(M))&&kr(M,a,String(e));const k=Pt[M[0]];return k(l,M,s.localize,u)}).join("")}function Wr(e){const a=e.match(Pr);return a?a[1].replace(Or,"'"):e}function Er(e,a,t){const n=he(),s=(t==null?void 0:t.locale)??n.locale??at,o=2520,i=Me(e,a);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:i}),[c,u]=J(t==null?void 0:t.in,...i>0?[a,e]:[e,a]),d=Ln(u,c),f=(de(u)-de(c))/1e3,m=Math.round((d-f)/60);let h;if(m<2)return t!=null&&t.includeSeconds?d<5?s.formatDistance("lessThanXSeconds",5,l):d<10?s.formatDistance("lessThanXSeconds",10,l):d<20?s.formatDistance("lessThanXSeconds",20,l):d<40?s.formatDistance("halfAMinute",0,l):d<60?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",1,l):m===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",m,l);if(m<45)return s.formatDistance("xMinutes",m,l);if(m<90)return s.formatDistance("aboutXHours",1,l);if(m<_t){const x=Math.round(m/60);return s.formatDistance("aboutXHours",x,l)}else{if(m<o)return s.formatDistance("xDays",1,l);if(m<De){const x=Math.round(m/_t);return s.formatDistance("xDays",x,l)}else if(m<De*2)return h=Math.round(m/De),s.formatDistance("aboutXMonths",h,l)}if(h=Rn(u,c),h<12){const x=Math.round(m/De);return s.formatDistance("xMonths",x,l)}else{const x=h%12,v=Math.trunc(h/12);return x<3?s.formatDistance("aboutXYears",v,l):x<9?s.formatDistance("overXYears",v,l):s.formatDistance("almostXYears",v+1,l)}}function Ir(e,a){return Er(e,Pn(e),a)}function Yr(e,a){const t=D(e,a==null?void 0:a.in),n=t.getFullYear(),s=t.getMonth(),o=P(t,0);return o.setFullYear(n,s+1,0),o.setHours(0,0,0,0),o.getDate()}function Rr(e){return Math.trunc(+D(e)/1e3)}function Lr(e,a){const t=D(e,a==null?void 0:a.in),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(0,0,0,0),D(t,a==null?void 0:a.in)}function Ar(e,a){const t=D(e,a==null?void 0:a.in);return Fn(Lr(t,a),I(t,a),a)+1}function Je(e,a){return+D(e)>+D(a)}function oa(e,a){return+D(e)<+D(a)}function nt(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()}function Hr(e,a,t){const[n,s]=J(t==null?void 0:t.in,e,a);return n.getFullYear()===s.getFullYear()}function Ye(e,a,t){return F(e,-a,t)}function Re(e,a,t){const n=D(e,t==null?void 0:t.in),s=n.getFullYear(),o=n.getDate(),i=P(e,0);i.setFullYear(s,a,15),i.setHours(0,0,0,0);const l=Yr(i);return n.setMonth(a,Math.min(o,l)),n}function Et(e,a,t){const n=D(e,t==null?void 0:t.in);return isNaN(+n)?P(e,NaN):(n.setFullYear(a),n)}function Br({sortDirection:e,onToggleSortDirection:a,displayedTraceCount:t,isLoading:n,onRefresh:s}){return r.jsxs("div",{className:"flex items-center justify-between p-6 pb-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ce,{className:"h-5 w-5 text-blue-600"}),r.jsx("h3",{className:"text-xl font-semibold text-gray-900",children:"Traces"})]}),r.jsx("p",{className:"text-sm text-gray-600",children:n?"Loading traces...":t!==void 0?r.jsxs(r.Fragment,{children:[t," trace",t!==1?"s":""," found",t>0&&r.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:["• Last updated ",Ir(new Date,{addSuffix:!0})]})]}):"Traces"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(O,{variant:"outline",size:"sm",onClick:a,className:"border-gray-200 hover:bg-gray-50",children:["Sort ",e==="desc"?"↓":"↑"]}),r.jsxs(O,{variant:"outline",size:"sm",onClick:s,className:"border-gray-200 hover:bg-gray-50",disabled:n,children:[r.jsx(Gt,{className:`h-4 w-4 mr-2 ${n?"animate-spin":""}`}),"Refresh"]})]})]})}function $r({searchQuery:e,onSearchQueryChange:a,onOpenFilterModal:t,selectedCount:n,onDeleteSelected:s,onExportSelected:o,onCopySelected:i,isLoading:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-4 px-6 py-4 border-t border-gray-100",children:[r.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(tn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4"}),r.jsx(Qe,{placeholder:"Search traces...",value:e,onChange:c=>a(c.target.value),className:"pl-10 border-gray-200 focus:border-blue-500 focus:ring-blue-500",disabled:l})]}),r.jsxs(O,{variant:"outline",size:"sm",onClick:t,className:"border-gray-200 hover:bg-gray-50",disabled:l,children:[r.jsx(qa,{className:"h-4 w-4 mr-2"}),"Filter"]})]}),n>0&&r.jsxs(r.Fragment,{children:[r.jsx(qe,{orientation:"vertical",className:"h-6"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(R,{variant:"secondary",className:"text-sm",children:[n," selected"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(O,{variant:"outline",size:"sm",onClick:i,className:"border-gray-200 hover:bg-gray-50",children:[r.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Copy"]}),r.jsxs(O,{variant:"outline",size:"sm",onClick:o,className:"border-gray-200 hover:bg-gray-50",children:[r.jsx(Va,{className:"h-4 w-4 mr-2"}),"Export"]}),r.jsxs(O,{variant:"outline",size:"sm",onClick:s,className:"border-red-200 text-red-600 hover:bg-red-50",children:[r.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}function qr({table:e,columns:a,isLoading:t,isError:n,traces:s,selectedTraces:o,isFiltered:i,onRetry:l,onClearFilters:c}){var u;return n?r.jsx("div",{className:"border-t border-gray-100",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6",children:[r.jsx(Ia,{className:"h-12 w-12 text-red-400 mb-4"}),r.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Error loading traces"}),r.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"There was a problem loading the traces. Please try again."}),r.jsxs(O,{onClick:l,variant:"outline",children:[r.jsx(Gt,{className:"h-4 w-4 mr-2"}),"Try Again"]})]})}):r.jsx("div",{className:"border-t border-gray-100",children:r.jsxs(za,{children:[r.jsx(Qa,{children:e.getHeaderGroups().map(d=>r.jsx(pe,{className:"border-b border-gray-100 bg-gray-50/50",children:d.headers.map(f=>r.jsx(Xa,{className:"font-semibold text-gray-700 py-4",children:f.isPlaceholder?null:f.column.getCanSort()?r.jsxs(O,{variant:"ghost",onClick:f.column.getToggleSortingHandler(),className:"-ml-4 h-auto p-0 hover:bg-transparent font-semibold text-gray-700 hover:text-gray-900",children:[We(f.column.columnDef.header,f.getContext()),f.column.getIsSorted()==="asc"&&" ↑",f.column.getIsSorted()==="desc"&&" ↓"]}):We(f.column.columnDef.header,f.getContext())},f.id))},d.id))}),r.jsx(Ga,{children:t?(s.length>0?s:Array.from({length:5})).map((d,f)=>r.jsx(pe,{className:"border-b border-gray-50",children:a.map((m,h)=>r.jsx(Ee,{className:"py-6",children:r.jsx(an,{className:"h-4 w-full"})},h))},f)):(u=e.getRowModel().rows)!=null&&u.length?e.getRowModel().rows.map((d,f)=>r.jsx(pe,{"data-state":o[d.original.id]?"selected":void 0,className:`
                  ${f%2===0?"bg-white/60":"bg-gray-50/60"} 
                  ${o[d.original.id]?"bg-gradient-to-r from-blue-50/80 to-blue-100/60 border-l-4 border-blue-500 shadow-sm":""}
                  hover:bg-gradient-to-r hover:from-blue-50/70 hover:to-blue-100/50 hover:shadow-md hover:scale-[1.01] transition-all duration-300 border-b border-gray-200/60
                  data-[state=selected]:bg-gradient-to-r data-[state=selected]:from-blue-50/80 data-[state=selected]:to-blue-100/60
                  cursor-pointer
                `,children:d.getVisibleCells().map(m=>r.jsx(Ee,{className:"py-5 px-6 text-gray-900",style:{width:m.column.getSize()!==150?m.column.getSize():void 0},children:We(m.column.columnDef.cell,m.getContext())},m.id))},d.id)):r.jsx(pe,{children:r.jsx(Ee,{colSpan:a.length,className:"h-32 text-center",children:r.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[r.jsx(ce,{className:"h-12 w-12 text-gray-300"}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-sm font-medium text-gray-900",children:i?"No traces match your filters":"No traces found"}),r.jsx("p",{className:"text-xs text-gray-500",children:i?"Try adjusting your search or filters":"Traces will appear here when they are created"})]}),i&&r.jsx(O,{variant:"outline",size:"sm",onClick:c,children:"Clear filters"})]})})})})]})})}function Vr({currentPage:e,hasNextPage:a,onPrevPage:t,onNextPage:n,isLoading:s,currentTraceCount:o,pageSize:i}){const l=e>0,c=a&&!s;return r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-gray-100",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"text-sm text-gray-600",children:["Page ",r.jsx("span",{className:"font-medium",children:e+1})]}),o>0&&r.jsxs("div",{className:"text-xs text-gray-500",children:["Showing ",o," traces"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(O,{variant:"outline",size:"sm",onClick:t,disabled:!l||s,className:"border-gray-200 hover:bg-gray-50 disabled:opacity-50",children:[r.jsx(Qt,{className:"h-4 w-4 mr-1"}),"Previous"]}),r.jsxs(O,{variant:"outline",size:"sm",onClick:n,disabled:!c,className:"border-gray-200 hover:bg-gray-50 disabled:opacity-50",children:["Next",r.jsx(_e,{className:"h-4 w-4 ml-1"})]})]})]})}var N=function(){return N=Object.assign||function(a){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(a[o]=t[o])}return a},N.apply(this,arguments)};function zr(e,a){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)a.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]]);return t}function ia(e,a,t){for(var n=0,s=a.length,o;n<s;n++)(o||!(n in a))&&(o||(o=Array.prototype.slice.call(a,0,n)),o[n]=a[n]);return e.concat(o||Array.prototype.slice.call(a))}function be(e){return e.mode==="multiple"}function we(e){return e.mode==="range"}function Pe(e){return e.mode==="single"}var Qr={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function Xr(e,a){return T(e,"LLLL y",a)}function Gr(e,a){return T(e,"d",a)}function Kr(e,a){return T(e,"LLLL",a)}function Ur(e){return"".concat(e)}function Jr(e,a){return T(e,"cccccc",a)}function Zr(e,a){return T(e,"yyyy",a)}var es=Object.freeze({__proto__:null,formatCaption:Xr,formatDay:Gr,formatMonthCaption:Kr,formatWeekNumber:Ur,formatWeekdayName:Jr,formatYearCaption:Zr}),ts=function(e,a,t){return T(e,"do MMMM (EEEE)",t)},as=function(){return"Month: "},ns=function(){return"Go to next month"},rs=function(){return"Go to previous month"},ss=function(e,a){return T(e,"cccc",a)},os=function(e){return"Week n. ".concat(e)},is=function(){return"Year: "},ls=Object.freeze({__proto__:null,labelDay:ts,labelMonthDropdown:as,labelNext:ns,labelPrevious:rs,labelWeekNumber:os,labelWeekday:ss,labelYearDropdown:is});function cs(){var e="buttons",a=Qr,t=at,n={},s={},o=1,i={},l=new Date;return{captionLayout:e,classNames:a,formatters:es,labels:ls,locale:t,modifiersClassNames:n,modifiers:s,numberOfMonths:o,styles:i,today:l,mode:"default"}}function ds(e){var a=e.fromYear,t=e.toYear,n=e.fromMonth,s=e.toMonth,o=e.fromDate,i=e.toDate;return n?o=I(n):a&&(o=new Date(a,0,1)),s?i=Te(s):t&&(i=new Date(t,11,31)),{fromDate:o?ue(o):void 0,toDate:i?ue(i):void 0}}var la=g.createContext(void 0);function us(e){var a,t=e.initialProps,n=cs(),s=ds(t),o=s.fromDate,i=s.toDate,l=(a=t.captionLayout)!==null&&a!==void 0?a:n.captionLayout;l!=="buttons"&&(!o||!i)&&(l="buttons");var c;(Pe(t)||be(t)||we(t))&&(c=t.onSelect);var u=N(N(N({},n),t),{captionLayout:l,classNames:N(N({},n.classNames),t.classNames),components:N({},t.components),formatters:N(N({},n.formatters),t.formatters),fromDate:o,labels:N(N({},n.labels),t.labels),mode:t.mode||n.mode,modifiers:N(N({},n.modifiers),t.modifiers),modifiersClassNames:N(N({},n.modifiersClassNames),t.modifiersClassNames),onSelect:c,styles:N(N({},n.styles),t.styles),toDate:i});return r.jsx(la.Provider,{value:u,children:e.children})}function S(){var e=g.useContext(la);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function ca(e){var a=S(),t=a.locale,n=a.classNames,s=a.styles,o=a.formatters.formatCaption;return r.jsx("div",{className:n.caption_label,style:s.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:o(e.displayMonth,{locale:t})})}function ms(e){return r.jsx("svg",N({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:r.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function da(e){var a,t,n=e.onChange,s=e.value,o=e.children,i=e.caption,l=e.className,c=e.style,u=S(),d=(t=(a=u.components)===null||a===void 0?void 0:a.IconDropdown)!==null&&t!==void 0?t:ms;return r.jsxs("div",{className:l,style:c,children:[r.jsx("span",{className:u.classNames.vhidden,children:e["aria-label"]}),r.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:u.classNames.dropdown,style:u.styles.dropdown,value:s,onChange:n,children:o}),r.jsxs("div",{className:u.classNames.caption_label,style:u.styles.caption_label,"aria-hidden":"true",children:[i,r.jsx(d,{className:u.classNames.dropdown_icon,style:u.styles.dropdown_icon})]})]})}function fs(e){var a,t=S(),n=t.fromDate,s=t.toDate,o=t.styles,i=t.locale,l=t.formatters.formatMonthCaption,c=t.classNames,u=t.components,d=t.labels.labelMonthDropdown;if(!n)return r.jsx(r.Fragment,{});if(!s)return r.jsx(r.Fragment,{});var f=[];if(Hr(n,s))for(var m=I(n),h=n.getMonth();h<=s.getMonth();h++)f.push(Re(m,h));else for(var m=I(new Date),h=0;h<=11;h++)f.push(Re(m,h));var x=function(y){var p=Number(y.target.value),b=Re(I(e.displayMonth),p);e.onChange(b)},v=(a=u==null?void 0:u.Dropdown)!==null&&a!==void 0?a:da;return r.jsx(v,{name:"months","aria-label":d(),className:c.dropdown_month,style:o.dropdown_month,onChange:x,value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:i}),children:f.map(function(y){return r.jsx("option",{value:y.getMonth(),children:l(y,{locale:i})},y.getMonth())})})}function hs(e){var a,t=e.displayMonth,n=S(),s=n.fromDate,o=n.toDate,i=n.locale,l=n.styles,c=n.classNames,u=n.components,d=n.formatters.formatYearCaption,f=n.labels.labelYearDropdown,m=[];if(!s)return r.jsx(r.Fragment,{});if(!o)return r.jsx(r.Fragment,{});for(var h=s.getFullYear(),x=o.getFullYear(),v=h;v<=x;v++)m.push(Et(ea(new Date),v));var y=function(b){var M=Et(I(t),Number(b.target.value));e.onChange(M)},p=(a=u==null?void 0:u.Dropdown)!==null&&a!==void 0?a:da;return r.jsx(p,{name:"years","aria-label":f(),className:c.dropdown_year,style:l.dropdown_year,onChange:y,value:t.getFullYear(),caption:d(t,{locale:i}),children:m.map(function(b){return r.jsx("option",{value:b.getFullYear(),children:d(b,{locale:i})},b.getFullYear())})})}function xs(e,a){var t=g.useState(e),n=t[0],s=t[1],o=a===void 0?n:a;return[o,s]}function gs(e){var a=e.month,t=e.defaultMonth,n=e.today,s=a||t||n||new Date,o=e.toDate,i=e.fromDate,l=e.numberOfMonths,c=l===void 0?1:l;if(o&&me(o,s)<0){var u=-1*(c-1);s=H(o,u)}return i&&me(s,i)<0&&(s=i),I(s)}function vs(){var e=S(),a=gs(e),t=xs(a,e.month),n=t[0],s=t[1],o=function(i){var l;if(!e.disableNavigation){var c=I(i);s(c),(l=e.onMonthChange)===null||l===void 0||l.call(e,c)}};return[n,o]}function ys(e,a){for(var t=a.reverseMonths,n=a.numberOfMonths,s=I(e),o=I(H(s,n)),i=me(o,s),l=[],c=0;c<i;c++){var u=H(s,c);l.push(u)}return t&&(l=l.reverse()),l}function bs(e,a){if(!a.disableNavigation){var t=a.toDate,n=a.pagedNavigation,s=a.numberOfMonths,o=s===void 0?1:s,i=n?o:1,l=I(e);if(!t)return H(l,i);var c=me(t,e);if(!(c<o))return H(l,i)}}function ws(e,a){if(!a.disableNavigation){var t=a.fromDate,n=a.pagedNavigation,s=a.numberOfMonths,o=s===void 0?1:s,i=n?o:1,l=I(e);if(!t)return H(l,-i);var c=me(l,t);if(!(c<=0))return H(l,-i)}}var ua=g.createContext(void 0);function js(e){var a=S(),t=vs(),n=t[0],s=t[1],o=ys(n,a),i=bs(n,a),l=ws(n,a),c=function(f){return o.some(function(m){return nt(f,m)})},u=function(f,m){c(f)||(m&&oa(f,m)?s(H(f,1+a.numberOfMonths*-1)):s(f))},d={currentMonth:n,displayMonths:o,goToMonth:s,goToDate:u,previousMonth:l,nextMonth:i,isDateDisplayed:c};return r.jsx(ua.Provider,{value:d,children:e.children})}function je(){var e=g.useContext(ua);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function It(e){var a,t=S(),n=t.classNames,s=t.styles,o=t.components,i=je().goToMonth,l=function(d){i(H(d,e.displayIndex?-e.displayIndex:0))},c=(a=o==null?void 0:o.CaptionLabel)!==null&&a!==void 0?a:ca,u=r.jsx(c,{id:e.id,displayMonth:e.displayMonth});return r.jsxs("div",{className:n.caption_dropdowns,style:s.caption_dropdowns,children:[r.jsx("div",{className:n.vhidden,children:u}),r.jsx(fs,{onChange:l,displayMonth:e.displayMonth}),r.jsx(hs,{onChange:l,displayMonth:e.displayMonth})]})}function Ns(e){return r.jsx("svg",N({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:r.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function ps(e){return r.jsx("svg",N({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:r.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Se=g.forwardRef(function(e,a){var t=S(),n=t.classNames,s=t.styles,o=[n.button_reset,n.button];e.className&&o.push(e.className);var i=o.join(" "),l=N(N({},s.button_reset),s.button);return e.style&&Object.assign(l,e.style),r.jsx("button",N({},e,{ref:a,type:"button",className:i,style:l}))});function Ds(e){var a,t,n=S(),s=n.dir,o=n.locale,i=n.classNames,l=n.styles,c=n.labels,u=c.labelPrevious,d=c.labelNext,f=n.components;if(!e.nextMonth&&!e.previousMonth)return r.jsx(r.Fragment,{});var m=u(e.previousMonth,{locale:o}),h=[i.nav_button,i.nav_button_previous].join(" "),x=d(e.nextMonth,{locale:o}),v=[i.nav_button,i.nav_button_next].join(" "),y=(a=f==null?void 0:f.IconRight)!==null&&a!==void 0?a:ps,p=(t=f==null?void 0:f.IconLeft)!==null&&t!==void 0?t:Ns;return r.jsxs("div",{className:i.nav,style:l.nav,children:[!e.hidePrevious&&r.jsx(Se,{name:"previous-month","aria-label":m,className:h,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:s==="rtl"?r.jsx(y,{className:i.nav_icon,style:l.nav_icon}):r.jsx(p,{className:i.nav_icon,style:l.nav_icon})}),!e.hideNext&&r.jsx(Se,{name:"next-month","aria-label":x,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:s==="rtl"?r.jsx(p,{className:i.nav_icon,style:l.nav_icon}):r.jsx(y,{className:i.nav_icon,style:l.nav_icon})})]})}function Yt(e){var a=S().numberOfMonths,t=je(),n=t.previousMonth,s=t.nextMonth,o=t.goToMonth,i=t.displayMonths,l=i.findIndex(function(x){return nt(e.displayMonth,x)}),c=l===0,u=l===i.length-1,d=a>1&&(c||!u),f=a>1&&(u||!c),m=function(){n&&o(n)},h=function(){s&&o(s)};return r.jsx(Ds,{displayMonth:e.displayMonth,hideNext:d,hidePrevious:f,nextMonth:s,previousMonth:n,onPreviousClick:m,onNextClick:h})}function Ms(e){var a,t=S(),n=t.classNames,s=t.disableNavigation,o=t.styles,i=t.captionLayout,l=t.components,c=(a=l==null?void 0:l.CaptionLabel)!==null&&a!==void 0?a:ca,u;return s?u=r.jsx(c,{id:e.id,displayMonth:e.displayMonth}):i==="dropdown"?u=r.jsx(It,{displayMonth:e.displayMonth,id:e.id}):i==="dropdown-buttons"?u=r.jsxs(r.Fragment,{children:[r.jsx(It,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),r.jsx(Yt,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=r.jsxs(r.Fragment,{children:[r.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),r.jsx(Yt,{displayMonth:e.displayMonth,id:e.id})]}),r.jsx("div",{className:n.caption,style:o.caption,children:u})}function Cs(e){var a=S(),t=a.footer,n=a.styles,s=a.classNames.tfoot;return t?r.jsx("tfoot",{className:s,style:n.tfoot,children:r.jsx("tr",{children:r.jsx("td",{colSpan:8,children:t})})}):r.jsx(r.Fragment,{})}function ks(e,a,t){for(var n=t?oe(new Date):q(new Date,{locale:e,weekStartsOn:a}),s=[],o=0;o<7;o++){var i=F(n,o);s.push(i)}return s}function Ss(){var e=S(),a=e.classNames,t=e.styles,n=e.showWeekNumber,s=e.locale,o=e.weekStartsOn,i=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,u=ks(s,o,i);return r.jsxs("tr",{style:t.head_row,className:a.head_row,children:[n&&r.jsx("td",{style:t.head_cell,className:a.head_cell}),u.map(function(d,f){return r.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":c(d,{locale:s}),children:l(d,{locale:s})},f)})]})}function _s(){var e,a=S(),t=a.classNames,n=a.styles,s=a.components,o=(e=s==null?void 0:s.HeadRow)!==null&&e!==void 0?e:Ss;return r.jsx("thead",{style:n.head,className:t.head,children:r.jsx(o,{})})}function Ts(e){var a=S(),t=a.locale,n=a.formatters.formatDay;return r.jsx(r.Fragment,{children:n(e.date,{locale:t})})}var rt=g.createContext(void 0);function Ps(e){if(!be(e.initialProps)){var a={selected:void 0,modifiers:{disabled:[]}};return r.jsx(rt.Provider,{value:a,children:e.children})}return r.jsx(Os,{initialProps:e.initialProps,children:e.children})}function Os(e){var a=e.initialProps,t=e.children,n=a.selected,s=a.min,o=a.max,i=function(u,d,f){var m,h;(m=a.onDayClick)===null||m===void 0||m.call(a,u,d,f);var x=!!(d.selected&&s&&(n==null?void 0:n.length)===s);if(!x){var v=!!(!d.selected&&o&&(n==null?void 0:n.length)===o);if(!v){var y=n?ia([],n):[];if(d.selected){var p=y.findIndex(function(b){return E(u,b)});y.splice(p,1)}else y.push(u);(h=a.onSelect)===null||h===void 0||h.call(a,y,u,d,f)}}},l={disabled:[]};n&&l.disabled.push(function(u){var d=o&&n.length>o-1,f=n.some(function(m){return E(m,u)});return!!(d&&!f)});var c={selected:n,onDayClick:i,modifiers:l};return r.jsx(rt.Provider,{value:c,children:t})}function st(){var e=g.useContext(rt);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function Fs(e,a){var t=a||{},n=t.from,s=t.to;return n&&s?E(s,e)&&E(n,e)?void 0:E(s,e)?{from:s,to:void 0}:E(n,e)?void 0:Je(n,e)?{from:e,to:s}:{from:n,to:e}:s?Je(e,s)?{from:s,to:e}:{from:e,to:s}:n?oa(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var ot=g.createContext(void 0);function Ws(e){if(!we(e.initialProps)){var a={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return r.jsx(ot.Provider,{value:a,children:e.children})}return r.jsx(Es,{initialProps:e.initialProps,children:e.children})}function Es(e){var a=e.initialProps,t=e.children,n=a.selected,s=n||{},o=s.from,i=s.to,l=a.min,c=a.max,u=function(h,x,v){var y,p;(y=a.onDayClick)===null||y===void 0||y.call(a,h,x,v);var b=Fs(h,n);(p=a.onSelect)===null||p===void 0||p.call(a,b,h,x,v)},d={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(d.range_start=[o],i?(d.range_end=[i],E(o,i)||(d.range_middle=[{after:o,before:i}])):d.range_end=[o]):i&&(d.range_start=[i],d.range_end=[i]),l&&(o&&!i&&d.disabled.push({after:Ye(o,l-1),before:F(o,l-1)}),o&&i&&d.disabled.push({after:o,before:F(o,l-1)}),!o&&i&&d.disabled.push({after:Ye(i,l-1),before:F(i,l-1)})),c){if(o&&!i&&(d.disabled.push({before:F(o,-c+1)}),d.disabled.push({after:F(o,c-1)})),o&&i){var f=$(i,o)+1,m=c-f;d.disabled.push({before:Ye(o,m)}),d.disabled.push({after:F(i,m)})}!o&&i&&(d.disabled.push({before:F(i,-c+1)}),d.disabled.push({after:F(i,c-1)}))}return r.jsx(ot.Provider,{value:{selected:n,onDayClick:u,modifiers:d},children:t})}function it(){var e=g.useContext(ot);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Ce(e){return Array.isArray(e)?ia([],e):e!==void 0?[e]:[]}function Is(e){var a={};return Object.entries(e).forEach(function(t){var n=t[0],s=t[1];a[n]=Ce(s)}),a}var B;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(B||(B={}));var Ys=B.Selected,z=B.Disabled,Rs=B.Hidden,Ls=B.Today,Le=B.RangeEnd,Ae=B.RangeMiddle,He=B.RangeStart,As=B.Outside;function Hs(e,a,t){var n,s=(n={},n[Ys]=Ce(e.selected),n[z]=Ce(e.disabled),n[Rs]=Ce(e.hidden),n[Ls]=[e.today],n[Le]=[],n[Ae]=[],n[He]=[],n[As]=[],n);return e.fromDate&&s[z].push({before:e.fromDate}),e.toDate&&s[z].push({after:e.toDate}),be(e)?s[z]=s[z].concat(a.modifiers[z]):we(e)&&(s[z]=s[z].concat(t.modifiers[z]),s[He]=t.modifiers[He],s[Ae]=t.modifiers[Ae],s[Le]=t.modifiers[Le]),s}var ma=g.createContext(void 0);function Bs(e){var a=S(),t=st(),n=it(),s=Hs(a,t,n),o=Is(a.modifiers),i=N(N({},s),o);return r.jsx(ma.Provider,{value:i,children:e.children})}function fa(){var e=g.useContext(ma);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function $s(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function qs(e){return!!(e&&typeof e=="object"&&"from"in e)}function Vs(e){return!!(e&&typeof e=="object"&&"after"in e)}function zs(e){return!!(e&&typeof e=="object"&&"before"in e)}function Qs(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function Xs(e,a){var t,n=a.from,s=a.to;if(n&&s){var o=$(s,n)<0;o&&(t=[s,n],n=t[0],s=t[1]);var i=$(e,n)>=0&&$(s,e)>=0;return i}return s?E(s,e):n?E(n,e):!1}function Gs(e){return et(e)}function Ks(e){return Array.isArray(e)&&e.every(et)}function Us(e,a){return a.some(function(t){if(typeof t=="boolean")return t;if(Gs(t))return E(e,t);if(Ks(t))return t.includes(e);if(qs(t))return Xs(e,t);if(Qs(t))return t.dayOfWeek.includes(e.getDay());if($s(t)){var n=$(t.before,e),s=$(t.after,e),o=n>0,i=s<0,l=Je(t.before,t.after);return l?i&&o:o||i}return Vs(t)?$(e,t.after)>0:zs(t)?$(t.before,e)>0:typeof t=="function"?t(e):!1})}function lt(e,a,t){var n=Object.keys(a).reduce(function(o,i){var l=a[i];return Us(e,l)&&o.push(i),o},[]),s={};return n.forEach(function(o){return s[o]=!0}),t&&!nt(e,t)&&(s.outside=!0),s}function Js(e,a){for(var t=I(e[0]),n=Te(e[e.length-1]),s,o,i=t;i<=n;){var l=lt(i,a),c=!l.disabled&&!l.hidden;if(!c){i=F(i,1);continue}if(l.selected)return i;l.today&&!o&&(o=i),s||(s=i),i=F(i,1)}return o||s}var Zs=365;function ha(e,a){var t=a.moveBy,n=a.direction,s=a.context,o=a.modifiers,i=a.retry,l=i===void 0?{count:0,lastFocused:e}:i,c=s.weekStartsOn,u=s.fromDate,d=s.toDate,f=s.locale,m={day:F,week:Ue,month:H,year:Sn,startOfWeek:function(y){return s.ISOWeek?oe(y):q(y,{locale:f,weekStartsOn:c})},endOfWeek:function(y){return s.ISOWeek?ta(y):tt(y,{locale:f,weekStartsOn:c})}},h=m[t](e,n==="after"?1:-1);n==="before"&&u?h=_n([u,h]):n==="after"&&d&&(h=Tn([d,h]));var x=!0;if(o){var v=lt(h,o);x=!v.disabled&&!v.hidden}return x?h:l.count>Zs?l.lastFocused:ha(h,{moveBy:t,direction:n,context:s,modifiers:o,retry:N(N({},l),{count:l.count+1})})}var xa=g.createContext(void 0);function eo(e){var a=je(),t=fa(),n=g.useState(),s=n[0],o=n[1],i=g.useState(),l=i[0],c=i[1],u=Js(a.displayMonths,t),d=s??(l&&a.isDateDisplayed(l))?l:u,f=function(){c(s),o(void 0)},m=function(y){o(y)},h=S(),x=function(y,p){if(s){var b=ha(s,{moveBy:y,direction:p,context:h,modifiers:t});E(s,b)||(a.goToDate(b,s),m(b))}},v={focusedDay:s,focusTarget:d,blur:f,focus:m,focusDayAfter:function(){return x("day","after")},focusDayBefore:function(){return x("day","before")},focusWeekAfter:function(){return x("week","after")},focusWeekBefore:function(){return x("week","before")},focusMonthBefore:function(){return x("month","before")},focusMonthAfter:function(){return x("month","after")},focusYearBefore:function(){return x("year","before")},focusYearAfter:function(){return x("year","after")},focusStartOfWeek:function(){return x("startOfWeek","before")},focusEndOfWeek:function(){return x("endOfWeek","after")}};return r.jsx(xa.Provider,{value:v,children:e.children})}function ct(){var e=g.useContext(xa);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function to(e,a){var t=fa(),n=lt(e,t,a);return n}var dt=g.createContext(void 0);function ao(e){if(!Pe(e.initialProps)){var a={selected:void 0};return r.jsx(dt.Provider,{value:a,children:e.children})}return r.jsx(no,{initialProps:e.initialProps,children:e.children})}function no(e){var a=e.initialProps,t=e.children,n=function(o,i,l){var c,u,d;if((c=a.onDayClick)===null||c===void 0||c.call(a,o,i,l),i.selected&&!a.required){(u=a.onSelect)===null||u===void 0||u.call(a,void 0,o,i,l);return}(d=a.onSelect)===null||d===void 0||d.call(a,o,o,i,l)},s={selected:a.selected,onDayClick:n};return r.jsx(dt.Provider,{value:s,children:t})}function ga(){var e=g.useContext(dt);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function ro(e,a){var t=S(),n=ga(),s=st(),o=it(),i=ct(),l=i.focusDayAfter,c=i.focusDayBefore,u=i.focusWeekAfter,d=i.focusWeekBefore,f=i.blur,m=i.focus,h=i.focusMonthBefore,x=i.focusMonthAfter,v=i.focusYearBefore,y=i.focusYearAfter,p=i.focusStartOfWeek,b=i.focusEndOfWeek,M=function(j){var w,Y,ge,ie;Pe(t)?(w=n.onDayClick)===null||w===void 0||w.call(n,e,a,j):be(t)?(Y=s.onDayClick)===null||Y===void 0||Y.call(s,e,a,j):we(t)?(ge=o.onDayClick)===null||ge===void 0||ge.call(o,e,a,j):(ie=t.onDayClick)===null||ie===void 0||ie.call(t,e,a,j)},k=function(j){var w;m(e),(w=t.onDayFocus)===null||w===void 0||w.call(t,e,a,j)},L=function(j){var w;f(),(w=t.onDayBlur)===null||w===void 0||w.call(t,e,a,j)},A=function(j){var w;(w=t.onDayMouseEnter)===null||w===void 0||w.call(t,e,a,j)},V=function(j){var w;(w=t.onDayMouseLeave)===null||w===void 0||w.call(t,e,a,j)},Q=function(j){var w;(w=t.onDayPointerEnter)===null||w===void 0||w.call(t,e,a,j)},Z=function(j){var w;(w=t.onDayPointerLeave)===null||w===void 0||w.call(t,e,a,j)},ee=function(j){var w;(w=t.onDayTouchCancel)===null||w===void 0||w.call(t,e,a,j)},Oe=function(j){var w;(w=t.onDayTouchEnd)===null||w===void 0||w.call(t,e,a,j)},X=function(j){var w;(w=t.onDayTouchMove)===null||w===void 0||w.call(t,e,a,j)},te=function(j){var w;(w=t.onDayTouchStart)===null||w===void 0||w.call(t,e,a,j)},Fe=function(j){var w;(w=t.onDayKeyUp)===null||w===void 0||w.call(t,e,a,j)},xe=function(j){var w;switch(j.key){case"ArrowLeft":j.preventDefault(),j.stopPropagation(),t.dir==="rtl"?l():c();break;case"ArrowRight":j.preventDefault(),j.stopPropagation(),t.dir==="rtl"?c():l();break;case"ArrowDown":j.preventDefault(),j.stopPropagation(),u();break;case"ArrowUp":j.preventDefault(),j.stopPropagation(),d();break;case"PageUp":j.preventDefault(),j.stopPropagation(),j.shiftKey?v():h();break;case"PageDown":j.preventDefault(),j.stopPropagation(),j.shiftKey?y():x();break;case"Home":j.preventDefault(),j.stopPropagation(),p();break;case"End":j.preventDefault(),j.stopPropagation(),b();break}(w=t.onDayKeyDown)===null||w===void 0||w.call(t,e,a,j)},W={onClick:M,onFocus:k,onBlur:L,onKeyDown:xe,onKeyUp:Fe,onMouseEnter:A,onMouseLeave:V,onPointerEnter:Q,onPointerLeave:Z,onTouchCancel:ee,onTouchEnd:Oe,onTouchMove:X,onTouchStart:te};return W}function so(){var e=S(),a=ga(),t=st(),n=it(),s=Pe(e)?a.selected:be(e)?t.selected:we(e)?n.selected:void 0;return s}function oo(e){return Object.values(B).includes(e)}function io(e,a){var t=[e.classNames.day];return Object.keys(a).forEach(function(n){var s=e.modifiersClassNames[n];if(s)t.push(s);else if(oo(n)){var o=e.classNames["day_".concat(n)];o&&t.push(o)}}),t}function lo(e,a){var t=N({},e.styles.day);return Object.keys(a).forEach(function(n){var s;t=N(N({},t),(s=e.modifiersStyles)===null||s===void 0?void 0:s[n])}),t}function co(e,a,t){var n,s,o,i=S(),l=ct(),c=to(e,a),u=ro(e,c),d=so(),f=!!(i.onDayClick||i.mode!=="default");g.useEffect(function(){var A;c.outside||l.focusedDay&&f&&E(l.focusedDay,e)&&((A=t.current)===null||A===void 0||A.focus())},[l.focusedDay,e,t,f,c.outside]);var m=io(i,c).join(" "),h=lo(i,c),x=!!(c.outside&&!i.showOutsideDays||c.hidden),v=(o=(s=i.components)===null||s===void 0?void 0:s.DayContent)!==null&&o!==void 0?o:Ts,y=r.jsx(v,{date:e,displayMonth:a,activeModifiers:c}),p={style:h,className:m,children:y,role:"gridcell"},b=l.focusTarget&&E(l.focusTarget,e)&&!c.outside,M=l.focusedDay&&E(l.focusedDay,e),k=N(N(N({},p),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||b?0:-1,n)),u),L={isButton:f,isHidden:x,activeModifiers:c,selectedDays:d,buttonProps:k,divProps:p};return L}function uo(e){var a=g.useRef(null),t=co(e.date,e.displayMonth,a);return t.isHidden?r.jsx("div",{role:"gridcell"}):t.isButton?r.jsx(Se,N({name:"day",ref:a},t.buttonProps)):r.jsx("div",N({},t.divProps))}function mo(e){var a=e.number,t=e.dates,n=S(),s=n.onWeekNumberClick,o=n.styles,i=n.classNames,l=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,d=u(Number(a),{locale:l});if(!s)return r.jsx("span",{className:i.weeknumber,style:o.weeknumber,children:d});var f=c(Number(a),{locale:l}),m=function(h){s(a,t,h)};return r.jsx(Se,{name:"week-number","aria-label":f,className:i.weeknumber,style:o.weeknumber,onClick:m,children:d})}function fo(e){var a,t,n=S(),s=n.styles,o=n.classNames,i=n.showWeekNumber,l=n.components,c=(a=l==null?void 0:l.Day)!==null&&a!==void 0?a:uo,u=(t=l==null?void 0:l.WeekNumber)!==null&&t!==void 0?t:mo,d;return i&&(d=r.jsx("td",{className:o.cell,style:s.cell,children:r.jsx(u,{number:e.weekNumber,dates:e.dates})})),r.jsxs("tr",{className:o.row,style:s.row,children:[d,e.dates.map(function(f){return r.jsx("td",{className:o.cell,style:s.cell,role:"presentation",children:r.jsx(c,{displayMonth:e.displayMonth,date:f})},Rr(f))})]})}function Rt(e,a,t){for(var n=t!=null&&t.ISOWeek?ta(a):tt(a,t),s=t!=null&&t.ISOWeek?oe(e):q(e,t),o=$(n,s),i=[],l=0;l<=o;l++)i.push(F(s,l));var c=i.reduce(function(u,d){var f=t!=null&&t.ISOWeek?aa(d):ra(d,t),m=u.find(function(h){return h.weekNumber===f});return m?(m.dates.push(d),u):(u.push({weekNumber:f,dates:[d]}),u)},[]);return c}function ho(e,a){var t=Rt(I(e),Te(e),a);if(a!=null&&a.useFixedWeeks){var n=Ar(e,a);if(n<6){var s=t[t.length-1],o=s.dates[s.dates.length-1],i=Ue(o,6-n),l=Rt(Ue(o,1),i,a);t.push.apply(t,l)}}return t}function xo(e){var a,t,n,s=S(),o=s.locale,i=s.classNames,l=s.styles,c=s.hideHead,u=s.fixedWeeks,d=s.components,f=s.weekStartsOn,m=s.firstWeekContainsDate,h=s.ISOWeek,x=ho(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:h,locale:o,weekStartsOn:f,firstWeekContainsDate:m}),v=(a=d==null?void 0:d.Head)!==null&&a!==void 0?a:_s,y=(t=d==null?void 0:d.Row)!==null&&t!==void 0?t:fo,p=(n=d==null?void 0:d.Footer)!==null&&n!==void 0?n:Cs;return r.jsxs("table",{id:e.id,className:i.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&r.jsx(v,{}),r.jsx("tbody",{className:i.tbody,style:l.tbody,children:x.map(function(b){return r.jsx(y,{displayMonth:e.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),r.jsx(p,{displayMonth:e.displayMonth})]})}function go(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var vo=go()?g.useLayoutEffect:g.useEffect,Be=!1,yo=0;function Lt(){return"react-day-picker-".concat(++yo)}function bo(e){var a,t=e??(Be?Lt():null),n=g.useState(t),s=n[0],o=n[1];return vo(function(){s===null&&o(Lt())},[]),g.useEffect(function(){Be===!1&&(Be=!0)},[]),(a=e??s)!==null&&a!==void 0?a:void 0}function wo(e){var a,t,n=S(),s=n.dir,o=n.classNames,i=n.styles,l=n.components,c=je().displayMonths,u=bo(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),d=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,f=[o.month],m=i.month,h=e.displayIndex===0,x=e.displayIndex===c.length-1,v=!h&&!x;s==="rtl"&&(a=[h,x],x=a[0],h=a[1]),h&&(f.push(o.caption_start),m=N(N({},m),i.caption_start)),x&&(f.push(o.caption_end),m=N(N({},m),i.caption_end)),v&&(f.push(o.caption_between),m=N(N({},m),i.caption_between));var y=(t=l==null?void 0:l.Caption)!==null&&t!==void 0?t:Ms;return r.jsxs("div",{className:f.join(" "),style:m,children:[r.jsx(y,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),r.jsx(xo,{id:d,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function jo(e){var a=S(),t=a.classNames,n=a.styles;return r.jsx("div",{className:t.months,style:n.months,children:e.children})}function No(e){var a,t,n=e.initialProps,s=S(),o=ct(),i=je(),l=g.useState(!1),c=l[0],u=l[1];g.useEffect(function(){s.initialFocus&&o.focusTarget&&(c||(o.focus(o.focusTarget),u(!0)))},[s.initialFocus,c,o.focus,o.focusTarget,o]);var d=[s.classNames.root,s.className];s.numberOfMonths>1&&d.push(s.classNames.multiple_months),s.showWeekNumber&&d.push(s.classNames.with_weeknumber);var f=N(N({},s.styles.root),s.style),m=Object.keys(n).filter(function(x){return x.startsWith("data-")}).reduce(function(x,v){var y;return N(N({},x),(y={},y[v]=n[v],y))},{}),h=(t=(a=n.components)===null||a===void 0?void 0:a.Months)!==null&&t!==void 0?t:jo;return r.jsx("div",N({className:d.join(" "),style:f,dir:s.dir,id:s.id,nonce:n.nonce,title:n.title,lang:n.lang},m,{children:r.jsx(h,{children:i.displayMonths.map(function(x,v){return r.jsx(wo,{displayIndex:v,displayMonth:x},v)})})}))}function po(e){var a=e.children,t=zr(e,["children"]);return r.jsx(us,{initialProps:t,children:r.jsx(js,{children:r.jsx(ao,{initialProps:t,children:r.jsx(Ps,{initialProps:t,children:r.jsx(Ws,{initialProps:t,children:r.jsx(Bs,{children:r.jsx(eo,{children:a})})})})})})})}function Do(e){return r.jsx(po,N({},e,{children:r.jsx(No,{initialProps:e})}))}function At({className:e,classNames:a,showOutsideDays:t=!0,...n}){return r.jsx(Do,{showOutsideDays:t,className:U("p-3",e),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:U(gt({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:U("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",n.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:U(gt({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:({className:s,...o})=>r.jsx(Qt,{className:U("size-4",s),...o}),IconRight:({className:s,...o})=>r.jsx(_e,{className:U("size-4",s),...o})},...n})}const Mo=[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];function Co({open:e,onOpenChange:a,filters:t,onApply:n,onReset:s,projectId:o}){const[i,l]=g.useState(t),[c,u]=g.useState(t.fromDate?new Date(t.fromDate):void 0),[d,f]=g.useState(t.toDate?new Date(t.toDate):void 0);g.useEffect(()=>{l(t),u(t.fromDate?new Date(t.fromDate):void 0),f(t.toDate?new Date(t.toDate):void 0)},[t]);const m=(v,y)=>{l(p=>({...p,status:y?[...p.status,v]:p.status.filter(b=>b!==v)}))},h=()=>{const v={...i,fromDate:c?c.toISOString():void 0,toDate:d?d.toISOString():void 0};n(v)},x=()=>{l({status:[]}),u(void 0),f(void 0),s()};return r.jsx(Xe,{open:e,onOpenChange:a,children:r.jsxs(Kt,{className:"sm:max-w-[425px]",children:[r.jsxs(Ut,{children:[r.jsx(Jt,{children:"Filter Traces"}),r.jsx(nn,{children:"Apply filters to narrow down the traces displayed in the table."})]}),r.jsxs("div",{className:"space-y-6 py-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(G,{className:"text-sm font-medium",children:"Status"}),r.jsx("div",{className:"space-y-2",children:Mo.map(v=>r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Ve,{id:`status-${v.value}`,checked:i.status.includes(v.value),onCheckedChange:y=>m(v.value,!!y)}),r.jsx(G,{htmlFor:`status-${v.value}`,className:"text-sm font-normal cursor-pointer",children:v.label})]},v.value))})]}),r.jsx(qe,{}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(G,{className:"text-sm font-medium",children:"Date Range"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(G,{htmlFor:"from-date",className:"text-xs text-gray-500",children:"From"}),r.jsxs(vt,{children:[r.jsx(yt,{asChild:!0,children:r.jsxs(O,{variant:"outline",className:U("w-full justify-start text-left font-normal",!c&&"text-muted-foreground"),children:[r.jsx(ke,{className:"mr-2 h-4 w-4"}),c?T(c,"PPP"):"Pick a date"]})}),r.jsx(bt,{className:"w-auto p-0",children:r.jsx(At,{mode:"single",selected:c,onSelect:u,initialFocus:!0})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(G,{htmlFor:"to-date",className:"text-xs text-gray-500",children:"To"}),r.jsxs(vt,{children:[r.jsx(yt,{asChild:!0,children:r.jsxs(O,{variant:"outline",className:U("w-full justify-start text-left font-normal",!d&&"text-muted-foreground"),children:[r.jsx(ke,{className:"mr-2 h-4 w-4"}),d?T(d,"PPP"):"Pick a date"]})}),r.jsx(bt,{className:"w-auto p-0",children:r.jsx(At,{mode:"single",selected:d,onSelect:f,initialFocus:!0})})]})]})]})]}),r.jsx(qe,{}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(G,{className:"text-sm font-medium",children:"Duration (ms)"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(G,{htmlFor:"min-duration",className:"text-xs text-gray-500",children:"Min"}),r.jsx(Qe,{id:"min-duration",type:"number",placeholder:"0",value:i.minDuration||"",onChange:v=>l(y=>({...y,minDuration:v.target.value?Number(v.target.value):void 0}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(G,{htmlFor:"max-duration",className:"text-xs text-gray-500",children:"Max"}),r.jsx(Qe,{id:"max-duration",type:"number",placeholder:"1000",value:i.maxDuration||"",onChange:v=>l(y=>({...y,maxDuration:v.target.value?Number(v.target.value):void 0}))})]})]})]})]}),r.jsxs(rn,{children:[r.jsx(O,{variant:"outline",onClick:x,children:"Reset"}),r.jsx(O,{onClick:h,children:"Apply Filters"})]})]})})}const Ht=e=>e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`,ko=({span:e})=>e.metadata&&Object.keys(e.metadata).length>0?r.jsxs(Xe,{children:[r.jsx(Ct,{asChild:!0,children:r.jsx("button",{className:"flex items-center justify-center w-5 h-5 rounded hover:bg-blue-100 transition-colors",title:"View span metadata",children:r.jsx(Nt,{className:"w-3 h-3 text-blue-600 hover:text-blue-800"})})}),r.jsxs(Kt,{className:"max-w-2xl max-h-[80vh] overflow-hidden",children:[r.jsx(Ut,{children:r.jsxs(Jt,{className:"flex items-center gap-2",children:[r.jsx(Ge,{className:"h-5 w-5 text-blue-600"}),"Span Metadata: ",e.name]})}),r.jsx(Xt,{className:"max-h-[60vh] pr-4",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 rounded-lg p-4",children:[r.jsxs("h4",{className:"font-semibold text-gray-900 mb-3 flex items-center gap-2",children:[r.jsx(Ke,{className:"h-4 w-4 text-gray-600"}),"Span Information"]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"font-medium text-gray-600",children:"ID:"}),r.jsx("p",{className:"font-mono text-gray-900 break-all",children:e.id})]}),r.jsxs("div",{children:[r.jsx("span",{className:"font-medium text-gray-600",children:"Name:"}),r.jsx("p",{className:"text-gray-900",children:e.name})]}),e.parentSpanId&&r.jsxs("div",{children:[r.jsx("span",{className:"font-medium text-gray-600",children:"Parent Span ID:"}),r.jsx("p",{className:"font-mono text-gray-900 break-all",children:e.parentSpanId})]}),r.jsxs("div",{children:[r.jsx("span",{className:"font-medium text-gray-600",children:"Status:"}),r.jsx(R,{className:`ml-2 ${e.status==="completed"?"bg-green-100 text-green-800":e.status==="failed"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800"}`,children:e.status})]})]})]}),r.jsxs("div",{className:"bg-blue-50 rounded-lg p-4",children:[r.jsxs("h4",{className:"font-semibold text-gray-900 mb-3 flex items-center gap-2",children:[r.jsx(Ge,{className:"h-4 w-4 text-blue-600"}),"Metadata"]}),r.jsx("div",{className:"space-y-3",children:Object.entries(e.metadata).map(([t,n])=>r.jsx("div",{className:"border-b border-blue-200 last:border-b-0 pb-2 last:pb-0",children:r.jsx("div",{className:"flex items-start gap-3",children:r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"font-medium text-blue-900 text-sm break-all",children:t}),r.jsx("div",{className:"mt-1 text-sm text-gray-700",children:typeof n=="object"?r.jsx("pre",{className:"bg-white rounded p-2 text-xs font-mono overflow-x-auto border border-blue-200",children:JSON.stringify(n,null,2)}):r.jsx("span",{className:"font-mono break-all",children:String(n)})})]})})},t))})]})]})})]})]}):r.jsx(Xe,{children:r.jsx(Ct,{asChild:!0,children:r.jsx("button",{className:"flex items-center justify-center w-5 h-5 rounded hover:bg-gray-200 transition-colors opacity-50 cursor-not-allowed",title:"No metadata available",disabled:!0,children:r.jsx(Nt,{className:"w-3 h-3 text-gray-400"})})})}),va=(e,a=0,t=new Set)=>{const n=[];for(const s of e){const o=s.spans?s.spans.length>0:!1;n.push({...s,level:a,hasChildren:o}),o&&!t.has(s.id)&&n.push(...va((s==null?void 0:s.spans)??[],a+1,t))}return n};function So({open:e,onOpenChange:a,trace:t}){const[n,s]=g.useState(new Set),o=m=>{s(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})};if(!t)return r.jsx(wt,{open:e,onOpenChange:a,children:r.jsx(jt,{className:"w-[100vw] !max-w-[100vw] h-[100vh] overflow-hidden !w-[100vw] bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsxs("div",{className:"text-center space-y-6",children:[r.jsx("div",{className:"inline-flex items-center justify-center p-6 bg-gradient-to-r from-blue-500 to-purple-600 rounded-3xl text-white shadow-xl",children:r.jsx(ce,{className:"h-12 w-12"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-2xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"No Trace Selected"}),r.jsx("p",{className:"text-gray-600 max-w-md mx-auto",children:"Select a trace from the table to view detailed information about its execution and spans."})]})]})})})});const i=new Date(t.startTime),l=t.endTime?new Date(t.endTime):null,c=l?l.getTime()-i.getTime():null,u=t.spans||[],d=va(u,0,n),f=t.status||"running";return r.jsx(wt,{open:e,onOpenChange:a,children:r.jsxs(jt,{className:"w-[100vw] !max-w-[100vw] h-[100vh] overflow-hidden !w-[100vw] bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:[r.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-purple-600 text-white p-8 -m-6 mb-8 shadow-xl",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"p-3 bg-white/20 rounded-2xl backdrop-blur-sm",children:r.jsx(ce,{className:"h-8 w-8"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-bold",children:"Trace Details"}),r.jsx("p",{className:"text-blue-100 text-lg mt-1",children:"Comprehensive trace execution analysis"})]})]})}),r.jsx(Xt,{className:"h-[calc(100vh-200px)] px-2",children:r.jsxs("div",{className:"space-y-8",children:[r.jsxs(ze,{className:"border-0 shadow-xl bg-white/80 backdrop-blur-sm",children:[r.jsx(pt,{className:"pb-6",children:r.jsxs(Dt,{className:"flex items-center gap-3 text-2xl",children:[r.jsx("div",{className:"p-2 bg-gradient-to-r from-blue-500 to-purple-600 rounded-xl text-white",children:r.jsx(Ge,{className:"h-6 w-6"})}),r.jsx("span",{className:"bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Basic Information"})]})}),r.jsx(Mt,{className:"space-y-6",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(Ke,{className:"h-4 w-4 text-blue-600"}),"TRACE NAME"]}),r.jsx("div",{className:"p-4 bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl border border-blue-200/50 shadow-sm",children:r.jsx("p",{className:"font-mono text-sm text-gray-900 break-all",children:t.name})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(Ke,{className:"h-4 w-4 text-purple-600"}),"TRACE ID"]}),r.jsx("div",{className:"p-4 bg-gradient-to-r from-purple-50 to-pink-50 rounded-xl border border-purple-200/50 shadow-sm",children:r.jsx("p",{className:"font-mono text-sm text-gray-900 break-all",children:t.id})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(ke,{className:"h-4 w-4 text-green-600"}),"START TIME"]}),r.jsx("div",{className:"p-4 bg-gradient-to-r from-green-50 to-emerald-50 rounded-xl border border-green-200/50 shadow-sm",children:r.jsx("p",{className:"font-mono text-sm text-gray-900",children:T(i,"MMM dd, yyyy HH:mm:ss")})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(ke,{className:"h-4 w-4 text-orange-600"}),"END TIME"]}),r.jsx("div",{className:"p-4 bg-gradient-to-r from-orange-50 to-amber-50 rounded-xl border border-orange-200/50 shadow-sm",children:r.jsx("p",{className:"font-mono text-sm text-gray-900",children:l?T(l,"MMM dd, yyyy HH:mm:ss"):"In Progress"})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(vn,{className:"h-4 w-4 text-cyan-600"}),"DURATION"]}),r.jsx("div",{className:"p-4 bg-gradient-to-r from-cyan-50 to-sky-50 rounded-xl border border-cyan-200/50 shadow-sm",children:r.jsx("p",{className:"font-mono text-sm text-gray-900",children:c!==null?Ht(c):"N/A"})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[r.jsx(ce,{className:"h-4 w-4 text-indigo-600"}),"STATUS"]}),r.jsxs("div",{className:"p-4 bg-gradient-to-r from-indigo-50 to-violet-50 rounded-xl border border-indigo-200/50 shadow-sm",children:[f==="completed"&&r.jsxs(R,{className:"bg-gradient-to-r from-green-500 to-emerald-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[r.jsx(dn,{className:"h-4 w-4 mr-2"}),"Completed"]}),f==="failed"&&r.jsxs(R,{className:"bg-gradient-to-r from-red-500 to-rose-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[r.jsx(on,{className:"h-4 w-4 mr-2"}),"Failed"]}),f==="running"&&r.jsxs(R,{className:"bg-gradient-to-r from-blue-500 to-cyan-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[r.jsx(zt,{className:"h-4 w-4 mr-2"}),"Running"]})]})]})]})})]}),r.jsxs(ze,{className:"border-0 shadow-xl bg-white/80 backdrop-blur-sm",children:[r.jsx(pt,{className:"pb-6",children:r.jsxs(Dt,{className:"flex items-center gap-3 text-2xl",children:[r.jsx("div",{className:"p-2 bg-gradient-to-r from-green-500 to-blue-600 rounded-xl text-white",children:r.jsx(ln,{className:"h-6 w-6"})}),r.jsx("span",{className:"bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Spans"}),r.jsxs(R,{className:"ml-auto bg-gradient-to-r from-green-500 to-blue-600 text-white border-0 shadow-lg text-base px-4 py-2",children:[d.length," ",d.length===1?"span":"spans"]})]})}),r.jsx(Mt,{children:d.length>0?r.jsx("div",{className:"space-y-6",children:r.jsx("div",{className:"bg-gradient-to-r from-white to-gray-50/50 rounded-2xl border border-gray-200/50 shadow-lg p-6",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsx("h4",{className:"text-lg font-semibold text-gray-900",children:"Timeline Visualization"}),r.jsx("div",{className:"text-sm text-gray-600 font-mono",children:i&&l?r.jsxs("span",{children:[T(i,"HH:mm:ss")," → ",T(l,"HH:mm:ss")]}):r.jsx("span",{children:"Timeline"})})]}),r.jsx("div",{className:"space-y-3",children:d.map((m,h)=>{var V,Q;const x=m.startTime?new Date(m.startTime).getTime():0,v=m.endTime?new Date(m.endTime).getTime():Date.now(),y=i.getTime(),b=(l?l.getTime():Date.now())-y,M=b>0?(x-y)/b*100:0,k=b>0?(v-x)/b*100:100,L=["from-blue-500 to-blue-600","from-purple-500 to-purple-600","from-green-500 to-green-600","from-orange-500 to-orange-600","from-pink-500 to-pink-600","from-cyan-500 to-cyan-600","from-indigo-500 to-indigo-600","from-red-500 to-red-600"],A=L[h%L.length];return r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-3",style:{marginLeft:`${m.level*20}px`},children:[m.hasChildren?r.jsx("button",{onClick:()=>o(m.id),className:"flex items-center justify-center w-5 h-5 rounded hover:bg-gray-200 transition-colors",title:n.has(m.id)?"Expand children":"Collapse children",children:n.has(m.id)?r.jsx(_e,{className:"w-3 h-3 text-gray-600"}):r.jsx(Pa,{className:"w-3 h-3 text-gray-600"})}):r.jsx("div",{className:"w-5 h-5 flex items-center justify-center",children:m.level>0&&r.jsx("div",{className:"w-1 h-1 bg-gray-400 rounded-full"})}),m.level>0&&r.jsxs("div",{className:"flex items-center",children:[[...Array(m.level)].map((Z,ee)=>r.jsx("div",{className:"w-4 h-px bg-gray-300 mr-1"},ee)),r.jsx("div",{className:"w-2 h-2 border-l border-b border-gray-300 mr-2"})]}),r.jsx("div",{className:`w-3 h-3 rounded-full bg-gradient-to-r ${A}`}),r.jsx("span",{className:"text-sm font-medium text-gray-900 truncate max-w-xs",children:m.name||`Span ${h+1}`}),m.level>0&&r.jsxs(R,{variant:"outline",className:"text-xs px-2 py-1 bg-gray-50",children:["L",m.level]}),m.hasChildren&&r.jsxs(R,{variant:"outline",className:"text-xs px-2 py-1 bg-blue-50 text-blue-700",children:[(V=m.spans)==null?void 0:V.length," child",((Q=m==null?void 0:m.spans)==null?void 0:Q.length)!==1?"ren":""]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[m.startTime&&m.endTime&&r.jsx(R,{variant:"outline",className:"text-xs px-2 py-1",children:Ht(v-x)}),r.jsx(ko,{span:m})]})]}),r.jsxs("div",{className:"relative h-8 bg-gray-100 rounded-lg overflow-hidden",style:{marginLeft:`${m.level*20}px`},children:[r.jsx("div",{className:"absolute inset-0 flex",children:[...Array(10)].map((Z,ee)=>r.jsx("div",{className:"flex-1 border-r border-gray-200 last:border-r-0"},ee))}),r.jsx("div",{className:`absolute top-1 bottom-1 bg-gradient-to-r ${A} rounded shadow-sm transition-all duration-300 hover:shadow-md`,style:{left:`${Math.max(0,Math.min(M,100))}%`,width:`${Math.max(1,Math.min(k,100-Math.max(0,M)))}%`},children:r.jsx("div",{className:"h-full flex items-center justify-center text-white text-xs font-medium px-2",children:k>15&&r.jsx("span",{className:"truncate",children:m.startTime&&T(new Date(m.startTime),"HH:mm:ss")})})})]}),r.jsx("div",{className:"mt-2 text-xs text-gray-500 font-mono pl-6",style:{marginLeft:`${m.level*20}px`},children:m.startTime&&r.jsxs("span",{children:["Start: ",T(new Date(m.startTime),"HH:mm:ss.SSS"),m.endTime&&r.jsxs("span",{className:"ml-4",children:["End: ",T(new Date(m.endTime),"HH:mm:ss.SSS")]})]})})]},m.id||h)})}),r.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-200",children:[r.jsxs("div",{className:"flex justify-between text-xs text-gray-500 font-mono",children:[r.jsx("span",{children:"0%"}),r.jsx("span",{children:"25%"}),r.jsx("span",{children:"50%"}),r.jsx("span",{children:"75%"}),r.jsx("span",{children:"100%"})]}),r.jsx("div",{className:"mt-1 text-xs text-gray-400 text-center",children:"Timeline Progress"})]})]})})}):r.jsxs("div",{className:"text-center py-20",children:[r.jsx("div",{className:"inline-flex items-center justify-center p-6 bg-gradient-to-r from-gray-100 to-gray-200 rounded-3xl mb-6",children:r.jsx(hn,{className:"h-12 w-12 text-gray-500"})}),r.jsx("h3",{className:"text-2xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent mb-3",children:"No spans found for this trace"}),r.jsx("p",{className:"text-gray-600 max-w-md mx-auto text-lg",children:"Spans will appear here when available"})]})})]})]})})]})})}function _o(e){const[a,t]=g.useState(void 0),[n,s]=g.useState([void 0]),[o,i]=g.useState(0),l=g.useCallback(d=>{const f=[...n.slice(0,o+1),d];s(f),t(d),i(o+1)},[n,o]),c=g.useCallback(()=>{if(o>0){const d=n[o-1];t(d),i(o-1)}},[n,o]),u=g.useCallback(()=>{t(void 0),s([void 0]),i(0)},[]);return{cursor:a,currentPage:o,handleNextPage:l,handlePrevPage:c,resetPagination:u}}const To=e=>e<100?"bg-green-500":e<500?"bg-yellow-500":e<1e3?"bg-orange-500":"bg-red-500",Bt=e=>e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`;function Po({selectedTraces:e,onSelectAll:a,onSelectRow:t,onViewTrace:n,onDeleteTrace:s,currentTraces:o}){return[{id:"select",header:({table:i})=>{const l=o.length>0&&o.every(u=>e[u.id]),c=o.some(u=>e[u.id])&&!l;return r.jsx(Ve,{checked:l,ref:u=>{u&&(u.isIndeterminate=c)},onCheckedChange:u=>a(!!u),"aria-label":"Select all",className:"translate-y-[2px]"})},cell:({row:i})=>r.jsx(Ve,{checked:!!e[i.original.id],onCheckedChange:l=>t(i.original.id,!!l),"aria-label":"Select row",className:"translate-y-[2px]"}),enableSorting:!1,enableHiding:!1},{accessorKey:"startTime",header:"Start Time",enableSorting:!0,cell:({row:i})=>{const l=new Date(i.getValue("startTime"));return r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-sm font-medium text-gray-900",children:T(l,"MMM dd, HH:mm:ss")}),r.jsx("div",{className:"text-xs text-gray-500",children:T(l,"yyyy")})]})}},{accessorKey:"name",header:"Trace Name",size:300,cell:({row:i})=>{const l=new Date(i.getValue("startTime")),c=i.getValue("name");return r.jsxs("div",{className:"space-y-1 w-[300px]",children:[r.jsxs(Oa,{children:[r.jsx(Fa,{asChild:!0,children:r.jsx("div",{className:"font-medium text-gray-900 truncate cursor-pointer",children:c})}),r.jsx(Wa,{children:r.jsx("p",{className:"max-w-xs break-words",children:c})})]}),r.jsxs("div",{className:"text-xs text-gray-500 flex items-center gap-1",children:[r.jsx(zt,{className:"h-3 w-3"}),T(l,"HH:mm:ss")]})]})}},{accessorKey:"duration",header:"Duration",cell:({row:i,table:l})=>{const c=i.getValue("status"),u=new Date(i.getValue("startTime")),d=i.original.endTime;console.log({startTime:u,endTime:d});const m=l.getRowModel().rows.map(b=>b.original).map(b=>{const M=new Date(b.startTime).getTime();if(b.endTime){const k=new Date(b.endTime).getTime();return Math.max(0,k-M)}else if(b.status==="running"){const k=new Date().getTime();return Math.max(0,k-M)}return 0}),h=m.length>0?Math.max(...m):1;if(!d&&c==="running"){const M=Math.max(0,new Date().getTime()-u.getTime()),k=Bt(M),L=h>0?Math.min(M/h*100,100):0;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:"text-sm font-mono font-medium text-gray-900",children:k})}),r.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:r.jsx("div",{className:"bg-blue-500 h-2 rounded-full animate-pulse",style:{width:`${L}%`}})})]})}if(!d)return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:"text-sm font-mono font-medium text-gray-500",children:"-"})}),r.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:r.jsx("div",{className:"bg-gray-300 h-2 rounded-full",style:{width:"0%"}})})]});const x=Math.max(0,new Date(d).getTime()-u.getTime()),v=Bt(x),y=To(x),p=h>0?Math.min(x/h*100,100):0;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:"text-sm font-mono font-medium text-gray-900",children:v})}),r.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:r.jsx("div",{className:`h-2 rounded-full transition-all duration-300 ${y}`,style:{width:`${p}%`}})})]})}},{accessorKey:"spans",header:"Spans",cell:({row:i})=>{const l=i.getValue("spans"),c=d=>{if(!d||d.length===0)return 0;let f=d.length;for(const m of d)m.spans&&Array.isArray(m.spans)&&(f+=c(m.spans));return f},u=c(l);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(R,{variant:"outline",className:"text-purple-600 border-purple-200",children:u}),r.jsx("span",{className:"text-xs text-gray-500",children:u===1?"span":"spans"})]})}},{accessorKey:"status",header:"Status",cell:({row:i})=>{const l=i.getValue("status"),c=new Date(i.getValue("startTime")),d=new Date().getTime()-c.getTime()<3e5;switch(l){case"running":return r.jsxs(R,{variant:"outline",className:"text-blue-600 border-blue-200",children:[r.jsx(ce,{className:"h-3 w-3 mr-1 animate-pulse"}),"Running"]});case"failed":return r.jsxs(R,{variant:"outline",className:"text-red-600 border-red-200",children:[r.jsx(St,{className:"h-3 w-3 mr-1"}),"Failed"]});case"completed":default:return r.jsxs(R,{variant:"outline",className:`${d?"text-green-600 border-green-200":"text-gray-600 border-gray-200"}`,children:[r.jsx(St,{className:"h-3 w-3 mr-1"}),"Completed"]})}}},{id:"actions",header:"",cell:({row:i})=>{const l=i.original;return r.jsx(O,{variant:"ghost",size:"icon",onClick:()=>n(l),className:"rounded-full hover:bg-blue-50 hover:border-blue-200 border border-transparent transition-all duration-200 group","aria-label":"View trace details",children:r.jsx(_e,{className:"h-4 w-4 text-gray-600 group-hover:text-blue-600 transition-colors"})})},size:50}]}const Oo=500,$t=20;function Fo({projectId:e}){const{searchQuery:a,inputValue:t,setSearchQuery:n,filterModalOpen:s,openFilterModal:o,setFilterModalOpen:i,filters:l,handleApplyFilters:c,handleResetFilters:u,filtersActive:d}=jn({debounceTimeout:Oo}),{sortDirection:f,sorting:m,handleToggleSortDirection:h,setSorting:x,resetSort:v}=pn("desc"),{cursor:y,currentPage:p,handleNextPage:b,handlePrevPage:M,resetPagination:k}=_o(),{isDetailSheetOpen:L,currentTraceDetail:A,openDetailSheet:V,setIsDetailSheetOpen:Q}=Dn(),[Z,ee]=g.useState([]),Oe={limit:$t,sortDirection:f,...l.status.length>0?{status:l.status}:{},...l.fromDate?{fromDate:l.fromDate}:{},...l.toDate?{toDate:l.toDate}:{},...l.minDuration!==void 0?{minDuration:l.minDuration}:{},...l.maxDuration!==void 0?{maxDuration:l.maxDuration}:{},...a?{nameContains:a}:{},...y?{cursor:y}:{}},{data:X,isLoading:te,isError:Fe,refetch:xe}=wn(e,Oe),W=(X==null?void 0:X.traces)??[],j=(X==null?void 0:X.hasNextPage)||!1,w=g.useCallback(()=>{if(j&&W.length>0){const _=W[W.length-1];return console.log("get next cursor",{cursor:y,latestTrace:_}),{id:_.id,timestamp:_.startTime}}return null},[j,W]),{selectedTraces:Y,selectedCount:ge,handleSelectAll:ie,handleSelectRow:ut,resetSelection:ae}=Nn(W),ya=g.useCallback(_=>{c(_),k(),ae()},[c,k,ae]),mt=g.useCallback(()=>{u(),k(),v(),ae()},[u,k,v,ae]),ba=g.useCallback(()=>{h(),k(),ae()},[h,k,ae]),wa=g.useCallback(()=>{const _=w();_&&b(_)},[b,w]),ja=g.useCallback(()=>{M()},[M]);g.useCallback(()=>{k(),xe()},[k,xe]);const ft=g.useCallback(_=>{V(_)},[V]),ht=g.useCallback(_=>{se.info(`Mock Deleting trace ${_}...`,{description:"This is a placeholder. Actual deletion would be implemented here."})},[]),Na=()=>{const _=Object.keys(Y).filter(Ne=>Y[Ne]);se.info(`Mock Deleting ${_.length} traces...`,{description:"This is a placeholder. Actual deletion would be implemented here."}),ae()},pa=()=>{const _=Object.keys(Y).filter(Ne=>Y[Ne]);se.info(`Mock Exporting ${_.length} traces...`,{description:"This is a placeholder. Actual export would be implemented here."})},Da=()=>{const _=Object.keys(Y).filter(ne=>Y[ne]),Ca=W.filter(ne=>_.includes(ne.id)).map(ne=>`[${new Date(ne.startTime).toLocaleString()}] ${ne.name} (${ne.id})`).join(`
`);navigator.clipboard.writeText(Ca).then(()=>{se.success(`Copied ${_.length} traces to clipboard`)}).catch(()=>{se.error("Failed to copy traces to clipboard")})},xt=g.useMemo(()=>Po({selectedTraces:Y,onSelectAll:_=>ie(_),onSelectRow:ut,onViewTrace:ft,onDeleteTrace:ht,currentTraces:W}),[Y,ie,ut,ft,ht,W]),Ma=Ka({data:W,columns:xt,getCoreRowModel:Za(),getSortedRowModel:Ja(),getFilteredRowModel:Ua(),onSortingChange:x,onColumnFiltersChange:ee,state:{sorting:m,columnFilters:Z},manualPagination:!0,manualSorting:!0,manualFiltering:!0,enableRowSelection:!0,onRowSelectionChange:()=>{},debugTable:!1});return r.jsxs(r.Fragment,{children:[r.jsx(Co,{open:s,onOpenChange:i,filters:l,onApply:ya,onReset:mt,projectId:e}),r.jsxs(ze,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg w-full",children:[r.jsx(Br,{filters:l,sortDirection:f,onOpenFilterModal:o,onToggleSortDirection:ba,displayedTraceCount:te?void 0:W.length,isLoading:te}),r.jsx($r,{searchQuery:t,onSearchQueryChange:n,onOpenFilterModal:o,selectedCount:ge,onDeleteSelected:Na,onExportSelected:pa,onCopySelected:Da,isLoading:te}),r.jsx(qr,{table:Ma,columns:xt,isLoading:te,isError:Fe,traces:W,selectedTraces:Y,isFiltered:d||!!a,onRetry:()=>{k(),xe()},onClearFilters:mt}),r.jsx(Vr,{currentPage:p,hasNextPage:j,onPrevPage:ja,onNextPage:wa,isLoading:te,currentTraceCount:W.length,pageSize:$t})]}),r.jsx(So,{open:L,onOpenChange:Q,trace:A})]})}function Wo({projectId:e}){const{data:a,isLoading:t,isError:n}=Ya(e),{data:s,isLoading:o}=en(e),i=bn(),[l,c]=g.useState(!1),{editModalOpen:u,setEditModalOpen:d,deleteDialogOpen:f,setDeleteDialogOpen:m,autoRefresh:h,setAutoRefresh:x,handleRefresh:v,handleDeleteProject:y,handleConfirmDelete:p,handleEditProject:b,handleEditSubmit:M,updateProject:k,deleteProject:L}=Ra(e),A=()=>{c(!0)},V=()=>{i.mutate(e,{onSuccess:()=>{c(!1)}})},Q=t||o;return g.useEffect(()=>{if(!h)return;const Z=setInterval(()=>{v()},5e3);return()=>clearInterval(Z)},[h,e,v]),e?t?r.jsx(Aa,{}):n||!a?r.jsx(Ha,{projectId:e,project:a}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"min-h-full bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-6",children:r.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[r.jsx(Ba,{project:a,isRefreshing:Q,autoRefresh:h,onAutoRefreshChange:x,onEdit:b,onDelete:y,onRefresh:v}),r.jsx($a,{projectId:a.id,currentPage:"traces"}),r.jsxs("div",{className:"bg-white/60 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-lg p-6",children:[r.jsxs("div",{className:"flex justify-between items-center mb-6",children:[r.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Project Traces"}),r.jsxs(O,{variant:"outline",size:"sm",onClick:A,className:"transition-all hover:border-orange-500/50 hover:bg-orange-50 text-orange-600 hover:text-orange-700",children:[r.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Clear All Traces"]})]}),r.jsx(Fo,{projectId:a.id})]})]})}),r.jsx(sn,{open:u,onOpenChange:d,initialData:a?{name:a.name,description:a.description}:void 0,onSubmit:M,loading:k.isPending,mode:"edit"}),r.jsx(kt,{open:f,onOpenChange:m,title:"Delete Project?",description:"This will permanently delete the project and all its logs. This action cannot be undone.",onConfirm:p,loading:L.isPending,confirmLabel:"Delete"}),r.jsx(kt,{open:l,onOpenChange:c,title:"Clear All Traces?",description:"This will permanently delete all traces for this project. The project itself will remain, but all trace data will be lost. This action cannot be undone.",onConfirm:V,loading:i.isPending,confirmLabel:"Clear Traces"})]}):r.jsx(La,{})}const Qo=()=>{const{projectId:e}=Ea.useParams();return r.jsx(Wo,{projectId:e})};export{Qo as component};
