import{a as k,r as l,q as h,j as o,c as p,L as I,D as z,G as N,w as v,z as M,T as $}from"./index-CUDottTv.js";import{B as P}from"./badge-BOfEUuSW.js";import{S as G}from"./textarea-DAwdLdON.js";import{J as O}from"./json-viewer-Dup5M0px.js";import{E as V}from"./empty-config-state-ReVUjdJ_.js";import{E as W}from"./export-button-D7y2ugNf.js";import{b as _}from"./format-CF_gowqw.js";import{C as q}from"./chevron-right-Df1qu9CE.js";import{T as E}from"./tag-Czqgl1tA.js";import"./download-CwvkYJyJ.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const F=k("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const H=k("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const J=k("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]),K={"ui.click":{icon:H,color:"text-blue"},breadcrumb:{icon:F,color:"text-purple"},navigation:{icon:J,color:"text-cyan"},"console.log":{icon:v,color:"text-text-secondary"},"console.info":{icon:v,color:"text-blue"},"console.warn":{icon:$,color:"text-amber"},"console.error":{icon:M,color:"text-red"},"console.debug":{icon:v,color:"text-text-muted"},http:{icon:N,color:"text-green"},"http.error":{icon:N,color:"text-red"},state:{icon:z,color:"text-indigo"},custom:{icon:E,color:"text-teal"}};function g(a){return K[a]??{icon:E,color:"text-text-muted"}}const U={error:"red",warning:"amber",info:"blue",debug:"default"};function Y(a){return a.map(e=>{const s=e.action==="click",i=s?"ui.click":"breadcrumb",n=g(i);return{id:`ui-${e.eventId}`,timestamp:e.timestamp,category:i,level:"info",message:s?e.text?`Click: ${e.text}`:`Click: ${e.target}`:e.text??e.target,icon:n.icon,color:n.color,data:{target:e.target,...e.data}}})}function Q(a){return a.map(e=>{const s=`console.${e.level}`,i=g(s),n=e.level==="error"?"error":e.level==="warn"?"warning":e.level==="debug"||e.level==="trace"?"debug":"info";return{id:`con-${e.eventId}`,timestamp:e.timestamp,category:s,level:n,message:e.message.slice(0,200),icon:i.icon,color:i.color,...e.stackTrace&&{data:{hasStack:!0}}}})}function X(a){return a.map(e=>{const s=e.errorPhase||e.status>=400,i=s?"http.error":"http",n=g(i);let d;try{d=new URL(e.url).pathname}catch{d=e.url}return{id:`net-${e.eventId}`,timestamp:e.timestamp,category:i,level:s?"error":"info",message:`${e.method} ${d} → ${e.status||e.errorPhase||"pending"}`,icon:n.icon,color:n.color,data:{duration:e.duration,status:e.status,url:e.url}}})}const Z=["all","ui.click","breadcrumb","console","http","navigation"],ee=["all","error","warning","info","debug"],C={debug:0,info:1,warning:2,error:3},b=300,te=l.memo(function({entry:e,isExpanded:s,onToggle:i}){const n=g(e.category),d=n.icon,m=e.data&&Object.keys(e.data).length>0;return o.jsxs("div",{className:"border-b border-border-muted",children:[o.jsxs("div",{onClick:()=>m&&i(e.id),className:p("flex items-center gap-3 px-5 py-2 transition-colors",m&&"cursor-pointer hover:bg-bg-hover",s&&"bg-bg-hover"),children:[m&&o.jsx(q,{size:12,className:p("shrink-0 text-text-muted transition-transform",s&&"rotate-90")}),!m&&o.jsx("div",{className:"w-3 shrink-0"}),o.jsx(d,{size:14,strokeWidth:1.75,className:p("shrink-0",n.color)}),o.jsx("span",{className:"text-[11px] font-mono text-text-muted tabular-nums shrink-0",children:_(e.timestamp)}),o.jsx("span",{className:p("text-[13px] flex-1 min-w-0 truncate",e.level==="error"?"text-red":e.level==="warning"?"text-amber":"text-text-primary"),children:e.message}),o.jsx(P,{variant:U[e.level]??"default",className:"shrink-0 text-[10px]",children:e.category})]}),s&&m&&o.jsx("div",{className:"px-5 pb-3 pl-16",children:o.jsx("div",{className:"bg-bg-elevated rounded-md p-3 border border-border-muted",children:o.jsx(O,{data:e.data,defaultExpanded:!0})})})]})});function ue(){const[a,e]=l.useState("all"),[s,i]=l.useState("all"),[n,d]=l.useState(""),[m,S]=l.useState(null),[f,L]=l.useState(!1),T=h(t=>t.initialLoadDone),y=h(t=>t.ui),j=h(t=>t.console),w=h(t=>t.network),u=l.useMemo(()=>{const t=[...Y(y),...Q(j),...X(w)];return t.sort((r,c)=>c.timestamp-r.timestamp),t},[y,j,w]),B=l.useMemo(()=>{const t={all:u.length};for(const r of u){const c=r.category.startsWith("console")?"console":r.category.startsWith("http")?"http":r.category;t[c]=(t[c]??0)+1}return t},[u]),x=l.useMemo(()=>{let t=u;if(a!=="all"&&(t=t.filter(r=>a==="console"?r.category.startsWith("console"):a==="http"?r.category.startsWith("http"):r.category===a)),s!=="all"){const r=C[s]??0;t=t.filter(c=>(C[c.level]??0)>=r)}if(n){const r=n.toLowerCase();t=t.filter(c=>c.message.toLowerCase().includes(r)||c.category.includes(r))}return t},[u,a,s,n]),A=l.useMemo(()=>f||x.length<=b?x:x.slice(-b),[x,f]),R=!f&&x.length>b,D=l.useCallback(t=>{S(r=>r===t?null:t)},[]);return o.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[o.jsxs("div",{className:"border-b border-border-default px-5 py-2.5 flex items-center gap-3",children:[o.jsx("div",{className:"flex items-center gap-1",children:Z.map(t=>{const r=a===t,c=t==="all"?null:g(t);return o.jsxs("button",{onClick:()=>e(t),className:p("h-7 px-2.5 rounded-md text-[12px] font-medium transition-colors cursor-pointer flex items-center gap-1.5",r?"bg-bg-elevated text-text-primary":"text-text-tertiary hover:text-text-secondary hover:bg-bg-hover"),children:[c&&o.jsx(c.icon,{size:12,className:r?c.color:""}),o.jsx("span",{className:"capitalize",children:t==="ui.click"?"Clicks":t==="http"?"HTTP":t}),o.jsx("span",{className:p("text-[10px] tabular-nums",r?"text-text-secondary":"text-text-muted"),children:B[t]??0})]},t)})}),o.jsx("div",{className:"h-4 w-px bg-border-default"}),o.jsx("div",{className:"flex items-center gap-1",children:ee.map(t=>{const r=s===t;return o.jsx("button",{onClick:()=>i(t),className:p("h-7 px-2 rounded-md text-[11px] font-medium transition-colors cursor-pointer capitalize",r?"bg-bg-elevated text-text-primary":"text-text-tertiary hover:text-text-secondary hover:bg-bg-hover"),children:t},t)})}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[o.jsx("div",{className:"w-56",children:o.jsx(G,{value:n,onChange:t=>d(t.target.value),placeholder:"Search breadcrumbs..."})}),o.jsx(W,{data:x,filename:"breadcrumbs"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:!T&&u.length===0?o.jsx(I,{rows:12}):u.length===0?o.jsx(V,{title:"No Breadcrumbs",description:"Breadcrumbs are custom markers you add to trace user flows and debug sequences. Add them in your code with the SDK's addBreadcrumb() function.",configHints:[{key:"RuntimeScope.addBreadcrumb('label'",value:"{ key: 'value' })",description:"Add trail markers"},{key:"RuntimeScope.track('event_name'",value:"{ data })",description:"Track custom events"}]}):o.jsxs(o.Fragment,{children:[A.map(t=>o.jsx(te,{entry:t,isExpanded:m===t.id,onToggle:D},t.id)),R&&o.jsx("div",{className:"px-5 py-3 text-center",children:o.jsxs("button",{onClick:()=>L(!0),className:"text-xs text-text-tertiary hover:text-text-secondary transition-colors",children:["Showing ",b," of ",x.length," entries — click to show all"]})})]})})]})}export{ue as BreadcrumbsPage};
