import{r as u,j as e,a9 as Ui,v as s,F as B,R as ke,b as _,aa as Bn,w as K,ab as Te,ac as Oe,$ as H,ad as Hn,y as be,z as Se,D as J,B as Nn,o as el,ae as an,af as se,ag as ln,ah as Ji,E as Ka,ai as An,a7 as ae,a1 as bn,a2 as U,aj as de,ak as cn,al as Xi,am as oa,an as da,ao as ca,ap as In,aq as Fe,ar as nl,n as al,a as Yi,as as Zi,at as er,au as nr,av as ar,aw as lr,c as tr,d as ir,ax as rr}from"./vendor-CP0b0YG0.js";import{R as Ce,u as Ie,a as Pe,T as xa,P as ll,b as tl,M as $a,c as Va,d as $n,D as sr,e as or,f as V,g as il,h as ge,i as Jn,j as Sn,k as rl,l as vn,m as Fn,n as sl,o as Me,p as sn,C as te,q as Xn,r as je,s as Ta,t as Vn,E as ol,v as dr,w as cr,L as ue,x as ur,y as mr,F as gr,z as pr,A as Rn,B as xe,S as yr,G as fr,H as dl,I as hr,J as kr,K as za,N as br,O as Sr,Q as vr,U as Fr,V as Kr,W as xr,X as cl,Y as Kn,Z as Tr,_ as Dr,$ as Cr,a0 as Ir,a1 as Lr,a2 as tn,a3 as Da,a4 as ul,a5 as yn,a6 as va,a7 as gn,a8 as Ke,a9 as ve,aa as Y,ab as on,ac as Er,ad as Ca,ae as Ee,af as _e,ag as _r,ah as Rr,ai as wr,aj as fe,ak as Re,al as zn,am as Pr,an as Mr,ao as Nr,ap as Ia,aq as we,ar as Yn,as as ml,at as Ar,au as Qn,av as xn,aw as Ne,ax as gl,ay as Tn,az as Dn,aA as $r,aB as Qa,aC as pl,aD as Vr,aE as zr,aF as Qr,aG as Gn,aH as Or,aI as jr,aJ as qr,aK as Br,aL as Hr,aM as Gr,aN as Wr,aO as Ur,aP as fn,aQ as Xe,aR as Jr,aS as La,aT as Ye,aU as Xr,aV as Yr,aW as Zn,aX as Zr,aY as Ea,aZ as es}from"./components-kGgeFkHp.js";import{C as G,j as T,D as ea,G as ee,H as yl,J as he,K as q,M as hn,N as me,O as ns,l as _a,Q as On,P as dn,I as M,e as P,S as qe,a as fl,c as oe,p as na,q as aa,t as le,h as x,n as hl,U as Ae,i as b,L as Ze,V as kl,f as z,s as ne,W as bl,X as Sl,Y as as,Z as ls,_ as $e,b as en,T as pe,d as ye,y as la,$ as Q,a0 as vl,r as wn,E as Ra,B as ta,a1 as wa,a2 as ts,x as ia,u as is,a3 as rs}from"./vendor-arizeai-B5Hti8OB.js";import{R as Be,C as jn,X as He,Y as De,a as Ge,T as We,B as kn,A as Pn,b as Fl,c as Pa,L as Kl,d as ss,P as os,e as ds,f as cs}from"./vendor-recharts-A0DA1O99.js";import{p as Ma,R as ra,n as sa,j as us,E as ms,k as gs,b as ps}from"./vendor-codemirror-DtdPDzrv.js";const xl="arize-phoenix-feature-flags",ua={annotations:!1};function ys(){const n=localStorage.getItem(xl);if(!n)return ua;try{const a=JSON.parse(n);return Object.assign({},ua,a)}catch{return ua}}const Tl=u.createContext(null);function Dl(){const n=ke.useContext(Tl);if(n===null)throw new Error("useFeatureFlags must be used within a FeatureFlagsProvider");return n}function fs(n){const{featureFlags:a}=Dl();return a[n]}function cu(n){const[a,l]=u.useState(ys()),t=i=>{localStorage.setItem(xl,JSON.stringify(i)),l(i)};return e(Tl.Provider,{value:{featureFlags:a,setFeatureFlags:t},children:e(hs,{children:n.children})})}function hs(n){const{children:a}=n,{featureFlags:l,setFeatureFlags:t}=Dl(),[i,r]=u.useState(!1);return Ui("ctrl+shift+f",()=>r(!0)),s(B,{children:[a,e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>r(!1),children:i&&e(G,{title:"Feature Flags",children:e(T,{height:"size-1000",padding:"size-100",children:Object.keys(l).map(o=>e(ea,{isSelected:l[o],onChange:c=>t({...l,[o]:c}),children:o},o))})})})]})}const Cl=function(){var n=[{alias:null,args:null,concreteType:"Functionality",kind:"LinkedField",name:"functionality",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"modelInferences",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"homeLoaderQuery",selections:n,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"homeLoaderQuery",selections:n},params:{cacheID:"6926e4e720b443f7b7252b60271944e6",id:null,metadata:{},name:"homeLoaderQuery",operationKind:"query",text:`query homeLoaderQuery {
  functionality {
    modelInferences
  }
  projects {
    edges {
      project: node {
        id
        endTime
      }
    }
  }
}
`}}}();Cl.hash="a4bbc4917b3217b8254d68ec7c76dbdd";async function uu(n){var l;const a=await _.fetchQuery(Ce,Cl,{}).toPromise();if(a!=null&&a.functionality.modelInferences)return Bn("/model");if((l=a==null?void 0:a.projects.edges)!=null&&l.length){let t=0,i=null;for(const{project:o}of a.projects.edges)o.endTime!=null&&(t++,i=o.id);if(t>1)return Bn("/projects");if(t===1&&i!=null)return Bn(`/projects/${i}`);const r=a==null?void 0:a.projects.edges[0].project.id;return Bn(`/projects/${r}`)}else throw new Error("No functionality available")}const Il=function(){var n={defaultValue:null,kind:"LocalArgument",name:"endTime"},a={defaultValue:null,kind:"LocalArgument",name:"startTime"},l=[{kind:"Variable",name:"endTime",variableName:"endTime"},{kind:"Variable",name:"startTime",variableName:"startTime"}],t=[{kind:"Literal",name:"first",value:50}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},o={fields:[{kind:"Variable",name:"end",variableName:"endTime"},{kind:"Variable",name:"start",variableName:"startTime"}],kind:"ObjectValue",name:"timeRange"},c={alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},d=[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],m={alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ModelPageQuery",selections:[{args:l,kind:"FragmentSpread",name:"ModelSchemaTable_dimensions"},{args:l,kind:"FragmentSpread",name:"ModelEmbeddingsTable_embeddingDimensions"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ModelPageQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:t,concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dimension",args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[i,r,{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"dataType",storageKey:null},{alias:"cardinality",args:[{kind:"Literal",name:"metric",value:"cardinality"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"percentEmpty",args:[{kind:"Literal",name:"metric",value:"percentEmpty"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"min",args:[{kind:"Literal",name:"metric",value:"min"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"mean",args:[{kind:"Literal",name:"metric",value:"mean"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"max",args:[{kind:"Literal",name:"metric",value:"max"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},o],kind:"ScalarField",name:"driftMetric",storageKey:null}],storageKey:null},c,{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:d,storageKey:null}],storageKey:null},m],storageKey:"dimensions(first:50)"},{alias:null,args:t,filters:null,handle:"connection",key:"ModelSchemaTable_dimensions",kind:"LinkedHandle",name:"dimensions"},{alias:null,args:t,concreteType:"EmbeddingDimensionConnection",kind:"LinkedField",name:"embeddingDimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"EmbeddingDimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"embedding",args:null,concreteType:"EmbeddingDimension",kind:"LinkedField",name:"node",plural:!1,selections:[i,r,{alias:"euclideanDistance",args:[{kind:"Literal",name:"metric",value:"euclideanDistance"},o],kind:"ScalarField",name:"driftMetric",storageKey:null}],storageKey:null},c,{alias:null,args:null,concreteType:"EmbeddingDimension",kind:"LinkedField",name:"node",plural:!1,selections:d,storageKey:null}],storageKey:null},m],storageKey:"embeddingDimensions(first:50)"},{alias:null,args:t,filters:null,handle:"connection",key:"ModelEmbeddingsTable_embeddingDimensions",kind:"LinkedHandle",name:"embeddingDimensions"}],storageKey:null}]},params:{cacheID:"18059ac8df6b3c15d5e4bc04ca2c9877",id:null,metadata:{},name:"ModelPageQuery",operationKind:"query",text:`query ModelPageQuery(
  $startTime: DateTime!
  $endTime: DateTime!
) {
  ...ModelSchemaTable_dimensions_3uKjWt
  ...ModelEmbeddingsTable_embeddingDimensions_3uKjWt
}

fragment ModelEmbeddingsTable_embeddingDimensions_3uKjWt on Query {
  model {
    embeddingDimensions(first: 50) {
      edges {
        embedding: node {
          id
          name
          euclideanDistance: driftMetric(metric: euclideanDistance, timeRange: {start: $startTime, end: $endTime})
        }
        cursor
        node {
          __typename
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

fragment ModelSchemaTable_dimensions_3uKjWt on Query {
  model {
    dimensions(first: 50) {
      edges {
        dimension: node {
          id
          name
          type
          dataType
          cardinality: dataQualityMetric(metric: cardinality, timeRange: {start: $startTime, end: $endTime})
          percentEmpty: dataQualityMetric(metric: percentEmpty, timeRange: {start: $startTime, end: $endTime})
          min: dataQualityMetric(metric: min, timeRange: {start: $startTime, end: $endTime})
          mean: dataQualityMetric(metric: mean, timeRange: {start: $startTime, end: $endTime})
          max: dataQualityMetric(metric: max, timeRange: {start: $startTime, end: $endTime})
          psi: driftMetric(metric: psi, timeRange: {start: $startTime, end: $endTime})
        }
        cursor
        node {
          __typename
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}
`}}}();Il.hash="b612239336c7638df42037315b00f635";function mu(n){const{referenceInferences:a}=Ie(),{timeRange:l}=Pe(),t=_.useLazyLoadQuery(Il,{startTime:l.start.toISOString(),endTime:l.end.toISOString()});return s("main",{children:[s(xa,{children:[e(ll,{}),a?e(tl,{inferencesRole:"reference",timeRange:{start:new Date(a.startTime),end:new Date(a.endTime)}}):null]}),e("section",{css:K`
          margin: var(--px-spacing-lg);
        `,children:e(yl,{title:"Model Schema",variant:"compact",bodyStyle:{padding:0},children:s(he,{children:[e(q,{name:"All",children:s(hn,{children:[e(me,{title:"Embeddings",id:"embeddings",children:e($a,{model:t})}),e(me,{title:"Dimensions",id:"dimensions",children:e(Va,{model:t})})]})},"all"),e(q,{name:"Embeddings",children:e($a,{model:t})},"embeddings"),e(q,{name:"Dimensions",children:e(Va,{model:t})},"dimensions")]})})}),e(Te,{})]})}const Ll={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"EmbeddingPageModelQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"MetricSelector_dimensions"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"EmbeddingPageModelQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:"numericDimensions",args:[{kind:"Literal",name:"include",value:{dataTypes:["numeric"]}}],concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'dimensions(include:{"dataTypes":["numeric"]})'}],storageKey:null}]},params:{cacheID:"4ccf476dd862525b059197daccd0d4d9",id:null,metadata:{},name:"EmbeddingPageModelQuery",operationKind:"query",text:`query EmbeddingPageModelQuery {
  model {
    ...MetricSelector_dimensions
  }
}

fragment MetricSelector_dimensions on Model {
  numericDimensions: dimensions(include: {dataTypes: [numeric]}) {
    edges {
      node {
        id
        name
        type
      }
    }
  }
}
`}};Ll.hash="374499f7f8ce6919e4a0a4ecbe380c52";const El=function(){var n={defaultValue:null,kind:"LocalArgument",name:"clusterMinSamples"},a={defaultValue:null,kind:"LocalArgument",name:"clusterSelectionEpsilon"},l={defaultValue:null,kind:"LocalArgument",name:"dataQualityMetricColumnName"},t={defaultValue:null,kind:"LocalArgument",name:"fetchDataQualityMetric"},i={defaultValue:null,kind:"LocalArgument",name:"fetchPerformanceMetric"},r={defaultValue:null,kind:"LocalArgument",name:"id"},o={defaultValue:null,kind:"LocalArgument",name:"minClusterSize"},c={defaultValue:null,kind:"LocalArgument",name:"minDist"},d={defaultValue:null,kind:"LocalArgument",name:"nNeighbors"},m={defaultValue:null,kind:"LocalArgument",name:"nSamples"},y={defaultValue:null,kind:"LocalArgument",name:"performanceMetric"},g={defaultValue:null,kind:"LocalArgument",name:"timeRange"},p=[{kind:"Variable",name:"id",variableName:"id"}],f={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},k={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},S={alias:null,args:null,kind:"ScalarField",name:"x",storageKey:null},h={alias:null,args:null,kind:"ScalarField",name:"y",storageKey:null},F=[f,{alias:null,args:null,kind:"ScalarField",name:"eventId",storageKey:null},{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"coordinates",plural:!1,selections:[k,{kind:"InlineFragment",selections:[S,h,{alias:null,args:null,kind:"ScalarField",name:"z",storageKey:null}],type:"Point3D",abstractKey:null},{kind:"InlineFragment",selections:[S,h],type:"Point2D",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EmbeddingMetadata",kind:"LinkedField",name:"embeddingMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"linkToData",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"rawData",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EventMetadata",kind:"LinkedField",name:"eventMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"predictionId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualScore",storageKey:null}],storageKey:null}],L=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"referenceValue",storageKey:null}],I={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"clusterMinSamples",variableName:"clusterMinSamples"},{kind:"Variable",name:"clusterSelectionEpsilon",variableName:"clusterSelectionEpsilon"},{kind:"Variable",name:"minClusterSize",variableName:"minClusterSize"},{kind:"Variable",name:"minDist",variableName:"minDist"},{kind:"Variable",name:"nNeighbors",variableName:"nNeighbors"},{kind:"Variable",name:"nSamples",variableName:"nSamples"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"UMAPPoints",kind:"LinkedField",name:"UMAPPoints",plural:!1,selections:[{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"data",plural:!0,selections:F,storageKey:null},{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"referenceData",plural:!0,selections:F,storageKey:null},{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"corpusData",plural:!0,selections:F,storageKey:null},{alias:null,args:null,concreteType:"Cluster",kind:"LinkedField",name:"clusters",plural:!0,selections:[f,{alias:null,args:null,kind:"ScalarField",name:"eventIds",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"driftRatio",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"primaryToCorpusRatio",storageKey:null},{condition:"fetchDataQualityMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"columnName",variableName:"dataQualityMetricColumnName"},{kind:"Literal",name:"metric",value:"mean"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"dataQualityMetric",plural:!1,selections:L,storageKey:null}]},{condition:"fetchPerformanceMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"metric",variableName:"performanceMetric"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"performanceMetric",plural:!1,selections:L,storageKey:null}]}],storageKey:null},{alias:null,args:null,concreteType:"Retrieval",kind:"LinkedField",name:"contextRetrievals",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"queryId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"relevance",storageKey:null}],storageKey:null}],storageKey:null}],type:"EmbeddingDimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l,t,i,r,o,c,d,m,y,g],kind:"Fragment",metadata:null,name:"EmbeddingPageUMAPQuery",selections:[{alias:"embedding",args:p,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[I],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[r,g,c,d,m,o,n,a,t,l,i,y],kind:"Operation",name:"EmbeddingPageUMAPQuery",selections:[{alias:"embedding",args:p,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[k,I,{kind:"TypeDiscriminator",abstractKey:"__isNode"},f],storageKey:null}]},params:{cacheID:"d30210c52f86b9d9a7ac958f866aa93e",id:null,metadata:{},name:"EmbeddingPageUMAPQuery",operationKind:"query",text:`query EmbeddingPageUMAPQuery(
  $id: GlobalID!
  $timeRange: TimeRange!
  $minDist: Float!
  $nNeighbors: Int!
  $nSamples: Int!
  $minClusterSize: Int!
  $clusterMinSamples: Int!
  $clusterSelectionEpsilon: Float!
  $fetchDataQualityMetric: Boolean!
  $dataQualityMetricColumnName: String
  $fetchPerformanceMetric: Boolean!
  $performanceMetric: PerformanceMetric!
) {
  embedding: node(id: $id) {
    __typename
    ... on EmbeddingDimension {
      UMAPPoints(timeRange: $timeRange, minDist: $minDist, nNeighbors: $nNeighbors, nSamples: $nSamples, minClusterSize: $minClusterSize, clusterMinSamples: $clusterMinSamples, clusterSelectionEpsilon: $clusterSelectionEpsilon) {
        data {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        referenceData {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        corpusData {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        clusters {
          id
          eventIds
          driftRatio
          primaryToCorpusRatio
          dataQualityMetric(metric: {columnName: $dataQualityMetricColumnName, metric: mean}) @include(if: $fetchDataQualityMetric) {
            primaryValue
            referenceValue
          }
          performanceMetric(metric: {metric: $performanceMetric}) @include(if: $fetchPerformanceMetric) {
            primaryValue
            referenceValue
          }
        }
        contextRetrievals {
          queryId
          documentId
          relevance
        }
      }
    }
    __isNode: __typename
    id
  }
}
`}}}();El.hash="f1ee7ce02317f1c3fe96b77af405095f";function ks(){const{theme:n}=$n();return u.useMemo(()=>n==="light"?sr:or,[n])}function bs(){const{embeddingDimensionId:n}=Oe();if(!n)throw new Error("Missing embeddingDimensionId in URL params");return n}const _l={euclideanDistance:{name:"Euclidean Distance",shortName:"Euc. Distance",definition:"Euclidean distance over time captures how much your primary inferences's embeddings are drifting from the reference data. Euclidean distance of the embeddings is calculated by taking the centroid of the embedding vectors for each inferences and calculating the distance between the two centroids."},queryDistance:{name:"Query Distance",shortName:"Query Distance",definition:"The query distance is the euclidean distance of the centroid of queries from the centroid of the corpus."},accuracyScore:{name:"Accuracy Score",shortName:"Accuracy",definition:"Accuracy classification score. In multi-label classification, this function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in the ground truth."}};function nn(n){const a=_l[n];return a!=null?a.shortName:n}function ma(n){const a=_l[n];return a&&a.definition!=null&&a.definition||null}function un(n){return`${n.column}:${n.dir}`}function Ss(){const{referenceInferences:n}=Ie(),a=!!n,l=V(d=>d.clusterSort),t=V(d=>d.setClusterSort),[i,r]=u.useState(!1),o=u.useMemo(()=>{const d=[];return a&&d.push({label:"Most drift",value:un({column:"driftRatio",dir:"desc"})}),[...d,{label:"Largest clusters",value:un({column:"size",dir:"desc"})},{label:"Smallest clusters",value:un({column:"size",dir:"asc"})},{label:"Highest metric value",value:un({column:"primaryMetricValue",dir:"desc"})},{label:"Lowest metric value",value:un({column:"primaryMetricValue",dir:"asc"})}]},[a]),c=un(l);return e("div",{css:d=>K`
        .ac-action-button {
          background: none;
          border: none;
          color: ${"var(--ac-global-text-color-700)"};
          font-size: ${d.typography.sizes.small.fontSize}px;
          line-height: ${d.typography.sizes.small.lineHeight}px;
          cursor: pointer;
          outline: none;
          &:hover {
            color: var(--ac-global-text-color-900);
          }
        }
      `,children:s(dn,{placement:"bottom right","aria-label":"Sort clusters by",isOpen:i,onOpenChange:d=>r(d),children:[s(ns,{children:["Sort",e("span",{"aria-hidden":!0,"data-testid":"dropdown-caret",css:K`
              margin-left: var(--px-spacing-sm);
              border-bottom-color: #0000;
              border-left-color: #0000;
              border-right-color: #0000;
              border-style: solid;
              border-width: 3px 3px 0;
              content: "";
              display: inline-block;
              height: 0;
              vertical-align: middle;
              width: 0;
            `})]}),e(_a,{children:e(On,{style:{width:200},selectedKeys:[c],selectionMode:"single",items:o,onSelectionChange:d=>{if(d instanceof Set&&d.size>0){const[m]=d.values(),[y,g]=m.split(":");t({column:y,dir:g})}r(!1)},children:d=>e(H,{children:d.label},d.value)})})]})})}const Rl=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"clusters"}],a=[{alias:null,args:[{kind:"Variable",name:"clusters",variableName:"clusters"}],concreteType:"ExportedFile",kind:"LinkedField",name:"exportClusters",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EmbeddingActionMenuExportClustersMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EmbeddingActionMenuExportClustersMutation",selections:a},params:{cacheID:"1bef6586fcb3d6eb7034204fbe49633c",id:null,metadata:{},name:"EmbeddingActionMenuExportClustersMutation",operationKind:"mutation",text:`mutation EmbeddingActionMenuExportClustersMutation(
  $clusters: [ClusterInput!]!
) {
  exportClusters(clusters: $clusters) {
    fileName
  }
}
`}}}();Rl.hash="b5ff2517dbb0d19a1b24dea1796a3576";function vs(){const n=V(r=>r.clusters),{notifyError:a,notifySuccess:l}=il(),[t,i]=_.useMutation(Rl);return e(qe,{align:"end",buttonSize:"compact",icon:i?e(M,{svg:e(P.LoadingOutline,{})}):null,onAction:r=>{switch(r){case"export_cluster":t({variables:{clusters:n.map(o=>({eventIds:o.eventIds,id:o.id}))},onCompleted:o=>{const{fileName:c}=o.exportClusters;l({title:"Clusters Exported",message:"dataframe is available via px.active_session().exports or can be downloaded by clicking below",action:{text:"Download",onClick:()=>{window.open(`/exports?filename=${c}`,"_self")}}})},onError:o=>{a({title:"Failed to export clusters",message:`Failed to export clusters: ${o.message}`})}});break}},children:s(H,{children:[e(M,{svg:e(P.Download,{})}),"Export clusters"]},"export_cluster")})}const wl={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"MetricSelector_dimensions",selections:[{alias:"numericDimensions",args:[{kind:"Literal",name:"include",value:{dataTypes:["numeric"]}}],concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'dimensions(include:{"dataTypes":["numeric"]})'}],type:"Model",abstractKey:null};wl.hash="55d03de16503d7af254c17cef7d18ee0";const pn=":";function Fs(n){return["drift","performance","dataQuality","retrieval"].includes(n)}function Ln(n){const{type:a,metric:l}=n;switch(a){case"drift":return`${a}${pn}${l}`;case"retrieval":return`${a}${pn}${l}`;case"performance":return`${a}${pn}${l}`;case"dataQuality":{const{name:t}=n.dimension;return`${a}${pn}${l}${pn}${t}`}default:ge()}}function Ks({metricKey:n,dimensions:a}){const[l,t,i]=n.split(pn);if(!Fs(l))throw new Error(`Invalid metric type: ${l}`);switch(l){case"drift":return{type:l,metric:t};case"retrieval":return{type:l,metric:t};case"performance":return{type:l,metric:t};case"dataQuality":{const r=a.find(o=>o.name===i);if(!r)throw new Error(`Invalid dimension name: ${i}`);return{type:l,metric:t,dimension:r}}default:ge()}}const xs=s(aa,{variant:"info",children:[e(oe,{level:4,children:"Analysis Metric"}),s(na,{children:[e("p",{children:"Select a metric to drive the analysis of your embeddings."}),e("p",{children:"To analyze the the drift between your two inferencess, select a drift metric and the UI will highlight areas of high drift."}),e("p",{children:"To analyze the quality of your embeddings, select a dimension data quality metric by which to analyze the point cloud. The UI will highlight areas where the data quality is degrading."})]})]});function Ts({model:n}){const[,a]=u.useTransition(),l=_.useFragment(wl,n),{referenceInferences:t,corpusInferences:i}=Ie(),r=!!t,o=!!i,c=V(f=>f.metric),d=V(f=>f.loading),m=V(f=>f.setMetric),y=l.numericDimensions.edges.map(f=>f.node),g=y.length>0,p=u.useCallback(f=>{const k=Ks({metricKey:f,dimensions:y});a(()=>{m(k)})},[m,y,a]);return s(fl,{label:"metric",labelExtra:xs,selectedKey:c?Ln(c):void 0,onSelectionChange:p,placeholder:"Select a metric...",isDisabled:d,children:[r?e(Hn,{title:"Drift",children:e(H,{children:"Euclidean Distance"},Ln({type:"drift",metric:"euclideanDistance"}))}):null,o?e(Hn,{title:"Retrieval",children:e(H,{children:"Query Distance"},Ln({type:"retrieval",metric:"queryDistance"}))}):null,e(Hn,{title:"Performance",children:e(H,{children:"Accuracy Score"},Ln({type:"performance",metric:"accuracyScore"}))}),g?e(Hn,{title:"Data Quality",children:y.map(f=>e(H,{children:`${f.name} avg`},Ln({type:"dataQuality",metric:"average",dimension:f})))}):null]})}const Pl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"embeddingDimensionId"},t={defaultValue:null,kind:"LocalArgument",name:"fetchDataQuality"},i={defaultValue:null,kind:"LocalArgument",name:"fetchDrift"},r={defaultValue:null,kind:"LocalArgument",name:"fetchPerformance"},o={defaultValue:null,kind:"LocalArgument",name:"fetchQueryDistance"},c={defaultValue:null,kind:"LocalArgument",name:"metricGranularity"},d={defaultValue:null,kind:"LocalArgument",name:"performanceMetric"},m={defaultValue:null,kind:"LocalArgument",name:"timeRange"},y=[{kind:"Variable",name:"id",variableName:"embeddingDimensionId"}],g={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},p={kind:"Variable",name:"granularity",variableName:"metricGranularity"},f={kind:"Variable",name:"timeRange",variableName:"timeRange"},k=[p,{kind:"Literal",name:"metric",value:"euclideanDistance"},f],S=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],h={kind:"InlineFragment",selections:[{condition:"fetchDrift",kind:"Condition",passingValue:!0,selections:[{alias:"euclideanDistanceTimeSeries",args:k,concreteType:"DriftTimeSeries",kind:"LinkedField",name:"driftTimeSeries",plural:!1,selections:S,storageKey:null}]},{condition:"fetchQueryDistance",kind:"Condition",passingValue:!0,selections:[{alias:null,args:k,concreteType:"DriftTimeSeries",kind:"LinkedField",name:"retrievalMetricTimeSeries",plural:!1,selections:S,storageKey:null}]},{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},f],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:S,storageKey:null}],type:"EmbeddingDimension",abstractKey:null},F=[{kind:"Variable",name:"id",variableName:"dimensionId"}],L={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:[p,{kind:"Literal",name:"metric",value:"mean"},f],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:S,storageKey:null}],type:"Dimension",abstractKey:null},I={alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{condition:"fetchPerformance",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[p,{fields:[{kind:"Variable",name:"metric",variableName:"performanceMetric"}],kind:"ObjectValue",name:"metric"},f],concreteType:"PerformanceTimeSeries",kind:"LinkedField",name:"performanceTimeSeries",plural:!1,selections:S,storageKey:null}]}],storageKey:null},C={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null};return{fragment:{argumentDefinitions:[n,a,l,t,i,r,o,c,d,m],kind:"Fragment",metadata:null,name:"MetricTimeSeriesQuery",selections:[{alias:"embedding",args:y,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[g,h],storageKey:null},{condition:"fetchDataQuality",kind:"Condition",passingValue:!0,selections:[{alias:"dimension",args:F,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[L],storageKey:null}]},I],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[l,m,c,n,i,o,t,a,r,d],kind:"Operation",name:"MetricTimeSeriesQuery",selections:[{alias:"embedding",args:y,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[C,g,h],storageKey:null},{condition:"fetchDataQuality",kind:"Condition",passingValue:!0,selections:[{alias:"dimension",args:F,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[C,L,{kind:"TypeDiscriminator",abstractKey:"__isNode"},g],storageKey:null}]},I]},params:{cacheID:"a68a8204bf7fdd13e6915b338d4b5497",id:null,metadata:{},name:"MetricTimeSeriesQuery",operationKind:"query",text:`query MetricTimeSeriesQuery(
  $embeddingDimensionId: GlobalID!
  $timeRange: TimeRange!
  $metricGranularity: Granularity!
  $countGranularity: Granularity!
  $fetchDrift: Boolean!
  $fetchQueryDistance: Boolean!
  $fetchDataQuality: Boolean!
  $dimensionId: GlobalID!
  $fetchPerformance: Boolean!
  $performanceMetric: PerformanceMetric!
) {
  embedding: node(id: $embeddingDimensionId) {
    __typename
    id
    ... on EmbeddingDimension {
      euclideanDistanceTimeSeries: driftTimeSeries(metric: euclideanDistance, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchDrift) {
        data {
          timestamp
          value
        }
      }
      retrievalMetricTimeSeries(metric: euclideanDistance, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchQueryDistance) {
        data {
          timestamp
          value
        }
      }
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
  dimension: node(id: $dimensionId) @include(if: $fetchDataQuality) {
    __typename
    ... on Dimension {
      name
      dataQualityTimeSeries(metric: mean, timeRange: $timeRange, granularity: $metricGranularity) {
        data {
          timestamp
          value
        }
      }
    }
    __isNode: __typename
    id
  }
  model {
    performanceTimeSeries(metric: {metric: $performanceMetric}, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchPerformance) {
      data {
        timestamp
        value
      }
    }
  }
}
`}}}();Pl.hash="f31abad2141a5a1c461ef2a598ffa4f3";const Oa=new Intl.NumberFormat([],{maximumFractionDigits:2}),Ml=()=>{const n=Me(),a=n.blue400,l=n.gray500;return{color:a,barColor:l}};function Ds({active:n,payload:a,label:l}){var r,o,c;const{color:t,barColor:i}=Ml();if(n&&a&&a.length){const d=((r=a[1])==null?void 0:r.value)??null,m=((o=a[0])==null?void 0:o.value)??null,y=typeof d=="number"?Oa.format(d):"--",g=typeof m=="number"?Oa.format(m):"--";return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,name:((c=a[1])==null?void 0:c.payload.metricName)??"Metric",value:y}),e(te,{color:i,shape:"square",name:"Count",value:g}),e(Xn,{}),s("div",{css:K`
            display: flex;
            flex-direction: row;
            align-items: center;
            color: var(--ac-global-color-primary);
            gap: var(--px-spacing-sm);

            margin-top: var(--px-spacing-sm);
          `,children:[e(M,{svg:e(hl,{})}),e("span",{children:"Click to view the point cloud at this time"})]})]})}return null}function Cs(n){switch(n.type){case"drift":return"Embedding Drift";case"performance":return"Model Performance";case"dataQuality":return"Data Quality";case"retrieval":return"Query Distance";default:ge()}}function Is(n){if(n)switch(n.type){case"drift":return nn(n.metric);case"performance":return nn(n.metric);case"dataQuality":return`${n.dimension.name} avg`;case"retrieval":return nn(n.metric);default:ge()}else return"Count"}function Ls(n){switch(n.type){case"drift":return ma(n.metric);case"performance":return ma(n.metric);case"dataQuality":return null;case"retrieval":return ma(n.metric);default:ge()}}function Es({embeddingDimensionId:n}){const a=V(v=>v.metric),l=a.type==="drift",t=a.type==="retrieval",i=a.type==="dataQuality",r=a.type==="performance",{timeRange:o}=Pe(),{selectedTimestamp:c,setSelectedTimestamp:d}=Jn(),m=Sn(o),y=_.useLazyLoadQuery(Pl,{embeddingDimensionId:n,timeRange:{start:o.start.toISOString(),end:o.end.toISOString()},metricGranularity:rl(o),countGranularity:m,fetchDrift:l,fetchQueryDistance:t,fetchDataQuality:i,fetchPerformance:r,dimensionId:a.type==="dataQuality"?a.dimension.id:n,performanceMetric:a.type==="performance"?a.metric:"accuracyScore"}),g=vn({samplingIntervalMinutes:m.samplingIntervalMinutes}),p=u.useCallback(v=>{const{activePayload:D}=v;if(D!=null&&D.length>0){const N=D[0].payload;d(new Date(N.timestamp))}},[d]),f=_s({data:y,metric:a}),S=Rs(y).reduce((v,D)=>(v[D.timestamp]=D.value,v),{})??{},h=f.map(v=>{const D=S[v.timestamp];return{...v,traffic:D,timestamp:new Date(v.timestamp).getTime()}}),F=Is(a),L=Ls(a),{color:I,barColor:C}=Ml();return s("section",{css:K`
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        h3 {
          padding: var(--px-spacing-sm) var(--px-spacing-lg) 0
            var(--px-spacing-lg);
          flex: none;
          display: flex;
          flex-direction: row;
          align-items: center;
          gap: var(--px-spacing-sm);
        }
        & > div {
          flex: 1 1 auto;
          width: 100%;
          overflow: hidden;
        }
      `,children:[s(oe,{level:3,children:[Cs(a),L!=null?s(aa,{children:[e(oe,{level:4,children:F}),e(na,{children:L})]}):null]}),e("div",{children:e(Be,{width:"100%",height:"100%",children:s(jn,{data:h,margin:{top:25,right:18,left:18,bottom:10},onClick:p,children:[s("defs",{children:[s("linearGradient",{id:"colorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:I,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:I,stopOpacity:0})]}),s("linearGradient",{id:"barColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:C,stopOpacity:.3}),e("stop",{offset:"95%",stopColor:C,stopOpacity:0})]})]}),e(He,{...Fn,tickFormatter:v=>g(new Date(v)),style:{fill:"var(--ac-global-text-color-700)"}}),e(De,{stroke:le.colors.gray200,label:{value:F,angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(De,{yAxisId:"right",orientation:"right",label:{value:"Count",angle:90,position:"insideRight",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(Ds,{})}),e(kn,{yAxisId:"right",dataKey:"traffic",fill:"url(#barColor)",spacing:5}),e(Pn,{type:"monotone",dataKey:"value",stroke:I,fillOpacity:1,fill:"url(#colorUv)"}),c!=null?e(Fl,{...sl,x:c.getTime()}):null]})})})]})}function _s({data:n,metric:a}){var l,t,i,r,o,c;if(((l=n.embedding.euclideanDistanceTimeSeries)==null?void 0:l.data)!=null&&n.embedding.euclideanDistanceTimeSeries.data.length>0)return n.embedding.euclideanDistanceTimeSeries.data.map(d=>({metricName:nn(a.metric),...d}));if(((t=n.embedding.retrievalMetricTimeSeries)==null?void 0:t.data)!=null&&n.embedding.retrievalMetricTimeSeries.data.length>0)return n.embedding.retrievalMetricTimeSeries.data.map(d=>({metricName:nn(a.metric),...d}));if(n.dimension&&((r=(i=n.dimension)==null?void 0:i.dataQualityTimeSeries)==null?void 0:r.data)!=null&&n.dimension.dataQualityTimeSeries.data.length>0){const d=n.dimension.name||"unknown";return n.dimension.dataQualityTimeSeries.data.map(m=>({metricName:`${d} avg`,...m}))}else{if(n.model&&((o=n.model.performanceTimeSeries)==null?void 0:o.data)!=null&&n.model.performanceTimeSeries.data.length>0)return n.model.performanceTimeSeries.data.map(d=>({metricName:nn(a.metric),...d}));if(((c=n.embedding.trafficTimeSeries)==null?void 0:c.data)!=null)return n.embedding.trafficTimeSeries.data.map(d=>({metricName:"Count",...d}))}return[]}function Rs(n){var a;return((a=n.embedding.trafficTimeSeries)==null?void 0:a.data)!=null?[...n.embedding.trafficTimeSeries.data]:[]}const Nl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"corpusEventIds"},a={defaultValue:null,kind:"LocalArgument",name:"primaryEventIds"},l={defaultValue:null,kind:"LocalArgument",name:"referenceEventIds"},t=[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,concreteType:"DimensionWithValue",kind:"LinkedField",name:"dimensions",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"dimension",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EventMetadata",kind:"LinkedField",name:"eventMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"predictionId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualScore",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PromptResponse",kind:"LinkedField",name:"promptAndResponse",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"prompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"response",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentText",storageKey:null}],i=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"primaryInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"primaryEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"referenceInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"referenceEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"corpusInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"corpusEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"PointSelectionPanelContentQuery",selections:i,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,l,n],kind:"Operation",name:"PointSelectionPanelContentQuery",selections:i},params:{cacheID:"8b48064eba35d0d6c8dc834c2f7795c0",id:null,metadata:{},name:"PointSelectionPanelContentQuery",operationKind:"query",text:`query PointSelectionPanelContentQuery(
  $primaryEventIds: [ID!]!
  $referenceEventIds: [ID!]!
  $corpusEventIds: [ID!]!
) {
  model {
    primaryInferences {
      events(eventIds: $primaryEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
    referenceInferences {
      events(eventIds: $referenceEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
    corpusInferences {
      events(eventIds: $corpusEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
  }
}
`}}}();Nl.hash="4bd627481610322f2acbcf73dfbfaadc";const ja=K`
  margin: var(--px-spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--px-spacing-med);
  & > div {
    display: flex;
    flex-direction: row;
    dt {
      font-weight: bold;
      flex: none;
      width: 130px;
    }
    dd {
      flex: 1 1 auto;
      margin-inline-start: 0;
    }
  }
`;function En(n){return e("div",{css:K`
        max-height: 200px;
        overflow-y: auto;
      `,children:e("pre",{css:K`
          padding: var(--px-spacing-lg);
          color: var(--ac-global-text-color-900);
          white-space: normal;
          margin: 0;
        `,children:n.children})})}function ws({event:n}){const a=n.retrievedDocuments&&n.retrievedDocuments.length>0,l=!n.id.includes("CORPUS");return s("section",{css:K`
        height: 100%;
        overflow-y: auto;
      `,children:[e(As,{event:n}),s(hn,{children:[l?e(me,{id:"prediction",title:"Prediction Details",children:s("dl",{css:ja,children:[n.predictionId!=null&&s("div",{children:[e("dt",{children:"Prediction ID"}),e("dd",{css:K`
                      display: flex;
                      align-items: center;
                    `,children:n.predictionId})]}),n.predictionLabel!=null&&s("div",{children:[e("dt",{children:"Prediction Label"}),e("dd",{children:n.predictionLabel})]}),n.predictionScore!=null&&s("div",{children:[e("dt",{children:"Prediction Score"}),e("dd",{children:n.predictionScore})]}),n.actualLabel!=null&&s("div",{children:[e("dt",{children:"Actual Label"}),e("dd",{children:n.actualLabel})]}),n.actualScore!=null&&s("div",{children:[e("dt",{children:"Actual Score"}),e("dd",{children:n.actualScore})]})]})}):e(me,{id:"document",title:"Document Details",children:e("dl",{css:ja,children:n.predictionId!=null&&s("div",{children:[e("dt",{children:"Document ID"}),e("dd",{css:K`
                      display: flex;
                      align-items: center;
                    `,children:n.predictionId})]})})}),e(me,{id:"dimensions",title:"Dimensions",children:e(Ms,{dimensions:n.dimensions})}),a&&e(me,{id:"retrievals",title:"Retrieved Documents",titleExtra:e(Ae,{variant:"light",children:n.retrievedDocuments.length}),children:e("ul",{css:K`
                padding: var(--px-spacing-med);
                li + li {
                  margin-top: var(--px-spacing-med);
                }
              `,children:n.retrievedDocuments.map(t=>e("li",{children:e(Ps,{document:t})},t.id))})})]})]})}function Ps({document:n}){return e(T,{borderRadius:"medium",backgroundColor:"light",children:s(b,{direction:"column",children:[e(T,{width:"100%",borderBottomWidth:"thin",borderBottomColor:"dark",children:s(b,{direction:"row",justifyContent:"space-between",margin:"size-100",alignItems:"center",children:[s(b,{direction:"row",gap:"size-50",alignItems:"center",children:[e(M,{svg:e(P.FileOutline,{})}),s(oe,{level:4,children:["document ",n.id]})]}),typeof n.relevance=="number"&&e(Ze,{color:"blue",children:`relevance ${Ta(n.relevance)}`})]})}),e("pre",{css:K`
            padding: var(--px-spacing-lg);
            white-space: normal;
            margin: 0;
          `,children:n.text})]})})}function Ms({dimensions:n}){const a=u.useMemo(()=>n.map(i=>({name:i.dimension.name,type:i.dimension.type,value:i.value??"--"})),[n]),l=u.useMemo(()=>[{header:()=>"Name",accessorKey:"name"},{header:()=>"Type",accessorKey:"type"},{header:()=>"Value",accessorKey:"value"}],[]),t=be({columns:l,data:a,getCoreRowModel:Se()});return s("table",{css:Vn,children:[e("thead",{children:t.getHeaderGroups().map(i=>e("tr",{children:i.headers.map(r=>e("th",{colSpan:r.colSpan,children:r.isPlaceholder?null:e("div",{children:J(r.column.columnDef.header,r.getContext())})},r.id))},i.id))}),t.getCoreRowModel().rows.length?e("tbody",{children:t.getRowModel().rows.map(i=>e("tr",{children:i.getVisibleCells().map(r=>e("td",{children:J(r.column.columnDef.cell,r.getContext())},r.id))},i.id))}):e($s,{})]})}function Ns({dataUrl:n}){const a=dr(n),l=cr(n);return a?e("video",{src:n,controls:!0,css:K`
          width: 100%;
          height: 500px;
          background-color: black;
        `}):l?e("audio",{src:n,controls:!0,autoPlay:!0}):e("img",{src:n,alt:"event image",width:"100%",height:"200px",css:K`
        object-fit: contain;
        background-color: black;
      `})}function As({event:n}){const a=n.linkToData||void 0,l=n.rawData,t=n.prompt||n.response?{prompt:n.prompt,response:n.response}:null,i=n.documentText;let r=null;return a?r=s(b,{direction:"column",children:[e(Ns,{dataUrl:a}),l&&e(hn,{children:e(me,{id:"raw",title:"Raw Data",children:e(En,{children:l})})})]}):i?r=e(hn,{children:e(me,{id:"document",title:"Document",children:e(En,{children:i})})}):t?r=s(hn,{children:[e(me,{id:"prompt",title:"Prompt",children:e(En,{children:t.prompt})}),e(me,{id:"response",title:"Response",children:e(En,{children:t.response})})]}):n.rawData&&n.rawData&&n.rawData,r}function $s(){return e("tbody",{className:"is-empty",children:e("tr",{children:e("td",{colSpan:100,css:n=>K`
            text-align: center;
            padding: ${n.spacing.margin24}px ${n.spacing.margin24}px !important;
          `,children:e(ol,{graphicKey:"documents",message:"This embedding has no associated dimensions"})})})})}const Al=function(){var n=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"ExportedFile",kind:"LinkedField",name:"exportedFiles",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ExportSelectionButtonExportsQuery",selections:n,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"ExportSelectionButtonExportsQuery",selections:n},params:{cacheID:"2f7e3554305121746dc799b6a8d120da",id:null,metadata:{},name:"ExportSelectionButtonExportsQuery",operationKind:"query",text:`query ExportSelectionButtonExportsQuery {
  model {
    exportedFiles {
      fileName
    }
  }
}
`}}}();Al.hash="7e6db431afe21f137e54505645c787f4";const $l=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"eventIds"}],a=[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"eventIds"}],concreteType:"ExportedFile",kind:"LinkedField",name:"exportEvents",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExportSelectionButtonMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExportSelectionButtonMutation",selections:a},params:{cacheID:"d370df04ca30a5059288c7aa298239a8",id:null,metadata:{},name:"ExportSelectionButtonMutation",operationKind:"mutation",text:`mutation ExportSelectionButtonMutation(
  $eventIds: [ID!]!
) {
  exportEvents(eventIds: $eventIds) {
    fileName
  }
}
`}}}();$l.hash="8b0d6962e2034d4c148d1b9919111d2f";const Vs=`import phoenix as px

exports = px.active_session().exports
dataframe = exports[-1]
dataframe`,zs=K`
  .cm-content {
    padding: var(--ac-global-dimension-static-size-100);
  }
`;function Qs({value:n}){const{theme:a}=$n(),l=a==="light"?void 0:sa;return e(ra,{value:n,basicSetup:!1,extensions:[Ma()],editable:!1,theme:l,css:zs})}function Os(){const n=V(o=>o.selectedEventIds),[a,l]=_.useMutation($l),[t,i]=u.useState(null),r=u.useCallback(()=>{a({variables:{eventIds:[...n]},onCompleted:o=>{i(o.exportEvents)}})},[a,n]);return s(B,{children:[e(z,{variant:"default",size:"compact",icon:e(M,{svg:e(kl,{})}),"aria-label":"Export selection / cluster",loading:l,onClick:r,children:l?"Exporting":"Export"}),e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>i(null),children:t!=null&&s(G,{title:"Cluster Exports",size:"M",children:[e(ne,{variant:"success",banner:!0,title:"Export succeeded",extra:e(z,{variant:"success",size:"compact",onClick:()=>{window.open(`/exports?filename=${t.fileName}`,"_self")},children:"Download"})}),s("div",{css:K`
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                align-items: flex-start;
                padding: 16px;
                gap: 16px;
              `,children:[e("p",{css:K`
                  margin: 0;
                  flex: 1 1 auto;
                `,children:"You can retrieve your export in your notebook via"}),e(T,{borderColor:"light",borderWidth:"thin",borderRadius:"medium",children:e(Qs,{value:Vs})})]}),e(hn,{children:e(me,{id:"all-exports",title:"Latest Exports",children:e(u.Suspense,{fallback:e(ue,{}),children:e(js,{})})})})]})})]})}function js(){const n=_.useLazyLoadQuery(Al,{},{fetchPolicy:"network-only"});return e(Sl,{children:n.model.exportedFiles.map((a,l)=>e(bl,{children:s("div",{css:K`
              display: flex;
              flex-direction: row;
              justify-content: space-between;
              align-items: center;
            `,children:[a.fileName,e(z,{size:"compact","aria-label":"Download",variant:"default",icon:e(M,{svg:e(kl,{})}),onClick:()=>{window.open(`/exports?filename=${a.fileName}`,"_self")}})]})},l))})}function qs(n){const{getInferencesNameByRole:a}=Ie(),{events:l,onItemSelected:t}=n,i=V(m=>m.eventIdToDataMap),r=V(m=>m.eventIdToGroup),o=V(m=>m.pointGroupColors),c=V(m=>m.selectionGridSize),d=V(m=>m.setHoveredEventId);return e("div",{css:K`
        flex: 1 1 auto;
        overflow-y: auto;
      `,"data-testid":"grid-view-scroll-container",children:e("ul",{"data-grid-size":c,css:K`
          &[data-grid-size="small"] {
            --grid-item-min-width: 100px;
            --grid-item-height: 100px;
          }
          &[data-grid-size="medium"] {
            --grid-item-min-width: 200px;
            --grid-item-height: 200px;
          }
          &[data-grid-size="large"] {
            --grid-item-min-width: 300px;
            --grid-item-height: 200px;
          }
          padding: var(--px-spacing-lg);
          transition: all 0.2s ease-in-out;
          display: grid;
          grid-template-columns: repeat(
            auto-fill,
            minmax(var(--grid-item-min-width), 1fr)
          );
          flex-wrap: wrap;
          gap: var(--px-spacing-lg);
          & > li {
            min-width: var(--grid-item-min-width);
            height: var(--grid-item-height);
          }
        `,children:l.map((m,y)=>{const g=i.get(m.id),{rawData:p=null,linkToData:f=null}=(g==null?void 0:g.embeddingMetadata)??{},{predictionLabel:k=null,actualLabel:S=null}=(g==null?void 0:g.eventMetadata)??{},h=ur(m.id),F=a(h),L=r[m.id],I=o[L];return e("li",{children:e(mr,{rawData:p,linkToData:f,inferencesName:F,group:L,onClick:()=>{t(m.id)},onMouseOver:()=>{d(m.id)},onMouseOut:()=>{d(null)},color:I,size:c,predictionLabel:k,actualLabel:S,promptAndResponse:m.promptAndResponse,documentText:m.documentText,autoPlay:!1})},y)})})})}function Bs({data:n,onPointSelected:a}){const{primaryInferences:l,referenceInferences:t}=Ie(),i=V(y=>y.metric),[r,o]=u.useState([]),{columns:c,tableData:d}=u.useMemo(()=>{const y=n.filter(I=>I.id.includes("CORPUS")===!1);let g=!1,p=!1,f=!1,k=!1,S=!1;n.forEach(I=>{I.linkToData&&(g=!0),I.rawData&&(p=!0),(I.prompt||I.response)&&(f=!0),I.predictionLabel&&(k=!0),I.actualLabel&&(S=!0)});const h=[];t&&h.push({header:"Inference Set",accessorKey:"id",size:50,cell:({getValue:I})=>e(Hs,{id:I(),primaryInferencesName:l.name,referenceInferencesName:(t==null?void 0:t.name)??"reference"})}),g&&h.push({header:"Link",accessorKey:"linkToData",cell:({getValue:I})=>{const C=I();if(typeof C=="string"){const v=C.split("/").pop();return e(Rn,{href:C,children:v})}return null}}),f?(h.push({header:"Prompt",accessorKey:"prompt",cell:xe,size:200}),h.push({header:"Response",accessorKey:"response",cell:xe,size:200})):p&&h.push({header:"Raw Data",accessorKey:"rawData"}),k&&h.push({header:"Prediction Label",accessorKey:"predictionLabel",size:50}),S&&h.push({header:"Actual Label",accessorKey:"actualLabel",size:50});const F=[];if(i&&i.type==="dataQuality"){const I=i.dimension.name;F.push({header:i.dimension.name,accessorKey:"metric",cell:gr,sortingFn:"basic"}),y.forEach(C=>{var D;const v=(D=C.dimensions.find(N=>N.dimension.name===I))==null?void 0:D.value;C.metric=v!=null?Number(v):null})}return{columns:[...h,...F,{header:"",id:"view-details",size:50,cell:({row:I})=>e(pr,{"aria-label":"view point details",onClick:()=>{a(I.original.id)},children:"view details"})}],tableData:y}},[n,a,l,t,i]),m=be({columns:c,data:d,state:{sorting:r},getCoreRowModel:Se(),onSortingChange:o,getSortedRowModel:Nn()});return s("table",{css:Vn,children:[e("thead",{children:m.getHeaderGroups().map(y=>e("tr",{children:y.headers.map(g=>s("th",{children:[g.isPlaceholder?null:s("div",{className:g.column.getCanSort()?"cursor-pointer":"",onClick:g.column.getToggleSortingHandler(),children:[J(g.column.columnDef.header,g.getContext()),g.column.getIsSorted()?e(M,{className:"sort-icon",svg:g.column.getIsSorted()==="asc"?e(P.ArrowDownFilled,{}):e(P.ArrowUpFilled,{})}):null]}),e("div",{onMouseDown:g.getResizeHandler(),onTouchStart:g.getResizeHandler(),className:`resizer ${g.column.getIsResizing()?"isResizing":""}`,style:{transform:g.column.getIsResizing()?`translateX(${m.getState().columnSizingInfo.deltaOffset}px)`:""}})]},g.id))},y.id))}),e("tbody",{children:m.getRowModel().rows.map(y=>e("tr",{children:y.getVisibleCells().map(g=>e("td",{style:{width:g.column.getSize()},children:J(g.column.columnDef.cell,g.getContext())},g.id))},y.id))})]})}function Hs({id:n,primaryInferencesName:a,referenceInferencesName:l}){const t=n.includes("PRIMARY"),i=ks();return s(b,{direction:"row",gap:"size-100",alignItems:"center",children:[e(fr,{shape:yr.circle,color:i[t?0:1]}),t?a:l]})}const Gs=K`
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Give spacing for the close icon */
  & > .ac-tabs {
    padding-top: 17px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    [role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      overflow: hidden;
      [role="tabpanel"] {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        overflow: hidden;
      }
    }
  }
`;function Ws({event:n,relevance:a}){return{id:n.eventMetadata.predictionId||"unknown id",text:n.documentText??"empty document",relevance:a}}function Us(){const n=V(v=>v.selectedEventIds),a=V(v=>v.setSelectedEventIds),l=V(v=>v.setSelectedClusterId),t=V(v=>v.selectionDisplay),[i,r]=ke.useState(null),{primaryEventIds:o,referenceEventIds:c,corpusEventIds:d}=u.useMemo(()=>{const v=[],D=[],N=[];return n.forEach(R=>{R.includes("PRIMARY")?v.push(R):R.includes("CORPUS")?N.push(R):D.push(R)}),{primaryEventIds:v,referenceEventIds:D,corpusEventIds:N}},[n]),m=_.useLazyLoadQuery(Nl,{primaryEventIds:[...o],referenceEventIds:[...c],corpusEventIds:[...d]}),y=u.useMemo(()=>{var R,O,j,X,ie,re;const v=((O=(R=m.model)==null?void 0:R.primaryInferences)==null?void 0:O.events)??[],D=((X=(j=m.model)==null?void 0:j.referenceInferences)==null?void 0:X.events)??[],N=((re=(ie=m.model)==null?void 0:ie.corpusInferences)==null?void 0:re.events)??[];return[...v,...D,...N]},[m]),g=()=>{a(new Set),l(null)},p=V(v=>v.eventIdToDataMap),f=V(v=>v.pointData),k=V(v=>v.selectionSearchText),S=u.useMemo(()=>y.map(v=>{var R,O,j,X,ie,re,w;const D=p.get(v.id),N=[];return f!=null&&(D==null?void 0:D.retrievals)!=null&&D.retrievals.forEach(({documentId:A,relevance:E})=>{const $=f[A];$!=null&&N.push(Ws({event:$,relevance:E}))}),{id:v.id,predictionId:((R=v.eventMetadata)==null?void 0:R.predictionId)??null,actualLabel:((O=v.eventMetadata)==null?void 0:O.actualLabel)??null,actualScore:((j=v.eventMetadata)==null?void 0:j.actualScore)??null,predictionLabel:((X=v.eventMetadata)==null?void 0:X.predictionLabel)??null,predictionScore:((ie=v.eventMetadata)==null?void 0:ie.predictionScore)??null,rawData:(D==null?void 0:D.embeddingMetadata.rawData)??null,linkToData:(D==null?void 0:D.embeddingMetadata.linkToData)??null,dimensions:v.dimensions,prompt:((re=v.promptAndResponse)==null?void 0:re.prompt)??null,response:((w=v.promptAndResponse)==null?void 0:w.response)??null,retrievedDocuments:N,documentText:v.documentText??null}}),[y,p,f]),h=u.useMemo(()=>{if(k){const v=k.toLowerCase();return S.filter(D=>{var N,R,O,j;return D.id.includes(v)||((N=D.documentText)==null?void 0:N.toLowerCase().includes(v))||((R=D.predictionId)==null?void 0:R.includes(v))||((O=D.prompt)==null?void 0:O.toLowerCase().includes(v))||((j=D.response)==null?void 0:j.toLowerCase().includes(v))})}return S},[S,k]),F=u.useMemo(()=>{if(k){const v=k.toLowerCase();return y.filter(D=>{var N,R,O,j,X,ie,re;return D.id.includes(v)||((N=D.documentText)==null?void 0:N.toLowerCase().includes(v))||((O=(R=D.eventMetadata)==null?void 0:R.predictionId)==null?void 0:O.includes(v))||((X=(j=D.promptAndResponse)==null?void 0:j.prompt)==null?void 0:X.toLowerCase().includes(v))||((re=(ie=D.promptAndResponse)==null?void 0:ie.response)==null?void 0:re.toLowerCase().includes(v))})}return y},[y,k]),L=u.useMemo(()=>i?S.find(D=>D.id===i)??null:null,[S,i]),I=y.length,C=F.length;return s("section",{css:Gs,children:[s("div",{role:"toolbar",css:K`
          position: absolute;
          top: var(--px-spacing-med);
          right: var(--px-spacing-lg);
          display: flex;
          flex-direction: row-reverse;
          gap: var(--px-spacing-med);
        `,children:[e(z,{variant:"default",size:"compact",icon:e(M,{svg:e(as,{})}),"aria-label":"Clear selection",onClick:g}),e(Os,{})]}),e(he,{children:s(q,{name:"Selection",children:[e(Js,{numSelectedEvents:I,numMatchingEvents:C,searchText:k}),t===dl.list?e("div",{css:K`
                flex: 1 1 auto;
                overflow-y: auto;
              `,children:e(Bs,{data:h,onPointSelected:r})}):e(qs,{events:F,onItemSelected:r})]})}),e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>r(null),children:L&&e(G,{title:"Embedding Details",size:"L",children:e(ws,{event:L})})})]})}function Js({numSelectedEvents:n,numMatchingEvents:a,searchText:l}){const t=V(m=>m.selectionDisplay),i=V(m=>m.setSelectionDisplay),r=V(m=>m.selectionGridSize),o=V(m=>m.setSelectionGridSize),c=V(m=>m.setSelectionSearchText),d=u.useMemo(()=>l?`${a}/${n} match "${l}"`:`${n} selected`,[n,a,l]);return e(xa,{extra:s("div",{css:K`
            display: flex;
            flex-direction: row;
            gap: var(--px-spacing-med);
          `,children:[e(ls,{placeholder:"Search by text or ID",onChange:m=>{c(m)}}),t===dl.gallery&&e(hr,{size:r,onChange:o}),e(kr,{mode:t,onChange:m=>{i(m)}})]}),children:e(x,{children:d})})}const Vl=El;function gu(){const{referenceInferences:n,corpusInferences:a}=Ie(),{timeRange:l}=Pe(),t=u.useMemo(()=>{let i={};return a!=null?i=vr():n!=null?i=Fr():i=Kr(),i={...i,umapParameters:{...window.Config.UMAP}},i},[a,n]);return e(cl,{initialTimestamp:l.end,children:e(xr,{...t,children:e(Xs,{})})})}function Xs(){const n=bs(),{primaryInferences:a,referenceInferences:l}=Ie(),t=V(F=>F.umapParameters),i=V(F=>F.getHDSCANParameters),r=V(F=>F.getMetric),o=V(F=>F.reset),c=V(F=>F.setLoading),[d,m]=u.useState(!0),[y,g,p]=_.useQueryLoader(Vl),{selectedTimestamp:f}=Jn(),k=u.useMemo(()=>f??new Date(a.endTime),[f,a.endTime]),S=u.useMemo(()=>({start:el(k,2).toISOString(),end:k.toISOString()}),[k]),h=_.useLazyLoadQuery(Ll,{});return u.useEffect(()=>{o(),c(!0);const F=r();return g({id:n,timeRange:S,...t,...i(),fetchDataQualityMetric:F.type==="dataQuality",fetchPerformanceMetric:F.type==="performance",dataQualityMetricColumnName:F.type==="dataQuality"?F.dimension.name:null,performanceMetric:F.type==="performance"?F.metric:"accuracyScore"},{fetchPolicy:"network-only"}),()=>{p()}},[c,o,n,g,p,t,i,r,S]),s("main",{css:K`
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      `,children:[e(io,{}),s(xa,{extra:s(b,{direction:"row",justifyContent:"center",alignItems:"center",gap:"size-100",children:[e(ea,{onChange:F=>{m(F)},defaultSelected:!0,labelPlacement:"start",children:"Show Timeseries"}),e(vs,{})]}),children:[e(ll,{}),l?e(tl,{inferencesRole:"reference",timeRange:{start:new Date(l.startTime),end:new Date(l.endTime)}}):null,e(Ts,{model:h.model})]}),s(an,{direction:"vertical",children:[d?s(B,{children:[e(se,{defaultSize:20,collapsible:!0,order:1,children:e(u.Suspense,{fallback:e(ue,{}),children:e(Es,{embeddingDimensionId:n})})}),e(ln,{css:Kn})]}):null,e(se,{order:2,children:e("div",{css:K`
              width: 100%;
              height: 100%;
              position: relative;
            `,children:e(u.Suspense,{fallback:e(Tr,{}),children:y?e(Zs,{queryReference:y}):null})})})]})]})}function Ys(n){if(n.__typename!=="Point3D")throw new Error(`Expected Point3D but got ${n.__typename} for coordinates`);return[n.x,n.y,n.z]}function Zs({queryReference:n}){const a=_.usePreloadedQuery(Vl,n),l=u.useMemo(()=>{var m,y;return((y=(m=a.embedding)==null?void 0:m.UMAPPoints)==null?void 0:y.data)??[]},[a]),t=u.useMemo(()=>{var m,y;return((y=(m=a.embedding)==null?void 0:m.UMAPPoints)==null?void 0:y.referenceData)??[]},[a]),i=u.useMemo(()=>{var m,y;return((y=(m=a.embedding)==null?void 0:m.UMAPPoints)==null?void 0:y.corpusData)??[]},[a]),r=u.useMemo(()=>{var m,y;return((y=(m=a.embedding)==null?void 0:m.UMAPPoints)==null?void 0:y.contextRetrievals)??[]},[a]),o=u.useMemo(()=>[...l,...t,...i].map(y=>({...y,position:Ys(y.coordinates),metaData:{id:y.eventId}})),[t,l,i]),c=V(m=>m.setInitialData),d=V(m=>m.setClusters);return Ji(()=>{var y,g;const m=((g=(y=a.embedding)==null?void 0:y.UMAPPoints)==null?void 0:g.clusters)||[];c({points:o,clusters:m,retrievals:r})},[o,n,r,c,d]),e("div",{css:K`
        flex: 1 1 auto;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        width: 100%;
        height: 100%;
      `,"data-testid":"point-cloud-display",children:s(an,{direction:"horizontal",children:[e(se,{id:"embedding-left",defaultSize:15,maxSize:30,minSize:10,collapsible:!0,children:s(an,{autoSaveId:"embedding-controls-vertical",direction:"vertical",children:[e(se,{css:K`
                display: flex;
                flex-direction: column;
                .ac-tabs {
                  height: 100%;
                  overflow: hidden;
                  display: flex;
                  flex-direction: column;
                  [role="tablist"] {
                    flex: none;
                  }
                  .ac-tabs__pane-container {
                    flex: 1 1 auto;
                    overflow: hidden;
                    display: flex;
                    flex-direction: column;
                    & > div {
                      height: 100%;
                    }
                  }
                }
              `,children:e(lo,{})}),e(ln,{css:Kn}),e(se,{css:K`
                .ac-tabs {
                  height: 100%;
                  overflow: hidden;
                  .ac-tabs__pane-container {
                    height: 100%;
                    overflow-y: auto;
                  }
                }
              `,children:s(he,{children:[e(q,{name:"Display",children:e(Dr,{})}),e(q,{name:"Hyperparameters",children:e(Cr,{})})]})})]})}),e(ln,{css:Ir}),e(se,{children:s("div",{css:K`
              position: relative;
              width: 100%;
              height: 100%;
            `,children:[e(eo,{}),e(Lr,{})]})})]})})}function eo(){return V(a=>a.selectedEventIds).size===0?null:e("div",{css:K`
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
      `,"data-testid":"selection-panel",children:s(an,{direction:"vertical",children:[e(se,{}),e(ln,{css:Kn,style:{zIndex:1}}),e(se,{id:"embedding-point-selection",defaultSize:40,minSize:20,order:2,style:{zIndex:1},children:e(no,{children:e(u.Suspense,{fallback:e(ue,{}),children:e(Us,{})})})})]})})}function no(n){return e("div",{css:K`
        background-color: var(--ac-global-color-grey-75);
        width: 100%;
        height: 100%;
      `,children:n.children})}const ao=1,lo=ke.memo(function(){const{referenceInferences:a}=Ie(),l=V(g=>g.clusters),t=V(g=>g.selectedClusterId),i=V(g=>g.metric),r=V(g=>g.setSelectedClusterId),o=V(g=>g.setSelectedEventIds),c=V(g=>g.setHighlightedClusterId),d=V(g=>g.setClusterColorMode),m=a==null||i.type==="drift",y=u.useCallback(g=>{d(g===ao?za.highlight:za.default)},[d]);return s(he,{onChange:y,children:[e(q,{name:"Clusters",extra:e(Ae,{children:l.length}),children:s(b,{direction:"column",height:"100%",children:[e(T,{borderBottomColor:"dark",borderBottomWidth:"thin",backgroundColor:"dark",flex:"none",padding:"size-50",children:e(b,{direction:"row",justifyContent:"end",children:e(Ss,{})})}),e(T,{flex:"1 1 auto",overflow:"auto",children:e("ul",{css:g=>K`
                flex: 1 1 auto;
                display: flex;
                flex-direction: column;
                gap: ${g.spacing.margin8}px;
                margin: ${g.spacing.margin8}px;
              `,children:l.map(g=>e("li",{children:e(br,{clusterId:g.id,numPoints:g.eventIds.length,isSelected:t===g.id,driftRatio:g.driftRatio,primaryToCorpusRatio:g.primaryToCorpusRatio,primaryMetricValue:g.primaryMetricValue,referenceMetricValue:g.referenceMetricValue,metricName:to(i),hideReference:m,onClick:()=>{t!==g.id?(r(g.id),o(new Set(g.eventIds))):(r(null),o(new Set))},onMouseEnter:()=>{c(g.id)},onMouseLeave:()=>{c(null)}})},g.id))})})]})}),e(q,{name:"Configuration",children:e(T,{overflow:"auto",height:"100%",children:e(Sr,{})})})]})});function to(n){const{type:a,metric:l}=n;switch(a){case"dataQuality":return`${n.dimension.name} avg`;case"drift":{switch(l){case"euclideanDistance":return"Cluster Drift";default:ge()}break}case"performance":return nn(l);case"retrieval":{switch(l){case"queryDistance":return"% Query";default:ge()}break}default:ge()}}function io(){const{notifyError:n}=il(),a=V(t=>t.errorMessage),l=V(t=>t.setErrorMessage);return u.useEffect(()=>{a!==null&&n({title:"An error occurred",message:a,action:{text:"Dismiss",onClick:()=>{l(null)}}})},[a,n,l]),null}const zl=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"embeddingLoaderQuery",selections:[{alias:"embedding",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,t],type:"EmbeddingDimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"embeddingLoaderQuery",selections:[{alias:"embedding",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[t],type:"EmbeddingDimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"cff0ac130f1ef79784f7bef4161ac60d",id:null,metadata:{},name:"embeddingLoaderQuery",operationKind:"query",text:`query embeddingLoaderQuery(
  $id: GlobalID!
) {
  embedding: node(id: $id) {
    __typename
    ... on EmbeddingDimension {
      id
      name
    }
    __isNode: __typename
    id
  }
}
`}}}();zl.hash="c049e57d92943f64b5e751e0daa89dc8";async function pu(n){const{embeddingDimensionId:a}=n.params;return _.fetchQuery(Ce,zl,{id:a}).toPromise()}const Ql=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"hasReference"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"Variable",name:"timeRange",variableName:"timeRange"},o=[r],c=[{kind:"Variable",name:"hasReference",variableName:"hasReference"},r],d={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},m=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null}],y={kind:"Literal",name:"metric",value:"cardinality"},g={kind:"Literal",name:"metric",value:"percentEmpty"},p={kind:"Literal",name:"inferencesRole",value:"reference"};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionPageQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[i,{args:o,kind:"FragmentSpread",name:"DimensionSegmentsBarChart_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionCountStats_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionDriftStats_dimension"},{args:c,kind:"FragmentSpread",name:"DimensionCardinalityStats_dimension"},{args:c,kind:"FragmentSpread",name:"DimensionPercentEmptyStats_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionQuantilesStats_dimension"}],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionPageQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[d,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[d,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null}],type:"IntervalBin",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:m,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:m,storageKey:null}],storageKey:null},{alias:"count",args:[{kind:"Literal",name:"metric",value:"count"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},r],kind:"ScalarField",name:"driftMetric",storageKey:null},{alias:"cardinality",args:[y,r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"percentEmpty",args:[g,r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p99",args:[{kind:"Literal",name:"metric",value:"p99"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p75",args:[{kind:"Literal",name:"metric",value:"p75"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p50",args:[{kind:"Literal",name:"metric",value:"p50"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p25",args:[{kind:"Literal",name:"metric",value:"p25"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p1",args:[{kind:"Literal",name:"metric",value:"p01"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referenceCardinality",args:[p,y],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"cardinality")'},{alias:"referencePercentEmpty",args:[p,g],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"percentEmpty")'}]}],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"2ad937e56d4647309b9d78ac11f57265",id:null,metadata:{},name:"DimensionPageQuery",operationKind:"query",text:`query DimensionPageQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $hasReference: Boolean!
) {
  dimension: node(id: $dimensionId) {
    __typename
    ... on Dimension {
      id
      ...DimensionSegmentsBarChart_dimension_3E0ZE6
      ...DimensionCountStats_dimension_3E0ZE6
      ...DimensionDriftStats_dimension_3E0ZE6
      ...DimensionCardinalityStats_dimension_1JBzL3
      ...DimensionPercentEmptyStats_dimension_1JBzL3
      ...DimensionQuantilesStats_dimension_3E0ZE6
    }
    __isNode: __typename
    id
  }
}

fragment DimensionCardinalityStats_dimension_1JBzL3 on Dimension {
  id
  cardinality: dataQualityMetric(metric: cardinality, timeRange: $timeRange)
  referenceCardinality: dataQualityMetric(metric: cardinality, inferencesRole: reference) @include(if: $hasReference)
}

fragment DimensionCountStats_dimension_3E0ZE6 on Dimension {
  id
  count: dataQualityMetric(metric: count, timeRange: $timeRange)
}

fragment DimensionDriftStats_dimension_3E0ZE6 on Dimension {
  id
  psi: driftMetric(metric: psi, timeRange: $timeRange)
}

fragment DimensionPercentEmptyStats_dimension_1JBzL3 on Dimension {
  id
  percentEmpty: dataQualityMetric(metric: percentEmpty, timeRange: $timeRange)
  referencePercentEmpty: dataQualityMetric(metric: percentEmpty, inferencesRole: reference) @include(if: $hasReference)
}

fragment DimensionQuantilesStats_dimension_3E0ZE6 on Dimension {
  p99: dataQualityMetric(metric: p99, timeRange: $timeRange)
  p75: dataQualityMetric(metric: p75, timeRange: $timeRange)
  p50: dataQualityMetric(metric: p50, timeRange: $timeRange)
  p25: dataQualityMetric(metric: p25, timeRange: $timeRange)
  p1: dataQualityMetric(metric: p01, timeRange: $timeRange)
}

fragment DimensionSegmentsBarChart_dimension_3E0ZE6 on Dimension {
  id
  segmentsComparison(primaryTimeRange: $timeRange) {
    segments {
      bin {
        __typename
        ... on NominalBin {
          __typename
          name
        }
        ... on IntervalBin {
          __typename
          range {
            start
            end
          }
        }
        ... on MissingValueBin {
          __typename
        }
      }
      counts {
        primaryValue
      }
    }
    totalCounts {
      primaryValue
    }
  }
}
`}}}();Ql.hash="d194bfd656408e8ba7cb427ddc80fc85";const Ol=function(){var n={kind:"Literal",name:"metric",value:"cardinality"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"hasReference"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionCardinalityStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"cardinality",args:[n,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referenceCardinality",args:[{kind:"Literal",name:"inferencesRole",value:"reference"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"cardinality")'}]}],type:"Dimension",abstractKey:null}}();Ol.hash="8b4edef350e4df49e799afa70ca34918";function ro(n){const a=_.useFragment(Ol,n.dimension);return s(B,{children:[e(x,{elementType:"h3",textSize:"small",color:"text-700",children:"Cardinality"}),e(x,{textSize:"xlarge",children:tn(a.cardinality)}),a.referenceCardinality!=null&&e(x,{textSize:"medium",color:"designationPurple",children:tn(a.referenceCardinality)})]})}const jl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"cardinalityTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"granularity"},{kind:"Literal",name:"metric",value:"cardinality"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionCardinalityTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionCardinalityTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"f53e5ac5e0bfd6a0a6c50b761223a617",id:null,metadata:{},name:"DimensionCardinalityTimeSeriesQuery",operationKind:"query",text:`query DimensionCardinalityTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      cardinalityTimeSeries: dataQualityTimeSeries(metric: cardinality, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();jl.hash="88ce04bb2022d5e2bc75c663abd7e5de";const qn={top:25,right:18,left:18,bottom:5},so=new Intl.NumberFormat([],{maximumFractionDigits:2}),ql=()=>{const{gray300:n}=Me();return{color:n}};function oo({active:n,payload:a,label:l}){var i;const{color:t}=ql();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?so.format(r):"--";return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,name:"Cardinality",value:o}),e(Xn,{})]})}return null}function co({dimensionId:n}){var c;const{timeRange:a}=Pe(),l=Sn(a),t=_.useLazyLoadQuery(jl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}),{color:i}=ql(),r=((c=t.dimension.cardinalityTimeSeries)==null?void 0:c.data.map(d=>({timestamp:new Date(d.timestamp).valueOf(),value:d.value})))||[],o=vn({samplingIntervalMinutes:l.samplingIntervalMinutes});return e(Be,{width:"100%",height:"100%",children:s(jn,{data:r,margin:qn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"cardinalityColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:i,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:i,stopOpacity:0})]})}),e(He,{...Fn,tickFormatter:d=>o(new Date(d))}),e(De,{stroke:le.colors.gray200,label:{value:"Cardinality",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(oo,{})}),e(Pn,{type:"monotone",dataKey:"value",stroke:i,fillOpacity:1,fill:"url(#cardinalityColorUv)"})]})})}const Bl={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionCountStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"count",args:[{kind:"Literal",name:"metric",value:"count"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null}],type:"Dimension",abstractKey:null};Bl.hash="6dccac51f3fb0853276677c692af5a43";function uo(n){const l=_.useFragment(Bl,n.dimension).count??0;return s(B,{children:[e(x,{elementType:"h3",textSize:"small",color:"text-700",children:"Total Count"}),e(x,{textSize:"xlarge",children:tn(l)})]})}const Hl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionCountTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,l,n],kind:"Operation",name:"DimensionCountTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"1f9eff6d8d453148844edae32b844df7",id:null,metadata:{},name:"DimensionCountTimeSeriesQuery",operationKind:"query",text:`query DimensionCountTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $countGranularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Hl.hash="9677ef7c6b298554824fe3fd3904c7aa";const mo=new Intl.NumberFormat([],{maximumFractionDigits:2}),Gl=()=>{const{gray300:n}=Me();return{barColor:n}};function go({active:n,payload:a,label:l}){var i;const{barColor:t}=Gl();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?mo.format(r):"--";return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,shape:"square",name:"Count",value:o})]})}return null}function po({dimensionId:n}){var d;const{timeRange:a}=Pe(),l=Sn(a),r=(((d=_.useLazyLoadQuery(Hl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},countGranularity:l}).embedding.trafficTimeSeries)==null?void 0:d.data)||[]).map(m=>({...m,timestamp:new Date(m.timestamp).valueOf()})),o=vn({samplingIntervalMinutes:l.samplingIntervalMinutes}),{barColor:c}=Gl();return e(Be,{width:"100%",height:"100%",children:s(Pa,{data:r,margin:qn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"countBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:c,stopOpacity:1}),e("stop",{offset:"95%",stopColor:c,stopOpacity:.5})]})}),e(He,{...Fn,tickFormatter:m=>o(new Date(m))}),e(De,{stroke:le.colors.gray200,label:{value:"Count",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Da,content:e(go,{})}),e(kn,{dataKey:"value",fill:"url(#countBarColor)",spacing:5})]})})}const Wl=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"dimensionId"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"dimensionId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t=[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],i={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},o={alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null},c=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"referenceValue",storageKey:null}],d={alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:c,storageKey:null},m={alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:c,storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DimensionDriftBreakdownSegmentBarChartQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[{kind:"RequiredField",field:{alias:null,args:t,concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[{kind:"InlineFragment",selections:[i,r],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[i,o],type:"IntervalBin",abstractKey:null},{kind:"InlineFragment",selections:[i],type:"MissingValueBin",abstractKey:null}],storageKey:null},d],storageKey:null},m],storageKey:null},action:"THROW",path:"dimension.segmentsComparison"}],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DimensionDriftBreakdownSegmentBarChartQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,l,{kind:"InlineFragment",selections:[{alias:null,args:t,concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[i,{kind:"InlineFragment",selections:[r],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[o],type:"IntervalBin",abstractKey:null}],storageKey:null},d],storageKey:null},m],storageKey:null}],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"7d11d88f419003f5ee8cd9d11312e427",id:null,metadata:{},name:"DimensionDriftBreakdownSegmentBarChartQuery",operationKind:"query",text:`query DimensionDriftBreakdownSegmentBarChartQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      segmentsComparison(primaryTimeRange: $timeRange) {
        segments {
          bin {
            __typename
            ... on NominalBin {
              __typename
              name
            }
            ... on IntervalBin {
              __typename
              range {
                start
                end
              }
            }
            ... on MissingValueBin {
              __typename
            }
          }
          counts {
            primaryValue
            referenceValue
          }
        }
        totalCounts {
          primaryValue
          referenceValue
        }
      }
    }
  }
}
`}}}();Wl.hash="6bb76e3cce4ee28c333e485b3aa2dffd";const qa=Ka(".2f"),Ul=()=>{const{primary:n,reference:a}=Me();return{primaryBarColor:n,referenceBarColor:a}};function yo({active:n,payload:a,label:l}){var r,o,c,d,m,y;const{primaryBarColor:t,referenceBarColor:i}=Ul();if(n&&a&&a.length){const g=(o=(r=a[0])==null?void 0:r.payload)==null?void 0:o.primaryName,p=(c=a[0])==null?void 0:c.value,f=(m=(d=a[0])==null?void 0:d.payload)==null?void 0:m.referenceName,k=(y=a[1])==null?void 0:y.value;return s(je,{children:[e(x,{elementType:"h3",textSize:"medium",weight:"heavy",children:l}),e(te,{color:t,shape:"square",name:g,value:p!=null?`${qa(p)}%`:"--"}),e(te,{color:i,shape:"square",name:f,value:k!=null?`${qa(k)}%`:"--"})]})}return null}function fo(n){var p,f,k,S,h;const{primaryInferences:a,referenceInferences:l}=Ie(),t=a.name,i=(l==null?void 0:l.name)||"reference",{selectedTimestamp:r}=Jn(),o=u.useMemo(()=>r??new Date(a.endTime),[r,a.endTime]),c=u.useMemo(()=>({start:el(o,2).toISOString(),end:o.toISOString()}),[o]),d=_.useLazyLoadQuery(Wl,{dimensionId:n.dimensionId,timeRange:c}),m=u.useMemo(()=>{var C,v,D,N,R;const F=((C=d.dimension.segmentsComparison)==null?void 0:C.segments)??[],L=((D=(v=d.dimension.segmentsComparison)==null?void 0:v.totalCounts)==null?void 0:D.primaryValue)??0,I=((R=(N=d.dimension.segmentsComparison)==null?void 0:N.totalCounts)==null?void 0:R.referenceValue)??0;return F.map(O=>{var A,E;const j=((A=O.counts)==null?void 0:A.primaryValue)??0,X=((E=O.counts)==null?void 0:E.referenceValue)??0,ie=ul(O.bin),re=j/L*100,w=X/I*100;return{name:ie,primaryName:t,referenceName:i,primaryPercent:re,referencePercent:w}})},[(p=d.dimension.segmentsComparison)==null?void 0:p.segments,(k=(f=d.dimension.segmentsComparison)==null?void 0:f.totalCounts)==null?void 0:k.primaryValue,(h=(S=d.dimension.segmentsComparison)==null?void 0:S.totalCounts)==null?void 0:h.referenceValue,t,i]),{primaryBarColor:y,referenceBarColor:g}=Ul();return s(b,{direction:"column",height:"100%",children:[e(T,{flex:"none",paddingTop:"size-100",paddingStart:"size-200",children:e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:`Distribution comparison at ${sn(new Date(c.end))}`})}),e(T,{flex:!0,children:e(Be,{children:s(Pa,{data:m,margin:{top:15,right:18,left:18,bottom:5},children:[s("defs",{children:[s("linearGradient",{id:"dimensionPrimarySegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:y,stopOpacity:1}),e("stop",{offset:"95%",stopColor:y,stopOpacity:.5})]}),s("linearGradient",{id:"dimensionReferenceSegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:g,stopOpacity:1}),e("stop",{offset:"95%",stopColor:g,stopOpacity:.5})]})]}),e(He,{dataKey:"name",style:{fill:"var(--ac-global-text-color-700)"}}),e(De,{stroke:le.colors.gray200,label:{value:"Percent",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Da,content:e(yo,{})}),e(kn,{dataKey:"primaryPercent",fill:"url(#dimensionPrimarySegmentsBarColor)"}),e(kn,{dataKey:"referencePercent",fill:"url(#dimensionReferenceSegmentsBarColor)"})]})})})]})}const Jl={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionDriftStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"driftMetric",storageKey:null}],type:"Dimension",abstractKey:null};Jl.hash="f8a9fb08a14f63906e38bc247d50b189";const ho=s(aa,{variant:"info",placement:"top end",children:[e(oe,{weight:"heavy",level:4,children:"Population Stability Index"}),e(na,{children:e(x,{children:"PSI is a symmetric metric that measures the relative entropy, or difference in information represented by two distributions. It can be thought of as measuring the distance between two data distributions showing how different the two distributions are from each other."})}),e("footer",{children:e(Rn,{href:"https://arize.com/blog-course/population-stability-index-psi/#:~:text=Population%20Stability%20Index%20(PSI)%20Overview,distributions%20are%20from%20each%20other.",children:"Learn more"})})]});function ko(n){const a=_.useFragment(Jl,n.dimension);return s(B,{children:[s(b,{direction:"row",alignItems:"center",gap:"size-25",children:[e(x,{elementType:"h3",textSize:"small",color:"text-700",children:"PSI"}),ho]}),e(x,{textSize:"xlarge",children:yn(a.psi)})]})}const Xl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"driftGranularity"},t={defaultValue:null,kind:"LocalArgument",name:"timeRange"},i=[{kind:"Variable",name:"id",variableName:"dimensionId"}],r={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],d={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"granularity",variableName:"driftGranularity"},{kind:"Literal",name:"metric",value:"psi"},o],concreteType:"DriftTimeSeries",kind:"LinkedField",name:"driftTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l,t],kind:"Fragment",metadata:null,name:"DimensionDriftTimeSeriesQuery",selections:[{alias:"embedding",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[r,d],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,t,l,n],kind:"Operation",name:"DimensionDriftTimeSeriesQuery",selections:[{alias:"embedding",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},r,d],storageKey:null}]},params:{cacheID:"af2d25e28675891b3c8a6bc75027f731",id:null,metadata:{},name:"DimensionDriftTimeSeriesQuery",operationKind:"query",text:`query DimensionDriftTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $driftGranularity: Granularity!
  $countGranularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      driftTimeSeries(metric: psi, timeRange: $timeRange, granularity: $driftGranularity) {
        data {
          timestamp
          value
        }
      }
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Xl.hash="6312b58dbb252b17efdf08d44dd58630";const Yl=()=>{const{orange300:n,gray300:a}=Me();return{color:n,barColor:a}};function bo({active:n,payload:a,label:l}){var i;const{color:t}=Yl();if(n&&a&&a.length){const r=((i=a[1])==null?void 0:i.value)??null;return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,name:"PSI",value:yn(r)}),e(Xn,{}),s("div",{css:K`
            display: flex;
            flex-direction: row;
            align-items: center;
            color: var(--ac-global-color-primary);
            gap: var(--px-spacing-sm);

            margin-top: var(--px-spacing-sm);
          `,children:[e(M,{svg:e(hl,{})}),e("span",{children:"Click to view details"})]})]})}return null}function So({dimensionId:n}){var f,k;const{timeRange:a}=Pe(),{selectedTimestamp:l,setSelectedTimestamp:t}=Jn(),i=Sn(a),r=_.useLazyLoadQuery(Xl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},driftGranularity:rl(a),countGranularity:i}),o=((f=r.embedding.driftTimeSeries)==null?void 0:f.data)||[],c=((k=r.embedding.trafficTimeSeries)==null?void 0:k.data.reduce((S,h)=>(S[h.timestamp]=h.value,S),{}))??{},d=o.map(S=>{const h=c[S.timestamp];return{...S,traffic:h,timestamp:new Date(S.timestamp).valueOf()}}),m=vn({samplingIntervalMinutes:i.samplingIntervalMinutes}),y=u.useCallback(S=>{const{activePayload:h}=S;if(h!=null&&h.length>0){const F=h[0].payload;t(new Date(F.timestamp))}},[t]),{color:g,barColor:p}=Yl();return e(Be,{width:"100%",height:"100%",children:s(jn,{data:d,margin:qn,onClick:y,syncId:"dimensionDetails",children:[s("defs",{children:[s("linearGradient",{id:"dimensionDriftColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:g,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:g,stopOpacity:0})]}),s("linearGradient",{id:"barColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:p,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:p,stopOpacity:0})]})]}),e(He,{...Fn,tickFormatter:S=>m(new Date(S))}),e(De,{stroke:le.colors.gray200,label:{value:"PSI",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(De,{yAxisId:"right",orientation:"right",tick:!1,tickLine:!1,width:0}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(bo,{})}),e(kn,{yAxisId:"right",dataKey:"traffic",fill:"url(#barColor)",spacing:5}),e(Pn,{type:"monotone",dataKey:"value",stroke:g,fillOpacity:1,fill:"url(#dimensionDriftColorUv)"}),l!=null?e(Fl,{...sl,x:l.getTime()}):null]})})}const Zl=function(){var n={kind:"Literal",name:"metric",value:"percentEmpty"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"hasReference"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionPercentEmptyStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"percentEmpty",args:[n,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referencePercentEmpty",args:[{kind:"Literal",name:"inferencesRole",value:"reference"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"percentEmpty")'}]}],type:"Dimension",abstractKey:null}}();Zl.hash="1e10d0449d6607d9292f355548c41c78";function vo(n){const a=_.useFragment(Zl,n.dimension);return s(B,{children:[e(x,{elementType:"h3",textSize:"small",color:"text-700",children:"% Empty"}),e(x,{textSize:"xlarge",children:va(a.percentEmpty)}),a.referencePercentEmpty!=null&&e(x,{textSize:"medium",color:"designationPurple",children:va(a.referencePercentEmpty)})]})}const et=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"percentEmptyTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"granularity"},{kind:"Literal",name:"metric",value:"percentEmpty"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionPercentEmptyTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionPercentEmptyTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"9be05c72f19755036f4829777a96f97d",id:null,metadata:{},name:"DimensionPercentEmptyTimeSeriesQuery",operationKind:"query",text:`query DimensionPercentEmptyTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      percentEmptyTimeSeries: dataQualityTimeSeries(metric: percentEmpty, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();et.hash="1e843d6c8dbe05b389b24188c6bdb394";const Fo=new Intl.NumberFormat([],{maximumFractionDigits:2}),nt=()=>{const{gray100:n}=Me();return{color:n}};function Ko({active:n,payload:a,label:l}){var i;const{color:t}=nt();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?Fo.format(r):"--";return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,name:"% Empty",value:o})]})}return null}function xo({dimensionId:n}){var c;const{timeRange:a}=Pe(),l=Sn(a),i=((c=_.useLazyLoadQuery(et,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}).embedding.percentEmptyTimeSeries)==null?void 0:c.data.map(d=>({timestamp:new Date(d.timestamp).valueOf(),value:d.value})))||[],r=vn({samplingIntervalMinutes:l.samplingIntervalMinutes}),{color:o}=nt();return e(Be,{width:"100%",height:"100%",children:s(jn,{data:i,margin:qn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"percentEmptyColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:o,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:o,stopOpacity:0})]})}),e(He,{...Fn,tickFormatter:d=>r(new Date(d))}),e(De,{stroke:le.colors.gray200,label:{value:"% Empty",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(Ko,{})}),e(Kl,{type:"monotone",dataKey:"value",stroke:o,fillOpacity:1,fill:"url(#percentEmptyColorUv)"})]})})}const at=function(){var n={kind:"Variable",name:"timeRange",variableName:"timeRange"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionQuantilesStats_dimension",selections:[{alias:"p99",args:[{kind:"Literal",name:"metric",value:"p99"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p75",args:[{kind:"Literal",name:"metric",value:"p75"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p50",args:[{kind:"Literal",name:"metric",value:"p50"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p25",args:[{kind:"Literal",name:"metric",value:"p25"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p1",args:[{kind:"Literal",name:"metric",value:"p01"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null}],type:"Dimension",abstractKey:null}}();at.hash="c306c8eafb1d34be464d3a658d5f94a7";function To(n){const a=_.useFragment(at,n.dimension);return e("ul",{css:K`
        display: flex;
        flex-direction: column;
        gap: var(--px-spacing-sm);
      `,children:Object.keys(a).map(l=>{const t=a[l];return s("li",{css:K`
              display: flex;
              flex-direction: column;
              align-items: flex-end;
            `,children:[e(x,{elementType:"h3",textSize:"xsmall",color:"text-700",children:l}),e(x,{textSize:"medium","data-raw":t,children:Ta(t)})]},l)})})}const lt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"Variable",name:"granularity",variableName:"granularity"},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],d={kind:"InlineFragment",selections:[{alias:"p99TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p99"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p75TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p75"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p50TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p50"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p25TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p25"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p01TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p01"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionQuantilesTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,d],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionQuantilesTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,d],storageKey:null}]},params:{cacheID:"0bb3d9faf9d7f0c2e27995120ae24e1c",id:null,metadata:{},name:"DimensionQuantilesTimeSeriesQuery",operationKind:"query",text:`query DimensionQuantilesTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      p99TimeSeries: dataQualityTimeSeries(metric: p99, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p75TimeSeries: dataQualityTimeSeries(metric: p75, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p50TimeSeries: dataQualityTimeSeries(metric: p50, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p25TimeSeries: dataQualityTimeSeries(metric: p25, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p01TimeSeries: dataQualityTimeSeries(metric: p01, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();lt.hash="134f0dad0e0ecc7863dfbb0f437d829b";const Do=Ka("~s");var tt=(n=>(n.p99_p01="p99_p01",n.p75_p25="p75_p25",n.p50="p50",n))(tt||{});const Co=new Intl.NumberFormat([],{maximumFractionDigits:2});function _n(n){return typeof n=="number"?Co.format(n):"--"}const it=()=>{const n=Me();return{outerColor:n.gray500,innerColor:n.gray300,lineColor:n.default}};function Io({active:n,payload:a,label:l}){const{outerColor:t,innerColor:i,lineColor:r}=it();if(n&&a&&a.length){const o=a[0].payload;return s(je,{children:[e(x,{weight:"heavy",textSize:"medium",children:`${sn(new Date(l))}`}),e(te,{color:t,name:"p99",value:_n(o.p99_p01[0])}),e(te,{color:i,name:"p75",value:_n(o.p75_p25[0])}),e(te,{color:r,name:"p50",value:_n(o.p50)}),e(te,{color:i,name:"p25",value:_n(o.p75_p25[1])}),e(te,{color:t,name:"p01",value:_n(o.p99_p01[1])})]})}return null}function Lo({dimensionId:n}){var I,C,v,D,N;const{timeRange:a}=Pe(),l=Sn(a),t=_.useLazyLoadQuery(lt,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}),i=((I=t.dimension.p99TimeSeries)==null?void 0:I.data.map(R=>R))||[],r=((C=t.dimension.p01TimeSeries)==null?void 0:C.data.map(R=>R))||[],o=((v=t.dimension.p75TimeSeries)==null?void 0:v.data.map(R=>R))||[],c=((D=t.dimension.p25TimeSeries)==null?void 0:D.data.map(R=>R))||[],d=((N=t.dimension.p50TimeSeries)==null?void 0:N.data.map(R=>R))||[],m=i.map((R,O)=>({timestamp:new Date(R.timestamp).valueOf(),p99_p01:[R.value,r[O].value],p75_p25:[o[O].value,c[O].value],p50:d[O].value})),y=vn({samplingIntervalMinutes:l.samplingIntervalMinutes}),[g,p]=u.useState(Object.keys(tt).reduce((R,O)=>(R[O]=!1,R),{})),f=R=>{g[R.dataKey]||p({...g})},k=()=>{p({...g})},S=R=>{p({...g,[String(R.dataKey)]:!g[R.dataKey]})},{outerColor:h,innerColor:F,lineColor:L}=it();return e(Be,{width:"100%",height:"100%",children:s(jn,{data:m,margin:qn,syncId:"dimensionDetails",children:[s("defs",{children:[s("linearGradient",{id:"p99_p01ColorUV",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"10%",stopColor:h,stopOpacity:.7}),e("stop",{offset:"50%",stopColor:h,stopOpacity:.3}),e("stop",{offset:"90%",stopColor:h,stopOpacity:.7})]}),s("linearGradient",{id:"p75_p25ColorUV",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"10%",stopColor:F,stopOpacity:.7}),e("stop",{offset:"50%",stopColor:F,stopOpacity:.3}),e("stop",{offset:"90%",stopColor:F,stopOpacity:.7})]})]}),e(He,{...Fn,tickFormatter:R=>y(new Date(R))}),e(De,{stroke:le.colors.gray200,label:{value:"Value",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},tickFormatter:R=>Do(R),style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(Io,{})}),e(ss,{onClick:S,onMouseOver:f,onMouseOut:k}),e(Pn,{type:"monotone",dataKey:"p99_p01",name:"p99 - p01",fillOpacity:1,fill:"url(#p99_p01ColorUV)",stroke:h,hide:g.p99_p01===!0}),e(Pn,{type:"monotone",dataKey:"p75_p25",name:"p75 - p25",fillOpacity:1,stroke:F,fill:"url(#p75_p25ColorUV)",hide:g.p75_p25===!0}),e(Kl,{type:"monotone",dataKey:"p50",stroke:L,hide:g.p50===!0})]})})}const rt=function(){var n={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},a=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionSegmentsBarChart_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[{kind:"InlineFragment",selections:[n,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[n,{alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null}],type:"IntervalBin",abstractKey:null},{kind:"InlineFragment",selections:[n],type:"MissingValueBin",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:a,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:a,storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null}}();rt.hash="8cef9841e9a5bd7d0d50acb5db9028b0";const Eo=Ka(".2f"),st=()=>{const{primary:n}=Me();return{color:n}};function _o({active:n,payload:a,label:l}){var i;const{color:t}=st();if(n&&a&&a.length){const r=(i=a[0])==null?void 0:i.value;return e(je,{children:e(te,{color:t,shape:"square",name:l,value:r!=null?`${Eo(r)}%`:"--"})})}return null}function Ro(n){const a=_.useFragment(rt,n.dimension),l=u.useMemo(()=>{var o,c,d;const i=((o=a.segmentsComparison)==null?void 0:o.segments)??[],r=((d=(c=a.segmentsComparison)==null?void 0:c.totalCounts)==null?void 0:d.primaryValue)??0;return i.map(m=>{var f;const y=((f=m.counts)==null?void 0:f.primaryValue)??0,g=ul(m.bin),p=y/r*100;return{name:g,percent:p}})},[a]),{color:t}=st();return e(Be,{children:s(Pa,{data:l,margin:{top:25,right:18,left:18,bottom:5},children:[e("defs",{children:s("linearGradient",{id:"dimensionSegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:t,stopOpacity:1}),e("stop",{offset:"95%",stopColor:t,stopOpacity:.5})]})}),e(He,{dataKey:"name",style:{fill:"var(--ac-global-text-color-700)"}}),e(De,{stroke:le.colors.gray200,label:{value:"% Volume",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Da,content:e(_o,{})}),e(kn,{dataKey:"percent",fill:"url(#dimensionSegmentsBarColor)",spacing:15})]})})}function yu(){const{dimensionId:n}=Oe(),{timeRange:a}=Pe(),l=An(),{referenceInferences:t}=Ie(),i=t!==null,r=i,o=l.dimension.shape!=="continuous",c=l.dimension.dataType==="numeric",d=ae(),m=_.useLazyLoadQuery(Ql,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},hasReference:i});if(!n)throw new Error("Dimension ID is required to display a dimension");return e(cl,{initialTimestamp:new Date(a.end),children:e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>d(-1),children:e(G,{size:"L",title:l.dimension.name,children:e("main",{css:K`
              padding: var(--px-spacing-med);
              display: flex;
              flex-direction: column;
              min-height: 400px;
              overflow-y: auto;
              height: 100%;
            `,children:e(u.Suspense,{fallback:e(ue,{}),children:s(b,{direction:"column",gap:"size-100",children:[e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:e(Ro,{dimension:m.dimension})}),e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600","data-testid":"dimension-count-time-series-view",children:s(b,{direction:"row",alignItems:"stretch",height:"100%",children:[e(po,{dimensionId:n}),e(gn,{children:e(uo,{dimension:m.dimension})})]})}),r?e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",children:s(b,{direction:"column",alignItems:"stretch",children:[e(T,{width:"100%",height:"size-1600",children:s(b,{direction:"row",alignItems:"stretch",height:"100%",children:[e(T,{flex:!0,children:e(So,{dimensionId:n})}),e(gn,{children:e(ko,{dimension:m.dimension})})]})}),e(T,{height:"size-1600",width:"100%",borderTopColor:"dark",borderTopWidth:"thin",children:e(u.Suspense,{fallback:e(ue,{}),children:e(fo,{dimensionId:n})})})]})}):null,c?e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-3000",children:s(b,{direction:"row",alignItems:"stretch",height:"100%",children:[e(T,{flex:!0,children:e(Lo,{dimensionId:n})}),e(gn,{children:e(To,{dimension:m.dimension})})]})}):null,o?e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:s(b,{direction:"row",alignItems:"stretch",height:"100%",children:[e(T,{flex:!0,children:e(co,{dimensionId:n})}),e(gn,{children:e(ro,{dimension:m.dimension})})]})}):null,e(T,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:s(b,{direction:"row",alignItems:"stretch",height:"100%",children:[e(xo,{dimensionId:n}),e(gn,{children:e(vo,{dimension:m.dimension})})]})})]})})})})})})}const ot=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"dataType",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"shape",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"dimensionLoaderQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,t,i,r],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"dimensionLoaderQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[t,i,r],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"03a9aafe3f08a9d093b029ff4a9e3253",id:null,metadata:{},name:"dimensionLoaderQuery",operationKind:"query",text:`query dimensionLoaderQuery(
  $id: GlobalID!
) {
  dimension: node(id: $id) {
    __typename
    ... on Dimension {
      id
      name
      dataType
      shape
    }
    __isNode: __typename
    id
  }
}
`}}}();ot.hash="5a662d77e69d2e9bb4eb2af4cad6b722";async function fu(n){const{dimensionId:a}=n.params;return _.fetchQuery(Ce,ot,{id:a}).toPromise()}const dt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"id"},a={defaultValue:null,kind:"LocalArgument",name:"traceId"},l=[{kind:"Variable",name:"id",variableName:"id"}],t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},r={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"traceId",variableName:"traceId"}],concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:[{kind:"Literal",name:"first",value:1e3}],concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[t,{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},i,{alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},{alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:"spans(first:1000)"}],storageKey:null}],type:"Project",abstractKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"TraceDetailsQuery",selections:[{alias:"project",args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"TraceDetailsQuery",selections:[{alias:"project",args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},r,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t],storageKey:null}]},params:{cacheID:"872e8d6e17fb1b6cf51bae98d6767208",id:null,metadata:{},name:"TraceDetailsQuery",operationKind:"query",text:`query TraceDetailsQuery(
  $traceId: ID!
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    ... on Project {
      trace(traceId: $traceId) {
        spans(first: 1000) {
          edges {
            span: node {
              id
              context {
                spanId
                traceId
              }
              name
              spanKind
              statusCode: propagatedStatusCode
              startTime
              parentId
              latencyMs
              tokenCountTotal
              tokenCountPrompt
              tokenCountCompletion
              spanEvaluations {
                name
                label
                score
              }
            }
          }
        }
      }
    }
    __isNode: __typename
    id
  }
}
`}}}();dt.hash="73a6eacf0bb44e37ed4963cb27883c51";function ct(n){return s(pe,{children:[e($e,{children:e(ga,{children:n.tokenCountTotal})}),e(en,{children:s(b,{direction:"column",gap:"size-50",children:[s(b,{direction:"row",gap:"size-100",justifyContent:"space-between",children:["prompt tokens",e(ga,{children:n.tokenCountPrompt})]}),s(b,{direction:"row",gap:"size-100",justifyContent:"space-between",children:["completion tokens",e(ga,{children:n.tokenCountCompletion})]})]})})]})}function ga({children:n}){return s(b,{direction:"row",gap:"size-25",alignItems:"center",children:[e(M,{svg:e(P.TokensOutline,{}),css:K`
          color: var(--ac-global-text-color-900);
        `}),e(x,{children:n})]})}const Ba=K`
  display: flex;
  align-items: center;
  .ac-text {
    display: inline-block;
    max-width: 9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
`;function Na({evaluation:n}){const a=n.label||typeof n.score=="number"&&Ke(n.score)||"n/a";return s(pe,{delay:500,offset:3,children:[e($e,{children:e(Ze,{color:"cyan-1000",shape:"badge",children:s(b,{direction:"row",gap:"size-50",children:[e("div",{css:Ba,children:e(x,{weight:"heavy",textSize:"small",color:"inherit",children:n.name})}),e("div",{css:Ba,children:e(x,{textSize:"small",children:a})})]})})}),e(en,{children:s(b,{direction:"row",gap:"size-100",children:[e(x,{weight:"heavy",textSize:"small",color:"inherit",children:n.name}),e(x,{textSize:"small",color:"inherit",children:a})]})})]})}const ut=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{kind:"Variable",name:"id",variableName:"spanId"}],l={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},i={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},o={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},c={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},d={alias:null,args:null,kind:"ScalarField",name:"statusMessage",storageKey:null},m={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},y={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},g={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},f={alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},k={alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},S=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"mimeType",storageKey:null}],h={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:S,storageKey:null},F={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:S,storageKey:null},L={alias:null,args:null,kind:"ScalarField",name:"attributes",storageKey:null},I={alias:null,args:null,concreteType:"SpanEvent",kind:"LinkedField",name:"events",plural:!0,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"message",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null}],storageKey:null},C={alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},v={alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},D={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},N={alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},R={alias:null,args:null,concreteType:"DocumentEvaluation",kind:"LinkedField",name:"documentEvaluations",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"documentPosition",storageKey:null},r,C,v,N],storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanDetailsQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[t,i,r,o,c,d,m,y,g,p,f,k,h,F,L,{kind:"RequiredField",field:I,action:"THROW",path:"span.events"},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[r,C,v],storageKey:null},D,R,{args:null,kind:"FragmentSpread",name:"SpanEvaluationsTable_evals"}],type:"Span",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanDetailsQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t,{kind:"InlineFragment",selections:[i,r,o,c,d,m,y,g,p,f,k,h,F,L,I,{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[r,C,v,N],storageKey:null},D,R],type:"Span",abstractKey:null}],storageKey:null}]},params:{cacheID:"994295103990e4b8fbff3b1422e1647f",id:null,metadata:{},name:"SpanDetailsQuery",operationKind:"query",text:`query SpanDetailsQuery(
  $spanId: GlobalID!
) {
  span: node(id: $spanId) {
    __typename
    ... on Span {
      id
      context {
        spanId
        traceId
      }
      name
      spanKind
      statusCode: propagatedStatusCode
      statusMessage
      startTime
      parentId
      latencyMs
      tokenCountTotal
      tokenCountPrompt
      tokenCountCompletion
      input {
        value
        mimeType
      }
      output {
        value
        mimeType
      }
      attributes
      events {
        name
        message
        timestamp
      }
      spanEvaluations {
        name
        label
        score
      }
      documentRetrievalMetrics {
        evaluationName
        ndcg
        precision
        hit
      }
      documentEvaluations {
        documentPosition
        name
        label
        score
        explanation
      }
      ...SpanEvaluationsTable_evals
    }
    __isNode: __typename
    id
  }
}

fragment SpanEvaluationsTable_evals on Span {
  spanEvaluations {
    name
    label
    score
    explanation
  }
}
`}}}();ut.hash="39420c6270d451eca0528e7bb90fd065";const pa=K`
  display: flex;
  align-items: center;
  .ac-text {
    display: inline-block;
    max-width: 9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
`;function ce(n){const{name:a,metric:l,k:t,score:i}=n,r=typeof t=="number"?`${l}@${t}`:l,o=u.useMemo(()=>l==="hit"?i?"true":"false":typeof i=="number"&&Ke(i)||"--",[i,l]);return s(pe,{delay:500,offset:3,children:[e($e,{children:e(Ze,{color:"seafoam-1000",shape:"badge",children:s(b,{direction:"row",gap:"size-50",children:[a?e("div",{css:pa,children:e(x,{weight:"heavy",textSize:"small",color:"inherit",children:a})}):null,e("div",{css:pa,children:e(x,{textSize:"small",color:"inherit",children:r})}),e("div",{css:pa,children:e(x,{textSize:"small",children:o})})]})})}),e(en,{children:s(b,{direction:"row",gap:"size-100",children:[s(x,{weight:"heavy",textSize:"small",color:"inherit",children:[a," ",r]}),e(x,{textSize:"small",color:"inherit",children:o})]})})]})}const mt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"projectId"},{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{kind:"Variable",name:"id",variableName:"projectId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanAnnotationNames",storageKey:null}],type:"Project",abstractKey:null},i=[{kind:"Variable",name:"id",variableName:"spanId"}],r={kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null},o={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EditSpanAnnotationsDialogNewAnnotationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,t],storageKey:null},{alias:"span",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EditSpanAnnotationsDialogNewAnnotationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[o,l,t],storageKey:null},{alias:"span",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[o,l,r],storageKey:null}]},params:{cacheID:"c27b51c4efeddd745d11b03ac3704a87",id:null,metadata:{},name:"EditSpanAnnotationsDialogNewAnnotationQuery",operationKind:"query",text:`query EditSpanAnnotationsDialogNewAnnotationQuery(
  $projectId: GlobalID!
  $spanId: GlobalID!
) {
  project: node(id: $projectId) {
    __typename
    id
    ... on Project {
      spanAnnotationNames
    }
  }
  span: node(id: $spanId) {
    __typename
    id
    ... on Span {
      spanAnnotations {
        id
        name
      }
    }
  }
}
`}}}();mt.hash="7498876efb347b23dc5d3a1fa0c3f2ef";const gt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EditSpanAnnotationsDialogSpanAnnotationsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"EditSpanAnnotationsDialog_spanAnnotations"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EditSpanAnnotationsDialogSpanAnnotationsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null}],storageKey:null}]},params:{cacheID:"8649eb1dd42a29a0d38b9a1538490de4",id:null,metadata:{},name:"EditSpanAnnotationsDialogSpanAnnotationsQuery",operationKind:"query",text:`query EditSpanAnnotationsDialogSpanAnnotationsQuery(
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...EditSpanAnnotationsDialog_spanAnnotations
    __isNode: __typename
    id
  }
}

fragment EditSpanAnnotationsDialog_spanAnnotations on Span {
  id
  spanAnnotations {
    id
    name
    annotatorKind
    score
    label
    explanation
  }
}
`}}}();gt.hash="07aedb847a2af03a77823f0afc0c98d4";const pt=function(){var n={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:gt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"EditSpanAnnotationsDialog_spanAnnotations",selections:[n,{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[n,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null}}();pt.hash="07aedb847a2af03a77823f0afc0c98d4";const yt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{kind:"Variable",name:"id",variableName:"spanId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EditSpanAnnotationsDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[{args:null,kind:"FragmentSpread",name:"EditSpanAnnotationsDialog_spanAnnotations"}],type:"Span",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EditSpanAnnotationsDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null}],storageKey:null}]},params:{cacheID:"532b3c148c3bf1411b8820714c68f4e3",id:null,metadata:{},name:"EditSpanAnnotationsDialogQuery",operationKind:"query",text:`query EditSpanAnnotationsDialogQuery(
  $spanId: GlobalID!
) {
  span: node(id: $spanId) {
    __typename
    id
    ... on Span {
      ...EditSpanAnnotationsDialog_spanAnnotations
    }
  }
}

fragment EditSpanAnnotationsDialog_spanAnnotations on Span {
  id
  spanAnnotations {
    id
    name
    annotatorKind
    score
    label
    explanation
  }
}
`}}}();yt.hash="36093f4285a168993ec87fd6aac82365";const ft=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"},{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{items:[{kind:"Variable",name:"input.0",variableName:"input"}],kind:"ListValue",name:"input"}],l=[{kind:"Variable",name:"id",variableName:"spanId"}],t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"NewSpanAnnotationFormMutation",selections:[{alias:null,args:a,concreteType:"SpanAnnotationMutationPayload",kind:"LinkedField",name:"createSpanAnnotations",plural:!1,selections:[{alias:null,args:null,concreteType:"Query",kind:"LinkedField",name:"query",plural:!1,selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[{args:null,kind:"FragmentSpread",name:"EditSpanAnnotationsDialog_spanAnnotations"}],type:"Span",abstractKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"NewSpanAnnotationFormMutation",selections:[{alias:null,args:a,concreteType:"SpanAnnotationMutationPayload",kind:"LinkedField",name:"createSpanAnnotations",plural:!1,selections:[{alias:null,args:null,concreteType:"Query",kind:"LinkedField",name:"query",plural:!1,selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},t,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"d6f016f4dfb0c142854c3ecd840b09f5",id:null,metadata:{},name:"NewSpanAnnotationFormMutation",operationKind:"mutation",text:`mutation NewSpanAnnotationFormMutation(
  $input: CreateSpanAnnotationInput!
  $spanId: GlobalID!
) {
  createSpanAnnotations(input: [$input]) {
    query {
      node(id: $spanId) {
        __typename
        ... on Span {
          ...EditSpanAnnotationsDialog_spanAnnotations
        }
        __isNode: __typename
        id
      }
    }
  }
}

fragment EditSpanAnnotationsDialog_spanAnnotations on Span {
  id
  spanAnnotations {
    id
    name
    annotatorKind
    score
    label
    explanation
  }
}
`}}}();ft.hash="ded0a7a64a2706f6ec472a63c1c57eca";function ht(n){const{initialData:a,isReadOnly:l,onSubmit:t,isSubmitting:i=!1}=n,r=u.useRef(null),{control:o,handleSubmit:c,formState:{isDirty:d,isValid:m},setError:y}=bn({defaultValues:a,disabled:l}),g=u.useCallback(p=>{if(!p.label&&p.score===""){y("label",{type:"manual",message:"Label or score is required"}),y("score",{type:"manual",message:"Label or score is required"});return}t&&t({...p,score:p.score!=null?parseFloat(p.score.toString()):null})},[t,y]);return s("form",{onSubmit:c(g),ref:r,children:[e(T,{padding:"size-200",children:s(b,{direction:"column",gap:"size-100",children:[s("div",{css:K`
              display: flex;
              flex-direction: row;
              width: 100%;
              overflow: hidden;
              gap: var(--ac-global-dimension-size-100);
              & > * {
                flex: 1 1 auto;
              }
              .ac-textfield {
                min-width: 0;
              }
            `,children:[e(U,{name:"label",control:o,render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>e(ye,{label:"Label",placeholder:"e.x. good, bad",description:"A categorical label like 'good' or 'bad'",isReadOnly:l,errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",onChange:p,onBlur:f,value:(k==null?void 0:k.toString())||""})}),e(U,{name:"score",control:o,render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>e(ye,{label:"Score",type:"number",placeholder:"e.x. 0.8",description:"A numeric grade",errorMessage:h==null?void 0:h.message,isReadOnly:l,validationState:S?"invalid":"valid",onChange:p,onBlur:f,value:(k==null?void 0:k.toString())||""})})]}),e(U,{name:"explanation",control:o,render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>e(la,{label:"Explanation",height:70,isReadOnly:l,description:"Why this score or label was given",errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",onChange:p,onBlur:f,value:(k==null?void 0:k.toString())||""})})]})}),e(B,{children:l?null:e(T,{paddingTop:"size-100",paddingBottom:"size-100",paddingEnd:"size-200",paddingStart:"size-200",borderTopWidth:"thin",borderColor:"dark",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:d?"primary":"default",type:"submit",size:"compact",isDisabled:!m||!d||i,onClick:()=>{var p;(p=r.current)==null||p.requestSubmit()},children:i?"Saving...":"Save"})})})})]})}function wo(n){const{annotationName:a,spanNodeId:l,onCreated:t}=n,[i,r]=_.useMutation(ft);return e(ht,{initialData:{name:a},isSubmitting:r,onSubmit:c=>{i({variables:{input:{spanId:l,annotatorKind:"HUMAN",...c},spanId:l},onCompleted:()=>{t()}})}})}const kt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"annotationId"},{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{fields:[{items:[{kind:"Variable",name:"annotationIds.0",variableName:"annotationId"}],kind:"ListValue",name:"annotationIds"}],kind:"ObjectValue",name:"input"}],l=[{kind:"Variable",name:"id",variableName:"spanId"}],t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanAnnotationActionMenuDeleteMutation",selections:[{alias:null,args:a,concreteType:"SpanAnnotationMutationPayload",kind:"LinkedField",name:"deleteSpanAnnotations",plural:!1,selections:[{alias:null,args:null,concreteType:"Query",kind:"LinkedField",name:"query",plural:!1,selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[{args:null,kind:"FragmentSpread",name:"EditSpanAnnotationsDialog_spanAnnotations"}],type:"Span",abstractKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanAnnotationActionMenuDeleteMutation",selections:[{alias:null,args:a,concreteType:"SpanAnnotationMutationPayload",kind:"LinkedField",name:"deleteSpanAnnotations",plural:!1,selections:[{alias:null,args:null,concreteType:"Query",kind:"LinkedField",name:"query",plural:!1,selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},t,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"SpanAnnotation",kind:"LinkedField",name:"spanAnnotations",plural:!0,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"422687a283120080277d2649c1b9f6ee",id:null,metadata:{},name:"SpanAnnotationActionMenuDeleteMutation",operationKind:"mutation",text:`mutation SpanAnnotationActionMenuDeleteMutation(
  $annotationId: GlobalID!
  $spanId: GlobalID!
) {
  deleteSpanAnnotations(input: {annotationIds: [$annotationId]}) {
    query {
      node(id: $spanId) {
        __typename
        ... on Span {
          ...EditSpanAnnotationsDialog_spanAnnotations
        }
        __isNode: __typename
        id
      }
    }
  }
}

fragment EditSpanAnnotationsDialog_spanAnnotations on Span {
  id
  spanAnnotations {
    id
    name
    annotatorKind
    score
    label
    explanation
  }
}
`}}}();kt.hash="a898fcb037b08cb626daaf3d385588ce";function Po(n){const{onDelete:a,isDisabled:l=!1}=n;return e("div",{onClick:t=>{t.preventDefault(),t.stopPropagation()},children:e(qe,{align:"end",buttonSize:"compact",isDisabled:l,onAction:t=>{switch(t){case"deleteAnnotation":a();break}},children:e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.TrashOutline,{})}),e(x,{children:"Delete"})]})},"deleteAnnotation")})})}function Mo(n){const{annotationId:a,spanNodeId:l,annotationName:t,onSpanAnnotationDelete:i,onSpanAnnotationDeleteError:r}=n,[o,c]=u.useState(null),[d,m]=_.useMutation(kt),y=u.useCallback(()=>{u.startTransition(()=>{d({variables:{annotationId:a,spanId:l},onCompleted:()=>{i()},onError:p=>{r(p)}})})},[d,a,l,i,r]),g=u.useCallback(()=>{c(s(G,{size:"S",title:"Delete Annotation",children:[e(T,{padding:"size-200",children:e(x,{color:"danger",children:`Are you sure you want to delete annotation ${t}? This cannot be undone.`})}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:"danger",onClick:()=>{y(),c(null)},children:"Delete Annotation"})})})]}))},[y,t]);return s("div",{children:[e(Po,{onDelete:g,isDisabled:m}),e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>c(null),children:o})]})}function No(n){const{projectId:a,spanNodeId:l}=n,[t,i]=u.useState(null),r=ve();return e(G,{title:"Annotate",size:"M",isDismissable:!0,extra:e(Ao,{projectId:a,spanNodeId:l,disabled:t!==null,onAnnotationNameSelect:i}),children:s("div",{css:K`
          height: 100%;
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-200);
        `,children:[t&&e(T,{paddingBottom:"size-200",children:e(Qo,{spanNodeId:l,name:t,onDelete:()=>{i(null)},onCreated:()=>{i(null),r({title:"New Span Annotation",message:`Annotation ${t} has been created.`})}})}),e(u.Suspense,{children:e(Vo,{...n})})]})})}function Ao(n){const{projectId:a,disabled:l=!1,spanNodeId:t,onAnnotationNameSelect:i}=n,[r,o]=u.useState(!1);return s(dn,{placement:"bottom end",crossOffset:300,isOpen:r,onOpenChange:c=>{o(c)},children:[e(z,{variant:"default",disabled:l,size:"compact",icon:e(M,{svg:e(P.PlusCircleOutline,{})}),onClick:()=>{o(!0)},children:"New"}),e($o,{projectId:a,spanNodeId:t,onAnnotationNameSelect:c=>{i(c),o(!1)}})]})}function $o(n){const{projectId:a,spanNodeId:l,onAnnotationNameSelect:t}=n;return e(Q,{title:"New Annotation",backgroundColor:"light",borderColor:"light",variant:"compact",bodyStyle:{padding:0},children:e(u.Suspense,{children:e(jo,{projectId:a,spanId:l,onAnnotationNameSelect:t})})})}function Vo(n){const a=_.useLazyLoadQuery(yt,{spanId:n.spanNodeId},{fetchPolicy:"store-and-network"});return e(zo,{span:a.span})}function zo(n){const{span:a}=n,[l]=_.useRefetchableFragment(pt,a),t=l.spanAnnotations||[],i=t.length>0;return s("div",{children:[!i&&e(ol,{graphicKey:"documents",message:"No annotations for this span"}),e("ul",{css:K`
          display: flex;
          flex-direction: column;
          gap: var(--ac-global-dimension-size-200);
        `,children:t.map((r,o)=>e("li",{children:e(Oo,{annotation:r,spanNodeId:l.id})},o))})]})}function Qo(n){const{spanNodeId:a,name:l,onDelete:t,onCreated:i}=n;return s(Q,{variant:"compact",title:l,borderColor:"orange-900",extra:s(b,{direction:"row",alignItems:"center",gap:"size-100",children:[e(bt,{kind:"HUMAN"}),e(z,{variant:"default",size:"compact",isDisabled:!0,"aria-label":"delete annotation",icon:e(M,{svg:e(P.CloseOutline,{})}),onClick:t})]}),bodyStyle:{padding:0},children:[e(ne,{variant:"info",banner:!0,children:"Fill out the fields below and click save to create a new annotation."}),e(wo,{annotationName:l,spanNodeId:a,onCreated:i})]})}function Oo(n){const{annotation:a,spanNodeId:l}=n,[t,i]=u.useState(null),r=ve();return s(Q,{variant:"compact",title:a.name,titleExtra:a.label||typeof a.score=="number"&&Ke(a.score)||null,collapsible:!0,bodyStyle:{padding:0},extra:s(b,{gap:"size-100",alignItems:"center",children:[e(bt,{kind:a.annotatorKind}),e(Mo,{annotationId:a.id,spanNodeId:l,annotationName:a.name,onSpanAnnotationDelete:()=>{r({title:"Annotation Deleted",message:`Annotation ${a.name} has been deleted.`})},onSpanAnnotationDeleteError:o=>{i(o)}})]}),children:[t&&e(ne,{variant:"danger",banner:!0,children:t.message}),e(ht,{initialData:a,isReadOnly:!0})]})}function bt(n){const{kind:a}=n;return e(Ze,{color:a==="HUMAN"?"blue-900":"orange-900",children:a})}function jo(n){const{projectId:a,spanId:l,onAnnotationNameSelect:t}=n,i=_.useLazyLoadQuery(mt,{projectId:a,spanId:l}),[r,o]=u.useState(""),c=u.useMemo(()=>{var y,g;return((g=(y=i==null?void 0:i.span)==null?void 0:y.spanAnnotations)==null?void 0:g.map(p=>p.name))||[]},[i.span.spanAnnotations]),d=u.useMemo(()=>(i.project.spanAnnotationNames||[]).filter(g=>!c.includes(g)),[i.project.spanAnnotationNames,c]),m=d.length>0;return s(B,{children:[e(T,{padding:"size-200",children:s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"Annotation Name",value:r,placeholder:"e.x. correctness",onChange:y=>{o(y)}}),e(z,{variant:"primary",onClick:()=>{t(r)},children:"Create"})]})}),m&&s(B,{children:[e(T,{borderTopWidth:"thin",borderBottomWidth:"thin",borderColor:"light",paddingStart:"size-200",paddingTop:"size-100",paddingBottom:"size-100",backgroundColor:"grey-300",children:e("label",{children:"select from existing"})}),e(On,{selectionMode:"single",onSelectionChange:y=>{if(y==="all"||y.size===0)return;const p=y.values().next().value;o(p||"")},disabledKeys:c,children:d.map(y=>e(H,{children:y},y))})]})]})}function qo(n){const{spanNodeId:a,projectId:l}=n,[t,i]=u.useState(null);return s(B,{children:[e(z,{variant:"default",icon:e(M,{svg:e(P.EditOutline,{})}),onClick:()=>i(e(No,{spanNodeId:a,projectId:l})),children:"Annotate"}),e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>i(null),children:t})]})}function Bo(n){const{spanId:a,traceId:l}=n;return e("div",{css:K`
        button.ac-dropdown-button {
          min-width: 50px;
          .ac-dropdown-button__text {
            padding-right: 10px;
          }
        }
      `,children:s(dn,{placement:"bottom right",children:[e(vl,{addonBefore:e(M,{svg:e(P.Code,{})}),children:"Code"}),e(_a,{children:e(T,{padding:"size-200",children:s(wn,{children:[s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"Span ID",isReadOnly:!0,value:a}),e(Y,{text:a,size:"normal"})]}),s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"Trace ID",isReadOnly:!0,value:l}),e(Y,{text:l,size:"normal"})]})]})})})]})})}const St={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"SpanEvaluationsTable_evals",selections:[{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null};St.hash="0604d02236eeb7e73817a68e2e6f12e2";const Ho=[{header:"name",accessorKey:"name",size:100},{header:"label",accessorKey:"label",size:100},{header:"score",accessorKey:"score",size:100},{header:"explanation",accessorKey:"explanation",cell:Er,size:400}];function Go(n){const a=_.useFragment(St,n.span),l=u.useMemo(()=>[...a.spanEvaluations],[a.spanEvaluations]),t=be({columns:Ho,data:l,getCoreRowModel:Se()}),r=t.getRowModel().rows.length===0;return s("table",{css:Vn,children:[e("thead",{children:t.getHeaderGroups().map(o=>e("tr",{children:o.headers.map(c=>e("th",{colSpan:c.colSpan,children:c.isPlaceholder?null:e(B,{children:J(c.column.columnDef.header,c.getContext())})},c.id))},o.id))}),r?e(on,{}):e("tbody",{children:t.getRowModel().rows.map(o=>e("tr",{children:o.getVisibleCells().map(c=>e("td",{style:{width:c.column.getSize()},children:J(c.column.columnDef.cell,c.getContext())},c.id))},o.id))})]})}const vt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addExamplesToDataset",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",selections:a},params:{cacheID:"d93c9d47668fc266ba09ecb14c2b72ae",id:null,metadata:{},name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",operationKind:"mutation",text:`mutation SpanToDatasetExampleDialogAddExampleToDatasetMutation(
  $input: AddExamplesToDatasetInput!
) {
  addExamplesToDataset(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();vt.hash="75120065d239f28304e9dd91fc34bec9";const Ft=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{kind:"Variable",name:"id",variableName:"spanId"}],l={kind:"InlineFragment",selections:[{alias:"revision",args:null,concreteType:"SpanAsExampleRevision",kind:"LinkedField",name:"asExampleRevision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null},t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanToDatasetExampleDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null},{args:null,kind:"FragmentSpread",name:"DatasetPicker__datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanToDatasetExampleDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t],storageKey:null},{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"340325aadd2b2d81cb509e6b6bee7f0b",id:null,metadata:{},name:"SpanToDatasetExampleDialogQuery",operationKind:"query",text:`query SpanToDatasetExampleDialogQuery(
  $spanId: GlobalID!
) {
  span: node(id: $spanId) {
    __typename
    ... on Span {
      revision: asExampleRevision {
        input
        output
        metadata
      }
    }
    __isNode: __typename
    id
  }
  ...DatasetPicker__datasets
}

fragment DatasetPicker__datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}}}();Ft.hash="5afd1a4eede339492f5473ed17b770b3";const Kt={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetPickerRefetchQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetPicker__datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetPickerRefetchQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"38a431d0ba6fa8c12622a1cbb3d1e446",id:null,metadata:{},name:"DatasetPickerRefetchQuery",operationKind:"query",text:`query DatasetPickerRefetchQuery {
  ...DatasetPicker__datasets
}

fragment DatasetPicker__datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};Kt.hash="03d88d1706089bb63edcd44d04563cbc";const xt={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:[],operation:Kt}},name:"DatasetPicker__datasets",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null};xt.hash="03d88d1706089bb63edcd44d04563cbc";function Wo(n){const[a,l]=_.useRefetchableFragment(xt,n.query);return s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(fl,{label:"dataset","data-testid":"dataset-picker",className:"dataset-picker",width:"100%","aria-label":"The dataset to add the example to",onSelectionChange:n.onSelectionChange,placeholder:"Select a dataset",onBlur:n.onBlur,isRequired:!0,validationState:n.validationState,errorMessage:n.errorMessage,children:a.datasets.edges.map(({dataset:t})=>e(H,{children:t.name},t.id))}),e(Uo,{onDatasetCreated:()=>{u.startTransition(()=>{l({},{fetchPolicy:"store-and-network"})})}})]})}function Uo({onDatasetCreated:n}){const[a,l]=u.useState(null),[t,i]=u.useState(!1),r=ve();return s(dn,{placement:"bottom right",isOpen:t,onOpenChange:o=>{l(null),i(o)},children:[e(z,{variant:"default",icon:e(M,{svg:e(P.PlusCircleOutline,{})}),"aria-label":"Create a new dataset"}),e(Q,{title:"Create New Dataset",bodyStyle:{padding:0},variant:"compact",borderColor:"light",backgroundColor:"light",children:s(T,{width:"500px",children:[a?e(ne,{variant:"danger",children:a}):null,e(Ca,{onDatasetCreateError:o=>l(o.message),onDatasetCreated:({id:o,name:c})=>{l(null),i(!1),r({title:"Dataset Created",message:`Dataset "${c}" created successfully`}),n(o)}})]})})]})}const ya={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function Jo({spanId:n,onCompleted:a}){const[l,t]=u.useState(null),i=_.useLazyLoadQuery(Ft,{spanId:n},{fetchPolicy:"store-and-network"}),{span:{revision:r}}=i,[o,c]=_.useMutation(vt),{control:d,setError:m,handleSubmit:y,formState:{isValid:g}}=bn({defaultValues:{input:JSON.stringify(r==null?void 0:r.input,null,2),output:JSON.stringify(r==null?void 0:r.output,null,2),metadata:JSON.stringify(r==null?void 0:r.metadata,null,2),datasetId:""}}),p=u.useCallback(f=>{if(t(null),!Ee(f==null?void 0:f.input))return m("input",{message:"Input must be a valid JSON object"});if(!Ee(f==null?void 0:f.output))return m("output",{message:"Output must be a valid JSON object"});if(!Ee(f==null?void 0:f.metadata))return m("metadata",{message:"Metadata must be a valid JSON object"});if(!(f!=null&&f.datasetId))return m("datasetId",{message:"Dataset is required"});o({variables:{input:{datasetId:f.datasetId,examples:[{input:JSON.parse(f.input),output:JSON.parse(f.output),metadata:JSON.parse(f.metadata),spanId:n}]}},onCompleted:()=>{a(f.datasetId)},onError:k=>{t(k.message)}})},[o,m,n,a]);return e(G,{size:"fullscreen",title:"Add Example to Dataset",extra:e(z,{variant:"primary",size:"compact",disabled:!g||c,loading:c,onClick:y(p),icon:e(M,{svg:e(P.PlusCircleOutline,{})}),children:"Add Example"}),children:e("div",{css:K`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
          /* Make widths configurable */
          .dataset-picker {
            width: 100%;
            .ac-dropdown--picker,
            .ac-dropdown-button {
              width: 100%;
            }
          }
        `,children:e(b,{direction:"row",justifyContent:"center",children:e(T,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(b,{direction:"column",gap:"size-200",children:[l?e(ne,{variant:"danger",children:l}):null,e(U,{control:d,name:"datasetId",render:({field:{onChange:f,onBlur:k},fieldState:{invalid:S,error:h}})=>e(Wo,{onSelectionChange:f,onBlur:k,validationState:S?"invalid":"valid",errorMessage:h==null?void 0:h.message,query:i})}),e(U,{control:d,name:"input",render:({field:{onChange:f,onBlur:k,value:S},fieldState:{invalid:h,error:F}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...ya,children:[h?e(ne,{variant:"danger",banner:!0,children:F==null?void 0:F.message}):null,e(_e,{value:S,onChange:f,onBlur:k})]})}),e(U,{control:d,name:"output",render:({field:{onChange:f,onBlur:k,value:S},fieldState:{invalid:h,error:F}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...ya,backgroundColor:"green-100",borderColor:"green-700",children:[h?e(ne,{variant:"danger",banner:!0,children:F==null?void 0:F.message}):null,e(_e,{value:S,onChange:f,onBlur:k})]})}),e(U,{control:d,name:"metadata",render:({field:{onChange:f,onBlur:k,value:S},fieldState:{invalid:h,error:F}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...ya,children:[h?e(ne,{variant:"danger",banner:!0,children:F==null?void 0:F.message}):null,e(_e,{value:S,onChange:f,onBlur:k})]})})]})})})})})}const Xo=n=>u.useMemo(()=>{try{return{json:JSON.parse(n)}}catch(a){return{json:null,parseError:a}}},[n]),Yo=n=>n.events.some(a=>a.name==="exception"),Z={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0};function Zo({spanNodeId:n,projectId:a}){const{span:l}=_.useLazyLoadQuery(ut,{spanId:n});if(l.__typename!=="Span")throw new Error("Expected a span, but got a different type"+l.__typename);const t=u.useMemo(()=>Yo(l),[l]),i=fs("annotations");return s(b,{direction:"column",flex:"1 1 auto",height:"100%",children:[e(T,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-150",paddingEnd:"size-200",flex:"none",children:s(b,{direction:"row",gap:"size-200",justifyContent:"space-between",alignItems:"center",children:[e(_r,{...l}),s(b,{flex:"none",direction:"row",alignItems:"center",gap:"size-100",children:[e(Bo,{traceId:l.context.traceId,spanId:l.context.spanId}),e(ed,{span:l}),i?e(qo,{spanNodeId:l.id,projectId:a}):null]})]})}),s(he,{children:[e(q,{name:"Info",children:e(nd,{span:l})}),e(q,{name:"Evaluations",extra:e(Ae,{variant:"light",children:l.spanEvaluations.length}),children:r=>r?e(hd,{span:l}):null}),e(q,{name:"Attributes",title:"Attributes",children:e(T,{padding:"size-200",children:e(Q,{title:"All Attributes",...Z,titleExtra:Dt,extra:e(Y,{text:l.attributes}),bodyStyle:{padding:0},children:e(Ve,{children:l.attributes})})})}),e(q,{name:"Events",extra:e(Ae,{variant:t?"danger":"light",children:l.events.length}),children:e(fd,{events:l.events})})]})]})}function ed({span:n}){const[a,l]=u.useState(null),t=ve(),i=ae(),r=u.useCallback(()=>{l(e(Jo,{spanId:n.id,onCompleted:o=>{l(null),t({title:"Span Added to Dataset",message:"Successfully added span to dataset",action:{text:"View Dataset",onClick:()=>{i(`/datasets/${o}/examples`)}}})}}))},[n.id,t,i]);return s(B,{children:[e(z,{variant:"default",icon:e(M,{svg:e(P.DatabaseOutline,{})}),onClick:r,children:"Add to Dataset"}),e(u.Suspense,{children:e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>l(null),children:a})})]})}function nd({span:n}){const{spanKind:a,attributes:l}=n,{json:t,parseError:i}=Xo(l),r=u.useMemo(()=>n.statusMessage?e(ne,{variant:"danger",title:"Status Description",children:n.statusMessage}):null,[n]);if(i||!t)return e(T,{padding:"size-200",children:s(b,{direction:"column",gap:"size-200",children:[r,e(ne,{variant:"warning",title:"Un-parsable attributes",children:`Failed to parse span attributes. ${i instanceof Error?i.message:""}`}),e(Q,{...Z,title:"Attributes",children:e(T,{padding:"size-100",children:l})})]})});let o;switch(a){case"llm":{o=e(ad,{span:n,spanAttributes:t});break}case"retriever":{o=e(ld,{span:n,spanAttributes:t});break}case"reranker":{o=e(td,{span:n,spanAttributes:t});break}case"embedding":{o=e(id,{span:n,spanAttributes:t});break}case"tool":{o=e(rd,{span:n,spanAttributes:t});break}default:o=e(gd,{span:n})}return e(T,{padding:"size-200",children:s(b,{direction:"column",gap:"size-200",children:[r,o,t!=null&&t.metadata?e(Q,{...Z,title:"Metadata",children:e(Ve,{children:JSON.stringify(t.metadata)})}):null]})})}function ad(n){const{spanAttributes:a,span:l}=n,{input:t,output:i}=l,r=u.useMemo(()=>a[de.llm]||null,[a]),o=u.useMemo(()=>{if(r==null)return null;const C=r[cn.model_name];return typeof C=="string"?C:null},[r]),c=u.useMemo(()=>{var C;return r==null?[]:((C=r[cn.input_messages])==null?void 0:C.map(v=>v[de.message]).filter(Boolean))||[]},[r]),d=u.useMemo(()=>{var C;return r==null?[]:((C=r[cn.output_messages])==null?void 0:C.map(v=>v[de.message]).filter(Boolean))||[]},[r]),m=u.useMemo(()=>{if(r==null)return[];const C=r[cn.prompts];return Rr(C)?C:[]},[r]),y=u.useMemo(()=>{if(r==null)return null;const C=r[cn.prompt_template];return C??null},[r]),g=u.useMemo(()=>r==null?"{}":r[cn.invocation_parameters]||"{}",[r]),p=u.useMemo(()=>o==null?null:s(b,{direction:"row",gap:"size-100",alignItems:"center",children:[e(wr,{spanKind:"llm"}),e(x,{textSize:"large",weight:"heavy",children:o})]}),[o]),f=t!=null&&t.value!=null,k=c.length>0,S=i!=null&&i.value!=null,h=d.length>0,F=m.length>0,L=Object.keys(JSON.parse(g)).length>0,I=y!=null;return s(b,{direction:"column",gap:"size-200",children:[e(Q,{collapsible:!0,backgroundColor:"light",borderColor:"light",bodyStyle:{padding:0},titleSeparator:!1,variant:"compact",title:p,children:s(he,{children:[k?e(q,{name:"Input Messages",hidden:!k,children:e(Ha,{messages:c})}):null,f?e(q,{name:"Input",hidden:!f,children:e(T,{padding:"size-200",children:e(fe,{children:e(Q,{...Z,title:"LLM Input",extra:s(b,{direction:"row",gap:"size-100",children:[e(Re,{}),e(Y,{text:t.value})]}),children:e(ze,{...t})})})})}):null,I?e(q,{name:"Prompt Template",hidden:!I,children:e(T,{padding:"size-200",children:s(b,{direction:"column",gap:"size-100",children:[e(T,{borderRadius:"medium",borderColor:"light",backgroundColor:"light",borderWidth:"thin",padding:"size-200",children:s(Wn,{text:y.template,children:[e(x,{color:"text-700",fontStyle:"italic",children:"prompt template"}),e(Tt,{children:y.template})]})}),e(T,{borderRadius:"medium",borderColor:"light",backgroundColor:"light",borderWidth:"thin",padding:"size-200",children:s(Wn,{text:JSON.stringify(y.variables),children:[e(x,{color:"text-700",fontStyle:"italic",children:"template variables"}),e(Ve,{children:JSON.stringify(y.variables)})]})})]})})}):null,e(q,{name:"Prompts",hidden:!F,children:e(dd,{prompts:m})}),e(q,{name:"Invocation Params",hidden:!L,children:e(Wn,{text:g,padding:"size-100",children:e(Ve,{children:g})})})]})}),S||h?e(yl,{...Z,children:s(he,{children:[h?e(q,{name:"Output Messages",hidden:!h,children:e(Ha,{messages:d})}):null,S?e(q,{name:"Output",hidden:!S,children:e(T,{padding:"size-200",children:e(fe,{children:e(Q,{...Z,title:"LLM Output",extra:s(b,{direction:"row",gap:"size-100",children:[e(Re,{}),e(Y,{text:i.value})]}),children:e(ze,{...i})})})})}):null]})}):null]})}function ld(n){const{spanAttributes:a,span:l}=n,{input:t}=l,i=u.useMemo(()=>a[de.retrieval]||null,[a]),r=u.useMemo(()=>{var y;return i==null?[]:((y=i[Xi.documents])==null?void 0:y.map(g=>g[de.document]).filter(Boolean))||[]},[i]),o=u.useMemo(()=>l.documentEvaluations.reduce((g,p)=>{const f=p.documentPosition,k=g[f]||[];return{...g,[f]:[...k,p]}},{}),[l.documentEvaluations]),c=t!=null&&t.value!=null,d=r.length>0,m=l.documentRetrievalMetrics.length>0;return s(b,{direction:"column",gap:"size-200",children:[c?e(fe,{children:e(Q,{title:"Input",...Z,extra:s(b,{direction:"row",gap:"size-100",children:[e(Re,{}),e(Y,{text:t.value})]}),children:e(ze,{...t})})}):null,d?e(fe,{children:e(Q,{title:"Documents",...Z,titleExtra:m&&e(b,{direction:"row",alignItems:"center",gap:"size-100",children:l.documentRetrievalMetrics.map(y=>s(B,{children:[e(ce,{name:y.evaluationName,metric:"ndcg",score:y.ndcg},"ndcg"),e(ce,{name:y.evaluationName,metric:"precision",score:y.precision},"precision"),e(ce,{name:y.evaluationName,metric:"hit",score:y.hit},"hit")]}))}),extra:e(Re,{}),children:e("ul",{css:K`
                display: flex;
                flex-direction: column;
                gap: var(--ac-global-dimension-static-size-200);
              `,children:r.map((y,g)=>e("li",{children:e(Fa,{document:y,documentEvaluations:o[g],borderColor:"seafoam-700",backgroundColor:"seafoam-100",labelColor:"seafoam-1000"})},g))})})}):null]})}function td(n){const{spanAttributes:a}=n,l=u.useMemo(()=>a[de.reranker]||null,[a]),t=u.useMemo(()=>l==null?"":l[oa.query]||"",[l]),i=u.useMemo(()=>{var d;return l==null?[]:((d=l[oa.input_documents])==null?void 0:d.map(m=>m[de.document]).filter(Boolean))||[]},[l]),r=u.useMemo(()=>{var d;return l==null?[]:((d=l[oa.output_documents])==null?void 0:d.map(m=>m[de.document]).filter(Boolean))||[]},[l]),o=i.length,c=r.length;return s(b,{direction:"column",gap:"size-200",children:[e(fe,{children:e(Q,{title:"Query",...Z,children:e(zn,{children:t})})}),e(Q,{title:"Input Documents",titleExtra:e(Ae,{variant:"light",children:o}),...Z,defaultOpen:!1,children:e("ul",{css:K`
              padding: var(--ac-global-dimension-static-size-200);
              display: flex;
              flex-direction: column;
              gap: var(--ac-global-dimension-static-size-200);
            `,children:i.map((d,m)=>e("li",{children:e(Fa,{document:d,borderColor:"seafoam-700",backgroundColor:"seafoam-100",labelColor:"seafoam-1000"})},m))})}),e(Q,{title:"Output Documents",titleExtra:e(Ae,{variant:"light",children:c}),...Z,children:e("ul",{css:K`
              padding: var(--ac-global-dimension-static-size-200);
              display: flex;
              flex-direction: column;
              gap: var(--ac-global-dimension-static-size-200);
            `,children:r.map((d,m)=>e("li",{children:e(Fa,{document:d,borderColor:"celery-700",backgroundColor:"celery-100",labelColor:"celery-1000"})},m))})})]})}function id(n){const{spanAttributes:a}=n,l=u.useMemo(()=>a[de.embedding]||null,[a]),t=u.useMemo(()=>{var o;return l==null?[]:((o=l[da.embeddings])==null?void 0:o.map(c=>c[de.embedding]).filter(Boolean))||[]},[l]),i=t.length>0,r=l==null?void 0:l[da.model_name];return e(b,{direction:"column",gap:"size-200",children:i?e(Q,{title:"Embeddings"+(typeof r=="string"?`: ${r}`:""),...Z,children:e("ul",{css:K`
                display: flex;
                flex-direction: column;
                gap: var(--ac-global-dimension-static-size-200);
              `,children:t.map((o,c)=>e("li",{children:e(fe,{children:e(Q,{...Z,backgroundColor:"purple-100",borderColor:"purple-700",title:"Embedded Text",children:e(zn,{children:o[da.text]||""})})})},c))})}):null})}function rd(n){const{span:a,spanAttributes:l}=n,{input:t,output:i}=a,r=typeof(t==null?void 0:t.value)=="string",o=typeof(i==null?void 0:i.value)=="string",c=(t==null?void 0:t.mimeType)==="text",d=(i==null?void 0:i.mimeType)==="text",m=u.useMemo(()=>l[de.tool]||{},[l]),y=Object.keys(m).length>0,g=m[ca.name],p=m[ca.description],f=m[ca.parameters];return!r&&!o&&!y?null:s(b,{direction:"column",gap:"size-200",children:[r?e(fe,{children:e(Q,{title:"Input",...Z,extra:s(b,{direction:"row",gap:"size-100",children:[c?e(Re,{}):null,e(Y,{text:t.value})]}),children:e(ze,{...t})})}):null,o?e(fe,{children:e(Q,{title:"Output",...Z,backgroundColor:"green-100",borderColor:"green-700",extra:s(b,{direction:"row",gap:"size-100",children:[d?e(Re,{}):null,e(Y,{text:i.value})]}),children:e(ze,{...i})})}):null,y?e(Q,{title:"Tool"+(typeof g=="string"?`: ${g}`:""),...Z,children:s(b,{direction:"column",children:[p!=null?e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",backgroundColor:"light",children:s(b,{direction:"column",alignItems:"start",gap:"size-50",children:[e(x,{color:"text-700",fontStyle:"italic",children:"Description"}),e(x,{children:p})]})}):null,f!=null?e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",children:s(b,{direction:"column",alignItems:"start",width:"100%",children:[e(x,{color:"text-700",fontStyle:"italic",children:"Parameters"}),e(Ve,{children:JSON.stringify(f)})]})}):null]})}):null]})}const sd=["irrelevant","unrelated"];function Fa({document:n,documentEvaluations:a,backgroundColor:l,borderColor:t,labelColor:i}){const r=n[In.metadata],o=a&&a.length,c=n[In.content];return e(Q,{...Z,backgroundColor:l,borderColor:t,bodyStyle:{padding:0},title:s(b,{direction:"row",gap:"size-50",alignItems:"center",children:[e(M,{svg:e(P.FileOutline,{})}),s(oe,{level:4,children:["document ",n[In.id]]})]}),extra:typeof n[In.score]=="number"&&e(Ze,{color:i,children:`score ${Ta(n[In.score])}`}),children:s(b,{direction:"column",children:[c&&e(T,{padding:"size-200",children:e(zn,{children:c})}),r&&e(B,{children:e(T,{borderColor:t,borderTopWidth:"thin",children:e(Ve,{children:JSON.stringify(r)})})}),o&&e(T,{borderColor:t,borderTopWidth:"thin",padding:"size-200",children:s(b,{direction:"column",gap:"size-100",children:[e(oe,{level:3,weight:"heavy",children:"Evaluations"}),e("ul",{children:a.map((d,m)=>{const y=d.label&&sd.includes(d.label)?"danger":i;return e("li",{children:e(T,{padding:"size-200",borderWidth:"thin",borderColor:t,borderRadius:"medium",children:s(b,{direction:"column",gap:"size-50",children:[s(b,{direction:"row",gap:"size-100",children:[e(x,{weight:"heavy",elementType:"h5",children:d.name}),d.label&&e(Ze,{color:y,shape:"badge",children:d.label}),typeof d.score=="number"&&e(Ze,{color:y,shape:"badge",children:s(b,{direction:"row",gap:"size-50",children:[e(x,{textSize:"xsmall",weight:"heavy",color:"inherit",children:"score"}),e(x,{textSize:"xsmall",children:Ke(d.score)})]})})]}),typeof d.explanation&&e("p",{css:K`
                                margin-top: var(
                                  --ac-global-dimension-static-size-100
                                );
                                margin-bottom: 0;
                              `,children:d.explanation})]})})},m)})})]})})]})})}function od({message:n}){var c;const a=n[Fe.content],l=n[Fe.contents],t=((c=n[Fe.tool_calls])==null?void 0:c.map(d=>d[de.tool_call]).filter(Boolean))||[],i=n[Fe.function_call_arguments_json]&&n[Fe.function_call_name],r=n[Fe.role]||"unknown",o=u.useMemo(()=>r==="user"?{backgroundColor:"grey-100",borderColor:"grey-500"}:r==="assistant"?{backgroundColor:"blue-100",borderColor:"blue-700"}:r==="system"?{backgroundColor:"indigo-100",borderColor:"indigo-700"}:["function","tool"].includes(r)?{backgroundColor:"yellow-100",borderColor:"yellow-700"}:{backgroundColor:"grey-100",borderColor:"grey-700"},[r]);return e(fe,{children:s(Q,{...Z,...o,title:r+(n[Fe.name]?`: ${n[Fe.name]}`:""),extra:s(b,{direction:"row",gap:"size-100",children:[e(Re,{}),e(Y,{text:a||JSON.stringify(n)})]}),children:[e(Pr,{children:l?e(cd,{messageContents:l}):null}),s(b,{direction:"column",alignItems:"start",children:[a?e(zn,{children:a}):null,t.length>0?t.map((d,m)=>{var y,g;return s("pre",{css:K`
                      text-wrap: wrap;
                      margin: var(--ac-global-dimension-static-size-100) 0;
                    `,children:[(y=d==null?void 0:d.function)==null?void 0:y.name,"(",JSON.stringify(JSON.parse((g=d==null?void 0:d.function)==null?void 0:g.arguments),null,2),")"]},m)}):null,i?s("pre",{css:K`
                text-wrap: wrap;
                margin: var(--ac-global-dimension-static-size-100) 0;
              `,children:[n[Fe.function_call_name],"(",JSON.stringify(JSON.parse(n[Fe.function_call_arguments_json]),null,2),")"]}):null]})]})})}function Ha({messages:n}){return e("ul",{css:K`
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-static-size-100);
        padding: var(--ac-global-dimension-static-size-200);
      `,children:n.map((a,l)=>e("li",{children:e(od,{message:a})},l))})}function dd({prompts:n}){return e("ul",{"data-testid":"llm-prompts-list",css:K`
        padding: var(--ac-global-dimension-size-200);
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-size-100);
      `,children:n.map((a,l)=>e("li",{children:e(T,{backgroundColor:"gray-600",borderColor:"gray-400",borderWidth:"thin",borderRadius:"medium",padding:"size-100",children:e(Wn,{text:a,children:e(ze,{value:a,mimeType:"text"})})})},l))})}function cd({messageContents:n}){return e("ul",{css:K`
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-size-100);
      `,children:n.map((a,l)=>e("li",{children:e(md,{messageContentAttribute:a})},l))})}const ud=K`
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
`;function md({messageContentAttribute:n}){var r;const{message_content:a}=n,l=a==null?void 0:a.text,t=a==null?void 0:a.image,i=(r=t==null?void 0:t.image)==null?void 0:r.url;return s(b,{direction:"column",children:[l?e("pre",{css:K`
            white-space: pre-wrap;
            padding: 0;
            margin: 0;
          `,children:l}):null,i?e("img",{src:i,css:ud}):null]})}function gd({span:n}){const{input:a,output:l}=n,t=a==null&&l==null,i=(a==null?void 0:a.mimeType)==="text",r=(l==null?void 0:l.mimeType)==="text";return s(b,{direction:"column",gap:"size-200",children:[a&&a.value!=null?e(fe,{children:e(Q,{title:"Input",...Z,extra:s(b,{direction:"row",gap:"size-100",children:[i?e(Re,{}):null,e(Y,{text:a.value})]}),children:e(ze,{...a})})}):null,l&&l.value!=null?e(fe,{children:e(Q,{title:"Output",...Z,backgroundColor:"green-100",borderColor:"green-700",extra:s(b,{direction:"row",gap:"size-100",children:[r?e(Re,{}):null,e(Y,{text:l.value})]}),children:e(ze,{...l})})}):null,t?e(Q,{title:"All Attributes",titleExtra:Dt,...Z,bodyStyle:{padding:0},extra:e(Y,{text:n.attributes}),children:e(Ve,{children:n.attributes})}):null]})}const pd=K`
  .cm-content {
    padding: var(--ac-global-dimension-static-size-200) 0;
  }
  .cm-editor,
  .cm-gutters {
    background-color: transparent;
  }
`;function Wn({text:n,children:a,padding:l}){const t=l?`var(--ac-global-dimension-${l})`:"0";return s("div",{css:K`
        position: relative;
        .copy-to-clipboard-button {
          transition: opacity 0.2s ease-in-out;
          opacity: 0;
          position: absolute;
          right: ${t};
          top: ${t};
          z-index: 1;
        }
        &:hover .copy-to-clipboard-button {
          opacity: 1;
        }
      `,children:[e(Y,{text:n}),a]})}function Ve({children:n}){const{theme:a}=$n(),l=a==="light"?void 0:sa,{value:t,mimeType:i}=u.useMemo(()=>{try{return{value:JSON.stringify(JSON.parse(n),null,2),mimeType:"json"}}catch{return{value:n,mimeType:"text"}}},[n]);return i==="json"?e(ra,{value:t,basicSetup:{lineNumbers:!0,foldGutter:!0,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1},extensions:[us(),ms.lineWrapping],editable:!1,theme:l,css:pd}):e(Tt,{children:t})}function Tt({children:n}){return e("pre",{css:K`
        white-space: pre-wrap;
        padding: 0;
      `,children:n})}function ze({value:n,mimeType:a}){let l;switch(a){case"json":l=e(Ve,{children:n});break;case"text":l=e(zn,{children:n});break;default:ge()}return l}function yd({text:n}){return s(b,{direction:"column",alignItems:"center",flex:"1 1 auto",height:"size-2400",justifyContent:"center",gap:"size-100",children:[e(Ra,{graphicKey:"documents"}),e(x,{children:n})]})}function fd({events:n}){return n.length===0?e(yd,{text:"No events"}):e(Sl,{children:n.map((a,l)=>{const t=a.name==="exception";return e(bl,{children:s(b,{direction:"row",alignItems:"center",gap:"size-100",children:[e(T,{flex:"none",children:e("div",{"data-event-type":t?"exception":"info",css:i=>K`
                    &[data-event-type="exception"] {
                      --px-event-icon-color: ${i.colors.statusDanger};
                    }
                    &[data-event-type="info"] {
                      --px-event-icon-color: ${i.colors.statusInfo};
                    }
                    .ac-icon-wrap {
                      color: var(--px-event-icon-color);
                    }
                  `,children:e(M,{svg:t?e(P.AlertTriangleOutline,{}):e(P.InfoOutline,{})})})}),s(b,{direction:"column",gap:"size-25",flex:"1 1 auto",children:[e(x,{weight:"heavy",children:a.name}),e(x,{color:"text-700",children:a.message})]}),e(T,{children:e(x,{color:"text-700",children:new Date(a.timestamp).toLocaleString()})})]})},l)})})}function hd(n){return e(Go,{span:n.span})}const Dt=e(b,{alignItems:"center",justifyContent:"center",children:e(T,{marginStart:"size-100",children:s(aa,{children:[e(oe,{weight:"heavy",level:4,children:"Span Attributes"}),e(na,{children:e(x,{children:"Attributes are key-value pairs that represent metadata associated with a span. For detailed descriptions of specific attributes, consult the semantic conventions section of the OpenInference tracing specification."})}),e("footer",{children:e(Rn,{href:"https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md",children:"Semantic Conventions"})})]})})}),Ga="selectedSpanNodeId";function kd(n){const a=n.find(i=>i.parentId==null);if(a)return a;const l=new Set(n.map(i=>i.context.spanId)),t=n.filter(i=>i.parentId!=null&&!l.has(i.parentId));return t.length===1?t[0]:null}function Ct(n){const{traceId:a,projectId:l}=n,[t,i]=nl(),r=_.useLazyLoadQuery(dt,{traceId:a,id:l},{fetchPolicy:"store-and-network"}),o=u.useMemo(()=>{var g;return(((g=r.project.trace)==null?void 0:g.spans.edges)||[]).map(p=>p.span)},[r]),d=t.get(Ga)??o[0].id,m=u.useMemo(()=>kd(o),[o]);return u.useEffect(()=>()=>{i(y=>(y.delete("spanNodeId"),y),{replace:!0})},[]),s("main",{css:K`
        flex: 1 1 auto;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      `,children:[e(bd,{rootSpan:m}),s(an,{direction:"horizontal",autoSaveId:"trace-panel-group",css:K`
          flex: 1 1 auto;
          overflow: hidden;
        `,children:[e(se,{defaultSize:30,minSize:10,maxSize:40,children:e(vd,{children:e(Mr,{spans:o,selectedSpanNodeId:d,onSpanClick:y=>{i(g=>(g.set(Ga,y.id),g),{replace:!0})}})})}),e(ln,{css:Kn}),e(se,{children:e(Sd,{children:d?e(u.Suspense,{fallback:e(ue,{}),children:e(Zo,{spanNodeId:d,projectId:l})}):null})})]})]})}function bd({rootSpan:n}){const{latencyMs:a,statusCode:l,spanEvaluations:t}=n??{latencyMs:null,statusCode:"UNSET",spanEvaluations:[]},i=t.length>0,r=Nr(l);return e(T,{padding:"size-200",borderBottomWidth:"thin",borderBottomColor:"dark",children:s(b,{direction:"row",gap:"size-400",children:[s(b,{direction:"column",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Trace Status"}),e(x,{textSize:"xlarge",children:s(b,{direction:"row",gap:"size-50",alignItems:"center",children:[e(Ia,{statusCode:l}),e(x,{textSize:"xlarge",color:r,children:l})]})})]}),s(b,{direction:"column",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency"}),e(x,{textSize:"xlarge",children:typeof a=="number"?e(we,{latencyMs:a,textSize:"xlarge"}):"--"})]}),i?s(b,{direction:"column",gap:"size-50",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Evaluations"}),e(b,{direction:"row",gap:"size-50",children:t.map(o=>e(Na,{evaluation:o},o.name))})]}):null]})})}function Sd({children:n}){return e("div",{"data-testid":"scrolling-tabs-wrapper",css:K`
        height: 100%;
        overflow: hidden;
        .ac-tabs {
          height: 100%;
          overflow: hidden;
          .ac-tabs__pane-container {
            height: 100%;
            overflow-y: auto;
          }
        }
      `,children:n})}function vd({children:n}){return e("div",{"data-testid":"scrolling-panel-content",css:K`
        height: 100%;
        overflow-y: auto;
      `,children:n})}function hu(){const{traceId:n,projectId:a}=Oe(),l=ae();return e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>l(`/projects/${a}`),children:e(G,{size:"fullscreen",title:"Trace Details",children:e(Ct,{traceId:n,projectId:a})})})}const It=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},i={kind:"Literal",name:"first",value:100},r={kind:"Literal",name:"sort",value:{col:"startTime",dir:"desc"}},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[i,r,o],d={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},m={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},y={alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},g={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},f={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},k=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],S={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:k,storageKey:null},h={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:k,storageKey:null},F={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[m,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},L={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},I={alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},C={alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null},v={alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null},D=[i,{kind:"Literal",name:"rootSpansOnly",value:!0},r,o],N={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},R={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},O=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],j=[o];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectPageQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"SpansTable_spans"},{args:null,kind:"FragmentSpread",name:"TracesTable_spans"},{args:null,kind:"FragmentSpread",name:"ProjectPageHeader_stats"},{args:null,kind:"FragmentSpread",name:"StreamToggle_data"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectPageQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:c,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[t,d,m,y,{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},g,p,{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},f,S,h,F,L],storageKey:null},I,C],storageKey:null},v],storageKey:null},{alias:null,args:c,filters:["sort","filterCondition","timeRange"],handle:"connection",key:"SpansTable_spans",kind:"LinkedHandle",name:"spans"},{alias:"rootSpans",args:D,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[t,d,m,y,N,g,p,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},R,S,h,f,F,L,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[t,d,m,N,g,p,R,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:O,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:O,storageKey:null},f,F,L],storageKey:null}],storageKey:null},I,C],storageKey:null},v],storageKey:null},{alias:"rootSpans",args:D,filters:["sort","rootSpansOnly","filterCondition","timeRange"],handle:"connection",key:"TracesTable_rootSpans",kind:"LinkedHandle",name:"spans"},{alias:null,args:j,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:j,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},o],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},o],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"f91a1a2f14ed08ee58a7f39925bac3c8",id:null,metadata:{},name:"ProjectPageQuery",operationKind:"query",text:`query ProjectPageQuery(
  $id: GlobalID!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...SpansTable_spans
    ...TracesTable_spans
    ...ProjectPageHeader_stats
    ...StreamToggle_data
    __isNode: __typename
    id
  }
}

fragment ProjectPageHeader_stats on Project {
  traceCount(timeRange: $timeRange)
  tokenCountTotal(timeRange: $timeRange)
  latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
  latencyMsP99: latencyMsQuantile(probability: 0.99, timeRange: $timeRange)
  spanEvaluationNames
  documentEvaluationNames
  id
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment SpansTable_spans on Project {
  ...SpanColumnSelector_evaluations
  spans(first: 100, sort: {col: startTime, dir: desc}, timeRange: $timeRange) {
    edges {
      span: node {
        id
        spanKind
        name
        metadata
        statusCode
        startTime
        latencyMs
        tokenCountTotal
        tokenCountPrompt
        tokenCountCompletion
        context {
          spanId
          traceId
        }
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}

fragment StreamToggle_data on Project {
  streamingLastUpdatedAt
  id
}

fragment TracesTable_spans on Project {
  ...SpanColumnSelector_evaluations
  rootSpans: spans(first: 100, sort: {col: startTime, dir: desc}, rootSpansOnly: true, timeRange: $timeRange) {
    edges {
      rootSpan: node {
        id
        spanKind
        name
        metadata
        statusCode: propagatedStatusCode
        startTime
        latencyMs
        cumulativeTokenCountTotal
        cumulativeTokenCountPrompt
        cumulativeTokenCountCompletion
        parentId
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        context {
          spanId
          traceId
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
        descendants {
          id
          spanKind
          name
          statusCode: propagatedStatusCode
          startTime
          latencyMs
          parentId
          cumulativeTokenCountTotal: tokenCountTotal
          cumulativeTokenCountPrompt: tokenCountPrompt
          cumulativeTokenCountCompletion: tokenCountCompletion
          input {
            value
          }
          output {
            value
          }
          context {
            spanId
            traceId
          }
          spanEvaluations {
            name
            label
            score
          }
          documentRetrievalMetrics {
            evaluationName
            ndcg
            precision
            hit
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();It.hash="c1b22588515ba56f88b7ea8ed8bb12fa";const Lt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"id"},a={defaultValue:null,kind:"LocalArgument",name:"timeRange"},l=[{kind:"Variable",name:"id",variableName:"id"}],t={kind:"Variable",name:"timeRange",variableName:"timeRange"},i=[t];return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ProjectPageHeaderQuery",selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"ProjectPageHeader_stats"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ProjectPageHeaderQuery",selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:i,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},t],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},t],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"b55d98cce8db8be868e94c1b1dd649af",id:null,metadata:{},name:"ProjectPageHeaderQuery",operationKind:"query",text:`query ProjectPageHeaderQuery(
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ProjectPageHeader_stats
    __isNode: __typename
    id
  }
}

fragment ProjectPageHeader_stats on Project {
  traceCount(timeRange: $timeRange)
  tokenCountTotal(timeRange: $timeRange)
  latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
  latencyMsP99: latencyMsQuantile(probability: 0.99, timeRange: $timeRange)
  spanEvaluationNames
  documentEvaluationNames
  id
}
`}}}();Lt.hash="22a98df993a4375f85851e92f6844c09";const Et=function(){var n={kind:"Variable",name:"timeRange",variableName:"timeRange"},a=[n];return{argumentDefinitions:[{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:Lt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ProjectPageHeader_stats",selections:[{alias:null,args:a,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:a,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},n],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},n],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null}}();Et.hash="22a98df993a4375f85851e92f6844c09";const _t=u.createContext(null);function Cn(){const n=ke.useContext(_t);if(n===null)throw new Error("useStreamState must be used within a StreamStateProvider");return n}function Fd({initialFetchKey:n="initial",children:a}){const[l,t]=u.useState(!0),[i,r]=u.useState(n),o=u.useCallback(c=>{u.startTransition(()=>{r(c)})},[r]);return e(_t.Provider,{value:{isStreaming:l,setIsStreaming:t,fetchKey:i,setFetchKey:o},children:a})}const Rt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DocumentEvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"DocumentEvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DocumentEvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"60d7798d88e1408e6b6b0bebdc1716f5",id:null,metadata:{},name:"DocumentEvaluationSummaryValueQuery",operationKind:"query",text:`query DocumentEvaluationSummaryValueQuery(
  $evaluationName: String!
  $timeRange: TimeRange!
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...DocumentEvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment DocumentEvaluationSummaryValueFragment_1dJL9N on Project {
  documentEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    averageNdcg
    averagePrecision
    meanReciprocalRank
    hitRate
  }
  id
}
`}}}();Rt.hash="15d0652aa260c80f62acec943f615d93";const wt={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:Rt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"DocumentEvaluationSummaryValueFragment",selections:[{alias:null,args:[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};wt.hash="15d0652aa260c80f62acec943f615d93";const Pt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"id"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DocumentEvaluationSummaryQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"DocumentEvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DocumentEvaluationSummaryQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"3ebd1cf66ef8f31c995ec6aae6505e94",id:null,metadata:{},name:"DocumentEvaluationSummaryQuery",operationKind:"query",text:`query DocumentEvaluationSummaryQuery(
  $evaluationName: String!
  $id: GlobalID!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...DocumentEvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment DocumentEvaluationSummaryValueFragment_1dJL9N on Project {
  documentEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    averageNdcg
    averagePrecision
    meanReciprocalRank
    hitRate
  }
  id
}
`}}}();Pt.hash="4d50474ffa9b9e4a68d07f6e0777c144";function Kd({evaluationName:n}){const{projectId:a}=Oe(),{timeRange:l}=Yn(),t=_.useLazyLoadQuery(Pt,{id:a,evaluationName:n,timeRange:{start:l.start.toISOString(),end:l.end.toISOString()}});return s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:n}),e(u.Suspense,{fallback:e(x,{textSize:"xlarge",children:"--"}),children:e(xd,{evaluationName:n,project:t==null?void 0:t.project})})]})}function xd(n){var m,y,g,p;const{project:a}=n,{fetchKey:l}=Cn(),[t,i]=_.useRefetchableFragment(wt,a);u.useEffect(()=>{u.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=(m=t==null?void 0:t.documentEvaluationSummary)==null?void 0:m.averageNdcg,o=(y=t==null?void 0:t.documentEvaluationSummary)==null?void 0:y.averagePrecision,c=(g=t==null?void 0:t.documentEvaluationSummary)==null?void 0:g.hitRate,d=(p=t==null?void 0:t.documentEvaluationSummary)==null?void 0:p.meanReciprocalRank;return s(pe,{delay:0,placement:"bottom",children:[e($e,{children:e(b,{direction:"row",alignItems:"center",gap:"size-50",height:"28px",children:s(B,{children:[e(ce,{metric:"ndcg",score:r},"ndcg"),e(ce,{metric:"precision",score:o},"precision"),e(ce,{metric:"hit rate",score:c},"hit")]})})}),e(ta,{children:e(T,{width:"size-2400",children:s(b,{direction:"column",children:[s(b,{justifyContent:"space-between",children:[e(x,{children:"average ndcg"}),e(x,{children:typeof r=="number"?Ke(r):"--"})]}),s(b,{justifyContent:"space-between",children:[e(x,{children:"average precision"}),e(x,{children:typeof o=="number"?Ke(o):"--"})]}),s(b,{justifyContent:"space-between",children:[e(x,{children:"mean reciprocal rank"}),e(x,{children:typeof d=="number"?Ke(d):"--"})]}),s(b,{justifyContent:"space-between",children:[e(x,{children:"hit rate"}),e(x,{children:typeof c=="number"?Ke(c):"--"})]})]})})})]})}const Mt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"EvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"EvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"EvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"99465624550be40aec8146116c3a223b",id:null,metadata:{},name:"EvaluationSummaryValueQuery",operationKind:"query",text:`query EvaluationSummaryValueQuery(
  $evaluationName: String!
  $timeRange: TimeRange!
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...EvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment EvaluationSummaryValueFragment_1dJL9N on Project {
  spanEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    labelFractions {
      label
      fraction
    }
    meanScore
  }
  id
}
`}}}();Mt.hash="ba0ee13567d5484ec0697c50e1a77bfa";const Nt={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:Mt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"EvaluationSummaryValueFragment",selections:[{alias:null,args:[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};Nt.hash="ba0ee13567d5484ec0697c50e1a77bfa";const At=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"EvaluationSummaryQuery",selections:[{alias:"project",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"EvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n,l],kind:"Operation",name:"EvaluationSummaryQuery",selections:[{alias:"project",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"df512af7fecec8c6f2731f53f703b0f4",id:null,metadata:{},name:"EvaluationSummaryQuery",operationKind:"query",text:`query EvaluationSummaryQuery(
  $id: GlobalID!
  $evaluationName: String!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...EvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment EvaluationSummaryValueFragment_1dJL9N on Project {
  spanEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    labelFractions {
      label
      fraction
    }
    meanScore
  }
  id
}
`}}}();At.hash="6947c95234456d6fef0b4f148b6ae42c";function Td({evaluationName:n}){const{projectId:a}=Oe(),{timeRange:l}=Yn(),t=_.useLazyLoadQuery(At,{evaluationName:n,id:a,timeRange:{start:l.start.toISOString(),end:l.end.toISOString()}});return s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:n}),e(u.Suspense,{fallback:e(x,{textSize:"xlarge",children:"--"}),children:e(Dd,{evaluationName:n,project:t.project})})]})}function Dd(n){var g,p;const{project:a}=n,{fetchKey:l}=Cn(),[t,i]=_.useRefetchableFragment(Nt,a);u.useEffect(()=>{u.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=Me(),o=[r.default,r.gray600,r.gray400,r.gray200],c=(g=t==null?void 0:t.spanEvaluationSummary)==null?void 0:g.meanScore,d=(p=t==null?void 0:t.spanEvaluationSummary)==null?void 0:p.labelFractions,m=typeof c=="number",y=Array.isArray(d)&&d.length>0;return s(pe,{delay:0,placement:"bottom",children:[e($e,{children:s(b,{direction:"row",alignItems:"center",gap:"size-50",children:[y?e(os,{width:24,height:24,children:e(ds,{data:d,dataKey:"fraction",nameKey:"label",cx:"50%",cy:"50%",innerRadius:8,outerRadius:11,strokeWidth:0,stroke:"transparent",children:d.map((f,k)=>e(cs,{fill:o[k%o.length]},`cell-${k}`))})}):null,e(x,{textSize:"xlarge",children:m?Ke(c):"--"})]})}),e(ta,{children:e(T,{width:"size-2400",children:s(b,{direction:"column",gap:"size-50",children:[y&&e("ul",{children:d.map((f,k)=>e("li",{children:e(te,{color:o[k%o.length],name:f.label,shape:"square",value:ml(f.fraction*100)})},f.label))}),y&&m?e(Xn,{}):null,m?s(b,{direction:"row",justifyContent:"space-between",children:[e(x,{children:"mean"}),e(x,{children:Ke(c)})]}):null]})})})]})}function Cd(n){const{extra:a}=n,{fetchKey:l}=Cn(),[t,i]=_.useRefetchableFragment(Et,n.project);u.useEffect(()=>{u.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=t==null?void 0:t.latencyMsP50,o=t==null?void 0:t.latencyMsP99,c=t==null?void 0:t.tokenCountTotal,d=t==null?void 0:t.spanEvaluationNames,m=t==null?void 0:t.documentEvaluationNames;return e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-200",paddingBottom:"size-50",flex:"none",children:s(b,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e("div",{css:K`
            overflow-x: auto;
            overflow-y: hidden;
            flex: 1 1 auto;
            background-image: linear-gradient(
                to right,
                var(--ac-global-color-grey-75),
                var(--ac-global-color-grey-75)
              ),
              linear-gradient(
                to right,
                var(--ac-global-color-grey-75),
                var(--ac-global-color-grey-75)
              ),
              linear-gradient(
                to right,
                rgba(var(--ac-global-color-grey-300-rgb), 0.9),
                rgba(var(--ac-global-color-grey-300-rgb), 0)
              ),
              linear-gradient(
                to left,
                rgba(var(--ac-global-color-grey-300-rgb), 0.9),
                rgba(var(--ac-global-color-grey-300-rgb), 0)
              );
            background-repeat: no-repeat;
            background-size:
              32px 100%,
              32px 100%,
              32px 100%,
              32px 100%;
            background-position:
              left center,
              right center,
              left center,
              right center;
            background-attachment: local, local, scroll, scroll;
          `,children:s(b,{direction:"row",gap:"size-400",alignItems:"center",children:[s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Traces"}),e(x,{textSize:"xlarge",children:tn(t==null?void 0:t.traceCount)})]}),s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Tokens"}),e(x,{textSize:"xlarge",children:tn(c)})]}),s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P50"}),r!=null?e(we,{latencyMs:r,textSize:"xlarge"}):e(x,{textSize:"xlarge",children:"--"})]}),s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P99"}),o!=null?e(we,{latencyMs:o,textSize:"xlarge"}):e(x,{textSize:"xlarge",children:"--"})]}),d.map(y=>e(Td,{evaluationName:y},y)),m.map(y=>e(Kd,{evaluationName:y},`document-${y}`))]})}),e(T,{flex:"none",paddingStart:"size-100",children:a})]})})}const $t=function(){var n={defaultValue:null,kind:"LocalArgument",name:"after"},a={defaultValue:null,kind:"LocalArgument",name:"filterCondition"},l={defaultValue:100,kind:"LocalArgument",name:"first"},t={defaultValue:null,kind:"LocalArgument",name:"id"},i={defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},r={defaultValue:null,kind:"LocalArgument",name:"timeRange"},o=[{kind:"Variable",name:"id",variableName:"id"}],c={kind:"Variable",name:"after",variableName:"after"},d={kind:"Variable",name:"filterCondition",variableName:"filterCondition"},m={kind:"Variable",name:"first",variableName:"first"},y={kind:"Variable",name:"sort",variableName:"sort"},g={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},f=[c,d,m,y,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],k={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},S=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l,t,i,r],kind:"Fragment",metadata:null,name:"SpansTableSpansQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:[c,d,m,y],kind:"FragmentSpread",name:"SpansTable_spans"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,a,l,i,r,t],kind:"Operation",name:"SpansTableSpansQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[g,{kind:"TypeDiscriminator",abstractKey:"__isNode"},p,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:f,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[p,{alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},k,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:S,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:S,storageKey:null},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[k,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[g],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:f,filters:["sort","filterCondition","timeRange"],handle:"connection",key:"SpansTable_spans",kind:"LinkedHandle",name:"spans"}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"2413f18f0d411113ca2ad6117d901511",id:null,metadata:{},name:"SpansTableSpansQuery",operationKind:"query",text:`query SpansTableSpansQuery(
  $after: String = null
  $filterCondition: String = null
  $first: Int = 100
  $sort: SpanSort = {col: startTime, dir: desc}
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...SpansTable_spans_1XEuU
    __isNode: __typename
    id
  }
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment SpansTable_spans_1XEuU on Project {
  ...SpanColumnSelector_evaluations
  spans(first: $first, after: $after, sort: $sort, filterCondition: $filterCondition, timeRange: $timeRange) {
    edges {
      span: node {
        id
        spanKind
        name
        metadata
        statusCode
        startTime
        latencyMs
        tokenCountTotal
        tokenCountPrompt
        tokenCountCompletion
        context {
          spanId
          traceId
        }
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();$t.hash="78738e3d457d0b4140c9bb4f4dc1180a";const Vt=function(){var n=["spans"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},t=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"filterCondition"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:$t,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"SpansTable_spans",selections:[{args:null,kind:"FragmentSpread",name:"SpanColumnSelector_evaluations"},{alias:"spans",args:[{kind:"Variable",name:"filterCondition",variableName:"filterCondition"},{kind:"Variable",name:"sort",variableName:"sort"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"SpanConnection",kind:"LinkedField",name:"__SpansTable_spans_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},l,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:t,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:t,storageKey:null},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Project",abstractKey:null}}();Vt.hash="78738e3d457d0b4140c9bb4f4dc1180a";const zt=u.createContext(null);function Id({children:n,...a}){const l=u.useRef();return l.current||(l.current=Ar(a)),e(zt.Provider,{value:l.current,children:n})}function Qe(n,a){const l=ke.useContext(zt);if(!l)throw new Error("Missing TracingContext.Provider in the tree");return al(l,n,a)}const Qt={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"SpanColumnSelector_evaluations",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null}],type:"Project",abstractKey:null};Qt.hash="b15c9caa847912fdb7b07a0c01a69ed9";const Ld=["spanKind","name"];function Ot(n){return e(wa,{menu:e(Ed,{...n}),triggerProps:{placement:"bottom end"},children:s(b,{direction:"row",alignItems:"center",gap:"size-100",children:[e(M,{svg:e(P.Column,{})}),"Columns"]})})}const Un=K`
  padding: var(--ac-global-dimension-static-size-50)
    var(--ac-global-dimension-static-size-100);
  label {
    display: flex;
    align-items: center;
    gap: var(--ac-global-dimension-static-size-100);
  }
`;function Ed(n){const{columns:a}=n,l=Qe(d=>d.columnVisibility),t=Qe(d=>d.setColumnVisibility),i=u.useMemo(()=>a.filter(d=>!Ld.includes(d.id)),[a]),r=u.useMemo(()=>i.every(d=>{const m=l[d.id];return m??!0}),[i,l]),o=u.useCallback(d=>{const{name:m,checked:y}=d.target;t({...l,[m]:y})},[l,t]),c=u.useCallback(d=>{const{checked:m}=d.target,y=i.reduce((g,p)=>({...g,[p.id]:m}),{});t(y)},[i,t]);return e("div",{css:K`
        overflow-y: auto;
        max-height: calc(100vh - 200px);
      `,children:s(T,{paddingTop:"size-50",paddingBottom:"size-50",children:[e(T,{borderBottomColor:"dark",borderBottomWidth:"thin",paddingBottom:"size-50",children:e("div",{css:Un,children:s("label",{children:[e("input",{type:"checkbox",name:"toggle-all",checked:r,onChange:c}),"span columns"]})})}),e("ul",{children:i.map(d=>{const m=l[d.id],y=m??!0,g=typeof d.columnDef.header=="string"?d.columnDef.header:d.id;return e("li",{css:Un,children:s("label",{children:[e("input",{type:"checkbox",name:d.id,checked:y,onChange:o}),g]})},d.id)})}),e(_d,{...n})]})})}function _d({query:n}){const a=_.useFragment(Qt,n),l=Qe(o=>o.evaluationVisibility),t=Qe(o=>o.setEvaluationVisibility),i=u.useMemo(()=>a.spanEvaluationNames.every(o=>l[o]||!1),[l,a.spanEvaluationNames]),r=u.useCallback(()=>{const o=a.spanEvaluationNames.reduce((c,d)=>({...c,[d]:!i}),{});t(o)},[t,i,a.spanEvaluationNames]);return s("section",{children:[e(T,{paddingTop:"size-50",paddingBottom:"size-50",borderColor:"dark",borderTopWidth:"thin",borderBottomWidth:"thin",children:e("div",{css:Un,children:s("label",{children:[e("input",{type:"checkbox",name:"toggle-evaluations-all",checked:i,onChange:r}),"evaluations"]})})}),e("ul",{children:a.spanEvaluationNames.map(o=>{const c=l[o];return e("li",{css:Un,children:s("label",{children:[e("input",{type:"checkbox",name:o,checked:c,onChange:()=>{t({...l,[o]:!c})}}),o]})},o)})})]})}const jt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"condition"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"condition",variableName:"condition"}],concreteType:"ValidationResult",kind:"LinkedField",name:"validateSpanFilterCondition",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"isValid",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorMessage",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanFilterConditionFieldValidationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanFilterConditionFieldValidationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}]},params:{cacheID:"29583e7ec666cef832dc7effb9e75678",id:null,metadata:{},name:"SpanFilterConditionFieldValidationQuery",operationKind:"query",text:`query SpanFilterConditionFieldValidationQuery(
  $condition: String!
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    ... on Project {
      validateSpanFilterCondition(condition: $condition) {
        isValid
        errorMessage
      }
    }
    __isNode: __typename
    id
  }
}
`}}}();jt.hash="22836f192038b0c40201d3b25aad65b4";const qt=K`
  flex: 1 1 auto;
  .cm-content {
    padding: var(--ac-global-dimension-static-size-100) 0;
  }
  .cm-editor {
    background-color: transparent;
  }
  .cm-focused {
    outline: none;
  }
  .cm-selectionLayer .cm-selectionBackground {
    background: var(--ac-global-color-cyan-400) !important;
  }
`,Bt=K`
  border-width: var(--ac-global-border-size-thin);
  border-style: solid;
  border-color: var(--ac-global-input-field-border-color);
  border-radius: var(--ac-global-rounding-small);
  background-color: var(--ac-global-input-field-background-color);
  transition: all 0.2s ease-in-out;
  overflow-x: hidden;
  &:hover,
  &[data-is-focused="true"] {
    border-color: var(--ac-global-input-field-border-color-active);
    background-color: var(--ac-global-input-field-background-color-active);
  }
  &[data-is-invalid="true"] {
    border-color: var(--ac-global-color-danger);
  }
  box-sizing: border-box;
`;function Rd(n){const a=n.matchBefore(/\w*/);return!a||a.from==a.to&&!n.explicit?null:{from:a.from,options:[{label:"span_kind",type:"variable",info:"The span variant: CHAIN, LLM, RETRIEVER, TOOL, etc."},{label:"status_code",type:"variable",info:"The span status: OK, UNSET, or ERROR"},{label:"input.value",type:"variable",info:"The input value of a span, typically a query"},{label:"output.value",type:"variable",info:"The output value of a span, typically a response"},{label:"name",type:"variable",info:"The name given to a span - e.x. OpenAI"},{label:"latency_ms",type:"variable",info:"Latency (i.e. duration) in milliseconds"},{label:"cumulative_token_count.prompt",type:"variable",info:"Sum of token count for prompt from self and all child spans"},{label:"cumulative_token_count.completion",type:"variable",info:"Sum of token count for completion from self and all child spans"},{label:"cumulative_token_count.total",type:"variable",info:"Sum of token count total (prompt + completion) from self and all child spans"},{label:"llm spans",type:"text",apply:"span_kind == 'LLM'",detail:"macro"},{label:"retriever spans",type:"text",apply:"span_kind == 'RETRIEVER'",detail:"macro"},{label:"search input",type:"text",apply:"'' in input.value",detail:"macro"},{label:"search output",type:"text",apply:"'' in output.value",detail:"macro"},{label:"status_code error",type:"text",apply:"status_code == 'ERROR'",detail:"macro"},{label:"Latency >= 10s",type:"text",apply:"latency_ms >= 10_000",detail:"macro"},{label:"Tokens >= 1,000",type:"text",apply:"llm.token_count.total >= 1_000",detail:"macro"},{label:"Hallucinations",type:"text",apply:"annotations['Hallucination'].label == 'hallucinated'",detail:"macro"},{label:"Annotations",type:"text",apply:"annotations['Hallucination'].label == 'hallucinated'",detail:"macro"},{label:"Metadata",type:"text",apply:"metadata['topic'] == 'agent'",detail:"macro"},{label:"Substring",type:"text",apply:"'agent' in input.value",detail:"macro"}]}}async function wd(n,a){if(!n)return{isValid:!0,errorMessage:null};const l=await Yi.fetchQuery(Ce,jt,{condition:n,id:a}).toPromise();if(!l)throw new Error("Filter condition validation is null");return l.project.validateSpanFilterCondition}const Pd=[gs.of([{key:"Enter",run:n=>!0}]),Ma(),ps({override:[Rd]})];function Ht(n){const{onValidCondition:a,placeholder:l="filter condition (e.x. span_kind == 'LLM')"}=n,[t,i]=u.useState(!1),[r,o]=u.useState(""),[c,d]=u.useState(""),m=u.useDeferredValue(c),{theme:y}=$n(),g=y==="dark"?sa:void 0,p=u.useCallback(h=>{c.length>0?d(`${c} and ${h}`):d(h)},[c,d]),{projectId:f}=Oe();u.useEffect(()=>{wd(m,f).then(h=>{h!=null&&h.isValid?(o(""),u.startTransition(()=>{a(m)})):o((h==null?void 0:h.errorMessage)??"Invalid filter condition")})},[a,m,f]);const k=r!=="",S=c!=="";return s("div",{"data-is-focused":t,"data-is-invalid":k,className:"span-filter-condition-field",css:Bt,children:[s(b,{direction:"row",children:[e(ts,{children:e(M,{svg:e(P.Search,{})})}),e(ra,{css:qt,indentWithTab:!1,basicSetup:{lineNumbers:!1,foldGutter:!1,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1,defaultKeymap:!1},onFocus:()=>i(!0),onBlur:()=>i(!1),value:c,onChange:d,height:"36px",width:"100%",theme:g,placeholder:l,extensions:Pd}),e("button",{css:K`
            margin-right: var(--ac-global-dimension-static-size-100);
            color: var(--ac-global-text-color-700);
            visibility: ${S?"visible":"hidden"};
          `,onClick:()=>d(""),className:"button--reset",children:e(M,{svg:e(P.CloseCircleOutline,{})})}),s(dn,{placement:"bottom right",children:[e($e,{children:e("button",{css:K`
                color: var(--ac-global-text-color-700);
                background-color: var(--ac-global-color-grey-400);
                padding-left: var(--ac-global-dimension-static-size-100);
                padding-right: var(--ac-global-dimension-static-size-100);
                height: 100%;
              `,className:"button--reset",children:e(M,{svg:e(P.PlusCircleOutline,{})})})}),e(Md,{onAddFilterConditionSnippet:p})]})]}),s(pe,{isOpen:k&&t,placement:"bottom",children:[e($e,{children:e("div",{})}),e(ta,{children:r!=""?e(x,{color:"danger",children:r}):e(x,{color:"success",children:"Valid Expression"})})]})]})}function Md(n){const{onAddFilterConditionSnippet:a}=n;return e(T,{width:"500px",paddingTop:"size-200",paddingStart:"size-200",paddingEnd:"size-200",borderRadius:"medium",borderWidth:"thin",borderColor:"light",backgroundColor:"light",children:s(wn,{children:[e(Je,{label:"filter by kind",initialSnippet:"span_kind == 'LLM'",onAddFilterConditionSnippet:a},"kind"),e(Je,{label:"filter by token count",initialSnippet:"cumulative_token_count.total > 1000",onAddFilterConditionSnippet:a},"token_count"),e(Je,{label:"filter by annotation label",initialSnippet:"annotations['Hallucination'].label == 'hallucinated'",onAddFilterConditionSnippet:a},"annotation_label"),e(Je,{label:"filter by evaluation label",initialSnippet:"evals['Hallucination'].label == 'hallucinated'",onAddFilterConditionSnippet:a},"eval_label"),e(Je,{label:"filter by evaluation score",initialSnippet:"evals['Hallucination'].score < 1",onAddFilterConditionSnippet:a},"eval_score"),e(Je,{label:"filter by metadata",initialSnippet:"metadata['topic'] == 'agent'",onAddFilterConditionSnippet:a},"metadata"),e(Je,{label:"filter by substring",initialSnippet:"'agent' in input.value",onAddFilterConditionSnippet:a},"substring")]})})}function Je(n){const{initialSnippet:a,onAddFilterConditionSnippet:l}=n,[t,i]=u.useState(a),{theme:r}=$n(),o=r==="light"?void 0:sa;return e(ia,{label:n.label,children:s(b,{direction:"row",width:"100%",gap:"size-100",children:[e("div",{css:K(Bt,K`
              flex: 1 1 auto;
            `),children:e(ra,{value:t,basicSetup:{lineNumbers:!1,foldGutter:!1,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1},extensions:[Ma()],editable:!0,onChange:i,theme:o,css:qt})}),e(z,{title:"Add to filter condition",variant:"default",onClick:()=>l(t),icon:e(M,{svg:e(P.PlusCircleOutline,{})})})]})})}const Gt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addSpansToDataset",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanSelectionToolbarAddSpansToDatasetMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanSelectionToolbarAddSpansToDatasetMutation",selections:a},params:{cacheID:"1c694540190478b8fba8ef3c0cacf30c",id:null,metadata:{},name:"SpanSelectionToolbarAddSpansToDatasetMutation",operationKind:"mutation",text:`mutation SpanSelectionToolbarAddSpansToDatasetMutation(
  $input: AddSpansToDatasetInput!
) {
  addSpansToDataset(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();Gt.hash="5e3aef907285081a06c0e0360045e865";const Wt={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetSelectorPopoverContentDatasetsQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetSelectorPopoverContent_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetSelectorPopoverContentDatasetsQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"6d459b61a36b99979f025742892941f9",id:null,metadata:{},name:"DatasetSelectorPopoverContentDatasetsQuery",operationKind:"query",text:`query DatasetSelectorPopoverContentDatasetsQuery {
  ...DatasetSelectorPopoverContent_datasets
}

fragment DatasetSelectorPopoverContent_datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};Wt.hash="40d5267ad0ec2335a73ff2a4d05bbed1";const Ut={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:[],operation:Wt}},name:"DatasetSelectorPopoverContent_datasets",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null};Ut.hash="40d5267ad0ec2335a73ff2a4d05bbed1";const Jt={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetSelectorPopoverContentQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetSelectorPopoverContent_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetSelectorPopoverContentQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"5fb28a402f330dd235295da21efea58b",id:null,metadata:{},name:"DatasetSelectorPopoverContentQuery",operationKind:"query",text:`query DatasetSelectorPopoverContentQuery {
  ...DatasetSelectorPopoverContent_datasets
}

fragment DatasetSelectorPopoverContent_datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};Jt.hash="7cd8a13144d97d2b5294f2a09c9e1351";function Nd(n){const{onCreateNewDataset:a,onDatasetSelected:l}=n,[t,i]=u.useState(""),r=_.useLazyLoadQuery(Jt,{},{fetchPolicy:"network-only"});return s(Q,{title:"Add to Dataset",variant:"compact",backgroundColor:"light",borderColor:"light",bodyStyle:{padding:0},extra:e(z,{variant:"default",size:"compact",onClick:a,children:"New Dataset"}),children:[e(T,{padding:"size-100",children:e(ye,{type:"search",placeholder:"Search datasets",addonBefore:e(M,{svg:e(P.Search,{})}),onChange:o=>{i(o)}})}),e(T,{borderTopWidth:"thin",borderColor:"light",children:e("div",{css:K`
            height: 400px;
            overflow-y: auto;
          `,children:e(Ad,{query:r,search:t,onDatasetSelected:l})})})]})}function Ad(n){const{search:a,onDatasetSelected:l}=n,[t]=_.useRefetchableFragment(Ut,n.query),i=u.useMemo(()=>{let o=t.datasets.edges.map(c=>c.dataset);return a&&(o=o.filter(c=>c.name.toLowerCase().includes(a.toLowerCase()))),o},[a,t]);return i.length===0?e(b,{direction:"column",justifyContent:"center",alignItems:"center",flex:"1 1 auto",children:e(x,{children:"No datasets found"})}):e(On,{selectionMode:"single",onSelectionChange:o=>{if(typeof o=="object"){const c=Array.from(o);l(c[0])}},children:i.map(o=>e(H,{children:o.name},o.id))})}function Xt(n){const a=ae(),[l,t]=u.useState(null),i=ve(),r=Qn(),[o,c]=u.useState(!1),{selectedSpans:d,onClearSelection:m}=n,[y,g]=_.useMutation(Gt),p=d.length!==1,f=u.useCallback(k=>{y({variables:{input:{datasetId:k,spanIds:d.map(S=>S.id)}},onCompleted:()=>{i({title:"Examples added to dataset",message:`${d.length} example${p?"s":""} have been added to the dataset.`,action:{text:"View dataset",onClick:()=>{a(`/datasets/${k}/examples`)}}}),m()},onError:S=>{r({title:"An error occurred",message:`Failed to add spans to dataset: ${S.message}`})}})},[y,d,i,p,m,a,r]);return s("div",{css:K`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(T,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(b,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(x,{children:`${d.length} span${p?"s":""} selected`}),s(b,{direction:"row",gap:"size-100",children:[e(z,{variant:"default",size:"compact",onClick:m,children:"Cancel"}),s(dn,{placement:"top end",crossOffset:300,isOpen:o,onOpenChange:k=>{c(k)},children:[e(z,{variant:"primary",size:"compact",icon:e(M,{svg:e(P.DatabaseOutline,{})}),loading:g,disabled:g,children:g?"Adding to dataset":"Add to dataset"}),e(u.Suspense,{children:e(Nd,{onDatasetSelected:k=>{f(k),c(!1)},onCreateNewDataset:()=>{c(!1),t(e(G,{title:"New Dataset",isDismissable:!0,onDismiss:()=>t(null),children:e(Ca,{onDatasetCreateError:()=>{r({title:"Dataset creation failed",message:"Failed to create dataset."})},onDatasetCreated:k=>{t(null),i({title:"Dataset created",message:`${k.name} has been successfully created.`}),c(!0)}})}))}})})]})]})]})}),e(ee,{onDismiss:()=>{t(null)},children:l})]})}const Yt=K`
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
  .span-filter-condition-field {
    flex: 1 1 auto;
  }

  // Style the column selector
  .ac-dropdown-button {
    min-width: var(--ac-global-dimension-static-size-300);
  }
`,Mn="evals",Le=":",Zt={col:"startTime",dir:"desc"};function ei(n){let a=null,l=null;if(n.id&&n.id.startsWith(Mn)){const[,t,i]=n.id.split(Le);l={attr:t,name:i}}else a=n.id;return{col:a,evalResultKey:l,dir:n.desc?"desc":"asc"}}const Wa=50;function $d(n){const{fetchKey:a}=Cn(),l=u.useRef(null),[t,i]=u.useState({}),[r,o]=u.useState([]),[c,d]=u.useState(""),m=Qe(w=>w.columnVisibility),y=ae(),{data:g,loadNext:p,hasNext:f,isLoadingNext:k,refetch:S}=_.usePaginationFragment(Vt,n.project),h=Qe(w=>w.evaluationVisibility),F=u.useMemo(()=>Object.keys(h).filter(w=>h[w]),[h]),L=u.useMemo(()=>g.spans.edges.map(({span:A})=>A),[g]),I=F.map(w=>({header:w,columns:[{header:"label",accessorKey:`${Mn}${Le}label${Le}${w}`,cell:({row:A})=>{const E=A.original.spanEvaluations.find($=>$.name===w);return E?E.label:null}},{header:"score",accessorKey:`${Mn}${Le}score${Le}${w}`,cell:({row:A})=>{const E=A.original.spanEvaluations.find($=>$.name===w);return E?E.score:null}}]})),C=[{header:"evaluations",accessorKey:"spanEvaluations",enableSorting:!1,cell:({row:w})=>s(b,{direction:"row",gap:"size-50",wrap:"wrap",children:[w.original.spanEvaluations.map(A=>e(Na,{evaluation:A},A.name)),w.original.documentRetrievalMetrics.map(A=>s(B,{children:[e(ce,{name:A.evaluationName,metric:"ndcg",score:A.ndcg},"ndcg"),e(ce,{name:A.evaluationName,metric:"precision",score:A.precision},"precision"),e(ce,{name:A.evaluationName,metric:"hit",score:A.hit},"hit")]}))]})},...I],v=[{id:"select",maxSize:10,header:({table:w})=>e(Ne,{checked:w.getIsAllRowsSelected(),indeterminate:w.getIsSomeRowsSelected(),onChange:w.getToggleAllRowsSelectedHandler()}),cell:({row:w})=>e(Ne,{checked:w.getIsSelected(),disabled:!w.getCanSelect(),indeterminate:w.getIsSomeSelected(),onChange:w.getToggleSelectedHandler()})},{header:"kind",accessorKey:"spanKind",maxSize:100,enableSorting:!1,cell:({getValue:w})=>e(gl,{spanKind:w()})},{header:"name",accessorKey:"name",enableSorting:!1,cell:({getValue:w,row:A})=>{const E=A.original,{traceId:$}=E.context;return e(Tn,{to:`traces/${$}?selectedSpanNodeId=${E.id}`,children:w()})}},{header:"input",accessorKey:"input.value",cell:xe,enableSorting:!1},{header:"output",accessorKey:"output.value",cell:xe,enableSorting:!1},{header:"metadata",accessorKey:"metadata",cell:xe,enableSorting:!1},...C,{header:"start time",accessorKey:"startTime",cell:Dn},{header:"latency",accessorKey:"latencyMs",cell:({getValue:w})=>{const A=w();return A===null||typeof A!="number"?null:e(we,{latencyMs:A})}},{header:"total tokens",accessorKey:"tokenCountTotal",cell:({row:w,getValue:A})=>{const E=A();return E===null?"--":e(ct,{tokenCountTotal:E,tokenCountPrompt:w.original.tokenCountPrompt||0,tokenCountCompletion:w.original.tokenCountCompletion||0})}},{header:"status",accessorKey:"statusCode",enableSorting:!1,cell:({getValue:w})=>e(Ia,{statusCode:w()})}];u.useEffect(()=>{const w=r[0];u.startTransition(()=>{S({sort:w?ei(w):Zt,after:null,first:Wa,filterCondition:c},{fetchPolicy:"store-and-network"})})},[r,S,c,a]);const D=u.useCallback(w=>{if(w){const{scrollHeight:A,scrollTop:E,clientHeight:$}=w;A-E-$<300&&!k&&f&&p(Wa)}},[f,k,p]),N=be({columns:v,data:L,state:{sorting:r,columnVisibility:m,rowSelection:t},manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:i,onSortingChange:o,getCoreRowModel:Se(),getSortedRowModel:Nn()}),R=N.getRowModel().rows,O=N.getSelectedRowModel().rows,j=O.map(w=>w.original),X=u.useCallback(()=>{i({})},[i]),ie=R.length===0,re=N.getAllColumns().filter(w=>w.columns.length===0);return s("div",{css:Yt,children:[e(T,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-200",paddingEnd:"size-200",borderBottomColor:"grey-300",borderBottomWidth:"thin",flex:"none",children:s(b,{direction:"row",gap:"size-100",width:"100%",alignItems:"center",children:[e(Ht,{onValidCondition:d}),e(Ot,{columns:re,query:g})]})}),e("div",{css:K`
          flex: 1 1 auto;
          overflow: auto;
        `,onScroll:w=>D(w.target),ref:l,children:s("table",{css:xn,children:[e("thead",{children:N.getHeaderGroups().map(w=>e("tr",{children:w.headers.map(A=>e("th",{colSpan:A.colSpan,children:A.isPlaceholder?null:s("div",{className:A.column.getCanSort()?"cursor-pointer":"",onClick:A.column.getToggleSortingHandler(),style:{left:A.getStart(),width:A.getSize()},children:[J(A.column.columnDef.header,A.getContext()),A.column.getIsSorted()?e(M,{className:"sort-icon",svg:A.column.getIsSorted()==="asc"?e(P.ArrowUpFilled,{}):e(P.ArrowDownFilled,{})}):null]})},A.id))},w.id))}),ie?e(on,{}):e("tbody",{children:R.map(w=>e("tr",{onClick:()=>y(`traces/${w.original.context.traceId}?selectedSpanNodeId=${w.original.id}`),children:w.getVisibleCells().map(A=>e("td",{children:J(A.column.columnDef.cell,A.getContext())},A.id))},w.id))})]})}),O.length?e(Xt,{selectedSpans:j,onClearSelection:X}):null]})}const ni=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"StreamToggleRefetchQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"StreamToggle_data"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"StreamToggleRefetchQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"4e136f41c0942f253822336dc0c5b291",id:null,metadata:{},name:"StreamToggleRefetchQuery",operationKind:"query",text:`query StreamToggleRefetchQuery(
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...StreamToggle_data
    __isNode: __typename
    id
  }
}

fragment StreamToggle_data on Project {
  streamingLastUpdatedAt
  id
}
`}}}();ni.hash="30a8f0bcf1aa6021b2c9a47866f5dc49";const ai={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:ni,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"StreamToggle_data",selections:[{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};ai.hash="30a8f0bcf1aa6021b2c9a47866f5dc49";function li(n,a){const l=u.useRef(null);u.useEffect(()=>{l.current=n},[n]),u.useEffect(()=>{function t(){l.current&&l.current()}if(a!==null){const i=setInterval(t,a);return()=>clearInterval(i)}},[a])}const Vd=2e3;function zd(n){const{isStreaming:a,setIsStreaming:l,setFetchKey:t}=Cn(),[i,r]=_.useRefetchableFragment(ai,n.project),o=u.useRef(i.streamingLastUpdatedAt),c=u.useCallback(()=>{a&&u.startTransition(()=>{r({},{fetchPolicy:"store-and-network"})})},[a,r]),d=i.streamingLastUpdatedAt;return u.useEffect(()=>{d!=null&&(o.current==null||o.current<d)&&(o.current=d,t(`fetch-traces-${d}`))},[t,d]),li(c,Vd),e(ea,{labelPlacement:"start",defaultSelected:!0,onChange:()=>{l(!a)},children:"Stream"})}const ti=function(){var n={defaultValue:null,kind:"LocalArgument",name:"after"},a={defaultValue:null,kind:"LocalArgument",name:"filterCondition"},l={defaultValue:100,kind:"LocalArgument",name:"first"},t={defaultValue:null,kind:"LocalArgument",name:"id"},i={defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},r={defaultValue:null,kind:"LocalArgument",name:"timeRange"},o=[{kind:"Variable",name:"id",variableName:"id"}],c={kind:"Variable",name:"after",variableName:"after"},d={kind:"Variable",name:"filterCondition",variableName:"filterCondition"},m={kind:"Variable",name:"first",variableName:"first"},y={kind:"Variable",name:"sort",variableName:"sort"},g={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},f=[c,d,m,{kind:"Literal",name:"rootSpansOnly",value:!0},y,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],k={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},S={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},h={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},F={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},L={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},I={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},C=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],v={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},D={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[S,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},N={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},R=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l,t,i,r],kind:"Fragment",metadata:null,name:"TracesTableQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:[c,d,m,y],kind:"FragmentSpread",name:"TracesTable_spans"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,a,l,i,r,t],kind:"Operation",name:"TracesTableQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[g,{kind:"TypeDiscriminator",abstractKey:"__isNode"},p,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:"rootSpans",args:f,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[p,k,S,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},h,F,L,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},I,{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:C,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:C,storageKey:null},v,D,N,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[p,k,S,h,F,L,I,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:R,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:R,storageKey:null},v,D,N],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[g],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:"rootSpans",args:f,filters:["sort","rootSpansOnly","filterCondition","timeRange"],handle:"connection",key:"TracesTable_rootSpans",kind:"LinkedHandle",name:"spans"}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"82574e0f30ec618a7a89afd7c4664347",id:null,metadata:{},name:"TracesTableQuery",operationKind:"query",text:`query TracesTableQuery(
  $after: String = null
  $filterCondition: String = null
  $first: Int = 100
  $sort: SpanSort = {col: startTime, dir: desc}
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...TracesTable_spans_1XEuU
    __isNode: __typename
    id
  }
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment TracesTable_spans_1XEuU on Project {
  ...SpanColumnSelector_evaluations
  rootSpans: spans(first: $first, after: $after, sort: $sort, rootSpansOnly: true, filterCondition: $filterCondition, timeRange: $timeRange) {
    edges {
      rootSpan: node {
        id
        spanKind
        name
        metadata
        statusCode: propagatedStatusCode
        startTime
        latencyMs
        cumulativeTokenCountTotal
        cumulativeTokenCountPrompt
        cumulativeTokenCountCompletion
        parentId
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        context {
          spanId
          traceId
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
        descendants {
          id
          spanKind
          name
          statusCode: propagatedStatusCode
          startTime
          latencyMs
          parentId
          cumulativeTokenCountTotal: tokenCountTotal
          cumulativeTokenCountPrompt: tokenCountPrompt
          cumulativeTokenCountCompletion: tokenCountCompletion
          input {
            value
          }
          output {
            value
          }
          context {
            spanId
            traceId
          }
          spanEvaluations {
            name
            label
            score
          }
          documentRetrievalMetrics {
            evaluationName
            ndcg
            precision
            hit
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();ti.hash="b8e7c42b9731568c7e348cf191017d06";const ii=function(){var n=["rootSpans"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},i={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},o={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},c={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},d=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],m={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},y={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},g={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},p=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"filterCondition"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:ti,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"TracesTable_spans",selections:[{args:null,kind:"FragmentSpread",name:"SpanColumnSelector_evaluations"},{alias:"rootSpans",args:[{kind:"Variable",name:"filterCondition",variableName:"filterCondition"},{kind:"Literal",name:"rootSpansOnly",value:!0},{kind:"Variable",name:"sort",variableName:"sort"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"SpanConnection",kind:"LinkedField",name:"__TracesTable_rootSpans_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[a,l,t,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},i,r,o,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},c,{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:d,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:d,storageKey:null},m,y,g,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[a,l,t,i,r,o,c,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:p,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:p,storageKey:null},m,y,g],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Project",abstractKey:null}}();ii.hash="b8e7c42b9731568c7e348cf191017d06";const Ua=50;function ri(n){const a=[];for(const l of n){const t={...l.span,children:ri(l.children)};a.push(t)}return a}function Qd(n){const a=u.useRef(null),[l,t]=u.useState({}),[i,r]=u.useState([]),[o,c]=u.useState(""),d=ae(),{fetchKey:m}=Cn(),{data:y,loadNext:g,hasNext:p,isLoadingNext:f,refetch:k}=_.usePaginationFragment(ii,n.project),S=Qe(E=>E.evaluationVisibility),h=u.useMemo(()=>Object.keys(S).filter(E=>S[E]),[S]),F=u.useMemo(()=>y.rootSpans.edges.map(({rootSpan:$})=>{const W=$r([$,...$.descendants]),[Ue]=ri(W);return Ue}),[y]),L=h.map(E=>({header:E,columns:[{header:"label",accessorKey:`${Mn}${Le}label${Le}${E}`,cell:({row:$})=>{const W=$.original.spanEvaluations.find(Ue=>Ue.name===E);return W?W.label:null}},{header:"score",accessorKey:`${Mn}${Le}score${Le}${E}`,cell:({row:$})=>{const W=$.original.spanEvaluations.find(Ue=>Ue.name===E);return W?W.score:null}}]})),I=[{header:"evaluations",accessorKey:"spanEvaluations",enableSorting:!1,cell:({row:E})=>{const $=E.original.spanEvaluations.length===0&&E.original.documentRetrievalMetrics.length===0;return s(b,{direction:"row",gap:"size-50",wrap:"wrap",children:[E.original.spanEvaluations.map(W=>e(Na,{evaluation:W},W.name)),E.original.documentRetrievalMetrics.map(W=>s(u.Fragment,{children:[e(ce,{name:W.evaluationName,metric:"ndcg",score:W.ndcg},"ndcg"),e(ce,{name:W.evaluationName,metric:"precision",score:W.precision},"precision"),e(ce,{name:W.evaluationName,metric:"hit",score:W.hit},"hit")]},"doc-evals")),$?"--":null]})}},...L],C=[{id:"select",maxSize:10,header:({table:E})=>e(Ne,{checked:E.getIsAllRowsSelected(),indeterminate:E.getIsSomeRowsSelected(),onChange:E.getToggleAllRowsSelectedHandler()}),cell:({row:E})=>e(Ne,{checked:E.getIsSelected(),disabled:!E.getCanSelect(),indeterminate:E.getIsSomeSelected(),onChange:E.getToggleSelectedHandler()})},{header:()=>s(b,{gap:"size-50",direction:"row",alignItems:"center",children:[e(Qa,{isExpanded:O.getIsAllRowsExpanded(),onClick:O.getToggleAllRowsExpandedHandler(),"aria-label":"Expand all rows"}),"kind"]}),enableSorting:!1,accessorKey:"spanKind",maxSize:100,cell:E=>e("div",{css:K`
              // Since rows are flattened by default,
              // we can use the row.depth property
              // and paddingLeft to visually indicate the depth
              // of the row
              padding-left: ${E.row.depth*2}rem;
            `,children:s(b,{gap:"size-50",children:[E.row.getCanExpand()?e(Qa,{isExpanded:E.row.getIsExpanded(),onClick:E.row.getToggleExpandedHandler(),"aria-label":"Expand row"}):null,e(gl,{spanKind:E.getValue()})]})})},{header:"name",accessorKey:"name",enableSorting:!1,cell:({getValue:E,row:$})=>{const{traceId:W}=$.original.context;return e(Tn,{to:`traces/${W}?selectedSpanNodeId=${$.original.id}`,children:E()})}},{header:"input",accessorKey:"input.value",enableSorting:!1,cell:xe},{header:"output",accessorKey:"output.value",enableSorting:!1,cell:xe},{header:"metadata",accessorKey:"metadata",enableSorting:!1,cell:xe},...I,{header:"start time",accessorKey:"startTime",cell:Dn},{header:"latency",accessorKey:"latencyMs",cell:({getValue:E})=>{const $=E();return $===null||typeof $!="number"?null:e(we,{latencyMs:$})}},{header:"total tokens",minSize:80,accessorKey:"cumulativeTokenCountTotal",cell:({row:E,getValue:$})=>{const W=$();return W===null?"--":e(ct,{tokenCountTotal:W,tokenCountPrompt:E.original.cumulativeTokenCountPrompt||0,tokenCountCompletion:E.original.cumulativeTokenCountCompletion||0})}},{header:"status",accessorKey:"statusCode",enableSorting:!1,cell:({getValue:E})=>e(Ia,{statusCode:E()})}];u.useEffect(()=>{const E=i[0];u.startTransition(()=>{k({sort:E?ei(E):Zt,after:null,first:Ua,filterCondition:o},{fetchPolicy:"store-and-network"})})},[i,k,o,m]);const v=ke.useCallback(E=>{if(E){const{scrollHeight:$,scrollTop:W,clientHeight:Ue}=E;$-W-Ue<300&&!f&&p&&g(Ua)}},[p,f,g]),[D,N]=u.useState({}),R=Qe(E=>E.columnVisibility),O=be({columns:C,data:F,onExpandedChange:N,manualSorting:!0,getSubRows:E=>E.children,state:{sorting:i,expanded:D,columnVisibility:R,rowSelection:l},onRowSelectionChange:t,enableSubRowSelection:!1,onSortingChange:r,getCoreRowModel:Se(),getSortedRowModel:Nn(),getExpandedRowModel:Zi(),getRowId:E=>E.id}),j=O.getRowModel().rows,X=O.getSelectedRowModel().flatRows,ie=X.map(E=>E.original),re=u.useCallback(()=>{t({})},[t]),w=j.length===0,A=O.getAllColumns().filter(E=>E.columns.length===0);return s("div",{css:Yt,children:[e(T,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-200",paddingEnd:"size-200",borderBottomColor:"grey-300",borderBottomWidth:"thin",flex:"none",children:s(b,{direction:"row",gap:"size-100",width:"100%",alignItems:"center",children:[e(Ht,{onValidCondition:c}),e(Ot,{columns:A,query:y})]})}),e("div",{css:K`
          flex: 1 1 auto;
          overflow: auto;
        `,onScroll:E=>v(E.target),ref:a,children:s("table",{css:xn,children:[e("thead",{children:O.getHeaderGroups().map(E=>e("tr",{children:E.headers.map($=>e("th",{colSpan:$.colSpan,children:$.isPlaceholder?null:s("div",{"data-sortable":$.column.getCanSort(),className:$.column.getCanSort()?"cursor-pointer":"",onClick:$.column.getToggleSortingHandler(),style:{left:$.getStart(),width:$.getSize()},children:[J($.column.columnDef.header,$.getContext()),$.column.getIsSorted()?e(M,{className:"sort-icon",svg:$.column.getIsSorted()==="asc"?e(P.ArrowUpFilled,{}):e(P.ArrowDownFilled,{})}):null]})},$.id))},E.id))}),w?e(on,{}):e("tbody",{children:j.map(E=>e("tr",{onClick:()=>d(`traces/${E.original.context.traceId}`),children:E.getVisibleCells().map($=>e("td",{children:J($.column.columnDef.cell,$.getContext())},$.id))},E.id))})]})}),X.length?e(Xt,{selectedSpans:ie,onClearSelection:re}):null]})}const Od=K`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .ac-tabs {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    div[role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      div[role="tabpanel"]:not([hidden]) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
`;function ku(){const{projectId:n}=Oe(),{timeRange:a}=Yn();return e(u.Suspense,{fallback:e(ue,{}),children:e(jd,{projectId:n,timeRange:a})})}function jd({projectId:n,timeRange:a}){const l=u.useMemo(()=>({start:a.start.toISOString(),end:a.end.toISOString()}),[a]),t=_.useLazyLoadQuery(It,{id:n,timeRange:l},{fetchPolicy:"store-and-network"});return s("main",{css:Od,children:[e(Cd,{project:t.project,extra:s(b,{direction:"row",alignItems:"center",gap:"size-100",children:[e(zd,{project:t.project}),e(pl,{})]})}),s(he,{children:[e(q,{name:"Traces",children:({isSelected:i})=>i&&e(u.Suspense,{children:e(Qd,{project:t.project})})}),e(q,{name:"Spans",title:"Spans",children:({isSelected:i})=>i&&e(u.Suspense,{children:e($d,{project:t.project})})})]}),e(u.Suspense,{children:e(Te,{})})]})}const si=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"Project",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"projectLoaderQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,t],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"projectLoaderQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,t],storageKey:null}]},params:{cacheID:"04c84b5bc2a01477851d347af75dcc11",id:null,metadata:{},name:"projectLoaderQuery",operationKind:"query",text:`query projectLoaderQuery(
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    id
    ... on Project {
      name
    }
  }
}
`}}}();si.hash="3d31e323c06df38ec2eaa6f3adb55e79";async function bu(n){const{projectId:a}=n.params;return await _.fetchQuery(Ce,si,{id:a}).toPromise()}const qd=K`
  display: flex;
  direction: row;
  height: 100vh;
  overflow: hidden;
`,Bd=K`
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
  padding-left: var(--px-nav-collapsed-width);
`,Hd=K`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
`,Gd=K`
  display: flex;
  flex-direction: column;
  margin: 0;
  list-style: none;
  gap: var(--ac-global-dimension-size-50);
  padding-inline-start: 0;
`,Wd=K`
  display: flex;
  flex-direction: column;
  gap: var(--ac-global-dimension-size-50);
`;function Su(){return s("div",{css:qd,"data-testid":"layout",children:[e(Ud,{}),s("div",{css:Bd,children:[e(zr,{children:e(Vr,{})}),e("div",{"data-testid":"content",css:Hd,children:e(u.Suspense,{fallback:e(ue,{}),children:e(Te,{})})})]})]})}function Ud(){const n=u.useMemo(()=>window.Config.hasInferences,[]);return s(Br,{children:[e(Qr,{}),s(b,{direction:"column",justifyContent:"space-between",flex:"1 1 auto",children:[s("ul",{css:Wd,children:[n&&e("li",{children:e(Gn,{to:"/model",text:"Model",icon:e(M,{svg:e(P.CubeOutline,{})})})}),e("li",{children:e(Gn,{to:"/projects",text:"Projects",icon:e(M,{svg:e(P.GridOutline,{})})})}),e("li",{children:e(Gn,{to:"/datasets",text:"Datasets",icon:e(M,{svg:e(P.DatabaseOutline,{})})})}),e("li",{children:e(Gn,{to:"/apis",text:"APIs",icon:e(M,{svg:e(P.Code,{})})})})]}),s("ul",{css:Gd,children:[e("li",{children:e(Or,{})}),e("li",{children:e(jr,{})}),e("li",{children:e(qr,{})})]})]})]})}function vu(){const n=er(),a=u.useMemo(()=>n instanceof Error&&n.message==="Failed to fetch"?e(Jd,{}):e(Xd,{error:n}),[n]);return e("main",{css:K`
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
      `,children:e("section",{css:K`
          width: 500px;
          /* Add spacing on the bottom so it gets pushed down */
          margin-top: 200px;
          display: flex;
          flex-direction: column;
        `,children:a})})}function Jd(){return s(B,{children:[s(b,{direction:"column",width:"100%",alignItems:"center",children:[e(Ra,{graphicKey:"not found"}),e("h1",{children:"Server disconnected"})]}),e("p",{children:"We are unable to reach the Phoenix server. Please ensure that Phoenix is running and try again."})]})}function Xd({error:n}){return s(B,{children:[s(b,{direction:"column",width:"100%",alignItems:"center",children:[e(Ra,{graphicKey:"error"}),e("h1",{children:"Something went wrong"})]}),e("p",{children:"We strive to do our very best but 🐛 bugs happen. It would mean a lot to us if you could file a an issue. If you feel comfortable, please include the error details below in your issue. We will get back to you as soon as we can."}),e("p",{css:K`
          display: flex;
          flex-direction: row;
          justify-content: flex-end;
          gap: var(--px-spacing-med);
        `,children:s("span",{css:K`
            display: inline-flex;
            flex-direction: row;
            align-items: baseline;
            gap: 0.2em;
          `,children:["💙 the",e(Rn,{href:"mailto:phoenix-devs@arize.com",children:"phoenix team"})]})}),s("div",{css:K`
          display: flex;
          flex-direction: row;
          justify-content: flex-end;
          align-items: center;
          gap: var(--px-spacing-med);
        `,children:[e(Rn,{href:"https://github.com/Arize-ai/phoenix/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D",children:"file an issue with us"}),e(z,{variant:"primary",size:"compact",onClick:()=>{window.location.href="/"},children:"Return Home"})]}),s("details",{open:!0,children:[e("summary",{children:"error details"}),e("pre",{css:K`
            white-space: pre-wrap;
            overflow-wrap: break-word;
            overflow: hidden;
            overflow-y: auto;
            max-height: 500px;
          `,children:n instanceof Error?n.message:null})]})]})}const oi=function(){var n=[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null}],a=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"primaryInferences",plural:!1,selections:n,storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"referenceInferences",plural:!1,selections:n,storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"corpusInferences",plural:!1,selections:n,storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ModelRootQuery",selections:a,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"ModelRootQuery",selections:a},params:{cacheID:"c3baccc5527002697b40a06eef432a4d",id:null,metadata:{},name:"ModelRootQuery",operationKind:"query",text:`query ModelRootQuery {
  model {
    primaryInferences {
      name
      startTime
      endTime
    }
    referenceInferences {
      name
      startTime
      endTime
    }
    corpusInferences {
      name
      startTime
      endTime
    }
  }
}
`}}}();oi.hash="b73d8f3f532a0c6f88863f3c6dd5734f";const Yd=oi;function Fu(){const n=_.useLazyLoadQuery(Yd,{}),{model:{primaryInferences:a,referenceInferences:l,corpusInferences:t}}=n;return e(Gr,{primaryInferences:a,referenceInferences:l??null,corpusInferences:t??null,children:e(Hr,{timeRangeBounds:{start:new Date(a.startTime),end:new Date(a.endTime)},children:e(Te,{})})})}function Ku(){return e(Id,{children:e(Fd,{children:e(Te,{})})})}function xu(){return e(Wr,{children:e(Te,{})})}const di=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],l={kind:"Variable",name:"timeRange",variableName:"timeRange"},t=[l];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectsPageProjectsQuery",selections:[{args:a,kind:"FragmentSpread",name:"ProjectsPageProjectsFragment"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectsPageProjectsQuery",selections:[{alias:null,args:a,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},l],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:a,filters:null,handle:"connection",key:"ProjectsPage_projects",kind:"LinkedHandle",name:"projects"}]},params:{cacheID:"dd65be0e4921fda8c7330e4b91d0d016",id:null,metadata:{},name:"ProjectsPageProjectsQuery",operationKind:"query",text:`query ProjectsPageProjectsQuery(
  $after: String = null
  $first: Int = 100
  $timeRange: TimeRange
) {
  ...ProjectsPageProjectsFragment_2HEEH6
}

fragment ProjectsPageProjectsFragment_2HEEH6 on Query {
  projects(first: $first, after: $after) {
    edges {
      project: node {
        id
        name
        gradientStartColor
        gradientEndColor
        traceCount(timeRange: $timeRange)
        endTime
        latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
        tokenCountTotal(timeRange: $timeRange)
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();di.hash="720b12837ec779f66a493b8c4f993cba";const ci=function(){var n=["projects"],a={kind:"Variable",name:"timeRange",variableName:"timeRange"},l=[a];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:[],operation:di}},name:"ProjectsPageProjectsFragment",selections:[{alias:"projects",args:null,concreteType:"ProjectConnection",kind:"LinkedField",name:"__ProjectsPage_projects_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:l,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},a],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:l,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null}}();ci.hash="720b12837ec779f66a493b8c4f993cba";const ui=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Literal",name:"first",value:100}],l={kind:"Variable",name:"timeRange",variableName:"timeRange"},t=[l];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectsPageQuery",selections:[{args:null,kind:"FragmentSpread",name:"ProjectsPageProjectsFragment"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectsPageQuery",selections:[{alias:null,args:a,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},l],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"projects(first:100)"},{alias:null,args:a,filters:null,handle:"connection",key:"ProjectsPage_projects",kind:"LinkedHandle",name:"projects"}]},params:{cacheID:"e510243be5e7bcef0561820e0515c779",id:null,metadata:{},name:"ProjectsPageQuery",operationKind:"query",text:`query ProjectsPageQuery(
  $timeRange: TimeRange!
) {
  ...ProjectsPageProjectsFragment
}

fragment ProjectsPageProjectsFragment on Query {
  projects(first: 100) {
    edges {
      project: node {
        id
        name
        gradientStartColor
        gradientEndColor
        traceCount(timeRange: $timeRange)
        endTime
        latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
        tokenCountTotal(timeRange: $timeRange)
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();ui.hash="c28f5ced0b3ec4b3b8277d0aac29de2d";const mi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"Query",kind:"LinkedField",name:"clearProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectActionMenuClearMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectActionMenuClearMutation",selections:a},params:{cacheID:"63319b4e42b499db2447817f1dc821fb",id:null,metadata:{},name:"ProjectActionMenuClearMutation",operationKind:"mutation",text:`mutation ProjectActionMenuClearMutation(
  $input: ClearProjectInput!
) {
  clearProject(input: $input) {
    __typename
  }
}
`}}}();mi.hash="c43eec4d6b882468c611dd9ebf3b095e";const gi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"projectId"}],a=[{alias:null,args:[{kind:"Variable",name:"id",variableName:"projectId"}],concreteType:"Query",kind:"LinkedField",name:"deleteProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectActionMenuDeleteMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectActionMenuDeleteMutation",selections:a},params:{cacheID:"8b00ab3aaef4c5fb3de24f7295d38499",id:null,metadata:{},name:"ProjectActionMenuDeleteMutation",operationKind:"mutation",text:`mutation ProjectActionMenuDeleteMutation(
  $projectId: GlobalID!
) {
  deleteProject(id: $projectId) {
    __typename
  }
}
`}}}();gi.hash="3bf82e90b3f2d3485b4efb954e30b2cf";const pi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"Query",kind:"LinkedField",name:"clearProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"RemoveProjectDataFormMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"RemoveProjectDataFormMutation",selections:a},params:{cacheID:"1b27a3f7535c3f3943b0f2248d1505a6",id:null,metadata:{},name:"RemoveProjectDataFormMutation",operationKind:"mutation",text:`mutation RemoveProjectDataFormMutation(
  $input: ClearProjectInput!
) {
  clearProject(input: $input) {
    __typename
  }
}
`}}}();pi.hash="212501fe2d6367ec1503bd7a00c1730f";const Zd=24*60*60*1e3,ec=30*Zd;function nc(n){const{projectId:a}=n,l=u.useRef(null),[t,i]=_.useMutation(pi),{control:r,handleSubmit:o,setError:c,formState:{isValid:d}}=bn({defaultValues:{endDate:new Date(Date.now()-ec).toISOString().slice(0,16)}}),m=u.useCallback(y=>{const g=nr(y.endDate);if(!ar(g))return c("endDate",{message:"Date is not in a valid format"});t({variables:{input:{id:a,endTime:new Date(g).toISOString()}},onCompleted:()=>{n.onComplete()},onError:p=>{alert("Failed to clear project traces: "+p)}})},[t,a,n,c]);return s("form",{onSubmit:o(m),ref:l,children:[s(T,{padding:"size-200",children:[e(x,{color:"danger",children:"You are about to remove all data before the following date. This cannot be undone."}),e(U,{name:"endDate",control:r,rules:{required:"field is required"},render:({field:{name:y,onChange:g,onBlur:p,value:f},fieldState:{invalid:k,error:S}})=>e(ye,{label:"End Date",type:"datetime-local",name:y,description:"The date up to which you want to remove data",errorMessage:S==null?void 0:S.message,validationState:k?"invalid":"valid",onChange:g,onBlur:p,defaultValue:f})})]}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{type:"submit",variant:"danger",isDisabled:!d,size:"compact",loading:i,onClick:()=>{var y;(y=l.current)==null||y.requestSubmit()},children:i?"Removing...":"Remove Data"})})})]})}function ac({projectId:n,projectName:a,onProjectDelete:l,onProjectClear:t,onProjectRemoveData:i}){const[r,o]=u.useState(null),c=a!=="default",[d]=_.useMutation(gi),[m]=_.useMutation(mi),y=u.useCallback(()=>{u.startTransition(()=>{d({variables:{projectId:n}}),l()})},[d,n,l]),g=u.useCallback(()=>{u.startTransition(()=>{m({variables:{input:{id:n}},onCompleted:()=>{t()},onError:S=>{alert("Failed to clear project: "+S)}})})},[m,n,t]),p=u.useCallback(()=>{o(s(G,{size:"S",title:"Delete Project",children:[e(T,{padding:"size-200",children:e(x,{color:"danger",children:`Are you sure you want to delete project ${a}? This cannot be undone.`})}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:"danger",onClick:()=>{y(),o(null)},children:"Delete Project"})})})]}))},[y,a]),f=u.useCallback(()=>{o(s(G,{size:"S",title:"Clear Project",children:[e(T,{padding:"size-200",children:e(x,{color:"danger",children:`Are you sure you want to clear project ${a}? All traces and evaluations for this project will be deleted. This cannot be undone.`})}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:"danger",onClick:()=>{g(),o(null)},children:"Clear"})})})]}))},[g,a]),k=u.useCallback(()=>{o(e(G,{size:"M",title:"Remove Data",children:e(nc,{projectId:n,onComplete:()=>{i(),o(null)}})}))},[i,n]);return s("div",{onClick:S=>{S.preventDefault(),S.stopPropagation()},children:[s(qe,{buttonVariant:"quiet",align:"end",onAction:S=>{switch(S){case"deleteProject":return p();case"clearProject":return f();case"removeProjectData":return k()}},disabledKeys:c?[]:["deleteProject"],children:[e(H,{textValue:"Clear Traces",children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.Refresh,{})}),e(x,{children:"Clear Data"})]})},"clearProject"),e(H,{textValue:"Remove Data",children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.CloseCircleOutline,{})}),e(x,{children:"Remove Data"})]})},"removeProjectData"),c?e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.TrashOutline,{})}),e(x,{children:"Delete"})]})},"deleteProject"):null]}),e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>o(null),children:r})]})}const lc=1e4,tc=100;function Tu(){const{timeRange:n}=Yn();return e(u.Suspense,{fallback:e(ue,{}),children:e(ic,{timeRange:n})})}function ic({timeRange:n}){const[a,l]=is(),t=u.useMemo(()=>({start:n.start.toISOString(),end:n.end.toISOString()}),[n]),i=_.useLazyLoadQuery(ui,{timeRange:t}),{data:r,loadNext:o,hasNext:c,isLoadingNext:d,refetch:m}=_.usePaginationFragment(ci,i),y=r.projects.edges.map(h=>h.project),g=u.useRef(null),p=u.useCallback(h=>{if(h){const{scrollHeight:F,scrollTop:L,clientHeight:I}=h;F-L-I<300&&!d&&c&&o(tc)}},[c,d,o]);li(()=>{u.startTransition(()=>{m({},{fetchPolicy:"store-and-network"})})},lc);const f=u.useCallback(h=>{u.startTransition(()=>{m({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Deleted",message:`Project ${h} has been deleted.`})})},[a,m]),k=u.useCallback(h=>{u.startTransition(()=>{m({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Cleared",message:`Project ${h} has been cleared of traces.`})})},[a,m]),S=u.useCallback(h=>{u.startTransition(()=>{m({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Data Removed",message:`Old data from project ${h} have been removed.`})})},[a,m]);return s("div",{css:K`
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: var(--ac-global-dimension-size-750);
      `,onScroll:h=>p(h.target),ref:g,children:[e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",width:"100%",borderBottomColor:"grey-200",borderBottomWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(pl,{})})}),e(T,{padding:"size-200",width:"100%",children:e("ul",{css:K`
            display: flex;
            flex-direction: row;
            gap: var(--ac-global-dimension-size-200);
            flex-wrap: wrap;
          `,children:y.map(h=>e("li",{children:e(Tn,{to:`/projects/${h.id}`,css:K`
                  text-decoration: none;
                `,children:e(sc,{project:h,onProjectDelete:()=>f(h.name),onProjectClear:()=>k(h.name),onProjectRemoveData:()=>S(h.name)})})},h.id))})}),l]})}function rc({gradientStartColor:n,gradientEndColor:a}){return e("div",{css:K`
        border-radius: 50%;
        width: 32px;
        height: 32px;
        background: linear-gradient(
          136.27deg,
          ${n} 14.03%,
          ${a} 84.38%
        );
        flex-shrink: 0;
      `})}function sc({project:n,onProjectDelete:a,onProjectClear:l,onProjectRemoveData:t}){const{endTime:i,traceCount:r,tokenCountTotal:o,latencyMsP50:c,gradientStartColor:d,gradientEndColor:m}=n,y=u.useMemo(()=>i?`Last updated  ${lr(new Date(i),new Date,{addSuffix:!0})}`:"No traces uploaded yet.",[i]);return s("div",{css:K`
        padding: var(--ac-global-dimension-size-200);
        border: 1px solid var(--ac-global-color-grey-400);
        background-color: var(--ac-global-color-grey-100);
        border-radius: var(--ac-global-rounding-medium);
        height: var(--ac-global-dimension-size-1250);
        width: var(--ac-global-dimension-size-3600);
        transition: border-color 0.2s;
        &:hover {
          border-color: var(--ac-global-color-primary);
        }
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      `,children:[s(b,{direction:"row",justifyContent:"space-between",alignItems:"start",children:[s(b,{direction:"row",gap:"size-100",alignItems:"center",minWidth:0,children:[e(rc,{gradientStartColor:d,gradientEndColor:m}),s(b,{direction:"column",minWidth:0,children:[e(oe,{level:2,css:K`
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              `,children:n.name}),e(x,{color:"text-700",textSize:"small",fontStyle:"italic",children:y})]})]}),e(ac,{projectId:n.id,projectName:n.name,onProjectDelete:a,onProjectClear:l,onProjectRemoveData:t})]}),s(b,{direction:"row",justifyContent:"space-between",children:[s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Traces"}),e(x,{textSize:"xlarge",children:tn(r)})]}),s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Tokens"}),e(x,{textSize:"xlarge",children:tn(o)})]}),s(b,{direction:"column",flex:"none",children:[e(x,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P50"}),c!=null?e(we,{latencyMs:c,textSize:"xlarge"}):e(x,{textSize:"xlarge",children:"--"})]})]})]})}const yi=function(){var n=[{kind:"Literal",name:"first",value:100},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetsPageQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetsTable_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetsPageQuery",selections:[{alias:null,args:n,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:'datasets(first:100,sort:{"col":"createdAt","dir":"desc"})'},{alias:null,args:n,filters:["sort"],handle:"connection",key:"DatasetsTable_datasets",kind:"LinkedHandle",name:"datasets"}]},params:{cacheID:"695b221e981c4795492d79faa7d007e4",id:null,metadata:{},name:"DatasetsPageQuery",operationKind:"query",text:`query DatasetsPageQuery {
  ...DatasetsTable_datasets
}

fragment DatasetsTable_datasets on Query {
  datasets(first: 100, sort: {col: createdAt, dir: desc}) {
    edges {
      node {
        id
        name
        description
        metadata
        createdAt
        exampleCount
        experimentCount
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();yi.hash="985853a7939f44c0cefdd1a91472c67e";function oc(n){const a=n.split(`
`);return a.length>0?a[0].split(",").map(l=>l.trim()):[]}function dc(n){const{onDatasetCreated:a,onDatasetCreateError:l}=n,[t,i]=u.useState([]),{control:r,handleSubmit:o,resetField:c,formState:{isDirty:d,isValid:m}}=bn({defaultValues:{name:"Dataset "+new Date().toISOString(),input_keys:[],output_keys:[],metadata_keys:[],description:"",metadata:{}}}),y=u.useCallback(g=>{const p=new FormData;return p.append("file",g.file[0]),p.append("name",g.name),p.append("description",g.description),p.append("metadata",JSON.stringify(g.metadata)),g.input_keys.forEach(f=>{p.append("input_keys[]",f)}),g.output_keys.forEach(f=>{p.append("output_keys[]",f)}),g.metadata_keys.forEach(f=>{p.append("metadata_keys[]",f)}),fetch("/v1/datasets/upload?sync=true",{method:"POST",body:p}).then(f=>{if(!f.ok)throw l(new Error(f.statusText||"Failed to create dataset"));return f.json()}).then(f=>{a({name:g.name,id:f.data.dataset_id})})},[l,a]);return s(wn,{onSubmit:o(y),children:[s("div",{css:K`
          padding: var(--ac-global-dimension-size-200);
          .ac-dropdown-button {
            width: 100%;
          }
        `,children:[e(U,{name:"name",control:r,rules:{required:"field is required"},render:({field:{onChange:g,onBlur:p,value:f},fieldState:{invalid:k,error:S}})=>e(ye,{label:"Dataset Name",description:"The name of the dataset",errorMessage:S==null?void 0:S.message,validationState:k?"invalid":"valid",onChange:g,onBlur:p,value:f.toString()})}),e(U,{name:"description",control:r,render:({field:{onChange:g,onBlur:p,value:f},fieldState:{invalid:k,error:S}})=>e(la,{label:"description",placeholder:"Description of the dataset",isRequired:!1,height:100,errorMessage:S==null?void 0:S.message,validationState:k?"invalid":"valid",onChange:g,onBlur:p,value:f.toString()})}),e(U,{control:r,name:"file",rules:{required:"CSV file is required"},render:({field:{value:g,onChange:p,...f},fieldState:{invalid:k,error:S}})=>e(ia,{label:"CSV file",validationState:k?"invalid":"valid",errorMessage:S==null?void 0:S.message,children:e("input",{...f,onChange:h=>{var L;p(h.target.files),c("input_keys"),c("output_keys"),c("metadata_keys");const F=(L=h.target.files)==null?void 0:L[0];if(F){const I=new FileReader;I.onload=function(C){if(!C.target)return;const v=C.target.result,D=oc(v);i(D)},I.readAsText(F)}},type:"file",id:"file",accept:".csv"})})}),e(U,{name:"input_keys",control:r,rules:{required:"field is required"},render:({field:{value:g,onChange:p},fieldState:{invalid:f,error:k}})=>e(fa,{label:"input keys",validationState:f?"invalid":"valid",description:"the columns to use as input",columns:t,selectedColumns:g,onChange:p,errorMessage:k==null?void 0:k.message})}),e(U,{name:"output_keys",control:r,render:({field:{value:g,onChange:p},fieldState:{invalid:f,error:k}})=>e(fa,{label:"output keys",validationState:f?"invalid":"valid",description:"the columns to use as output",columns:t,selectedColumns:g,onChange:p,errorMessage:k==null?void 0:k.message})}),e(U,{name:"metadata_keys",control:r,render:({field:{value:g,onChange:p},fieldState:{invalid:f,error:k}})=>e(fa,{label:"metadata keys",validationState:f?"invalid":"valid",description:"the columns to use as metadata",columns:t,selectedColumns:g,onChange:p,errorMessage:k==null?void 0:k.message})})]}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{type:"submit",isDisabled:!m,variant:d?"primary":"default",size:"compact",loading:!1,children:"Create Dataset"})})})]})}function fa(n){const{columns:a,selectedColumns:l,onChange:t,label:i,validationState:r,description:o,errorMessage:c,...d}=n,m=a.length===0,y=u.useMemo(()=>m?"No columns to select":l.length>0?`${l.join(", ")}`:"No columns selected",[l,m]);return e(ia,{label:i,isDisabled:m,validationState:r,description:o,errorMessage:c,children:e(wa,{isDisabled:m,...d,menu:e(On,{selectionMode:"multiple",onSelectionChange:g=>{t(Array.from(g))},selectedKeys:new Set(l),children:a.map(g=>e(H,{children:g},g))}),triggerProps:{placement:"bottom end"},children:y})})}const fi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"createdAt",dir:"desc"},kind:"LocalArgument",name:"sort"}],a=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"},{kind:"Variable",name:"sort",variableName:"sort"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetsTableDatasetsQuery",selections:[{args:a,kind:"FragmentSpread",name:"DatasetsTable_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetsTableDatasetsQuery",selections:[{alias:null,args:a,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:a,filters:["sort"],handle:"connection",key:"DatasetsTable_datasets",kind:"LinkedHandle",name:"datasets"}]},params:{cacheID:"5ac1688f54e51f9bb3247c83e23d98fb",id:null,metadata:{},name:"DatasetsTableDatasetsQuery",operationKind:"query",text:`query DatasetsTableDatasetsQuery(
  $after: String = null
  $first: Int = 100
  $sort: DatasetSort = {col: createdAt, dir: desc}
) {
  ...DatasetsTable_datasets_dWkdd
}

fragment DatasetsTable_datasets_dWkdd on Query {
  datasets(first: $first, after: $after, sort: $sort) {
    edges {
      node {
        id
        name
        description
        metadata
        createdAt
        exampleCount
        experimentCount
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();fi.hash="fa378bc7ec26f5e877e6cf90e5ee553d";const hi=function(){var n=["datasets"];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"createdAt",dir:"desc"},kind:"LocalArgument",name:"sort"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:[],operation:fi}},name:"DatasetsTable_datasets",selections:[{alias:"datasets",args:[{kind:"Variable",name:"sort",variableName:"sort"}],concreteType:"DatasetConnection",kind:"LinkedField",name:"__DatasetsTable_datasets_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null}}();hi.hash="fa378bc7ec26f5e877e6cf90e5ee553d";const ki=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{alias:null,args:[{fields:[{kind:"Variable",name:"datasetId",variableName:"datasetId"}],kind:"ObjectValue",name:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"deleteDataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DeleteDatasetDialogMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DeleteDatasetDialogMutation",selections:a},params:{cacheID:"3d32b97acd630dd7dbc9c85a632a1d49",id:null,metadata:{},name:"DeleteDatasetDialogMutation",operationKind:"mutation",text:`mutation DeleteDatasetDialogMutation(
  $datasetId: GlobalID!
) {
  deleteDataset(input: {datasetId: $datasetId}) {
    __typename
  }
}
`}}}();ki.hash="7066cca7015a7e344b77862b0bdab21c";function cc({datasetId:n,datasetName:a,onDatasetDelete:l,onDatasetDeleteError:t}){const[i,r]=_.useMutation(ki),o=u.useCallback(()=>{u.startTransition(()=>{i({variables:{datasetId:n},onCompleted:()=>{l()},onError:c=>{t(c)}})})},[i,n,l,t]);return s(G,{size:"S",title:"Delete Dataset",children:[e(T,{padding:"size-200",children:e(x,{color:"danger",children:`Are you sure you want to delete dataset ${a}? This will also delete all associated experiments and traces, and it cannot be undone.`})}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:"danger",onClick:()=>{o()},disabled:r,loading:r,children:"Delete Dataset"})})})]})}function uc({datasetName:n,datasetId:a,datasetDescription:l,datasetMetadata:t,onDatasetEdited:i,onDatasetEditError:r}){return e(G,{title:"Edit Dataset",size:"M",children:e(Ur,{datasetName:n,datasetId:a,datasetDescription:l,datasetMetadata:t,onDatasetEdited:i,onDatasetEditError:r})})}function mc(n){const{datasetId:a,datasetName:l,datasetDescription:t,datasetMetadata:i,onDatasetDelete:r,onDatasetDeleteError:o,onDatasetEdit:c,onDatasetEditError:d}=n,[m,y]=u.useState(null),g=u.useCallback(()=>{y(e(cc,{datasetId:a,datasetName:l,onDatasetDelete:()=>{r(),y(null)},onDatasetDeleteError:o}))},[a,l,r,o]),p=u.useCallback(()=>{y(e(uc,{datasetId:a,datasetName:l,datasetDescription:t,datasetMetadata:i,onDatasetEdited:()=>{c(),y(null)},onDatasetEditError:d}))},[t,a,i,l,c,d]);return s("div",{onClick:f=>{f.preventDefault(),f.stopPropagation()},children:[s(qe,{align:"end",buttonSize:"compact",onAction:f=>{switch(f){case"deleteDataset":g();break;case"editDataset":p();break}},children:[e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.TrashOutline,{})}),e(x,{children:"Delete"})]})},"deleteDataset"),e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.Edit2Outline,{})}),e(x,{children:"Edit"})]})},"editDataset")]}),e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>y(null),children:m})]})}const Ja=100;function gc(n){const a=n.id;if(a!=="createdAt"&&a!=="name")throw new Error("Invalid sort column");return{col:a,dir:n.desc?"desc":"asc"}}function pc(n){const[a,l]=u.useState([]),t=u.useRef(null),i=ae(),r=ve(),o=Qn(),{data:c,loadNext:d,hasNext:m,isLoadingNext:y,refetch:g}=_.usePaginationFragment(hi,n.query),p=u.useMemo(()=>c.datasets.edges.map(F=>F.node),[c]),f=ke.useCallback(F=>{if(F){const{scrollHeight:L,scrollTop:I,clientHeight:C}=F;L-I-C<300&&!y&&m&&d(Ja)}},[m,y,d]),k=be({columns:[{header:"name",accessorKey:"name",cell:({row:F})=>{const I=F.original.experimentCount>0?`${F.original.id}/experiments`:`${F.original.id}/examples`;return e(Tn,{to:I,children:F.original.name})}},{header:"description",accessorKey:"description",enableSorting:!1},{header:"created at",accessorKey:"createdAt",cell:Dn},{header:"example count",accessorKey:"exampleCount",enableSorting:!1,meta:{textAlign:"right"}},{header:"experiment count",accessorKey:"experimentCount",enableSorting:!1,meta:{textAlign:"right"}},{header:"metadata",accessorKey:"metadata",enableSorting:!1,cell:fn},{header:"",id:"actions",enableSorting:!1,size:10,cell:({row:F})=>e(mc,{datasetId:F.original.id,datasetName:F.original.name,datasetDescription:F.original.description,datasetMetadata:F.original.metadata,onDatasetEdit:()=>{r({title:"Dataset updated",message:`${F.original.name} has been successfully updated.`}),g({},{fetchPolicy:"store-and-network"})},onDatasetEditError:L=>{o({title:"Dataset update failed",message:L.message})},onDatasetDelete:()=>{r({title:"Dataset deleted",message:`${F.original.name} has been successfully deleted.`}),g({},{fetchPolicy:"store-and-network"})},onDatasetDeleteError:L=>{o({title:"Dataset deletion failed",message:L.message})}})}],data:p,state:{sorting:a},getCoreRowModel:Se(),getSortedRowModel:Nn(),onSortingChange:l,manualSorting:!0});u.useEffect(()=>{const F=a[0];u.startTransition(()=>{g({sort:F?gc(F):{col:"createdAt",dir:"desc"},after:null,first:Ja},{fetchPolicy:"store-and-network"})})},[a,g]);const S=k.getRowModel().rows,h=S.length===0;return e("div",{css:K`
        flex: 1 1 auto;
        overflow: auto;
      `,onScroll:F=>f(F.target),ref:t,children:s("table",{css:xn,children:[e("thead",{children:k.getHeaderGroups().map(F=>e("tr",{children:F.headers.map(L=>{var I;return e("th",{colSpan:L.colSpan,children:L.isPlaceholder?null:s("div",{className:L.column.getCanSort()?"cursor-pointer":"",onClick:L.column.getToggleSortingHandler(),style:{textAlign:(I=L.column.columnDef.meta)==null?void 0:I.textAlign},children:[J(L.column.columnDef.header,L.getContext()),L.column.getIsSorted()?e(M,{className:"sort-icon",svg:L.column.getIsSorted()==="asc"?e(P.ArrowUpFilled,{}):e(P.ArrowDownFilled,{})}):null]})},L.id)})},F.id))}),h?e(on,{}):e("tbody",{children:S.map(F=>e("tr",{onClick:()=>{const I=F.original.experimentCount>0?`${F.original.id}/experiments`:`${F.original.id}/examples`;i(I)},children:F.getVisibleCells().map(L=>{var I;return e("td",{align:(I=L.column.columnDef.meta)==null?void 0:I.textAlign,children:J(L.column.columnDef.cell,L.getContext())},L.id)})},F.id))})]})})}function Du(){return e(u.Suspense,{fallback:e(ue,{}),children:e(yc,{})})}function yc(){const[n,a]=u.useState(0),l=_.useLazyLoadQuery(yi,{},{fetchKey:n,fetchPolicy:"store-and-network"}),t=u.useCallback(()=>{a(i=>i+1)},[a]);return s(b,{direction:"column",height:"100%",children:[e(T,{padding:"size-200",borderBottomWidth:"thin",borderBottomColor:"dark",flex:"none",children:s(b,{direction:"row",justifyContent:"space-between",children:[e(oe,{level:1,children:"Datasets"}),e(fc,{onDatasetCreated:t})]})}),e(pc,{query:l})]})}function fc({onDatasetCreated:n}){const a=ae(),l=ve(),t=Qn(),[i,r]=u.useState(null),o=()=>{r(e(G,{size:"S",title:"New Dataset",children:e(Ca,{onDatasetCreated:d=>{l({title:"Dataset created",message:`${d.name} has been successfully created.`,action:{text:"Go to Dataset",onClick:()=>{a(`/datasets/${d.id}`)}}}),r(null),n()},onDatasetCreateError:d=>{t({title:"Dataset creation failed",message:d.message})}})}))},c=()=>{r(e(G,{size:"M",title:"New Dataset from CSV",children:e(dc,{onDatasetCreated:d=>{l({title:"Dataset created",message:`${d.name} has been successfully created.`,action:{text:"Go to Dataset",onClick:()=>{a(`/datasets/${d.id}`)}}}),r(null),n()},onDatasetCreateError:d=>{t({title:"Dataset creation failed",message:d.message})}})}))};return s(B,{children:[s(qe,{buttonText:"Create Dataset",align:"end",icon:e(M,{svg:e(P.DatabaseOutline,{})}),onAction:d=>{switch(d){case"newDataset":o();break;case"datasetFromCSV":c();break}},children:[e(H,{children:"New Dataset"},"newDataset"),e(H,{children:"Dataset from CSV"},"datasetFromCSV")]}),e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>r(null),children:i})]})}const bi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{kind:"Variable",name:"id",variableName:"datasetId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={kind:"InlineFragment",selections:[{alias:"latestVersions",args:[{kind:"Literal",name:"first",value:1},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}],concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"version",args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'versions(first:1,sort:{"col":"createdAt","dir":"desc"})'}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"datasetStore_latestVersionQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,t],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"datasetStore_latestVersionQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,t],storageKey:null}]},params:{cacheID:"d7075240e4dae8871997e57616c05302",id:null,metadata:{},name:"datasetStore_latestVersionQuery",operationKind:"query",text:`query datasetStore_latestVersionQuery(
  $datasetId: GlobalID!
) {
  dataset: node(id: $datasetId) {
    __typename
    id
    ... on Dataset {
      latestVersions: versions(first: 1, sort: {col: createdAt, dir: desc}) {
        edges {
          version: node {
            id
            description
            createdAt
          }
        }
      }
    }
  }
}
`}}}();bi.hash="a1349b92d8b0c745f5e8039c55b048c7";const hc=n=>{const a=(l,t)=>({...n,isRefreshingLatestVersion:!1,refreshLatestVersion:async()=>{const i=t();l({isRefreshingLatestVersion:!0});const r=await kc({datasetId:i.datasetId});l({latestVersion:r,isRefreshingLatestVersion:!1})}});return tr()(ir(a))};async function kc({datasetId:n}){var i;const a=await _.fetchQuery(Ce,bi,{datasetId:n}).toPromise(),l=(i=a==null?void 0:a.dataset.latestVersions)==null?void 0:i.edges;return l&&l.length&&l[0].version||null}const Si=u.createContext(null);function bc({children:n,...a}){const l=u.useRef();return l.current||(l.current=hc(a)),e(Si.Provider,{value:l.current,children:n})}function rn(n,a){const l=u.useContext(Si);if(!l)throw new Error("Missing DatasetContext.Provider in the tree");return al(l,n,a)}const vi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addExamplesToDataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"AddDatasetExampleDialogMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"AddDatasetExampleDialogMutation",selections:a},params:{cacheID:"718cf02ccb39b279132822bf503e51e6",id:null,metadata:{},name:"AddDatasetExampleDialogMutation",operationKind:"mutation",text:`mutation AddDatasetExampleDialogMutation(
  $input: AddExamplesToDatasetInput!
) {
  addExamplesToDataset(input: $input) {
    __typename
  }
}
`}}}();vi.hash="8d99470f590cd5d28701fa6e3c0330e6";const ha={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function Sc(n){const{datasetId:a,onCompleted:l}=n,[t,i]=u.useState(null),[r,o]=_.useMutation(vi),{control:c,setError:d,handleSubmit:m,formState:{isValid:y}}=bn({defaultValues:{input:"{}",output:"{}",metadata:"{}"}}),g=u.useCallback(p=>{if(i(null),!Ee(p==null?void 0:p.input))return d("input",{message:"Input must be a valid JSON object"});if(!Ee(p==null?void 0:p.output))return d("output",{message:"Output must be a valid JSON object"});if(!Ee(p==null?void 0:p.metadata))return d("metadata",{message:"Metadata must be a valid JSON object"});r({variables:{input:{datasetId:a,examples:[{input:JSON.parse(p.input),output:JSON.parse(p.output),metadata:JSON.parse(p.metadata)}],datasetVersionDescription:p.description}},onCompleted:()=>{l()},onError:f=>{i(f.message)}})},[r,a,d,l]);return s(G,{size:"L",title:"Add Example",children:[e("div",{css:K`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
        `,children:e(b,{direction:"row",justifyContent:"center",children:e(T,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(b,{direction:"column",gap:"size-200",children:[t?e(ne,{variant:"danger",children:t}):null,e(U,{control:c,name:"input",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...ha,children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"output",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...ha,backgroundColor:"green-100",borderColor:"green-700",children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"metadata",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...ha,children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"description",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>e(la,{label:"Version Description",value:k,onChange:p,onBlur:f,errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",placeholder:"A description of the changes made. Will be displayed in the version history.",height:100})})]})})})}),e(T,{padding:"size-200",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",gap:"size-100",children:e(z,{variant:"primary",size:"compact",disabled:!y||o,loading:o,onClick:m(g),children:"Add Example"})})})]})}function vc(n){const{datasetId:a,onAddExampleCompleted:l}=n,[t,i]=u.useState(null),r=u.useCallback(()=>{i(e(Sc,{datasetId:a,onCompleted:()=>{l(),i(null)}}))},[a,l]);return s(B,{children:[e(z,{icon:e(M,{svg:e(P.PlusCircleOutline,{})}),size:"compact",variant:"default",onClick:r,children:"Add Example"}),e(ee,{isDismissable:!0,onDismiss:()=>{i(null)},children:t})]})}function Fc(){const n=rn(i=>i.datasetId),a=rn(i=>i.latestVersion);let l=`${Jr}/v1/datasets/${n}/examples`;a&&(l+=`?version-id=${a.id}`);const t=u.useMemo(()=>`import phoenix as px
client = px.Client()
# Get the current dataset version
dataset = client.get_dataset(id="${n}"${a?`, version_id="${a.id}"`:""})`,[n,a]);return e("div",{css:K`
        button.ac-dropdown-button {
          min-width: 80px;
          .ac-dropdown-button__text {
            padding-right: 10px;
          }
        }
      `,children:s(dn,{placement:"bottom right",children:[e(vl,{addonBefore:e(M,{svg:e(P.Code,{})}),children:"Code"}),e(_a,{children:s("section",{css:K`
              width: 500px;
              .ac-field {
                flex: 1 1 auto;
              }
            `,children:[e(T,{padding:"size-200",children:s(wn,{children:[s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"Dataset ID",isReadOnly:!0,value:n}),e(Y,{text:n,size:"normal"})]}),s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"Version ID",isReadOnly:!0,value:(a==null?void 0:a.id)||"No Versions",validationState:a?"valid":"invalid"}),e(Y,{text:(a==null?void 0:a.id)||"No Versions",disabled:!a,size:"normal"})]})]})}),s(he,{children:[e(q,{name:"Python",children:e(T,{margin:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"small",children:e(Xe,{value:t})})}),e(q,{name:"REST",children:e(T,{padding:"size-200",children:e(wn,{children:s(b,{direction:"row",gap:"size-100",alignItems:"end",children:[e(ye,{label:"URL",isReadOnly:!0,value:l}),e(Y,{text:l,size:"normal"})]})})})})]})]})})]})})}const Fi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{kind:"Variable",name:"id",variableName:"datasetId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetHistoryDialogQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,{args:null,kind:"FragmentSpread",name:"DatasetHistoryTable_versions"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetHistoryDialogQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},t],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"versions(first:100)"},{alias:null,args:i,filters:null,handle:"connection",key:"DatasetHistoryTable_versions",kind:"LinkedHandle",name:"versions"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"df94b4e72c0187fd0fd1c8416af19354",id:null,metadata:{},name:"DatasetHistoryDialogQuery",operationKind:"query",text:`query DatasetHistoryDialogQuery(
  $datasetId: GlobalID!
) {
  dataset: node(id: $datasetId) {
    __typename
    ... on Dataset {
      id
      ...DatasetHistoryTable_versions
    }
    __isNode: __typename
    id
  }
}

fragment DatasetHistoryTable_versions on Dataset {
  versions(first: 100) {
    edges {
      node {
        id
        description
        createdAt
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Fi.hash="7215c18bda690418c5ecbcb3131a288e";const Ki=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetHistoryTableVersionsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"DatasetHistoryTable_versions"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetHistoryTableVersionsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},t],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"DatasetHistoryTable_versions",kind:"LinkedHandle",name:"versions"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"e8e3a05b4e86c8eaeea98172405fdc7e",id:null,metadata:{},name:"DatasetHistoryTableVersionsQuery",operationKind:"query",text:`query DatasetHistoryTableVersionsQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...DatasetHistoryTable_versions_2HEEH6
    __isNode: __typename
    id
  }
}

fragment DatasetHistoryTable_versions_2HEEH6 on Dataset {
  versions(first: $first, after: $after) {
    edges {
      node {
        id
        description
        createdAt
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ki.hash="37e453bc58759a1e89bc5862c460de6b";const xi=function(){var n=["versions"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:Ki,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"DatasetHistoryTable_versions",selections:[{alias:"versions",args:null,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"__DatasetHistoryTable_versions_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Dataset",abstractKey:null}}();xi.hash="37e453bc58759a1e89bc5862c460de6b";const Kc=100;function xc(n){const a=u.useRef(null),{data:l,loadNext:t,hasNext:i,isLoadingNext:r}=_.usePaginationFragment(xi,n.dataset),o=u.useMemo(()=>l.versions.edges.map(g=>g.node),[l]),c=ke.useCallback(g=>{if(g){const{scrollHeight:p,scrollTop:f,clientHeight:k}=g;p-f-k<300&&!r&&i&&t(Kc)}},[i,r,t]),d=be({columns:[{header:"version ID",accessorKey:"id"},{header:"description",accessorKey:"description"},{header:"created at",accessorKey:"createdAt",cell:Dn}],data:o,getCoreRowModel:Se(),getSortedRowModel:Nn()}),m=d.getRowModel().rows,y=m.length===0;return e("div",{css:K`
        flex: 1 1 auto;
        overflow: auto;
      `,onScroll:g=>c(g.target),ref:a,children:s("table",{css:Vn,children:[e("thead",{children:d.getHeaderGroups().map(g=>e("tr",{children:g.headers.map(p=>e("th",{colSpan:p.colSpan,children:p.isPlaceholder?null:s("div",{className:p.column.getCanSort()?"cursor-pointer":"",onClick:p.column.getToggleSortingHandler(),style:{left:p.getStart(),width:p.getSize()},children:[J(p.column.columnDef.header,p.getContext()),p.column.getIsSorted()?e(M,{className:"sort-icon",svg:p.column.getIsSorted()==="asc"?e(P.ArrowUpFilled,{}):e(P.ArrowDownFilled,{})}):null]})},p.id))},g.id))}),y?e(on,{}):e("tbody",{children:m.map(g=>e("tr",{children:g.getVisibleCells().map(p=>e("td",{children:J(p.column.columnDef.cell,p.getContext())},p.id))},g.id))})]})})}function Tc(n){const{datasetId:a}=n,l=_.useLazyLoadQuery(Fi,{datasetId:a});return e(G,{size:"L",title:"Dataset History",children:e("div",{css:K`
          height: 500px;
        `,children:e(xc,{dataset:l.dataset})})})}function Dc(n){const{datasetId:a}=n,[l,t]=u.useState(null);return s(B,{children:[s(pe,{children:[e(z,{variant:"default",icon:e(M,{svg:e(P.ClockOutline,{})}),"aria-label":"Version History",onClick:()=>{t(e(Tc,{datasetId:a}))}}),e(en,{children:"Dataset Version History"})]}),e(u.Suspense,{fallback:null,children:e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>{t(null)},children:l})})]})}const Cc=`pip install arize-phoenix>=${window.Config.platformVersion}`,Ic=`import os
# Set the phoenix collector endpoint. Commonly http://localhost:6060 
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "<your-phoenix-url>"`,Lc=`from phoenix.experiments import Example
# Define your task
# Typically should be an LLM call or a call to your application
def my_task(example: Example) -> str:
    # This is just an example of how to return a JSON serializable value
    return f"Hello {example.input["person"]}"`,Ec=`# Define an evaluator. This just an example.
def exact_match(input, output) -> float:
    return 1.0 if output is f"Hello {input}" else 0.0

# Store the evaluators for later use
evaluators = [exact_match]`,_c=`# Run an experiment
from phoenix.experiments import run_experiment

experiment = run_experiment(dataset, my_task, evaluators=evaluators)`;function Ti(){const[n,a]=u.useState(null),l=u.useCallback(()=>{a(e(G,{title:"Run Experiment",size:"XL",children:e(Rc,{})}))},[]);return s(B,{children:[e(z,{size:"compact",variant:"default",icon:e(M,{svg:e(P.ExperimentOutline,{})}),onClick:l,children:"Run Experiment"}),e(ee,{isDismissable:!0,type:"slideOver",onDismiss:()=>{a(null)},children:n})]})}function Rc(){const n=rn(t=>t.datasetName),a=rn(t=>t.latestVersion),l=u.useMemo(()=>`import phoenix as px
# Initialize a phoenix client
client = px.Client()
# Get the current dataset version. You can omit the version for the latest.
dataset = client.get_dataset(name="${n}"${a?`, version_id="${a.id}"`:""})`,[n,a]);return s(T,{padding:"size-400",overflow:"auto",children:[e(T,{paddingBottom:"size-100",children:e(x,{children:"Install Phoenix"})}),e(mn,{children:e(Xe,{value:Cc})}),e(T,{paddingTop:"size-100",paddingBottom:"size-100",children:e(x,{children:"Point to a running instance of Phoenix"})}),e(mn,{children:e(Xe,{value:Ic})}),e(T,{paddingTop:"size-100",paddingBottom:"size-100",children:e(x,{children:"Pull down this dataset"})}),e(mn,{children:e(Xe,{value:l})}),e(T,{paddingTop:"size-100",paddingBottom:"size-100",children:e(x,{children:"Define your task"})}),e(mn,{children:e(Xe,{value:Lc})}),e(T,{paddingTop:"size-100",paddingBottom:"size-100",children:e(x,{children:"Define evaluators"})}),e(mn,{children:e(Xe,{value:Ec})}),e(T,{paddingTop:"size-100",paddingBottom:"size-100",children:e(x,{children:"Run an experiment"})}),e(mn,{children:e(Xe,{value:_c})})]})}function mn({children:n}){return e(T,{borderColor:"light",borderWidth:"thin",borderRadius:"small",children:n})}function Cu(){const n=An(),a=u.useMemo(()=>{const l=n.dataset.latestVersions;return l!=null&&l.edges&&l.edges.length?l.edges[0].version:null},[n]);return e(bc,{datasetId:n.dataset.id,datasetName:n.dataset.name,latestVersion:a,children:e(u.Suspense,{fallback:e(ue,{}),children:e(Pc,{dataset:n.dataset})})})}const wc=K`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .ac-tabs {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    div[role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      div[role="tabpanel"]:not([hidden]) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
`;function Pc({dataset:n}){const a=n.id,l=rn(d=>d.refreshLatestVersion),t=ve(),i=ae(),r=u.useCallback(d=>{d===0?i(`/datasets/${a}/experiments`):d===1&&i(`/datasets/${a}/examples`)},[i,a]),c=rr().pathname.includes("examples")?1:0;return s("main",{css:wc,children:[e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-200",paddingBottom:"size-50",flex:"none",children:s(b,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(b,{direction:"column",justifyContent:"space-between",children:e(b,{direction:"row",gap:"size-200",alignItems:"center",children:s(b,{direction:"column",children:[e(x,{elementType:"h1",textSize:"xlarge",weight:"heavy",children:n.name}),e(x,{color:"text-700",children:n.description||"--"})]})})}),s(b,{direction:"row",gap:"size-100",children:[s(qe,{align:"end",icon:e(M,{svg:e(P.DownloadOutline,{})}),onAction:d=>{switch(d){case"csv":window.open(`/v1/datasets/${n.id}/csv`,"_blank");break;case"openai-ft":window.open(`/v1/datasets/${n.id}/jsonl/openai_ft`,"_blank");break;case"openai-evals":window.open(`/v1/datasets/${n.id}/jsonl/openai_evals`,"_blank");break}},children:[e(H,{children:"Download CSV"},"csv"),e(H,{children:"Download OpenAI Fine-Tuning JSONL"},"openai-ft"),e(H,{children:"Download OpenAI Evals JSONL"},"openai-evals")]}),e(Dc,{datasetId:n.id}),e(Fc,{}),e(Ti,{}),e(vc,{datasetId:n.id,onAddExampleCompleted:()=>{t({title:"Example added",message:"The example has been added successfully and the version has been updated."}),l()}})]})]})}),s(he,{onChange:r,defaultIndex:c,children:[e(q,{name:"Experiments",extra:e(Ae,{children:n.experimentCount}),children:e(u.Suspense,{children:e(Te,{})})}),e(q,{name:"Examples",extra:e(Ae,{children:n.exampleCount}),children:e(u.Suspense,{children:e(Te,{})})})]})]})}const Di=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},i={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},t,{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:"latestVersions",args:[{kind:"Literal",name:"first",value:1},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}],concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"version",args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,t,{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'versions(first:1,sort:{"col":"createdAt","dir":"desc"})'}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"datasetLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,i],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"datasetLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,i],storageKey:null}]},params:{cacheID:"5b221627cf7e63f41fbec41027cc0951",id:null,metadata:{},name:"datasetLoaderQuery",operationKind:"query",text:`query datasetLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      id
      name
      description
      exampleCount
      experimentCount
      latestVersions: versions(first: 1, sort: {col: createdAt, dir: desc}) {
        edges {
          version: node {
            id
            description
            createdAt
          }
        }
      }
    }
  }
}
`}}}();Di.hash="469da2debdebd608c88a6ef83c2540aa";async function Iu(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ce,Di,{id:a}).toPromise()}const Ci=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"exampleId"}],a=[{kind:"Variable",name:"id",variableName:"exampleId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},i={alias:"latestRevision",args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},t,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},o={alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"span",plural:!1,selections:[l,{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[r],storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null}],storageKey:null},c={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},d=[{kind:"Literal",name:"first",value:100}],m={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleDetailsDialogQuery",selections:[{alias:"example",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,i,o],type:"DatasetExample",abstractKey:null},{args:null,kind:"FragmentSpread",name:"ExampleExperimentRunsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleDetailsDialogQuery",selections:[{alias:"example",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[c,{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[i,o,{alias:null,args:d,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"experimentRuns",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},t,m,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},m],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[c],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"experimentRuns(first:100)"},{alias:null,args:d,filters:null,handle:"connection",key:"ExampleExperimentRunsTable_experimentRuns",kind:"LinkedHandle",name:"experimentRuns"}],type:"DatasetExample",abstractKey:null}],storageKey:null}]},params:{cacheID:"6fa23dc80c23ecdf48e57d139d76a721",id:null,metadata:{},name:"ExampleDetailsDialogQuery",operationKind:"query",text:`query ExampleDetailsDialogQuery(
  $exampleId: GlobalID!
) {
  example: node(id: $exampleId) {
    __typename
    ... on DatasetExample {
      id
      latestRevision: revision {
        input
        output
        metadata
      }
      span {
        id
        context {
          traceId
        }
        project {
          id
        }
      }
    }
    ...ExampleExperimentRunsTableFragment
    __isNode: __typename
    id
  }
}

fragment ExampleExperimentRunsTableFragment on DatasetExample {
  experimentRuns(first: 100) {
    edges {
      run: node {
        id
        startTime
        endTime
        error
        output
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              label
              score
              explanation
              annotatorKind
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ci.hash="65b1c049bacc1ef8739c61af32a9414c";const Ii=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"patchDatasetExamples",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EditExampleDialogMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EditExampleDialogMutation",selections:a},params:{cacheID:"7217082d3d3796ecb60481d17133c351",id:null,metadata:{},name:"EditExampleDialogMutation",operationKind:"mutation",text:`mutation EditExampleDialogMutation(
  $input: PatchDatasetExamplesInput!
) {
  patchDatasetExamples(input: $input) {
    __typename
  }
}
`}}}();Ii.hash="a5e0e601ed24ffaa37a99ba358f960d3";const ka={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function Mc(n){const{exampleId:a,onCompleted:l}=n,[t,i]=u.useState(null),[r,o]=_.useMutation(Ii),{control:c,setError:d,handleSubmit:m,formState:{isValid:y}}=bn({defaultValues:n.currentRevision}),g=u.useCallback(p=>{if(i(null),!Ee(p==null?void 0:p.input))return d("input",{message:"Input must be a valid JSON object"});if(!Ee(p==null?void 0:p.output))return d("output",{message:"Output must be a valid JSON object"});if(!Ee(p==null?void 0:p.metadata))return d("metadata",{message:"Metadata must be a valid JSON object"});r({variables:{input:{patches:[{exampleId:a,input:JSON.parse(p.input),output:JSON.parse(p.output),metadata:JSON.parse(p.metadata)}],versionDescription:p.description}},onCompleted:()=>{l()},onError:f=>{i(f.message)}})},[r,a,d,l]);return e(G,{size:"fullscreen",title:`Edit Example: ${a}`,extra:e(z,{variant:"primary",size:"compact",disabled:!y||o,loading:o,onClick:m(g),children:"Save Changes"}),children:e("div",{css:K`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
          /* Make widths configurable */
          .dataset-picker {
            width: 100%;
            .ac-dropdown--picker,
            .ac-dropdown-button {
              width: 100%;
            }
          }
        `,children:e(b,{direction:"row",justifyContent:"center",children:e(T,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(b,{direction:"column",gap:"size-200",children:[t?e(ne,{variant:"danger",children:t}):null,e(U,{control:c,name:"input",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...ka,children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"output",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...ka,backgroundColor:"green-100",borderColor:"green-700",children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"metadata",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...ka,children:[S?e(ne,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(_e,{value:k,onChange:p,onBlur:f})]})}),e(U,{control:c,name:"description",render:({field:{onChange:p,onBlur:f,value:k},fieldState:{invalid:S,error:h}})=>e(la,{label:"Revision Description",value:k,onChange:p,onBlur:f,errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",placeholder:"A description of the changes made in this revision. Will be displayed in the version history.",height:100})})]})})})})})}function Nc(n){const{onCompleted:a,...l}=n,[t,i]=u.useState(null);return s(B,{children:[e(z,{variant:"default",size:"compact",icon:e(M,{svg:e(P.EditOutline,{})}),onClick:()=>i(e(Mc,{...l,onCompleted:()=>{i(null),a()}})),children:"Edit Example"}),e(ee,{type:"slideOver",isDismissable:!0,onDismiss:()=>i(null),children:t})]})}const Li=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleExperimentRunsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExampleExperimentRunsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleExperimentRunsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"experimentRuns",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},r,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},r],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"ExampleExperimentRunsTable_experimentRuns",kind:"LinkedHandle",name:"experimentRuns"}],type:"DatasetExample",abstractKey:null}],storageKey:null}]},params:{cacheID:"2ec7ead16e6df0877bc47db0ed7c7553",id:null,metadata:{},name:"ExampleExperimentRunsTableQuery",operationKind:"query",text:`query ExampleExperimentRunsTableQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExampleExperimentRunsTableFragment_2HEEH6
    __isNode: __typename
    id
  }
}

fragment ExampleExperimentRunsTableFragment_2HEEH6 on DatasetExample {
  experimentRuns(first: $first, after: $after) {
    edges {
      run: node {
        id
        startTime
        endTime
        error
        output
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              label
              score
              explanation
              annotatorKind
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Li.hash="6ca0f938b309407e8c184a1c13d1c52d";const Ei=function(){var n=["experimentRuns"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:Li,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExampleExperimentRunsTableFragment",selections:[{alias:"experimentRuns",args:null,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"__ExampleExperimentRunsTable_experimentRuns_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},l,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},l],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"DatasetExample",abstractKey:null}}();Ei.hash="6ca0f938b309407e8c184a1c13d1c52d";const Ac=100;function $c(){return e("tbody",{className:"is-empty",children:e("tr",{children:e("td",{colSpan:100,css:n=>K`
            text-align: center;
            padding: ${n.spacing.margin24}px ${n.spacing.margin24}px !important;
          `,children:"No experiments have been run for this example."})})})}function Vc({example:n}){const a=u.useRef(null),l=ae(),{data:t,loadNext:i,hasNext:r,isLoadingNext:o}=_.usePaginationFragment(Ei,n),c=u.useMemo(()=>t.experimentRuns.edges.map(f=>{let k=null;return f.run.startTime&&f.run.endTime&&(k=new Date(f.run.endTime).getTime()-new Date(f.run.startTime).getTime()),{...f.run,output:JSON.stringify(f.run.output),latencyMs:k}}),[t]),m=be({columns:[{header:"start time",accessorKey:"startTime",cell:Dn},{header:"output",accessorKey:"output",cell:f=>{var S;const k=(S=f.row.original)==null?void 0:S.error;return k!==null?e(x,{color:"danger",children:k}):e(xe,{...f})}},{header:"latency",accessorKey:"latencyMs",cell:({getValue:f})=>{const k=f();return k===null||typeof k!="number"?"--":e(we,{latencyMs:k})}},{header:"evaluations",accessorKey:"annotations",cell:({row:f})=>e(b,{direction:"row",gap:"size-50",wrap:"wrap",children:f.original.annotations.edges.map((k,S)=>{const h=k.annotation;return e(La,{annotation:h,onClick:()=>{h.trace&&l(`/projects/${h.trace.projectId}/traces/${h.trace.traceId}`)}},S)})})},{id:"actions",cell:({row:f})=>{const k=f.original.trace;if(k)return e(z,{variant:"default",size:"compact",icon:e(M,{svg:e(P.Trace,{})}),onClick:()=>{l(`/projects/${k.projectId}/traces/${k.traceId}`)},"aria-label":"view trace"})}}],data:c,getCoreRowModel:Se()}),y=m.getRowModel().rows,g=y.length===0,p=u.useCallback(f=>{if(f){const{scrollHeight:k,scrollTop:S,clientHeight:h}=f;k-S-h<300&&!o&&r&&i(Ac)}},[r,o,i]);return e("div",{css:K`
        flex: 1 1 auto;
        overflow: auto;
      `,ref:a,onScroll:f=>p(f.target),children:s("table",{css:xn,children:[e("thead",{children:m.getHeaderGroups().map(f=>e("tr",{children:f.headers.map(k=>e("th",{children:e("div",{children:J(k.column.columnDef.header,k.getContext())})},k.id))},f.id))}),g?e($c,{}):e("tbody",{children:y.map(f=>e("tr",{children:f.getVisibleCells().map(k=>e("td",{children:J(k.column.columnDef.cell,k.getContext())},k.id))},f.id))})]})})}function _i({exampleId:n,onDismiss:a}){const[l,t]=u.useState(0),i=_.useLazyLoadQuery(Ci,{exampleId:n},{fetchKey:l,fetchPolicy:"store-and-network"}),r=u.useMemo(()=>{const p=i.example.latestRevision;return{input:JSON.stringify(p==null?void 0:p.input,null,2),output:JSON.stringify(p==null?void 0:p.output,null,2),metadata:JSON.stringify(p==null?void 0:p.metadata,null,2)}},[i]),o=u.useMemo(()=>{const p=i.example.span;return p?{id:p.id,traceId:p.context.traceId,projectId:p.project.id}:null},[i]),{input:c,output:d,metadata:m}=r,y=ae(),g=ve();return e(ee,{type:"slideOver",isDismissable:!0,onDismiss:a,children:e(G,{size:"XL",title:`Example: ${n}`,extra:s(b,{direction:"row",gap:"size-100",children:[o?e(z,{variant:"default",size:"compact",onClick:()=>{y(`/projects/${o.projectId}/traces/${o.traceId}?selectedSpanNodeId=${o.id}`)},children:"View Source Span"}):null,e(Nc,{exampleId:n,currentRevision:r,onCompleted:()=>{g({title:"Example updated",message:`Example ${n} has been updated.`}),t(p=>p+1)}})]}),children:s(an,{direction:"vertical",autoSaveId:"example-panel-group",children:[e(se,{defaultSize:200,children:e("div",{css:K`
                overflow-y: auto;
                height: 100%;
              `,children:e(b,{direction:"row",justifyContent:"center",children:e(T,{width:"900px",paddingStart:"auto",paddingEnd:"auto",paddingTop:"size-200",paddingBottom:"size-200",children:s(b,{direction:"column",gap:"size-200",children:[e(Q,{title:"Input",...ba,extra:e(Y,{text:c}),children:e(Ye,{value:c})}),e(Q,{title:"Output",...ba,extra:e(Y,{text:d}),children:e(Ye,{value:d})}),e(Q,{title:"Metadata",...ba,extra:e(Y,{text:m}),children:e(Ye,{value:m})})]})})})})}),e(ln,{css:Kn}),e(se,{defaultSize:100,children:s(b,{direction:"column",height:"100%",children:[e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:e(oe,{level:3,children:"Experiment Runs"})}),e(Vc,{example:i.example})]})})]})})})}const ba={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0,bodyStyle:{padding:0}};function Lu(){const{exampleId:n,datasetId:a}=Oe(),l=ae();return e(_i,{exampleId:n,onDismiss:()=>{l(`/datasets/${a}/examples`)}})}const Ri=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"examplesLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{args:null,kind:"FragmentSpread",name:"ExamplesTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"examplesLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,l,{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"examples",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"examples(first:100)"},{alias:null,args:i,filters:["datasetVersionId"],handle:"connection",key:"ExamplesTable_examples",kind:"LinkedHandle",name:"examples"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"7e303fa9a3c09ccd6a3dc1f3dbb2afb3",id:null,metadata:{},name:"examplesLoaderQuery",operationKind:"query",text:`query examplesLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ...ExamplesTableFragment
  }
}

fragment ExamplesTableFragment on Dataset {
  examples(first: 100) {
    edges {
      example: node {
        id
        revision {
          input
          output
          metadata
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ri.hash="6406bbf43a2e850b384ba9573d8e69de";async function Eu(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ce,Ri,{id:a}).toPromise()}const wi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"datasetVersionId"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"datasetVersionId",variableName:"datasetVersionId"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExamplesTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExamplesTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExamplesTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"examples",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:["datasetVersionId"],handle:"connection",key:"ExamplesTable_examples",kind:"LinkedHandle",name:"examples"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"ca59c018695d41ca01b5f9d453386886",id:null,metadata:{},name:"ExamplesTableQuery",operationKind:"query",text:`query ExamplesTableQuery(
  $after: String = null
  $datasetVersionId: GlobalID
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExamplesTableFragment_4a6F8Z
    __isNode: __typename
    id
  }
}

fragment ExamplesTableFragment_4a6F8Z on Dataset {
  examples(datasetVersionId: $datasetVersionId, first: $first, after: $after) {
    edges {
      example: node {
        id
        revision {
          input
          output
          metadata
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();wi.hash="e04e697cdb44ab2dd115f4562211f6a4";const Pi=function(){var n=["examples"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"datasetVersionId"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:wi,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExamplesTableFragment",selections:[{alias:"examples",args:[{kind:"Variable",name:"datasetVersionId",variableName:"datasetVersionId"}],concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"__ExamplesTable_examples_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Dataset",abstractKey:null}}();Pi.hash="e04e697cdb44ab2dd115f4562211f6a4";const Mi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"deleteDatasetExamples",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleSelectionToolbarDeleteExamplesMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleSelectionToolbarDeleteExamplesMutation",selections:a},params:{cacheID:"b63159f3c325b9af3dc469692f9329e5",id:null,metadata:{},name:"ExampleSelectionToolbarDeleteExamplesMutation",operationKind:"mutation",text:`mutation ExampleSelectionToolbarDeleteExamplesMutation(
  $input: DeleteDatasetExamplesInput!
) {
  deleteDatasetExamples(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();Mi.hash="455bf9e5dc4b9cc655095dc829ef7e12";function zc(n){const a=rn(f=>f.refreshLatestVersion),{selectedExamples:l,onExamplesDeleted:t,onClearSelection:i}=n,[r,o]=u.useState(null),c=ve(),d=Qn(),[m,y]=_.useMutation(Mi),g=l.length!==1,p=u.useCallback(()=>{m({variables:{input:{exampleIds:l.map(f=>f.id)}},onCompleted:()=>{c({title:"Examples Deleted",message:`${l.length} example${g?"s":""} have been deleted.`}),t(),i(),a()},onError:f=>{d({title:"An error occurred",message:`Failed to delete examples: ${f.message}`})}})},[m,l,c,g,t,i,a,d]);return s("div",{css:K`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(T,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(b,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(x,{children:`${l.length} example${g?"s":""} selected`}),s(b,{direction:"row",gap:"size-100",children:[e(z,{variant:"default",size:"compact",onClick:i,children:"Cancel"}),e(z,{variant:"danger",size:"compact",icon:e(M,{svg:e(P.TrashOutline,{})}),loading:y,disabled:y,onClick:p,children:y?"Deleting...":"Delete Example"+(g?"s":"")})]})]})}),e(ee,{onDismiss:()=>{o(null)},children:r})]})}const Qc=100;function Oc({dataset:n}){const a=rn(C=>C.latestVersion),l=u.useRef(null),[t,i]=ke.useState({}),{data:r,loadNext:o,hasNext:c,isLoadingNext:d,refetch:m}=_.usePaginationFragment(Pi,n);u.useEffect(()=>{u.startTransition(()=>{m({datasetVersionId:(a==null?void 0:a.id)||null},{fetchPolicy:"store-and-network"})})},[a,m]);const y=u.useMemo(()=>r.examples.edges.map(C=>{const v=C.example,D=v.revision;return{id:v.id,input:D.input,output:D.output,metadata:D.metadata}}),[r]),p=be({columns:[{id:"select",header:({table:C})=>e(Ne,{checked:C.getIsAllRowsSelected(),indeterminate:C.getIsSomeRowsSelected(),onChange:C.getToggleAllRowsSelectedHandler()}),cell:({row:C})=>e(Ne,{checked:C.getIsSelected(),disabled:!C.getCanSelect(),indeterminate:C.getIsSomeSelected(),onChange:C.getToggleSelectedHandler()})},{header:"example id",accessorKey:"id",cell:({getValue:C,row:v})=>{const D=v.original.id;return e(Tn,{to:`${D}`,children:C()})}},{header:"input",accessorKey:"input",cell:fn},{header:"output",accessorKey:"output",cell:fn},{header:"metadata",accessorKey:"metadata",cell:fn}],data:y,state:{rowSelection:t},onRowSelectionChange:i,getCoreRowModel:Se()}),f=p.getRowModel().rows,k=f.length===0,S=p.getSelectedRowModel().rows,h=S.map(C=>C.original),F=u.useCallback(()=>{i({})},[i]),L=u.useCallback(C=>{if(C){const{scrollHeight:v,scrollTop:D,clientHeight:N}=C;v-D-N<300&&!d&&c&&o(Qc)}},[c,d,o]),I=ae();return s("div",{css:K`
        flex: 1 1 auto;
        overflow: auto;
      `,ref:l,onScroll:C=>L(C.target),children:[s("table",{css:xn,children:[e("thead",{children:p.getHeaderGroups().map(C=>e("tr",{children:C.headers.map(v=>e("th",{children:e("div",{children:J(v.column.columnDef.header,v.getContext())})},v.id))},C.id))}),k?e(on,{}):e("tbody",{children:f.map(C=>e("tr",{onClick:()=>{I(`${C.original.id}`)},children:C.getVisibleCells().map(v=>e("td",{children:J(v.column.columnDef.cell,v.getContext())},v.id))},C.id))})]}),S.length?e(zc,{selectedExamples:h,onClearSelection:F,onExamplesDeleted:()=>{m({},{fetchPolicy:"store-and-network"})}}):null]})}function _u(){const n=An();return s(B,{children:[e(Oc,{dataset:n.dataset})," ",e(u.Suspense,{children:e(Te,{})})]})}const Ni=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null},r=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"experimentsLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[{args:null,kind:"FragmentSpread",name:"ExperimentsTableFragment"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"experimentsLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,l,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:null,args:r,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"experiments(first:100)"},{alias:null,args:r,filters:null,handle:"connection",key:"ExperimentsTable_experiments",kind:"LinkedHandle",name:"experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"91f92395f5df4858554b124deed3f47a",id:null,metadata:{},name:"experimentsLoaderQuery",operationKind:"query",text:`query experimentsLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      ...ExperimentsTableFragment
    }
  }
}

fragment ExperimentsTableFragment on Dataset {
  experimentAnnotationSummaries {
    annotationName
    minScore
    maxScore
  }
  experiments(first: 100) {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        description
        createdAt
        metadata
        errorRate
        runCount
        averageRunLatencyMs
        project {
          id
        }
        annotationSummaries {
          annotationName
          meanScore
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ni.hash="1461484d9e1232cbb99e1251edabbec3";async function Ru(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ce,Ni,{id:a}).toPromise()}const Ai=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExperimentsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExperimentsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExperimentsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:null,args:l,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[i],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"ExperimentsTable_experiments",kind:"LinkedHandle",name:"experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"1db5ce5523fa9a472c91d093b0e6160e",id:null,metadata:{},name:"ExperimentsTableQuery",operationKind:"query",text:`query ExperimentsTableQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExperimentsTableFragment_2HEEH6
    __isNode: __typename
    id
  }
}

fragment ExperimentsTableFragment_2HEEH6 on Dataset {
  experimentAnnotationSummaries {
    annotationName
    minScore
    maxScore
  }
  experiments(first: $first, after: $after) {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        description
        createdAt
        metadata
        errorRate
        runCount
        averageRunLatencyMs
        project {
          id
        }
        annotationSummaries {
          annotationName
          meanScore
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ai.hash="c7c7580fe40888ceb86a1701fe4eedf4";const $i=function(){var n=["experiments"],a={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:Ai,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExperimentsTableFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:"experiments",args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"__ExperimentsTable_experiments_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},l],type:"Dataset",abstractKey:null}}();$i.hash="c7c7580fe40888ceb86a1701fe4eedf4";function jc({getValue:n}){const a=n(),l=a!==null?a*100:null,t=u.useMemo(()=>{if(l!==null)return l>=80?"red-1100":l>0?"orange-1100":"green-1100"},[l]);return e(x,{color:t,children:va(l)})}const Vi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"ExperimentMutationPayload",kind:"LinkedField",name:"deleteExperiments",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExperimentSelectionToolbarDeleteExperimentsMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExperimentSelectionToolbarDeleteExperimentsMutation",selections:a},params:{cacheID:"3af24cbaf3208c0d5ad1cd9313dd3823",id:null,metadata:{},name:"ExperimentSelectionToolbarDeleteExperimentsMutation",operationKind:"mutation",text:`mutation ExperimentSelectionToolbarDeleteExperimentsMutation(
  $input: DeleteExperimentsInput!
) {
  deleteExperiments(input: $input) {
    __typename
  }
}
`}}}();Vi.hash="4ab310746eb51c6a3fcb799d2c972762";function qc(n){const a=ae(),[l,t]=u.useState(null),[i,r]=_.useMutation(Vi),{datasetId:o,selectedExperiments:c,onClearSelection:d,onExperimentsDeleted:m}=n,y=c.length!==1,g=ve(),p=Qn(),f=u.useCallback(()=>{i({variables:{input:{experimentIds:c.map(S=>S.id)}},onCompleted:()=>{g({title:"Examples Deleted",message:`${c.length} experiment${y?"s":""} have been deleted.`}),m(),d()},onError:S=>{p({title:"An error occurred",message:`Failed to delete examples: ${S.message}`})}})},[i,y,p,g,d,m,c]),k=u.useCallback(()=>{t(s(G,{size:"S",title:"Delete Experiments",children:[e(T,{padding:"size-200",children:e(x,{color:"danger",children:"Are you sure you want to delete these experiments? This will also delete all associated annotations and traces, and it cannot be undone."})}),e(T,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(b,{direction:"row",justifyContent:"end",children:e(z,{variant:"danger",onClick:()=>{f(),t(null)},children:"Delete Experiments"})})})]}))},[f]);return s("div",{css:K`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(T,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(b,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:"size-100",children:[e(x,{children:`${c.length} experiment${y?"s":""} selected`}),s(b,{direction:"row",gap:"size-100",children:[e(z,{variant:"default",size:"compact",onClick:d,children:"Cancel"}),e(z,{variant:"danger",size:"compact",icon:e(M,{svg:e(P.TrashOutline,{})}),loading:r,disabled:r,onClick:k,children:r?"Deleting...":"Delete"}),e(z,{variant:"primary",size:"compact",onClick:()=>{a(`/datasets/${o}/compare?${c.map(S=>`experimentId=${S.id}`).join("&")}`)},icon:e(M,{svg:e(P.ArrowCompareOutline,{})}),children:"Compare Experiments"})]})]})}),e(ee,{onDismiss:()=>{t(null)},children:l})]})}const Bc=100;function Hc(){return e("tbody",{className:"is-empty",children:e("tr",{children:s("td",{colSpan:100,css:K`
            text-align: center;
            padding: var(--ac-global-dimension-size-400) !important;
            .ac-button {
              margin-top: var(--ac-global-dimension-size-200);
              margin-left: auto;
              margin-right: auto;
            }
          `,children:["No experiments for this dataset. To see how to run experiments on a dataset, check out the documentation.",e(Ti,{})]})})})}function Gc({dataset:n}){const a=u.useRef(null),[l,t]=u.useState({}),{data:i,loadNext:r,hasNext:o,isLoadingNext:c,refetch:d}=_.usePaginationFragment($i,n),m=u.useMemo(()=>i.experiments.edges.map(v=>{const D=v.experiment.annotationSummaries.reduce((N,R)=>(N[R.annotationName]=R,N),{});return{...v.experiment,annotationSummaryMap:D}}),[i]),y=[{id:"select",header:({table:v})=>e(Ne,{checked:v.getIsAllRowsSelected(),indeterminate:v.getIsSomeRowsSelected(),onChange:v.getToggleAllRowsSelectedHandler()}),cell:({row:v})=>e(Ne,{checked:v.getIsSelected(),disabled:!v.getCanSelect(),indeterminate:v.getIsSomeSelected(),onChange:v.getToggleSelectedHandler()})},{header:"name",accessorKey:"name",minSize:200,cell:({getValue:v,row:D})=>{const N=D.original.id,R=D.original.sequenceNumber;return s(b,{direction:"row",gap:"size-100",children:[e(Zn,{sequenceNumber:R}),e(Tn,{to:`/datasets/${n.id}/compare?experimentId=${N}`,children:v()})]})}},{header:"description",accessorKey:"description",minSize:300,cell:xe},{header:"created at",accessorKey:"createdAt",cell:Dn}],g=i.experimentAnnotationSummaries.map(v=>{const{annotationName:D,minScore:N,maxScore:R}=v;return{header:()=>s(b,{direction:"row",gap:"size-100",wrap:!0,alignItems:"center",justifyContent:"end",children:[e(x,{children:D}),e(Xr,{annotationName:D})]}),id:`annotation-${D}`,meta:{textAlign:"right"},cell:({row:O})=>{const j=O.original.annotationSummaryMap[D];return!j||j.meanScore==null?e("span",{css:K`
                  float: right;
                `,children:"--"}):e(Wc,{annotationName:D,value:j.meanScore,min:N,max:R})}}}),p=[{header:"run count",accessorKey:"runCount",meta:{textAlign:"right"},cell:Zr},{header:"avg latency",accessorKey:"averageRunLatencyMs",meta:{textAlign:"right"},cell:({getValue:v})=>{const D=v();return D===null||typeof D!="number"?"--":e(we,{latencyMs:D})}},{header:"error rate",accessorKey:"errorRate",meta:{textAlign:"right"},cell:jc},{header:"metadata",accessorKey:"metadata",minSize:200,cell:fn},{id:"actions",cell:({row:v})=>{const D=v.original.project,N=v.original.metadata;return e(Uc,{projectId:(D==null?void 0:D.id)||null,metadata:N})}}],f=be({columns:[...y,...g,...p],data:m,getCoreRowModel:Se(),state:{rowSelection:l},onRowSelectionChange:t}),k=f.getRowModel().rows,S=f.getSelectedRowModel().rows,h=S.map(v=>v.original),F=u.useCallback(()=>{t({})},[t]),L=k.length===0,I=u.useCallback(v=>{if(v){const{scrollHeight:D,scrollTop:N,clientHeight:R}=v;D-N-R<300&&!c&&o&&r(Bc)}},[o,c,r]),C=ae();return s("div",{css:K`
        flex: 1 1 auto;
        overflow: auto;
        width: table.getTotalSize();
      `,ref:a,onScroll:v=>I(v.target),children:[s("table",{css:xn,children:[e("thead",{children:f.getHeaderGroups().map(v=>e("tr",{children:v.headers.map(D=>{var N,R;return e("th",{align:(R=(N=D.column.columnDef)==null?void 0:N.meta)==null?void 0:R.textAlign,children:e("div",{children:J(D.column.columnDef.header,D.getContext())})},D.id)})},v.id))}),L?e(Hc,{}):e("tbody",{children:k.map(v=>e("tr",{onClick:()=>{C(`/datasets/${n.id}/compare?experimentId=${v.original.id}`)},children:v.getVisibleCells().map(D=>e("td",{children:J(D.column.columnDef.cell,D.getContext())},D.id))},v.id))})]}),S.length?e(qc,{datasetId:n.id,selectedExperiments:h,onClearSelection:F,onExperimentsDeleted:()=>{d({},{fetchPolicy:"store-and-network"})}}):null]})}function Wc({annotationName:n,value:a,min:l,max:t}){const i=Yr(n),r=u.useMemo(()=>{const o=typeof l=="number"?l:0,c=typeof t=="number"?t:1;if(o===c&&c===a)return 100;const d=c-o||1;return(a-o)/d*100},[a,l,t]);return s(pe,{children:[e($e,{children:s("div",{css:K`
            float: right;
            --mod-barloader-fill-color: ${i};
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: var(--ac-global-dimension-size-100);
          `,children:[yn(a),e(rs,{width:"40px",value:r,"aria-label":"where the mean score lands between overall min max"})]})}),e(ta,{children:s(T,{width:"size-2400",children:[e(oe,{level:3,weight:"heavy",children:n}),s(b,{direction:"column",children:[s(b,{justifyContent:"space-between",children:[e(x,{weight:"heavy",textSize:"small",children:"Mean Score"}),e(x,{textSize:"small",children:yn(a)})]}),s(b,{justifyContent:"space-between",children:[e(x,{weight:"heavy",textSize:"small",children:"All Experiments Min"}),e(x,{textSize:"small",children:yn(l)})]}),s(b,{justifyContent:"space-between",children:[e(x,{weight:"heavy",textSize:"small",children:"All Experiments Max"}),e(x,{textSize:"small",children:yn(t)})]}),s(b,{justifyContent:"space-between",children:[e(x,{weight:"heavy",textSize:"small",children:"Mean Score Percentile"}),e(x,{textSize:"small",children:ml(r)})]})]})]})})]})}function Uc(n){const{projectId:a}=n,l=ae(),[t,i]=u.useState(null);return s("div",{onClick:r=>{r.preventDefault(),r.stopPropagation()},children:[s(qe,{buttonSize:"compact",align:"end",disabledKeys:a?[]:["GO_TO_EXPERIMENT_RUN_TRACES"],onAction:r=>{switch(r){case"GO_TO_EXPERIMENT_RUN_TRACES":return l(`/projects/${a}`);case"VIEW_METADATA":{i(e(G,{title:"Metadata",onDismiss:()=>i(null),children:e(Ye,{value:JSON.stringify(n.metadata,null,2)})}));break}default:ge()}},children:[e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.Trace,{})}),e(x,{children:"View run traces"})]})},"GO_TO_EXPERIMENT_RUN_TRACES"),e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.InfoOutline,{})}),e(x,{children:"View Metadata"})]})},"VIEW_METADATA")]}),e(ee,{type:"modal",isDismissable:!0,onDismiss:()=>{i(null)},children:t})]})}function wu(){const n=An();return s(B,{children:[e(Gc,{dataset:n.dataset}),e(u.Suspense,{children:e(Te,{})})]})}const zi=function(){var n={defaultValue:null,kind:"LocalArgument",name:"datasetId"},a={defaultValue:null,kind:"LocalArgument",name:"experimentIds"},l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},r={alias:"comparisons",args:[{kind:"Variable",name:"experimentIds",variableName:"experimentIds"}],concreteType:"ExperimentComparison",kind:"LinkedField",name:"compareExperiments",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"example",plural:!1,selections:[l,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:"referenceOutput",args:null,kind:"ScalarField",name:"output",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"RunComparisonItem",kind:"LinkedField",name:"runComparisonItems",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"experimentId",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"runs",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},t,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[l,i,{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},t],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},o=[{kind:"Variable",name:"id",variableName:"datasetId"}],c={kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,i,{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ExperimentCompareTableQuery",selections:[r,{alias:"dataset",args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,c],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ExperimentCompareTableQuery",selections:[r,{alias:"dataset",args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,c],storageKey:null}]},params:{cacheID:"97e80c617426f75b81affa68e276b3d8",id:null,metadata:{},name:"ExperimentCompareTableQuery",operationKind:"query",text:`query ExperimentCompareTableQuery(
  $experimentIds: [GlobalID!]!
  $datasetId: GlobalID!
) {
  comparisons: compareExperiments(experimentIds: $experimentIds) {
    example {
      id
      revision {
        input
        referenceOutput: output
      }
    }
    runComparisonItems {
      experimentId
      runs {
        output
        error
        startTime
        endTime
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              score
              label
              annotatorKind
              explanation
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
    }
  }
  dataset: node(id: $datasetId) {
    __typename
    id
    ... on Dataset {
      experiments {
        edges {
          experiment: node {
            id
            name
            sequenceNumber
          }
        }
      }
    }
  }
}
`}}}();zi.hash="e6132b301f6d80be7f5c5b0653e25178";const Sa={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0,bodyStyle:{padding:0}},Jc=K`
  flex: 1 1 auto;
  overflow: auto;
  // Make sure the table fills up the remaining space
  table {
    min-width: 100%;
    td {
      vertical-align: top;
    }
  }
`,Qi=K`
  position: relative;
  min-height: 75px;
  .controls {
    transition: opacity 0.2s ease-in-out;
    opacity: 0;
    display: none;
    z-index: 1;
  }
  &:hover .controls {
    opacity: 1;
    display: flex;
    // make them stand out
    .ac-button {
      border-color: var(--ac-global-color-primary);
    }
  }
`,Oi=K`
  position: absolute;
  top: -23px;
  right: 0px;
  display: flex;
  flex-direction: row;
  gap: var(--ac-global-dimension-static-size-100);
`;function Xc(n){const{datasetId:a,experimentIds:l,displayFullText:t}=n,i=_.useLazyLoadQuery(zi,{experimentIds:l,datasetId:a}),r=u.useMemo(()=>{var h,F;return((F=(h=i.dataset)==null?void 0:h.experiments)==null?void 0:F.edges.reduce((L,I)=>(L[I.experiment.id]={...I.experiment},L),{}))||{}},[i]),o=u.useMemo(()=>i.comparisons.map(h=>{const F=h.runComparisonItems.reduce((L,I)=>(L[I.experimentId]=I,L),{});return{...h,id:h.example.id,input:h.example.revision.input,referenceOutput:h.example.revision.referenceOutput,runComparisonMap:F}}),[i]),[c,d]=u.useState(null),m=u.useMemo(()=>[{header:"input",accessorKey:"input",minWidth:500,cell:({row:h})=>s("div",{css:Qi,children:[e(Aa,{children:e(Ea,{json:h.original.input,disableTitle:!0,space:t?2:0})}),e("div",{className:"controls",css:Oi,children:s(pe,{children:[e(z,{variant:"default",size:"compact","aria-label":"View example details",icon:e(M,{svg:e(P.ExpandOutline,{})}),onClick:()=>{u.startTransition(()=>{d(e(u.Suspense,{children:e(_i,{exampleId:h.original.example.id,onDismiss:()=>{d(null)}})}))})}}),e(en,{children:"View Example"})]})})]})},{header:"reference output",accessorKey:"referenceOutput",minWidth:500,cell:t?au:fn}],[t]),y=u.useMemo(()=>l.map(h=>({header:()=>{var I,C;const F=(I=r[h])==null?void 0:I.name,L=((C=r[h])==null?void 0:C.sequenceNumber)||0;return s(b,{direction:"row",gap:"size-100",wrap:!0,children:[e(Zn,{sequenceNumber:L}),e(x,{children:F})]})},accessorKey:h,minSize:500,cell:({row:F})=>{var O,j;const L=F.original.runComparisonMap[h],I=(L==null?void 0:L.runs.length)||0;if(I===0)return e(Xa,{});if(I>1)return e(x,{color:"warning",children:`${I} runs`});const C=L==null?void 0:L.runs[0];let v=null;const D=(O=C==null?void 0:C.trace)==null?void 0:O.traceId,N=(j=C==null?void 0:C.trace)==null?void 0:j.projectId;D&&N&&(v=s(pe,{children:[e(z,{variant:"default",className:"trace-button",size:"compact","aria-label":"View run trace",icon:e(M,{svg:e(P.Trace,{})}),onClick:X=>{X.preventDefault(),X.stopPropagation(),u.startTransition(()=>{d(e(Hi,{traceId:D,projectId:N,title:"Experiment Run Trace"}))})}}),e(en,{children:"View Trace"})]}));const R=s(B,{children:[s(pe,{children:[e(z,{variant:"default",className:"expand-button",size:"compact","aria-label":"View example run details",icon:e(M,{svg:e(P.ExpandOutline,{})}),onClick:X=>{X.preventDefault(),X.stopPropagation(),u.startTransition(()=>{d(e(lu,{selectedExample:F.original,datasetId:a,experimentInfoById:r}))})}}),e(en,{children:"View run details"})]}),v]});return C?e(nu,{controls:R,children:e(eu,{...C,displayFullText:t,setDialog:d})}):e(Xa,{})}})),[l,r,a,t]),g=u.useMemo(()=>[...m,...y,{id:"tail",minSize:500}],[m,y]),p=be({columns:g,data:o,getCoreRowModel:Se(),columnResizeMode:"onChange"}),f=ke.useMemo(()=>{const h=p.getFlatHeaders(),F={};for(let L=0;L<h.length;L++){const I=h[L];F[`--header-${I.id}-size`]=I.getSize(),F[`--col-${I.column.id}-size`]=I.column.getSize()}return F},[p.getState().columnSizingInfo,p.getState().columnSizing]),S=p.getRowModel().rows.length===0;return s("div",{css:Jc,children:[s("table",{css:h=>K(Vn(h),es),style:{...f,width:p.getTotalSize(),minWidth:"100%"},children:[e("thead",{children:p.getHeaderGroups().map(h=>e("tr",{children:h.headers.map(F=>s("th",{style:{width:`calc(var(--header-${F==null?void 0:F.id}-size) * 1px)`},children:[e("div",{children:J(F.column.columnDef.header,F.getContext())}),e("div",{onMouseDown:F.getResizeHandler(),onTouchStart:F.getResizeHandler(),className:`resizer ${F.column.getIsResizing()?"isResizing":""}`})]},F.id))},h.id))}),S?e(on,{}):p.getState().columnSizingInfo.isResizingColumn?e(Yc,{table:p}):e(ji,{table:p})]}),e(ee,{isDismissable:!0,type:"slideOver",onDismiss:()=>{d(null)},children:c})]})}function ji({table:n}){return e("tbody",{children:n.getRowModel().rows.map(a=>e("tr",{children:a.getVisibleCells().map(l=>e("td",{style:{width:`calc(var(--col-${l.column.id}-size) * 1px)`},children:J(l.column.columnDef.cell,l.getContext())},l.id))},a.id))})}const Yc=ke.memo(ji,(n,a)=>n.table.options.data===a.table.options.data);function Zc(n){const{datasetId:a,exampleId:l}=n,t=ae();return e("div",{onClick:i=>{i.preventDefault(),i.stopPropagation()},children:e(qe,{buttonSize:"compact",align:"end",onAction:i=>{switch(i){case"gotoExample":return t(`/datasets/${a}/examples/${l}`);default:ge()}},children:e(H,{children:s(b,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(M,{svg:e(P.ExternalLinkOutline,{})}),e(x,{children:"Go to example"})]})},"gotoExample")})})}function eu(n){const{output:a,error:l,startTime:t,endTime:i,annotations:r,displayFullText:o,setDialog:c}=n;if(l)return e(qi,{error:l});const d=r!=null&&r.edges.length?r.edges.map(m=>m.annotation):[];return s(b,{direction:"column",gap:"size-100",height:"100%",justifyContent:"space-between",children:[e(Aa,{children:e(Ea,{json:a,disableTitle:!0,space:o?2:0})}),s("ul",{css:K`
          display: flex;
          flex-direction: row;
          gap: var(--ac-global-dimension-static-size-100);
          align-items: center;
          flex-wrap: wrap;
        `,children:[e("li",{children:e(Bi,{startTime:t,endTime:i})},"run-latency"),d.map(m=>e("li",{children:e(La,{annotation:m,onClick:()=>{const y=m.trace;y&&u.startTransition(()=>{c(e(Hi,{traceId:y.traceId,projectId:y.projectId,title:`Evaluator Trace: ${m.name}`}))})}})},m.id))]})]})}function nu(n){return s("div",{css:Qi,children:[n.children,e("div",{css:Oi,className:"controls",children:n.controls})]})}function qi({error:n}){return s(b,{direction:"row",gap:"size-50",alignItems:"center",children:[e(M,{svg:e(P.AlertCircleOutline,{}),color:"danger"}),e(x,{color:"danger",children:n})]})}function Bi({startTime:n,endTime:a}){const l=u.useMemo(()=>{let t=null;return n&&a&&(t=new Date(a).getTime()-new Date(n).getTime()),t},[n,a]);return l===null?null:e(we,{latencyMs:l})}function Xa(){return s(b,{direction:"row",gap:"size-50",children:[e(M,{svg:e(P.MinusCircleOutline,{}),color:"grey-800"}),e(x,{color:"text-700",children:"not run"})]})}function au({getValue:n}){const a=n();return e(Aa,{children:e(Ea,{json:a,space:2})})}function Aa({children:n}){return e("div",{css:K`
        max-height: 300px;
        overflow-y: auto;
      `,children:n})}function lu({selectedExample:n,datasetId:a,experimentInfoById:l}){return e(G,{title:`Comparing Experiments for Example: ${n.id}`,size:"fullscreen",extra:e(Zc,{datasetId:a,exampleId:n.id}),children:s(an,{direction:"vertical",autoSaveId:"example-compare-panel-group",children:[e(se,{defaultSize:100,children:e("div",{css:K`
              overflow-y: auto;
              height: 100%;
            `,children:e(T,{overflow:"hidden",padding:"size-200",children:s(b,{direction:"row",gap:"size-200",flex:"1 1 auto",children:[e(T,{width:"50%",children:e(Q,{title:"Input",...Sa,bodyStyle:{padding:0,maxHeight:"300px",overflowY:"auto"},extra:e(Y,{text:JSON.stringify(n.input)}),children:e(Ye,{value:JSON.stringify(n.input,null,2)})})}),e(T,{width:"50%",children:e(Q,{title:"Reference Output",...Sa,extra:e(Y,{text:JSON.stringify(n.input)}),bodyStyle:{padding:0,maxHeight:"300px",overflowY:"auto"},children:e(Ye,{value:JSON.stringify(n.referenceOutput,null,2)})})})]})})})}),e(ln,{css:Kn}),e(se,{defaultSize:200,children:s(b,{direction:"column",height:"100%",children:[e(T,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:e(oe,{level:2,children:"Experiments"})}),e("div",{css:K`
                overflow-y: auto;
                height: 100%;
                padding: var(--ac-global-dimension-static-size-200);
              `,children:e("ul",{css:K`
                  display: flex;
                  flex-direction: column;
                  gap: var(--ac-global-dimension-static-size-200);
                `,children:n.runComparisonItems.map(t=>{const i=l[t.experimentId];return e("li",{children:e(Q,{...Sa,title:i==null?void 0:i.name,titleExtra:e(Zn,{sequenceNumber:(i==null?void 0:i.sequenceNumber)||0}),children:e("ul",{children:t.runs.map((r,o)=>{var c;return e("li",{children:s(b,{direction:"row",children:[e(T,{flex:!0,children:r.error?e(T,{padding:"size-200",children:e(qi,{error:r.error})}):e(Ye,{value:JSON.stringify(r.output,null,2)})}),s(gn,{width:"size-3000",children:[e(Bi,{startTime:r.startTime,endTime:r.endTime}),e("ul",{css:K`
                                      margin-top: var(
                                        --ac-global-dimension-static-size-100
                                      );
                                      display: flex;
                                      flex-direction: column;
                                      justify-content: flex-start;
                                      align-items: flex-end;
                                      gap: var(
                                        --ac-global-dimension-static-size-100
                                      );
                                    `,children:(c=r.annotations)==null?void 0:c.edges.map(d=>e("li",{children:e(La,{annotation:d.annotation})},d.annotation.id))})]})]})},o)})})})},t.experimentId)})})})]})})]})})}function Hi({traceId:n,projectId:a,title:l}){const t=ae();return e(G,{title:l,size:"fullscreen",extra:e(z,{variant:"default",onClick:()=>t(`/projects/${a}/traces/${n}`),children:"View Trace in Project"}),children:e(Ct,{traceId:n,projectId:a})})}const Gi={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ExperimentMultiSelector__experiments",selections:[{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null};Gi.hash="1aa376b1e9425f49268ac231dc2c0412";function tu(n){const{dataset:a,selectedExperimentIds:l,onChange:t,label:i,validationState:r,description:o,errorMessage:c,...d}=n,m=_.useFragment(Gi,a),y=u.useMemo(()=>m.experiments.edges.map(f=>f.experiment),[m]),g=y.length===0,p=u.useMemo(()=>{if(g)return"No experiments";const f=l.length;return f>0?`${f} experiment${f>1?"s":""}`:"No experiments selected"},[l,g]);return e(ia,{label:i,isDisabled:g,validationState:r,description:o,errorMessage:c,children:e(wa,{isDisabled:g,...d,menu:e(On,{selectionMode:"multiple",onSelectionChange:f=>{t(Array.from(f))},selectedKeys:new Set(l),children:y.map(f=>e(H,{textValue:f.name,children:s(b,{direction:"column",gap:"size-50",children:[s(b,{direction:"row",gap:"size-100",children:[e(Zn,{sequenceNumber:f.sequenceNumber}),e(x,{children:f.name})]}),e(x,{textSize:"small",color:"text-700",children:new Date(f.createdAt).toLocaleString()})]})},f.id))}),triggerProps:{placement:"bottom start"},children:p})})}function Pu(){const n=An(),[a,l]=u.useState(!1),[t,i]=nl(),r=t.getAll("experimentId"),o=r.length>0;return s("main",{css:K`
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      `,children:[e(T,{padding:"size-200",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:s(b,{direction:"column",gap:"size-100",children:[e(oe,{level:1,children:"Compare Experiments"}),s(b,{direction:"row",justifyContent:"space-between",alignItems:"end",children:[e(tu,{dataset:n.dataset,selectedExperimentIds:r,label:"experiments",onChange:c=>{u.startTransition(()=>{t.delete("experimentId"),c.forEach(d=>{t.append("experimentId",d)}),i(t)})}}),e(ea,{onChange:c=>{l(c)},defaultSelected:!1,labelPlacement:"start",children:"Full Text"})]})]})}),o?e(u.Suspense,{fallback:e(ue,{}),children:e(Xc,{datasetId:n.dataset.id,experimentIds:r,displayFullText:a})}):e(T,{padding:"size-200",children:e(ne,{variant:"info",title:"No Experiment Selected",children:"Please select one or more experiments."})})]})}const Wi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"experimentCompareLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[t,{args:null,kind:"FragmentSpread",name:"ExperimentMultiSelector__experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"experimentCompareLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"InlineFragment",selections:[t,{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,t,{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"7e89f99f940098a21985137aae870de7",id:null,metadata:{},name:"experimentCompareLoaderQuery",operationKind:"query",text:`query experimentCompareLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      id
      name
      ...ExperimentMultiSelector__experiments
    }
  }
}

fragment ExperimentMultiSelector__experiments on Dataset {
  experiments {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        createdAt
      }
    }
  }
}
`}}}();Wi.hash="fa02088830fd16688f0f2fba9a0009eb";async function Mu(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ce,Wi,{id:a}).toPromise()}const Ya=window.Config.basename,Za={width:"100%",height:"100%",border:"none",backgroundColor:"white"};function Nu(){return s("div",{css:K`
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        height: 100%;
        .ac-tabs {
          flex: 1 1 auto;
        }
        .ac-tabs__pane-container,
        .ac-tabs__pane-container > div {
          flex: 1 1 auto;
          height: 100%;
        }
      `,children:[e(ne,{variant:"info",banner:!0,icon:e(M,{svg:e(P.InfoFilled,{})}),children:"These APIs are under active development and are subject to change."}),s(he,{children:[e(q,{name:"REST",children:({isSelected:n})=>n&&e("iframe",{src:`${Ya}/docs`,style:Za})}),e(q,{name:"GraphQL",children:({isSelected:n})=>n&&e("iframe",{src:`${Ya}/graphql`,style:Za})})]})]})}export{Nu as A,yu as D,vu as E,cu as F,Su as L,Fu as M,xu as P,ct as T,mu as a,gu as b,Tu as c,fu as d,pu as e,Ku as f,ku as g,uu as h,hu as i,Du as j,Iu as k,Cu as l,wu as m,Ru as n,_u as o,bu as p,Eu as q,Lu as r,Mu as s,Pu as t,ks as u};
