PageSourceSearch

http://parisobs.com/_next/static/chunks/4200-36c7c41905bc89f2.js

js parisobs.com collected 2026-10-04 01:42:18 UTC 321,535 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4200],{3341:(e,t,n)=>{n.d(t,{a:()=>I,j:()=>S});var a=n(73154),r=n(96810),s=n(86843),l=n(85369),o=n(81509),i=n(52441),d=n(18254);function c(e){let{message:t,toolCallNumbers:n,className:r}=e,s=t.tool_calls;return s&&Array.isArray(s)&&0!==s.length?(0,a.jsx)("div",{className:(0,o.cn)("flex flex-col gap-2",r),"data-sentry-component":"ToolCallInvocationsView","data-sentry-source-file":"ToolCallInvocationsView.tsx",children:s.map((e,r)=>{let s=null==n?void 0:n[r],i=e.arguments;if("string"==typeof e.arguments)try{i=JSON.parse(e.arguments)}catch(t){i=e.arguments}return(0,a.jsxs)("div",{className:(0,o.cn)("w-full border-t px-2 py-2",("assistant"===t.role||"Output"===t.name||"Model"===t.name)&&"bg-accent-light-green"),children:[(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsxs)("span",{className:"font-mono text-xs font-medium text-foreground",children:[void 0!==s&&(0,a.jsxs)("span",{className:"mr-1",children:[s,"."]}),e.name]})]}),e.id&&(0,a.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:e.id})]}),(0,a.jsxs)("div",{className:"py-2 [&_.io-message-content]:px-0",children:[(0,a.jsx)("div",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:"Arguments"}),(0,a.jsx)(l.U,{json:i,currentView:"pretty",codeClassName:"text-xs"})]})]},"".concat(e.id,"-").concat(r))})}):null}var u=n(59077),m=n(71339),p=n(42661);function h(e){return null!=e.content&&""!==e.content||!!e.audio}function x(e){return Object.keys(e).filter(e=>"role"!==e&&"content"!==e).length>0}function f(e){return"placeholder"===e.type}function g(e){return h(e)||x(e)||f(e)}function y(e){return Array.isArray(e.thinking)&&e.thinking.length>0}function v(e){return Array.isArray(e.redacted_thinking)&&e.redacted_thinking.length>0}var j=n(59757);function b(e){let{content:t,summary:n,defaultExpanded:s=!1}=e,[l,i]=(0,r.useState)(s),d=n||t;return(0,a.jsxs)("div",{className:"my-2 px-1","data-sentry-component":"ThinkingBlock","data-sentry-source-file":"ThinkingBlock.tsx",children:[(0,a.jsxs)("button",{type:"button",className:"flex w-full cursor-pointer items-start gap-1 text-left text-muted-foreground hover:text-foreground",onClick:()=>i(!l),"aria-expanded":l,children:[(0,a.jsx)(j.A,{className:(0,o.cn)("mt-0.5 h-3 w-3 flex-shrink-0 transition-transform",l&&"rotate-90"),"data-sentry-element":"ChevronRight","data-sentry-source-file":"ThinkingBlock.tsx"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Thinking"}),!l&&(0,a.jsx)("span",{className:"line-clamp-1 text-xs italic",children:d})]}),l&&(0,a.jsx)("div",{className:"ml-4 mt-1 whitespace-pre-wrap text-sm italic text-muted-foreground",children:t})]})}function w(e){let{data:t,defaultExpanded:n=!1}=e,[s,l]=(0,r.useState)(n);return(0,a.jsxs)("div",{className:"my-2 px-1","data-sentry-component":"RedactedThinkingBlock","data-sentry-source-file":"ThinkingBlock.tsx",children:[(0,a.jsxs)("button",{type:"button",className:"flex w-full cursor-pointer items-start gap-1 text-left text-muted-foreground hover:text-foreground",onClick:()=>l(!s),"aria-expanded":s,children:[(0,a.jsx)(j.A,{className:(0,o.cn)("mt-0.5 h-3 w-3 flex-shrink-0 transition-transform",s&&"rotate-90"),"data-sentry-element":"ChevronRight","data-sentry-source-file":"ThinkingBlock.tsx"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Thinking (redacted)"}),!s&&(0,a.jsx)("span",{className:"text-xs italic",children:"[Encrypted thinking data]"})]}),s&&(0,a.jsx)("div",{className:"ml-4 mt-1 break-all rounded bg-muted/50 p-2 font-mono text-xs text-muted-foreground",children:t})]})}function N(e){var t,n,d,g,j,N;let{message:C,shouldRenderMarkdown:T,currentView:I,toolCallNumbers:S,projectIdForPromptButtons:k,isOutputMessage:E}=e,[O,A]=(0,r.useState)(!1),M=null!=(n=null!=(t=C.name)?t:C.role)?n:"",D=C.tool_calls&&Array.isArray(C.tool_calls)?C.tool_calls:(null==(d=C.json)?void 0:d.tool_calls)&&Array.isArray(null==(g=C.json)?void 0:g.tool_calls)?C.json.tool_calls:[],P=h(C),L=null!=C.json?(0,a.jsx)(s.$,{variant:"ghost",size:"icon-xs",onClick:()=>A(e=>!e),title:O?"Show formatted view":"Show passthrough JSON data",className:"-mr-2 hover:bg-border",children:O?(0,a.jsx)(u.A,{className:"h-3 w-3 text-primary"}):(0,a.jsx)(m.A,{className:"h-3 w-3"})}):void 0;if(f(C))return(0,a.jsxs)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:[(0,a.jsx)("div",{style:{display:T?"block":"none"},children:(0,a.jsx)(i.$,{title:"Placeholder",content:C.name||"Unnamed placeholder",customCodeHeaderClassName:(0,o.cn)("bg-primary-foreground")})}),(0,a.jsx)("div",{style:{display:T?"none":"block"},children:(0,a.jsx)(l.U,{title:"Placeholder",json:C.name||"Unnamed placeholder",projectIdForPromptButtons:k,currentView:I})})]});if(null==C.content&&null==C.tool_calls&&null==C.audio&&null!=C.json)return(0,a.jsx)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:(0,a.jsx)(l.U,{title:M||(E?"Output":"Input"),json:C.json,projectIdForPromptButtons:k,currentView:I})});if(O)return(0,a.jsx)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:(0,a.jsx)(l.U,{title:M,json:C.json,projectIdForPromptButtons:k,currentView:"pretty",controlButtons:L})});if(!P&&!y(C)&&!v(C)&&D.length>0)return(0,a.jsxs)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:[(0,a.jsx)(i.Q,{title:M,handleOnValueChange:()=>{},handleOnCopy:()=>{let e=JSON.stringify(C,null,2);(0,p.e)(e)},controlButtons:L}),(0,a.jsx)(c,{message:C,toolCallNumbers:S})]});if(P||y(C)||v(C)){let e=(0,a.jsxs)(a.Fragment,{children:[y(C)&&(null==(j=C.thinking)?void 0:j.map((e,t)=>(0,a.jsx)(b,{content:e.content,summary:e.summary},"thinking-".concat(t)))),v(C)&&(null==(N=C.redacted_thinking)?void 0:N.map((e,t)=>(0,a.jsx)(w,{data:e.data},"redacted-".concat(t))))]});return(0,a.jsxs)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:[(0,a.jsxs)("div",{style:{display:T?"block":"none"},children:[(0,a.jsx)(i.$,{title:M,content:C.content||"",customCodeHeaderClassName:(0,o.cn)("assistant"===C.role&&"bg-secondary","system"===C.role&&"bg-primary-foreground"),audio:C.audio,controlButtons:L,afterHeader:e}),D.length>0&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(c,{message:C,toolCallNumbers:S})})]}),(0,a.jsxs)("div",{style:{display:T?"none":"block"},children:[(0,a.jsx)(l.U,{title:M,json:C.content,projectIdForPromptButtons:k,currentView:I,controlButtons:L,afterHeader:e}),D.length>0&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(c,{message:C,toolCallNumbers:S})})]})]})}return x(C)?(0,a.jsx)("div",{className:(0,o.cn)("transition-colors hover:bg-muted"),children:(0,a.jsx)(l.U,{title:M||(E?"Output":"Input"),json:C,projectIdForPromptButtons:k,currentView:I})}):null}var C=n(54959);function T(e){let{media:t}=e;return 0===t.length?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"my-1 px-2 py-1 text-xs text-muted-foreground",children:"Media"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 p-4 pt-1",children:t.map(e=>(0,a.jsx)(C.P,{mediaAPIReturnValue:e,asFileIcon:!0},e.mediaId))})]})}function I(e){let{messages:t,shouldRenderMarkdown:n,media:o,additionalInput:i,currentView:d,messageToToolCallNumbers:c,collapseLongHistory:u=!0,projectIdForPromptButtons:m,inputMessageCount:p}=e,h=(0,r.useMemo)(()=>t.filter(g),[t]),[x,f]=(0,r.useState)(!!u&&h.length>3||null);return(0,a.jsx)("div",{className:"flex max-h-full min-h-0 flex-col gap-2","data-sentry-component":"ChatMessageList","data-sentry-source-file":"ChatMessageList.tsx",children:(0,a.jsxs)("div",{className:"flex max-h-full min-h-0 flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:h.map((e,t)=>({message:e,originalIndex:t})).filter(e=>{let{originalIndex:t}=e;return!x||0===t||t>h.length-3}).map(e=>{let{message:t,originalIndex:l}=e;return(0,a.jsxs)(r.Fragment,{children:[(0,a.jsx)(N,{message:t,shouldRenderMarkdown:n,currentView:d,toolCallNumbers:c.get(l),projectIdForPromptButtons:m,isOutputMessage:l>=(null!=p?p:0)}),null!==x&&0===l&&(0,a.jsx)(s.$,{variant:"ghost",size:"xs",onClick:()=>f(e=>!e),className:"underline",children:x?"Show ".concat(h.length-3," more ..."):"Hide history"})]},l)})}),i&&(0,a.jsx)(l.U,{title:"Additional Input",json:i,projectIdForPromptButtons:m,currentView:n?"pretty":"json"}),o&&o.length>0&&(0,a.jsx)(T,{media:o})]})})}let S=I},5258:(e,t,n)=>{n.d(t,{C:()=>tM});var a=n(73154),r=n(8862),s=n(45607),l=n(96810),o=n(6300),i=n(63748);let d=["preview","log","scores"],c="preview",u=["formatted","json"],m=(0,l.createContext)(null);function p(){let e=(0,l.useContext)(m);if(!e)throw Error("useSelection must be used within a SelectionProvider");return e}function h(e){let{children:t}
1=e,[n,r]=(0,o.useQueryParam)("observation",o.StringParam),[p,h]=(0,o.useQueryParam)("traceTab",o.StringParam),[x,f]=(0,o.useQueryParam)("pref",o.StringParam),{jsonViewPreference:g,setJsonViewPreference:y}=(0,s.v)(),[v,j]=(0,l.useState)([]),[b,w]=(0,l.useState)(""),[N,C]=(0,l.useState)(""),T=d.includes(p)?p:c,I=u.includes(x)?x:"json"===g||"json-beta"===g?"json":"formatted",S=(0,l.useCallback)(e=>{h(e===c?null:e)},[h]),k=(0,l.useCallback)(e=>{let t="json"===e?"json":"pretty";y(t),f(e===("json"===t?"json":"formatted")?null:e)},[y,f]),E=(0,i.d)(C,500,!1),O=(0,l.useCallback)(e=>{w(e),E(e)},[E]),A=(0,l.useCallback)(e=>{w(e),C(e)},[]),M=(0,l.useMemo)(()=>new Set(v),[v]),D=(0,l.useCallback)(e=>{j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),P=(0,l.useCallback)(()=>{j([])},[]),L=(0,l.useCallback)(e=>{j(e)},[]),B=(0,l.useCallback)(e=>{r(e)},[r]),R=(0,l.useMemo)(()=>({selectedNodeId:null!=n?n:null,setSelectedNodeId:B,collapsedNodes:M,toggleCollapsed:D,expandAll:P,collapseAll:L,searchQuery:N,searchInputValue:b,setSearchInputValue:O,setSearchQueryImmediate:A,selectedTab:T,setSelectedTab:S,viewPref:I,setViewPref:k}),[n,B,M,D,P,L,N,b,O,A,T,S,I,k]);return(0,a.jsx)(m.Provider,{value:R,"data-sentry-element":"SelectionContext.Provider","data-sentry-component":"SelectionProvider","data-sentry-source-file":"SelectionContext.tsx",children:t})}let x=(0,l.createContext)(null);function f(e){let{children:t}=e,[n,r]=(0,l.useState)(""),[s,o]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=setTimeout(()=>{o(n)},500);return()=>clearTimeout(e)},[n]);let i=(0,l.useCallback)(e=>{r(e),o(e)},[]);return(0,a.jsx)(x.Provider,{value:{searchQuery:s,searchInputValue:n,setSearchInputValue:r,setSearchQueryImmediate:i},"data-sentry-element":"SearchContext.Provider","data-sentry-component":"SearchProvider","data-sentry-source-file":"SearchContext.tsx",children:t})}function g(){let e=(0,l.useContext)(x);if(!e)throw Error("useSearch must be used within SearchProvider");return e}var y=n(35545),v=n(93367),j=n(55803);let b=(0,l.createContext)(null);function w(){let e=(0,l.useContext)(b);if(!e)throw Error("useTraceGraphData must be used within a TraceGraphDataProvider");return e}function N(e){let{children:t,projectId:n,traceId:r,observations:s}=e,{isBetaEnabled:o}=(0,j.I)(),i=s.length>=5e3,{minStartTime:d,maxStartTime:c}=(0,l.useMemo)(()=>{if(i||0===s.length)return{minStartTime:null,maxStartTime:null};let e=1/0,t=0;for(let n of s){let a=n.startTime.getTime();a<e&&(e=a),a>t&&(t=a)}return{minStartTime:new Date(e).toISOString(),maxStartTime:new Date(t).toISOString()}},[s,i]),u=!i&&s.length>0&&null!==d&&null!==c,m={projectId:n,traceId:r,minStartTime:null!=d?d:"",maxStartTime:null!=c?c:""},p={refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,staleTime:3e6},h=v.FH.traces.getAgentGraphData.useQuery(m,{...p,enabled:u&&!o}),x=v.FH.events.getAgentGraphData.useQuery(m,{...p,enabled:u&&o}),f=o?x:h,g=(0,l.useMemo)(()=>{var e;return null!=(e=f.data)?e:[]},[f.data]),y=(0,l.useMemo)(()=>{if(0===g.length||g.length>=5e3)return!1;let e=g.some(e=>"SPAN"!==e.observationType&&"EVENT"!==e.observationType&&"GENERATION"!==e.observationType),t=g.some(e=>null!=e.step&&0!==e.step);return e||t},[g]),w=(0,l.useMemo)(()=>({agentGraphData:g,isGraphViewAvailable:y,isLoading:f.isLoading}),[g,y,f.isLoading]);return(0,a.jsx)(b.Provider,{value:w,"data-sentry-element":"TraceGraphDataContext.Provider","data-sentry-component":"TraceGraphDataProvider","data-sentry-source-file":"TraceGraphDataContext.tsx",children:t})}var C=n(86843),T=n(66428),I=n(21);let S=(0,l.createContext)(null);function k(e){let{children:t}=e,[n,r]=(0,l.useState)(!0);return(0,a.jsx)(S.Provider,{value:{isNavigationExpanded:n,setIsNavigationExpanded:r},"data-sentry-element":"LayoutContext.Provider","data-sentry-component":"TraceLayoutMobile","data-sentry-source-file":"TraceLayoutMobile.tsx",children:(0,a.jsx)("div",{className:"flex h-full w-full flex-col",children:t})})}k.NavigationPanel=function(e){let{children:t}=e,{isNavigationExpanded:n,setIsNavigationExpanded:r}=function(){let e=(0,l.useContext)(S);if(!e)throw Error("TraceLayoutMobile compound components must be used within TraceLayoutMobile");return e}();return(0,a.jsxs)("div",{className:"flex flex-shrink-0 flex-col border-b",children:[(0,a.jsxs)(C.$,{variant:"ghost",className:"flex w-full justify-between rounded-none px-4 py-3 text-left",onClick:()=>r(!n),children:[(0,a.jsx)("span",{className:"font-medium",children:"Navigation"}),n?(0,a.jsx)(T.A,{className:"h-4 w-4"}):(0,a.jsx)(I.A,{className:"h-4 w-4"})]}),n&&(0,a.jsx)("div",{className:"max-h-96 overflow-y-auto",children:t})]})},k.DetailPanel=function(e){let{children:t}=e;return(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:t})};var E=n(49859);let O="trace-layout",A="trace-layout-handle",M=(0,l.createContext)(null);function D(){let e=(0,l.useContext)(M);if(!e)throw Error("TraceLayoutDesktop compound components must be used within TraceLayoutDesktop");return e}function P(e){let{children:t}=e,[n]=(0,o.useQueryParam)("view",o.StringParam),r="timeline"===n,[s,i]=(0,l.useState)(10),[d,c]=(0,l.useState)(10),[u,m]=(0,l.useState)(5),[p,h]=(0,l.useState)(!1),[x,f]=(0,l.useState)(null),g=(0,l.useRef)(null);(0,l.useLayoutEffect)(()=>{let e=document.querySelector("#".concat(O)),t=document.querySelectorAll("#".concat(A));if(!e||!t)return;let n=new ResizeObserver(()=>{let n=e.offsetWidth;
1t.forEach(e=>{n-=e.offsetWidth});let a=450/n*100,r=360/n*100,s=40/n*100;i(a),c(r),m(s)});return n.observe(e),t.forEach(e=>{n.observe(e)}),()=>{n.disconnect()}},[]);let[y,v]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(r){v(!0);let e=setTimeout(()=>{v(!1)},12e3);return()=>clearTimeout(e)}v(!1)},[r]),(0,a.jsx)(M.Provider,{value:{navigationPanelMinSize:d,navigationPanelCollapsedSize:u,isNavigationPanelCollapsed:p,setIsNavigationPanelCollapsed:h,panelRef:g,handleTogglePanel:()=>{g.current&&(p?(g.current.resize(null!=x?x:s),h(!1)):(f(g.current.getSize()),h(!0),g.current.resize(u)))},shouldPulseToggle:y},"data-sentry-element":"LayoutContext.Provider","data-sentry-component":"TraceLayoutDesktop","data-sentry-source-file":"TraceLayoutDesktop.tsx",children:(0,a.jsx)("div",{className:"h-full w-full",children:(0,a.jsx)(E.YZ,{direction:"horizontal",id:O,"data-sentry-element":"PanelGroup","data-sentry-source-file":"TraceLayoutDesktop.tsx",children:t})})})}P.NavigationPanel=function(e){let{children:t}=e,{navigationPanelMinSize:n,navigationPanelCollapsedSize:r,setIsNavigationPanelCollapsed:s,panelRef:l}=D();return(0,a.jsx)(E.Zk,{id:"trace-layout-panel-navigation",ref:l,collapsible:!0,collapsedSize:r,minSize:n,onCollapse:()=>s(!0),onExpand:()=>s(!1),children:t})},P.ResizeHandle=function(){let{handleTogglePanel:e}=D();return(0,a.jsx)(E.TW,{id:A,className:"relative w-px bg-border transition-colors duration-200 after:absolute after:inset-y-0 after:left-0 after:w-1 after:bg-blue-200 after:opacity-0 after:transition-opacity after:duration-200 hover:after:opacity-100 data-[resize-handle-state='drag']:after:opacity-100",onDoubleClick:e})},P.DetailPanel=function(e){let{children:t}=e;return(0,a.jsx)(E.Zk,{id:"trace-layout-panel-preview",defaultSize:70,minSize:50,children:t})};var L=n(10614),B=n(81509);function R(e){let{roots:t,collapsedNodes:n,selectedNodeId:r,renderNode:s,onToggleCollapse:o,onSelectNode:i,estimateSize:d,overscan:c=500,defaultRowHeight:u=37,className:m}=e,p=(0,l.useRef)(null),h=(0,l.useMemo)(()=>(function(e,t){if(0===e.length)return[];let n=[],a=[...e].sort((e,t)=>{var n,a,r,s;return(null!=(r=null==(n=e.startTime)?void 0:n.getTime())?r:0)-(null!=(s=null==(a=t.startTime)?void 0:a.getTime())?s:0)}),r=[];for(let e=a.length-1;e>=0;e--)r.push({node:a[e],depth:0,treeLines:[],isLastSibling:e===a.length-1});for(;r.length>0;){let e=r.pop();if(n.push({node:e.node,depth:e.depth,treeLines:e.treeLines,isLastSibling:e.isLastSibling}),e.node.children.length>0&&!t.has(e.node.id)){let t=[...e.node.children].sort((e,t)=>{var n,a,r,s;return(null!=(r=null==(n=e.startTime)?void 0:n.getTime())?r:0)-(null!=(s=null==(a=t.startTime)?void 0:a.getTime())?s:0)});for(let n=t.length-1;n>=0;n--){let a=t[n],s=n===t.length-1;r.push({node:a,depth:e.depth+1,treeLines:[...e.treeLines,!s],isLastSibling:s})}}}return n})(t,n),[t,n]),x=(0,L.Te)({count:h.length,getScrollElement:()=>p.current,estimateSize:d?e=>d(h[e].node,e):()=>u,overscan:c,measureElement:e=>e.getBoundingClientRect().height}),f=(0,l.useRef)(r),g=(0,l.useRef)(!1);return(0,l.useLayoutEffect)(()=>{if(r&&!g.current&&r===f.current){let e=h.findIndex(e=>e.node.id===r);-1!==e&&(x.scrollToIndex(e,{align:"center",behavior:"auto"}),g.current=!0)}},[r,h,x]),(0,a.jsx)("div",{ref:p,className:(0,B.cn)("h-full overflow-y-auto",m),"data-sentry-component":"VirtualizedTree","data-sentry-source-file":"VirtualizedTree.tsx",children:(0,a.jsx)("div",{style:{height:"".concat(x.getTotalSize(),"px"),width:"100%",position:"relative"},children:x.getVirtualItems().map(e=>{let t=h[e.index],l=t.node.id===r,d=n.has(t.node.id);return(0,a.jsx)("div",{"data-index":e.index,ref:x.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(e.start,"px)")},children:s({node:t.node,treeMetadata:{depth:t.depth,treeLines:t.treeLines,isLastSibling:t.isLastSibling},isSelected:l,isCollapsed:d,onToggleCollapse:()=>o(t.node.id),onSelect:()=>i(t.node.id)})},t.node.id)})})})}var V=n(57404),z=n(59757);function _(e){let{metadata:t,nodeType:n,hasChildren:r,isCollapsed:s,onToggleCollapse:l,isSelected:o,onSelect:i,children:d,className:c}=e,{depth:u,treeLines:m,isLastSibling:p}=t;return(0,a.jsx)("div",{className:(0,B.cn)("relative flex w-full cursor-pointer px-0",o?"bg-muted":"hover:bg-muted/50",c),style:{paddingTop:0,paddingBottom:0},onClick:e=>{var t;(null==(t=e.currentTarget)?void 0:t.closest("[data-expand-button]"))||i()},"data-sentry-component":"VirtualizedTreeNodeWrapper","data-sentry-source-file":"VirtualizedTreeNodeWrapper.tsx",children:(0,a.jsxs)("div",{className:"flex w-full pl-2",children:[u>0&&(0,a.jsx)("div",{className:"flex flex-shrink-0",children:Array.from({length:u-1},(e,t)=>(0,a.jsx)("div",{className:"relative w-5",children:m[t]&&(0,a.jsx)("div",{className:"absolute bottom-0 left-3 top-0 w-px bg-border"})},t))}),u>0&&(0,a.jsx)("div",{className:"relative w-5 flex-shrink-0",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:(0,B.cn)("absolute left-3 top-0 w-px bg-border",p?"h-3":"bottom-3")}),!p&&(0,a.jsx)("div",{className:"absolute bottom-0 left-3 top-3 w-px bg-border"}),(0,a.jsx)("div",{className:"absolute left-3 top-3 h-px w-2 bg-border"})]})}),(0,a.jsxs)("div",{className:"relative flex w-6 flex-shrink-0 flex-col py-1.5",children:[(0,a.jsx)("div",{className:"relative z-10 flex h-4 items-center justify-center",children:(0,a.jsx)(V.L,{type:n,isSmall:!0,className:"!size-3","data-sentry-element":"ItemBadge","data-sentry-source-file":"VirtualizedTreeNodeWrapper.tsx"})}),r&&!s&&(0,a.jsx)("div",{className:"absolute bottom-0 left-1/2 top-3 w-px bg-border"}),0===u&&r&&!s&&(0,a.jsx)("div",{className:"absolute bottom-0 left-1/2 top-3 w-px bg-border"})]}),(0,a.jsx)("div",{className:"flex min-w-0 flex-1",children:d}),r&&(0,a.jsx)("div",{className:"flex items-center justify-end py-1 pr-1",children:(0,a.jsx)(C.$,{"aria-expanded":!s,"data-expand-button":!0,size:"icon",variant:"ghost",onClick:e=>{e.stopPropagation(),l()},className:"h-6 w-6 flex-shrink-0 hover:bg-primary/10",children:(0,a.jsx)("span",{className:(0,B.cn)("inline-block h-4 w-4 transform transition-transform duration-200 ease-in-out",s?"rotate-0":"rotate-90"),children:(0,a.jsx)(z.A,{className:"h-4 w-4"})})})})]})})}var F=n(46719),H=n(48977),J=n(32165),U=n(47106),W=n(67005),G=n(66763);function $(e){var t,n;let{node:l,parentTotalCost:o,parentTotalDuration:i,commentCount:d,onSelect:c,onHover:u,className:m}=e,{mergedScores:p,roots:h}=(0,r.f)(),{showDuration:x,showCostTokens:f,showScores:g,colorCodeMetrics:y,showComments:v}=(0,s.v)(),j=l.totalCost,b=l.endTime&&l.startTime?l.endTime.getTime()-l.startTime.getTime():l.latency?1e3*l.latency:void 0,w=x&&!!(b||l.latency),N=f&&!!(l.inputUsage||l.outputUsage||l.totalUsage||j),C=h.some(e=>"TRACE"===e.type),T="TRACE"===l.type?p.filter(e=>null===e.observationId):null!==l.parentObservationId||C?p.filter(e=>e.observationId===l.id):p.filter(e=>e.observationId===l.id||null===e.observationId);return(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==c||c()},onMouseEnter:u,title:l.name,className:(0,B.cn)("peer relative flex min-w-0 flex-1 items-start rounded-md py-0.5 pl-1 pr-2 text-left",m),"data-sentry-component":"SpanContent","data-sentry-source-file":"SpanContent.tsx",children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[(0,a.jsx)("span",{className:"flex-shrink truncate text-xs",children:l.name||"Unnamed ".concat(l.type.toLowerCase())}),(0,a.jsxs)("div",{className:"flex items-center gap-x-2",children:[v&&void 0!==d&&(0,a.jsx)(J.o,{count:d}),"TRACE"!==l.type&&l.level&&"DEFAULT"!==l.level&&(0,a.jsx)("div",{className:"flex",children:(0,a.jsx)("span",{className:(0,B.cn)("rounded-sm p-0.5 text-xs",null==(t=H.$H[l.level])?void 0:t.bg,null==(n=H.$H[l.level])?void 0:n.text),children:l.level})})]})]}),(w||N)&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-x-2",children:[w&&(b||l.latency)?(0,a.jsx)("span",{title:l.children.length>0||"TRACE"===l.type?"Aggregated duration of all child observations":void 0,className:(0,B.cn)("text-xs text-muted-foreground",i&&y&&(0,G.$s)({max:i,value:b||(l.latency?1e3*l.latency:0)})),children:(0,U.O_)((b||(l.latency?1e3*l.latency:0))/1e3)}):null,N&&(l.inputUsage||l.outputUsage||l.totalUsage)?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,W.nK)(l.inputUsage,l.outputUsage,l.totalUsage)}):null,N&&j?(0,a.jsxs)("span",{title:l.children.length>0||"TRACE"===l.type?"Aggregated cost of all child observations":void 0,className:(0,B.cn)("text-xs text-muted-foreground",o&&y&&(0,G.$s)({max:o,value:j})),children:[l.children.length>0||"TRACE"===l.type?"∑ ":"",(0,W.hp)(j.toNumber())]}):null]}),g&&T.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,a.jsx)(F.P,{compact:!0,scores:T})})]})})}var K=n(65637);function Q(){let{trace:e}=(0,r.f)(),{prefetch:t}=(0,K.z)({projectId:e.projectId});return{handleHover:(0,l.useCallback)(n=>{"TRACE"!==n.type&&t(n.id,e.id,n.startTime)},[t,e.id])}}function q(){let{roots:e,comments:t}=(0,r.f)(),{selectedNodeId:n,setSelectedNodeId:s,collapsedNodes:l,toggleCollapsed:o}=p(),{handleHover:i}=Q(),d=e.reduce((e,t)=>
1t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),c=e.length>0?Math.max(...e.map(e=>null!=e.latency?1e3*e.latency:0)):void 0;return(0,a.jsx)(R,{roots:e,collapsedNodes:l,selectedNodeId:n,onToggleCollapse:o,onSelectNode:s,renderNode:e=>{let{node:n,treeMetadata:r,isSelected:s,isCollapsed:l,onToggleCollapse:o,onSelect:u}=e;return(0,a.jsx)(_,{metadata:r,nodeType:n.type,hasChildren:n.children.length>0,isCollapsed:l,onToggleCollapse:o,isSelected:s,onSelect:u,children:(0,a.jsx)($,{node:n,parentTotalCost:d,parentTotalDuration:c,commentCount:t.get(n.id),onSelect:u,onHover:()=>i(n)})})},"data-sentry-element":"VirtualizedTree","data-sentry-component":"TraceTree","data-sentry-source-file":"TraceTree.tsx"})}function X(e){let{items:t,renderItem:n,selectedItemId:r,onSelectItem:s,getItemId:o,estimatedItemSize:i=48,overscan:d=500}=e,c=(0,l.useRef)(null),u=(0,L.Te)({count:t.length,getScrollElement:()=>c.current,estimateSize:()=>i,overscan:d}),m=u.getVirtualItems();return(0,a.jsx)("div",{ref:c,className:"h-full overflow-auto","data-sentry-component":"VirtualizedList","data-sentry-source-file":"VirtualizedList.tsx",children:(0,a.jsx)("div",{style:{height:"".concat(u.getTotalSize(),"px"),width:"100%",position:"relative"},children:m.map(e=>{let l=t[e.index],i=o(l),d=r===i;return(0,a.jsx)("div",{"data-index":e.index,ref:u.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(e.start,"px)")},children:n({item:l,index:e.index,isSelected:d,onSelect:()=>s(i)})},i)})})})}function Z(e){let{item:t,isSelected:n,onSelect:s,onHover:l}=e,{node:o,parentTotalCost:i,parentTotalDuration:d}=t,{comments:c}=(0,r.f)(),u=(0,U.O_)(o.startTimeSinceTrace/1e3),m=null!==o.startTimeSinceParentStart?(0,U.O_)(o.startTimeSinceParentStart/1e3):null;return(0,a.jsxs)("div",{onClick:s,onMouseEnter:l,className:(0,B.cn)("flex cursor-pointer items-start gap-2 px-2 py-1.5 transition-colors hover:bg-muted/50",n&&"bg-muted"),"data-sentry-component":"TraceSearchListItem","data-sentry-source-file":"TraceSearchListItem.tsx",children:[(0,a.jsx)(V.L,{type:o.type,"data-sentry-element":"ItemBadge","data-sentry-source-file":"TraceSearchListItem.tsx"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,a.jsx)($,{node:o,parentTotalCost:i,parentTotalDuration:d,commentCount:c.get(o.id),onSelect:s,"data-sentry-element":"SpanContent","data-sentry-source-file":"TraceSearchListItem.tsx"}),"TRACE"!==o.type&&(0,a.jsxs)("div",{className:"text-xs text-muted-foreground/70",children:["depth ",o.depth," • +",u,null!==m&&" • +".concat(m," from parent")]})]})]})}var Y=n(41641);function ee(){let{searchItems:e}=(0,r.f)(),{searchQuery:t,setSearchInputValue:n}=g(),{selectedNodeId:s,setSelectedNodeId:o}=p(),{handleHover:i}=Q(),d=(0,l.useMemo)(()=>{if(!t.trim())return[];let n=t.toLowerCase();return e.filter(e=>{let t=e.node;return t.type.toLowerCase().includes(n)||t.name.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)})},[e,t]);return 0===d.length&&t.trim()?(0,a.jsx)("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("p",{className:"text-muted-foreground",children:"No results found"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Try searching by type, title, or id"}),(0,a.jsxs)(C.$,{variant:"outline",size:"sm",onClick:()=>n(""),children:[(0,a.jsx)(Y.A,{className:"mr-2 h-4 w-4"}),"Clear search"]})]})}):(0,a.jsx)(X,{items:d,selectedItemId:s,onSelectItem:o,getItemId:e=>e.node.id,estimatedItemSize:48,overscan:500,renderItem:e=>{let{item:t,isSelected:n,onSelect:r}=e;return(0,a.jsx)(Z,{item:t,isSelected:n,onSelect:r,onHover:()=>i(t.node)})},"data-sentry-element":"VirtualizedList","data-sentry-component":"TraceSearchList","data-sentry-source-file":"TraceSearchList.tsx"})}let et=[.25,.5,.75,1,1.25,1.5,2,2.5,3,4,5,6,7,8,9,10,15,20,25,35,40,45,50,100,150,200,250,300,350,400,450,500];function en(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:900;return(e.getTime()-t.getTime())/1e3/n*a}function ea(e){let{traceDuration:t,scaleWidth:n,stepSize:r}=e,s=Math.ceil(n/100)+1;return(0,a.jsx)("div",{className:"mb-2 ml-2","data-sentry-component":"TimelineScale","data-sentry-source-file":"TimelineScale.tsx",children:(0,a.jsxs)("div",{className:"relative mr-2 h-8",style:{width:"".concat(n,"px")},children:[Array.from({length:s}).map((e,n)=>{let s=r*n;return s>t?null:(0,a.jsx)("div",{className:"absolute h-full border-l text-xs",style:{left:"".concat(100*n,"px")},children:(0,a.jsxs)("span",{className:"absolute left-2 text-xs text-muted-foreground",title:"".concat(s.toFixed(2),"s"),children:[s.toFixed(2),"s"]})},n)}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0",children:Array.from({length:s}).map((e,n)=>r*n>t||0===n?null:(0,a.jsx)("div",{className:"absolute h-full border-l border-border/30",style:{left:"".concat(100*n,"px")}},"grid-".concat(n)))})]})})}var er=n(45596);function es(e){let{node:t,metrics:n,isSelected:r,onSelect:s,onHover:l,showDuration:o,showCostTokens:i,showScores:d,showComments:c,colorCodeMetrics:u,parentTotalCost:m,parentTotalDuration:p,commentCount:h,scores:x}
1=e,{startOffset:f,itemWidth:g,firstTokenTimeOffset:y,latency:v}=n,j=v?1e3*v:void 0,b=t.children.length>0;if(y){let e=y-f;return(0,a.jsx)("div",{className:"group my-0.5 flex w-full min-w-fit cursor-pointer flex-row items-center",onClick:s,onMouseEnter:l,children:(0,a.jsxs)("div",{className:(0,B.cn)("flex rounded-sm border border-border",r?"ring ring-primary-accent":"group-hover:ring group-hover:ring-tertiary"),style:{marginLeft:"".concat(f,"px")},children:[(0,a.jsx)("div",{className:(0,B.cn)("flex h-8 items-center justify-start rounded-l-sm border-r border-gray-400 bg-muted opacity-60",g?"":"border border-dashed"),style:{width:"".concat(e,"px")}}),(0,a.jsx)("div",{className:(0,B.cn)("flex h-8 items-center justify-start rounded-r-sm bg-muted",g?"":"border border-dashed"),style:{width:"".concat(g-e,"px")},children:(0,a.jsxs)("div",{className:"-ml-8 flex flex-row items-center justify-start gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"text-xxs text-primary",children:"First token"}),(0,a.jsx)(V.L,{type:t.type,isSmall:!0}),(0,a.jsx)("span",{className:"whitespace-nowrap text-sm font-medium text-primary",children:t.name}),c&&h?(0,a.jsx)(J.o,{count:h}):null,o&&(0,er.isPresent)(v)&&(0,a.jsx)("span",{className:(0,B.cn)("text-xs text-muted-foreground",p&&u&&j&&(0,G.$s)({max:p,value:j})),children:(0,U.O_)(v)}),i&&t.totalCost&&(0,a.jsx)("span",{className:(0,B.cn)("text-xs text-muted-foreground",m&&u&&(0,G.$s)({max:m,value:t.totalCost})),children:(0,W.hp)(t.totalCost.toNumber())}),d&&x&&x.length>0&&(0,a.jsx)("div",{className:"flex max-h-8 gap-1",children:(0,a.jsx)(F.P,{scores:x,maxVisible:3})})]})})]})})}return(0,a.jsx)("div",{className:"group my-0.5 flex w-full min-w-fit cursor-pointer flex-row items-center",onClick:s,onMouseEnter:l,"data-sentry-component":"TimelineBar","data-sentry-source-file":"TimelineBar.tsx",children:(0,a.jsx)("div",{className:"relative",style:{marginLeft:"".concat(f,"px")},children:(0,a.jsx)("div",{className:(0,B.cn)("flex h-8 items-center justify-start rounded-sm border border-border bg-muted",g?"":"border-dashed",r?"ring ring-primary-accent":"group-hover:ring group-hover:ring-tertiary"),style:{width:"".concat(g||10,"px")},children:(0,a.jsxs)("div",{className:(0,B.cn)("flex flex-row items-center justify-start gap-2 text-xs text-muted-foreground",b?"ml-6":"ml-1"),children:[(0,a.jsx)(V.L,{type:t.type,isSmall:!0,"data-sentry-element":"ItemBadge","data-sentry-source-file":"TimelineBar.tsx"}),(0,a.jsx)("span",{className:"whitespace-nowrap text-sm font-medium text-primary",children:t.name}),c&&h?(0,a.jsx)(J.o,{count:h}):null,o&&(0,er.isPresent)(v)&&(0,a.jsx)("span",{className:(0,B.cn)("text-xs text-muted-foreground",p&&u&&j&&(0,G.$s)({max:p,value:j})),children:(0,U.O_)(v)}),i&&t.totalCost&&(0,a.jsx)("span",{className:(0,B.cn)("text-xs text-muted-foreground",m&&u&&(0,G.$s)({max:m,value:t.totalCost})),children:(0,W.hp)(t.totalCost.toNumber())}),d&&x&&x.length>0&&(0,a.jsx)("div",{className:"flex max-h-8 gap-1",children:(0,a.jsx)(F.P,{scores:x,maxVisible:3})})]})})})})}function el(e){let{item:t,isSelected:n,onSelect:r,onHover:s,onToggleCollapse:l,hasChildren:o,isCollapsed:i,showDuration:d,showCostTokens:c,showScores:u,showComments:m,colorCodeMetrics:p,parentTotalCost:h,parentTotalDuration:x,commentCount:f,scores:g}=e,{node:y,depth:v,treeLines:j,isLastSibling:b,metrics:w}=t;return(0,a.jsxs)("div",{className:"group my-0.5 flex w-full min-w-fit cursor-pointer flex-row items-center","data-sentry-component":"TimelineRow","data-sentry-source-file":"TimelineRow.tsx",children:[v>0&&(0,a.jsx)("div",{className:"flex flex-shrink-0",children:Array.from({length:v-1},(e,t)=>(0,a.jsx)("div",{className:"relative",style:{width:"".concat(12,"px")},children:j[t]&&(0,a.jsx)("div",{className:"absolute bottom-0 left-1.5 top-0 w-px bg-border"})},t))}),v>0&&(0,a.jsxs)("div",{className:"relative flex-shrink-0",style:{width:"".concat(12,"px")},children:[(0,a.jsx)("div",{className:(0,B.cn)("absolute left-1.5 top-0 w-px bg-border",b?"h-3":"bottom-0")}),(0,a.jsx)("div",{className:"absolute left-1.5 top-3 h-px w-2 bg-border"})]}),o&&(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),l()},className:"absolute z-10 rounded hover:bg-muted",style:{left:"".concat(12*v+(w.startOffset>0?w.startOffset+4:4),"px"),top:"50%",transform:"translateY(-50%)"},children:(0,a.jsx)(z.A,{className:(0,B.cn)("h-4 w-4 transition-transform duration-200",!i&&"rotate-90")})}),(0,a.jsx)(es,{node:y,metrics:w,isSelected:n,onSelect:r,onHover:s,showDuration:d,showCostTokens:c,showScores:u,showComments:m,colorCodeMetrics:p,parentTotalCost:h,parentTotalDuration:x,commentCount:f,scores:g,"data-sentry-element":"TimelineBar","data-sentry-source-file":"TimelineRow.tsx"})]})}function eo(){let{roots:e,serverScores:t,comments:n}=(0,r.f)(),{collapsedNodes:o,toggleCollapsed:i,selectedNodeId:d,setSelectedNodeId:c}=p(),{showDuration:u,showCostTokens:m,showScores:h,showComments:x,colorCodeMetrics:f}=(0,s.v)(),{handleHover:g}=Q(),y=(0,l.useRef)(null),v=(0,l.useRef)(null),j=(0,l.useMemo)(()=>0===e.length?0:Math.max(...e.map(e=>{var t;return null!=(t=e.latency)?t:0})),[e]),b=(0,l.useMemo)(()=>0===e.length?new Date:new Date(Math.min(...e.map(e=>e.startTime.getTime()))),[e]),w=(0,l.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,n=e/(t/100);return et.find(e=>e>=n)||et[et.length-1]})(j,900),[j]),N=(0,l.useMemo)(()=>(function(e,t,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:900;
1if(0===e.length)return[];let s=[],l=[...e].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime()),o=[];for(let e=l.length-1;e>=0;e--)o.push({node:l[e],depth:0,treeLines:[],isLastSibling:e===l.length-1});for(;o.length>0;){let e=o.pop(),l=e.node,i=l.endTime?(l.endTime.getTime()-l.startTime.getTime())/1e3:void 0,d=en(l.startTime,n,a,r),c={startOffset:d,itemWidth:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:900;return e/t*n}(null!=i?i:0,a,r),firstTokenTimeOffset:"completionStartTime"in l&&l.completionStartTime instanceof Date?en(l.completionStartTime,n,a,r):void 0,latency:i};if(s.push({node:l,depth:e.depth,treeLines:e.treeLines,isLastSibling:e.isLastSibling,metrics:c}),l.children.length>0&&!t.has(l.id)){let t=[...l.children].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime());for(let n=t.length-1;n>=0;n--){let a=t[n],r=n===t.length-1;o.push({node:a,depth:e.depth+1,treeLines:[...e.treeLines,!r],isLastSibling:r})}}}return s})(e,o,b,j,900),[e,o,b,j]),C=(0,l.useMemo)(()=>0===N.length?900:Math.max(900,Math.max(...N.map(e=>e.metrics.startOffset+e.metrics.itemWidth))+50),[N]),T=(0,L.Te)({count:N.length,getScrollElement:()=>v.current,estimateSize:()=>42,overscan:500}),I=(0,l.useRef)(d),S=(0,l.useRef)(!1);(0,l.useLayoutEffect)(()=>{if(d&&!S.current&&d===I.current){let e=N.findIndex(e=>e.node.id===d);-1!==e&&(T.scrollToIndex(e,{align:"center",behavior:"auto"}),S.current=!0)}},[d,N,T]);let k=(0,l.useMemo)(()=>e.reduce((e,t)=>t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),[e]);return(0,a.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden","data-sentry-component":"TraceTimeline","data-sentry-source-file":"index.tsx",children:[(0,a.jsx)("div",{ref:y,className:"overflow-x-auto overflow-y-hidden",onScroll:e=>{v.current&&(v.current.scrollLeft=e.currentTarget.scrollLeft)},children:(0,a.jsx)("div",{style:{width:"".concat(C,"px")},children:(0,a.jsx)(ea,{traceDuration:j,scaleWidth:900,stepSize:w,"data-sentry-element":"TimelineScale","data-sentry-source-file":"index.tsx"})})}),(0,a.jsx)("div",{ref:v,className:"flex-1 overflow-auto",onScroll:e=>{y.current&&(y.current.scrollLeft=e.currentTarget.scrollLeft)},children:(0,a.jsx)("div",{style:{height:"".concat(T.getTotalSize(),"px"),width:"".concat(C,"px"),position:"relative"},children:T.getVirtualItems().map(e=>{var r;let s=N[e.index];if(!s)return null;let l=s.node.id,p=d===l,y=s.node.children.length>0,v=o.has(l),b=t.filter(e=>"TRACE"===s.node.type?e.traceId===s.node.id:e.observationId===s.node.id),w=null!=(r=n.get(l))?r:0;return(0,a.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"".concat(e.size,"px"),transform:"translateY(".concat(e.start,"px)")},children:(0,a.jsx)(el,{item:s,isSelected:p,onSelect:()=>c(l),onHover:()=>g(s.node),onToggleCollapse:()=>i(l),hasChildren:y,isCollapsed:v,showDuration:u,showCostTokens:m,showScores:h,showComments:x,colorCodeMetrics:f,parentTotalCost:k,parentTotalDuration:j,commentCount:w,scores:b})},l)})})})]})}function ei(){let{searchQuery:e}=g(),[t]=(0,o.useQueryParam)("view",o.StringParam),n=e.trim().length>0,r="timeline"===t;return(0,l.useMemo)(()=>n?(0,a.jsx)(ee,{}):r?(0,a.jsx)(eo,{}):(0,a.jsx)(q,{}),[n,r])}var ed=n(41547),ec=n(90859),eu=n(1597),em=n(53524),ep=n(97898),eh=n(70198),ex=n(30180);function ef(e){let{projectId:t,traceId:n,observationId:a}=e;return v.FH.media.getByTraceOrObservationId.useQuery({projectId:t,traceId:n,observationId:a},{refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,staleTime:3e6})}var eg=n(81101),ey=n(75708);function ev(e){return(0,l.useMemo)(()=>{if(!e)return;let t=new Map,n=new Map,a=new Map;for(let r of e)r.dataField&&r.path&&r.path.length>0&&r.rangeStart&&r.rangeStart.length>0&&r.rangeEnd&&r.rangeEnd.length>0&&r.path.forEach((e,s)=>{let l,o={start:r.rangeStart[s],end:r.rangeEnd[s],preview:r.content.length>150?r.content.slice(0,150)+"...":r.content};if("input"===r.dataField)l=t;else if("output"===r.dataField)l=n;else{if("metadata"!==r.dataField)return;l=a}let i=l.get(e)||[];l.set(e,[...i,o])});return{input:t.size>0?t:void 0,output:n.size>0?n:void 0,metadata:a.size>0?a:void 0}},[e])}var ej=n(11058),eb=n(70242),ew=n(92297),eN=n(95601),eC=n(6786),eT=n(6670),eI=n(68389),eS=n.n(eI),ek=n(72459),eE=n(67716);function eO(e){let{sessionId:t,projectId:n}=e;return t?(0,a.jsx)(eS(),{href:"/project/".concat(n,"/sessions/").concat(encodeURIComponent(t)),className:"inline-flex","data-sentry-element":"Link","data-sentry-component":"SessionBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:(0,a.jsxs)(eE.E,{"data-sentry-element":"Badge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:[(0,a.jsxs)("span",{className:"truncate",children:["Session: ",t]}),(0,a.jsx)(ek.A,{className:"ml-1 h-3 w-3","data-sentry-element":"ExternalLinkIcon","data-sentry-source-file":"TraceMetadataBadges.tsx"})]})}):null}function eA(e){let{userId:t,projectId:n}=e;return t?(0,a.jsx)(eS(),{href:"/project/".concat(n,"/users/").concat(encodeURIComponent(t)),className:"inline-flex","data-sentry-element":"Link","data-sentry-component":"UserIdBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:(0,a.jsxs)(eE.E,{"data-sentry-element":"Badge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:[(0,a.jsxs)("span",{className:"truncate",children:["User ID: ",t]}),(0,a.jsx)(ek.A,{className:"ml-1 h-3 w-3","data-sentry-element":"ExternalLinkIcon","data-sentry-source-file":"TraceMetadataBadges.tsx"})]})}):null}function eM(e){let{targetTraceId:t,projectId:n}=e;return t?(0,a.jsx)(eS(),{href:"/project/".concat(n,"/traces/").concat(encodeURIComponent(t)),className:"inline-flex","data-sentry-element":"Link","data-sentry-component":"TargetTraceBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:(0,a.jsxs)(eE.E,{"data-sentry-element":"Badge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:[(0,a.jsxs)("span",{className:"truncate",children:["Target Trace: ",t]}),(0,a.jsx)(ek.A,{className:"ml-1 h-3 w-3","data-sentry-element":"ExternalLinkIcon","data-sentry-source-file":"TraceMetadataBadges.tsx"})]})}):null}function eD(e){let{environment:t}=e;return t?(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"EnvironmentBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:["Env: ",t]}):null}function eP(e){let{release:t}=e;return t?(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"ReleaseBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:["Release: ",t]}):null}function eL(e){let{version:t}=e;return t?(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"VersionBadge","data-sentry-source-file":"TraceMetadataBadges.tsx",children:["Version: ",t]}):null}function eB(e){let{latencySeconds:t}=e;return null==t?null:(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"LatencyBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:["Latency: ",(0,U.O_)(t)]})}function eR(e){let{timeToFirstToken:t}=e;return null==t?null:(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"TimeToFirstTokenBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:["Time to first token: ",(0,U.O_)(t)]})}function eV(e){let{environment:t}=e;return t?(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"EnvironmentBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:["Env: ",t]}):null}function ez(e){let{version:t}=e;return t?(0,a.jsxs)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"VersionBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:["Version: ",t]}):null}function e_(e){let{level:t}=e;return t&&"DEFAULT"!==t?(0,a.jsx)(eE.E,{variant:"ERROR"===t?"destructive":"WARNING"===t?"warning":"tertiary","data-sentry-element":"Badge","data-sentry-component":"LevelBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:t}):null}function eF(e){let{statusMessage:t}=e;return t?(0,a.jsx)(eE.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-component":"StatusMessageBadge","data-sentry-source-file":"ObservationMetadataBadgesSimple.tsx",children:t}):null}var eH=n(16538),eJ=n(80263);function eU(e){let{totalCost:t,costDetails:n}=e;return null!=t&&0!==t&&n?(0,a.jsx)(eH.X,{details:n,isCost:!0,"data-sentry-element":"BreakdownTooltip","data-sentry-component":"CostBadge","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx",children:(0,a.jsxs)(eE.E,{variant:"tertiary",className:"flex items-center gap-1","data-sentry-element":"Badge","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx",children:[(0,a.jsx)("span",{children:(0,W.hp)(t)}),(0,a.jsx)(eJ.A,{className:"h-3 w-3","data-sentry-element":"InfoIcon","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx"})]})}):null}function eW(e){let{type:t,inputUsage:n,outputUsage:r,totalUsage:s,usageDetails:l}=e;if(!(0,er.isGenerationLike)(t)||!l)return null;let o=(0,W.nK)(n,r,s,!0),i=o.length>0;return(0,a.jsx)(eH.X,{details:l,isCost:!1,"data-sentry-element":"BreakdownTooltip","data-sentry-component":"UsageBadge","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx",children:(0,a.jsxs)(eE.E,{variant:"tertiary",className:"flex items-center gap-1 ".concat(i?"":"h-6 pl-2"),"data-sentry-element":"Badge","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx",children:[i&&(0,a.jsx)("span",{children:o}),(0,a.jsx)(eJ.A,{className:"h-3 w-3","data-sentry-element":"InfoIcon","data-sentry-source-file":"ObservationMetadataBadgesTooltip.tsx"})]})})}function eG(e){let t=null,n={},a=0,r=0,s=0,l={},o=!1;for(let p of e){var i,d,c,u,m;if(null!=p.totalCost&&(t=(null!=t?t:0)+Number(p.totalCost)),p.costDetails)for(let[e,t]of Object.entries(p.costDetails))n[e]=(null!=(i=n[e])?i:0)+t;if((0,er.isGenerationLike)(p.type)&&(o=!0,a+=null!=(d=p.totalUsage)?d:0,r+=null!=(c=p.inputUsage)?c:0,s+=null!=(u=p.outputUsage)?u:0,p.usageDetails))for(let[e,t]of Object.entries(p.usageDetails))l[e]=(null!=(m=l[e])?m:0)+t}return{totalCost:t,costDetails:Object.keys(n).length>0?n:void 0,totalUsage:a,inputUsage:r,outputUsage:s,usageDetails:Object.keys(l).length>0?l:void 0,hasGenerationLike:o}}var e$=n(94636);let eK=(0,l.memo)(function(e){var t;let{trace:n,observations:r,parsedMetadata:s,projectId:o,traceScores:i,commentCount:d,pendingSelection:c,onSelectionUsed:u,isCommentDrawerOpen:m,onCommentDrawerOpenChange:p}=e,h=(0,l.useMemo)(()=>eG(r),[r]),x=n.environment===er.LangfuseInternalTraceEnvironment.LLMJudge?(0,e$.W)(s):null;return(0,a.jsxs)("div",{className:"flex-shrink-0 space-y-2 border-b p-2 @container",children:[(0,a.jsxs)("div",{className:"grid w-full grid-cols-1 items-start gap-2 @2xl:gr
1id-cols-[auto,auto] @2xl:justify-between",children:[(0,a.jsxs)("div",{className:"flex w-full flex-row items-start gap-1",children:[(0,a.jsx)("div",{className:"mt-1.5",children:(0,a.jsx)(V.L,{type:"TRACE",isSmall:!0})}),(0,a.jsx)("span",{className:"mb-0 ml-1 line-clamp-2 min-w-0 break-all font-medium md:break-normal md:break-words",children:n.name||n.id}),(0,a.jsx)(eb.j,{idItems:[{id:n.id,name:"Trace ID"}]})]}),(0,a.jsxs)("div",{className:"flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end",children:[(0,a.jsx)(ew.C,{traceId:n.id,projectId:o,input:n.input,output:n.output,metadata:n.metadata,size:"sm"},n.id),(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(eN.k,{projectId:o,scoreTarget:{type:"trace",traceId:n.id},scores:i,scoreMetadata:{projectId:o,environment:n.environment},size:"sm"},"annotation-drawer-"+n.id),(0,a.jsx)(eC.E,{projectId:o,objectId:n.id,objectType:er.AnnotationQueueObjectType.TRACE,size:"sm"})]}),(0,a.jsx)(eT.X,{projectId:o,objectId:n.id,objectType:"TRACE",count:d,size:"sm",pendingSelection:c,onSelectionUsed:u,isOpen:m,onOpenChange:p})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1",children:(0,a.jsx)(ej.t,{date:n.timestamp,accuracy:"millisecond",className:"text-sm"})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,a.jsx)(eB,{latencySeconds:null!=(t=n.latency)?t:null}),(0,a.jsx)(eO,{sessionId:n.sessionId,projectId:o}),(0,a.jsx)(eA,{userId:n.userId,projectId:o}),(0,a.jsx)(eM,{targetTraceId:x,projectId:o}),(0,a.jsx)(eD,{environment:n.environment}),(0,a.jsx)(eP,{release:n.release}),(0,a.jsx)(eL,{version:n.version}),(0,a.jsx)(eU,{totalCost:h.totalCost,costDetails:h.costDetails}),h.hasGenerationLike&&h.usageDetails&&(0,a.jsx)(eW,{type:"GENERATION",inputUsage:h.inputUsage,outputUsage:h.outputUsage,totalUsage:h.totalUsage,usageDetails:h.usageDetails})]})]})]})});var eQ=n(26077),eq=n(79077),eX=n(14355),eZ=n(69115);function eY(e){var t,n,o;let{trace:i,observations:d,scores:c,corrections:u,projectId:m}=e,{selectedTab:h,setSelectedTab:x}=p(),[f,g]=(0,l.useState)(!0),[j,b]=(0,l.useState)(!1),[w,N]=(0,l.useState)(null),[C,T]=(0,l.useState)(!1),I=(0,l.useCallback)(e=>{N(e),T(!0)},[]),S=(0,l.useCallback)(()=>{N(null)},[]),{jsonViewPreference:k,setJsonViewPreference:E,jsonBetaEnabled:O,setJsonBetaEnabled:A}=(0,s.v)(),M="pretty"===k?"pretty":"json",D=(0,l.useCallback)(e=>{"pretty"===e?E("pretty"):E(O?"json-beta":"json")},[O,E]),P=(0,l.useCallback)(e=>{A(e),E(e?"json-beta":"json")},[A,E]),{comments:L}=(0,r.f)(),{formattedExpansion:B,setFormattedFieldExpansion:R,jsonExpansion:V,setJsonFieldExpansion:z,advancedJsonExpansion:_,setAdvancedJsonExpansion:F}=(0,y.vG)(),H=ef({projectId:m,traceId:i.id}),{parsedInput:J,parsedOutput:U,parsedMetadata:W,isParsing:G}
1=(0,eg.y)({traceId:i.id,input:i.input,output:i.output,metadata:i.metadata}),$=ev(v.FH.comments.getByObjectId.useQuery({projectId:m,objectId:i.id,objectType:"TRACE"},{refetchOnMount:!1}).data),K=(0,l.useMemo)(()=>c.filter(e=>!e.observationId),[c]),Q=(0,l.useMemo)(()=>u.filter(e=>!e.observationId),[u]),q=(0,eZ.N)(Q),X=d.length>0,Z=d.length>=eq.f.logView.virtualizationThreshold,Y=(0,ey.r)(m);return(0,a.jsxs)("div",{className:"flex h-full flex-col overflow-hidden","data-sentry-component":"TraceDetailView","data-sentry-source-file":"TraceDetailView.tsx",children:[(0,a.jsx)(eK,{trace:i,observations:d,parsedMetadata:W,projectId:m,traceScores:K,commentCount:L.get(i.id),pendingSelection:w,onSelectionUsed:S,isCommentDrawerOpen:C,onCommentDrawerOpenChange:T,"data-sentry-element":"TraceDetailViewHeader","data-sentry-source-file":"TraceDetailView.tsx"}),(0,a.jsxs)(ed.U0,{value:h,className:"flex min-h-0 flex-1 flex-col overflow-hidden",onValueChange:e=>{x(e)},"data-sentry-element":"TabsBar","data-sentry-source-file":"TraceDetailView.tsx",children:[(0,a.jsx)(em.Bc,{"data-sentry-element":"TooltipProvider","data-sentry-source-file":"TraceDetailView.tsx",children:(0,a.jsxs)(ed.Wp,{"data-sentry-element":"TabsBarList","data-sentry-source-file":"TraceDetailView.tsx",children:[(0,a.jsx)(ed.Iw,{value:"preview","data-sentry-element":"TabsBarTrigger","data-sentry-source-file":"TraceDetailView.tsx",children:"Preview"}),X&&(0,a.jsx)(ed.Iw,{value:"log",children:(0,a.jsxs)(em.m_,{children:[(0,a.jsx)(em.k$,{asChild:!0,children:(0,a.jsx)("span",{children:"Log View"})}),(0,a.jsx)(em.ZI,{className:"text-xs",children:Z?"Shows all ".concat(d.length," observations with virtualization enabled."):"Shows all observations concatenated. Great for quickly scanning through them."})]})}),Y&&(0,a.jsx)(ed.Iw,{value:"scores",children:"Scores"}),("log"===h||"preview"===h&&f)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec.tU,{className:"ml-auto h-fit px-2 py-0.5",value:"log"===h&&Z?"pretty":M,onValueChange:e=>{"log"===h&&Z&&"json"===e||D(e)},children:(0,a.jsxs)(ec.j7,{className:"h-fit py-0.5",children:[(0,a.jsx)(ec.Xi,{value:"pretty",className:"h-fit px-1 text-xs",children:"Formatted"}),"log"===h&&Z?(0,a.jsxs)(ep.jc,{openDelay:200,children:[(0,a.jsx)(ep.d0,{asChild:!0,children:(0,a.jsx)(ec.Xi,{value:"json",className:"h-fit px-1 text-xs",disabled:!0,children:"JSON"})}),(0,a.jsxs)(ep.Et,{align:"end",className:"w-64 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"JSON view unavailable"}),(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Disabled for traces with"," ",eq.f.logView.virtualizationThreshold,"+ observations to maintain performance."]})]})]}):(0,a.jsx)(ec.Xi,{value:"json",className:"h-fit px-1 text-xs",children:"JSON"})]})}),"json"===M&&!("log"===h&&Z)&&(0,a.jsxs)("div",{className:"mr-1 flex items-center gap-1.5",children:[(0,a.jsx)(eu.d,{size:"sm",checked:O,onCheckedChange:P}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Beta"})]})]})]})}),(0,a.jsx)(ed.pB,{value:"preview",className:"mt-0 flex max-h-full min-h-0 w-full flex-1","data-sentry-element":"TabsBarContent","data-sentry-source-file":"TraceDetailView.tsx",children:(0,a.jsxs)("div",{className:"flex min-h-0 w-full flex-1 flex-col ".concat("json-beta"===k&&j?"overflow-hidden":"overflow-auto pb-4"),children:[i.tags.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"px-2 pt-2 text-sm font-medium ".concat("pretty"!==k?"flex-shrink-0":""),children:"Tags"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-x-1 gap-y-1 px-2 pb-2 ".concat("pretty"!==k?"flex-shrink-0":""),children:(0,a.jsx)(ex.A,{selectedTags:i.tags,isLoading:!1})})]}),(0,a.jsx)(eh.H,{input:null!=(t=i.input)?t:void 0,output:null!=(n=i.output)?n:void 0,metadata:null!=(o=i.metadata)?o:void 0,outputCorrection:q,parsedInput:J,parsedOutput:U,parsedMetadata:W,isParsing:G,media:H.data,currentView:k,setIsPrettyViewAvailable:g,inputExpansionState:B.input,outputExpansionState:B.output,metadataExpansionState:B.metadata,onInputExpansionChange:e=>R("input",e),onOutputExpansionChange:e=>R("output",e),onMetadataExpansionChange:e=>R("metadata",e),advancedJsonExpansionState:_,onAdvancedJsonExpansionChange:F,jsonInputExpanded:V.input,jsonOutputExpanded:V.output,jsonMetadataExpanded:V.metadata,onJsonInputExpandedChange:e=>z("input",e),onJsonOutputExpandedChange:e=>z("output",e),onJsonMetadataExpandedChange:e=>z("metadata",e),enableInlineComments:!0,onAddInlineComment:I,commentedPathsByField:$,showMetadata:!0,onVirtualizationChange:b,projectId:m,traceId:i.id,environment:i.environment,"data-sentry-element":"IOPreview","data-sentry-source-file":"TraceDetailVie
1w.tsx"},i.id+"-io")]})}),(0,a.jsx)(ed.pB,{value:"log",className:"mt-0 flex max-h-full min-h-0 w-full flex-1","data-sentry-element":"TabsBarContent","data-sentry-source-file":"TraceDetailView.tsx",children:(0,a.jsx)(eQ.T,{traceId:i.id,projectId:m,currentView:Z?"pretty":k,"data-sentry-element":"TraceLogView","data-sentry-source-file":"TraceDetailView.tsx"})}),Y&&(0,a.jsx)(ed.pB,{value:"scores",className:"mt-0 flex max-h-full min-h-0 w-full flex-1 overflow-hidden",children:(0,a.jsx)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-hidden pr-3",children:(0,a.jsx)(eX.A,{projectId:m,omittedFilter:["Trace ID"],traceId:i.id,hiddenColumns:["traceName","jobConfigurationId","userId"],localStorageSuffix:"TracePreview",disableUrlPersistence:!0})})})]})]})}var e0=n(84662),e1=n(90410),e5=n(90119),e2=n(60222),e3=n(34242);function e4(e){let{model:t,internalModelId:n,projectId:r,usageDetails:s}=e;return t?n?(0,a.jsx)(eE.E,{children:(0,a.jsxs)(eS(),{href:"/project/".concat(r,"/settings/models/").concat(n),className:"flex items-center",title:"View model details",children:[(0,a.jsx)("span",{className:"truncate",children:t}),(0,a.jsx)(ek.A,{className:"ml-1 h-3 w-3"})]})}):(0,a.jsx)(e3.b,{action:"create",projectId:r,prefilledModelData:{modelName:t,prices:s&&Object.keys(s).length>0?Object.keys(s).filter(e=>"total"!==e).reduce((e,t)=>(e[t]=1e-6,e),{}):void 0},className:"cursor-pointer","data-sentry-element":"UpsertModelFormDialog","data-sentry-component":"ModelBadge","data-sentry-source-file":"ObservationMetadataBadgeModel.tsx",children:(0,a.jsxs)(eE.E,{variant:"tertiary",className:"flex items-center gap-1","data-sentry-element":"Badge","data-sentry-source-file":"ObservationMetadataBadgeModel.tsx",children:[(0,a.jsx)("span",{children:t}),(0,a.jsx)(e2.A,{className:"h-3 w-3","data-sentry-element":"PlusCircle","data-sentry-source-file":"ObservationMetadataBadgeModel.tsx"})]})}):null}function e6(e){let{modelParameters:t}=e;if(!t||"object"!=typeof t||Array.isArray(t))return null;let n=Object.entries(t).filter(e=>{let[t,n]=e;return null!==n});return 0===n.length?null:(0,a.jsx)(a.Fragment,{children:n.map(e=>{let[t,n]=e,r="[object Object]"===Object.prototype.toString.call(n)?JSON.stringify(n):null==n?void 0:n.toString();return(0,a.jsx)(eE.E,{variant:"tertiary",className:"max-w-md",children:(0,a.jsxs)("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",title:r,children:[t,": ",r]})},t)})})}let e7=(0,l.memo)(function(e){var t,n,r,s;let{observation:l,observationWithIO:o,projectId:i,traceId:d,latencySeconds:c,observationScores:u,commentCount:m,pendingSelection:p,onSelectionUsed:h,isCommentDrawerOpen:x,onCommentDrawerOpenChange:f,subtreeMetrics:g,treeNodeTotalCost:y}=e,v=l.totalCost,j=l.totalUsage,b=l.inputUsage,w=l.outputUsage;return(0,a.jsxs)("div",{className:"flex-shrink-0 space-y-2 border-b p-2 @container",children:[(0,a.jsxs)("div",{className:"grid w-full grid-cols-1 items-start gap-2 @2xl:grid-cols-[auto,auto] @2xl:justify-between",children:[(0,a.jsxs)("div",{className:"flex w-full flex-row items-start gap-1",children:[(0,a.jsx)("div",{className:"mt-1.5",children:(0,a.jsx)(V.L,{type:l.type,isSmall:!0})}),(0,a.jsx)("span",{className:"mb-0 ml-1 line-clamp-2 min-w-0 break-all font-medium md:break-normal md:break-words",children:l.name||l.id}),(0,a.jsx)(eb.j,{idItems:[{id:d,name:"Trace ID"},{id:l.id,name:"Observation ID"}]})]}),(0,a.jsxs)("div",{className:"flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end",children:[o&&(0,a.jsx)(ew.C,{traceId:d,observationId:l.id,projectId:i,input:o.input,output:o.output,metadata:o.metadata,size:"sm"},l.id),(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(eN.k,{projectId:i,scoreTarget:{type:"trace",traceId:d,observationId:l.id},scores:u,scoreMetadata:{projectId:i,environment:l.environment},size:"sm"},"annotation-drawer-"+l.id),(0,a.jsx)(eC.E,{projectId:i,objectId:l.id,objectType:er.AnnotationQueueObjectType.OBSERVATION,size:"sm"})]}),o&&(0,er.isGenerationLike)(o.type)&&(0,a.jsx)(e1.J,{source:"generation",generation:o,analyticsEventName:"trace_detail:test_in_playground_button_click",size:"sm"}),(0,a.jsx)(eT.X,{projectId:i,objectId:l.id,objectType:"OBSERVATION",count:m,size:"sm",pendingSelection:p,onSelectionUsed:h,isOpen:x,onOpenChange:f})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1",children:(0,a.jsx)(ej.t,{date:l.startTime,accuracy:"millisecond",className:"text-sm"})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,a.jsx)(eB,{latencySeconds:c}),(0,a.jsx)(eR,{timeToFirstToken:l.timeToFirstToken}),(0,a.jsx)(eO,{sessionId:null!=(t=l.sessionId)?t:null,projectId:i}),(0,a.jsx)(eA,{userId:null!=(n=l.userId)?n:null,projectId:i}),(0,a.jsx)(eV,{environment:l.environment}),(0,a.jsx)(eU,{totalCost:g?null!=(r=null==y?void 0:y.toNumber())?r:g.totalCost:v,costDetails:null!=(s=null==g?void 0:g.costDetails)?s:l.costDetails}),g?g.hasGenerationLike&&g.usageDetails&&(0,a.jsx)(eW,{type:"GENERATION",inputUsage:g.inputUsage,outputUsage:g.outputUsage,totalUsage:g.totalUsage,usageDetails:g.usageDetails}):(0,a.jsx)(eW,{type:l.type,inputUsage:b,outputUsage:w,totalUsage:j,usageDetails:l.usageDetails}),(0,a.jsx)(ez,{version:l.version}),(0,a.jsx)(e4,{model:l.model,internalModelId:l.internalModelId,projectId:i,usageDetails:l.usageDetails}),(0,a.jsx)(e6,{modelParameters:l.modelParameters}),(0,a.jsx)(e_,{level:l.level}),(0,a.jsx)(eF,{statusMessage:l.statusMessage}),l.promptId&&(0,a.jsx)(e5.E,{promptId:l.promptId,projectId:i})]})]})]})});function e9(e){var t,n,o,i;let{observation:d,projectId:c,traceId:u}=e,{selectedTab:m,setSelectedTab:h}=p(),{isBetaEnabled:x}=(0,j.I)(),{observations:f,roots:g,nodeMap:b}=(0,r.f)(),w=x&&f.length>0,N=f.length>=eq.f.logView.virtualizationThreshold,C=b.get(d.id),T=g.some(e=>e.id===d.id),I=(0,l.useMemo)(()=>
1{if(!T||!C)return null;let e=new Set(function(e){let t=[],n=[...e.children];for(;n.length>0;){let e=n.pop();t.push(e.id),n.push(...e.children)}return t}(C));return eG([d,...f.filter(t=>e.has(t.id))])},[T,C,f,d]),S=(0,l.useMemo)(()=>"scores"===m?"scores":"log"===m&&w?"log":"preview",[m,w]),{jsonViewPreference:k,setJsonViewPreference:E,jsonBetaEnabled:O,setJsonBetaEnabled:A}=(0,s.v)(),M="pretty"===k?"pretty":"json",D=(0,l.useCallback)(e=>{"pretty"===e?E("pretty"):E(O?"json-beta":"json")},[O,E]),P=(0,l.useCallback)(e=>{A(e),E(e?"json-beta":"json")},[A,E]),[L,B]=(0,l.useState)(!0),[R,V]=(0,l.useState)(!1),[z,_]=(0,l.useState)(null),[F,H]=(0,l.useState)(!1),J=(0,l.useCallback)(e=>{_(e),H(!0)},[]),U=(0,l.useCallback)(()=>{_(null)},[]),{comments:W,serverScores:G,corrections:$}=(0,r.f)(),{formattedExpansion:K,setFormattedFieldExpansion:Q,jsonExpansion:q,setJsonFieldExpansion:X,advancedJsonExpansion:Z,setAdvancedJsonExpansion:Y}=(0,y.vG)(),ee=(0,l.useMemo)(()=>G.filter(e=>e.observationId===d.id),[G,d.id]),et=(0,l.useMemo)(()=>$.filter(e=>e.observationId===d.id),[$,d.id]),en=(0,eZ.N)(et),{observation:ea,parsedInput:er,parsedOutput:es,parsedMetadata:el,isLoadingObservation:eo,isWaitingForParsing:ei}=(0,e0.V)({observationId:d.id,traceId:u,projectId:c,startTime:d.startTime,baseObservation:d}),ex=ea&&"type"in ea?ea:void 0,eg=ef({projectId:c,traceId:u,observationId:d.id}),ey=ev(v.FH.comments.getByObjectId.useQuery({projectId:c,objectId:d.id,objectType:"OBSERVATION"},{refetchOnMount:!1}).data),ej=(0,l.useMemo)(()=>d.latency?d.latency:d.startTime&&d.endTime?(d.endTime.getTime()-d.startTime.getTime())/1e3:null,[d.latency,d.startTime,d.endTime]);return(0,a.jsxs)("div",{className:"flex h-full flex-col overflow-hidden","data-sentry-component":"ObservationDetailView","data-sentry-source-file":"ObservationDetailView.tsx",children:[(0,a.jsx)(e7,{observation:d,observationWithIO:ex,projectId:c,traceId:u,latencySeconds:ej,observationScores:ee,commentCount:W.get(d.id),pendingSelection:z,onSelectionUsed:U,isCommentDrawerOpen:F,onCommentDrawerOpenChange:H,subtreeMetrics:I,treeNodeTotalCost:null==C?void 0:C.totalCost,"data-sentry-element":"ObservationDetailViewHeader","data-sentry-source-file":"ObservationDetailView.tsx"}),(0,a.jsxs)(ed.U0,{value:S,className:"flex min-h-0 flex-1 flex-col overflow-hidden",onValueChange:e=>{h(e)},"data-sentry-element":"TabsBar","data-sentry-source-file":"ObservationDetailView.tsx",children:[(0,a.jsx)(em.Bc,{"data-sentry-element":"TooltipProvider","data-sentry-source-file":"ObservationDetailView.tsx",children:(0,a.jsxs)(ed.Wp,{"data-sentry-element":"TabsBarList","data-sentry-source-file":"ObservationDetailView.tsx",children:[(0,a.jsx)(ed.Iw,{value:"preview","data-sentry-element":"TabsBarTrigger","data-sentry-source-file":"ObservationDetailView.tsx",children:"Preview"}),(0,a.jsx)(ed.Iw,{value:"scores","data-sentry-element":"TabsBarTrigger","data-sentry-source-file":"ObservationDetailView.tsx",children:"Scores"}),w&&(0,a.jsx)(ed.Iw,{value:"log",children:(0,a.jsxs)(em.m_,{children:[(0,a.jsx)(em.k$,{asChild:!0,children:(0,a.jsx)("span",{children:"Log View"})}),(0,a.jsx)(em.ZI,{className:"text-xs",children:N?"Shows all ".concat(f.length," observations with virtualization enabled."):"Shows all observations concatenated. Great for quickly scanning through them."})]})}),("log"===S||"preview"===S&&L)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec.tU,{className:"ml-auto h-fit px-2 py-0.5",value:"log"===S&&N?"pretty":M,onValueChange:e=>{"log"===S&&N&&"json"===e||D(e)},children:(0,a.jsxs)(ec.j7,{className:"h-fit py-0.5",children:[(0,a.jsx)(ec.Xi,{value:"pretty",className:"h-fit px-1 text-xs",children:"Formatted"}),"log"===S&&N?(0,a.jsxs)(ep.jc,{openDelay:200,children:[(0,a.jsx)(ep.d0,{asChild:!0,children:(0,a.jsx)("span",{children:(0,a.jsx)(ec.Xi,{value:"json",className:"h-fit px-1 text-xs",disabled:!0,children:"JSON"})})}),(0,a.jsxs)(ep.Et,{align:"end",className:"w-64 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"JSON view unavailable"}),(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Disabled for traces with"," ",eq.f.logView.virtualizationThreshold,"+ observations to maintain performance."]})]})]}):(0,a.jsx)(ec.Xi,{value:"json",className:"h-fit px-1 text-xs",children:"JSON"})]})}),"json"===M&&!("log"===S&&N)&&(0,a.jsxs)("div",{className:"mr-1 flex items-center gap-1.5",children:[(0,a.jsx)(eu.d,{size:"sm",checked:O,onCheckedChange:P}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Beta"})]})]})]})}),(0,a.jsx)(ed.pB,{value:"preview",className:"mt-0 flex max-h-full min-h-0 w-full flex-1","data-sentry-element":"TabsBarContent","data-sentry-source-file":"ObservationDetailVie
1w.tsx",children:(0,a.jsxs)("div",{className:"flex min-h-0 w-full flex-1 flex-col ".concat("json-beta"===k&&R?"overflow-hidden":"overflow-auto pb-4"),children:[(0,a.jsx)(eh.H,{observationName:null!=(t=d.name)?t:void 0,input:null!=(n=null==ex?void 0:ex.input)?n:void 0,output:null!=(o=null==ex?void 0:ex.output)?o:void 0,outputCorrection:en,metadata:null!=(i=null==ex?void 0:ex.metadata)?i:void 0,parsedInput:er,parsedOutput:es,parsedMetadata:el,isLoading:eo,isParsing:ei,media:eg.data,currentView:k,setIsPrettyViewAvailable:B,inputExpansionState:K.input,outputExpansionState:K.output,metadataExpansionState:K.metadata,onInputExpansionChange:e=>Q("input",e),onOutputExpansionChange:e=>Q("output",e),onMetadataExpansionChange:e=>Q("metadata",e),advancedJsonExpansionState:Z,onAdvancedJsonExpansionChange:Y,jsonInputExpanded:q.input,jsonOutputExpanded:q.output,jsonMetadataExpanded:q.metadata,onJsonInputExpandedChange:e=>X("input",e),onJsonOutputExpandedChange:e=>X("output",e),onJsonMetadataExpandedChange:e=>X("metadata",e),enableInlineComments:!0,onAddInlineComment:J,commentedPathsByField:ey,showMetadata:!0,observationId:d.id,onVirtualizationChange:V,projectId:c,traceId:u,environment:d.environment,"data-sentry-element":"IOPreview","data-sentry-source-file":"ObservationDetailView.tsx"},d.id),"json-beta"!==k&&(0,a.jsx)("div",{className:"h-4 w-full flex-shrink-0"})]})}),(0,a.jsx)(ed.pB,{value:"scores",className:"mb-2 mr-4 mt-0 flex h-full min-h-0 flex-1 overflow-hidden","data-sentry-element":"TabsBarContent","data-sentry-source-file":"ObservationDetailView.tsx",children:(0,a.jsx)("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden",children:(0,a.jsx)(eX.A,{projectId:c,traceId:u,observationId:d.id,hiddenColumns:["traceId","observationId","traceName","jobConfigurationId","userId"],localStorageSuffix:"ObservationPreview",disableUrlPersistence:!0,"data-sentry-element":"ScoresTable","data-sentry-source-file":"ObservationDetailView.tsx"})})}),w&&(0,a.jsx)(ed.pB,{value:"log",className:"mt-0 flex max-h-full min-h-0 w-full flex-1",children:(0,a.jsx)(eQ.T,{traceId:u,projectId:c,currentView:N?"pretty":k})})]})]})}function e8(){let{selectedNodeId:e,setSelectedNodeId:t}=p(),{trace:n,roots:s,nodeMap:o,observations:i,serverScores:d,corrections:c}=(0,r.f)();(0,l.useEffect)(()=>{!e&&s.length>0&&"TRACE"!==s[0].type&&t(s[0].id)},[e,s,t]);let u=(0,l.useMemo)(()=>{let t=e?o.get(e):null;if(null!==e&&(null==t?void 0:t.type)!=="TRACE"&&t){let e=i.find(e=>e.id===t.id);return e?(0,a.jsx)(e9,{observation:e,projectId:n.projectId,traceId:n.id}):(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Observation not found"})})}return(0,a.jsx)(eY,{trace:n,observations:i,scores:d,corrections:c,projectId:n.projectId})},[e,o,n,i,d,c]);return(0,a.jsx)("div",{className:"h-full w-full overflow-y-auto bg-background","data-sentry-component":"TracePanelDetail","data-sentry-source-file":"TracePanelDetail.tsx",children:u})}var te=n(16758),tt=n(95266),tn=n(47616),ta=n(98069),tr=n(91163),ts=n(59649),tl=n(88377),to=n(92125);function ti(e){let{isGraphViewAvailable:t}=e,n=(0,to.B)(),{showGraph:r,setShowGraph:l,showComments:o,setShowComments:i,showScores:d,setShowScores:c,showDuration:u,setShowDuration:m,showCostTokens:p,setShowCostTokens:h,colorCodeMetrics:x,setColorCodeMetrics:f,minObservationLevel:g,setMinObservationLevel:y}=(0,s.v)(),v=u||p;return(0,a.jsxs)(tl.rI,{"data-sentry-element":"DropdownMenu","data-sentry-component":"TraceSettingsDropdown","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:[(0,a.jsx)(tl.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsx)(C.$,{variant:"ghost",size:"icon",title:"View Options",className:"h-7 w-7","data-sentry-element":"Button","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsx)(ts.A,{className:"h-3.5 w-3.5","data-sentry-element":"Settings2","data-sentry-source-file":"TraceSettingsDropdown.tsx"})})}),(0,a.jsxs)(tl.SQ,{align:"end",className:"w-64 space-x-0 space-y-0 p-0 px-0","data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:[(0,a.jsx)(tl.lp,{"data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:"View Options"}),(0,a.jsx)(tl.mB,{"data-sentry-element":"DropdownMenuSeparator","data-sentry-source-file":"TraceSettingsDropdown.tsx"}),(0,a.jsxs)("div",{className:"space-y-0 p-0 py-1",children:[t&&(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),className:"space-y-0 px-2 py-1",children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("span",{className:"mr-2",children:"Show Graph"}),(0,a.jsx)(eu.d,{size:"sm",checked:r,onCheckedChange:l})]})}),(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),className:"px-2 py-1","data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("span",{className:"mr-2",children:"Show Comments"}),(0,a.jsx)(eu.d,{size:"sm",checked:o,onCheckedChange:i,"data-sentry-element":"Switch","data-sentry-source-file":"TraceSettingsDropdown.tsx"})]})}),(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),className:"px-2 py-1","data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("span",{className:"mr-2",children:"Show Scores"}),(0,a.jsx)(eu.d,{size:"sm",checked:d,onCheckedChange:e=>{n("trace_detail:observation_tree_toggle_scores",{show:e}),c(e)},"data-sentry-element":"Switch","data-sentry-source-file":"TraceSettingsDropdown.tsx"})]})}),(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),className:"px-2 py-1","data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("span",{className:"mr-2",children:"Show Duration"}),(0,a.jsx)(eu.d,{size:"sm",checked:u,onCheckedChange:m,"data-sentry-element":"Switch","data-sentry-source-file":"TraceSettingsDropdown.tsx"})]})}),(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),className:"px-2 py-1","data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("span",{className:"mr-2",children:"Show Cost/Tokens"}),(0,a.jsx)(eu.d,{size:"sm",checked:p,onCheckedChange:h,"data-sentry-element":"Switch","data-sentry-source-file":"TraceSettingsDropdown.tsx"})]})}),(0,a.jsx)(tl._2,{asChild:!0,onSelect:e=>e.preventDefault(),disabled:!v,className:(0,B.cn)(["px-2 py-1",v?"":"cursor-not-allowed"]),"data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("div",{className:(0,B.cn)("flex w-full items-center justify-between",!v&&"curs
1or-not-allowed"),children:[(0,a.jsx)("span",{className:(0,B.cn)("mr-2",!v&&"cursor-not-allowed"),children:"Show Color Code Metrics"}),(0,a.jsx)(eu.d,{size:"sm",checked:x,onCheckedChange:f,disabled:!v,className:(0,B.cn)(!v&&"cursor-not-allowed"),"data-sentry-element":"Switch","data-sentry-source-file":"TraceSettingsDropdown.tsx"})]})})]}),(0,a.jsxs)(tl.lv,{"data-sentry-element":"DropdownMenuSub","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:[(0,a.jsx)(tl.nV,{"data-sentry-element":"DropdownMenuSubTrigger","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:(0,a.jsxs)("span",{className:"flex items-center",children:["Min Level: ",g]})}),(0,a.jsxs)(tl.M5,{"data-sentry-element":"DropdownMenuSubContent","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:[(0,a.jsx)(tl.lp,{className:"font-semibold","data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"TraceSettingsDropdown.tsx",children:"Minimum Level"}),Object.values(er.ObservationLevel).map(e=>(0,a.jsx)(tl._2,{onSelect:t=>{t.preventDefault(),y(e)},children:e},e))]})]})]})]})}var td=n(35174),tc=n(39570);function tu(e){let{isPanelCollapsed:t,onTogglePanel:n,shouldPulseToggle:r=!1}=e,s=(0,to.B)();return(0,a.jsxs)("div",{className:"relative","data-sentry-component":"TracePanelNavigationButton","data-sentry-source-file":"TracePanelNavigationButton.tsx",children:[(0,a.jsx)(C.$,{onClick:()=>{n(),s("trace_detail:tree_panel_toggle",{collapsed:!t})},variant:"ghost",size:"icon",title:t?"Expand panel":"Collapse panel",className:"h-7 w-7 shrink-0","data-sentry-element":"Button","data-sentry-source-file":"TracePanelNavigationButton.tsx",children:t?(0,a.jsx)(td.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(tc.A,{className:"h-3.5 w-3.5"})}),r&&(0,a.jsxs)("span",{className:"pointer-events-none absolute right-0.5 top-0.5 flex h-2.5 w-2.5",children:[(0,a.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-400 opacity-75"}),(0,a.jsx)("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-blue-500"})]})]})}function tm(e){return e.isPanelCollapsed?(0,a.jsx)(tp,{...e}):(0,a.jsx)(th,{...e,"data-sentry-element":"TracePanelNavigationHeaderExpanded","data-sentry-component":"TracePanelNavigationHeader","data-sentry-source-file":"TracePanelNavigationHeader.tsx"})}function tp(e){let{isPanelCollapsed:t,onTogglePanel:n,shouldPulseToggle:r=!1}=e;return(0,a.jsx)("div",{className:"flex w-full flex-row items-center justify-center p-2","data-sentry-component":"TracePanelNavigationHeaderCollapsed","data-sentry-source-file":"TracePanelNavigationHeader.tsx",children:(0,a.jsx)(tu,{isPanelCollapsed:t,onTogglePanel:n,shouldPulseToggle:r,"data-sentry-element":"TracePanelNavigationButton","data-sentry-source-file":"TracePanelNavigationHeader.tsx"})})}function th(e){let{isPanelCollapsed:t,onTogglePanel:n,shouldPulseToggle:s=!1}=e,{searchInputValue:i,setSearchInputValue:d,setSearchQueryImmediate:c}=g(),{expandAll:u,collapseAll:m,collapsedNodes:h}=p(),{roots:x,trace:f,observations:y}=(0,r.f)(),{isGraphViewAvailable:v}=w(),[j,b]=(0,o.useQueryParam)("view",o.StringParam),N=x.length>0&&x.every(e=>h.has(e.id)),T=(0,l.useCallback)(e=>{let t=[e.id];return e.children.forEach(e=>{t.push(...T(e))}),t},[]),I=(0,l.useCallback)(()=>{N?u():m(x.flatMap(e=>T(e)))},[N,u,m,T,x]),S=(0,l.useCallback)(()=>{!function(e){let{trace:t,observations:n,filename:a}=e,r=new Blob([JSON.stringify({trace:t,observations:n},null,2)],{type:"application/json; charset=utf-8"}),s=URL.createObjectURL(r),l=document.createElement("a");l.href=s,l.download=a||"trace-".concat(t.id,".json"),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}({trace:f,observations:y})},[f,y]),k="timeline"===j;return(0,a.jsx)(tt.uB,{className:"mt-1 flex h-auto flex-shrink-0 flex-col gap-1 overflow-hidden rounded-none border-b","data-sentry-element":"Command","data-sentry-component":"TracePanelNavigationHeaderExpanded","data-sentry-source-file":"TracePanelNavigationHeader.tsx",children:(0,a.jsxs)("div",{className:"flex flex-row justify-between pl-1 pr-2",children:[(0,a.jsx)("div",{className:"flex flex-row items-center p-0.5",children:(0,a.jsx)(tu,{isPanelCollapsed:t,onTogglePanel:n,shouldPulseToggle:s,"data-sentry-element":"TracePanelNavigationButton","data-sentry-source-file":"TracePanelNavigationHeader.tsx"})}),(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)(tt.G7,{showBorder:!1,placeholder:"Search",className:"h-7 min-w-20 border-0 pr-0 focus:ring-0",value:i,onValueChange:d,onKeyDown:e=>{"Enter"===e.key&&c(i)},"data-sentry-element":"CommandInput","data-sentry-source-file":"TracePanelNavigationHeader.tsx"})}),(0,a.jsxs)("div",{className:"flex flex-row items-center gap-0.5",children:[(0,a.jsx)(C.$,{onClick:I,variant:"ghost",size:"icon",title:N?"Expand all":"Collapse all",className:"h-7 w-7","data-sentry-element":"Button","data-sentry-source-file":"TracePanelNavigationHeader.tsx",children:N?(0,a.jsx)(tn.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(ta.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(ti,{isGraphViewAvailable:v,"data-sentry-element":"TraceSettingsDropdown","data-sentry-source-file":"TracePanelNavigationHeader.tsx"}),(0,a.jsx)(C.$,{variant:"ghost",size:"icon",onClick:S,title:"Download trace as JSON",className:"h-7 w-7","data-sentry-element":"Button","data-sentry-source-file":"TracePanelNavigationHeader.tsx",children:(0,a.jsx)(tr.A,{className:"h-3.5 w-3.5","data-sentry-element":"Download","data-sentry-source-file":"TracePanelNavigationHeader.tsx"})}),(0,a.jsx)(C.$,{variant:k?"default":"ghost",size:"sm",onClick:()=>b(k?null:"timeline"),className:(0,B.cn)("h-7 px-2 text-xs",k&&"bg-primary text-primary-foreground"),"data-sentry-element":"Button","data-sentry-source-file":"TracePanelNavigationHeader.tsx",children:(0,a.jsx)("span",{className:"text-xs",children:"Timeline"})})]})]})})}function tx(){let{hiddenObservationsCount:e}=(0,r.f)(),{minObservationLevel:t,setMinObservationLevel:n}=(0,s.v)(),l=()=>{n(er.ObservationLevel.DEBUG)};return 0===e?null:(0,a.jsx)("div",{className:"flex flex-shrink-0 items-center justify-end gap-1 border-b px-4 py-1","data-sentry-component":"TracePanelNavigationHiddenNotice","data-sentry-source-file":"TracePanelNavigationHiddenNotice.t
1sx",children:(0,a.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground sm:flex-row",children:[(0,a.jsxs)("p",{children:[e," hidden observations below"," ",t," level."]}),(0,a.jsx)("p",{className:"cursor-pointer underline",onClick:l,role:"button",tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&l()},children:"Show all"})]})})}function tf(e){let{children:t,secondaryContent:n}=e,{isNavigationPanelCollapsed:r,handleTogglePanel:s,shouldPulseToggle:l}=D();return(0,a.jsxs)("div",{className:"flex h-full flex-col border-r","data-sentry-component":"TracePanelNavigationLayoutDesktop","data-sentry-source-file":"TracePanelNavigationLayoutDesktop.tsx",children:[(0,a.jsx)(tm,{isPanelCollapsed:r,onTogglePanel:s,shouldPulseToggle:l,"data-sentry-element":"TracePanelNavigationHeader","data-sentry-source-file":"TracePanelNavigationLayoutDesktop.tsx"}),!r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tx,{}),n?(0,a.jsxs)(te.HK,{direction:"vertical",className:"flex-1 overflow-hidden",children:[(0,a.jsx)(te.wV,{defaultSize:60,minSize:20,children:(0,a.jsx)("div",{className:"h-full overflow-hidden",children:t})}),(0,a.jsx)(te.WM,{className:"h-px bg-border"}),(0,a.jsx)(te.wV,{defaultSize:40,minSize:20,children:(0,a.jsx)("div",{className:"h-full overflow-hidden",children:n})})]}):(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:t})]})]})}function tg(e){let{children:t,secondaryContent:n}=e,[r,s]=(0,l.useState)(!1);return(0,a.jsxs)("div",{className:"flex h-full flex-col","data-sentry-component":"TracePanelNavigationLayoutMobile","data-sentry-source-file":"TracePanelNavigationLayoutMobile.tsx",children:[(0,a.jsx)(tx,{"data-sentry-element":"TracePanelNavigationHiddenNotice","data-sentry-source-file":"TracePanelNavigationLayoutMobile.tsx"}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:t}),n&&(0,a.jsxs)("div",{className:"border-t",children:[(0,a.jsxs)(C.$,{variant:"ghost",size:"sm",onClick:()=>s(!r),className:"flex w-full items-center justify-between px-2 py-1",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:"Graph View"}),r?(0,a.jsx)(T.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(I.A,{className:"h-3.5 w-3.5"})]}),r&&(0,a.jsx)("div",{className:"h-64 overflow-hidden",children:n})]})]})}var ty=n(96916),tv=n(86053),tj=n(910),tb=n(87648),tw=n(93769),tN=n(31790),tC=n(41454);let tT="__start__",tI="__end__",tS="__start__",tk="__end__";tC.z.object({langgraph_node:tC.z.string(),langgraph_step:tC.z.number()}),tC.z.object({id:tC.z.string(),parent_observation_id:tC.z.string().nullish(),type:tC.z.string(),name:tC.z.string(),start_time:tC.z.string(),end_time:tC.z.string().nullish(),node:tC.z.string().nullish(),step:tC.z.coerce.number().nullish()});let tE=e=>{let{graph:t,selectedNodeName:n,onCanvasNodeNameChange:r,disablePhysics:s=!1,nodeToObservationsMap:o={},currentObservationIndices:i={}}=e,[d,c]=(0,l.useState)(!1),u=(0,l.useRef)(null),m=(0,l.useRef)(null),p=(0,l.useRef)(null),h=(0,l.useRef)(r);(0,l.useEffect)(()=>{h.current=r},[r]);let x=(0,l.useMemo)(()=>t.nodes.map(e=>{let t={id:e.id,label:e.label,color:(e=>{switch(e){case"AGENT":return{border:"#c4b5fd",background:"#f3f4f6",highlight:{border:"#a78bfa",background:"#e5e7eb"}};case"TOOL":return{border:"#fed7aa",background:"#f3f4f6",highlight:{border:"#fdba74",background:"#e5e7eb"}};case"GENERATION":return{border:"#f0abfc",background:"#f3f4f6",highlight:{border:"#e879f9",background:"#e5e7eb"}};case"SPAN":default:return{border:"#93c5fd",background:"#f3f4f6",highlight:{border:"#60a5fa",background:"#e5e7eb"}};case"CHAIN":return{border:"#f9a8d4",background:"#f3f4f6",highlight:{border:"#f472b6",background:"#e5e7eb"}};case"RETRIEVER":return{border:"#5eead4",background:"#f3f4f6",highlight:{border:"#2dd4bf",background:"#e5e7eb"}};case"EVENT":return{border:"#6ee7b7",background:"#f3f4f6",highlight:{border:"#34d399",background:"#e5e7eb"}};case"EMBEDDING":return{border:"#fbbf24",background:"#f3f4f6",highlight:{border:"#f59e0b",background:"#e5e7eb"}};case"GUARDRAIL":return{border:"#fca5a5",background:"#f3f4f6",highlight:{border:"#f87171",background:"#e5e7eb"}};case"LANGGRAPH_SYSTEM":return{border:"#d1d5db",background:"#f3f4f6",highlight:{border:"#9ca3af",background:"#e5e7eb"}}}})(e.type)};return e.id===tS||e.id===tT?{...t,x:-200,y:0,color:{border:"#166534",background:"#86efac",highlight:{border:"#15803d",background:"#4ade80"}}}:e.id===tk||e.id===tI?{...t,x:200,y:0,color:{border:"#7f1d1d",background:"#fecaca",highlight:{border:"#991b1b",background:"#fca5a5"}}}:t}),[t.nodes]),f=(0,l.useMemo)(()=>({autoResize:!0,layout:{hierarchical:{enabled:!0,direction:"UD",levelSeparation:60,nodeSpacing:175,sortMethod:"hubsize",shakeTowards:"roots"},randomSeed:1},physics:{enabled:!s,stabilization:{iterations:500*!s}},interaction:{zoomView:!1},nodes:{shape:"box",margin:{top:10,right:10,bottom:10,left:10},borderWidth:2,font:{size:14,color:"#000000"},shadow:{enabled:!0,color:"rgba(0,0,0,0.2)",size:3,x:3,y:3},scaling:{label:{enabled:!0,min:14,max:16}
1}},edges:{arrows:{to:{enabled:!0,scaleFactor:.5}},width:1.5,color:{color:"#64748b"},selectionWidth:0,chosen:!1}}),[s]);return((0,l.useEffect)(()=>{if(!u.current)return;let e=new tj.PG(x);p.current=e;let n=new tj.lg(u.current,{...t,nodes:e},f);m.current=n,n.on("click",e=>{e.nodes.length>0?h.current(e.nodes[0]):(h.current(null),n.unselectAll())});let a=()=>{let e=n.getViewPosition(),t=n.getScale(),a=u.current;if(!a)return;let r=a.getBoundingClientRect(),s=n.getPositions(),l=Object.keys(s);if(0===l.length)return;let o=1/0,i=-1/0,d=1/0,c=-1/0;l.forEach(e=>{let t=s[e];o=Math.min(o,t.x),i=Math.max(i,t.x),d=Math.min(d,t.y),c=Math.max(c,t.y)});let m=(i-o+200)*t,p=(c-d+200)*t,h=(r.width/2+.35*m)/t,x=(r.height/2+.35*p)/t,f=Math.max(-h,Math.min(h,e.x)),g=Math.max(-x,Math.min(x,e.y));(f!==e.x||g!==e.y)&&n.moveTo({position:{x:f,y:g},scale:t,animation:!1})};n.on("dragEnd",e=>{0===e.nodes.length&&a()}),n.on("zoom",()=>{a()});let r=()=>{n&&(n.redraw(),n.fit())};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),m.current=null,p.current=null,n.destroy()}},[t,x,f]),(0,l.useEffect)(()=>{let e=p.current;if(e)try{let n=[];t.nodes.forEach(e=>{if(e.id===tS||e.id===tk||e.id===tT||e.id===tI)return;let t=o[e.id]||[],a=i[e.id]||0,r=t.length>1?" (".concat(t.length-a,"/").concat(t.length,")"):"",s="".concat(e.label).concat(r);n.push({id:e.id,label:s})}),n.length>0&&e.update(n)}catch(e){console.error("Error updating node labels:",e)}},[t.nodes,o,i]),(0,l.useEffect)(()=>{let e=m.current;if(e)if(n)if(t.nodes.some(e=>e.id===n))try{e.selectNodes([n])}catch(t){console.error("Error selecting node:",n,t),e.unselectAll()}else console.warn("Cannot select node that doesn't exist:",n),e.unselectAll();else e.unselectAll()},[n,t.nodes]),t.nodes.length)?(0,a.jsxs)("div",{className:"relative h-full min-h-[50dvh] w-full pb-2",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),"data-sentry-component":"TraceGraphCanvas","data-sentry-source-file":"TraceGraphCanvas.tsx",children:[d&&(0,a.jsxs)("div",{className:"absolute right-2 top-2 z-10 flex flex-col gap-1",children:[(0,a.jsx)(C.$,{onClick:()=>{if(m.current){let e=m.current.getScale();m.current.moveTo({scale:1.2*e})}},variant:"ghost",size:"icon",className:"p-1.5 shadow-md dark:shadow-border",title:"Zoom in",children:(0,a.jsx)(tb.A,{className:"h-4 w-4"})}),(0,a.jsx)(C.$,{onClick:()=>{if(m.current){let e=m.current.getScale();m.current.moveTo({scale:e/1.2})}},variant:"ghost",size:"icon",className:"p-1.5 shadow-md dark:shadow-border",title:"Zoom out",children:(0,a.jsx)(tw.A,{className:"h-4 w-4"})}),(0,a.jsx)(C.$,{onClick:()=>{m.current&&m.current.fit({animation:{duration:300,easingFunction:"easeInOutQuad"}})},variant:"ghost",size:"icon",className:"p-1.5 shadow-md dark:shadow-border",title:"Reset view",children:(0,a.jsx)(tN.A,{className:"h-4 w-4"})})]}),(0,a.jsx)("div",{ref:u,className:"h-full w-full"})]}):(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:"No graph data available"})},tO=e=>{let{agentGraphData:t}=e,[n,r]=(0,l.useState)(null),[s,i]=(0,o.useQueryParam)("observation",o.StringParam),[d,c]=(0,l.useState)({}),[u,m]=(0,l.useState)(null),p=(0,l.useRef)(!1),h=(0,l.useMemo)(()=>t.some(e=>null!=e.step&&0!==e.step&&null!=e.node)?t.some(e=>e.node&&e.node.trim().length>0)?function(e){let t=e.filter(e=>e.node&&e.node.trim().length>0).map(e=>{let t={...e,name:e.node||e.name};return e.node===tT?(t.name=tS,t.id=tS):e.node===tI&&(t.name=tk,t.id=tk),t}),n=t.some(e=>e.name===tS),a=t.some(e=>e.name===tk),r=[];if(!n){let e=t.find(e=>!e.parentObservationId);r.push({id:tS,name:tS,node:tS,step:0,parentObservationId:(null==e?void 0:e.parentObservationId)||null,startTime:new Date().toISOString(),endTime:new Date().toISOString(),observationType:"LANGGRAPH_SYSTEM"})}if(!a){let e=t.find(e=>!e.parentObservationId),n=Math.max(...t.map(e=>e.step||0));r.push({id:tk,name:tk,node:tk,step:n+1,parentObservationId:(null==e?void 0:e.parentObservationId)||null,startTime:new Date().toISOString(),endTime:new Date().toISOString(),observationType:"LANGGRAPH_SYSTEM"})}return[...t,...r]}(t):t:function(e){let t=[],n=e.find(e=>!e.parentObservationId),a="2024-01-01T00:00:00.000Z";return t.push({id:tS,name:tS,node:tS,step:0,parentObservationId:(null==n?void 0:n.parentObservationId)||null,startTime:a,endTime:a,observationType:"LANGGRAPH_SYSTEM"}),t.push({id:tk,name:tk,node:tk,step:Math.max(...e.map(e=>e.step||0))+1,parentObservationId:(null==n?void 0:n.parentObservationId)||null,startTime:a,endTime:a,observationType:"LANGGRAPH_SYSTEM"}),[...e,...t]}(function(e){let t=[],n=new Map;for(let a of e){let e={...a};t.push(e),n.set(a.id,{start:new Date(a.startTime).getTime(),end:a.endTime?new Date(a.endTime).getTime():new Date(a.startTime).getTime()})}let a=function e(t,n){if(0===t.length)return[];let a=[],r=[t[0]],s=t.slice(1),l=n.get(t[0].id).end;for(let e of s){let t=n.get(e.id).start;if(t>=l)break;if(r.some(e=>t<n.get(e.id).end)){r.push(e);let t=n.get(e.id).end;t>l&&(l=t)}}let o=[],i=new Set;
1r.forEach(e=>{let t=n.get(e.id).start;r.some(a=>a!==e&&t>n.get(a.id).end)||(o.push(e),i.add(e.id))}),a.push(o);let d=t.filter(e=>!i.has(e.id));if(d.length>0){let t=e(d,n);a.push(...t)}return a}([...t].sort((e,t)=>n.get(e.id).start-n.get(t.id).start),n),r=[];a.forEach((e,t)=>{e.forEach(e=>{e.step=t+1,e.node=e.name,r.push(e)})});let s=!0,l=0;for(;s;){if(++l>1500){console.debug("Aborting graph processing due to excessive iterations.");break}s=!1;let e=new Map,t=new Map(r.map(e=>[e.id,e])),n=e=>{let n=new Set,a=t.get(e);for(;null==a?void 0:a.parentObservationId;)n.add(a.parentObservationId),a=t.get(a.parentObservationId);return n};for(let a of r){if(!a.parentObservationId||null===a.step)continue;let l=t.get(a.parentObservationId);if(!l||null===l.step)continue;let o=l.step+1;if(a.step<o){s=!0;let t=n(a.id);for(let n of r)null!==n.step&&(n.id===a.id?e.set(n.id,(e.get(n.id)||0)+(o-a.step)):n.step>=o&&!t.has(n.id)&&e.set(n.id,(e.get(n.id)||0)+1))}}r=r.map(t=>({...t,step:null!==t.step?t.step+(e.get(t.id)||0):t.step}))}return r}(t.filter(e=>e.observationType!==er.ObservationType.EVENT))),[t]),{graph:x,nodeToObservationsMap:f}=(0,l.useMemo)(()=>(function(e){if(0===e.length)return{graph:{nodes:[],edges:[]},nodeToObservationsMap:{}};let t=new Map,n=new Map;return e.forEach(a=>{let{node:r,step:s}=a;if(null!==s&&null!==r&&(t.has(s)||t.set(s,new Set),t.get(s).add(r)),a.parentObservationId){let t=e.find(e=>e.id===a.parentObservationId);t||null!==r||(n.has(tk)||n.set(tk,[]),n.get(tk).push(a.id)),a.name!==(null==t?void 0:t.name)&&null!==r&&(n.has(r)||n.set(r,[]),n.get(r).push(a.id))}else null!==r&&r!==tS&&r!==tk&&r!==tT&&r!==tI&&(n.has(r)||n.set(r,[]),n.get(r).push(a.id))}),{graph:{nodes:[...new Set([...Array.from(t.values()).flatMap(e=>Array.from(e)),tk])].map(t=>{if(t===tk||t===tS)return{id:t,label:t,type:"LANGGRAPH_SYSTEM"};let n=e.find(e=>e.node===t);return{id:t,label:t,type:(null==n?void 0:n.observationType)||"UNKNOWN"}}),edges:function(e){let t=[...e.entries()].sort((e,t)=>{let[n]=e,[a]=t;return n-a}),n=[];return t.forEach((e,a)=>{let[,r]=e,s=a===t.length-1?[tk]:Array.from(t[a+1][1]);Array.from(r).forEach(e=>{e!==tk&&e!==tI&&s.forEach(t=>{n.push({from:e,to:t})})})}),n}(t)},nodeToObservationsMap:Object.fromEntries(n.entries())}})(h),[h]),g=t.length>=500;(0,l.useEffect)(()=>{c({})},[h]),(0,l.useEffect)(()=>{if(p.current){p.current=!1;return}let e=null,t=0;for(let[n,a]of Object.entries(f)){let r=a.findIndex(e=>e===s);if(-1!==r){e=n,t=r;break}}e&&x.nodes.some(t=>t.id===e)?(r(e),c(n=>({...n,[e]:t})),m(e)):(r(null),m(null))},[s,t,x.nodes,f]);let y=(0,l.useCallback)(e=>{if(e){if(e===tS||e===tk||e===tT||e===tI){m(e),r(e),p.current=!0,i(null);return}let t=f[e]||[];if(t.length>0){let n=0;u===e&&t.length>1&&(n=((d[e]||0)+1)%t.length),c(t=>({...t,[e]:n})),p.current=!0,i(t[n])}else p.current=!0,i(null);m(e)}else m(null);r(e)},[f,d,u,i]);return(0,a.jsx)("div",{className:"grid h-full w-full gap-4","data-sentry-component":"TraceGraphView","data-sentry-source-file":"TraceGraphView.tsx",children:(0,a.jsx)(tE,{graph:x,selectedNodeName:n,onCanvasNodeNameChange:y,disablePhysics:g,nodeToObservationsMap:f,currentObservationIndices:d,"data-sentry-element":"TraceGraphCanvas","data-sentry-source-file":"TraceGraphView.tsx"})})};function tA(){let{agentGraphData:e,isLoading:t}=w();return t?(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading graph..."})}):0===e.length?null:(0,a.jsx)(tO,{agentGraphData:e,"data-sentry-element":"TraceGraphViewComponent","data-sentry-component":"TraceGraphView","data-sentry-source-file":"TraceGraphView.tsx"})}function tM(e){let{trace:t,observations:n,scores:o,corrections:i,projectId:d,context:c}=e,{observationCommentCounts:u,traceCommentCount:m}=function(e){var t;let{projectId:n,traceId:a}=e,r=(0,ey.r)(n),s=v.FH.comments.getCountByObjectType.useQuery({projectId:n,objectType:"OBSERVATION"},{refetchOnMount:!1,enabled:r}),l=v.FH.comments.getCountByObjectId.useQuery({projectId:n,objectId:a,objectType:"TRACE"},{refetchOnMount:!1,enabled:r}),o=l.data?(0,tv.e)(l.data):void 0,i=null!=(t=null==o?void 0:o.get(a))?t:0;return{observationCommentCounts:s.data?(0,tv.e)(s.data):new Map,traceCommentCount:i,isLoading:s.isLoading||l.isLoading}}({projectId:d,traceId:t.id}),p=(0,l.useMemo)(()=>{let e=new Map(u);return m>
10&&e.set(t.id,m),e},[u,m,t.id]);return(0,a.jsx)(s.T,{traceContext:c,"data-sentry-element":"ViewPreferencesProvider","data-sentry-component":"Trace","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(r.$,{trace:t,observations:n,serverScores:o,corrections:i,comments:p,"data-sentry-element":"TraceDataProvider","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(N,{projectId:t.projectId,traceId:t.id,observations:n,"data-sentry-element":"TraceGraphDataProvider","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(h,{"data-sentry-element":"SelectionProvider","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(f,{"data-sentry-element":"SearchProvider","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(y.jh,{"data-sentry-element":"JsonExpansionProvider","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(tD,{"data-sentry-element":"TraceContent","data-sentry-source-file":"Trace.tsx"})})})})})})})}function tD(){let e=(0,ty.a)(),{showGraph:t}=(0,s.v)(),{isGraphViewAvailable:n}=w(),r=t&&n;return e?(0,a.jsx)(tL,{shouldShowGraph:r,"data-sentry-element":"MobileTraceContent","data-sentry-component":"TraceContent","data-sentry-source-file":"Trace.tsx"}):(0,a.jsx)(tP,{shouldShowGraph:r,"data-sentry-element":"DesktopTraceContent","data-sentry-component":"TraceContent","data-sentry-source-file":"Trace.tsx"})}function tP(e){let{shouldShowGraph:t}=e;return(0,a.jsxs)(P,{"data-sentry-element":"TraceLayoutDesktop","data-sentry-component":"DesktopTraceContent","data-sentry-source-file":"Trace.tsx",children:[(0,a.jsx)(P.NavigationPanel,{"data-sentry-element":"TraceLayoutDesktop.NavigationPanel","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(tf,{secondaryContent:t?(0,a.jsx)(tA,{}):void 0,"data-sentry-element":"TracePanelNavigationLayoutDesktop","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(ei,{"data-sentry-element":"TracePanelNavigation","data-sentry-source-file":"Trace.tsx"})})}),(0,a.jsx)(P.ResizeHandle,{"data-sentry-element":"TraceLayoutDesktop.ResizeHandle","data-sentry-source-file":"Trace.tsx"}),(0,a.jsx)(P.DetailPanel,{"data-sentry-element":"TraceLayoutDesktop.DetailPanel","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(e8,{"data-sentry-element":"TracePanelDetail","data-sentry-source-file":"Trace.tsx"})})]})}function tL(e){let{shouldShowGraph:t}=e;return(0,a.jsx)("div",{className:"h-full w-full","data-sentry-component":"MobileTraceContent","data-sentry-source-file":"Trace.tsx",children:(0,a.jsxs)(k,{"data-sentry-element":"TraceLayoutMobile","data-sentry-source-file":"Trace.tsx",children:[(0,a.jsx)(k.NavigationPanel,{"data-sentry-element":"TraceLayoutMobile.NavigationPanel","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(tg,{secondaryContent:t?(0,a.jsx)(tA,{}):void 0,"data-sentry-element":"TracePanelNavigationLayoutMobile","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(ei,{"data-sentry-element":"TracePanelNavigation","data-sentry-source-file":"Trace.tsx"})})}),(0,a.jsx)(k.DetailPanel,{"data-sentry-element":"TraceLayoutMobile.DetailPanel","data-sentry-source-file":"Trace.tsx",children:(0,a.jsx)(e8,{"data-sentry-element":"TracePanelDetail","data-sentry-source-file":"Trace.tsx"})})]})})}},6670:(e,t,n)=>{n.d(t,{X:()=>p});var a=n(73154),r=n(28353),s=n(86843),l=n(28436),o=n(73156),i=n(18799),d=n(96665),c=n(12485),u=n(96810),m=n(39156);function p(e){let{projectId:t,objectId:n,objectType:p,count:h,variant:x="secondary",className:f,size:g="default",pendingSelection:y,onSelectionUsed:v,isOpen:j,onOpenChange:b}=e,w=(0,m.useRouter)(),[N,C]=(0,u.useState)(!1),[T,I]=(0,u.useState)(!1),S=(0,u.useRef)(!1),k=null!=j?j:T,E=null!=b?b:I,O=(0,u.useRef)(!1),A=(0,i.lp)({projectId:t,scope:"comments:read"}),M=(0,i.lp)({projectId:t,scope:"comments:CUD"});return((0,u.useEffect)(()=>{"open"===w.query.comments&&w.query.commentObjectType===p&&w.query.commentObjectId===n&&A&&!k&&!S.current&&(S.current=!0,E(!0),w.asPath.includes("#comment-")&&setTimeout(()=>{let e=w.asPath.split("#")[1],t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},300)),"open"!==w.query.comments&&S.current&&(S.current=!1)},[w.query.comments,w.query.commentObjectType,w.query.commentObjectId,w.asPath,A,p,n,k,E]),A&&(M||h))?(0,a.jsxs)(l._s,{open:k,onOpenChange:e=>{if((e||!N)&&(E(e),e||(O.current=!1),!e&&"open"===w.query.comments)){let{comments:e,commentObjectType:t,commentObjectId:n,...a}=w.query;w.replace({pathname:w.pathname,query:a},void 0,{shallow:!0})}},"data-sentry-element":"Drawer","data-sentry-component":"CommentDrawerButton","data-sentry-source-file":"CommentDrawerButton.tsx",children:[(0,a.jsx)(l.Uz,{asChild:!0,"data-sentry-element":"DrawerTrigger","data-sentry-source-file":"CommentDrawerButton.tsx",children:(0,a.jsx)(s.$,{type:"button",variant:x,size:g,className:f,id:"comment-drawer-button","data-sentry-element":"Button","data-sentry-source-file":"CommentDrawerButton.tsx",children:h?(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(c.A,{className:"sm"===g?"h-3.5 w-3.5":"h-4 w-4"}),(0,a.jsx)("span",{children:"Add comment"}),(0,a.jsx)("span",{className:"flex h-3.5 w-fit items-center justify-center rounded-sm bg-primary/50 px-1 text-xs text-primary-foreground shadow-sm",children:h>99?"99+":h})]}):(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(c.A,{className:"sm"===g?"h-3.5 w-3.5":"h-4 w-4"}),(0,a.jsx)("span",{children:"Add comment"})]})})}),(0,a.jsx)(l.zj,{overlayClassName:"bg-primary/10","data-sentry-element":"DrawerContent","data-sentry-source-file":"CommentDrawerButton.tsx",children:(0,a.jsxs)("div",{className:"mx-auto flex h-full w-full flex-col overflow-hidden focu
1s:outline-none focus:ring-0 focus-visible:outline-none focus-visible:ring-0 md:max-h-full",tabIndex:-1,ref:e=>{e&&k&&!O.current&&(O.current=!0,setTimeout(()=>e.focus({preventScroll:!0}),100))},children:[(0,a.jsx)(l.BE,{className:"sr-only flex-shrink-0 rounded-sm bg-background","data-sentry-element":"DrawerHeader","data-sentry-source-file":"CommentDrawerButton.tsx",children:(0,a.jsx)(l.gk,{"data-sentry-element":"DrawerTitle","data-sentry-source-file":"CommentDrawerButton.tsx",children:(0,a.jsx)(r.Ay,{title:"Comments","data-sentry-element":"Header","data-sentry-source-file":"CommentDrawerButton.tsx"})})}),(0,a.jsx)("div",{"data-vaul-no-drag":!0,className:"min-h-0 flex-1 px-2 pt-2",children:(0,a.jsx)(o.Q,{projectId:t,objectId:n,objectType:p,onMentionDropdownChange:C,isDrawerOpen:k,pendingSelection:y,onSelectionUsed:v,"data-sentry-element":"CommentList","data-sentry-source-file":"CommentDrawerButton.tsx"})})]})})]}):(0,a.jsx)(s.$,{type:"button",variant:"secondary",size:g,className:f,disabled:!0,children:(0,a.jsx)(d.A,{className:"sm"===g?"h-3.5 w-3.5 text-muted-foreground":"h-4 w-4 text-muted-foreground"})})}},6786:(e,t,n)=>{n.d(t,{E:()=>x});var a=n(73154),r=n(97390),s=n(86843),l=n(88377),o=n(18799),i=n(93367),d=n(21),c=n(72459),u=n(38834),m=n(68389),p=n.n(m),h=n(96810);let x=e=>{var t,n,m,x,f;let{projectId:g,objectId:y,objectType:v,variant:j="secondary",size:b="default"}=e,[w,N]=(0,h.useState)(!1),C=(0,u.useSession)(),T=(0,o.lp)({projectId:g,scope:"annotationQueues:CUD"}),I=i.FH.annotationQueues.byObjectId.useQuery({projectId:g,objectId:y,objectType:v},{enabled:"authenticated"===C.status}),S=i.FH.useUtils(),k=i.FH.annotationQueueItems.createMany.useMutation(),E=i.FH.annotationQueueItems.deleteMany.useMutation(),O=(0,h.useCallback)(async(e,t,n)=>{try{n?confirm('Are you sure you want to remove this item from the queue "'.concat(t,'"?'))&&await E.mutateAsync({projectId:g,itemIds:[n]}):await k.mutateAsync({projectId:g,objectIds:[y],objectType:v,queueId:e}),await S.annotationQueues.byObjectId.invalidate({projectId:g,objectId:y,objectType:v})}catch(e){console.error("Error toggling queue item:",e)}},[k,E,g,y,v,S.annotationQueues]);return"authenticated"!==C.status||I.isLoading?(0,a.jsx)(s.$,{variant:j,size:b,disabled:"authenticated"!==C.status,className:"rounded-l-none rounded-r-md border-l-2",children:(0,a.jsx)("span",{className:"relative mr-1 text-xs",children:(0,a.jsx)(d.A,{className:"h-3 w-3"})})}):(0,a.jsxs)(l.rI,{open:w,onOpenChange:()=>{T&&N(!w)},"data-sentry-element":"DropdownMenu","data-sentry-component":"CreateNewAnnotationQueueItem","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:[(0,a.jsx)(l.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:(0,a.jsx)(s.$,{variant:j,size:b,disabled:!T,className:"rounded-l-none rounded-r-md border-l-2","data-sentry-element":"Button","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:(null==(t=I.data)?void 0:t.totalCount)?(0,a.jsxs)("span",{className:"relative mr-1 text-xs",children:[(0,a.jsx)(d.A,{className:"h-3 w-3 text-secondary-foreground"}),(0,a.jsx)("span",{className:"absolute -top-1 left-2.5 flex h-3 min-w-3 items-center justify-center rounded-sm bg-slate-600 px-0.5 text-[8px] font-medium text-white shadow-sm",children:(null==(n=I.data)?void 0:n.totalCount)>99?"99+":null==(m=I.data)?void 0:m.totalCount})]}):(0,a.jsx)("span",{className:"relative mr-1 text-xs",children:(0,a.jsx)(d.A,{className:"h-3 w-3"})})})}),(0,a.jsxs)(l.SQ,{"data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:[(0,a.jsx)(l.lp,{"data-sentry-element":"DropdownMenuLabel","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:"In queue(s)"}),(null==(x=I.data)?void 0:x.queues.length)?null==(f=I.data)?void 0:f.queues.map(e=>(0,a.jsxs)(l.hO,{className:"hover:bg-accent",checked:!!e.itemId,onSelect:e=>{e.preventDefault()},onClick:t=>{t.preventDefault(),t.stopPropagation(),O(e.id,e.name,e.itemId)},children:[e.name,e.status&&(0,a.jsx)(r.W,{type:e.status.toLowerCase(),isLive:!1,className:"ml-2"})]},e.id)):(0,a.jsx)(l._2,{onClick:e=>{e.preventDefault(),e.stopPropagation()},children:"No queues defined"}),(0,a.jsx)(l.mB,{"data-sentry-element":"DropdownMenuSeparator","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx"}),(0,a.jsx)(l._2,{className:"hover:bg-accent",asChild:!0,"data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:(0,a.jsxs)("div",{children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4","data-sentry-element":"ExternalLink","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx"}),(0,a.jsx)(p(),{href:"/project/".concat(g,"/annotation-queues"),"data-sentry-element":"Link","data-sentry-source-file":"CreateNewAnnotationQueueItem.tsx",children:"Manage queues"})]})},"manage-queues")]})]},"queue")}}
1,8862:(e,t,n)=>{n.d(t,{$:()=>p,f:()=>m});var a=n(73154),r=n(96810),s=n(92065),l=n(45596),o=n(45607),i=n(22379),d=n(16968),c=n(52402);let u=(0,r.createContext)(null);function m(){let e=(0,r.useContext)(u);if(!e)throw Error("useTraceData must be used within a TraceDataProvider");return e}function p(e){let{trace:t,observations:n,serverScores:m,corrections:p,comments:h,children:x}=e,{minObservationLevel:f}=(0,o.v)(),g=(0,r.useMemo)(()=>(function(e,t,n){let{roots:a,hiddenObservationsCount:r,nodeMap:o}=function(e,t,n){var a,r;let{sortedObservations:o,hiddenObservationsCount:i}=function(e,t){if(0===e.length)return{sortedObservations:[],hiddenObservationsCount:0};let n=e.filter(e=>(function(e){let t=[l.ObservationLevel.DEBUG,l.ObservationLevel.DEFAULT,l.ObservationLevel.WARNING,l.ObservationLevel.ERROR];if(!e)return t;let n=t.indexOf(e);return t.slice(n)})(t).includes(e.level)),a=e.length-n.length,r=new Set(e.map(e=>e.id));return n.forEach(e=>{e.parentObservationId&&!r.has(e.parentObservationId)&&(e.parentObservationId=null)}),{sortedObservations:n.sort((e,t)=>e.startTime.getTime()-t.startTime.getTime()),hiddenObservationsCount:a}}(t,n);if(0===o.length){if(e.rootObservationType)return{roots:[],hiddenObservationsCount:i,nodeMap:new Map};let t={id:"trace-".concat(e.id),type:"TRACE",name:null!=(a=e.name)?a:"",startTime:e.timestamp,endTime:null,children:[],latency:e.latency,totalCost:void 0,startTimeSinceTrace:0,startTimeSinceParentStart:null,depth:-1,childrenDepth:0},n=new Map;return n.set(t.id,t),{roots:[t],hiddenObservationsCount:i,nodeMap:n}}let{nodeRegistry:d,leafIds:c}=function(e){let t=new Map;for(let n of e)t.set(n.id,{observation:n,childrenIds:[],inDegree:0,depth:0,treeNode:void 0});for(let n of e)if(n.parentObservationId){let e=t.get(n.parentObservationId);e&&e.childrenIds.push(n.id)}let n=[];for(let[e,a]of t)a.observation.parentObservationId||(n.push(e),a.depth=0);let a=[...n],r=0;for(;r<a.length;){let e=a[r++],n=t.get(e);for(let e of n.childrenIds)t.get(e).depth=n.depth+1,a.push(e)}let s=[];for(let[e,n]of t)n.inDegree=n.childrenIds.length,0===n.childrenIds.length&&s.push(e);return{nodeRegistry:t,leafIds:s}}(o),u=new Map,m=function(e,t,n,a){let r=[...t],l=0,o=[];for(;l<r.length;){var i;let t,d=r[l++],c=e.get(d),u=c.observation,m=[];for(let t of c.childrenIds){let n=e.get(t);n.treeNode&&m.push(n.treeNode)}if(null!=u.totalCost){let e=new s.A(u.totalCost);e.isZero()||(t=e)}else if(null!=u.inputCost||null!=u.outputCost){let e=new s.A(null!=u.inputCost?u.inputCost:0),n=new s.A(null!=u.outputCost?u.outputCost:0),a=e.plus(n);a.isZero()||(t=a)}let p=m.reduce((e,t)=>t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),h=t&&p?t.plus(p):t||p,x=u.startTime.getTime()-a.getTime(),f=null;if(u.parentObservationId){let t=e.get(u.parentObservationId);t&&(f=u.startTime.getTime()-t.observation.startTime.getTime())}let g=c.depth,y=m.length>0?Math.max(...m.map(e=>e.childrenDepth))+1:0,v={id:u.id,type:u.type,name:null!=(i=u.name)?i:"",startTime:u.startTime,endTime:u.endTime,level:u.level,children:m,inputUsage:u.inputUsage,outputUsage:u.outputUsage,totalUsage:u.totalUsage,calculatedInputCost:u.inputCost,calculatedOutputCost:u.outputCost,calculatedTotalCost:u.totalCost,parentObservationId:u.parentObservationId,traceId:u.traceId,totalCost:h,startTimeSinceTrace:x,startTimeSinceParentStart:f,depth:g,childrenDepth:y};if(c.treeNode=v,n.set(d,v),u.parentObservationId){let t=e.get(u.parentObservationId);t&&(t.inDegree--,0===t.inDegree&&r.push(u.parentObservationId))}else o.push(d)}return o}(d,c,u,e.timestamp),p=[];for(let e of m){let t=d.get(e);t.treeNode&&p.push(t.treeNode)}if(p.sort((e,t)=>e.startTime.getTime()-t.startTime.getTime()),e.rootObservationType)return{roots:p,hiddenObservationsCount:i,nodeMap:u};let h=p.reduce((e,t)=>t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),x=p.length>0?Math.max(...p.map(e=>e.childrenDepth))+1:0,f={id:"trace-".concat(e.id),type:"TRACE",name:null!=(r=e.name)?r:"",startTime:e.timestamp,endTime:null,children:p,latency:e.latency,totalCost:h,startTimeSinceTrace:0,startTimeSinceParentStart:null,depth:-1,childrenDepth:x};return u.set(f.id,f),{roots:[f],hiddenObservationsCount:i,nodeMap:u}}(e,t,n);if(0===a.length)return{roots:a,hiddenObservationsCount:r,searchItems:[],nodeMap:o};let i=a.reduce((e,t)=>
1t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),d=a.length>0?Math.max(...a.map(e=>e.latency?1e3*e.latency:e.endTime?e.endTime.getTime()-e.startTime.getTime():0)):void 0,c=[],u=[];for(let e=a.length-1;e>=0;e--)u.push(a[e]);for(;u.length>0;){let e=u.pop();c.push({node:e,parentTotalCost:i,parentTotalDuration:d,observationId:"TRACE"===e.type?void 0:e.id});for(let t=e.children.length-1;t>=0;t--)u.push(e.children[t])}return{roots:a,hiddenObservationsCount:r,searchItems:c,nodeMap:o}})(t,n,f),[t,n,f]),y=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"target-scores-only",{getAllForTarget:a,isDeleted:s}=(0,i.I)(),l=a(n,{traceId:"trace"===t.type?t.traceId:void 0,observationId:"trace"===t.type?t.observationId:void 0,sessionId:"session"===t.type?t.sessionId:void 0}),o=(0,r.useMemo)(()=>(0,c.a)(e,t,n),[e,t,n]),u=(0,r.useMemo)(()=>{let e=new Set;return o.forEach(t=>{s(t.id)&&e.add(t.id)}),e},[o,s]);return(0,r.useMemo)(()=>(0,d.gm)(o,l,u),[o,l,u])}(m,{type:"trace",traceId:t.id},"target-and-child-scores"),v=(0,r.useMemo)(()=>({trace:t,observations:n,serverScores:m,mergedScores:y,corrections:p,roots:g.roots,nodeMap:g.nodeMap,searchItems:g.searchItems,hiddenObservationsCount:g.hiddenObservationsCount,comments:h}),[t,n,m,y,p,g,h]);return(0,a.jsx)(u.Provider,{value:v,"data-sentry-element":"TraceDataContext.Provider","data-sentry-component":"TraceDataProvider","data-sentry-source-file":"TraceDataContext.tsx",children:x})}},9476:(e,t,n)=>{n.d(t,{k:()=>a,y:()=>r});let a={EXECUTE_ALL:"playground:execute-all",STOP_ALL:"playground:stop-all",WINDOW_REGISTERED:"playground:window-registered",WINDOW_UNREGISTERED:"playground:window-unregistered",WINDOW_EXECUTION_STATE_CHANGE:"playground:window-execution-state-change",WINDOW_MODEL_CONFIG_CHANGE:"playground:window-model-config-change"},r={MAX_WINDOWS:10,MAX_WINDOWS_MOBILE:1,MIN_WINDOW_WIDTH:400,MOBILE_BREAKPOINT:768,DEFAULT_WINDOW_ID:"default"}},16538:(e,t,n)=>{n.d(t,{P:()=>i,X:()=>d});var a=n(73154),r=n(53524),s=n(96810),l=n(92065),o=n(16549);let i=e=>{var t;let n=Array.isArray(e)?e.reduce((e,t)=>(Object.entries(t).forEach(t=>{let[n,a]=t;e[n]=new l.A(e[n]||0).plus(new l.A(a||0)).toNumber()}),e),{}):e,a=Object.entries(n).filter(e=>{let[t]=e;return t.includes("input")}).reduce((e,t)=>{let[n,a]=t;return new l.A(e).plus(new l.A(null!=a?a:0)).toNumber()},0),r=Object.entries(n).filter(e=>{let[t]=e;return t.includes("output")}).reduce((e,t)=>{let[n,a]=t;return new l.A(e).plus(new l.A(null!=a?a:0)).toNumber()},0),s=null!=(t=n.total)?t:a+r;return{input:a,output:r,total:s}},d=e=>{var t;let{details:n,children:i,isCost:d=!1,pricingTierName:m}
1=e,[p,h]=(0,s.useState)(!1),x=Array.isArray(n)?n.reduce((e,t)=>(Object.entries(t).forEach(t=>{let[n,a]=t;e[n]=new l.A(e[n]||0).plus(new l.A(a||0)).toNumber()}),e),{}):n,f=(e,t)=>e?d?"$".concat(e.toFixed(t)):e.toLocaleString():"0",g=d?Math.max(...Object.values(x).map(e=>(0,o.V)(e))):0;return(0,a.jsx)(r.Bc,{"data-sentry-element":"TooltipProvider","data-sentry-component":"BreakdownTooltip","data-sentry-source-file":"BreakdownToolTip.tsx",children:(0,a.jsxs)(r.m_,{open:p,onOpenChange:h,"data-sentry-element":"Tooltip","data-sentry-source-file":"BreakdownToolTip.tsx",children:[(0,a.jsx)(r.k$,{className:"flex cursor-pointer",onClick:()=>h(!p),"data-sentry-element":"TooltipTrigger","data-sentry-source-file":"BreakdownToolTip.tsx",children:i}),(0,a.jsx)(r.ZI,{className:"w-64 p-4","data-sentry-element":"TooltipContent","data-sentry-source-file":"BreakdownToolTip.tsx",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("span",{className:"font-semibold",children:d?"Cost breakdown":"Usage breakdown"}),Array.isArray(n)&&n.length>0&&(0,a.jsxs)("span",{className:"text-xs italic text-muted-foreground",children:["Aggregate across ",n.length," ",1===n.length?"generation":"generations"]}),m&&(0,a.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:"Pricing Tier:"}),(0,a.jsx)("span",{className:"font-mono",children:m})]})]}),(0,a.jsx)(c,{title:d?"Input cost":"Input usage",details:x,filterFn:e=>e.includes("input"),formatValue:e=>f(e,g),"data-sentry-element":"Section","data-sentry-source-file":"BreakdownToolTip.tsx"}),(0,a.jsx)(c,{title:d?"Output cost":"Output usage",details:x,filterFn:e=>e.includes("output"),formatValue:e=>f(e,g),"data-sentry-element":"Section","data-sentry-source-file":"BreakdownToolTip.tsx"}),(0,a.jsx)(u,{details:x,isCost:d,formatValue:e=>f(e,g),"data-sentry-element":"OtherSection","data-sentry-source-file":"BreakdownToolTip.tsx"}),(0,a.jsxs)("div",{className:"flex justify-between border-b-4 border-t border-double py-1",children:[(0,a.jsx)("span",{className:"text-xs font-semibold",children:d?"Total cost":"Total usage"}),(0,a.jsx)("span",{className:"font-mono text-xs font-semibold",children:f(null!=(t=x.total)?t:0,g)})]})]})})]})})},c=e=>{let{title:t,details:n,filterFn:r,formatValue:s}=e,o=Object.entries(n).filter(e=>{let[t]=e;return r(t)}).sort((e,t)=>{let[,n]=e,[,a]=t;return(null!=a?a:0)-(null!=n?n:0)}),i=o.reduce((e,t)=>{let[n,a]=t;return new l.A(e).plus(new l.A(null!=a?a:0)).toNumber()},0);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-sentry-component":"Section","data-sentry-source-file":"BreakdownToolTip.tsx",children:[(0,a.jsxs)("div",{className:"flex justify-between border-b pb-1",children:[(0,a.jsx)("span",{className:"text-xs font-semibold",children:t}),(0,a.jsx)("span",{className:"text-right font-mono text-xs font-semibold",children:s(i)})]}),o.map(e=>{let[t,n]=e;return(0,a.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mr-4",children:t}),(0,a.jsx)("span",{className:"font-mono",children:s(null!=n?n:0)})]},t)})]})},u=e=>{let{details:t,isCost:n,formatValue:r}=e,s=Object.entries(t).filter(e=>{let[t]=e;return!t.includes("input")&&!t.includes("output")&&"total"!==t}).sort((e,t)=>{let[,n]=e,[,a]=t;return(null!=a?a:0)-(null!=n?n:0)});if(0===s.length)return null;let l=s.reduce((e,t)=>{var n;return"number"!=typeof t[1]?e:e+(null!=(n=t[1])?n:0)},0);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-sentry-component":"OtherSection","data-sentry-source-file":"BreakdownToolTip.tsx",children:[(0,a.jsxs)("div",{className:"flex justify-between border-b pb-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:n?"Other cost":"Other usage"}),(0,a.jsx)("span",{className:"text-right font-mono text-xs font-medium",children:r(l)})]}),s.map(e=>{let[t,n]=e;return(0,a.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mr-4",children:t}),(0,a.jsx)("span",{className:"font-mono",children:r(null!=n?n:0)})]},t)})]})}},16766:(e,t,n)=>{n.d(t,{z:()=>l});var a=n(96810),r=n(93367),s=n(18799);function l(e){var t;let{projectId:n,excludeUserIds:l,limit:o=50,enabled:i=!0}=e,[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(""),p=(0,s.lp)({projectId:n,scope:"projectMembers:read"});(0,a.useEffect)(()=>{let e=setTimeout(()=>{m(d)},300);return()=>clearTimeout(e)},[d]);let h=r.FH.members.byProjectId.useQuery({projectId:n,searchQuery:u||void 0,page:0,limit:o,excludeUserIds:l&&l.length>0?l:void 0},{enabled:p&&i}),x=h.data&&h.data.totalCount>h.data.users.length;return{searchQuery:d,setSearchQuery:c,searchResults:(null==(t=h.data)?void 0:t.users)||[],isLoading:h.isLoading,hasMoreResults:x||!1}}},16968:(e,t,n)=>{n.d(t,{DH:()=>l,HW:()=>s,gm:()=>r});var a=n(40741);function r(e,t,n){let a=new Map;
1return e.forEach(e=>{n.has(e.id)||a.set(e.id,e)}),t.forEach(e=>{let t=a.get(e.id);t?a.set(e.id,{...t,value:e.value,stringValue:e.stringValue,comment:e.comment}):a.set(e.id,e)}),Array.from(a.values())}function s(e,t,n){let r={...e};return Object.entries(r).forEach(e=>{let[t,a]=e;a.id&&n.has(a.id)&&delete r[t]}),t.forEach(e=>{let t=(0,a.ZV)({name:e.name,source:e.source,dataType:e.dataType});"NUMERIC"===e.dataType?r[t]={type:"NUMERIC",values:[e.value],average:e.value,comment:e.comment,id:e.id}:r[t]={type:"CATEGORICAL",values:[e.stringValue],valueCounts:[{value:e.stringValue,count:1}],comment:e.comment,id:e.id}}),r}function l(e,t,n){let a=new Map;return e.forEach(e=>{var t,r;n.has(null!=(t=e.id)?t:"")||a.set(null!=(r=e.id)?r:"",e)}),t.forEach(e=>{let t=a.get(e.id);if(t)a.set(e.id,{...t,value:e.value,stringValue:e.stringValue,comment:e.comment});else{var n,r,s,l;a.set(e.id,{id:e.id,name:e.name,dataType:e.dataType,source:e.source,configId:e.configId,value:e.value,stringValue:e.stringValue,comment:e.comment,traceId:null!=(n=e.traceId)?n:null,observationId:null!=(r=e.observationId)?r:null,sessionId:null!=(s=e.sessionId)?s:null,timestamp:null!=(l=e.timestamp)?l:null})}}),Array.from(a.values())}},26077:(e,t,n)=>{n.d(t,{T:()=>er});var a=n(73154),r=n(96810),s=n(79077),l=n(8862),o=n(45607),i=n(35545),d=n(10614),c=n(81509);let u=(0,r.memo)(function(e){let{columns:t,hasExpandIcon:n}=e;return(0,a.jsxs)("div",{className:"flex min-h-6 items-center gap-2 border-b border-border bg-muted/50 px-3 py-0.5 text-xs font-medium text-muted-foreground","data-sentry-component":"JSONTableViewHeaderInner","data-sentry-source-file":"JSONTableViewHeader.tsx",children:[n&&(0,a.jsx)("div",{className:"w-4"}),t.map(e=>{var t;return(0,a.jsx)("div",{className:(0,c.cn)("flex-shrink-0",null!=(t=e.width)?t:"flex-1","right"===e.align&&"text-right"),children:e.header},e.key)})]})});var m=n(21),p=n(59757),h=n(33549);let x=(0,r.memo)(function(e){let{item:t,itemKey:n,index:r,columns:s,isExpanded:l,expandable:o,onToggle:i,renderExpanded:d,renderRowPrefix:u}=e,{props:x}=(0,h.g)({onClick:i,enabled:o}),f=l?m.A:p.A,g="expanded-content-".concat(n);return(0,a.jsxs)("div",{className:"border-b border-border bg-background","data-sentry-component":"JSONTableViewRowInner","data-sentry-source-file":"JSONTableViewRow.tsx",children:[(0,a.jsxs)("div",{className:(0,c.cn)("flex min-h-6 items-center gap-2 px-3 py-0.5",o&&"cursor-pointer hover:bg-muted/50",l&&"border-b border-border/50 bg-muted/30"),...o?x:{},role:o?"button":void 0,tabIndex:o?0:void 0,"aria-expanded":o?l:void 0,"aria-controls":o?g:void 0,onKeyDown:o?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),i())}:void 0,children:[u&&u(t,l),o&&(0,a.jsx)(f,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.map(e=>{var n;return(0,a.jsx)("div",{className:(0,c.cn)("flex-shrink-0 text-sm",null!=(n=e.width)?n:"min-w-0 flex-1","right"===e.align&&"text-right","flex-1"===e.width&&"truncate"),children:e.render(t,r)},e.key)})]}),l&&d&&(0,a.jsx)("div",{id:g,className:"w-full",children:d(t)})]})});function f(e){var t;let{items:n,columns:s,getItemKey:l,expandable:o=!1,renderExpanded:i,expandedKeys:m,onExpandedKeysChange:p,virtualized:h=!1,collapsedRowHeight:f=28,expandedRowHeight:g=150,stickyHeaderContent:y,onVisibleItemsChange:v,renderRowPrefix:j,overscan:b=100,className:w}=e,[N,C]=(0,r.useState)(new Set),T=void 0!==m,I=T?m:N,S=(0,r.useRef)(null),k=(0,r.useRef)(null),[E,O]=(0,r.useState)(0),A=(0,r.useCallback)(e=>{let t=t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n};T?null==p||p(t(I)):C(t)},[T,I,p]),M=(0,r.useCallback)(e=>{let t=n[e];if(!t)return f;let a=l(t);return I.has(a)?g:f},[n,l,I,f,g]),D=(0,d.Te)({count:h?n.length:0,getScrollElement:()=>S.current,estimateSize:M,overscan:b,measureElement:e=>e.getBoundingClientRect().height,enabled:h}),P=(0,r.useMemo)(()=>{var e,t;return h&&null!=(t=null==(e=D.getVirtualItems()[0])?void 0:e.index)?t:0},[h,D]);(0,r.useEffect)(()=>{if(h||!k.current)return;let e=k.current,t=()=>{for(let n of e.querySelectorAll("[data-row-index]")){let a=n.getBoundingClientRect(),r=e.getBoundingClientRect();if(a.top-r.top>=-a.height/2){var t;O(parseInt(null!=(t=n.getAttribute("data-row-index"))?t:"0",10));break}}};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[h]);let L=h?P:E,B=null!=(t=n[L])?t:null;(0,r.useEffect)(()=>
1{if(!h||!v)return;let e=D.getVirtualItems().map(e=>n[e.index]).filter(e=>void 0!==e);e.length>0&&v(e)},[h,D,n,v]);let R=n.length>0;return(0,a.jsxs)("div",{className:(0,c.cn)("flex h-full w-full flex-col overflow-hidden",w),"data-sentry-component":"JSONTableView","data-sentry-source-file":"JSONTableView.tsx",children:[R&&y&&(0,a.jsx)("div",{className:"flex-shrink-0",children:y(B,L)}),R&&(0,a.jsx)(u,{columns:s,hasExpandIcon:o}),R&&h&&(0,a.jsx)("div",{ref:S,className:"flex-1 overflow-y-scroll",children:(0,a.jsx)("div",{style:{height:"".concat(D.getTotalSize(),"px"),width:"100%",position:"relative"},children:D.getVirtualItems().map(e=>{let t=n[e.index];if(!t)return null;let r=l(t),d=I.has(r);return(0,a.jsx)("div",{"data-index":e.index,ref:D.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(e.start,"px)")},children:(0,a.jsx)(x,{item:t,itemKey:r,index:e.index,columns:s,isExpanded:d,expandable:o,onToggle:()=>A(r),renderExpanded:i,renderRowPrefix:j})},r)})})}),R&&!h&&(0,a.jsx)("div",{ref:k,className:"flex-1 overflow-y-auto",children:n.map((e,t)=>{let n=l(e),r=I.has(n);return(0,a.jsx)("div",{"data-row-index":t,children:(0,a.jsx)(x,{item:e,itemKey:n,index:t,columns:s,isExpanded:r,expandable:o,onToggle:()=>A(n),renderExpanded:i,renderRowPrefix:j})},n)})}
1),!R&&(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"No items"})})]})}var g=n(53567),y=n(73132),v=n(98069),j=n(47616),b=n(51883),w=n(92273),N=n(66798),C=n(91163),T=n(86843),I=n(95266),S=n(53524),k=n(97898);let E=(0,r.memo)(function(e){var t;let{searchQuery:n,onSearchChange:s,isVirtualized:l=!0,observationCount:o,loadedObservationCount:i,onToggleExpandAll:d,allRowsExpanded:u,onCopyJson:m,onDownloadJson:p,isDownloadCacheOnly:h=!1,currentView:x="pretty",indentEnabled:f=!1,indentDisabled:E=!1,onToggleIndent:O,showMilliseconds:A=!1,onToggleMilliseconds:M,isDownloadLoading:D=!1}=e,[P,L]=(0,r.useState)(!1);return(0,a.jsxs)("div",{className:"flex h-9 flex-shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[l&&(0,a.jsxs)(k.jc,{openDelay:200,children:[(0,a.jsx)(k.d0,{asChild:!0,children:(0,a.jsx)("span",{className:"cursor-help rounded bg-yellow-100 px-1.5 py-0.5 text-xs font-medium text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300",children:"Large Trace"})}),(0,a.jsxs)(k.Et,{align:"start",className:"w-72 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"Optimized for performance"}),(0,a.jsxs)("p",{className:"mt-1.5 text-muted-foreground",children:["This trace has ",null!=(t=null==o?void 0:o.toLocaleString())?t:"many"," ","observations. To keep things smooth:"]}),(0,a.jsxs)("ul",{className:"mt-1.5 list-inside list-disc space-y-0.5 text-muted-foreground",children:[(0,a.jsx)("li",{children:"Content loads as you scroll"}),(0,a.jsx)("li",{children:"JSON view is disabled"}),(0,a.jsx)("li",{children:"Download/copy includes I/O for cached observations only"})]})]})]}),"json"===x?(0,a.jsx)("div",{className:"flex-1"}):(0,a.jsx)(I.uB,{className:"flex-1 rounded-none border-0 bg-transparent",children:(0,a.jsx)(I.G7,{showBorder:!1,placeholder:"Search observations...",className:"h-7 border-0 focus:ring-0",value:n,onValueChange:s})}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:["json"!==x&&O&&(0,a.jsxs)(k.jc,{openDelay:200,children:[(0,a.jsx)(k.d0,{asChild:!0,children:(0,a.jsx)(T.$,{variant:f?"default":"ghost",size:"icon",className:(0,c.cn)("h-7 w-7",f&&"bg-primary text-primary-foreground",E&&"cursor-not-allowed opacity-50"),onClick:E?void 0:O,disabled:E,title:E?void 0:f?"Hide indentation":"Show indentation",children:(0,a.jsx)(g.A,{className:"h-3.5 w-3.5"})})}),E&&(0,a.jsxs)(k.Et,{className:"w-56 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"Indentation unavailable"}),(0,a.jsx)("p",{className:"mt-1 text-muted-foreground",children:"Disabled for deeply nested trees to maintain readability."})]})]}),"json"!==x&&M&&(0,a.jsx)(T.$,{variant:A?"default":"ghost",size:"icon",className:(0,c.cn)("h-7 w-7",A&&"bg-primary text-primary-foreground"),onClick:M,title:A?"Hide milliseconds":"Show milliseconds",children:(0,a.jsx)(y.A,{className:"h-3.5 w-3.5"})}),"json"!==x&&d&&(0,a.jsxs)(S.m_,{children:[(0,a.jsx)(S.k$,{asChild:!0,children:(0,a.jsx)("span",{children:(0,a.jsx)(T.$,{variant:"ghost",size:"icon",className:(0,c.cn)("h-7 w-7",l&&"cursor-not-allowed opacity-50"),onClick:l?void 0:d,disabled:l,children:u&&!l?(0,a.jsx)(v.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(j.A,{className:"h-3.5 w-3.5"})})})}),(0,a.jsx)(S.ZI,{children:l?"Disabled for large traces":u?"Collapse all":"Expand all"})]}),m&&(0,a.jsxs)(k.jc,{openDelay:200,children:[(0,a.jsx)(k.d0,{asChild:!0,children:(0,a.jsxs)(S.m_,{children:[(0,a.jsx)(S.k$,{asChild:!0,children:(0,a.jsx)(T.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:D?void 0:()=>{L(!0),null==m||m(),setTimeout(()=>L(!1),1e3)},disabled:D,children:D?(0,a.jsx)(b.A,{className:"h-3.5 w-3.5 animate-spin"}):P?(0,a.jsx)(w.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(N.A,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(S.ZI,{children:D?"Loading data...":h?"Copy as JSON (cache only
1)":"Copy as JSON"})]})}),h&&!D&&(0,a.jsxs)(k.Et,{className:"w-64 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"Cache-only mode"}),(0,a.jsx)("p",{className:"mt-1 text-muted-foreground",children:"For large traces, only expanded observations include full I/O data."}),void 0!==i&&void 0!==o&&(0,a.jsxs)("p",{className:"mt-1.5 text-muted-foreground",children:[(0,a.jsxs)("span",{className:"font-medium",children:[i," of ",o]})," ","observations loaded"]})]})]}),p&&(0,a.jsxs)(k.jc,{openDelay:200,children:[(0,a.jsx)(k.d0,{asChild:!0,children:(0,a.jsxs)(S.m_,{children:[(0,a.jsx)(S.k$,{asChild:!0,children:(0,a.jsx)(T.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:D?void 0:p,disabled:D,children:D?(0,a.jsx)(b.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(C.A,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(S.ZI,{children:D?"Loading data...":h?"Download as JSON (cache only)":"Download as JSON"})]})}),h&&!D&&(0,a.jsxs)(k.Et,{className:"w-64 text-sm",sideOffset:8,children:[(0,a.jsx)("p",{className:"font-medium",children:"Cache-only mode"}),(0,a.jsx)("p",{className:"mt-1 text-muted-foreground",children:"For large traces, only expanded observations include full I/O data."}),void 0!==i&&void 0!==o&&(0,a.jsxs)("p",{className:"mt-1.5 text-muted-foreground",children:[(0,a.jsxs)("span",{className:"font-medium",children:[i," of ",o]})," ","observations loaded"]})]})]})]})]})});var O=n(85369),A=n(95140),M=n(93367),D=n(55803);let P=(0,r.memo)(function(e){let{node:t,traceId:n,projectId:s,currentView:l="pretty",externalExpansionState:o,onExternalExpansionChange:i}=e,{data:d,isLoading:c,isError:u}=function(e){let{observationId:t,traceId:n,projectId:a,startTime:r,enabled:s}=e,{isBetaEnabled:l}=(0,D.I)(),o=M.FH.observations.byId.useQuery({observationId:t,traceId:n,projectId:a,startTime:r},{enabled:s&&!l,staleTime:1/0,refetchOnWindowFocus:!1}),i=M.FH.events.batchIO.useQuery({projectId:a,observations:[{id:t,traceId:n}],minStartTime:r,maxStartTime:r,truncated:!1},{enabled:s&&l,staleTime:1/0,refetchOnWindowFocus:!1,select:e=>e[0]});return l?{data:i.data,isLoading:i.isLoading,error:i.error,isError:i.isError}:o}({observationId:t.id,traceId:n,projectId:s,startTime:t.startTime,enabled:!0}),m=(0,r.useMemo)(()=>{if(!d)return null;let e={};return null!==d.input&&void 0!==d.input&&(e.input=d.input),null!==d.output&&void 0!==d.output&&(e.output=d.output),null!==d.metadata&&void 0!==d.metadata&&(e.metadata=d.metadata),Object.keys(e).length>0?e:null},[d]);return(0,a.jsxs)("div",{className:"w-full",children:[c&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,a.jsx)(b.A,{className:"h-4 w-4 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:"Loading..."})]}),u&&(0,a.jsx)("div",{className:"flex h-full w-full items-center bg-destructive/10 px-6 py-2 text-xs text-destructive",children:"Failed to load data"}),m&&!c&&(0,a.jsx)(O.U,{json:m,currentView:"json-beta"===l?"pretty":l,isLoading:!1,showNullValues:!1,stickyTopLevelKey:!1,showObservationTypeBadge:!0,scrollable:!0,externalExpansionState:o,onExternalExpansionChange:i,className:"w-full [&_.border]:border-0 [&_.io-message-content]:p-0 [&_.rounded-sm]:rounded-none [&_td:first-child]:pl-6 [&_th:first-child]:pl-6 [&_th]:h-6 [&_th]:text-xs"}),!m&&!c&&!u&&(0,a.jsx)("div",{className:"py-2 pl-6 text-xs text-muted-foreground",children:"No input/output/metadata"})]})}),L=(0,r.memo)(function(e){let{treeLines:t,isLastSibling:n,depth:r}=e;return r<=0?null:(0,a.jsxs)("div",{className:"flex flex-shrink-0",children:[t.map((e,t)=>(0,a.jsx)("div",{className:"relative w-3",children:e&&(0,a.jsx)("div",{className:"absolute bottom-0 left-1.5 top-0 w-px bg-border"})},t)),(0,a.jsxs)("div",{className:"relative w-3",children:[(0,a.jsx)("div",{className:(0,c.cn)("absolute left-1.5 top-0 w-px bg-border",n?"h-1/2":"h-full")}),(0,a.jsx)("div",{className:"absolute left-1.5 top-1/2 h-px w-1.5 bg-border"})]})]})});var B=n(56664),R=n(67827),V=n.n(R);function z(e){let t=e.name||e.type,n=e.id.substring(0,8);return"".concat(t," (").concat(n,")")}let _=s.f.logView.batchFetch.concurrency;function F(e,t,n,a){return[["observations","byId"],{input:{observationId:e,traceId:t,projectId:n,startTime:a},type:"query"}]}function H(e){let{items:t,traceId:n,projectId:a}=e,s=M.FH.useUtils(),l=(0,A.jE)(),[o,i]=(0,r.useState)(!1),[d,c]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[p,h]=(0,r.useState)([]),x=(0,r.useCallback)(()=>t.filter(e=>"TRACE"!==e.node.type).map(e=>{let t={id:e.node.id,type:e.node.type,name:z(e.node),startTime:e.node.startTime,endTime:e.node.endTime,depth:e.node.depth}
1,r=F(e.node.id,n,a,e.node.startTime),s=l.getQueryData(r);return s&&(null!==s.input&&void 0!==s.input&&(t.input=s.input),null!==s.output&&void 0!==s.output&&(t.output=s.output),null!==s.metadata&&void 0!==s.metadata&&(t.metadata=s.metadata)),t}),[t,n,a,l]),f=(0,r.useCallback)(async()=>{i(!0),c(!1),h([]);try{let e=t.filter(e=>"TRACE"!==e.node.type),r=[],o=[];for(let t of e){let e=F(t.node.id,n,a,t.node.startTime),s=l.getQueryData(e);if(s){let e={id:t.node.id,type:t.node.type,name:z(t.node),startTime:t.node.startTime,endTime:t.node.endTime,depth:t.node.depth};null!==s.input&&void 0!==s.input&&(e.input=s.input),null!==s.output&&void 0!==s.output&&(e.output=s.output),null!==s.metadata&&void 0!==s.metadata&&(e.metadata=s.metadata),r.push(e)}else o.push(t)}let d=[],c=V()(o,_),u=[];for(let e of c){let t=await Promise.all(e.map(async e=>{try{let t=await s.observations.byId.fetch({observationId:e.node.id,traceId:n,projectId:a,startTime:e.node.startTime}),r={id:e.node.id,type:e.node.type,name:z(e.node),startTime:e.node.startTime,endTime:e.node.endTime,depth:e.node.depth};return null!==t.input&&void 0!==t.input&&(r.input=t.input),null!==t.output&&void 0!==t.output&&(r.output=t.output),null!==t.metadata&&void 0!==t.metadata&&(r.metadata=t.metadata),r}catch(t){return d.push(e.node.id),{id:e.node.id,type:e.node.type,name:z(e.node),startTime:e.node.startTime,endTime:e.node.endTime,depth:e.node.depth}}}));u.push(...t)}let p=[...r,...u],x=new Map(e.map((e,t)=>[e.node.id,t]));return p.sort((e,t)=>{var n,a;return(null!=(n=x.get(e.id))?n:0)-(null!=(a=x.get(t.id))?a:0)}),m(p),h(d),i(!1),p}catch(e){throw c(!0),i(!1),Error("Failed to load observation data")}},[t,n,a,s,l]);return{data:u,isLoading:o,isError:d,failedObservationIds:p,loadAllData:f,buildDataFromCache:x,totalCount:t.filter(e=>"TRACE"!==e.node.type).length}}let J=(0,r.memo)(function(e){let{items:t,traceId:n,projectId:s,isCollapsed:l,onToggleCollapse:o}=e,{data:i,isLoading:d,isError:c,loadAllData:u,totalCount:m}=H({items:t,traceId:n,projectId:s});return(0,r.useEffect)(()=>{i||d||c||u()},[i,d,c,u]),(0,a.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[d&&(0,a.jsxs)("div",{className:"flex flex-1 items-center justify-center",children:[(0,a.jsx)(b.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,a.jsxs)("span",{className:"ml-2 text-sm text-muted-foreground",children:["Loading observations (0/",m,")..."]})]}),c&&!d&&(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,a.jsx)("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:"Failed to load observation data"})}),i&&!d&&(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsx)(B.GJ,{json:i,scrollable:!1,externalJsonCollapsed:l,onToggleCollapse:o,className:"h-full [&_.io-message-content]:border-none",codeClassName:"min-h-full"})}),!i&&!d&&!c&&(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"No observation data available"})})]})});var U=n(80539),W=n(54433),G=n(42661),$=n(57404),K=n(65637);let{prefetch:{rootMargin:Q,debounceMs:q},indentPx:X}=s.f.logView,Z=(0,r.memo)(function(e){var t,n;let{item:s,indentEnabled:l,projectId:o,traceId:i}=e,d=(0,r.useRef)(null),{prefetch:c}=(0,K.z)({projectId:o}),u=(0,r.useRef)(!1),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=d.current;if(!e||"TRACE"===s.node.type)return;u.current=!1;let t=new IntersectionObserver(e=>{let t=e[0];(null==t?void 0:t.isIntersecting)&&!u.current?m.current=setTimeout(()=>{u.current=!0,c(s.node.id,i,s.node.startTime)},q):(null==t?void 0:t.isIntersecting)||!m.current||(clearTimeout(m.current),m.current=null)},{rootMargin:Q});return t.observe(e),()=>{t.disconnect(),m.current&&clearTimeout(m.current)}},[s.node.id,s.node.type,s.node.startTime,i,c]);let p=z(s.node),h=null!=(n=null==(t=s.node.children)?void 0:t.length)?n:0,x=l?s.node.depth*X:0;return(0,a.jsxs)("div",{ref:d,className:"flex h-5 min-w-0 items-center gap-2",style:{paddingLeft:x},children:[(0,a.jsx)($.L,{type:s.node.type,isSmall:!0}),(0,a.jsx)("span",{className:"truncate",children:p}),h>0&&(0,a.jsxs)("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:[h," ",1===h?"item":"items"]})]})}),{virtualizationThreshold:Y,downloadThreshold:ee,rowHeight:{collapsed:et,expanded:e
1n},maxIndentDepth:ea}=s.f.logView,er=e=>{let{traceId:t,projectId:n,currentView:s="pretty"}=e,{roots:d,observations:c}=(0,l.f)(),{logViewMode:u,logViewTreeStyle:m}=(0,o.v)(),{formattedExpansion:p,setFormattedFieldExpansion:h}=(0,i.vG)(),x=c.length>=Y,g=c.length>=ee,y="logViewRows:".concat(t),v=(0,r.useMemo)(()=>{var e;return new Set(Object.entries(null!=(e=p[y])?e:{}).filter(e=>{let[,t]=e;return t}).map(e=>{let[t]=e;return t}))},[p,y]),j=(0,r.useCallback)(e=>{let t="function"==typeof e?e(v):e,n={};t.forEach(e=>{n[e]=!0}),h(y,n)},[v,h,y]),[b,w]=(0,r.useState)(""),[N,C]=(0,r.useState)(!1),{indentEnabled:T,setIndentEnabled:I,showMilliseconds:S,setShowMilliseconds:k}=function(){let[e,t]=(0,U.A)("logView-indentEnabled",!1),[n,a]=(0,U.A)("logView-showMilliseconds",!1);return{indentEnabled:e,setIndentEnabled:t,showMilliseconds:n,setShowMilliseconds:a}}(),O=(0,r.useMemo)(()=>0===d.length?0:Math.max(...d.map(e=>e.childrenDepth)),[d])>ea,M=T&&!O,D=(0,r.useMemo)(()=>"chronological"===u?function(e){let t=function(e){if(0===e.length)return[];let t=[],n=[...e];for(;n.length>0;){let e=n.pop();"TRACE"!==e.type&&t.push(e);for(let t=e.children.length-1;t>=0;t--)n.push(e.children[t])}return t}(e);return t.sort((e,t)=>e.startTime.getTime()-t.startTime.getTime()),t.map((e,n)=>
1({node:e,treeLines:[],isLastSibling:n===t.length-1}))}(d):function(e){if(0===e.length)return[];let t=[],n=[];if(1===e.length&&"TRACE"===e[0].type){let t=[...e[0].children].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime());for(let e=t.length-1;e>=0;e--)n.push({node:t[e],depth:0,treeLines:[],isLastSibling:e===t.length-1})}else{let t=[...e].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime());for(let e=t.length-1;e>=0;e--)n.push({node:t[e],depth:0,treeLines:[],isLastSibling:e===t.length-1})}for(;n.length>0;){let e=n.pop();if(t.push({node:e.node,treeLines:e.treeLines,isLastSibling:e.isLastSibling}),e.node.children.length>0){let t=[...e.node.children].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime());for(let a=t.length-1;a>=0;a--){let r=t[a],s=a===t.length-1;n.push({node:r,depth:e.depth+1,treeLines:[...e.treeLines,!s],isLastSibling:s})}}}return t}(d),[d,u]),B=(0,r.useMemo)(()=>(function(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.filter(e=>{var t,a;let r=null!=(a=null==(t=e.node.name)?void 0:t.toLowerCase())?a:"",s=e.node.type.toLowerCase(),l=e.node.id.toLowerCase();return r.includes(n)||s.includes(n)||l.includes(n)})})(D,b),[D,b]),R="chronological"===u?"flat":m,V=function(e){let{indentEnabled:t,showMilliseconds:n,projectId:s,traceId:l}=e;return(0,r.useMemo)(()=>[{key:"observation",header:"Observation",width:"flex-1",render:e=>(0,a.jsx)(Z,{item:e,indentEnabled:t,projectId:s,traceId:l})},{key:"depth",header:"Depth",width:"w-12",align:"right",render:e=>(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.node.depth>=0?"L".concat(e.node.depth):"-"})},{key:"start",header:"Start",width:n?"w-20":"w-12",align:"right",render:e=>(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:function e(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t<0)return"-"+e(-t,n);let a=Math.floor(t/1e3),r=Math.floor(a/60),s=a%60;return n?"".concat(r,":").concat(s.toString().padStart(2,"0"),".").concat((t%1e3).toString().padStart(3,"0")):"".concat(r,":").concat(s.toString().padStart(2,"0"))}(e.node.startTimeSinceTrace,n)})},{key:"duration",header:"Duration",width:"w-16",align:"right",render:e=>(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:function(e,t){if(!t)return"-";let n=t.getTime()-e.getTime();if(n<0)return"-";if(n<1e3)return"".concat(Math.round(n),"ms");if(n<6e4)return"".concat((n/1e3).toFixed(1),"s");let a=Math.floor(n/1e3),r=Math.floor(a/60);return"".concat(r,":").concat((a%60).toString().padStart(2,"0"))}(e.node.startTime,e.node.endTime)})}],[t,n,s,l])}({indentEnabled:M,showMilliseconds:S,projectId:n,traceId:t}),z=(0,r.useCallback)(e=>"indented"!==R||e.node.depth<=0?null:(0,a.jsx)(L,{treeLines:e.treeLines,isLastSibling:e.isLastSibling,depth:e.node.depth}),[R]),_=(0,r.useCallback)(e=>{let r="log:".concat(e.node.id);return(0,a.jsx)(P,{node:e.node,traceId:t,projectId:n,currentView:s,externalExpansionState:p[r],onExternalExpansionChange:e=>h(r,e)})},[t,n,s,p,h]),F=(0,r.useMemo)(()=>0!==B.length&&B.every(e=>v.has(e.node.id)),[B,v]),$=(0,r.useCallback)(()=>{F?j(new Set):j(new Set(B.map(e=>e.node.id)))},[F,B,j]),K=H({items:B,traceId:t,projectId:n}),{loaded:Q}=function(e){let{items:t,traceId:n,projectId:a}=e,s=(0,A.jE)();return(0,r.useMemo)(()=>{let e=t.filter(e=>"TRACE"!==e.node.type),r=e.length,l=0;for(let t of e){let e=[["observations","byId"],{input:{observationId:t.node.id,traceId:n,projectId:a,startTime:t.node.startTime},type:"query"}],r=s.getQueryState(e);(null==r?void 0:r.status)==="success"&&l++}return{loaded:l,total:r}},[t,n,a,s])}({items:B,traceId:t,projectId:n}),{handleCopyJson:q,handleDownloadJson:X,isDownloadOrCopyLoading:er}=function(e){let{traceId:t,isDownloadCacheOnly:n,allObservationsData:a,isLoadingAllData:s,failedObservationIds:l,loadAllData:o,buildDataFromCache:i}=e,[d,c]=(0,r.useState)(!1),u=(0,r.useCallback)(e=>{let n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),a=URL.createObjectURL(n),r=document.createElement("a");r.href=a,r.download="trace-".concat(t,".json"),r.click(),URL.revokeObjectURL(a)},[t]),m=(0,r.useCallback)(async()=>
1{if(n)c(!0),setTimeout(()=>{let e=i();(0,G.e)(JSON.stringify(e,null,2)),W.oR.success("Copied to clipboard (cache only)"),c(!1)},0);else if(a)(0,G.e)(JSON.stringify(a,null,2)),l.length>0?W.oR.warning("Copied to clipboard. ".concat(l.length," observation").concat(1===l.length?"":"s"," failed to load and ").concat(1===l.length?"is":"are"," missing I/O data.")):W.oR.success("Copied to clipboard");else{c(!0);try{let e=await o();(0,G.e)(JSON.stringify(e,null,2)),l.length>0?W.oR.warning("Copied to clipboard. ".concat(l.length," observation").concat(1===l.length?"":"s"," failed to load and ").concat(1===l.length?"is":"are"," missing I/O data.")):W.oR.success("Copied to clipboard")}finally{c(!1)}}},[n,a,o,i,l]);return{handleCopyJson:m,handleDownloadJson:(0,r.useCallback)(async()=>{if(n)c(!0),setTimeout(()=>{u(i()),W.oR.success("Downloaded trace data (cache only)"),c(!1)},0);else if(a)u(a),l.length>0?W.oR.warning("Downloaded trace data. ".concat(l.length," observation").concat(1===l.length?"":"s"," failed to load and ").concat(1===l.length?"is":"are"," missing I/O data.")):W.oR.success("Downloaded trace data");else{c(!0);try{let e=await o();u(e),l.length>0?W.oR.warning("Downloaded trace data. ".concat(l.length," observation").concat(1===l.length?"":"s"," failed to load and ").concat(1===l.length?"is":"are"," missing I/O data.")):W.oR.success("Downloaded trace data")}finally{c(!1)}}},[n,a,o,i,u,l]),isDownloadOrCopyLoading:d||s}}({traceId:t,isDownloadCacheOnly:g,allObservationsData:K.data,isLoadingAllData:K.isLoading,failedObservationIds:K.failedObservationIds,loadAllData:K.loadAllData,buildDataFromCache:K.buildDataFromCache}),es=(0,r.useCallback)(()=>{C(e=>!e)},[]),el=0===D.length,eo=!el&&0===B.length;return(0,a.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden","data-sentry-component":"TraceLogView","data-sentry-source-file":"TraceLogView.tsx",children:[(0,a.jsx)(E,{searchQuery:b,onSearchChange:w,isVirtualized:x,observationCount:c.length,loadedObservationCount:Q,onToggleExpandAll:$,allRowsExpanded:F,onCopyJson:q,onDownloadJson:X,isDownloadCacheOnly:g,isDownloadLoading:er,currentView:s,indentEnabled:M,indentDisabled:O,onToggleIndent:()=>I(!T),showMilliseconds:S,onToggleMilliseconds:()=>k(!S),"data-sentry-element":"LogViewToolbar","data-sentry-source-file":"TraceLogView.tsx"}),el&&(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"No observations in this trace"})}),eo&&(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:['No observations match "',b,'"']})}),B.length>0&&"json"===s&&!x&&(0,a.jsx)(J,{items:B,traceId:t,projectId:n,isCollapsed:N,onToggleCollapse:es}),B.length>0&&("pretty"===s||"json-beta"===s)&&(0,a.jsx)(f,{items:B,columns:V,getItemKey:e=>e.node.id,expandable:!0,renderExpanded:_,expandedKeys:v,onExpandedKeysChange:j,virtualized:x,overscan:100,collapsedRowHeight:et,expandedRowHeight:en,renderRowPrefix:z})]})}},26202:(e,t,n)=>{n.d(t,{A:()=>l});var a=n(96810),r=n(47805);let s=e=>{let t=sessionStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch(t){return sessionStorage.removeItem(e),null}};function l(e){let t=(0,r.et)(null!=e?e:""),[n,l]=(0,a.useState)(()=>s(t));return(0,a.useEffect)(()=>
1{l(s(t))},[t]),{playgroundCache:n,setPlaygroundCache:e=>{null===e?sessionStorage.removeItem(t):sessionStorage.setItem(t,JSON.stringify(e))}}}},27185:(e,t,n)=>{n.d(t,{Zy:()=>a.normalizeOutput,ey:()=>a.cleanLegacyOutput,kz:()=>a.normalizeInput,vm:()=>a.combineInputOutputMessages,zx:()=>a.extractAdditionalInput});var a=n(45596)},28018:(e,t,n)=>{n.d(t,{q:()=>r});var a=n(80539);function r(e,t){let[n,r]=(0,a.A)("jsonBetaEnabled",'"json-beta"'===localStorage.getItem("jsonViewPreference"));return{jsonBetaEnabled:n,selectedViewTab:"pretty"===e?"pretty":"json",handleViewTabChange:e=>{"pretty"===e?t("pretty"):t(n?"json-beta":"json")},handleBetaToggle:e=>{r(e),t(e?"json-beta":"json")}}}},32165:(e,t,n)=>{n.d(t,{o:()=>l});var a=n(73154),r=n(81509),s=n(173);function l(e){let{count:t}=e;return t?(0,a.jsxs)("span",{className:"relative mr-1 text-xs","data-sentry-component":"CommentCountIcon","data-sentry-source-file":"CommentCountIcon.tsx",children:[(0,a.jsx)(s.A,{className:"h-4 w-4","data-sentry-element":"MessageCircleMore","data-sentry-source-file":"CommentCountIcon.tsx"}),(0,a.jsx)("span",{className:(0,r.cn)("absolute -top-0.5 left-2.5 flex max-h-[0.8rem] min-w-[0.8rem] items-center justify-center rounded-sm border border-muted-foreground bg-muted-foreground px-[0.2rem] text-[8px] text-muted shadow-sm dark:bg-muted dark:text-muted-foreground"),children:t>99?"99+":t})]}):null}},33749:(e,t,n)=>{n.d(t,{p:()=>r});var a=n(66449);function r(e){var t;return{...e,content:null!=(t=e.content)?t:"",id:(0,a.A)()}}},35545:(e,t,n)=>{n.d(t,{jh:()=>d,vG:()=>i});var a=n(73154),r=n(96810),s=n(77260);let l={formatted:"trace2-expansion:formatted",json:"trace2-expansion:json",advancedJson:"trace2-expansion:advanced-json"},o=(0,r.createContext)({formattedExpansion:{input:{},output:{},metadata:{}},setFormattedFieldExpansion:()=>{},jsonExpansion:{input:!0,output:!0,metadata:!0},setJsonFieldExpansion:()=>{},advancedJsonExpansion:{},setAdvancedJsonExpansion:()=>{}}),i=()=>(0,r.useContext)(o);function d(e){let{children:t}=e,[n,i]=(0,s.A)(l.formatted,{input:{},output:{},metadata:{}}),[d,c]=(0,s.A)(l.json,{input:!0,output:!0,metadata:!0}),[u,m]=(0,s.A)(l.advancedJson,{}),p=(0,r.useCallback)((e,t)=>{i(n=>({...n,[e]:t}))},[i]),h=(0,r.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[c]),x=(0,r.useCallback)(e=>{m(e)},[m]);return(0,a.jsx)(o.Provider,{value:{formattedExpansion:n,setFormattedFieldExpansion:p,jsonExpansion:d,setJsonFieldExpansion:h,advancedJsonExpansion:u,setAdvancedJsonExpansion:x},"data-sentry-element":"JsonExpansionContext.Provider","data-sentry-component":"JsonExpansionProvider","data-sentry-source-file":"JsonExpansionContext.tsx",children:t})}},37982:(e,t,n)=>{n.d(t,{G:()=>p});var a=n(73154),r=n(96810),s=n(31642),l=n(92273),o=n(81509),i=n(86843),d=n(95266),c=n(97638);function u(e){return e.length>0&&"object"==typeof e[0]&&"options"in e[0]&&Array.isArray(e[0].options)}function m(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t&&"id"in e&&"id"in t?e.id===t.id:e===t}function p(e){var t;let{options:n,value:p,onValueChange:h,placeholder:x="Select option...",emptyText:f="No option found.",searchPlaceholder:g="Search...",disabled:y=!1,className:v,name:j}=e,[b,w]=r.useState(!1),N=r.useMemo(()=>{if(u(n)){for(let e of n){let t=e.options.find(e=>m(e.value,p));if(t)return t}return}return n.find(e=>m(e.value,p))},[n,p]);return(0,a.jsxs)(c.AM,{open:b,onOpenChange:w,"data-sentry-element":"Popover","data-sentry-component":"Combobox","data-sentry-source-file":"combobox.tsx",children:[(0,a.jsx)(c.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"combobox.tsx",children:(0,a.jsxs)(i.$,{variant:"outline",role:"combobox","aria-expanded":b,className:(0,o.cn)("w-full justify-between text-xs font-normal",!p&&"text-muted-foreground",v),disabled:y,name:j,"data-sentry-element":"Button","data-sentry-source-file":"combobox.tsx",children:[(0,a.jsx)("span",{className:"truncate",children:N?null!=(t=N.label)?t:String(N.value):x}),(0,a.jsx)(s.A,{className:"ml-2 h-4 w-4 shrink-0 opacity-50","data-sentry-element":"ChevronsUpDown","data-sentry-source-file":"combobox.tsx"})]})}),(0,a.jsx)(c.hl,{className:"w-[var(--radix-popover-trigger-width)] p-0","data-sentry-element":"PopoverContent","data-sentry-source-file":"combobox.tsx",children:(0,a.jsxs)(d.uB,{"data-sentry-element":"Command","data-sentry-source-file":"combobox.tsx",children:[(0,a.jsx)(d.G7,{placeholder:g,className:"text-xs","data-sentry-element":"CommandInput","data-sentry-source-file":"combobox.tsx"}),(0,a.jsxs)(d.oI,{"data-sentry-element":"CommandList","data-sentry-source-file":"combobox.tsx",children:[(0,a.jsx)(d.xL,{"data-sentry-element":"CommandEmpty","data-sentry-source-file":"combobox.tsx",children:f}),u(n)?n.map((e,t)=>(0,a.jsx)(d.L$,{heading:e.heading,children:e.options.map(e=>{var t,n;return(0,a.jsxs)(d.h_,{value:null!=(t=e.label)?t:String(e.value),disabled:e.disabled,onSelect:()=>{!e.disabled&&h&&(h(e.value),w(!1))},className:(0,o.cn)("text-xs",e.disabled&&"text-muted-foreground line-through"),children:[(0,a.jsx)(l.A,{className:(0,o.cn)("mr-2 h-4 w-4",m(p,e.value)?"opacity-100":"opacity-0")}),null!=(n=e.label)?n:String(e.value)]},"object"==typeof e.value?e.value.id:String(e.value))})},t)):(0,a.jsx)(d.L$,{children:n.map(e=>{var t,n;return(0,a.jsxs)(d.h_,{value:null!=(t=e.label)?t:String(e.value),disabled:e.disabled,onSelect:()=>{!e.disabled&&h&&(h(e.value),w(!1))},className:(0,o.cn)("text-xs",e.disabled&&"text-muted-foreground line-through"),children:[(0,a.jsx)(l.A,{className:(0,o.cn)("mr-2 h-4 w-4",m(p,e.value)?"opacity-100":"opacity-0")}),null!=(n=e.label)?n:String(e.value)]},"object"==typeof e.value?e.value.id:String(e.value))})})]})]})})]})}},41547:(e,t,n)=>{n.d(t,{Iw:()=>d,U0:()=>o,Wp:()=>i,pB:()=>c});var a=n(73154),r=n(96810),s=n(5746),l=n(81509);let o=r.forwardRef((e,t)=>
1{let{className:n,...r}=e;return(0,a.jsx)(s.bL,{ref:t,className:(0,l.cn)("flex h-full w-full flex-col overflow-hidden",n),...r})});o.displayName=s.bL.displayName;let i=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(s.B8,{ref:t,className:(0,l.cn)("inline-flex h-8 items-center justify-start border-b bg-transparent",n),...r})});i.displayName=s.B8.displayName;let d=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(s.l9,{ref:t,className:(0,l.cn)("inline-flex h-full items-center justify-center whitespace-nowrap rounded-none border-b-4 border-transparent px-2 py-0.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-primary-accent data-[state=active]:bg-transparent data-[state=active]:shadow-none",n),...r})});d.displayName=s.l9.displayName;let c=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(s.UC,{ref:t,className:(0,l.cn)("mt-2 h-full ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[state=inactive]:hidden",n),...r})});c.displayName=s.UC.displayName},45607:(e,t,n)=>{n.d(t,{T:()=>d,v:()=>i});var a=n(73154),r=n(96810),s=n(45596),l=n(80539);let o=(0,r.createContext)(null);function i(){let e=(0,r.useContext)(o);if(!e)throw Error("useViewPreferences must be used within a ViewPreferencesProvider");return e}function d(e){let{children:t,traceContext:n="fullscreen"}=e,i="peek"===n,[d,c]=(0,l.A)("durationOnObservationTree",!0),[u,m]=(0,l.A)("costTokensOnObservationTree",!0),[p,h]=(0,l.A)("scoresOnObservationTree",!0),[x,f]=(0,l.A)("colorCodeMetricsOnObservationTree",!0),[g,y]=(0,l.A)("showComments",!0),[v,j]=(0,l.A)("showGraph",!0),[b,w]=(0,l.A)("minObservationLevel",s.ObservationLevel.DEFAULT),[N,C]=(0,l.A)("logViewMode","chronological"),[T,I]=(0,l.A)("logViewTreeStyle","flat"),[S,k]=(0,l.A)("jsonViewPreference","pretty"),[E,O]=(0,l.A)("jsonBetaEnabled",'"json-beta"'===localStorage.getItem("jsonViewPreference")),A=(0,r.useMemo)(()=>({showDuration:d,setShowDuration:c,showCostTokens:u,setShowCostTokens:m,showScores:p,setShowScores:h,colorCodeMetrics:x,setColorCodeMetrics:f,showComments:g,setShowComments:y,showGraph:v,setShowGraph:j,minObservationLevel:b,setMinObservationLevel:w,isPeekMode:i,logViewMode:N,setLogViewMode:C,logViewTreeStyle:T,setLogViewTreeStyle:I,jsonViewPreference:S,setJsonViewPreference:k,jsonBetaEnabled:E,setJsonBetaEnabled:O}),[d,c,u,m,p,h,x,f,g,y,v,j,b,w,i,N,C,T,I,S,k,E,O]);return(0,a.jsx)(o.Provider,{value:A,"data-sentry-element":"ViewPreferencesContext.Provider","data-sentry-component":"ViewPreferencesProvider","data-sentry-source-file":"ViewPreferencesContext.tsx",children:t})}},46719:(e,t,n)=>{n.d(t,{P:()=>h});var a=n(73154),r=n(67716),s=n(97898),l=n(173),o=n(72459),i=n(58579),d=n(56664),c=n(68389),u=n.n(c),m=n(18328);let p=e=>{let{name:t,scores:n,compact:c,badgeClassName:p}=e,h=(0,m.A)();return(0,a.jsxs)(r.E,{variant:"tertiary",className:"flex items-center gap-1 ".concat(c?"px-1.5 leading-tight":"px-2.5"," text-xs font-normal").concat(p?" "+p:""),"data-sentry-element":"Badge","data-sentry-component":"ScoreGroupBadge","data-sentry-source-file":"grouped-score-badge.tsx",children:[(0,a.jsxs)("div",{className:"w-fit max-w-20 truncate ".concat(c?"leading-tight":""),title:t,children:[t,":"]}),(0,a.jsx)("div",{className:"flex items-center gap-1 text-nowrap",children:n.map((e,t)=>{var n,r,c;return(0,a.jsxs)("span",{className:"group/score ml-1 flex items-center gap-1 rounded-sm first:ml-0",children:[null!=(c=null!=(r=e.stringValue)?r:null==(n=e.value)?void 0:n.toFixed(2))?c:"",e.comment&&(0,a.jsxs)(s.jc,{children:[(0,a.jsx)(s.d0,{className:"inline-block",children:(0,a.jsx)(l.A,{className:"mb-[0.0625rem] !size-3"})}),(0,a.jsxs)(s.Et,{className:"max-h-[50dvh] overflow-y-auto whitespace-normal break-normal text-xs",children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap",children:e.comment}),"executionTraceId"in e&&e.executionTraceId&&h&&(0,a.jsxs)(u(),{href:"/project/".concat(h,"/traces/").concat(encodeURIComponent(e.executionTraceId)),className:"mt-2 flex items-center gap-1 text-blue-600 hover:underline",target:"_blank",children:[(0,a.jsx)(o.A,{className:"h-3 w-3"}),"View execution trace"]})]})]}),(e=>{if(!e.metadata)return!1;try{let t="string"==typeof e.metadata?JSON.parse(e.metadata):e.metadata;return Object.keys(t).length>0}catch(e){return!1}})(e)&&(0,a.jsxs)(s.jc,{children:[(0,a.jsx)(s.d0,{className:"inline-block",children:(0,a.jsx)(i.A,{className:"mb-[0.0625rem] !size-3"})}),(0,a.jsx)(s.Et,{className:"max-h-[50dvh] overflow-y-auto whitespace-normal break-normal rounded-md border-none p-0 text-xs",children:(0,a.jsx)(d.GJ,{codeClassName:"!rounded-md",json:e.metadata})})]}),(0,a.jsx)("span",{className:"group-last/score:hidden",children:","})]},t)})})]},t)},h=e=>{let{scores:t,maxVisible:n,compact:l,badgeClassName:o}=e,{visibleScores:i,hiddenScores:d}=((e,t)=>{let n=Object.entries(e).sort((e,t)=>
1{let[n]=e,[a]=t;return n<a?-1:1});return t?{visibleScores:n.slice(0,t),hiddenScores:n.slice(t)}:{visibleScores:n,hiddenScores:[]}})(t.reduce((e,t)=>(e[t.name]&&Array.isArray(e[t.name])?e[t.name].push(t):e[t.name]=[t],e),{}),n);return(0,a.jsxs)(a.Fragment,{children:[i.map(e=>{let[t,n]=e;return(0,a.jsx)(p,{name:t,scores:n,compact:l,badgeClassName:o},t)}),!!d.length&&(0,a.jsxs)(s.jc,{children:[(0,a.jsx)(s.d0,{className:"inline-block rounded-sm",children:(0,a.jsxs)(r.E,{className:"cursor-pointer ".concat(l?"px-0.5 py-0 leading-tight":"px-1"," text-xs font-medium").concat(o?" "+o:""),variant:"tertiary",children:["+",d.length]})}),(0,a.jsx)(s.Et,{className:"max-h-[300px] max-w-[200px] overflow-y-auto p-2",children:(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:d.map(e=>{let[t,n]=e;return(0,a.jsx)(p,{name:t,scores:n,compact:l,badgeClassName:o},t)})})})]})]})}},47805:(e,t,n)=>{n.d(t,{YG:()=>o,et:()=>l,i:()=>i,u:()=>r});var a=n(9476);let r="playgroundWindowIds",s=(e,t)=>{let n=t||a.y.DEFAULT_WINDOW_ID;return n===a.y.DEFAULT_WINDOW_ID?e.endsWith("_")?e.slice(0,-1):e:"".concat(e).concat(n)},l=e=>s("langfuse-playgroundCache_",e),o=e=>s("langfuse-llmModelName_",e),i=e=>s("langfuse-llmModelProvider_",e)},48977:(e,t,n)=>{n.d(t,{$H:()=>a,Mr:()=>s,Qi:()=>r});let a={DEFAULT:{text:"",bg:""},DEBUG:{text:"text-muted-foreground",bg:"bg-primary-foreground"},WARNING:{text:"text-dark-yellow",bg:"bg-light-yellow"},ERROR:{text:"text-dark-red",bg:"bg-light-red"}},r={DEFAULT:"ℹ️",DEBUG:"\uD83D\uDD0D",WARNING:"⚠️",ERROR:"\uD83D\uDEA8"},s=e=>e.replace(/Count$/,"").toUpperCase()}
1,50439:(e,t,n)=>{n.d(t,{g:()=>d});var a=n(96810),r=n(93367),s=n(45596),l=n(54218),o=n(84796),i=n.n(o);function d(e){var t,n,o,d,c;let{projectId:u,traceId:m,enabled:p=!0}=e,h=r.FH.events.byTraceId.useQuery({projectId:u,traceId:m,timestamp:e.timestamp},{enabled:p&&!!m,retry(e,t){var n;return(null==(n=t.data)?void 0:n.code)!=="UNAUTHORIZED"&&e<3},staleTime:6e4}),x=null==(t=h.data)?void 0:t.observations,f=(0,a.useMemo)(()=>(null==x?void 0:x.length)?x.find(e=>!e.parentObservationId):null,[x]),g=(0,a.useMemo)(()=>{if(!(null==x?void 0:x.length))return null;let e=x.map(e=>e.startTime.getTime());return{min:new Date(Math.min(...e)),max:new Date(Math.max(...e))}},[x]),y=r.FH.events.batchIO.useQuery({projectId:u,observations:f?[{id:f.id,traceId:m}]:[],minStartTime:null!=(o=null==g?void 0:g.min)?o:new Date,maxStartTime:null!=(d=null==g?void 0:g.max)?d:new Date},{enabled:p&&!!f&&!!g&&!!h.data,staleTime:6e4}),v=r.FH.events.scoresForTrace.useQuery({traceId:m,projectId:u,timestamp:e.timestamp},{enabled:p&&!!m,staleTime:6e4}),j=(0,a.useMemo)(()=>{var e,t;if(!(null==x?void 0:x.length))return null;let n=(0,s.filterAndValidateDbScoreList)({scores:null!=(t=v.data)?t:[],dataTypes:[...s.AGGREGATABLE_SCORE_TYPES,s.ScoreDataTypeEnum.CORRECTION],onParseError:e=>{console.error("[useEventsTraceData] Score validation error:",e)}}),[a,r]=i()(n,e=>e.dataType===s.ScoreDataTypeEnum.CORRECTION),o=(0,l.a1)(r),d=null==(e=y.data)?void 0:e[0],c=function(e){var t,n,a,r,s,l,o;let{events:i,traceId:d,rootIO:c}=e;if(0===i.length)throw Error("Cannot adapt empty events array to trace format");let u=[...i].sort((e,t)=>e.startTime.getTime()-t.startTime.getTime())[0],m=i.find(e=>!e.parentObservationId),p=i.map(e=>e.endTime).filter(e=>null!==e),h=p.length>0?Math.max(...p.map(e=>e.getTime())):null,x=h?h-u.startTime.getTime():void 0;return{trace:{id:d,projectId:u.projectId,name:null!=(n=null!=(t=null==m?void 0:m.name)?t:u.name)?n:null,timestamp:u.startTime,input:(null==c?void 0:c.input)?JSON.stringify(c.input):null,output:(null==c?void 0:c.output)?JSON.stringify(c.output):null,metadata:JSON.stringify(null!=(a=null==m?void 0:m.metadata)?a:{}),tags:[],bookmarked:!1,public:!1,release:null!=(r=u.version)?r:null,version:null!=(s=u.version)?s:null,userId:null!=(l=u.userId)?l:null,sessionId:null!=(o=u.sessionId)?o:null,environment:u.environment,latency:void 0!==x?x/1e3:void 0,createdAt:u.createdAt,updatedAt:u.updatedAt,rootObservationType:null==m?void 0:m.type,rootObservationId:null==m?void 0:m.id},observations:i.map(e=>({...e,traceId:d,metadata:"string"==typeof e.metadata?e.metadata:JSON.stringify(e.metadata),input:void 0,output:void 0}))}}({events:x,traceId:m,rootIO:d?{input:d.input,output:d.output}:void 0});return{...c.trace,observations:c.observations,scores:o,corrections:a}},[x,m,y.data,v.data]),b=null!=(c=null==(n=h.data)?void 0:n.cutoffObservationsAfterMaxCount)&&c;return{data:null!=j?j:void 0,isLoading:h.isLoading||v.isLoading,error:h.error||v.error,cutoffObservationsAfterMaxCount:b}}}
1,52402:(e,t,n)=>{n.d(t,{a:()=>a});function a(e,t,n){return"target-and-child-scores"===n?e:e.filter(e=>{var n,a;return"session"===t.type?e.sessionId===t.sessionId:e.traceId===t.traceId&&(null!=(n=e.observationId)?n:null)===(null!=(a=t.observationId)?a:null)})}},54218:(e,t,n)=>{n.d(t,{XM:()=>a,a1:()=>s});let a=e=>e?JSON.stringify(e):null,r=e=>{let{metadata:t,...n}=e;return{...n,metadata:a(t)}},s=e=>e.map(r)},61631:(e,t,n)=>{n.d(t,{l:()=>d,v:()=>i});var a=n(73154),r=n(96810),s=n(35664),l=n(33616),o=n(81509);let i=(0,l.F)("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-8 px-3",xs:"h-6 px-1.5",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),d=r.forwardRef((e,t)=>{let{className:n,variant:r,size:l,...d}=e;return(0,a.jsx)(s.b,{ref:t,className:(0,o.cn)(i({variant:r,size:l,className:n})),...d})});d.displayName=s.b.displayName},62145:(e,t,n)=>{n.d(t,{A:()=>u});var a=n(73154),r=n(96810),s=n(25277),l=n(81509),o=n(83129),i=n(91053);let d={added:{text:"bg-green-500/30",line:"bg-green-500/10"},removed:{text:"bg-destructive/60",line:"bg-destructive/10"},unchanged:{text:"bg-muted",line:"bg-muted"},empty:{text:"bg-muted",line:"bg-muted"}},c=(e,t)=>{let n=(0,o.b2)(e,t,{}),a=[],r=[];for(let e=0;e<n.length;e++){let t=n[e];if(t.added||t.removed)if(t.removed){let s=n[e+1];void 0!==s&&n[e+1].added?(a.push({value:t.value,type:"removed"}),r.push({value:s.value,type:"added"}),e++):(a.push({value:t.value,type:"removed"}),r.push({value:"",type:"empty"}))}else a.push({value:"",type:"empty"}),r.push({value:t.value,type:"added"});else a.push({value:t.value,type:"unchanged"}),r.push({value:t.value,type:"unchanged"})}return{leftWords:a,rightWords:r}},u=e=>{let{oldString:t,newString:n,oldLabel:o="Original Version",newLabel:u="New Version",oldSubLabel:m,newSubLabel:p,className:h}=e,[x,f]=(0,r.useState)({left:[],right:[]});(0,r.useEffect)(()=>{let e=[],a=[],r=(0,i.Pp)(t,n,{});for(let t=0;t<r.length;t++){let n=r[t];if(n.added||n.removed)if(n.removed)if(t<r.length-1&&r[t+1].added){let{leftWords:s,rightWords:l}=c(n.value,r[t+1].value);e.push({parts:s,text:"",type:"removed"}),a.push({parts:l,text:"",type:"added"}),t++}else e.push({text:n.value,type:"removed"}),a.push({text:"",type:"empty"});else e.push({text:"",type:"empty"}),a.push({text:n.value,type:"added"});else e.push({text:n.value,type:"unchanged"}),a.push({text:n.value,type:"unchanged"})}f({left:e,right:a})},[t,n]);let g=e=>{let{leftLine:t,rightLine:n}=e,r={unchanged:"",removed:d.removed.line,added:d.added.line,empty:d.empty},s=e=>e.parts?e.parts.map((e,t)=>(0,a.jsx)("span",{className:e.type?d[e.type].text:void 0,children:e.value},t)):e.text||"\xa0";return(0,a.jsxs)("div",{className:"grid grid-cols-2","data-sentry-component":"DiffRow","data-sentry-source-file":"DiffViewer.tsx",children:[(0,a.jsx)("div",{className:(0,l.cn)("whitespace-pre-wrap break-words border-r px-4 py-1 font-mono text-xs",r[t.type]),children:s(t)}),(0,a.jsx)("div",{className:(0,l.cn)("whitespace-pre-wrap break-words px-4 py-1 font-mono text-xs",r[n.type]),children:s(n)})]})};return t===n?(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"No changes"}):(0,a.jsx)("div",{className:(0,l.cn)("w-full",h),"data-sentry-component":"DiffViewer","data-sentry-source-file":"DiffViewer.tsx",children:(0,a.jsx)(s.Zp,{"data-sentry-element":"Card","data-sentry-source-file":"DiffViewer.tsx",children:(0,a.jsxs)(s.Wu,{className:"p-0","data-sentry-element":"CardContent","data-sentry-source-file":"DiffViewer.tsx",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-1 border-b border-r bg-muted px-4 py-2 text-xs font-semibold",children:[o,m&&(0,a.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:m,children:m})]}),(0,a.jsxs)("div",{className:"flex flex-row gap-1 border-b bg-muted px-4 py-2 text-xs font-semibold",children:[u,p&&(0,a.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:p,children:p})]})]}),(0,a.jsx)("div",{children:x.left.map((e,t)=>(0,a.jsx)(g,{leftLine:e,rightLine:x.right[t]},t))})]})})})}}
1,63748:(e,t,n)=>{n.d(t,{d:()=>r});var a=n(96810);function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:600,n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],r=(0,a.useRef)(e);return(0,a.useLayoutEffect)(()=>{r.current=e},[e]),(0,a.useMemo)(()=>(function(e,t){let n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=null;return function(){for(var s=arguments.length,l=Array(s),o=0;o<s;o++)l[o]=arguments[o];let i=a&&!r;return r&&clearTimeout(r),r=setTimeout(()=>{r=null,n=e(...l)},t),i&&(n=e(...l)),n}})(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.current(...t)},t,n),[t,n])}},65637:(e,t,n)=>{n.d(t,{z:()=>s});var a=n(93367),r=n(55803);function s(e){let{projectId:t}=e,n=a.FH.useUtils(),{isBetaEnabled:s}=(0,r.I)();return{prefetch:(e,a,r)=>{s?r&&n.events.batchIO.prefetch({projectId:t,observations:[{id:e,traceId:a}],minStartTime:r,maxStartTime:r,truncated:!1},{staleTime:3e5}):n.observations.byId.prefetch({observationId:e,traceId:a,projectId:t,startTime:r},{staleTime:3e5})}}}},66763:(e,t,n)=>{n.d(t,{$s:()=>l,Y:()=>s,aD:()=>o});var a=n(92065),r=n(45596);function s(e){let t=e.allObservations;if(e.rootObservationId)for(t=t.filter(t=>t.parentObservationId===e.rootObservationId||t.id===e.rootObservationId);;){let n=e.allObservations.filter(e=>e.parentObservationId&&!t.map(e=>e.id).includes(e.id)&&t.map(e=>e.id).includes(e.parentObservationId));if(0===n.length)break;t=[...t,...n]}return t.reduce((e,t)=>{if(!t.totalCost&&!t.inputCost&&!t.outputCost)return e;if(!t.totalCost&&(t.inputCost||t.outputCost)){let n=new a.A(null!=t.inputCost?t.inputCost:0),r=new a.A(null!=t.outputCost?t.outputCost:0),s=n.plus(r);return e?e.plus(s):s.isZero()?void 0:s}return t.totalCost?e?e.plus(t.totalCost):new a.A(t.totalCost):e},void 0)}let l=e=>{let{min:t,max:n,value:r}=e,s=new a.A(t||0),l=new a.A(n),o=new a.A(r).sub(s).div(l.sub(s)).toNumber();for(let[e,t]of[[.75,"text-dark-red"],[.5,"text-dark-yellow"]])if(o>=e)return t;return""};function o(e,t,n){let{tree:s,hiddenObservationsCount:l,nodeMap:o}=function(e,t,n){var s;let{nestedObservations:l,hiddenObservationsCount:o}=function(e,t){if(0===e.length)return{nestedObservations:[],hiddenObservationsCount:0};let n=e.filter(e=>(function(e){let t=[r.ObservationLevel.DEBUG,r.ObservationLevel.DEFAULT,r.ObservationLevel.WARNING,r.ObservationLevel.ERROR];if(!e)return t;let n=t.indexOf(e);return t.slice(n)})(t).includes(e.level)),a=e.length-n.length,s=new Set(e.map(e=>e.id));n.forEach(e=>{e.parentObservationId&&!s.has(e.parentObservationId)&&(e.parentObservationId=null)});let l=n.sort((e,t)=>e.startTime.getTime()-t.startTime.getTime()),o=new Map;for(let e of l)o.set(e.id,{...e,children:[]});let i=new Map;for(let e of o.values())if(e.parentObservationId){let t=o.get(e.parentObservationId);t&&t.children.push(e)}else i.set(e.id,e);for(let e of o.values())e.children.sort((e,t)=>e.startTime.getTime()-t.startTime.getTime());return{nestedObservations:Array.from(i.values()),hiddenObservationsCount:a}}(t,n),i=new Map,d=(e,t,n,a)=>{var r;let s=e.children.map(n=>d(n,t,e.startTime,a+1)),l=s.length>0?Math.max(...s.map(e=>e.childrenDepth))+1:0;return{id:e.id,type:e.type,name:null!=(r=e.name)?r:"",startTime:e.startTime,endTime:e.endTime,level:e.level,children:s,inputUsage:e.inputUsage,outputUsage:e.outputUsage,totalUsage:e.totalUsage,calculatedInputCost:e.inputCost,calculatedOutputCost:e.outputCost,calculatedTotalCost:e.totalCost,parentObservationId:e.parentObservationId,traceId:e.traceId,startTimeSinceTrace:e.startTime.getTime()-t.getTime(),startTimeSinceParentStart:null!==n?e.startTime.getTime()-n.getTime():null,depth:a,childrenDepth:l}},c=l.map(t=>d(t,e.timestamp,null,0)).map(e=>(function e(t,n){let r,s=t.children.map(t=>e(t,n));if(null!=t.calculatedTotalCost){let e=new a.A(t.calculatedTotalCost);e.isZero()||(r=e)}else if(null!=t.calculatedInputCost||null!=t.calculatedOutputCost){let e=new a.A(null!=t.calculatedInputCost?t.calculatedInputCost:0),n=new a.A(null!=t.calculatedOutputCost?t.calculatedOutputCost:0),s=e.plus(n);s.isZero()||(r=s)}let l=s.reduce((e,t)=>
1t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),o=r&&l?r.plus(l):r||l,i={...t,children:s,totalCost:o};return n.set(i.id,i),i})(e,i)),u=c.reduce((e,t)=>t.totalCost?e?e.plus(t.totalCost):t.totalCost:e,void 0),m=c.length>0?Math.max(...c.map(e=>e.childrenDepth))+1:0,p={id:"trace-".concat(e.id),type:"TRACE",name:null!=(s=e.name)?s:"",startTime:e.timestamp,endTime:null,children:c,latency:e.latency,totalCost:u,startTimeSinceTrace:0,startTimeSinceParentStart:null,depth:-1,childrenDepth:m};return i.set(p.id,p),{tree:p,hiddenObservationsCount:o,nodeMap:i}}(e,t,n),i=e=>{let t;if(null!=e.calculatedTotalCost){let n=new a.A(e.calculatedTotalCost);n.isZero()||(t=n)}else if(null!=e.calculatedInputCost||null!=e.calculatedOutputCost){let n=new a.A(null!=e.calculatedInputCost?e.calculatedInputCost:0),r=new a.A(null!=e.calculatedOutputCost?e.calculatedOutputCost:0),s=n.plus(r);s.isZero()||(t=s)}let n=e.children.reduce((e,t)=>{let n=i(t);return n?e?e.plus(n):n:e},void 0);return t&&n?t.plus(n):t||n},d="TRACE"===s.type?s.children.reduce((e,t)=>{let n=i(t);return n?e?e.plus(n):n:e},void 0):i(s),c=s.latency?1e3*s.latency:void 0,u=[],m=e=>{u.push({node:e,parentTotalCost:d,parentTotalDuration:c,observationId:"TRACE"===e.type?void 0:e.id}),e.children.forEach(m)};return m(s),{tree:s,hiddenObservationsCount:l,searchItems:u,nodeMap:o}}},69115:(e,t,n)=>{n.d(t,{N:()=>a});function a(e){if(0!==e.length)return e.sort((e,t)=>t.timestamp.getTime()-e.timestamp.getTime())[0]}}
1,70198:(e,t,n)=>{n.d(t,{H:()=>tu});var a=n(73154),r=n(96810),s=n(92125),l=n(80539);function o(e){return void 0!==e.scrollBy&&void 0!==e.document}let i=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,a=null==(e=null==n?void 0:n.enabled)||e,s=(0,r.useRef)(null),l=(0,r.useRef)(null),i=(0,r.useRef)(!1),d=(0,r.useRef)(null),c=(0,r.useRef)(!1),u=(0,r.useCallback)(()=>{let e=l.current,t=()=>{i.current=!0},n=e=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&t()};window.addEventListener("wheel",t,{passive:!0,once:!0}),window.addEventListener("touchmove",t,{passive:!0,once:!0}),window.addEventListener("keydown",n,{once:!0}),e&&!o(e)&&(e.addEventListener("wheel",t,{passive:!0,once:!0}),e.addEventListener("touchmove",t,{passive:!0,once:!0}),e.addEventListener("keydown",n,{once:!0}))},[]),m=(0,r.useCallback)(()=>{s.current=null,l.current=null,i.current=!1,c.current=!1},[]),p=(0,r.useCallback)(e=>{if(c.current)return;let t=s.current,n=l.current;if(null==t||!n)return;if(i.current)return void m();let a=e.getBoundingClientRect().top-t;if(1>Math.abs(a))return void m();o(n)?window.scrollBy({top:a,left:0}):n.scrollTop+=a,c.current=!0,m()},[m]),h=(0,r.useCallback)(()=>{var e,t;if(!a)return;let r=d.current;r&&r.getBoundingClientRect&&(s.current=r.getBoundingClientRect().top,l.current=null!=(t=null==n||null==(e=n.getScrollTarget)?void 0:e.call(n,r))?t:function(e){let t=e;for(;t&&t!==document.body;){if(function(e){let t=window.getComputedStyle(e).overflowY;return("auto"===t||"scroll"===t)&&e.scrollHeight>e.clientHeight}(t))return t;t=t.parentElement}return window}(r),i.current=!1,u())},[u,a,n]),x=(0,r.useCallback)(()=>{if(!a)return;let e=d.current;e&&p(e)},[a,p]);return(0,r.useLayoutEffect)(()=>{x()},t),[d,h]};var d=n(90859),c=n(1597),u=n(28018);function m(e){let{selectedView:t,onViewChange:n,compensateScrollRef:r}=e,{jsonBetaEnabled:s,selectedViewTab:l,handleViewTabChange:o,handleBetaToggle:i}=(0,u.q)(t,n);return(0,a.jsxs)("div",{className:"flex w-full flex-row items-center justify-start gap-1.5","data-sentry-component":"ViewModeToggle","data-sentry-source-file":"ViewModeToggle.tsx",children:[(0,a.jsx)(d.tU,{ref:r,className:"h-fit py-0.5",value:l,onValueChange:o,"data-sentry-element":"Tabs","data-sentry-source-file":"ViewModeToggle.tsx",children:(0,a.jsxs)(d.j7,{className:"h-fit p-0.5","data-sentry-element":"TabsList","data-sentry-source-file":"ViewModeToggle.tsx",children:[(0,a.jsx)(d.Xi,{value:"pretty",className:"h-fit px-1 text-xs","data-sentry-element":"TabsTrigger","data-sentry-source-file":"ViewModeToggle.tsx",children:"Formatted"}),(0,a.jsx)(d.Xi,{value:"json",className:"h-fit px-1 text-xs","data-sentry-element":"TabsTrigger","data-sentry-source-file":"ViewModeToggle.tsx",children:"JSON"})]})}),"json"===l&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.d,{size:"sm",checked:s,onCheckedChange:i}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Beta"})]})]})}var p=n(97974);function h(e){if(null==e)return 0;let t=typeof e;if("string"===t||"number"===t||"boolean"===t)return 1;if(Array.isArray(e)){let t=1;for(let n of e)t+=h(n);return t}if("object"===t&&null!==e){let t=1;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t+=h(e[n]));return t}return 1}function x(e){if(null===e)return"null";if(void 0===e)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;return"string"===t?"string":"number"===t?"number":"boolean"===t?"boolean":"object"}function f(e){let t=x(e);return"object"===t||"array"===t}function g(e){let t=x(e);return"array"===t?e.map((e,t)=>[t,e]):"object"===t?Object.entries(e):[]}function y(e){return e.join(".")}function v(e){if(0===e.length||1===e.length)return"$";let t=e.slice(1),n="$";for(let e of t)"number"==typeof e?n+="[".concat(e,"]"):/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?n+=".".concat(e):n+="['".concat(e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),"']");return n}let j=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n]};function b(e){try{let t=sessionStorage.getItem("json-expansion:".concat(e));if(null===t)return;return JSON.parse(t)}catch(e){return}}function w(e){if(!e.isExpanded||0===e.children.length){e.childOffsets=[],e.visibleDescendantCount=0;return}let t=[],n=0;
1e.children.forEach(e=>{n+=1+e.visibleDescendantCount,t.push(n)}),e.childOffsets=t,e.visibleDescendantCount=n}function N(e,t){e.rootNode.children.forEach(e=>{if("section-header"!==e.nodeType||!e.minHeight)return;let n=e.children.find(e=>"section-spacer"===e.nodeType);if(n)n.spacerHeight=Math.max(0,parseFloat(e.minHeight)-e.visibleDescendantCount*t)})}function C(e,t){let n=e.nodeMap.get(t);if(!n||!n.isExpandable)return e;let a=!n.isExpanded;return n.isExpanded=a,n.userExpand=a,a?T(n):(n.childOffsets=[],n.visibleDescendantCount=0),function(e){let t=e;for(;null!==t;)T(t),t=t.parentNode}(n.parentNode),e}function T(e){if(!e.isExpanded||0===e.children.length){e.childOffsets=[],e.visibleDescendantCount=0;return}let t=[],n=0;e.children.forEach(e=>{n+=1+e.visibleDescendantCount,t.push(n)}),e.childOffsets=t,e.visibleDescendantCount=n}function I(e){let t={};return e.allNodes.forEach(e=>{e.isExpandable&&void 0!==e.userExpand&&(t[e.id]=e.userExpand)}),t}function S(e,t,n,a){let r=[];if(n){let t;for(;null!==(t=n.exec(e));)r.push({start:t.index,end:t.index+t[0].length,text:t[0]})}else{let n=a?e:e.toLowerCase(),s=a?t:t.toLowerCase(),l=0;for(;;){let a=n.indexOf(s,l);if(-1===a)break;r.push({start:a,end:a+t.length,text:e.slice(a,a+t.length)}),l=a+1}}return r}function k(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t||""===t.trim())return[];let{caseSensitive:a=!1,useRegex:r=!1}=n,s=[],l=a?t:t.toLowerCase(),o=null;if(r)try{o=new RegExp(l,a?"g":"gi")}catch(e){console.warn("Invalid regex pattern:",t,e)}return e.allNodes.forEach((e,t)=>{S(String(e.key),l,o,a).forEach(n=>{s.push({rowIndex:t,rowId:e.id,matchType:"key",highlightStart:n.start,highlightEnd:n.end,matchedText:n.text})}),e.isExpandable||S(String(e.value),l,o,a).forEach(n=>{s.push({rowIndex:t,rowId:e.id,matchType:"value",highlightStart:n.start,highlightEnd:n.end,matchedText:n.text})})}),s}let E="monospace-char-width-0.7rem";function O(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0.7rem",[t,n]=(0,r.useState)(()=>{try{let e=sessionStorage.getItem(E);if(e){let t=parseFloat(e);if(!isNaN(t)&&t>0)return t}}catch(e){console.warn("[useMonospaceCharWidth] Failed to read from sessionStorage:",e)}return 6.2});return(0,r.useEffect)(()=>{if(6.2===t)try{let t=document.createElement("span");t.style.fontFamily="monospace",t.style.fontSize=e,t.style.visibility="hidden",t.style.position="absolute",t.style.whiteSpace="nowrap",t.textContent="0",document.body.appendChild(t);let a=t.getBoundingClientRect().width;if(document.body.removeChild(t),!isNaN(a)&&a>0){try{sessionStorage.setItem(E,a.toString())}catch(e){console.warn("[useMonospaceCharWidth] Failed to write to sessionStorage:",e)}n(a)}else console.warn("[useMonospaceCharWidth] Invalid measurement:",a,"- using default")}catch(e){console.error("[useMonospaceCharWidth] Measurement failed:",e)}},[e,t]),t}let A={background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",keyColor:"#0550ae",stringColor:"#0a3069",numberColor:"#0550ae",booleanColor:"#0550ae",nullColor:"hsl(var(--muted-foreground))",punctuationColor:"hsl(var(--muted-foreground))",lineNumberColor:"hsl(var(--muted-foreground))",expandButtonColor:"hsl(var(--muted-foreground))",copyButtonColor:"hsl(var(--muted-foreground))",hoverBackground:"hsl(var(--accent))",selectedBackground:"hsl(var(--accent))",searchMatchBackground:"rgba(255, 255, 0, 0.25)",searchCurrentBackground:"rgba(255, 255, 0, 0.4)",fontSize:"0.75rem",lineHeight:24,indentSize:12},M={...A,keyColor:"#79c0ff",stringColor:"#a5d6ff",numberColor:"#79c0ff",booleanColor:"#79c0ff",searchMatchBackground:"rgba(255, 255, 0, 0.2)",searchCurrentBackground:"rgba(255, 255, 0, 0.35)"};var D=n(10614),P=n(21),L=n(59757),B=n(3262),R=n(3444),V=n(2838),z=n(82822),_=n(42933),F=n(54959),H=n(97638),J=n(93367),U=n(18328);function W(e){let{src:t}=e;return t?(0,a.jsxs)("audio",{controls:!0,className:"w-full",preload:"metadata","data-sentry-component":"AudioPlayer","data-sentry-source-file":"MediaButtonGroup.tsx",children:[(0,a.jsx)("source",{src:t}),"Your browser does not support the audio element."]}):null}function G(e){let{src:t}=e;return t?(0,a.jsxs)("video",{controls:!0,className:"w-full",preload:"metadata",playsInl
1ine:!0,"data-sentry-component":"VideoPlayer","data-sentry-source-file":"MediaButtonGroup.tsx",children:[(0,a.jsx)("source",{src:t}),"Your browser does not support the video element."]}):null}function $(e){let{src:t}=e;return t?(0,a.jsx)("button",{onClick:()=>{window.open(t,"_blank","noopener,noreferrer")},className:"h-24 w-24 overflow-hidden rounded-md border bg-muted transition-opacity hover:opacity-80","aria-label":"Open image in new tab","data-sentry-component":"ImagePreview","data-sentry-source-file":"MediaButtonGroup.tsx",children:(0,a.jsx)("img",{src:t,alt:"Media preview",className:"h-full w-full object-cover"})}):null}function K(e){let{mediaItem:t}=e,n=(0,U.A)(),{data:r}=J.FH.media.getById.useQuery({mediaId:t.mediaId,projectId:n},{enabled:!!n,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,staleTime:33e5}),s=null==r?void 0:r.url;if(!s)return null;let l=t.contentType;return l.startsWith("image")?(0,a.jsx)($,{src:s}):l.startsWith("audio")?(0,a.jsx)(W,{src:s}):l.startsWith("video")?(0,a.jsx)(G,{src:s}):(0,a.jsx)(F.P,{mediaAPIReturnValue:t,asFileIcon:!0})}function Q(e){let{media:t}=e,[n,s]=(0,r.useState)(null),[l,o]=(0,r.useState)(null),i=(0,r.useRef)(null),d=(0,r.useRef)(null),c=(0,r.useMemo)(()=>{let e=[],n=t.filter(e=>e.contentType.startsWith("image")),a=t.filter(e=>e.contentType.startsWith("audio")),r=t.filter(e=>e.contentType.startsWith("video")),s=t.filter(e=>!e.contentType.startsWith("image")&&!e.contentType.startsWith("audio")&&!e.contentType.startsWith("video"));return n.length>0&&e.push({category:"image",items:n,icon:R.A}),a.length>0&&e.push({category:"audio",items:a,icon:V.A}),r.length>0&&e.push({category:"video",items:r,icon:z.A}),s.length>0&&e.push({category:"document",items:s,icon:_.A}),e},[t]);return 0===c.length?null:(0,a.jsx)("div",{className:"flex items-center gap-1",onClick:e=>e.stopPropagation(),"data-sentry-component":"MediaButtonGroup","data-sentry-source-file":"MediaButtonGroup.tsx",children:c.map(e=>(0,a.jsxs)(H.AM,{open:n===e.category,onOpenChange:t=>{s(t?e.category:null),t||o(null)},children:[(0,a.jsx)(H.Wv,{asChild:!0,children:(0,a.jsxs)("button",{className:"relative flex h-6 w-6 items-center justify-center rounded hover:bg-accent",title:"".concat(e.items.length," ").concat(e.category," file").concat(e.items.length>1?"s":""),onMouseEnter:()=>{d.current&&(clearTimeout(d.current),d.current=null),s(e.category)},onMouseLeave:()=>{i.current!==e.category&&l!==e.category&&(d.current=setTimeout(()=>{s(null)},300))},onPointerDown:t=>{t.stopPropagation(),l===e.category?(o(null),s(null),i.current=null):(o(e.category),s(e.category),i.current=e.category,setTimeout(()=>{i.current=null},200))},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:[(0,a.jsx)(e.icon,{className:"h-3.5 w-3.5"}),e.items.length>1&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-primary text-[9px] font-medium text-primary-foreground",children:e.items.length})]})}),(0,a.jsx)(H.hl,{className:"w-auto max-w-md p-2",align:"end",side:"bottom",onMouseEnter:()=>{d.current&&(clearTimeout(d.current),d.current=null),(null===l||l===e.category)&&s(e.category)},onMouseLeave:()=>{l!==e.category&&(d.current=setTimeout(()=>{s(null)},300))},children:(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.items.map(e=>(0,a.jsx)(K,{mediaItem:e},e.mediaId))})})]},e.category))})}function q(e){let{title:t,context:n,media:r,commentCount:s}=e;return(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",cursor:"pointer",userSelect:"none",fontWeight:500},onClick:()=>n.setExpanded(!n.isExpanded),"data-sentry-component":"MultiSectionJsonViewerHeader","data-sentry-source-file":"MultiSectionJsonViewerHeader.tsx",children:[(0,a.jsx)("span",{style:{marginRight:"8px",width:"16px",display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.5},children:n.isExpanded?(0,a.jsx)(P.A,{size:14}):(0,a.jsx)(L.A,{size:14})}),(0,a.jsx)("span",{className:"text-xs font-medium",children:t}),(0,a.jsxs)("span",{style:{marginLeft:"8px",color:"#6b7280",fontWeight:400,fontSize:"0.65rem"}
1,children:[n.rowCount.toLocaleString()," keys"]}),void 0!==s&&s>0&&(0,a.jsxs)("span",{className:"text-muted-foreground",style:{marginLeft:"8px",display:"inline-flex",alignItems:"center",gap:"3px",fontSize:"0.65rem"},children:[(0,a.jsx)(B.A,{size:10}),s]}),(0,a.jsx)("div",{style:{marginLeft:"auto"},children:r&&r.length>0&&(0,a.jsx)(Q,{media:r})})]})}var X=n(88430),Z=n(51883);function Y(e){let{isExpanded:t,isExpandable:n,onClick:r,theme:s,isToggling:l=!1}=e;if(!n)return(0,a.jsx)("span",{className:"inline-block w-4"});let o=l?Z.A:t?P.A:L.A;return(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),r()},className:"inline-flex items-center justify-center transition-opacity hover:opacity-70 ".concat(l?"animate-spin":""),style:{width:"16px",height:"16px",color:s.expandButtonColor,background:"transparent",border:"none",cursor:l?"wait":"pointer",padding:0,opacity:l?.5:.3},"aria-label":l?"Processing...":t?"Collapse":"Expand",disabled:l,"data-sentry-component":"ExpandButton","data-sentry-source-file":"ExpandButton.tsx",children:(0,a.jsx)(o,{size:14,"data-sentry-element":"Icon","data-sentry-source-file":"ExpandButton.tsx"})})}function ee(e){let{lineNumber:t,theme:n,maxDigits:r=3}=e;return(0,a.jsx)("span",{className:"select-none",style:{display:"inline-block",width:"".concat(r,"ch"),textAlign:"right",marginRight:"8px",color:n.lineNumberColor,opacity:.3,fontFamily:"monospace",fontSize:n.fontSize},"data-sentry-component":"LineNumber","data-sentry-source-file":"LineNumber.tsx",children:t})}function et(e){let{row:t,theme:n,showLineNumber:r=!1,lineNumber:s,maxLineNumberDigits:l,searchMatch:o,isCurrentMatch:i=!1,matchCount:d,currentMatchIndexInRow:c,onToggleExpansion:u,stringWrapMode:m="wrap",className:p,isToggling:h=!1}=e,x=i?n.searchCurrentBackground:o?n.searchMatchBackground:"transparent";return(0,a.jsxs)("div",{className:p,style:{position:"relative",display:"flex",alignItems:"wrap"===m?"start":"center",minHeight:"".concat(n.lineHeight,"px"),paddingLeft:"4px",paddingRight:"4px",backgroundColor:x,fontSize:n.fontSize,lineHeight:"".concat(n.lineHeight,"px"),fontFamily:"monospace",transition:"background-color 0.15s ease"},"data-sentry-component":"JsonRowFixed","data-sentry-source-file":"JsonRowFixed.tsx",children:[r&&void 0!==s&&(0,a.jsx)(ee,{lineNumber:s,theme:n,maxDigits:l}),(0,a.jsx)(Y,{isExpanded:t.isExpanded,isExpandable:t.isExpandable,onClick:()=>null==u?void 0:u(t.id),theme:n,isToggling:h,"data-sentry-element":"ExpandButton","data-sentry-source-file":"JsonRowFixed.tsx"}),void 0!==d&&d>1&&(t.isExpandable&&!t.isExpanded||!t.isExpandable)&&(0,a.jsx)("span",{style:{position:"absolute",top:"2px",right:"2px",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0 4px",minWidth:"16px",height:"14px",fontSize:"9px",fontWeight:600,borderRadius:"7px",backgroundColor:n.searchMatchBackground,color:n.foreground,border:"1px solid ".concat(n.searchCurrentBackground),pointerEvents:"none"},title:t.isExpandable?"".concat(d," match").concat(1===d?"":"es"," in this section"):"".concat(d," match").concat(1===d?"":"es"," in this value"),children:void 0!==c?"".concat(c,"/").concat(d):d})]})}let en="rgba(147, 112, 219, 0.3)";function ea(e,t,n,a){if(!(null==a?void 0:a.length)&&(void 0===t||void 0===n))return[{text:e,type:null}];let r=[];void 0!==t&&void 0!==n&&r.push({start:t,end:n,type:"search"}),a&&a.forEach(e=>{r.push({start:e.start,end:e.end,type:"comment",preview:e.preview})}),r.sort((e,t)=>e.start-t.start);let s=[],l=0;return r.forEach(t=>{t.start>l&&s.push({text:e.slice(l,t.start),type:null});let n=Math.max(t.start,l),a=t.end;a>n&&(s.push({text:e.slice(n,a),type:t.type,preview:t.preview}),l=Math.max(l,a))}),l<e.length&&s.push({text:e.slice(l),type:null}),s}var er=n(53524);function es(e){let{keyName:t,theme:n,isArrayIndex:r,highlightStart:s,highlightEnd:l,commentRanges:o,className:i}=e,d=null!=r?r:function(e){if("number"==typeof e)return!0;let t=Number(e);return!isNaN(t)&&t>=0&&Number.isInteger(t)&&String(t)===e}(t),c=String(t),u=null==o?void 0:o.map(e=>({start:Math.max(0,e.start),end:Math.min(c.length,e.end),preview:e.preview})).filter(e=>e.end>0&&e.start<e.end),m=ea(c,s,l,u);return(0,a.jsx)("span",{className:i,style:{color:d?n.punctuationColor:n.keyColor,opacity:d?.5:1,fontFamily:"monospace",flexShrink:0,whiteSpace:"nowrap"},"data-sentry-component":"JsonKey","data-sentry-source-file":"JsonKey.tsx",children:m.map((e,t)=>
1{let r="search"===e.type?n.searchMatchBackground:"comment"===e.type?en:"transparent",s=(0,a.jsx)("span",{style:{backgroundColor:r},children:e.text},t);return"comment"===e.type&&e.preview?(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{asChild:!0,children:s}),(0,a.jsx)(er.ZI,{side:"top",align:"start",className:"max-w-xs px-2 py-1 text-xs",children:e.preview})]},t):s})})}var el=n(97898);function eo(e){let{value:t,maxLength:n,theme:s,highlightStart:l,highlightEnd:o,commentRanges:i}=e,d=t.length>n,c=d?t.slice(0,2*n):t,u=(0,r.useRef)(null),[m,p]=(0,r.useState)(void 0);(0,r.useEffect)(()=>{d&&u.current&&p(u.current.offsetWidth)},[d]);let h=ea(c,l,o,i);return d?(0,a.jsxs)(el.jc,{openDelay:300,closeDelay:100,"data-sentry-element":"HoverCard","data-sentry-component":"TruncatedString","data-sentry-source-file":"TruncatedString.tsx",children:[(0,a.jsx)(el.d0,{asChild:!0,"data-sentry-element":"HoverCardTrigger","data-sentry-source-file":"TruncatedString.tsx",children:(0,a.jsxs)("span",{ref:u,style:{color:s.stringColor,fontFamily:"monospace",cursor:"help",display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"bottom"},children:[(0,a.jsx)("span",{children:'"'}),h.map((e,t)=>{let n="search"===e.type?s.searchMatchBackground:"comment"===e.type?en:"transparent";return(0,a.jsx)("span",{style:{backgroundColor:n},children:e.text},t)}),(0,a.jsx)("span",{children:'"'})]})}),(0,a.jsx)(el.Et,{side:"bottom",align:"start",className:"p-0",style:{width:m?"".concat(m,"px"):void 0,minWidth:m?"".concat(m,"px"):void 0,maxWidth:m?"".concat(m,"px"):"28rem"},"data-sentry-element":"HoverCardContent","data-sentry-source-file":"TruncatedString.tsx",children:(0,a.jsx)("div",{className:"max-h-60 overflow-auto p-0.5",style:{fontFamily:"monospace",fontSize:s.fontSize,color:s.stringColor,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})})]}):(0,a.jsxs)("span",{style:{color:s.stringColor,fontFamily:"monospace"},children:['"',h.map((e,t)=>{let n="search"===e.type?s.searchMatchBackground:"comment"===e.type?en:"transparent",r=(0,a.jsx)("span",{style:{backgroundColor:n},children:e.text},t);return"comment"===e.type&&e.preview?(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{asChild:!0,children:r}),(0,a.jsx)(er.ZI,{side:"top",align:"start",className:"max-w-xs px-2 py-1 text-xs",children:e.preview})]},t):r}),'"']})}function ei(e){let{value:t,type:n,theme:r,isExpandable:s=!1,childCount:l,stringWrapMode:o="wrap",truncateStringsAt:i=null,highlightStart:d,highlightEnd:c,commentRanges:u,valueOffset:m=0,className:p}=e,h=null==u?void 0:u.map(e=>({start:Math.max(0,e.start-m),end:Math.max(0,e.end-m),preview:e.preview})).filter(e=>e.end>0&&e.start<e.end);if(s){let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50;switch(x(e)){case"array":{let t=e.length;return"Array(".concat(t,")")}case"object":{let t=Object.keys(e),n=t.length;if(0===n)return"{}";if(1===n)return"{".concat(t[0],"}");return"{".concat(n," keys}")}case"string":if(0===e.length)return'""';if(e.length>t)return'"'.concat(e.slice(0,t),'..."');return'"'.concat(e,'"');case"null":return"null";case"undefined":return"undefined";default:return String(e)}}(t);return(0,a.jsx)("span",{className:p,style:{color:r.punctuationColor,opacity:.4,fontFamily:"monospace",whiteSpace:"nowrap",flexShrink:0},children:e})}let f=(()=>{switch(n){case"string":return r.stringColor;case"number":return r.numberColor;case"boolean":return r.booleanColor;case"null":case"undefined":return r.nullColor;default:return r.foreground}})();if("string"===n){if("truncate"===o&&null!==i&&t.length>i)return(0,a.jsx)(eo,{value:t,maxLength:i,theme:r,highlightStart:d,highlightEnd:c,commentRanges:h});let e=ea(t,d,c,h);return(0,a.jsxs)("span",{className:p,style:{color:f,fontFamily:"monospace",whiteSpace:"wrap"===o?"pre-wrap":"nowrap",overflowWrap:"wrap"===o?"break-word":void 0,wordBreak:"wrap"===o?"break-word":void 0,display:"wrap"===o?"inline-block":void 0,maxWidth:"wrap"===o?"100%":void 0},children:['"',e.map((e,t)=>{let n="search"===e.type?r.searchMatchBackground:"comment"===e.type?en:"transparent",s=(0,a.jsx)("span",{style:{backgroundColor:n},children:e.text},t);return"comment"===e.type&&e.preview?(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{asChild:!0,children:s}),(0,a.jsx)(er.ZI,{side:"top",align:"start",className:"max-w-xs px-2 py-1 text-xs",children:e.preview})]},t):s}),'"']})}let g=ea((()=>{switch(n){case"null":return"null";case"undefined":return"undefined";default:return String(t)}})(),d,c,h);return(0,a.jsx)("span",{className:p,style:{color:f,fontFamily:"monospace"},"data-sentry-component":"JsonValue","data-sentry-source-file":"JsonValue.tsx",children:g.map((e,t)=>
1{let n="search"===e.type?r.searchMatchBackground:"comment"===e.type?en:"transparent",s=(0,a.jsx)("span",{style:{backgroundColor:n},children:e.text},t);return"comment"===e.type&&e.preview?(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{asChild:!0,children:s}),(0,a.jsx)(er.ZI,{side:"top",align:"start",className:"max-w-xs px-2 py-1 text-xs",children:e.preview})]},t):s})})}var ed=n(92273),ec=n(66798),eu=n(81509);function em(e){let{value:t,theme:n,className:s}=e,[l,o]=(0,r.useState)(!1),i=async e=>{e.stopPropagation();try{let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;try{let n=new WeakSet;return JSON.stringify(e,(e,t)=>{if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t},t)}catch(t){return String(e)}}(t,2);await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},d=l?ed.A:ec.A;return(0,a.jsx)("button",{type:"button",onClick:i,className:(0,eu.cn)("inline-flex items-center justify-center transition-opacity hover:opacity-100",s),style:{width:"12px",height:"12px",color:n.copyButtonColor,background:"transparent",border:"none",cursor:"pointer",padding:0,marginLeft:"4px",opacity:.3},"aria-label":l?"Copied!":"Copy value",title:l?"Copied!":"Copy value","data-sentry-component":"CopyButton","data-sentry-source-file":"CopyButton.tsx",children:(0,a.jsx)(d,{size:9,"data-sentry-element":"Icon","data-sentry-source-file":"CopyButton.tsx"})})}function ep(e){let{row:t,theme:n,stringWrapMode:r="wrap",truncateStringsAt:s=null,enableCopy:l=!1,searchMatch:o,isCurrentMatch:i=!1,className:d,jsonPath:c,commentRanges:u,sectionKey:m}=e,p=(null==o?void 0:o.matchType)==="key",h=(null==o?void 0:o.matchType)==="value",x=String(t.key).length,f=+("string"===t.type),g=i?n.searchCurrentBackground:o?n.searchMatchBackground:"transparent";return(0,a.jsxs)("div",{className:d,"data-json-path":c,"data-section-key":m,"data-json-key-value":"true",style:{display:"flex",alignItems:"start",flexWrap:"nowrap",minHeight:"".concat(n.lineHeight,"px"),paddingLeft:"".concat(t.depth*n.indentSize,"px"),paddingRight:"4px",backgroundColor:g,fontSize:n.fontSize,lineHeight:"".concat(n.lineHeight,"px"),fontFamily:"monospace",transition:"background-color 0.15s ease"},"data-sentry-component":"JsonRowScrollable","data-sentry-source-file":"JsonRowScrollable.tsx",children:[(0,a.jsx)(es,{keyName:t.key,theme:n,highlightStart:p?o.highlightStart:void 0,highlightEnd:p?o.highlightEnd:void 0,commentRanges:u,"data-sentry-element":"JsonKey","data-sentry-source-file":"JsonRowScrollable.tsx"}),(0,a.jsx)("span",{style:{color:n.punctuationColor,marginLeft:"2px",marginRight:"4px",flexShrink:0},children:":"}),(0,a.jsx)(ei,{value:t.value,type:t.type,theme:n,isExpandable:t.isExpandable,childCount:t.childCount,stringWrapMode:r,truncateStringsAt:s,highlightStart:h?null==o?void 0:o.highlightStart:void 0,highlightEnd:h?null==o?void 0:o.highlightEnd:void 0,commentRanges:u,valueOffset:x+1+f,"data-sentry-element":"JsonValue","data-sentry-source-file":"JsonRowScrollable.tsx"}),l&&(0,a.jsx)(em,{value:t.value,theme:n,className:"mt-0.5"})]})}function eh(e,t){let n=(0,r.useMemo)(()=>{let t=new Map;return e.forEach(e=>{t.set(e.rowId,e)}),t},[e]);return{matchMap:n,currentMatch:e[t],currentMatchIndexInRow:(0,r.useMemo)(()=>(function(e,t){let n=t[e];if(!n)return;let a=t.filter(e=>e.rowId===n.rowId).findIndex(e=>e.rowIndex===n.rowIndex&&e.matchType===n.matchType&&e.highlightStart===n.highlightStart);return -1!==a?a+1:void 0})(t,e),[t,e])}}function ex(e){let{tree:t,expansionVersion:n,theme:a,showLineNumbers:s,totalLineCount:l,stringWrapMode:o,truncateStringsAt:i,charWidth:d}=e,c=t?1+t.rootNode.visibleDescendantCount:0,u=(0,r.useMemo)(()=>Math.max(1,Math.floor(Math.log10(null!=l?l:c))+1),[l,c]),m=(0,r.useMemo)(()=>{let e;return e=28,s&&(e+=7.2*u+8),Math.ceil(e)},[s,u]),p=(0,r.useMemo)(()=>{if(!t)return;if("nowrap"===o)return t.maxContentWidth;let[,e]=(0,X.getVisibleDepthRange)(t.rootNode),n=Math.min(e,20)*a.indentSize;return"wrap"===o?n+400:"truncate"===o?n+600:void 0},[o,t,a]),h=(0,r.useMemo)(()=>{if(!t||"nowrap"===o)return;let[,e]=(0,X.getVisibleDepthRange)(t.rootNode),n=Math.min(e,20)*a.indentSize;if("wrap"===o||"truncate"===o)return n+600},[o,t,a]),x=(0,r.useCallback)(e=>{if(!t)return a.lineHeight;let n=(0,X.getNodeByIndex)(t.rootNode,e);if(!n)return a.lineHeight;let r=(0,X.treeNodeToFlatRow)(n,e);if(r.isExpandable||"nowrap"===o||"truncate"===o)return a.lineHeight;if("string"===r.type){let e=r.value,t=null!=i?i:100;if(e.length>t){if(d&&h){let t=n.depth*a.indentSize,s=h-(t+String(r.key).length*d+2*d+d);if(s>0){let t=Math.max(40,Math.floor(s/d)),n=Math.ceil(e.length/t);return a.lineHeight*Math.min(n,10)}}let t=Math.ceil(e.length/80);return a.lineHeight*Math.min(t,10)}}return a.lineHeight},[t,a.lineHeight,a.indentSize,o,i,d,h]);return{maxLineNumberDigits:u,fixedColumnWidth:m,scrollableMinWidth:p,scrollableMaxWidth:h,estimateSize:x}}function ef(e,t){var n,a;return e&&t&&("input"===e||"output"===e||"metadata"===e)&&null!=(a=null==(n=t[e])?void 0:n.size)?a:0}function eg(e,t,n){if(!t||!n||"input"!==t&&"output"!==t&&"metadata"!==t)return;let a=v(e.pathArray),r=n[t];return null==r?void 0:r.get(a)}let ey=(0,r.memo)((0,r.forwardRef)(function(e,t){let{tree:n,sections:s,exp
1ansionVersion:l,theme:o,defaultRenderHeader:i,searchQuery:d,currentMatchIndex:c=0,matchCounts:u,showLineNumbers:m=!0,enableCopy:p=!1,stringWrapMode:h="wrap",truncateStringsAt:x=100,onToggleExpansion:f,scrollContainerRef:g,media:y,commentedPathsByField:j}=e,b=(0,r.useRef)(null),[w,N]=(0,r.useState)(null),C=O(),T=(0,r.useMemo)(()=>new Map(s.map(e=>[e.key,e])),[s]);(0,r.useLayoutEffect)(()=>{let e=null==g?void 0:g.current;if(!e)return;let t=()=>{N(e.clientWidth)};if(t(),"undefined"!=typeof ResizeObserver){let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}}},[null==g?void 0:g.current]);let I=n?1+n.rootNode.visibleDescendantCount:0,{maxLineNumberDigits:S,fixedColumnWidth:E,scrollableMinWidth:A,scrollableMaxWidth:M,estimateSize:P}=ex({tree:n,expansionVersion:l,theme:o,showLineNumbers:m,totalLineCount:null==n?void 0:n.totalNodeCount,stringWrapMode:h,truncateStringsAt:x,charWidth:C}),L=(0,r.useMemo)(()=>{if(n){if("nowrap"===h)return E+n.maxContentWidth;if(M)return E+M}},[n,E,h,M]),B=(0,r.useMemo)(()=>{if(L||w)return L?w?Math.max(L,w):L:w},[L,w]),{matchMap:R,currentMatch:V,currentMatchIndexInRow:z}=eh((0,r.useMemo)(()=>d&&n?k(n,d):[],[n,d]),c),_=(0,D.Te)({count:I,getScrollElement:()=>(null==g?void 0:g.current)||b.current,estimateSize:e=>{if(!n)return 16;let t=(0,X.getNodeByIndex)(n.rootNode,e);return t?"meta"===t.nodeType?0:"section-header"===t.nodeType?32:"section-footer"===t.nodeType?40:"section-spacer"===t.nodeType?t.spacerHeight||0:P(e):16},overscan:100,measureElement:e=>e.getBoundingClientRect().height,getItemKey:e=>{if(!n)return e;let t=(0,X.getNodeByIndex)(n.rootNode,e);return t?t.id:e}});(0,r.useEffect)(()=>{if(!V||!n)return;let e=(0,X.findNodeIndex)(n.rootNode,V.rowId);-1!==e&&_.scrollToIndex(e,{align:"center"})},[V,n,_]),(0,r.useImperativeHandle)(t,()=>({scrollToSection:e=>{if(!n)return;let t=(0,X.findSectionHeaderIndex)(n.rootNode,e);-1!==t&&_.scrollToIndex(t,{align:"start",behavior:"auto"})}}),[n,_]);let F=_.getVirtualItems();return(0,a.jsx)("div",{ref:b,id:"virtualized-multi-section-parent",style:{height:"100%",width:"nowrap"===h?"fit-content":"100%",minWidth:"100%",backgroundColor:o.background},children:(0,a.jsx)("div",{id:"virtualized-multi-section-content",style:{height:"".concat(_.getTotalSize(),"px"),minWidth:L?"".concat(L,"px"):"100%",width:"max-content",position:"relative"},children:F.map(e=>{var t,r,s;let l=(0,X.getNodeByIndex)(n.rootNode,e.index);if(!l||l.depth<0)return null;let d=R.get(l.id),c=(null==V?void 0:V.rowId)===l.id;if("section-header"===l.nodeType){let n,r=l.sectionKey?T.get(l.sectionKey):null,s={sectionKey:l.sectionKey||"",rowCount:null!=(t=l.totalDescendantCount)?t:l.visibleDescendantCount,isExpanded:l.isExpanded,setExpanded:e=>{f&&f(l.id)}},d=(null==r?void 0:r.title)||(l.sectionKey?l.sectionKey.charAt(0).toUpperCase()+l.sectionKey.slice(1):""),c=null==y?void 0:y.filter(e=>e.field===l.sectionKey),u=ef(l.sectionKey,j);return n=(null==r?void 0:r.renderHeader)?r.renderHeader(s):i?i({...s,title:d}):(0,a.jsx)(q,{title:d,context:s,media:c,commentCount:u}),(0,a.jsx)("div",{"data-index":e.index,"data-section-key":l.sectionKey,ref:_.measureElement,style:{position:"absolute",top:0,left:0,minWidth:B?"".concat(B,"px"):"100%",width:"max-content",transform:"translateY(".concat(e.start,"px)")},children:(0,a.jsx)("div",{style:{position:"sticky",left:0,width:w?"".concat(w,"px"):"100%",zIndex:2,backgroundColor:l.backgroundColor||o.background,borderBottom:"1px solid",borderColor:o.punctuationColor||"#e5e7eb"},children:n})},e.key)}if("section-footer"===l.nodeType){if(!l.isExpanded)return null;let t=l.sectionKey?T.get(l.sectionKey):null,n={sectionKey:l.sectionKey||"",rowCount:0,isExpanded:!0,setExpanded:()=>{}};return(0,a.jsx)("div",{"data-index":e.index,ref:_.measureElement,style:{position:"absolute",top:0,left:0,width:w?"".concat(w,"px"):"100%",transform:"translateY(".concat(e.start,"px)"),backgroundColor:l.backgroundColor||o.background,paddingBottom:"0.5rem"},children:null==t||null==(r=t.renderFooter)?void 0:r.call(t,n)},e.key)}if("section-spacer"===l.nodeType)return(0,a.jsx)("div",{"data-index":e.index,ref:_.measureElement,style:{position:"absolute",top:0,left:0,minWidth:B?"".concat(B,"px"):"100%",width:"max-content",transform:"translateY(".concat(e.start,"px)"),height:"".concat(l.spacerHeight,"px"),backgroundColor:l.backgroundColor||o.background}},e.key);let g=(0,X.treeNodeToFlatRow)(l,e.index),b=null==u?void 0:u.get(g.id),N=eg(g,l.sectionKey,j),C=v(g.pathArray);return(0,a.jsxs)("div",{"data-index":e.index,ref:_.measureElement,style:{position:"absolute",top:0,left:0,minWidth:B?"".concat(B,"px"):"100%",width:"max-content",transform:"translateY(".concat(e.start,"px)"),display:"grid",gridTemplateColumns:"".concat(E,"px auto"),backgroundColor:l.backgroundColor||o.background},children:[(0,a.jsx)("div",{style:{position:"sticky",left:0,zIndex:1,width:"".concat(E,"px"),backgroundColor:l.backgroundColor||o.background},children:(0,a.jsx)(et,{row:g,theme:o,showLineNumber:m,lineNumber:null!=(s=l.sectionLineNumber)?s:e.index+1,maxLineNumberDigits:S,searchMatch:d,isCurrentMatch:c,matchCount:b,currentMatchIndexInRow:c?z:void 0,onToggleExpansion:f,stringWrapMode:h})}),(0,a.jsx)("div",{style:{width:"fit-content",minWidth:A?"".concat(A,"px"):0,maxWidth:M?"".concat(M,"px"):void 0,overflow:"nowrap"===h?void 0:"hidden"},children:(0,a.jsx)(ep,{row:g,theme:o,searchMatch:d,isCurrentMatch:c,enableCopy:p,stringWrapMode:h,truncateStringsAt:x,jsonPath:C,commentRanges:N,sectionKey:l.sectionKey})})]},e.key)})})})})),ev=(0,r.memo)((0,r.forwardRef)(function(e,t){let{tree:n,sections:s,exp
1ansionVersion:l,theme:o,defaultRenderHeader:i,searchQuery:d,currentMatchIndex:c=0,matchCounts:u,showLineNumbers:m=!0,enableCopy:p=!1,stringWrapMode:h="wrap",truncateStringsAt:x=100,onToggleExpansion:f,scrollContainerRef:g,media:y,commentedPathsByField:j}=e,b=(0,r.useRef)(null),[w,N]=(0,r.useState)(null),C=(0,r.useMemo)(()=>new Map(s.map(e=>[e.key,e])),[s]);(0,r.useLayoutEffect)(()=>{let e=null==g?void 0:g.current;if(!e)return;let t=()=>{let t=e.clientWidth;N(e=>e===t?e:t)};if(t(),"undefined"!=typeof ResizeObserver){let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}},[g]);let T=(0,r.useMemo)(()=>n?(0,X.getAllVisibleNodes)(n.rootNode):[],[n,l]),I=(0,r.useMemo)(()=>T.filter(e=>e.depth>=0),[T]),{maxLineNumberDigits:S,fixedColumnWidth:E,scrollableMinWidth:O,scrollableMaxWidth:A}=ex({tree:n,expansionVersion:l,theme:o,showLineNumbers:m,totalLineCount:null==n?void 0:n.totalNodeCount,stringWrapMode:h,truncateStringsAt:x}),{matchMap:M,currentMatch:D,currentMatchIndexInRow:P}=eh((0,r.useMemo)(()=>d&&n?k(n,d):[],[n,d]),c),L=(0,r.useRef)(new Map);(0,r.useEffect)(()=>{if(!D)return;let e=L.current.get(D.rowId);e&&e.scrollIntoView({block:"center",behavior:"smooth"})},[D]),(0,r.useImperativeHandle)(t,()=>({scrollToSection:e=>{let t=null==g?void 0:g.current;if(!t)return;let n=t.querySelector('[data-section-key="'.concat(e,'"]'));n&&n.scrollIntoView({behavior:"smooth",block:"start"})}}),[g]);let B=(0,r.useMemo)(()=>{let e=[],t=null;return I.forEach(n=>{"section-header"===n.nodeType?(t={header:n,content:[],spacer:null,footer:null},e.push(t)):"section-spacer"===n.nodeType?t&&(t.spacer=n):"section-footer"===n.nodeType?t&&(t.footer=n):"json"===n.nodeType&&t&&t.content.push(n)}),e},[I]);return(0,a.jsx)("div",{ref:b,style:{width:"wrap"===h?"100%":"fit-content",minWidth:"100%",backgroundColor:o.background,color:o.foreground,fontFamily:"monospace"},children:(0,a.jsx)("div",{style:{position:"relative"},children:B.map(e=>{var t;let n,r=e.header.sectionKey,s=r?C.get(r):null,l={sectionKey:r||"",rowCount:null!=(t=e.header.totalDescendantCount)?t:e.content.length,isExpanded:e.header.isExpanded,setExpanded:t=>{f&&f(e.header.id)}},d=(null==s?void 0:s.title)||(r?r.charAt(0).toUpperCase()+r.slice(1):""),c=null==y?void 0:y.filter(e=>e.field===r),g=ef(r,j);return n=(null==s?void 0:s.renderHeader)?s.renderHeader(l):i?i({...l,title:d}):(0,a.jsx)(q,{title:d,context:l,media:c,commentCount:g}),(0,a.jsxs)("div",{"data-section-key":r,style:{width:"wrap"===h?"100%":"fit-content",backgroundColor:e.header.backgroundColor||o.background},children:[(0,a.jsx)("div",{style:{position:"sticky",top:0,left:0,width:w?"".concat(w,"px"):"100%",zIndex:10,backgroundColor:e.header.backgroundColor||o.background,borderBottom:"1px solid",borderColor:o.punctuationColor||"#e5e7eb"},children:n}),(0,a.jsx)("div",{style:{width:"wrap"===h?"100%":"max-content"},children:e.content.map((e,t)=>((e,t)=>{var n;let r=M.get(e.id),s=(null==D?void 0:D.rowId)===e.id,l=(0,X.treeNodeToFlatRow)(e,t),i=null==u?void 0:u.get(e.id),d=eg(l,e.sectionKey,j),c=v(l.pathArray);return(0,a.jsxs)("div",{ref:t=>{t?L.current.set(e.id,t):L.current.delete(e.id)},style:{display:"grid",gridTemplateColumns:"".concat(E,"px auto"),width:"nowrap"===h?void 0:"100%",backgroundColor:e.backgroundColor||o.background},"data-sentry-component":"renderJsonRow","data-sentry-source-file":"SimpleMultiSectionViewer.tsx",children:[(0,a.jsx)("div",{style:{position:"sticky",left:0,zIndex:1,width:"".concat(E,"px"),backgroundColor:e.backgroundColor||o.background},children:(0,a.jsx)(et,{row:l,theme:o,showLineNumber:m,lineNumber:null!=(n=e.sectionLineNumber)?n:t+1,maxLineNumberDigits:S,searchMatch:r,isCurrentMatch:s,matchCount:i,currentMatchIndexInRow:s?P:void 0,onToggleExpansion:f,stringWrapMode:h,"data-sentry-element":"JsonRowFixed","data-sentry-source-file":"SimpleMultiSectionViewer.tsx"})}),(0,a.jsx)("div",{style:{width:"fit-content",minWidth:O?"".concat(O,"px"):0,maxWidth:A?"".concat(A,"px"):void 0,overflow:"nowrap"===h?void 0:"hidden"},children:(0,a.jsx)(ep,{row:l,theme:o,searchMatch:r,isCurrentMatch:s,enableCopy:p,stringWrapMode:h,truncateStringsAt:x,jsonPath:c,commentRanges:d,sectionKey:e.sectionKey,"data-sentry-element":"JsonRowScrollable","data-sentry-source-file":"SimpleMultiSectionViewer.tsx"})})]},e.id)})(e,t))}),e.spacer&&(0,a.jsx)("div",{style:{height:"".concat(e.spacer.spacerHeight,"px")}}),(null==s?void 0:s.renderFooter)&&l.isExpanded&&(0,a.jsx)("div",{style:{width:w?"".concat(w,"px"):"100%",paddingBottom:"0.5rem"},children:s.renderFooter(l)})]},e.header.id)})})})})),ej=(0,r.createContext)({});function eb(e){let{tree:t,onToggle:n,children:s}=e,l=(0,r.useMemo)(()=>{let e={};return t.rootNode.children.filter(e=>"section-header"===e.nodeType).map(e=>
1e.sectionKey).filter(Boolean).forEach(a=>{let r=function(e,t){let n=e.nodeMap.get("".concat(t,"__header"));return n?{rowCount:n.visibleDescendantCount,isExpanded:n.isExpanded}:{rowCount:0,isExpanded:!1}}(t,a);e[a]={sectionKey:a,rowCount:r.rowCount,isExpanded:r.isExpanded,setExpanded:e=>{e!==r.isExpanded&&n(a)}}}),e},[t,n]);return(0,a.jsx)(ej.Provider,{value:l,"data-sentry-element":"SectionContextMapContext.Provider","data-sentry-component":"SectionContextProvider","data-sentry-source-file":"SectionContext.tsx",children:s})}let ew=(0,r.forwardRef)(function(e,t){let{sections:n,virtualized:s,theme:l,defaultRenderHeader:o,searchQuery:i,onSearchQueryChange:d,currentMatchIndex:c,onCurrentMatchIndexChange:u,onSearchResults:m,showLineNumbers:h=!0,enableCopy:v=!0,stringWrapMode:S="wrap",truncateStringsAt:E=100,className:D,scrollContainerRef:P,media:L,commentedPathsByField:B,externalExpansionState:R,onExpansionChange:V}=e,z=(0,r.useRef)(null),_=function(e){let{resolvedTheme:t}=(0,p.D)();return(0,r.useMemo)(()=>{let n="dark"===t?M:A;return e?{...n,...e}:n},[t,e])}(l),{tree:F,expansionVersion:H,handleToggleExpansion:J,handleToggleSectionExpansion:U}=function(e){let{sectionConfigs:t,searchQuery:n,indentSizePx:a=12,externalExpansionState:s,onExpansionChange:l}=e,o=O(),i=(0,r.useMemo)(()=>(function(e,t){let n={id:"__meta_root__",key:"__meta_root__",pathArray:["__meta_root__"],value:null,type:"object",depth:-1,parentNode:null,children:[],childCount:0,isExpandable:!1,isExpanded:!0,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:0,indexInParent:0,isLastChild:!1,nodeType:"meta"},a=[n],r=new Map;r.set(n.id,n);let s=1,l=0,o=0;return e.forEach(e=>{var i,d;let c={id:"".concat(e.key,"__header"),key:"".concat(e.key,"__header"),pathArray:["__meta_root__","".concat(e.key,"__header")],value:null,type:"object",depth:0,parentNode:n,children:[],childCount:0,isExpandable:!0,isExpanded:null==(i=b("".concat(e.key,"__header")))||i,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:s++,indexInParent:n.children.length,isLastChild:!1,nodeType:"section-header",sectionKey:e.key,backgroundColor:e.backgroundColor,minHeight:e.minHeight,sectionLineNumber:void 0};if(a.push(c),r.set(c.id,c),n.children.push(c),e.hideData)c.totalDescendantCount=0;else{let n=function(e,t){var n;j("[buildTreeFromJSON] Starting four-pass build");let a=performance.now(),{rootNode:r,nodeMap:s}
1=function(e,t){let n=new Map,a=x(e),r=f(e),s={id:t,key:t,pathArray:[t],value:e,type:a,depth:0,parentNode:null,children:[],childCount:0,isExpandable:r,isExpanded:!1,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:1,indexInParent:0,isLastChild:!0};n.set(t,s);let l=[{value:e,key:t,pathArray:[t],depth:0,parentNode:null,indexInParent:0,isLastChild:!0}],o=new Map;for(o.set(t,s);l.length>0;){let{value:a,pathArray:i,depth:d}=l.pop(),c=y(i),u=o.get(c);if(c===t){if(r){let t=g(e);s.childCount=t.length,s.children=Array(t.length);for(let e=0;e<t.length;e++){let[a,r]=t[e],l=[...i,a],c=y(l),u=e===t.length-1,m=x(r),p=f(r),h={id:c,key:a,pathArray:l,value:r,type:m,depth:d+1,parentNode:s,children:[],childCount:p?g(r).length:0,isExpandable:p,isExpanded:!1,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:0,indexInParent:e,isLastChild:u};n.set(c,h),s.children[e]=h,o.set(c,h)}for(let e=t.length-1;e>=0;e--){let t=s.children[e];l.push({value:t.value,key:t.key,pathArray:t.pathArray,depth:t.depth,parentNode:s,indexInParent:e,isLastChild:t.isLastChild})}}continue}if(u&&u.isExpandable){let e=g(a);u.children=Array(e.length);for(let t=0;t<e.length;t++){let[a,r]=e[t],s=[...i,a],l=y(s),c=t===e.length-1,m=x(r),p=f(r),h={id:l,key:a,pathArray:s,value:r,type:m,depth:d+1,parentNode:u,children:[],childCount:p?g(r).length:0,isExpandable:p,isExpanded:!1,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:0,indexInParent:t,isLastChild:c};n.set(l,h),u.children[t]=h,o.set(l,h)}for(let t=e.length-1;t>=0;t--){let e=u.children[t];l.push({value:e.value,key:e.key,pathArray:e.pathArray,depth:e.depth,parentNode:u,indexInParent:t,isLastChild:e.isLastChild})}}}return{rootNode:s,nodeMap:n}}(e,t.rootKey),l=function(e){let t=0,n=[],a=[e];for(;a.length>0;){let e=a.pop();e.absoluteLineNumber=++t,n.push(e);for(let t=e.children.length-1;t>=0;t--)a.push(e.children[t])}return n}(r);!function(e,t,n){let a=new Set;"boolean"==typeof t?t||a.add("*"):Object.entries(t).forEach(e=>{let[t,n]=e;n||a.add(t)});let r=[e];for(;r.length>0;){let e=r.pop(),s=!0;void 0!==n?s=e.depth<n:a.has("*")?s=!1:"boolean"==typeof t?s=t:a.has(e.id)&&(s=!1),e.isExpanded=s&&e.isExpandable,e.userExpand=e.isExpandable?"boolean"==typeof t?void 0:t[e.id]:void 0,e.children.forEach(e=>r.push(e))}}(r,t.initialExpansion,t.expandDepth);let o=[],i=[{node:r,visited:!1}];for(;i.length>0;){let e=i.pop();if(e.visited)o.push(e.node);else{i.push({node:e.node,visited:!0});for(let t=e.node.children.length-1;t>=0;t--)i.push({node:e.node.children[t],visited:!1})}}o.forEach(e=>{if(!e.isExpandable||!e.isExpanded){e.visibleDescendantCount=0,e.childOffsets=[];return}let t=[],n=0;e.children.forEach(e=>{n+=1+e.visibleDescendantCount,t.push(n)}),e.childOffsets=t,e.visibleDescendantCount=n});let{maxDepth:d,maxContentWidth:c}=function(e,t){let n=0,a=0;for(let r of e){r.depth>n&&(n=r.depth);let e=function(e,t){let n=e.depth*t.indentSizePx,a=String(e.key).length,r=2*t.charWidthPx;return n+r+(a+function(e){if(null===e)return 4;if(void 0===e)return 9;if("boolean"==typeof e)return e?4:5;if("number"==typeof e)return String(e).length;if("string"==typeof e)return e.length+2;if(Array.isArray(e))return"Array(".concat(e.length,")").length;if("object"==typeof e){let t=Object.keys(e);return 0===t.length?2:1===t.length?t[0].length+2:"{".concat(t.length," keys}").length}return 0}(e.value))*t.charWidthPx+4+t.extraBufferPx}(r,t);e>a&&(a=e)}return{maxDepth:n,maxContentWidth:a}}(l,null!=(n=t.widthEstimator)?n:{charWidthPx:6.2,indentSizePx:16,extraBufferPx:50}),u=performance.now()-a;return j("[buildTreeFromJSON] Completed four-pass build:",{totalTime:"".concat(u.toFixed(2),"ms"),totalNodes:l.length,maxDepth:d,maxContentWidth:"".concat(c.toFixed(0),"px")}),{rootNode:r,nodeMap:s,allNodes:l,totalNodeCount:l.length,maxDepth:d,maxContentWidth:c}}(e.data,{rootKey:e.key,initialExpansion:null==(d=b(e.key))||d,widthEstimator:null==t?void 0:t.widthConfig});o=Math.max(o,n.maxContentWidth);let i=1,u=[{node:n.rootNode,newDepth:0}];for(;u.length>0;){let{node:t,newDepth:n}=u.pop();t.depth=n,t.sectionKey=e.key,t.backgroundColor=e.backgroundColor,t.minHeight=e.minHeight,t.nodeType="json",t.sectionLineNumber=i++,t.absoluteLineNumber=s++,l=Math.max(l,t.depth),a.push(t),r.set(t.i
1d,t);for(let e=t.children.length-1;e>=0;e--)u.push({node:t.children[e],newDepth:n+1})}n.rootNode.parentNode=c,n.rootNode.indexInParent=0,c.children.push(n.rootNode),c.childCount=1,c.totalDescendantCount=n.totalNodeCount}if(e.minHeight){let t=Math.max(0,parseFloat(e.minHeight)-14*c.visibleDescendantCount);if(t>0){let n={id:"".concat(e.key,"__spacer"),key:"".concat(e.key,"__spacer"),pathArray:["__meta_root__","".concat(e.key,"__spacer")],value:null,type:"object",depth:0,parentNode:c,children:[],childCount:0,isExpandable:!1,isExpanded:!0,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:s++,indexInParent:c.children.length,isLastChild:!1,nodeType:"section-spacer",sectionKey:e.key,backgroundColor:e.backgroundColor,spacerHeight:t};a.push(n),r.set(n.id,n),c.children.push(n),c.childCount+=1}}if(e.hasFooter){let t={id:"".concat(e.key,"__footer"),key:"".concat(e.key,"__footer"),pathArray:["__meta_root__","".concat(e.key,"__footer")],value:null,type:"object",depth:0,parentNode:c,children:[],childCount:0,isExpandable:!1,isExpanded:!0,userExpand:void 0,childOffsets:[],visibleDescendantCount:0,absoluteLineNumber:s++,indexInParent:c.children.length,isLastChild:!1,nodeType:"section-footer",sectionKey:e.key,backgroundColor:e.backgroundColor,sectionLineNumber:void 0};a.push(t),r.set(t.id,t),c.children.push(t),c.childCount+=1}w(c)}),n.children.forEach((e,t)=>{e.isLastChild=t===n.children.length-1}),n.childCount=n.children.length,w(n),{rootNode:n,nodeMap:r,allNodes:a,totalNodeCount:a.length,maxDepth:l,maxContentWidth:o}})(t,{widthConfig:{charWidthPx:o,indentSizePx:a,extraBufferPx:50}}),[t,o,a]),[d,c]=(0,r.useState)(0),u=(0,r.useRef)(null),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=u.current!==s,t=m.current!==i;s&&(e||t)&&(u.current=s,m.current=i,function(e,t){let n=new Set,a=new Set;"boolean"==typeof t?t||n.add("*"):Object.entries(t).forEach(e=>{let[t,r]=e;r?a.add(t):n.add(t)});let r=new Set;a.forEach(e=>{let t=e.split(".");for(let e=1;e<t.length;e++)r.add(t.slice(0,e).join("."))});let s=[],l=[{node:e.rootNode,visited:!1}];for(;l.length>0;){let e=l.pop();if(e.visited)s.push(e.node);else{l.push({node:e.node,visited:!0});for(let t=e.node.children.length-1;t>=0;t--)l.push({node:e.node.children[t],visited:!1})}}s.forEach(e=>{if(!e.isExpandable)return;let s=!0;n.has("*")?s=!1:"boolean"==typeof t?s=t:n.has(e.id)?s=!1:a.has(e.id)?s=!0:r.has(e.id)&&(s=!0),e.isExpanded=s,"boolean"==typeof t?e.userExpand=void 0:void 0!==t[e.id]?e.userExpand=t[e.id]:r.has(e.id)?e.userExpand=!0:e.userExpand=void 0,T(e)})}(i,s),N(i,14),c(e=>e+1))},[s,i]);let p=(0,r.useCallback)(e=>{C(i,e),N(i,14),c(e=>e+1),l&&l(I(i))},[i,l]),h=(0,r.useCallback)(e=>{C(i,"".concat(e,"__header")),N(i,14),c(e=>e+1),l&&l(I(i))},[i,l]);return(0,r.useEffect)(()=>{if(!n||""===n.trim())return;let e=k(i,n),t=new Set;e.forEach(e=>{let n=i.nodeMap.get(e.rowId);(null==n?void 0:n.sectionKey)&&t.add(n.sectionKey)});let a=!1;t.forEach(e=>{let t=i.nodeMap.get("".concat(e,"__header"));t&&!t.isExpanded&&(C(i,t.id),a=!0)}),a&&(N(i,14),c(e=>e+1))},[i,n]),{tree:i,expansionVersion:d,handleToggleExpansion:p,handleToggleSectionExpansion:h}}({sectionConfigs:(0,r.useMemo)(()=>n.map(e=>({key:e.key,data:e.data,backgroundColor:e.backgroundColor,minHeight:e.minHeight,hasFooter:!!e.renderFooter,hideData:e.hideData})),[n]),searchQuery:i,indentSizePx:_.indentSize,externalExpansionState:R,onExpansionChange:V}),W=(0,r.useMemo)(()=>i&&F?k(F,i,{caseSensitive:!1}):[],[F,i]),G=(0,r.useMemo)(()=>F&&W.length>0?function(e,t){let n=new Map;return e.allNodes.forEach(e=>n.set(e.id,0)),t.forEach(t=>{let a=e.nodeMap.get(t.rowId);if(!a)return;n.set(a.id,(n.get(a.id)||0)+1);let r=a.parentNode;for(;null!==r;)n.set(r.id,(n.get(r.id)||0)+1),r=r.parentNode}),n}(F,W):void 0,[F,W]);(0,r.useEffect)(()=>{m&&m(W.length)},[W,m]),(0,r.useImperativeHandle)(t,()=>({scrollToSection:e=>{var t;null==(t=z.current)||t.scrollToSection(e)}}),[]);let $=(0,r.useMemo)(()=>void 0!==s?s:!!F&&F.totalNodeCount>500,[s,F]),K=(0,r.useMemo)(()=>({tree:F,sections:n,expansionVersion:H,theme:_,defaultRenderHeader:o,searchQuery:i,currentMatchIndex:c,matchCounts:G,showLineNumbers:h,enableCopy:v,stringWrapMode:S,truncateStringsAt:E,onToggleExpansion:J,scrollC
1ontainerRef:P,media:L,commentedPathsByField:B}),[F,n,H,_,o,i,c,G,h,v,S,E,J,P,L,B]);return F?(0,a.jsx)(eb,{tree:F,onToggle:U,children:(0,a.jsx)("div",{className:D,style:{display:"flex",flexDirection:"column",...$&&{height:"100%"}},children:$?(0,a.jsx)(ey,{ref:z,...K}):(0,a.jsx)(ev,{ref:z,...K})})}):(0,a.jsx)("div",{className:D,children:"Building tree..."})});var eN=n(95266),eC=n(86843),eT=n(17385),eI=n(50219),eS=n(66428);let ek="langfuse:json-view-preferences",eE={stringWrapMode:"wrap"};function eO(){try{let e=localStorage.getItem(ek);if(!e)return eE;let t=JSON.parse(e);return{stringWrapMode:"truncate"===t.stringWrapMode||"wrap"===t.stringWrapMode||"nowrap"===t.stringWrapMode?t.stringWrapMode:eE.stringWrapMode}}catch(e){return console.warn("Failed to load JSON view preferences:",e),eE}}let eA=(0,r.createContext)(null);function eM(e){let{children:t}=e,[n,s]=(0,r.useState)(null),l=(0,r.useCallback)(()=>{var e;s(null),null==(e=window.getSelection())||e.removeAllRanges()},[]);return(0,a.jsx)(eA.Provider,{value:{selection:n,setSelection:s,clearSelection:l,isSelecting:null!==n},"data-sentry-element":"InlineCommentSelectionContext.Provider","data-sentry-component":"InlineCommentSelectionProvider","data-sentry-source-file":"InlineCommentSelectionContext.tsx",children:t})}function eD(){return(0,r.useContext)(eA)}function eP(e){let t=e;for(;t&&t!==document.body;){if(t instanceof HTMLElement&&t.dataset.jsonPath)return t.dataset.jsonPath;t=t.parentNode}return null}function eL(e){let t=e;for(;t&&t!==document.body;){if(t instanceof HTMLElement&&t.dataset.jsonKeyValue)return t;t=t.parentNode}return null}function eB(e,t,n){let a=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),r=0,s=a.nextNode();for(;s;){var l;if(s===e)break;r+=(null==(l=s.textContent)?void 0:l.length)||0,s=a.nextNode()}return r+t}function eR(e){let t=0,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a=n.nextNode();for(;a;){var r;t+=(null==(r=a.textContent)?void 0:r.length)||0,a=n.nextNode()}return t}function eV(e){let{children:t,dataField:n,enabled:s=!0,className:l}=e,o=(0,r.useRef)(null);return!function(e){let{containerRef:t,dataField:n,enabled:a=!0}=e,s=eD(),l=(0,r.useRef)(null),o=(0,r.useCallback)(()=>{a&&t.current&&s&&(l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{var e,a;let r=window.getSelection();if(!r||r.isCollapsed){let e=null==r?void 0:r.focusNode;e&&(null==(a=t.current)?void 0:a.contains(e))&&s.clearSelection();return}let l=r.getRangeAt(0);if(!(null==(e=t.current)?void 0:e.contains(l.commonAncestorContainer)))return;let o=null!=n?n:function(e){let t=e;for(;t&&t!==document.body;){if(t instanceof HTMLElement&&t.dataset.sectionKey){let e=t.dataset.sectionKey;if("input"===e||"output"===e||"metadata"===e)return e}t=t.parentNode}return null}(l.startContainer);if(!o)return;let i=function(e,t,n){if(0===e.rangeCount||e.isCollapsed)return null;let a=e.getRangeAt(0),r=a.toString();if(!r.trim())return null;let s=eP(a.startContainer),l=eL(a.startContainer),o=eP(a.endContainer),i=eL(a.endContainer);if(!s||!l||!o||!i)return null;if(l===i){let e=eB(a.startContainer,a.startOffset,l),t=eB(a.endContainer,a.endOffset,l);return e>t&&([e,t]=[t,e]),{dataField:n,path:[s],rangeStart:[e],rangeEnd:[t],selectedText:r}}let d=function(e,t,n){let a=Array.from(n.querySelectorAll("[data-json-key-value]")),r=a.indexOf(e),s=a.indexOf(t);if(-1===r||-1===s)return[];let[l,o]=r<=s?[r,s]:[s,r];return a.slice(l,o+1)}(l,i,t);if(0===d.length)return null;let c=d[0]!==l,[u,m]=c?[a.endContainer,a.endOffset]:[a.startContainer,a.startOffset],[p,h]=c?[a.startContainer,a.startOffset]:[a.endContainer,a.endOffset],x=[],f=[],g=[];for(let e=0;e<d.length;e++){let t=d[e],n=t.dataset.jsonPath;n&&(0===e?(x.push(n),f.push(eB(u,m,t)),g.push(eR(t))):e===d.length-1?(x.push(n),f.push(0),g.push(eB(p,h,t))):(x.push(n),f.push(0),g.push(eR(t))))}return 0===x.length?null:{dataField:n,path:x,rangeStart:f,rangeEnd:g,selectedText:r}}(r,t.current,o);if(i){let e=l.cloneRange();e.collapse(!0);let t=e.getBoundingClientRect();s.setSelection({...i,anchorRect:l.getBoundingClientRect(),startRect:t})}},150))},[a,t,n,s]);(0,r.useEffect)(()=>
1{if(a&&s)return document.addEventListener("selectionchange",o),()=>{document.removeEventListener("selectionchange",o),l.current&&clearTimeout(l.current)}},[a,o,s]),null==s||s.clearSelection}({containerRef:o,dataField:n,enabled:s}),(0,a.jsx)("div",{ref:o,className:l,"data-sentry-component":"CommentableJsonView","data-sentry-source-file":"CommentableJsonView.tsx",children:t})}var ez=n(16430);function e_(e){let{onAddComment:t}=e,n=eD(),[s,l]=(0,r.useState)(null);return((0,r.useEffect)(()=>{var e;let t=null==n?void 0:n.selection;if(!(null==t?void 0:t.anchorRect))return void l(null);let a=null!=(e=t.startRect)?e:t.anchorRect;l({top:a.top-6,left:a.left})},[null==n?void 0:n.selection]),(null==n?void 0:n.selection)&&s)?(0,a.jsx)("div",{style:{position:"fixed",top:s.top,left:s.left,transform:"translateY(-100%)",zIndex:50},className:"duration-100 animate-in fade-in-0 zoom-in-95","data-sentry-component":"InlineCommentBubble","data-sentry-source-file":"InlineCommentBubble.tsx",children:(0,a.jsxs)(eC.$,{size:"xs",variant:"secondary",onClick:()=>{t()},className:"border border-border bg-background px-3 py-2.5 text-muted-foreground shadow-md hover:bg-muted hover:text-foreground","data-sentry-element":"Button","data-sentry-source-file":"InlineCommentBubble.tsx",children:[(0,a.jsx)(ez.A,{className:"h-3 w-3","data-sentry-element":"MessageSquarePlus","data-sentry-source-file":"InlineCommentBubble.tsx"}),(0,a.jsx)("span",{className:"ml-1",children:"Comment"})]})}):null}var eF=n(80263),eH=n(97675),eJ=n(17982),eU=n(55247),eW=n(72681),eG=n(54433),e$=n(66449),eK=n(62065),eQ=n(18799),eq=n(14183),eX=n(62145);let eZ=(e,t)=>{if(null==e)return"";if(t)try{if("string"==typeof e){let t=JSON.parse(e);return JSON.stringify(t,null,2)}return JSON.stringify(e,null,2)}catch(t){return"string"==typeof e?e:JSON.stringify(e)}return"string"==typeof e?e:JSON.stringify(e,null,2)},eY=e=>{let{isOpen:t,setIsOpen:n,actualOutput:r,correctedOutput:s,strictJsonMode:l}=e,o=eZ(r,l),i=eZ(s,l),d=null==r;return(0,a.jsx)(eq.lG,{open:t,onOpenChange:n,"data-sentry-element":"Dialog","data-sentry-component":"CorrectedOutputDiffDialog","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:(0,a.jsxs)(eq.Cf,{size:"xl","data-sentry-element":"DialogContent","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:[(0,a.jsxs)(eq.c7,{"data-sentry-element":"DialogHeader","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:[(0,a.jsx)(eq.L3,{"data-sentry-element":"DialogTitle","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:"Output Correction Diff"}),(0,a.jsx)(eq.rr,{"data-sentry-element":"DialogDescription","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:"Compare the original output with the corrected version"})]}),(0,a.jsx)(eq.R4,{"data-sentry-element":"DialogBody","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:d?(0,a.jsx)("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:(0,a.jsxs)("div",{className:"text-muted-foreground",children:[(0,a.jsx)("p",{className:"text-lg font-medium",children:"No original output"}),(0,a.jsx)("p",{className:"mt-2 text-sm",children:"There is no original output to compare with the correction."})]})}):(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsx)(eX.A,{oldString:o,newString:i,oldLabel:"Original Output",newLabel:"Corrected Output"})})}),(0,a.jsx)(eq.Es,{"data-sentry-element":"DialogFooter","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:(0,a.jsx)(eC.$,{onClick:()=>n(!1),"data-sentry-element":"Button","data-sentry-source-file":"CorrectedOutputDiffDialog.tsx",children:"Close"})})]})})};var e0=n(68389),e1=n.n(e0);function e5(e){let{actualOutput:t,existingCorrection:n,observationId:s,projectId:o,traceId:i,environment:d="default",compact:u=!1}=e,m=(0,eQ.lp)({projectId:o,scope:"scores:CUD"}),[p,h]=(0,l.A)("correctionStrictJsonMode",!1),[x,f]=(0,r.useState)(!1),{effectiveCorrection:g,correctionValue:y}=function(e,t,n){let a=(0,eW.m)(),s=(0,r.useMemo)(()=>t?a.getForObservation(n,t):a.getForTrace(n),[a,t,n]),l=(0,r.useMemo)(()=>s?{...e,id:s.id,timestamp:s.timestamp,longStringValue:s.value}:(null==e?void 0:e.id)&&a.isDeleted(e.id)?null:e,[s,e,a]),o=(0,r.useMemo)(()=>null!=e&&!!e.id&&a.isDeleted(e.id),[null==e?void 0:e.id,a]);return{effectiveCorrection:l,correctionValue:(0,r.useMemo)(()=>{var t;return o?"":(null==s?void 0:s.value)!==void 0?s.value:null!=(t=null==e?void 0:e.longStringValue)?t:""},[s,e,o])}}(n,s,i),{saveStatus:v,setSaveStatus:j,handleSave:b,handleDelete:w}=function(e){let{projectId:t,traceId:n,observationId:a,environment:s,effectiveCorrection:l}=e,o=(0,eW.m)(),[i,d]=(0,r.useState)("idle"),c=J.FH.scores.upsertCorrection.useMutation({onMutate:async e=>{let r=o.get(e.id);return o.set(e.id,{id:e.id,timestamp:e.timestamp,projectId:t,traceId:n,observationId:null!=a?a:null,environment:s,value:e.value}),d("saving"),{previousValue:r,id:e.id}}
1,onError:(e,t,n)=>{(null==n?void 0:n.id)&&(n.previousValue?o.set(n.id,n.previousValue):o.rollbackSet(n.id),d("idle"))},onSuccess:()=>{d("saved")}}),u=J.FH.scores.deleteAnnotationScore.useMutation({onMutate:async()=>{if(!l)return;let e=o.get(l.id);return o.delete(l.id),{previousValue:e,correctionId:l.id}},onError:(e,t,n)=>{eG.oR.error("Failed to delete correction"),(null==n?void 0:n.correctionId)&&o.rollbackDelete(n.correctionId,n.previousValue)}}),m=(0,r.useCallback)(e=>{var r,i,d;let u=o.isDeleted(null!=(r=null==l?void 0:l.id)?r:"");c.mutate({projectId:t,id:u?(0,e$.A)():null!=(i=null==l?void 0:l.id)?i:(0,e$.A)(),environment:s,traceId:n,observationId:a,value:e,timestamp:u?new Date:null!=(d=null==l?void 0:l.timestamp)?d:new Date})},[t,n,a,s,null==l?void 0:l.id,null==l?void 0:l.timestamp,c,o]);return{saveStatus:i,setSaveStatus:d,handleSave:m,handleDelete:(0,r.useCallback)(()=>{l&&u.mutate({projectId:t,id:l.id})},[t,l,u]),isDeleting:u.isPending}}({projectId:o,traceId:i,observationId:s,environment:d,effectiveCorrection:g}),{isEditing:N,setIsEditing:C,value:T,isValidJson:I,handleEdit:S,handleChange:k}=function(e){let{correctionValue:t,actualOutput:n,onSave:a,setSaveStatus:s,debounceMs:l=500,strictJsonMode:o=!1}=e,[i,d]=(0,r.useState)(!1),[c,u]=(0,r.useState)(t),[m,p]=(0,r.useState)(!0),h=(0,r.useRef)(null),x=(0,r.useRef)(null);(0,r.useEffect)(()=>{u(t)},[t]),(0,r.useEffect)(()=>{let e=!1;if(o)try{c.trim()&&(JSON.parse(c),e=!0)}catch(t){e=!1}else e=c.trim().length>0;p(e)},[o]);let f=(0,r.useCallback)(()=>{if(d(!0),!c&&n)try{let e="string"==typeof n?n:JSON.stringify(n);u(e);let t=!1;if(o)try{e.trim()&&(JSON.parse(e),t=!0)}catch(e){t=!1}else t=e.trim().length>0;p(t),t&&(s("saving"),a(e))}catch(r){let e=String(n);u(e);let t=e.trim().length>0;p(t),t&&(s("saving"),a(e))}setTimeout(()=>{var e;return null==(e=x.current)?void 0:e.focus()},0)},[c,n,o,a,s]);return{isEditing:i,setIsEditing:d,value:c,isValidJson:m,handleEdit:f,handleChange:(0,r.useCallback)(e=>{u(e);let t=!1;if(o)try{e.trim()&&(JSON.parse(e),t=!0)}catch(e){t=!1}else t=e.trim().length>0;p(t),t?(s("saving"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{a(e)},l)):(s("idle"),h.current&&clearTimeout(h.current))},[a,s,l,o])}}({correctionValue:y,actualOutput:t,onSave:b,setSaveStatus:j,strictJsonMode:p}),E=N?T.trim().length>0:y.trim().length>0,O=(0,r.useMemo)(()=>{if(!T)return"";if(p)try{let e=JSON.parse(T);return JSON.stringify(e,null,2)}catch(e){return T}try{let e=JSON.parse(T);if("string"==typeof e)return e;return JSON.stringify(e,null,2)}catch(e){return T}},[T,p]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eY,{isOpen:x,setIsOpen:f,actualOutput:t,correctedOutput:T,strictJsonMode:p,"data-sentry-element":"CorrectedOutputDiffDialog","data-sentry-source-file":"CorrectedOutputField.tsx"}),(0,a.jsx)("div",{className:"px-2",children:(0,a.jsxs)("div",{className:"group relative rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:(0,eu.cn)("text-sm font-medium",u?"text-xs":"text-sm"),children:u?"":"Corrected Output (Beta)"}),(0,a.jsxs)(el.jc,{"data-sentry-element":"HoverCard","data-sentry-source-file":"CorrectedOutputField.tsx",children:[(0,a.jsx)(el.d0,{asChild:!0,"data-sentry-element":"HoverCardTrigger","data-sentry-source-file":"CorrectedOutputField.tsx",children:(0,a.jsx)("button",{className:"text-muted-foreground hover:text-foreground",children:(0,a.jsx)(eF.A,{className:"h-3.5 w-3.5","data-sentry-element":"Info","data-sentry-source-file":"CorrectedOutputField.tsx"})})}),(0,a.jsx)(el.Et,{className:"w-80 text-xs",side:"right","data-sentry-element":"HoverCardContent","data-sentry-source-file":"CorrectedOutputField.tsx",children:(0,a.jsxs)("p",{children:["Corrected outputs allow you to save the expected output for a trace or observation. Learn more in the"," ",(0,a.jsx)(e1(),{href:"https://langfuse.com/docs/observability/features/corrections",target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground","data-sentry-element":"Link","data-sentry-source-file":"CorrectedOutputField.tsx",children:"documentation"}),"."]})})]})]}),(0,a.jsxs)("div",{className:"-mr-1 flex items-center",children:[(0,a.jsxs)("div",{className:"flex items-center -space-x-1 opacity-0 transition-opacity group-hover:opacity-100",children:[!I&&N&&E&&(0,a.jsx)("span",{className:"mr-2 text-xs text-red-500",children:p?"Invalid JSON - fix to save":"Cannot save empty content"}
1),I&&"saving"===v&&(0,a.jsxs)("div",{className:"mr-2 flex items-center gap-1",children:[(0,a.jsx)(Z.A,{className:"h-3 w-3 animate-spin"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Saving"})]}),I&&"saved"===v&&(0,a.jsxs)("div",{className:"mr-2 flex items-center gap-1",children:[(0,a.jsx)(ed.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Saved"})]}),E&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eC.$,{size:"icon-xs",variant:"ghost",onClick:()=>f(!0),className:"hover:bg-border",title:"View diff between original and corrected output",children:(0,a.jsx)(eH.A,{className:"h-3 w-3"})}),!N&&(0,a.jsx)(eC.$,{size:"icon-xs",variant:"ghost",onClick:S,disabled:!m,className:"hover:bg-border",title:"Edit corrected output",children:(0,a.jsx)(eJ.A,{className:"h-3 w-3"})}),(0,a.jsx)(eC.$,{size:"icon-xs",variant:"ghost",onClick:()=>{w(),C(!1)},disabled:!m,className:"hover:bg-border",title:"Delete corrected output",children:(0,a.jsx)(eU.A,{className:"h-3 w-3"})})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.d,{checked:p,onCheckedChange:e=>{if(h(e),N&&T.trim()&&e)try{JSON.parse(T)}catch(e){k(JSON.stringify(T))}},disabled:!N,className:"scale-75","data-sentry-element":"Switch","data-sentry-source-file":"CorrectedOutputField.tsx"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"JSON"})]})]})]}),E||N?N?(0,a.jsx)(eK.g,{value:O,onChange:e=>{k(e)},mode:p?"json":"text",minHeight:200,placeholder:"Enter corrected output...",className:"bg-accent-light-green"}):(0,a.jsx)(eK.g,{value:O,mode:p?"json":"text",minHeight:200,editable:!1,className:"bg-accent-light-green"}):(0,a.jsx)("button",{onClick:S,disabled:!m,className:(0,eu.cn)("w-full cursor-pointer rounded-md border px-3 py-4 text-center text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:"Click to add corrected output"})]})})]})}function e2(e){let{parsedInput:t,parsedOutput:n,parsedMetadata:s,outputCorrection:l,isParsing:o=!1,hideIfNull:i=!1,hideOutput:d=!1,hideInput:c=!1,media:u,onVirtualizationChange:m,enableInlineComments:x=!1,onAddInlineComment:f,commentedPathsByField:g,observationId:y,projectId:v,traceId:j,environment:b="default",expansionState:w,onExpansionChange:N,showCorrections:C=!0}=e,T=eD(),I=(0,r.useCallback)(()=>{(null==T?void 0:T.selection)&&f&&f(T.selection)},[null==T?void 0:T.selection,f]),{resolvedTheme:S}=(0,p.D)(),k="dark"===S,{inputBgColor:E,outputBgColor:O,metadataBgColor:A}=(0,r.useMemo)(()=>({inputBgColor:k?"rgb(15, 23, 42)":"rgb(249, 252, 255)",outputBgColor:k?"rgb(20, 30, 41)":"rgb(248, 253, 250)",metadataBgColor:k?"rgb(30, 20, 40)":"rgb(253, 251, 254)"}),[k]),M=!c&&!(i&&void 0===t),D=!d&&!(i&&void 0===n),L=!(i&&void 0===s),B=(0,r.useMemo)(()=>({input:h(t),output:h(n),metadata:h(s)}),[t,n,s]),R=(0,r.useMemo)(()=>B.input>3333||B.output>3333||B.metadata>3333,[B]),{stringWrapMode:V,setStringWrapMode:z}=function(){let[e,t]=(0,r.useState)(eO);(0,r.useEffect)(()=>{try{localStorage.setItem(ek,JSON.stringify(e))}catch(e){console.warn("Failed to save JSON view preferences:",e)}},[e]);let n=(0,r.useCallback)(e=>{t(t=>({...t,stringWrapMode:e}))},[]);return{preferences:e,stringWrapMode:e.stringWrapMode,setStringWrapMode:n}}(),[_,F]=(0,r.useState)(""),[H,J]=(0,r.useState)(""),[U,W]=(0,r.useState)(0),[G,$]=(0,r.useState)(0),K=(0,r.useRef)(null),Q=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=setTimeout(()=>{J(_),W(0)},300);return()=>clearTimeout(e)},[_]),(0,r.useEffect)(()=>{null==m||m(R)},[R,m]);let q=(0,r.useCallback)(()=>{0!==G&&W(e=>(e+1)%G)},[G]),X=(0,r.useCallback)(()=>{0!==G&&W(e=>0===e?G-1:e-1)},[G]),Z=(0,r.useCallback)(()=>{F(""),J(""),W(0)},[]),Y=(0,r.useCallback)(()=>{"truncate"===V?z("wrap"):"wrap"===V?z("nowrap"):z("truncate")},[V,z]),ee=(0,r.useCallback)(e=>{var t;null==(t=Q.current)||t.scrollToSection(e)},[]),et=(0,r.useCallback)(()=>{let e={};M&&(e.input=t),D&&(e.output=n),L&&(e.metadata=s);let a=JSON.stringify(e,null,2);navigator.clipboard.writeText(a)},[M,D,L,t,n,s]),en=(0,r.useMemo)(()=>"truncate"===V?(0,a.jsx)(eT.A,{size:14}):"wrap"===V?(0,a.jsx)(eI.A,{size:14}):(0,a.jsx)(P.A,{size:14,className:"rotate-[-90deg]"}),[V]),ea=(0,r.useMemo)(()=>{let e=[];return M&&e.push({key:"input",title:"Input",data:t,backgroundColor:E,minHeight:"200px"}),D&&e.push({key:"output",title:"Output",data:n,backgroundColor:O,minHeight:"200px"}),C&&e.push({key:"corrections",title:"Output correction",data:null,hideData:!0,backgroundColor:O,minHeight:"4px",renderFooter:()=>(0,a.jsx)(e5,{actualOutput:n,existingCorrection:l,observationId:y,projectId:v,traceId:j,environment:b,compact:!0})}),L&&e.push({key:"metadata",title:"Metadata",data:s,backgroundColor:A,minHeight:"200px"}),e},[M,D,L,t,n,s,E,O,A,C,y,l,v,j,b]);if(o)return(0,a.jsx)("div",{className:"flex min-h-0 flex-1 flex-col border-b border-t",children:(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"Parsing data..."})})});let er=(0,a.jsx)(ew,{ref:Q,sections:ea,virtualized:R,showLineNumbers:!0,enableCopy:!0,stringWrapMode:V,truncateStringsAt:"truncate"===V?100:null,searchQuery:H,currentMatchIndex:U,onSearchResults:$,scrollC
1ontainerRef:K,media:u,commentedPathsByField:g,externalExpansionState:w,onExpansionChange:N,theme:{fontSize:"0.7rem",lineHeight:14,indentSize:12}});return(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col border-b border-t","data-sentry-component":"IOPreviewJSONInner","data-sentry-source-file":"IOPreviewJSON.tsx",children:[x&&(0,a.jsx)(e_,{onAddComment:I}),(0,a.jsxs)("div",{className:"flex h-9 flex-shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[(0,a.jsx)(eN.uB,{className:"flex-1 rounded-none border-0 bg-transparent","data-sentry-element":"Command","data-sentry-source-file":"IOPreviewJSON.tsx",children:(0,a.jsx)(eN.G7,{showBorder:!1,placeholder:"Search across all sections...",className:"h-7 border-0 focus:ring-0",value:_,onValueChange:F,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),e.shiftKey?X():q()):"Escape"===e.key&&Z()},"data-sentry-element":"CommandInput","data-sentry-source-file":"IOPreviewJSON.tsx"})}),_&&(0,a.jsx)("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:G>0?"".concat(U+1," of ").concat(G):"No matches"}),_&&G>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eC.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:X,title:"Previous match (Shift+Enter)",children:(0,a.jsx)(eS.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(eC.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:q,title:"Next match (Enter)",children:(0,a.jsx)(P.A,{className:"h-3.5 w-3.5"})})]}),(0,a.jsx)(eC.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Y,title:"String wrap mode: ".concat(V),"data-sentry-element":"Button","data-sentry-source-file":"IOPreviewJSON.tsx",children:en}),(0,a.jsx)(eC.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:et,title:"Copy to clipboard","data-sentry-element":"Button","data-sentry-source-file":"IOPreviewJSON.tsx",children:(0,a.jsx)(ec.A,{className:"h-3.5 w-3.5","data-sentry-element":"Copy","data-sentry-source-file":"IOPreviewJSON.tsx"})})]}),(0,a.jsxs)("div",{className:"flex h-6 flex-shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Jump to:"}),ea.map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center",children:[(0,a.jsx)("button",{onClick:()=>ee(e.key),className:"cursor-pointer text-xs text-primary hover:underline",children:e.title}),t<ea.length-1&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:",\xa0"})]},e.key)),R&&(0,a.jsxs)(el.jc,{children:[(0,a.jsx)(el.d0,{asChild:!0,children:(0,a.jsx)("span",{className:"ml-auto cursor-help rounded bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground",children:"Virtualized"})}),(0,a.jsx)(el.Et,{className:"w-80",side:"bottom",align:"end",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Virtualized View"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["This view is using virtualization due to a large number of keys (",B.input.toLocaleString()," input,"," ",B.output.toLocaleString()," output,"," ",B.metadata.toLocaleString()," metadata). Only visible rows are rendered for optimal performance."]})]})})]})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",ref:K,children:x?(0,a.jsx)(eV,{enabled:x,children:er}):er})]})}function e3(e){return e.enableInlineComments?(0,a.jsx)(eM,{children:(0,a.jsx)(e2,{...e})}):(0,a.jsx)(e2,{...e,"data-sentry-element":"IOPreviewJSONInner","data-sentry-component":"IOPreviewJSON","data-sentry-source-file":"IOPreviewJSON.tsx"})}var e4=n(45596),e6=n(85369);function e7(e){var t,n,s;let{input:l,output:o,metadata:i,outputCorrection:d,parsedInput:c,parsedOutput:u,parsedMetadata:m,isLoading:p=!1,isParsing:h=!1,hideIfNull:x=!1,hideOutput:f=!1,hideInput:g=!1,media:y,inputExpanded:v,outputExpanded:j,metadataExpanded:b,onInputExpandedChange:w,onOutputExpandedChange:N,onMetadataExpandedChange:C,observationId:T,projectId:I,traceId:S,environment:k="default",showCorrections:E=!0}=e,O=(0,r.useMemo)(()=>{if(!h)return null!=c?c:(0,e4.deepParseJson)(l)},[c,l,h]),A=(0,r.useMemo)(()=>
1{if(!h)return null!=u?u:(0,e4.deepParseJson)(o)},[u,o,h]),M=(0,r.useMemo)(()=>{if(!h)return null!=m?m:(0,e4.deepParseJson)(i)},[m,i,h]),D=!g&&!(x&&!O),P=!f&&!(x&&!A),L=!(x&&!M);return(0,a.jsxs)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2","data-sentry-component":"IOPreviewJSONSimple","data-sentry-source-file":"IOPreviewJSONSimple.tsx",children:[D&&(0,a.jsx)(e6.U,{title:"Input",json:l,parsedJson:O,isLoading:p,isParsing:h,media:null!=(t=null==y?void 0:y.filter(e=>"input"===e.field))?t:[],currentView:"json",externalExpansionState:v,onExternalExpansionChange:w}),P&&(0,a.jsx)(e6.U,{title:"Output",json:o,parsedJson:A,isLoading:p,isParsing:h,media:null!=(n=null==y?void 0:y.filter(e=>"output"===e.field))?n:[],currentView:"json",externalExpansionState:j,onExternalExpansionChange:N}),E&&(0,a.jsx)(e5,{actualOutput:A,existingCorrection:d,observationId:T,projectId:I,traceId:S,environment:k}),L&&(0,a.jsx)(e6.U,{title:"Metadata",json:i,parsedJson:M,isLoading:p,isParsing:h,media:null!=(s=null==y?void 0:y.filter(e=>"metadata"===e.field))?s:[],currentView:"json",externalExpansionState:b,onExternalExpansionChange:C})]})}var e9=n(96510),e8=n(27185),te=n(3341),tt=n(18254),tn=n(67716);function ta(e){let{tools:t,toolCallCounts:n,toolNameToDefinitionNumber:s,className:o}=e,[i,c]=(0,r.useState)(null),[u,m]=(0,l.A)("toolCallPillViewPreference","formatted");return t&&0!==t.length?(0,a.jsx)("div",{className:(0,eu.cn)("flex flex-col gap-2",o),"data-sentry-component":"ToolCallDefinitionCard","data-sentry-source-file":"ToolCallDefinitionCard.tsx",children:t.map((e,t)=>{let r=i===t,l=n.get(e.name)||0,o=l>0,p=null==s?void 0:s.get(e.name);return(0,a.jsxs)("div",{className:"w-full overflow-hidden rounded-sm border",children:[(0,a.jsxs)("div",{className:"flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-1.5 hover:bg-muted/20",onClick:()=>{c(r?null:t)},children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(tt.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsxs)("span",{className:"font-mono text-xs font-medium text-foreground",children:[void 0!==p&&(0,a.jsxs)("span",{className:"mr-1",children:[p,"."]}),e.name]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(tn.E,{variant:o?void 0:"secondary",className:(0,eu.cn)("text-xs font-medium",o&&"select-none border-transparent bg-light-green text-dark-green hover:bg-light-green"),children:0===l?"not called":1===l?"called":"called ".concat(l,"x")}),r?(0,a.jsx)(P.A,{className:"h-3.5 w-3.5 text-muted-foreground"}):(0,a.jsx)(L.A,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),r&&(0,a.jsxs)("div",{className:"relative border-t border-border bg-muted/30 px-4 py-3",children:[(0,a.jsx)("div",{className:"absolute right-4 top-1",children:(0,a.jsx)(d.tU,{className:"h-fit py-0.5",value:u,onValueChange:e=>m(e),children:(0,a.jsxs)(d.j7,{className:"h-fit p-0.5",children:[(0,a.jsx)(d.Xi,{value:"formatted",className:"h-fit px-1 text-xs",children:"Formatted"}),(0,a.jsx)(d.Xi,{value:"json",className:"h-fit px-1 text-xs",children:"JSON"})]})})}),"formatted"===u&&(0,a.jsxs)("div",{className:"space-y-4",children:[e.description&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:"Description"}),(0,a.jsx)("div",{className:"text-sm text-foreground",children:e.description})]}),e.parameters&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:"Parameters"}),(0,a.jsx)(e6.U,{json:e.parameters,currentView:"pretty",codeClassName:"text-xs"})]}),!e.description&&!e.parameters&&(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"No additional details available"})]}),"json"===u&&(0,a.jsx)(e6.U,{json:e,currentView:"json",codeClassName:"text-xs"})]})]},"".concat(e.name,"-").concat(t))})}):null}function tr(e){let{tools:t,toolCallCounts:n,toolNameToDefinitionNumber:r}=e;return 0===t.length?null:(0,a.jsx)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2","data-sentry-component":"SectionToolDefinitions","data-sentry-source-file":"SectionToolDefinitions.tsx",children:(0,a.jsxs)("div",{className:"mb-4 border-b border-border pb-4",children:[(0,a.jsx)("div",{className:"io-message-header px-1 py-1 text-sm font-medium capitalize",children:"Tools"}),(0,a.jsx)(ta,{tools:t,toolCallCounts:n,toolNameToDefinitionNumber:r,className:"px-2","data-sentry-element":"ToolCallDefinitionCard","data-sentry-source-file":"SectionToolDefinitions.tsx"})]})})}function ts(e){var t,n;let{parsedInput:r,parsedOutput:s,isLoading:l,isParsing:o,media:i,hideIfNull:d,hideInput:c,hideOutput:u,inputExpansionState:m,outputExpansionState:p,onInputExpansionChange:h,onOutputExpansionChange:x}=e,f=!c&&!(d&&!r),g=!u&&!(d&&!s);return(0,a.jsxs)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2","data-sentry-component":"JsonInputOutputView","data-sentry-source-file":"IOPreviewPretty.tsx",children:[f&&(0,a.jsx)(e6.U,{title:"Input",json:null!=r?r:null,isLoading:l,isParsing:o,media:null!=(t=null==i?void 0:i.filter(e=>"input"===e.field))?t:[],currentView:"pretty",externalExpansionState:m,onExternalExpansionChange:h}),g&&(0,a.jsx)(e6.U,{title:"Output",json:s,isLoading:l,isParsing:o,media:null!=(n=null==i?void 0:i.filter(e=>"output"===e.field))?n:[],currentView:"pretty",externalExpansionState:p,onExternalExpansionChange:x})]})}function tl(e){var t;
1let{input:n,output:s,metadata:l,outputCorrection:o,parsedInput:i,parsedOutput:d,parsedMetadata:c,observationName:u,isLoading:m=!1,isParsing:p=!1,hideIfNull:h=!1,hideOutput:x=!1,hideInput:f=!1,media:g,inputExpansionState:y,outputExpansionState:v,metadataExpansionState:j,onInputExpansionChange:b,onOutputExpansionChange:w,onMetadataExpansionChange:N,showMetadata:C=!1,observationId:T,projectId:I,traceId:S,environment:k="default",showCorrections:E=!0}=e,O=p?void 0:null!=i?i:(0,e4.deepParseJson)(n,{maxSize:3e5,maxDepth:2}),A=p?void 0:null!=d?d:(0,e4.deepParseJson)(s,{maxSize:3e5,maxDepth:2}),M=p?void 0:null!=c?c:(0,e4.deepParseJson)(l,{maxSize:1e5,maxDepth:2}),{canDisplayAsChat:D,allMessages:P,additionalInput:L,allTools:B,toolCallCounts:R,messageToToolCallNumbers:V,toolNameToDefinitionNumber:z,inputMessageCount:_}=function(e,t,n,a,s,l,o){let i=void 0!==s?s:(0,e4.deepParseJson)(e,{maxSize:3e5,maxDepth:25}),d=void 0!==l?l:(0,e4.deepParseJson)(t,{maxSize:3e5,maxDepth:25}),c=void 0!==o?o:(0,e4.deepParseJson)(n,{maxSize:1e5,maxDepth:25});return(0,r.useMemo)(()=>{let e={metadata:c,observationName:a},t=(0,e8.kz)(i,e),n=(0,e8.Zy)(d,e),r=(0,e8.ey)(d,d),s=(0,e8.vm)(t,n,r),l=new Map;for(let e of s)if(e.tools&&Array.isArray(e.tools))for(let t of e.tools)l.has(t.name)||l.set(t.name,t);let o=t.success?t.data.length:0,u=0,m=new Map,p=new Map;for(let e=0;e<s.length;e++){let t=s[e],n=e>=o,a=function(e){var t,n;return e.tool_calls&&Array.isArray(e.tool_calls)?e.tool_calls:(null==(t=e.json)?void 0:t.tool_calls)&&Array.isArray(null==(n=e.json)?void 0:n.tool_calls)?e.json.tool_calls:[]}(t);if(a.length>0){let t=[];for(let e of a){let a=e.name&&"string"==typeof e.name?e.name:e.toolName&&"string"==typeof e.toolName?e.toolName:void 0;
1a&&n&&(p.set(a,(p.get(a)||0)+1),u++,t.push(u))}t.length>0&&m.set(e,t)}}let h=Array.from(l.values()).sort((e,t)=>{let n=p.get(e.name)||0,a=p.get(t.name)||0;return n>0&&0===a?-1:0===n&&a>0?1:a-n}),x=new Map;return h.forEach((e,t)=>{x.set(e.name,t+1)}),{canDisplayAsChat:(t.success||n.success)&&s.length>0,allMessages:s,additionalInput:(0,e8.zx)(i),allTools:h,toolCallCounts:p,messageToToolCallNumbers:m,toolNameToDefinitionNumber:x,inputMessageCount:o}},[i,d,c,a])}(n,s,l,u,O,A,M),F=(0,r.useMemo)(()=>{let e=t=>null==t?4:"string"==typeof t?t.length:"number"==typeof t?t.toString().length:"boolean"==typeof t?t?4:5:Array.isArray(t)?t.reduce((t,n)=>t+e(n)+1,2):"object"==typeof t?Object.entries(t).reduce((t,n)=>{let[a,r]=n;return t+a.length+e(r)+3},2):0,t=e(O),n=e(A);return t+n+e(P)<=e9.x},[O,A,P]),H=(0,r.useMemo)(()=>{if(L&&0!==Object.keys(L).length)return L},[L]),J=C&&void 0!==M;return(0,a.jsxs)("div",{"data-sentry-component":"IOPreviewPretty","data-sentry-source-file":"IOPreviewPretty.tsx",children:[(0,a.jsx)(tr,{tools:B,toolCallCounts:R,toolNameToDefinitionNumber:z,"data-sentry-element":"SectionToolDefinitions","data-sentry-source-file":"IOPreviewPretty.tsx"}),D?(0,a.jsxs)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2",children:[(0,a.jsx)(te.a,{messages:P,shouldRenderMarkdown:F,additionalInput:H,media:null!=g?g:[],currentView:"pretty",messageToToolCallNumbers:V,inputMessageCount:_}),E&&(0,a.jsx)(e5,{actualOutput:A,existingCorrection:o,observationId:T,projectId:I,traceId:S,environment:k})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ts,{parsedInput:O,parsedOutput:A,isLoading:m,isParsing:p,media:g,hideIfNull:h,hideInput:f,hideOutput:x,inputExpansionState:y,outputExpansionState:v,onInputExpansionChange:b,onOutputExpansionChange:w}),(0,a.jsx)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2",children:E&&(0,a.jsx)(e5,{actualOutput:A,existingCorrection:o,observationId:T,projectId:I,traceId:S,environment:k})})]}),J&&(0,a.jsx)("div",{className:"[&_.io-message-content]:px-2 [&_.io-message-header]:px-2",children:(0,a.jsx)(e6.U,{title:"Metadata",json:M,isLoading:m,isParsing:p,media:null!=(t=null==g?void 0:g.filter(e=>"metadata"===e.field))?t:[],currentView:"pretty",externalExpansionState:j,onExternalExpansionChange:N})})]})}var to=n(68048),ti=n(41641),td=n(69157);let tc="empty-io";function tu(e){let{input:t,output:n,outputCorrection:o,metadata:d,parsedInput:c,parsedOutput:u,parsedMetadata:p,observationName:h,isLoading:x=!1,isParsing:f=!1,hideIfNull:g=!1,hideOutput:y=!1,hideInput:v=!1,media:j,currentView:b,inputExpansionState:w,outputExpansionState:N,metadataExpansionState:C,onInputExpansionChange:T,onOutputExpansionChange:I,onMetadataExpansionChange:S,advancedJsonExpansionState:k,onAdvancedJsonExpansionChange:E,jsonInputExpanded:O,jsonOutputExpanded:A,jsonMetadataExpanded:M,onJsonInputExpandedChange:D,onJsonOutputExpandedChange:P,onJsonMetadataExpandedChange:L,setIsPrettyViewAvailable:B,enableInlineComments:R,onAddInlineComment:V,commentedPathsByField:z,showMetadata:_=!1,onVirtualizationChange:F,observationId:H,projectId:J,traceId:U,environment:W="default",showCorrections:G=!0}=e,$=(0,s.B)(),[K,Q]=(0,l.A)("dismissed-trace-view-notifications",[]),[q,X]=(0,l.A)("jsonViewPreference","pretty"),Z=null!=b?b:q,[Y,ee]=i([Z]);(0,r.useEffect)(()=>{null==B||B(!0)},[B]);let et=null!=n,en=null==t&&!et&&!h&&!x&&!g&&!K.includes(tc);return(0,a.jsxs)(a.Fragment,{children:[void 0===b&&(0,a.jsx)(m,{selectedView:Z,onViewChange:e=>{ee(),$("trace_detail:io_mode_switch",{view:e}),X(e)},compensateScrollRef:Y}),"json-beta"===Z?(0,a.jsx)(e3,{parsedInput:c,parsedOutput:u,parsedMetadata:p,outputCorrection:o,isParsing:f,hideIfNull:g,hideInput:v,hideOutput:y,media:j,expansionState:k,onExpansionChange:E,onVirtualizationChange:F,enableInlineComments:R,onAddInlineComment:V,commentedPathsByField:z,observationId:H,projectId:J,traceId:U,environment:W,showCorrections:G}):"json"===Z?(0,a.jsx)(e7,{input:t,output:n,metadata:d,outputCorrection:o,parsedInput:c,parsedOutput:u,parsedMetadata:p,isLoading:x,isParsing:f,hideIfNull:g,hideInput:v,hideOutput:y,media:j,inputExpanded:O,outputExpanded:A,metadataExpanded:M,onInputExpandedChange:D,onOutputExpandedChange:P,onMetadataExpandedChange:L,observationId:H,projectId:J,traceId:U,environment:W}):(0,a.jsx)(tl,{input:t,output:n,outputCorrection:o,metadata:d,parsedInput:c,parsedOutput:u,parsedMetadata:p,isLoading:x,isParsing:f,hideIfNull:g,hideInput:v,hideOutput:y,media:j,inputExpansionState:w,outputExpansionState:N,metadataExpansionState:C,onInputExpansionChange:T,onOutputExpansionChange:I,onMetadataExpansionChange:S,observationId:H,projectId:J,traceId:U,environment:W,showCorrections:G,observationName:h,showMetadata:_}),en&&(0,a.jsx)("div",{className:"py-2",children:(0,a.jsxs)("div",{className:"relative mx-2 flex flex-col items-start gap-2 rounded-lg border border-dashed p-4",children:[(0,a.jsx)(eC.$,{variant:"ghost",size:"sm",className:"absolute right-1.5 top-1.5 h-5 w-5 p-0",onClick:()=>{$("notification:dismiss_notification",{notification_id:tc}),Q(e=>e.includes(tc)?e:[...e,tc])},title:"Dismiss",children:(0,a.jsx)(ti.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)("div",{className:"flex w-full flex-row items-center gap-2 pr-6",children:[(0,a.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent",children:(0,a.jsx)(td.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,a.jsx)("h3",{className:"text-sm font-semibold",children:"Looks like this trace didn't receive an input or output."})]}),(0,a.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Add it in your code to make debugging a lot easier."}),(0,a.jsx)(to.r,{variant:"outline",size:"sm",href:"https://langfuse.com/faq/all/empty-trace-input-and-output",trackingEventName:"notification:click_link",trackingProps:{notification_id:tc},children:"View Documentation"})]})})]})}},70242:(e,t,n)=>{n.d(t,{j:()=>u});var a=n(73154),r=n(86843),s=n(92273),l=n(66798),o=n(96810),i=n(97638),d=n(81509),c=n(42661);let u=e=>{let{idItems:t,className:n}=e,[u,m]=(0,o.useState)(null),p=e=>{(0,c.e)(e),m(e),setTimeout(()=>m(null),1500)};return 1===t.length?(0,a.jsxs)(r.$,{variant:"ghost",title:"Copy ID",className:(0,d.cn)("h-fit p-1",
1n),onClick:()=>p(t[0].id),children:[u===t[0].id?(0,a.jsx)(s.A,{className:"h-3 w-3 text-muted-green"}):(0,a.jsx)(l.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"ml-1 text-xs",children:"ID"})]}):(0,a.jsxs)(i.AM,{"data-sentry-element":"Popover","data-sentry-component":"CopyIdsPopover","data-sentry-source-file":"CopyIdsPopover.tsx",children:[(0,a.jsx)(i.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"CopyIdsPopover.tsx",children:(0,a.jsxs)(r.$,{variant:"ghost",title:"Copy ID",className:(0,d.cn)("h-fit px-1",n),"data-sentry-element":"Button","data-sentry-source-file":"CopyIdsPopover.tsx",children:[(0,a.jsx)(l.A,{className:"h-3 w-3","data-sentry-element":"CopyIcon","data-sentry-source-file":"CopyIdsPopover.tsx"}),(0,a.jsx)("span",{className:"ml-1 text-xs",children:"ID"})]})}),(0,a.jsx)(i.hl,{className:"max-h-[50vh] w-auto min-w-[280px] overflow-y-auto p-1",align:"start","data-sentry-element":"PopoverContent","data-sentry-source-file":"CopyIdsPopover.tsx",children:(0,a.jsx)("div",{className:"flex flex-col gap-0.5",children:t.map(e=>(0,a.jsxs)("div",{className:"group flex items-center justify-between gap-2 rounded-sm px-2 py-1.5 transition-colors hover:bg-muted/50",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e.name}),(0,a.jsx)("span",{className:"max-w-[220px] truncate font-mono text-xs",title:e.id,children:e.id})]}),(0,a.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-70 transition-opacity group-hover:opacity-100",onClick:()=>p(e.id),children:u===e.id?(0,a.jsx)(s.A,{className:"h-3 w-3 text-muted-green"}):(0,a.jsx)(l.A,{className:"h-3 w-3"})})]},e.id))})})]})}},73156:(e,t,n)=>{n.d(t,{Q:()=>_});var a=n(73154),r=n(325),s=n(86843),l=n(10873),o=n(97898),i=n(53524),d=n(49568),c=n(61653),u=n(90270),m=n(18799),p=n(93367),h=n(47106),x=n(81509),f=n(33100),g=n(45596),y=n(51883),v=n(27131),j=n(41641),b=n(55247),w=n(84621),N=n(38834),C=n(96810),T=n(17020),I=n(16766),S=n(95266);function k(e){var t;let{users:n,isLoading:s,selectedIndex:l,onSelect:o,onClose:i,onSelectedIndexChange:d}=e,c=(0,C.useRef)(null);(0,C.useEffect)(()=>{var e;null==(e=c.current)||e.scrollIntoView({block:"nearest"})},[l]);let u=null==(t=n[l])?void 0:t.id,m=n.slice(0,3),p=n.length-3;return(0,a.jsx)("div",{className:"absolute bottom-full left-0 right-0 z-50 mb-1",role:"region","aria-label":"User mention suggestions","data-sentry-component":"MentionAutocomplete","data-sentry-source-file":"MentionAutocomplete.tsx",children:(0,a.jsx)(S.uB,{className:"max-h-60 rounded-md border shadow-md",value:u,"aria-label":"Mention user autocomplete","data-sentry-element":"Command","data-sentry-source-file":"MentionAutocomplete.tsx",children:(0,a.jsxs)(S.oI,{role:"listbox","aria-activedescendant":u||"","data-sentry-element":"CommandList","data-sentry-source-file":"MentionAutocomplete.tsx",children:[s&&(0,a.jsxs)("div",{className:"flex items-center justify-center p-3",role:"status","aria-live":"polite",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{className:"sr-only",children:"Loading users..."})]}),!s&&0===n.length&&(0,a.jsx)(S.xL,{role:"status",children:"No users found"}),!s&&n.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.L$,{children:m.map((e,t)=>{var n;let s=e.name||e.email||"User",i=t===l;return(0,a.jsxs)(S.h_,{value:e.id,onSelect:()=>o(e.id,s),onMouseEnter:()=>d(t),ref:i?c:null,role:"option","aria-selected":i,id:e.id,children:[(0,a.jsx)(r.eu,{className:"h-6 w-6","aria-hidden":"true",children:(0,a.jsx)(r.q5,{className:"text-xs",children:e.name?e.name[0]:(null==(n=e.email)?void 0:n[0])||"U"})}),(0,a.jsxs)("div",{className:"flex-1 overflow-hidden text-foreground",children:[(0,a.jsx)("div",{className:"truncate font-medium",children:e.name||"Unknown"}),e.email&&(0,a.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]},e.id)})}),p>0&&(0,a.jsxs)("div",{className:"border-t px-2 py-2 text-xs text-muted-foreground",role:"status","aria-live":"polite",children:["and ",p," more..."]})]})]})})})}var E=n(39156),O=n(97638),A=n(78580),M=n(53887);function D(e){let{onEmojiSelect:t,disabled:n=!1}=e,[r,l]=(0,C.useState)(!1);return(0,a.jsxs)(O.AM,{open:r,onOpenChange:l,"data-sentry-element":"Popover","data-sentry-component":"ReactionPicker","data-sentry-source-file":"ReactionPicker.tsx",children:[(0,a.jsx)(O.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"ReactionPicker.tsx",children:(0,a.jsx)(s.$,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1 px-1.5 text-xs opacity-50 transition-opacity hover:opacity-100",disabled:n,"data-sentry-element":"Button","data-sentry-source-file":"ReactionPicker.tsx",children:(0,a.jsx)(A.A,{className:"h-3.5 w-3.5","data-sentry-element":"SmilePlusIcon","data-sentry-source-file":"ReactionPicker.tsx"})})}),(0,a.jsx)(O.hl,{className:"w-fit border-none bg-transparent p-0",align:"start","data-sentry-element":"PopoverContent","data-sentry-source-file":"ReactionPicker.tsx",children:(0,a.jsxs)(M.p,{onEmojiSelect:e=>{t(e),l(!1)},className:"h-[320px] w-[320px]","data-sentry-element":"EmojiPicker","data-sentry-source-file":"ReactionPicker.tsx",children:[(0,a.jsx)(M.p.Header,{className:"border-b px-2 py-2","data-sentry-element":"EmojiPicker.Header","data-sentry-source-file":"ReactionPicker.tsx",children:(0,a.jsx)(M.p.Input,{placeholder:"Search emoji...",className:"w-full rounded border py-1 text-sm outline-none focus:border-primary","data-sentry-element":"EmojiPicker.Input","data-sentry-source-file":"ReactionPicker.tsx"})}),(0,a.jsx)(M.p.Group,{className:"overflow-y-auto overscroll-contain","data-sentry-element":"EmojiPicker.Group","data-sentry-source-file":"ReactionPicker.tsx",children:(0,a.jsx)(M.p.List,{containerHeight:256,"data-sentry-element":"EmojiPicker.List","data-sentry-source-file":"ReactionPicker.tsx"})})]})})]})}function P(e){let{projectId:t,commentId:n,onReactionToggle:r}=e,{data:l}=p.FH.commentReactions.listForComment.useQuery({projectId:t,commentId:n});return l&&0!==l.length?(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1","data-sentry-component":"ReactionBar","data-sentry-source-file":"ReactionBar.tsx",children:l.map(e=>{let t=(0,a.jsxs)(s.$,{type:"button",variant:"ghost",size:"sm",className:(0,x.cn)("h-6 gap-1 rounded-full px-2 text-sm transition-colors",e.hasReacted?"bg-primary/10 hover:bg-primary/20":"bg-muted/20 hover:bg-muted/40"),onClick:()=>r(e.emoji,e.hasReacted),children:[(0,a.jsx)("span",{children:e.emoji}),(0,a.jsx)("span",{className:"text-[0.6rem] text-muted-foreground
1/80",children:e.count})]});return e.users?(0,a.jsxs)(o.jc,{openDelay:200,children:[(0,a.jsx)(o.d0,{asChild:!0,children:t}),(0,a.jsx)(o.Et,{className:"w-fit p-2",side:"top",children:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:e.users.map(e=>(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:e.name||"Unknown user"},e.id))})})]},e.emoji):(0,a.jsx)("div",{children:t},e.emoji)})}):null}var L=n(79057),B=n(67716),R=n(97974);let V={input:{light:"rgb(249, 252, 255)",dark:"rgb(15, 23, 42)"},output:{light:"rgb(248, 253, 250)",dark:"rgb(20, 30, 41)"},metadata:{light:"rgb(253, 251, 254)",dark:"rgb(30, 20, 40)"}},z=C.useLayoutEffect;function _(e){var t,n,S,O,A,M,_;let{projectId:F,objectId:H,objectType:J,cardView:U=!1,className:W,onDraftChange:G,onMentionDropdownChange:$,isDrawerOpen:K=!1,pendingSelection:Q,onSelectionUsed:q}=e,X=(0,N.useSession)(),Z=(0,E.useRouter)(),{resolvedTheme:Y}=(0,R.D)(),ee="dark"===Y,[et,en]=(0,C.useState)(0),[ea,er]=(0,C.useState)(""),es=(0,C.useRef)(null),el=(0,C.useRef)(null),eo=(0,C.useRef)(null),ei=(0,C.useRef)(!1),ed=(0,C.useMemo)(()=>{let e=window.location.hash;return e.startsWith("#comment-")?e.replace("#comment-",""):null},[Z.asPath]),ec=(0,m.lp)({projectId:F,scope:"comments:read"}),eu=(0,m.lp)({projectId:F,scope:"comments:CUD"}),em=(0,m.lp)({projectId:F,scope:"projectMembers:read"}),ep=eu&&em,eh=p.FH.comments.getByObjectId.useQuery({projectId:F,objectId:H,objectType:J},{enabled:ec&&"authenticated"===X.status}),ex=(0,T.mN)({resolver:(0,f.u)(g.CreateCommentData),defaultValues:{content:"",projectId:F,objectId:H,objectType:J}});(0,C.useEffect)(()=>{ex.reset({content:"",projectId:F,objectId:H,objectType:J}),er("")},[H,J]);let ef=function(e){let{projectId:t,getTextareaValue:n,cursorPosition:a,enabled:r}=e,[s,l]=(0,C.useState)(!1),[o,i]=(0,C.useState)(null),[d,c]=(0,C.useState)(0),u=(0,I.z)({projectId:t,limit:10,enabled:r&&s}),{setSearchQuery:m}=u;(0,C.useEffect)(()=>{if(!r)return;let e=n().substring(0,a),t=e.lastIndexOf("@");if(-1===t){l(!1),i(null);return}let s=e[t-1];if(!(0===t||/\s/.test(s)))return void l(!1);let o=e.substring(t+1);if(/\s/.test(o))return void l(!1);i(t),m(o),l(!0),c(0)},[n,a,r,m]);let p=(0,C.useCallback)(()=>{l(!1),i(null),m("")},[m]);return{showDropdown:s,users:u.searchResults,isLoading:u.isLoading,selectedIndex:d,setSelectedIndex:c,mentionStartPos:o,closeDropdown:p}}({projectId:F,getTextareaValue:(0,C.useCallback)(()=>ex.getValues("content"),[ex]),cursorPosition:et,enabled:ep});(0,C.useEffect)(()=>{null==$||$(ef.showDropdown)},[ef.showDropdown,$]);let eg=(0,C.useCallback)(e=>{requestAnimationFrame(()=>{if(e){e.style.height="auto";let t=Math.min(e.scrollHeight,100);e.style.height="".concat(t,"px")}})},[]),ey=(0,C.useCallback)(()=>{let e;return{resize:t=>{clearTimeout(e),e=setTimeout(()=>eg(t),16)},cleanup:()=>clearTimeout(e)}},[eg]),ev=(0,C.useMemo)(()=>ey(),[ey]);(0,C.useEffect)(()=>()=>{ev.cleanup()},[ev]);let ej=ex.watch("content");(0,C.useEffect)(()=>{G&&G(!!(ej&&ej.trim().length>0))},[ej]),z(()=>{if(ei.current||!eh.data||!es.current||ed)return;let e=es.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),ei.current=!0},[eh.data,ed]),z(()=>{if(!ed||!eh.data)return;let e=document.getElementById("comment-".concat(ed));e&&e.scrollIntoView({block:"center",behavior:"smooth"})},[eh.data,ed]),(0,C.useEffect)(()=>{Q&&el.current&&setTimeout(()=>{var e;null==(e=el.current)||e.focus()},150)},[Q]),(0,C.useEffect)(()=>{if(!K)return;let e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLElement&&"textbox"===e.target.getAttribute("role"))&&(e.metaKey||e.ctrlKey)&&"f"===e.key){var t;
1e.preventDefault(),e.stopPropagation(),null==(t=eo.current)||t.focus()}};return window.addEventListener("keydown",e,{capture:!0}),()=>window.removeEventListener("keydown",e,{capture:!0})},[K]);let eb=p.FH.useUtils(),ew=p.FH.comments.create.useMutation({onSuccess:async()=>{await Promise.all([eb.comments.invalidate()]),ex.reset(),null==q||q(),el.current&&(el.current.style.height="auto"),es.current&&es.current.scrollTo({top:es.current.scrollHeight,behavior:"smooth"})}}),eN=(0,C.useCallback)((e,t)=>{if(!el.current||null===ef.mentionStartPos)return;let n=el.current,a=ex.getValues("content"),r=n.selectionStart,s=a.substring(0,ef.mentionStartPos),l=a.substring(r),o="@[".concat(t,"](").concat(L.UI).concat(e,") "),i=s+o+l,d=ef.mentionStartPos+o.length;ex.setValue("content",i,{shouldDirty:!0}),setTimeout(()=>{n.setSelectionRange(d,d),n.focus(),en(d)},0),ef.closeDropdown()},[ex,ef]),eC=p.FH.comments.delete.useMutation({onSuccess:async()=>{await Promise.all([eb.comments.invalidate()])}}),eT=p.FH.commentReactions.add.useMutation({onSuccess:async()=>{await Promise.all([eb.commentReactions.invalidate()])}}),eI=p.FH.commentReactions.remove.useMutation({onSuccess:async()=>{await Promise.all([eb.commentReactions.invalidate()])}}),eS=(0,C.useMemo)(()=>{var e;return null==(e=eh.data)?void 0:e.map(e=>({...e,timestamp:(0,h.Jt)(e.createdAt),strippedLower:e.content.replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^\)]+\)/g,"$1").replace(/[*_~`#]/g,"").replace(/^>\s+/gm,"").replace(/^[-*+]\s+/gm,"").replace(/^\d+\.\s+/gm,"").replace(/\n+/g," ").trim().toLowerCase(),authorLower:(e.authorUserName||e.authorUserId||"").toLowerCase()})).sort((e,t)=>e.createdAt.getTime()-t.createdAt.getTime())},[eh.data]),ek=(0,C.useMemo)(()=>{if(!ea.trim())return eS;let e=ea.toLowerCase();return null==eS?void 0:eS.filter(t=>{let n=t.strippedLower.includes(e),a=t.authorLower.includes(e);return n||a})},[eS,ea]);if(!ec||!eu&&(null==(t=eh.data)?void 0:t.length)===0||"authenticated"!==X.status)return null;function eE(e){ew.mutateAsync({...e,dataField:null==Q?void 0:Q.dataField,path:null==Q?void 0:Q.path,rangeStart:null==Q?void 0:Q.rangeStart,rangeEnd:null==Q?void 0:Q.rangeEnd})}let eO=e=>{if("Enter"===e.key&&e.metaKey){e.preventDefault(),ex.handleSubmit(eE)();return}if(ef.showDropdown&&0!==ef.users.length){if("ArrowDown"===e.key){e.preventDefault();let t=(ef.selectedIndex+1)%ef.users.length;ef.setSelectedIndex(t);return}else if("ArrowUp"===e.key){e.preventDefault();let t=0===ef.selectedIndex?ef.users.length-1:ef.selectedIndex-1;ef.setSelectedIndex(t);return}else if("Enter"===e.key||"Tab"===e.key){e.preventDefault();let t=ef.users[ef.selectedIndex];if(t){let e=t.name||t.email||"User";eN(t.id,e)}return}else if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),ef.closeDropdown();return}}};return eh.isPending?(0,a.jsxs)("div",{className:(0,x.cn)("flex min-h-[5rem] items-center justify-center rounded border border-dashed p-1",W),children:[(0,a.jsx)(y.A,{className:"mr-1.5 h-4 w-4 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground opacity-60",children:"Loading comments..."})]}):(0,a.jsxs)("div",{className:(0,x.cn)(U&&"rounded-md border","flex h-full min-h-0 flex-col",W),"data-sentry-component":"CommentList","data-sentry-source-file":"CommentList.tsx",children:[U&&(0,a.jsxs)("div",{className:"flex-shrink-0 border-b px-2 py-1 text-sm font-medium",children:["Comments (",null!=(A=null==(n=eh.data)?void 0:n.length)?A:0,")"]}),(0,a.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[!U&&(0,a.jsxs)("div",{className:"flex-shrink-0 border-b",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 px-2 py-1.5",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:"Comments"}),(0,a.jsxs)("div",{className:"relative max-w-xs flex-1",children:[(0,a.jsx)(v.A,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,a.jsx)(u.p,{ref:eo,type:"text",placeholder:"Search comments...",value:ea,onChange:e=>er(e.target.value),className:"h-7 pl-7 pr-7 text-xs"}),ea&&(0,a.jsx)(s.$,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2",onClick:()=>er(""),children:(0,a.jsx)(j.A,{className:"h-3 w-3"})}),!ea&&(0,a.jsx)("kbd",{className:"pointer-events-none absolute right-1 top-1/2 h-5 -translate-y-1/2 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-50 sm:inline-flex",children:"undefined"!=typeof navigator&&navigator.platform.toLowerCase().includes("mac")?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-xs",children:"⌘"}),"F"]}):(0,a.jsx)(a.Fragment,{children:"Ctrl+F"})})]})]}),(0,a.jsx)("div",{className:"px-2 pb-1 text-xs text-muted-foreground",children:ea.trim()?ek&&ek.length>0?"Showing ".concat(ek.length," of ").concat(null!=(M=null==(S=eh.data)?void 0:S.length)?M:0," comments"):"No comments match your search":"".concat(null!=(_=null==(O=eh.data)?void 0:O.length)?_:0," comments")})]}),(0,a.jsx)("div",{ref:es,className:"flex min-h-0 flex-1 flex-col justify-end overflow-y-auto",children:(0,a.jsx)("div",{className:"max-h-full space-y-2 p-2",children:null==ek?void 0:ek.map(e=>{var t,n,l,o,c,u,m,p;return(0,a.jsxs)("div",{id:"comment-".concat(e.id),className:(0,x.cn)("group relative grid grid-cols-[auto,1fr] gap-2.5 rounded-lg border p-3 transition-colors",ed===e.id?"border-primary-accent":"border-border/40 hover:bg-muted/20"),children:[(0,a.jsxs)(r.eu,{className:"h-6 w-6",children:[(0,a.jsx)(r.BK,{src:null!=(o=e.authorUserImage)?o:void 0}),(0,a.jsx)(r.q5,{className:"text-xs",children:e.authorUserName?e.authorUserName.split(" ").map(e=>e[0]).slice(0,2).concat(""):null!=(c=e.authorUserId)?c:"U"})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center gap-2 pt-1.5 text-xs leading-none",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:null!=(m=null!=(u=e.authorUserName)?u:e.authorUserId)?m:"User"}
1),(0,a.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"}),(0,a.jsx)("span",{className:"text-muted-foreground/70",children:e.timestamp})]}),(0,a.jsx)(d.p,{markdown:e.content,className:"border-none p-0 py-1 text-xs [&_h1]:text-[0.9rem] [&_h1]:font-semibold [&_h2]:text-[0.85rem] [&_h2]:font-semibold [&_h3]:text-[0.8rem] [&_h3]:font-semibold [&_h4]:text-xs [&_h4]:font-medium [&_h5]:text-xs [&_h5]:font-medium [&_h6]:text-xs [&_h6]:font-medium [&_li]:text-xs [&_ol]:text-xs [&_p]:text-xs [&_ul]:text-xs"}),"dataField"in e&&e.dataField&&"path"in e&&Array.isArray(e.path)&&e.path.length>0&&(0,a.jsxs)(i.m_,{children:[(0,a.jsx)(i.k$,{asChild:!0,children:(0,a.jsxs)("div",{className:"mt-1 flex w-fit items-center gap-1.5 text-xs",children:[(0,a.jsx)(B.E,{className:"pointer-events-none px-1.5 py-0 text-[10px] font-medium text-foreground",style:{backgroundColor:null==(t=V[e.dataField])?void 0:t[ee?"dark":"light"]},children:e.dataField.toUpperCase()}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"$"===(p=e.path[0])?"(root)":p.replace(/^\$\.?/,"").replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean).join(" › ")})]})}),(0,a.jsx)(i.ZI,{side:"top",align:"start",className:"px-2 py-1 text-xs",children:"The location of the text commented on"})]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)(P,{projectId:F,commentId:e.id,onReactionToggle:(t,n)=>{n?eI.mutate({projectId:F,commentId:e.id,emoji:t}):eT.mutate({projectId:F,commentId:e.id,emoji:t})}}),eu&&(0,a.jsx)(D,{onEmojiSelect:t=>{eT.mutate({projectId:F,commentId:e.id,emoji:t})}})]})]}),(null==(l=X.data)||null==(n=l.user)?void 0:n.id)===e.authorUserId&&(0,a.jsx)("div",{className:"absolute right-2 top-2 opacity-50 transition-opacity hover:opacity-100",children:(0,a.jsx)(s.$,{type:"button",size:"icon-xs",variant:"ghost",title:"Delete comment",loading:eC.isPending,onClick:()=>{confirm("Are you sure you want to delete this comment?")&&eC.mutateAsync({commentId:e.id,projectId:F,objectId:H,objectType:J})},children:(0,a.jsx)(b.A,{className:"h-3 w-3"})})})]},e.id)})})}),eu&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"relative ml-2.5 mr-4 mt-2 flex flex-row items-center justify-between text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"sr-only",children:"New comment"}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{children:"Markdown and @-mentions support"})]}),(0,a.jsx)("div",{className:"relative mb-2 ml-2 mr-3 mt-0.5 min-h-[70px] flex-shrink-0 rounded-lg border border-border/60 pt-1",children:(0,a.jsx)(l.lV,{...ex,children:(0,a.jsxs)("form",{children:[(0,a.jsx)(l.zB,{control:ex.control,name:"content",render:e=>{let{field:t}=e;return(0,a.jsxs)(l.eI,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l.MJ,{children:(0,a.jsx)(c.T,{placeholder:"Add a comment...",...t,ref:e=>{el.current!==e&&(el.current=e),"function"==typeof t.ref&&t.ref(e)},onKeyDown:eO,className:"max-h-[100px] min-h-[2.25rem] w-full resize-none overflow-hidden border-none py-2 pr-7 text-xs leading-tight focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 active:ring-0",style:{whiteSpace:"pre-wrap",wordWrap:"break-word",overflowWrap:"break-word",height:"auto",minHeight:"2.25rem"},onInput:e=>{let t=e.target;ev.resize(t),en(t.selectionStart)},onClick:e=>{en(e.target.selectionStart)},onSelect:e=>{en(e.target.selectionStart)},autoFocus:!0})}),ep&&ef.showDropdown&&(0,a.jsx)(k,{users:ef.users,isLoading:ef.isLoading,selectedIndex:ef.selectedIndex,onSelect:eN,onClose:ef.closeDropdown,onSelectedIndexChange:ef.setSelectedIndex})]}),(0,a.jsx)(l.C5,{className:"ml-2 text-sm"})]})}}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsxs)(o.jc,{openDelay:200,children:[(0,a.jsx)(o.d0,{asChild:!0,children:(0,a.jsx)(s.$,{type:"submit",size:"icon-xs",variant:"outline",title:"Submit comment",loading:ew.isPending,onClick:()=>{ex.handleSubmit(eE)()},className:"absolute bottom-1 right-1",children:(0,a.jsx)(w.A,{className:"h-3 w-3"})})}),(0,a.jsx)(o.Et,{side:"top",align:"end",className:"w-auto p-2",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)("span",{children:"Send comment"}),(0,a.jsxs)("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",children:[(0,a.jsx)("span",{className:"text-xs",children:"⌘"}),"Enter"]})]})})]})})]})})})]})]})]})}},79077:(e,t,n)=>{n.d(t,{f:()=>a});let a={logView:{virtualizationThreshold:350,downloadThreshold:350,rowHeight:{collapsed:28,expanded:150},maxIndentDepth:5,indentPx:12,prefetch:{rootMargin:"100px",debounceMs:250},batchFetch:{concurrency:10}}}},81101:(e,t,n)=>{n.d(t,{y:()=>d});var a=n(9243);function r(e){if(null==e)return 0;if("string"==typeof e)return e.length;try{return JSON.stringify(e).length}catch(e){return 0}}let s=null,l=new Map;async function o(e,t,a){let{deepParseJsonIterative:r}=await Promise.resolve().then(n.t.bind(n,45596,23)),s=performance.now();return{input:r(e,{maxDepth:50,maxSize:5e5}),output:r(t,{maxDepth:50,maxSize:5e5}
1),metadata:r(a,{maxDepth:50,maxSize:5e5}),parseTime:performance.now()-s}}async function i(e,t,a){if(r(e)+r(t)+r(a)<1e5)return o(e,t,a);let i=function(){if(!window.Worker)return null;if(!s)try{(s=new Worker(n.tu(new URL(n.p+n.u(4444),n.b)))).onmessage=e=>{let t=l.get(e.data.id);t&&(t(e.data),l.delete(e.data.id))},s.onerror=e=>{console.error("[useParsedTrace] Worker error:",e)}}catch(e){return console.error("[useParsedTrace] Failed to create worker:",e),null}return s}();return i?new Promise((n,r)=>{let s="".concat(Date.now(),"-").concat(Math.random());l.set(s,e=>{var t;if(l.delete(s),e.error){console.error("[useParsedTrace] Parse error: ".concat(e.error)),r(Error(e.error));return}n({input:e.parsedInput,output:e.parsedOutput,metadata:e.parsedMetadata,parseTime:null!=(t=e.parseTime)?t:0})}),i.postMessage({id:s,input:e,output:t,metadata:a})}):o(e,t,a)}function d(e){var t,n,r,s,l;let{traceId:o,input:d,output:c,metadata:u}=e,m=(0,a.I)({queryKey:["parsed-trace",o,d,c,u],queryFn:async()=>i(d,c,u),enabled:!!(d||c||u),staleTime:1/0,gcTime:6e5});return{parsedInput:null==(t=m.data)?void 0:t.input,parsedOutput:null==(n=m.data)?void 0:n.output,parsedMetadata:null==(r=m.data)?void 0:r.metadata,isParsing:m.isLoading,isReady:!m.isLoading&&void 0!==m.data,parseTime:null==(s=m.data)?void 0:s.parseTime,parseError:null==(l=m.error)?void 0:l.message}}},84662:(e,t,n)=>{n.d(t,{V:()=>p});var a=n(9243),r=n(96810),s=n(93367),l=n(55803),o=n(54218);function i(e){if(null==e)return 0;if("string"==typeof e)return e.length;try{return JSON.stringify(e).length}catch(e){return 0}}let d=null,c=new Map;async function u(e,t,a){let{deepParseJsonIterative:r}=await Promise.resolve().then(n.t.bind(n,45596,23)),s=performance.now();return{input:r(e,{maxDepth:50,maxSize:5e5}),output:r(t,{maxDepth:50,maxSize:5e5}),metadata:r(a,{maxDepth:50,maxSize:5e5}),parseTime:performance.now()-s}}async function m(e,t,a){if(i(e)+i(t)+i(a)<1e5)return u(e,t,a);let r=function(){if(!window.Worker)return null;if(!d)try{(d=new Worker(n.tu(new URL(n.p+n.u(2063),n.b)))).onmessage=e=>{let t=c.get(e.data.id);t&&(t(e.data),c.delete(e.data.id))},d.onerror=e=>{console.error("[useParsedObservation] Worker error:",e)}}catch(e){return console.error("[useParsedObservation] Failed to create worker:",e),null}return d}();return r?new Promise((n,s)=>{let l="".concat(Date.now(),"-").concat(Math.random());c.set(l,e=>{var t;if(c.delete(l),e.error){console.error("[useParsedObservation] Parse error: ".concat(e.error)),s(Error(e.error));return}n({input:e.parsedInput,output:e.parsedOutput,metadata:e.parsedMetadata,parseTime:null!=(t=e.parseTime)?t:0})}),r.postMessage({id:l,input:e,output:t,metadata:a})}):u(e,t,a)}function p(e){var t,n,i,d,c;let{observationId:u,traceId:p,projectId:h,startTime:x,baseObservation:f}=e,{isBetaEnabled:g}=(0,l.I)(),y=s.FH.observations.byId.useQuery({observationId:u,traceId:p,projectId:h,startTime:x},{enabled:!g,staleTime:3e5}),v=s.FH.events.batchIO.useQuery({projectId:h,observations:[{id:u,traceId:p}],minStartTime:null!=x?x:new Date(0),maxStartTime:null!=x?x:new Date,truncated:!1},{enabled:g,staleTime:3e5,select:e=>e[0]}),j=(0,r.useMemo)(()=>g?f&&v.data?{...f,input:v.data.input,output:v.data.output,metadata:(0,o.XM)(v.data.metadata)}:v.data:y.data,[g,f,v.data,y.data]);(0,r.useEffect)(()=>{g&&v.data&&!f&&console.warn("[useParsedObservation] baseObservation missing - JumpToPlaygroundButton may not work correctly",{observationId:u})},[g,v.data,f,u]);let b=g?v.isLoading:y.isLoading,w=(0,a.I)({queryKey:["parsed-observation",u,null==j?void 0:j.input,null==j?void 0:j.output,null==j?void 0:j.metadata],queryFn:async()=>{if(!j)throw Error("No observation data to parse");return m(j.input,j.output,j.metadata)},enabled:!!j,staleTime:1/0,gcTime:6e5});return{observation:j,parsedInput:null==(t=w.data)?void 0:t.input,parsedOutput:null==(n=w.data)?void 0:n.output,parsedMetadata:null==(i=w.data)?void 0:i.metadata,isLoadingObservation:b,isParsing:w.isLoading,isReady:!b&&!w.isLoading&&void 0!==w.data,isWaitingForParsing:!!j&&(w.isLoading||void 0===w.data),parseTime:null==(d=w.data)?void 0:d.parseTime,parseError:null==(c=w.error)?void 0:c.message}}},88430:(e,t,n)=>{function a(e,t){if(t<0)return null;let n=e,a=t;for(;a>0;){if(!n.isExpanded||0===n.childOffsets.length)return console.error("[getNodeByIndex] ERROR: Index out of bounds",{requestedIndex:t,currentNode:n.id,remainingIndex:a,isExpanded:n.isExpanded,childOffsets:n.childOffsets}),null;let{childOffsets:e,children:r}=n,s=-1;
1if(a<=e[0])s=0;else{let t=0,n=e.length-1;for(;t<n;){let r=Math.floor((t+n)/2);a<=e[r]?n=r:t=r+1}s=t}let l=r[s];if(!l)return console.error("[getNodeByIndex] ERROR: Child not found",{requestedIndex:t,childIndex:s,childrenLength:r.length,parentNode:n.id}),null;a=a-(s>0?e[s-1]:0)-1,n=l}return n}function r(e){return 1+e.visibleDescendantCount}function s(e,t){var n,a;return{id:e.id,depth:e.depth,key:e.key,value:e.value,type:e.type,isExpandable:e.isExpandable,isExpanded:e.isExpanded,parentId:null!=(a=null==(n=e.parentNode)?void 0:n.id)?a:null,childCount:e.childCount,indexInParent:e.indexInParent,isLastChild:e.isLastChild,pathArray:e.pathArray,absoluteLineNumber:e.absoluteLineNumber}}function l(e,t){let n=[{node:e,index:0}];for(;n.length>0;){let{node:e,index:a}=n.pop();if(e.id===t)return a;if(e.isExpanded&&e.children.length>0)for(let t=e.children.length-1;t>=0;t--){let r=e.children[t],s=t>0?e.childOffsets[t-1]:0;n.push({node:r,index:a+(0===t?1:s+1)})}}return -1}function o(e,t){let n=[{node:e,index:0}];for(;n.length>0;){let{node:e,index:a}=n.pop();if("section-header"===e.nodeType&&e.sectionKey===t)return a;
1if(e.isExpanded&&e.children.length>0)for(let t=e.children.length-1;t>=0;t--){let r=e.children[t],s=t>0?e.childOffsets[t-1]:0;n.push({node:r,index:a+(0===t?1:s+1)})}}return -1}function i(e){let t=[],n=[e];for(;n.length>0;){let e=n.pop();if(t.push(e),e.isExpanded&&e.children.length>0)for(let t=e.children.length-1;t>=0;t--)n.push(e.children[t])}return t}function d(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e.isExpanded&&e.children.length>0){let{children:n,childOffsets:a}=e;if(a.length!==n.length)throw Error("[validateTreeOffsets] Node ".concat(e.id,": childOffsets.length (").concat(a.length,") !== children.length (").concat(n.length,")"));let r=0;for(let t=0;t<n.length;t++)if(r+=1+n[t].visibleDescendantCount,a[t]!==r)throw Error("[validateTreeOffsets] Node ".concat(e.id,": childOffsets[").concat(t,"] is ").concat(a[t],", expected ").concat(r));n.forEach(e=>t.push(e))}}return!0}function c(e){let t=[],n=e;for(;null!==n;)t.unshift(n),n=n.parentNode;return t}function u(e){let t=e.parentNode;for(;null!==t;){if(!t.isExpanded)return!1;t=t.parentNode}return!0}function m(e){let t=i(e);if(0===t.length)return[0,0];let n=1/0,a=-1/0;return t.forEach(e=>{e.depth<n&&(n=e.depth),e.depth>a&&(a=e.depth)}),[n,a]}function p(e){let t=i(e),n=t.length;for(let r=0;r<n;r++){let s=t[r],l=a(e,r);if(!l)throw console.error("[validateGetNodeByIndex] VALIDATION FAILED:",{message:"getNodeByIndex returned null",index:r,expectedNode:{id:s.id,key:s.key,depth:s.depth,isExpanded:s.isExpanded},totalVisibleRows:n}),Error("getNodeByIndex(".concat(r,") returned null, expected node ").concat(s.id));
1if(l.id!==s.id)throw console.error("[validateGetNodeByIndex] VALIDATION FAILED:",{message:"Node ID mismatch",index:r,expectedNode:{id:s.id,key:s.key,depth:s.depth,isExpanded:s.isExpanded,pathArray:s.pathArray},actualNode:{id:l.id,key:l.key,depth:l.depth,isExpanded:l.isExpanded,pathArray:l.pathArray},totalVisibleRows:n}),Error("Node mismatch at index ".concat(r,": expected ").concat(s.id,", got ").concat(l.id))}return!0}n.r(t),n.d(t,{findNodeIndex:()=>l,findSectionHeaderIndex:()=>o,getAllVisibleNodes:()=>i,getNodeByIndex:()=>a,getPathToNode:()=>c,getVisibleDepthRange:()=>m,getVisibleRowCount:()=>r,isNodeVisible:()=>u,treeNodeToFlatRow:()=>s,validateGetNodeByIndex:()=>p,validateTreeOffsets:()=>d})},89978:(e,t,n)=>{n.d(t,{V:()=>i});var a=n(96810),r=n(66449),s=n(9476),l=n(47805),o=n(54433);function i(){let[e,t]=(0,a.useState)([]),[n,i]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=(()=>{let e=sessionStorage.getItem(l.u);if(e)try{let t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t}catch(e){console.error("Failed to parse saved window IDs, clearing.",e),sessionStorage.removeItem(l.u)}return null})();t(null!=e?e:[(0,r.A)()]),i(!0)},[]),(0,a.useEffect)(()=>{n&&sessionStorage.setItem(l.u,JSON.stringify(e))},[e,n]);let d=(0,a.useCallback)(n=>e.includes(n)?n:e.length>=s.y.MAX_WINDOWS?(o.oR.error("Maximum window limit of ".concat(s.y.MAX_WINDOWS," reached")),null):(t(e=>[...e,n]),n),[e]),c=(0,a.useCallback)(n=>{if(e.length>=s.y.MAX_WINDOWS)return o.oR.error("Maximum window limit of ".concat(s.y.MAX_WINDOWS," reached")),null;let a=(0,r.A)(),i=null!=n?n:e[e.length-1];return i&&((e,t)=>{try{let n=(e=>{let t=(0,l.et)(e),n=sessionStorage.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch(n){return console.error("Failed to parse cache for window ".concat(e,":"),n),sessionStorage.removeItem(t),null}})(e);if(n){let e=JSON.parse(JSON.stringify(n));sessionStorage.setItem((0,l.et)(t),JSON.stringify(e))}let a=sessionStorage.getItem((0,l.YG)(e));a&&sessionStorage.setItem((0,l.YG)(t),a);let r=sessionStorage.getItem((0,l.i)(e));r&&sessionStorage.setItem((0,l.i)(t),r)}catch(n){console.error("Failed to clone window state from ".concat(e," to ").concat(t),n)}})(i,a),t(e=>[...e,a]),a},[e]),u=(0,a.useCallback)(n=>{if(e.length<=1)return void o.oR.error("Cannot remove the last remaining window");sessionStorage.removeItem((0,l.et)(n)),sessionStorage.removeItem((0,l.YG)(n)),sessionStorage.removeItem((0,l.i)(n)),t(e=>e.filter(e=>e!==n))},[e.length]);return{windowIds:e,isLoaded:n,addWindowWithId:d,addWindowWithCopy:c,removeWindowId:u,clearAllCache:(0,a.useCallback)(e=>{(()=>{let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);(null==n?void 0:n.startsWith("playground"))&&e.push(n)}e.forEach(e=>sessionStorage.removeItem(e));let t=[];for(let e=0;e<sessionStorage.length;e++){let n=sessionStorage.key(e);(null==n?void 0:n.startsWith("llmModel"))&&t.push(n)}t.forEach(e=>sessionStorage.removeItem(e))})(),t([null!=e?e:(0,r.A)()])},[])}}},90119:(e,t,n)=>{n.d(t,{E:()=>d});var a=n(73154),r=n(68389),s=n.n(r),l=n(72459),o=n(67716),i=n(93367);let d=e=>{let t=i.FH.prompts.byId.useQuery({id:e.promptId,projectId:e.projectId});return t.isLoading||!t.data?null:(0,a.jsx)(s(),{href:"/project/".concat(e.projectId,"/prompts/").concat(encodeURIComponent(t.data.name),"?version=").concat(t.data.version),className:"inline-flex","data-sentry-element":"Link","data-sentry-component":"PromptBadge","data-sentry-source-file":"PromptBadge.tsx",children:(0,a.jsxs)(o.E,{variant:"tertiary","data-sentry-element":"Badge","data-sentry-source-file":"PromptBadge.tsx",children:[(0,a.jsxs)("span",{className:"truncate",children:["Prompt: ",t.data.name," - v",t.data.version]}),(0,a.jsx)(l.A,{className:"ml-1 h-3 w-3","data-sentry-element":"ExternalLinkIcon","data-sentry-source-file":"PromptBadge.tsx"})]})})}},90410:(e,t,n)=>{n.d(t,{J:()=>I});var a=n(73154),r=n(25171),s=n(21),l=n(96810),o=n(39156),i=n(66449),d=n(33749),c=n(86843),u=n(88377),m=n(1597),p=n(89978),h=n(92125),x=n(18328),f=n(45596),g=n(27185),y=n(41454);function v(e){return e.map(e=>{var t;return{id:Math.random().toString(36).substring(2),name:e.function.name,description:null!=(t=e.function.description)?t:"",parameters:e.function.parameters}})}function j(e,t){if(t&&"object"==typeof t&&null!==t&&t.attributes&&"object"==typeof t.attributes){let e=t.attributes,n=e["gen_ai.tool.definitions"];if(n&&Array.isArray(n)){let e=y.z.array(f.OpenAIToolSchema).safeParse(n);if(e.success)return v(e.data)}let a=Object.keys(e).filter(e=>/^llm\.tools\.\d+\.tool\.json_schema$/.test(e));if(a.length>0){let t=a.map(t=>e[t]),n=y.z.array(f.OpenAIToolSchema).safeParse(t);if(n.success)return v(n.data)}}if(!e)return[];if(Array.isArray(e)){let t=e.find(e=>e&&"object"==typeof e&&e.tools&&Array.isArray(e.tools)&&e.tools.length>0);if(t&&Array.isArray(t.tools))return t.tools.map(e=>{var t,n,a,r,s;return{id:Math.random().toString(36).substring(2),name:e.name||(null==(t=e.function)?void 0:t.name),description:null!=(s=null!=(r=e.description)?r:null==(n=e.function)?void 0:n.description)?s:"",parameters:e.parameters||(null==(a=e.function)?void 0:a.parameters)}})}let n=(0,f.extractAdditionalInput)(e);if((null==n?void 0:n.tools)&&Array.isArray(n.tools))return n.tools.map(e=>{var t,n,a,r,s;return{id:Math.random().toString(36).substring(2),name:e.name||(null==(t=e.function)?void 0:t.name),description:null!=(s=null!=(r=e.description)?r:null==(n=e.function)?void 0:n.description)?s:"",parameters:e.parameters||(null==(a=e.function)?void 0:a.parameters)}});if("object"==typeof e&&null!==e&&"tools"in e){let t=y.z.array(f.OpenAIToolSchema).safeParse(e.tools);if(t.success)return v(t.data)}if(Array.isArray(e)){let t=e.filter(e=>{var t,n;return e&&"object"==typeof e&&"tool"===e.role&&"object"==typeof e.content&&(null==(t=e.content)?void 0:t.type)==="function"&&(null==(n=e.content)?void 0:n.function)});if(t.length>0){let e=t.map(e=>e.content),n=y.z.array(f.OpenAIToolSchema).safeParse(e);if(n.success)return v(n.data)}}if("object"==typeof e&&null!==e&&"messages"in e&&Array.isArray(e.messages)){let t=e.messages.filter(e=>{var t,n;return e&&"object"==typeof e&&"tool"===e.role&&"object"==typeof e.content&&(null==(t=e.content)?void 0:t.type)==="function"&&(null==(n=e.content)?void 0:n.function)});if(t.length>0){let e=t.map(e=>e.content),n=y.z.array(f.OpenAIToolSchema).safeParse(e);if(n.success)return v(n.data)}}return[]}function b(e){if("string"==typeof e)return e;if(null==e)return"";if(Array.isArray(e)){let t=[];for(let n of e)(0,f.isOpenAITextContentPart)(n)?t.push(n.text):(0,f.isOpenAIImageContentPart)(n)?t.push("[Image]"):n&&"object"==typeof n&&"type"in n&&"input_audio"===n.type&&t.push("[Audio]");if(t.length>0)return t.join("\n")}return JSON.stringify(e)}function w(e){var t;if("placeholder"===e.type)return{type:f.ChatMessageType.Placeholder,name:e.name||""};let n=(null==(t=e.json)?void 0:t.json)||e.json,a=e.tool_calls||(null==n?void 0:n.tool_calls);if(a&&Array.isArray(a)){let t=a.map(e=>{var t,n,a,r,s;let l,o;if(e.name&&!e.function){o=e.name;try{l="string"==typeof e.arguments?JSON.parse(e.arguments):null!=(t=e.arguments)?t:{}}catch(e){l={}}}else{o=(null==(n=e.function)?void 0:n.name)||"";try{l="string"==typeof(null==(a=e.function)?void 0:a.arguments)?JSON.parse(e.function.arguments):null!=(s=null==(r=e.function)?void 0:r.arguments)?s:{}}catch(e){l={}}}return{id:e.id||"",name:o,args:l}});return{role:f.ChatMessageRole.Assistant,content:b(e.content),type:f.ChatMessageType.AssistantToolCall,toolCalls:t}}let r=e.tool_call_id||(null==n?void 0:n.tool_call_id)||(null==n?void 0:n.toolCallId);if(r){let t=void 0!==e.content&&null!==e.content?e.content:n;return{role:f.ChatMessageRole.Tool,content:b(t),type:f.ChatMessageType.ToolResult,toolCallId:r}}return{role:e.role||f.ChatMessageRole.Assistant,content:b(e.content),type:f.ChatMessageType.PublicAPICreated}}var N=n(93367),C=n(81509),T=n(26202);let I=e=>{var t,n;let d=(0,o.useRouter)(),g=(0,h.B)(),y=(0,x.A)(),{addWindowWithId:v,clearAllCache:j}=(0,p.V)(),[b,w]=(0,l.useState)(null),[I,E]=(0,l.useState)(!1),[O,A]=(0,l.useState)(!1),M=(0,l.useMemo)(()=>
1"prompt"===e.source?"playground-prompt-".concat(e.prompt.id):"generation"===e.source?"playground-generation-".concat(e.generation.id):"playground-".concat((0,i.A)()),[e]),{setPlaygroundCache:D}=(0,T.A)(M),P=N.FH.llmApiKey.all.useQuery({projectId:y},{enabled:!!y}),L=(0,l.useMemo)(()=>{var e,t;let n={};return(null!=(t=null==(e=P.data)?void 0:e.data)?t:[]).forEach(e=>{let{provider:t,customModels:a,withDefaultModels:r,adapter:s}=e;if(r){var l;(null!=(l=f.supportedModels[s])?l:[]).forEach(e=>{n[e]=t})}a.forEach(e=>{n[e]=t})}),n},[P.data]),B="prompt"===e.source?e.prompt:null,R="generation"===e.source?e.generation:null;(0,l.useEffect)(()=>{B?w(S(B)):R&&w(k(R,L,O))},[B,R,L,O]),(0,l.useEffect)(()=>{b?E(!0):E(!1)},[b,E]);let V=t=>{if(g(e.analyticsEventName,{playgroundMode:t?"fresh":"add_to_existing"}),!b)return void console.warn("No captured state available for playground");if(t)j(M);else if(!v(M))return void console.warn("Failed to add window to existing playground, maximum windows reached");requestAnimationFrame(()=>{try{D(b),console.log("Cache saved for existing playground window ".concat(M)),d.push("/project/".concat(y,"/playground"))}
1catch(e){console.error("Failed to save playground cache:",e),d.push("/project/".concat(y,"/playground"))}})};return(0,a.jsxs)(u.rI,{"data-sentry-element":"DropdownMenu","data-sentry-component":"JumpToPlaygroundButton","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:[(0,a.jsx)(u.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:(0,a.jsxs)(c.$,{variant:null!=(t=e.variant)?t:"secondary",size:null!=(n=e.size)?n:"default",disabled:!I,title:I?"Test in LLM playground":"Test in LLM playground is not available since messages are not in valid ChatML format or tool calls have been used. If you think this is not correct, please open a GitHub issue.",className:(0,C.cn)("flex items-center gap-1",I?"cursor-pointer":"cursor-not-allowed opacity-50"),"data-sentry-element":"Button","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:[(0,a.jsx)(r.A,{className:"sm"===e.size?"h-3.5 w-3.5":"h-4 w-4","data-sentry-element":"Terminal","data-sentry-source-file":"JumpToPlaygroundButton.tsx"}),(0,a.jsx)("span",{className:(0,C.cn)("hidden md:inline",e.className),children:"Playground"}),(0,a.jsx)(s.A,{className:"h-3 w-3","data-sentry-element":"ChevronDown","data-sentry-source-file":"JumpToPlaygroundButton.tsx"})]})}),(0,a.jsxs)(u.SQ,{align:"end","data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:[(0,a.jsxs)(u._2,{onClick:()=>V(!0),"data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:[(0,a.jsx)(r.A,{className:"mr-2 h-4 w-4","data-sentry-element":"Terminal","data-sentry-source-file":"JumpToPlaygroundButton.tsx"}),"Fresh playground"]}),(0,a.jsxs)(u._2,{onClick:()=>V(!1),"data-sentry-element":"DropdownMenuItem","data-sentry-source-file":"JumpToPlaygroundButton.tsx",children:[(0,a.jsx)(r.A,{className:"mr-2 h-4 w-4","data-sentry-element":"Terminal","data-sentry-source-file":"JumpToPlaygroundButton.tsx"}),"Add to existing"]}),"generation"===e.source&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.mB,{}),(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5",children:[(0,a.jsx)("span",{className:"text-sm",children:"Include output"}),(0,a.jsx)(m.d,{checked:O,onCheckedChange:A})]})]})]})]})},S=e=>{if(e.type===f.PromptType.Chat)try{let t=(0,g.kz)(e.resolvedPrompt),n=t.success?t.data.map(w).filter(e=>null!==e):[];if(0===n.length)return null;return{messages:n}}catch(e){return null}{let t=e.resolvedPrompt;return{messages:[(0,d.p)({type:f.ChatMessageType.System,role:f.ChatMessageRole.System,content:"string"==typeof t?t:""})]}}},k=function(e,t){var n,a,r,s,l,o;let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!(0,f.isGenerationLike)(e.type))return null;let c=function(e,t){var n,a;let r,s=null==(n=e.model)?void 0:n.valueOf();if(s){let n=t[s];if(!n)return;r={provider:{value:n,enabled:!0},model:{value:s,enabled:!0}};let l=null==(a=e.modelParameters)?void 0:a.valueOf();if(l&&"object"==typeof l){let e=f.ZodModelConfig.safeParse(l);e.success&&Object.entries(e.data).forEach(e=>{let[t,n]=e;r&&(r[t]={value:n,enabled:!0})})}}return r}(e,t),u=function(e,t,n){if(!e&&!t&&!n)return[];try{let a=e?JSON.parse(e):null,r=t?JSON.parse(t):null,s=n?JSON.parse(n):null,l=j(a,s);if(l.length>0)return l;if(r)return j(r,s);return[]}catch(e){return[]}}(e.input,e.output,e.metadata),m=function(e){try{let t=e.metadata;try{"string"==typeof t&&(t=JSON.parse(t))}catch(e){}if("object"==typeof t&&null!==t&&"response_format"in t){let e=f.OpenAIResponseFormatSchema.safeParse(t.response_format);if(e.success)return{id:Math.random().toString(36).substring(2),name:e.data.json_schema.name,description:"Schema parsed from generation",schema:e.data.json_schema.schema}}let n=e.modelParameters;if(n&&"object"==typeof n&&"response_format"in n&&"string"==typeof n.response_format){let e=JSON.parse(n.response_format),t=f.OpenAIResponseFormatSchema.safeParse(e);if(t.success)return{id:Math.random().toString(36).substring(2),name:t.data.json_schema.name,description:"Schema parsed from generation",schema:t.data.json_schema.schema}}}catch(e){}return null}(e),p=function(e){let t=e.metadata;if(null==t)return;if("string"==typeof t){let e=t.trim();if(!e)return;try{t=JSON.parse(e)}catch(e){return}}if("object"!=typeof t||null===t)return;let n=t.requester_metadata;if("object"==typeof n&&null!==n)return{metadata:n}}(e);if(c&&p){let e={...null!=(r=null==(a=c.providerOptions)?void 0:a.value)?r:{},...p};c={...c,providerOptions:{value:e,enabled:!0}}}let h=null==(n=e.input)?void 0:n.valueOf();if(!h)return null;if("string"==typeof h){try{h=JSON.parse(h)}catch(e){return{messages:[(0,d.p)({type:f.ChatMessageType.System,role:f.ChatMessageRole.System,content:null!=(s=null==h?void 0:h.toString())?s:""})],modelParams:c,tools:u,structuredOutputSchema:m}}if("string"==typeof h)return{messages:[(0,d.p)({type:f.ChatMessageType.System,role:f.ChatMessageRole.System,content:h})],modelParams:c,tools:u,structuredOutputSchema:m}}if("object"==typeof h)try{let t={metadata:"string"==typeof e.metadata?JSON.parse(e.metadata):e.metadata,observationName:null!=(l=e.name)?l:void 0},n=(0,g.kz)(h,t),a=n.success?n.data.map(w).filter(e=>null!==e):[];if(i){let n=null==(o=e.output)?void 0:o.valueOf();if(n&&"string"==typeof n)try{n=JSON.parse(n)}catch(e){}if(n&&"object"==typeof n)try{let e=(0,g.Zy)(n,t),r=e.success?e.data.map(w).filter(e=>null!==e).filter(e=>e.type!==f.ChatMessageType.AssistantToolCall):[];a=[...a,...r]}catch(e){}}if(0===a.length)return null;let r=n.success&&n.data?j(n.data,t.metadata):[],s=r.length>0?r:u;return{messages:a,modelParams:c,tools:s,structuredOutputSchema:m}}catch(e){}return null}}
1,91449:(e,t,n)=>{n.d(t,{_:()=>ea});var a=n(73154),r=n(96810),s=n(86843),l=n(55247),o=n(51883),i=n(92273),d=n(173),c=n(12485),u=n(59895),m=n(41641),p=n(17020),h=n(33100),x=n(10873),f=n(45596),g=n(90270),y=n(97638),v=n(37982),j=n(61653),b=n(45103),w=n(97898),N=n(51092),C=n(90938),T=n(81509),I=n(61631);let S=r.createContext({size:"default",variant:"default"}),k=r.forwardRef((e,t)=>{let{className:n,variant:r,size:s,children:l,...o}=e;return(0,a.jsx)(C.bL,{ref:t,className:(0,T.cn)("flex items-center justify-center gap-1",n),...o,children:(0,a.jsx)(S.Provider,{value:{variant:r,size:s},children:l})})});k.displayName=C.bL.displayName;let E=r.forwardRef((e,t)=>{let{className:n,children:s,variant:l,size:o,...i}=e,d=r.useContext(S);return(0,a.jsx)(C.q7,{ref:t,className:(0,T.cn)((0,I.v)({variant:d.variant||l,size:d.size||o}),n),...i,children:s})});E.displayName=C.q7.displayName;var O=n(28353),A=n(92125);let M=Object.values(f.ScoreConfigDataType);var D=n(41454);let P=D.z.object({id:D.z.string().nullish(),timestamp:D.z.date().nullish(),name:D.z.string(),value:D.z.number().nullish(),stringValue:D.z.string().nullish(),dataType:D.z.enum(M),configId:D.z.string(),comment:D.z.string().nullish()}),L=D.z.object({scoreData:D.z.array(P)});function B(e){let{config:t}=e,{name:n,description:r,minValue:s,maxValue:l,dataType:o}=t;if(!r&&!(0,f.isPresent)(s)&&!(0,f.isPresent)(l))return null;let i=n.length>20;return(0,a.jsxs)("div",{className:"text-wrap bg-background p-2 text-xs font-light","data-sentry-component":"ScoreConfigDetails","data-sentry-source-file":"ScoreConfigDetails.tsx",children:[!!r&&(0,a.jsx)("p",{children:"Description: ".concat(r)}),(0,N.o3)(o)&&((0,f.isPresent)(s)||(0,f.isPresent)(l))?(0,a.jsx)("p",{children:"Range: [".concat(null!=s?s:"-∞",", ").concat(null!=l?l:"∞","]")}):null,i&&(0,a.jsx)("p",{children:"Full name: ".concat(n)})]})}var R=n(42430);let V=e=>{let{name:t,dataType:n}=e;return"".concat((0,R.ck)(n)," ").concat(t)};var z=n(22379),_=n(16968),F=n(52402),H=n(40741);function J(e,t,n,a){if(Array.isArray(e)){var r,s;return r=e,s=t,r.filter(e=>"ANNOTATION"===e.source&&M.includes(e.dataType)).map(e=>{var t,n,a;return s.find(t=>t.id===e.configId)&&e.configId?{id:e.id,name:e.name,dataType:e.dataType,source:e.source,configId:e.configId,value:e.value,stringValue:e.stringValue,comment:e.comment,traceId:null!=(t=e.traceId)?t:null,observationId:null!=(n=e.observationId)?n:null,sessionId:null!=(a=e.sessionId)?a:null,timestamp:e.timestamp}:null}).filter(e=>null!==e)}if(!n)throw Error("traceId is required when transforming score aggregates to annotation scores");var l=e,o=t,i=n,d=a;let c=[];return Object.entries(l).forEach(e=>{var t,n,a,r;
1let[s,l]=e,{name:u,source:m,dataType:p}=(0,H.Yz)(s);if("ANNOTATION"!==m||!l.id)return;let h=o.find(e=>(0,H.fN)(e.name)===u&&e.dataType===p);if(!h)return;let x={id:l.id,name:u,dataType:p,source:m,configId:h.id,traceId:i,observationId:null!=d?d:null,sessionId:null,comment:null!=(t=l.comment)?t:null,value:null,stringValue:null,timestamp:null!=(n=l.timestamp)?n:null};"NUMERIC"===l.type?x.value=null!=(a=l.average)?a:null:x.stringValue=null!=(r=l.values[0])?r:null,c.push(x)}),c}var U=n(66449),W=n(93367),G=n(8163),$=n(94795),K=n(88377),Q=n(42349),q=n(54433),X=n(39156),Z=n(84750);function Y(e){let{savedComment:t,disabled:n,loading:o,onSave:i}=e,[d,c]=(0,r.useState)(t||"");(0,r.useEffect)(()=>{c(t||"")},[t]);let u=d.trim()!==(t||"");return(0,a.jsxs)("div",{className:"relative","data-sentry-component":"CommentField","data-sentry-source-file":"AnnotationForm.tsx",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,a.jsx)(x.lR,{className:"text-sm","data-sentry-element":"FormLabel","data-sentry-source-file":"AnnotationForm.tsx",children:"Score Comment"}),(0,a.jsx)("div",{className:"relative",children:t&&(0,a.jsx)(y.iN,{asChild:!0,children:(0,a.jsx)(s.$,{variant:"ghost",type:"button",size:"icon-xs",loading:o,onClick:()=>i(null),children:(0,a.jsx)(l.A,{className:"h-3 w-3"})})})})]}),(0,a.jsx)(j.T,{className:"text-xs",value:d,onChange:e=>c(e.target.value),disabled:n,"data-sentry-element":"Textarea","data-sentry-source-file":"AnnotationForm.tsx"}),u&&(0,a.jsxs)("div",{className:"mt-2 flex justify-end gap-1",children:[(0,a.jsx)(y.iN,{asChild:!0,children:(0,a.jsx)(s.$,{type:"button",variant:"secondary",size:"sm",className:"text-xs",disabled:n,loading:o,onClick:()=>{c(t||"")},children:"Discard Changes"})}),(0,a.jsx)(y.iN,{asChild:!0,children:(0,a.jsx)(s.$,{type:"button",size:"sm",className:"text-xs",disabled:n,loading:o,onClick:()=>{i(d)},children:"Save Changes"})})]})]})}function ee(e){let{showSaving:t,actionButtons:n,description:r}=e;return(0,a.jsx)(O.Ay,{title:"Annotate",help:{description:r,href:"https://langfuse.com/docs/evaluation/evaluation-methods/annotation",className:"leading-relaxed"},actionButtons:[(0,a.jsxs)("div",{className:"flex items-center justify-end",children:[(0,a.jsx)("div",{className:"mr-1 items-center justify-center",children:t?(0,a.jsx)(o.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(i.A,{className:"h-3 w-3"})}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:t?"Saving score data":"Score data saved"})]},"saving-spinner"),n],"data-sentry-element":"Header","data-sentry-component":"AnnotateHeader","data-sentry-source-file":"AnnotationForm.tsx"})}let et=e=>e.isArchived;function en(e){let{scoreTarget:t,initialFormData:n,scoreMetadata:l,analyticsData:o,actionButtons:i,configControl:j}=e,C=(0,A.B)(),I=(0,X.useRouter)(),{configs:S,allowManualSelection:O}=j,M=(0,p.mN)({resolver:(0,h.u)(L),defaultValues:{scoreData:n}}),{fields:D,update:P,remove:R,insert:_}=(0,p.jz)({control:M.control,name:"scoreData"}),F=M.watch("scoreData"),H=D.map((e,t)=>({...e,...F[t]})),J=(0,N.yS)(t),{createMutation:Z,updateMutation:en,deleteMutation:ea}=function(e){let{scoreTarget:t,scoreMetadata:n}=e,{set:a,get:r,delete:s,rollbackSet:l,rollbackDelete:o,setColumn:i}=(0,z.I)(),d=W.FH.scores.createAnnotationScore.useMutation({onMutate:e=>{var r,s,l,o,d,c;if(e.id)return i({name:e.name,dataType:e.dataType,source:"ANNOTATION"}),a(e.id,{id:e.id,projectId:n.projectId,environment:null!=(r=n.environment)?r:"default",traceId:(0,N.EX)(t)?t.traceId:null,observationId:(0,N.EX)(t)&&null!=(s=t.observationId)?s:null,sessionId:(0,N.N$)(t)?t.sessionId:null,configId:e.configId,name:e.name,dataType:e.dataType,source:"ANNOTATION",value:null!=(l=e.value)?l:null,stringValue:null!=(o=e.stringValue)?o:null,comment:null!=(d=e.comment)?d:null,timestamp:null!=(c=e.timestamp)?c:new Date}),{scoreId:e.id}},onError:(e,t)=>{t.id&&(l(t.id),(0,G.N)("Failed to create score",e.message,"WARNING"))}});return{createMutation:d,updateMutation:W.FH.scores.updateAnnotationScore.useMutation({onMutate:e=>{var s,l,o,i,d,c,u,m,p;let h=r(e.id);return h?a(e.id,{...h,value:null!=(u=e.value)?u:h.value,stringValue:null!=(m=e.stringValue)?m:h.stringValue,comment:null!=(p=e.comment)?p:null}):a(e.id,{id:e.id,projectId:n.projectId,environment:null!=(s=n.environment)?s:"default",traceId:(0,N.EX)(t)?t.traceId:null,observationId:(0,N.EX)(t)&&null!=(l=t.observationId)?l:null,sessionId:(0,N.N$)(t)?t.sessionId:null,configId:e.configId,name:e.name,dataType:e.dataType,source:"ANNOTATION",value:null!=(o=e.value)?o:null,stringValue:null!=(i=e.stringValue)?i:null,comment:null!=(d=e.comment)?d:null,timestamp:null!=(c=e.timestamp)?c:new Date}),{previousCacheValue:h}}
1,onError:(e,t,n)=>{(null==n?void 0:n.previousCacheValue)?a(t.id,n.previousCacheValue):l(t.id),(0,G.N)("Failed to update score",e.message,"WARNING")}}),deleteMutation:W.FH.scores.deleteAnnotationScore.useMutation({onMutate:e=>{let t=r(e.id);return s(e.id),{previousCacheValue:t}},onError:(e,t,n)=>{o(t.id,null==n?void 0:n.previousCacheValue),(0,G.N)("Failed to delete score",e.message,"WARNING")}})}}({scoreTarget:t,scoreMetadata:l}),{selectionOptions:er,handleSelectionChange:es}=function(e){let{configs:t,controlledFields:n,isInputDisabled:a,insert:s,remove:l}=e,{emptySelectedConfigIds:o,setEmptySelectedConfigIds:i}=(0,Q.G)();return{selectionOptions:(0,r.useMemo)(()=>t.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({key:e.id,value:V({dataType:e.dataType,name:e.name}),disabled:a(e)})),[t,a]),handleSelectionChange:(0,r.useCallback)((e,a)=>{if(!a)return;let r=n.findIndex(e=>e.configId===a);if(-1!==r){let e=n[r];if(null==e?void 0:e.id)return void q.oR.error("Cannot deselect a populated score");l(r),null==i||i(o.filter(e=>e!==a))}else{let e=t.find(e=>e.id===a);e&&s(((e,t)=>{let n=t.findIndex(t=>t.name.localeCompare(e)>0);return -1===n?t.length:n})(e.name,n),{id:null,configId:e.id,name:e.name,dataType:e.dataType,value:null,stringValue:null,comment:null}),null==i||i([...o,a])}},[n,t,s,l,o,i])}}({configs:S,controlledFields:H,isInputDisabled:et,insert:_,remove:R}),[el,eo]=(0,r.useState)(!1);(0,r.useEffect)(()=>{eo(Z.isPending||en.isPending||ea.isPending)},[Z.isPending,en.isPending,ea.isPending]);let ei=e=>{let t=H[e],n={id:t.id,value:t.value,stringValue:t.stringValue,comment:t.comment,timestamp:t.timestamp};M.clearErrors("scoreData.".concat(e,".value")),P(e,{name:t.name,dataType:t.dataType,configId:t.configId,id:null,value:null,stringValue:null,comment:null}),n.id&&ea.mutate({id:n.id,projectId:l.projectId},{onError:()=>{P(e,{name:t.name,dataType:t.dataType,configId:t.configId,...n}),M.setValue("scoreData.".concat(e,".id"),n.id),M.setValue("scoreData.".concat(e,".value"),n.value),M.setValue("scoreData.".concat(e,".stringValue"),n.stringValue),M.setValue("scoreData.".concat(e,".comment"),n.comment),M.setValue("scoreData.".concat(e,".timestamp"),n.timestamp),M.setError("scoreData.".concat(e,".value"),{type:"server",message:"Failed to delete score"})}}),C("score:delete",o)},ed=(e,n,a)=>{let r=H[e];if(!r)return;let s=r.value,o=r.stringValue,i=r.id,d=r.timestamp;M.clearErrors("scoreData.".concat(e,".value")),M.setValue("scoreData.".concat(e,".value"),n),M.setValue("scoreData.".concat(e,".stringValue"),a);let{id:c,timestamp:u,...m}=r,p={...m,...l,value:n,stringValue:a,scoreTarget:t};if(c)en.mutate({...p,id:c,timestamp:null!=u?u:void 0},{onError:()=>{M.setValue("scoreData.".concat(e,".value"),s),M.setValue("scoreData.".concat(e,".stringValue"),o),M.setError("scoreData.".concat(e,".value"),{type:"server",message:"Failed to update score"})}});else{let t=(0,U.A)(),n=new Date;M.setValue("scoreData.".concat(e,".id"),t),M.setValue("scoreData.".concat(e,".timestamp"),n),Z.mutate({...p,id:t,timestamp:n},{onError:()=>{M.setValue("scoreData.".concat(e,".id"),i),M.setValue("scoreData.".concat(e,".timestamp"),d),M.setValue("scoreData.".concat(e,".value"),s),M.setValue("scoreData.".concat(e,".stringValue"),o),M.setError("scoreData.".concat(e,".value"),{type:"server",message:"Failed to create score"})}})}},ec=(e,t)=>{var n,a;let r=H[e],s=S.find(e=>e.id===r.configId);if(!s||!r)return;let l=null==(a=s.categories)||null==(n=a.find(e=>{let{label:n}=e;return n===t}))?void 0:n.value;(0,f.isPresent)(l)&&ed(e,l,t)};return(0,a.jsxs)("div",{className:"mx-auto w-full space-y-2 overflow-y-auto md:max-h-full","data-sentry-component":"InnerAnnotationForm","data-sentry-source-file":"AnnotationForm.tsx",children:[(0,a.jsxs)("div",{className:"sticky top-0 z-10 rounded-sm bg-background",children:[(0,a.jsx)(ee,{showSaving:el,actionButtons:i,description:J,"data-sentry-element":"AnnotateHeader","data-sentry-source-file":"AnnotationForm.tsx"}),O?(0,a.jsx)("div",{className:"grid grid-flow-col items-center",children:(0,a.jsx)($.X,{placeholder:"Value",align:"end",items:"empty scores",className:"grid grid-cols-[auto,1fr,auto,auto] gap-2",options:er,onValueChange:es,values:D.filter(e=>!!e.configId).map(e=>({key:e.configId,value:V({dataType:e.dataType,name:e.name})})),controlButtons:(0,a.jsx)(K._2,{onSelect:()=>{C("score_configs:manage_configs_item_click",o),I.push("/project/".concat(l.projectId,"/settings/scores"))},children:"Manage score configs"})})}):null]}),(0,a.jsx)(x.lV,{...M,"data-sentry-element":"Form","data-sentry-source-file":"AnnotationForm.tsx",children:(0,a.jsx)("form",{className:"flex flex-col gap-4",children:(0,a.jsx)("div",{className:"grid grid-flow-row gap-2",children:(0,a.jsx)(x.zB,{control:M.control,name:"scoreData",render:()=>(0,a.jsx)(a.Fragment,{children:H.map((e,n)=>{var r,o;let i=S.find(t=>
1t.id===e.configId);if(!i)return null;let p=((e,t)=>{if(0===e.length)return[];let n=e.map(e=>({...e,isOutdated:!1}));return!t||e.some(e=>e.label===t)?n:[{label:t,value:0,isOutdated:!0},...n]})(null!=(o=i.categories)?o:[],e.stringValue);return(0,a.jsxs)("div",{className:"grid w-full grid-cols-[1fr,2fr] items-center gap-8 text-left",children:[(0,a.jsxs)("div",{className:"grid h-full grid-cols-[1fr,auto] items-center",children:[i.description||(0,f.isPresent)(i.maxValue)||(0,f.isPresent)(i.minValue)?(0,a.jsxs)(w.jc,{children:[(0,a.jsx)(w.d0,{asChild:!0,children:(0,a.jsx)("span",{className:(0,T.cn)("line-clamp-2 break-words text-xs font-medium underline decoration-muted-gray decoration-dashed underline-offset-2",i.isArchived?"text-foreground/40":""),children:e.name})}),(0,a.jsx)(b.Et,{className:"z-20 max-h-[60vh] max-w-64 overflow-y-auto rounded border",children:(0,a.jsx)(B,{config:i})})]}):(0,a.jsx)("span",{className:(0,T.cn)("line-clamp-2 break-words text-xs font-medium",i.isArchived?"text-foreground/40":""),title:e.name,children:e.name}),(0,a.jsxs)(y.AM,{children:[(0,a.jsx)(y.Wv,{asChild:!0,children:(0,a.jsx)(s.$,{variant:"link",type:"button",size:"xs",title:"Add or view score comment",className:"h-full px-0 pl-1 disabled:text-primary/50 disabled:opacity-100",disabled:(0,N.h2)(e.id)||i.isArchived&&!e.comment,children:e.comment?(0,a.jsx)(d.A,{className:"h-4 w-4"}):(0,a.jsx)(c.A,{className:"h-4 w-4"})})}),(0,a.jsx)(y.hl,{children:(0,a.jsx)(x.zB,{control:M.control,name:"scoreData.".concat(n,".comment"),render:()=>{var r;return(0,a.jsxs)(x.eI,{className:"space-y-4",children:[(0,a.jsx)(x.MJ,{children:(0,a.jsx)(Y,{savedComment:null!=(r=e.comment)?r:null,disabled:et(i),loading:en.isPending,onSave:e=>{((e,n)=>{let a=H[e];if(!a||!a.id)return;let r=a.comment;P(e,{...a,comment:n}),en.mutate({...a,...l,scoreTarget:t,comment:n},{onError:()=>{P(e,{...a,comment:r}),M.setError("scoreData.".concat(e,".comment"),{type:"server",message:"Failed to update comment"})}})})(n,(null==e?void 0:e.trim())||null)}})}),(0,a.jsx)(x.C5,{className:"text-xs"})]})}})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-[11fr,1fr] items-center py-1",children:[(0,N.o3)(e.dataType)?(0,a.jsx)(x.zB,{control:M.control,name:"scoreData.".concat(n,".value"),render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(x.eI,{children:[(0,a.jsx)(x.MJ,{children:(0,a.jsx)(g.p,{...r,value:null!=(t=r.value)?t:"",onChange:e=>{let t=e.target.value;""!==t&&r.onChange(Number(t))},type:"number",className:"text-xs",disabled:et(i),onBlur:()=>(e=>{let t=H[e],n=S.find(e=>e.id===t.configId);if(!n||!t||null===t.value||void 0===t.value)return;let a=(e=>{let{value:t,minValue:n,maxValue:a}=e;return(0,f.isPresent)(a)&&Number(t)>a||(0,f.isPresent)(n)&&Number(t)<n?"Not in range: [".concat(null!=n?n:"-∞",",").concat(null!=a?a:"∞","]"):null})({value:t.value,maxValue:n.maxValue,minValue:n.minValue});if(a)return void M.setError("scoreData.".concat(e,".value"),{type:"custom",message:a});M.clearErrors("scoreData.".concat(e,".value")),ed(e,t.value,null)})(n)})}),(0,a.jsx)(x.C5,{className:"text-xs"})]})}}):i.categories&&(e=>{let t=e.length>3,n=e.some(e=>{let{label:t}=e;return t.length>6});return t||e.length>1&&n})(p)?(0,a.jsx)(x.zB,{control:M.control,name:"scoreData.".concat(n,".stringValue"),render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(x.eI,{children:[(0,a.jsx)(x.MJ,{children:(0,a.jsx)(v.G,{name:r.name,value:null!=(t=r.value)?t:"",disabled:et(i),onValueChange:e=>{r.onChange(e),ec(n,e)},options:p.map(e=>({value:e.label,disabled:e.isOutdated})),placeholder:"Select category",searchPlaceholder:"Search categories...",emptyText:"No category found."})}),(0,a.jsx)(x.C5,{className:"text-xs"})]})}}):(0,a.jsx)(x.zB,{control:M.control,name:"scoreData.".concat(n,".stringValue"),render:e=>{var t;let{field:r}=e;return(0,a.jsxs)(x.eI,{children:[(0,a.jsx)(x.MJ,{children:(0,a.jsx)(k,{type:"single",value:null!=(t=r.value)?t:"",disabled:et(i),className:"grid grid-cols-".concat(p.length),onValueChange:e=>{r.onChange(e),ec(n,e)},children:p.map(e=>e.isOutdated?(0,a.jsxs)(E,{value:e.label,disabled:!0,variant:"outline",className:"grid grid-flow-col gap-1 text-nowrap px-1 text-xs font-normal opacity-50",children:[(0,a.jsx)("span",{className:"truncate",title:e.label,children:e.label}),(0,a.jsx)("span",{children:"(".concat(e.value,")")})]},e.value):(0,a.jsx)(E,{value:e.label,variant:"outline",className:"grid grid-flow-col gap-1 text-nowrap px-1 text-xs font-normal",children:(0,a.jsx)("span",{className:"truncate",title:e.label,children:e.label})},e.value))})}),(0,a.jsx)(x.C5,{className:"text-xs"})]})}}),i.isArchived?(0,a.jsxs)(y.AM,{children:[(0,a.jsx)(y.Wv,{asChild:!0,children:(0,a.jsx)(s.$,{variant:"link",type:"button",className:"px-0 pl-1",title:"Delete archived score",disabled:(0,N.h2)(e.id),children:(0,a.jsx)(u.A,{className:"h-4 w-4"})})}),(0,a.jsxs)(y.hl,{children:[(0,a.jsx)("h2",{className:"text-md mb-3 font-semibold",children:"Your score is archived"}),(0,a.jsx)("p",{className:"mb-3 text-sm",children:"This action will delete your score irreversibly."}),(0,a.jsx)("div",{className:"flex justify-end space-x-4",children:(0,a.jsx)(s.$,{type:"button",variant:"destructive",loading:ea.isPending,onClick:()=>ei(n),children:"Delete"})})]})]}):(0,a.jsx)(s.$,{variant:"link",type:"button",className:"px-0 pl-1",title:"Delete score from trace/observation",disabled:(0,N.h2)(e.id)||en.isPending,loading:ea.isPending&&!(0,N.h2)(e.id),onClick:()=>ei(n),children:(0,a.jsx)(m.A,{className:"h-4 w-4"})})]})]},null==(r=D[n])?void 0:r.id)})}),"data-sentry-element":"FormField","data-sentry-source-file":"AnnotationForm.tsx"})})})})]})}function ea(e){let{scoreTarget:t,serverScores:n,scoreMetadata:s,analyticsData:l,actionButtons:o,configSelection:i={mode:"selectable"}}=e,{projectId:d}=s,{isLoading:c,availableConfigs:u,selectedConfigIds:m}=function(e){var t,n;let{projectId:a,configSelection:r}=e,{emptySelectedConfigIds:s}=(0,Q.G)(),l=W.FH.scoreConfigs.all.useQuery({projectId:a},{enabled:"selectable"===r.mode});return"fixed"===r.mode?{isLoading:!1,selectedConfigIds:r.configs.map(e=>e.id),availableConfigs:r.configs}:{isLoading:l.isLoading,selectedConfigIds:s,availableConfigs:null!=(n=null==(t=l.data)?void 0:t.configs)?n:[]}}({projectId:d,configSelection:i}),p=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"target-scores-only",{getAllForTarget:a,isDeleted:s}=(0,z.I)(),l=a(n,{traceId:"trace"===t.type?t.traceId:void 0,observationId:"trace"===t.type?t.observationId:void 0,sessionId:"session"===t.type?t.sessionId:void 0}),o=(0,r.useMemo)(()=>
1(0,F.a)(e,t,n),[e,t,n]),i=(0,r.useMemo)(()=>{let e=new Set;return o.forEach(t=>{t.id&&s(t.id)&&e.add(t.id)}),e},[o,s]);return(0,r.useMemo)(()=>(0,_.DH)(o,l,i),[o,l,i])}((0,r.useMemo)(()=>Array.isArray(n)?J(n,u):J(n,u,"trace"===t.type?t.traceId:"","trace"===t.type?t.observationId:void 0),[n,u,t]),t),h=[],x=new Set;p.forEach(e=>{x.add(e.configId),h.push({id:e.id,configId:e.configId,name:e.name,dataType:e.dataType,value:e.value,stringValue:e.stringValue,comment:e.comment,timestamp:e.timestamp})}),m.forEach(e=>{if(!x.has(e)){let t=u.find(t=>t.id===e);t&&h.push({id:null,configId:e,name:t.name,dataType:t.dataType,value:null,stringValue:null,comment:null,timestamp:null})}});let f=h.sort((e,t)=>e.name.localeCompare(t.name));return c?(0,a.jsx)(Z.E,{className:"h-full w-full","data-sentry-element":"Skeleton","data-sentry-component":"AnnotationForm","data-sentry-source-file":"AnnotationForm.tsx"}):(0,a.jsx)(en,{scoreTarget:t,initialFormData:f,scoreMetadata:s,analyticsData:l,actionButtons:o,configControl:{configs:u,allowManualSelection:"selectable"===i.mode},"data-sentry-element":"InnerAnnotationForm","data-sentry-component":"AnnotationForm","data-sentry-source-file":"AnnotationForm.tsx"})}},94636:(e,t,n)=>{n.d(t,{W:()=>a});let a=e=>{try{if("object"!=typeof e||null===e)return null;return e.target_trace_id}catch(e){return null}}},94795:(e,t,n)=>{n.d(t,{X:()=>x});var a=n(73154),r=n(96810),s=n(59895),l=n(21),o=n(27131),i=n(69762),d=n(81509),c=n(67716),u=n(86843),m=n(90270),p=n(88377),h=n(62766);function x(e){let{title:t="Select",placeholder:n,values:x,onValueChange:f,options:g,groupedOptions:y,className:v,disabled:j,items:b="items",align:w="center",controlButtons:N,hideClearButton:C=!1,iconLeft:T,iconRight:I,variant:S="secondary",showSelectedValueStrings:k=!0}=e,[E,O]=r.useState(!1),[A,M]=r.useState(""),D=new Set(x.map(e=>"string"==typeof e?e:e.key)),P=D.size>0&&!C,L=e=>{if(!A.trim())return e;let t=A.toLowerCase().trim();return e.filter(e=>{var n;let a=e.value.toLowerCase(),r=(null==(n=e.key)?void 0:n.toLowerCase())||"";return a.includes(t)||r.includes(t)})},B=e=>{var t,n;let r=D.has(null!=(t=e.key)?t:e.value);return(0,a.jsxs)(p.hO,{checked:r,onSelect:e=>e.preventDefault(),onCheckedChange:()=>{var t;let n=null!=(t=e.key)?t:e.value;r?D.delete(n):D.add(n);let a=x.length>0&&"string"==typeof x[0]?Array.from(D):(y?y.flatMap(e=>e.options):g||[]).filter(e=>!!e.key&&D.has(e.key)).map(e=>({key:e.key,value:e.value}));f(a.length?a:[],n,D)},disabled:e.disabled,className:"group","data-sentry-element":"DropdownMenuCheckboxItem","data-sentry-component":"renderOption","data-sentry-source-file":"multi-select-key-values.tsx",children:[(0,a.jsx)("span",{className:(0,d.cn)("capitalize",e.isArchived?"text-foreground/50":""),children:e.value}),e.isArchived&&(0,a.jsx)(s.A,{className:"ml-2 h-4 w-4 text-foreground/50"}),void 0!==e.count&&(0,a.jsx)("span",{className:"ml-auto font-mono text-xs",children:e.count})]},null!=(n=e.key)?n:e.value)},R=r.useRef(null);return(0,a.jsxs)(p.rI,{open:E,onOpenChange:e=>{O(e),e||M("")},"data-sentry-element":"DropdownMenu","data-sentry-component":"MultiSelectKeyValues","data-sentry-source-file":"multi-select-key-values.tsx",children:[(0,a.jsx)(p.ty,{asChild:!0,"data-sentry-element":"DropdownMenuTrigger","data-sentry-source-file":"multi-select-key-values.tsx",children:(0,a.jsxs)(u.$,{variant:S,className:(0,d.cn)("flex h-8 w-full items-center justify-between rounded-md px-3 py-1 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",v),disabled:j,"data-sentry-element":"Button","data-sentry-source-file":"multi-select-key-values.tsx",children:[T,t,I,(0,a.jsx)(l.A,{className:"h-4 w-4 opacity-50","data-sentry-element":"ChevronDown","data-sentry-source-file":"multi-select-key-values.tsx"}),D.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.w,{orientation:"vertical",className:"mx-2 h-4"}),(0,a.jsx)(c.E,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:D.size}),(0,a.jsx)("div",{className:"hidden space-x-1 overflow-x-auto lg:flex",children:D.size>2||!k?(0,a.jsx)(c.E,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:D.size}):g.filter(e=>{var t;return D.has(null!=(t=e.key)?t:e.value)}).map(e=>(0,a.jsx)(c.E,{variant:"secondary",className:"rounded-sm px-1 font-normal capitalize",children:e.value},e.key))})]})]})}),(0,a.jsxs)(p.SQ,{align:w,className:"w-[200px]",onPointerDownOutside:()=>O(!1),"data-sentry-element":"DropdownMenuContent","data-sentry-source-file":"multi-select-key-values.tsx",children:[(0,a.jsxs)("div",{className:"flex items-center border-b px-2 py-1",onClick:e=>{var t;
1e.stopPropagation(),null==(t=R.current)||t.focus()},children:[(0,a.jsx)(o.A,{className:"mr-1 h-3 w-3 opacity-50","data-sentry-element":"Search","data-sentry-source-file":"multi-select-key-values.tsx"}),(0,a.jsx)(m.p,{ref:R,placeholder:n,value:A,onChange:e=>M(e.target.value),className:"h-6 border-0 bg-transparent p-0 text-sm focus-visible:ring-0",autoComplete:"off",autoCorrect:"off",spellCheck:!1,onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),"data-sentry-element":"Input","data-sentry-source-file":"multi-select-key-values.tsx"})]}),(0,a.jsxs)("div",{className:"max-h-[300px] overflow-y-auto",children:[g&&g.length>0&&L(Array.from(g)).map(B),null==y?void 0:y.map(e=>{let t=L(e.options);return 0===t.length?null:(0,a.jsxs)(p.lv,{children:[(0,a.jsxs)(p.nV,{className:"flex w-full cursor-default select-none items-center",children:[(0,a.jsx)(i.A,{className:"mr-2 h-4 w-4 opacity-50"}),(0,a.jsx)("span",{children:e.label})]}),(0,a.jsx)(p.M5,{className:"max-h-[300px] overflow-y-auto",children:t.map(B)})]},e.label)}),A&&(!g||0===L(Array.from(g)).length)&&(!y||!y.some(e=>L(e.options).length>0))&&(0,a.jsx)("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No results found."}),P&&!A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.mB,{}),(0,a.jsxs)(p._2,{onSelect:e=>{e.preventDefault(),f([])},children:["Clear ",b]})]}),N&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.mB,{}),N]})]})]})]})}},95601:(e,t,n)=>{n.d(t,{k:()=>u});var a=n(73154);n(96810);var r=n(86843),s=n(72764),l=n(89822),o=n(28436),i=n(92125),d=n(18799),c=n(91449);function u(e){let{projectId:t,scoreTarget:n,scores:u,analyticsData:m={type:"trace",source:"TraceDetail"},scoreMetadata:p,buttonVariant:h="secondary",size:x="default"}=e,f=(0,i.B)(),g=(0,d.lp)({projectId:t,scope:"scores:CUD"}),y=u.some(e=>"ANNOTATION"!==e.source);return(0,a.jsxs)(o._s,{"data-sentry-element":"Drawer","data-sentry-component":"AnnotateDrawer","data-sentry-source-file":"AnnotateDrawer.tsx",children:[(0,a.jsx)(o.Uz,{asChild:!0,"data-sentry-element":"DrawerTrigger","data-sentry-source-file":"AnnotateDrawer.tsx",children:(0,a.jsxs)(r.$,{variant:h,size:x,disabled:!g,className:"rounded-r-none",onClick:()=>{f(u.length?"score:update_form_open":"score:create_form_open",m)},"data-sentry-element":"Button","data-sentry-source-file":"AnnotateDrawer.tsx",children:[g?(0,a.jsx)(l.A,{className:"sm"===x?"mr-1.5 h-3.5 w-3.5":"mr-1.5 h-4 w-4"}):(0,a.jsx)(s.A,{className:"mr-1.5 h-3 w-3"}),(0,a.jsx)("span",{children:"Annotate"})]})}),(0,a.jsxs)(o.zj,{className:"p-3","data-sentry-element":"DrawerContent","data-sentry-source-file":"AnnotateDrawer.tsx",children:[(0,a.jsx)(c._,{serverScores:u,scoreTarget:n,analyticsData:m,scoreMetadata:p,"data-sentry-element":"AnnotationForm","data-sentry-source-file":"AnnotateDrawer.tsx"}),y&&(0,a.jsx)("div",{className:"mt-4 text-xs text-muted-foreground",children:"API and eval scores visible on left. Add manual annotations above."})]})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.