import{ak as I,al as v,r as j,an as C,ap as L,bj as A,ah as h,j as t,am as b,as as u,at as S,b1 as w,f as k,R as F,aI as M,S as p,h as i,q as N,t as P,L as T,T as E,m as U}from"./vendor-ClLR6ncd.js";import{e as g}from"./lodash-ZyeDnt0e.js";import{L as _}from"./index-OtVJl4GC.js";import{E as D}from"./index-Czq32Zhb.js";import{u as G}from"./useNamespaces-B-2wwTCG.js";import{p as O}from"./pluralize-BF8NJH6e.js";import{e as W}from"./model-D2J-D42I.js";import{c as z}from"./model-Dfrorm_S.js";import{C as B}from"./Card-DCyqxUVE.js";import{C as Q}from"./CardContent-B36bxiGw.js";import{A as V}from"./Avatar-FLlqk0a0.js";import"./model-DgFcCvKB.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./highlightSearch-BTHB3jgf.js";import"./WithMeasure-BDk9QPMF.js";import"./TableRow-CGDSOtFZ.js";import"./TableSortLabel-BJFq2axQ.js";import"./Box-Co2WcNPC.js";import"./TypographyWithTooltip-BFAG3Va9.js";import"./Link-BLwKPJFF.js";function $(a){return I("MuiListItemAvatar",a)}v("MuiListItemAvatar",["root","alignItemsFlexStart"]);const H=["className"],J=a=>{const{alignItems:e,classes:r}=a;return u({root:["root",e==="flex-start"&&"alignItemsFlexStart"]},$,r)},K=S("div",{name:"MuiListItemAvatar",slot:"Root",overridesResolver:(a,e)=>{const{ownerState:r}=a;return[e.root,r.alignItems==="flex-start"&&e.alignItemsFlexStart]}})(({ownerState:a})=>h({minWidth:56,flexShrink:0},a.alignItems==="flex-start"&&{marginTop:8})),X=j.forwardRef(function(e,r){const o=C({props:e,name:"MuiListItemAvatar"}),{className:c}=o,n=L(o,H),s=j.useContext(A),l=h({},o,{alignItems:s.alignItems}),m=J(l);return t.jsx(K,h({className:b(m.root,c),ownerState:l,ref:r},n))});function ht(){const{queryResultPairs:a}=w(),{data:e,isLoading:r}=G(),o=k(),c=F.useCallback(n=>{o(`./modal?${W(n)}`)},[o]);return t.jsxs(t.Fragment,{children:[t.jsx(M,{context:{namespaces:e}}),t.jsx(p,{p:2,useFlexGap:!0,spacing:1,flexDirection:"column-reverse",children:a.map(({queryText:n,queryResult:s,queryError:l},m)=>t.jsx(B,{variant:"outlined",sx:{textAlign:"left"},children:t.jsxs(Q,{children:[t.jsxs(p,{direction:"row",alignItems:"center",spacing:1,children:[t.jsx(i,{color:"text.secondary",children:"Query:"}),t.jsx(i,{variant:"h6",children:n})]}),l?t.jsx(D,{queryResultError:l}):s?(s==null?void 0:s.result.length)===0?t.jsx(i,{color:"text.secondary",children:"Answer isn't available"}):t.jsxs(t.Fragment,{children:[t.jsxs(p,{direction:"row",alignItems:"baseline",spacing:1,children:[t.jsx(i,{color:"text.secondary",children:"Answer:"}),t.jsx(i,{children:s==null?void 0:s.result[0].response})]}),t.jsxs(i,{color:"text.secondary",children:[O("Citation",s==null?void 0:s.result.length),":"]}),t.jsx(N,{dense:!0,sx:{pt:0,pb:0},children:s==null?void 0:s.result.map(({score:x,citation:d,label:f})=>t.jsx(P,{disablePadding:!0,children:t.jsxs(T,{disabled:r,disableGutters:!0,onClick:()=>c(z([],!1,d)),children:[t.jsx(X,{children:t.jsx(E,{title:"Score of the citation from 0 to 100",children:t.jsx(V,{sx:{bgcolor:g(x*100)>=80?"success.main":g(x*100)>=70?"warning.main":"error.main"},children:g(x*100)})})}),t.jsx(U,{primary:t.jsx(i,{variant:"subtitle2",children:f||d})})]})},d))})]}):t.jsx(_,{})]})},m))})]})}export{ht as default};
