import{f as g,R as f,j as n,S as m,aI as y,h as j,H as C}from"./vendor-ClLR6ncd.js";import{o as w}from"./lodash-ZyeDnt0e.js";import{d as T}from"./Search-BYaM2U5J.js";import{d as v}from"./Warning-DsmyDRzF.js";import{b as B}from"./index-OtVJl4GC.js";import{p as E}from"./pluralize-BF8NJH6e.js";import{E as S,u as I}from"./highlightSearch-BTHB3jgf.js";import{T as Q,a as q}from"./Tabs-dk9tYIBM.js";import{B as H}from"./Box-Co2WcNPC.js";function l(e){return n.jsx(j,{...w(e,["queryResult","queryResultError"]),sx:{fontSize:"inherit",fontWeight:"inherit"}})}function R({queryResult:e,queryResultError:r}){var a,s,u;const t=(e==null?void 0:e._queryType)==="nl-query"?(a=e==null?void 0:e.values)==null?void 0:a.length:(u=(s=e==null?void 0:e.queryInfo)==null?void 0:s.other)==null?void 0:u.rowCount;return n.jsx(l,{queryResult:e,queryResultError:r,children:Number.isInteger(t)&&!r?`${new Intl.NumberFormat().format(t)} ${E("row",t)}`:"result"})}function _({queryResult:e,queryResultError:r,children:o}){var a;const t=n.jsx(l,{children:o});return!((a=e==null?void 0:e.queryInfo)!=null&&a.warn)&&!r?t:n.jsxs(m,{direction:"row",alignItems:"center",spacing:1,children:[n.jsx(v,{sx:{color:"warning.light"}}),t]})}const c=({currentQuery:e,queryResponseType:r})=>!!e&&(r==="nl-query"||r==="boolean-nl-query"),M=[{path:"results",label:"Results",Component:R,isRendered:({currentQuery:e})=>!!e},{path:"download-results",label:"Download results",Component:l,isRendered:({currentQuery:e,queryResponseType:r,queryError:o})=>!!e&&!!r&&r!=="boolean"&&r!=="nl-query"&&r!=="boolean-nl-query"&&!o},{path:"info",label:"Query Information",Component:_,isRendered:({currentQuery:e,isSparqlEngineQuery:r,queryError:o})=>!!e&&r&&!o},{path:"shapes",label:"Used SHACL",Component:l,isRendered:c},{path:"referenced-examples",label:"References",Component:l,isRendered:c},{path:"query-critique",label:"Query Critique",Component:l,isRendered:c}];function N({disabled:e}){const{toggleEnabledSearch:r}=I();return n.jsx(C,{disabled:e,variant:"outlined",sx:{pl:1,pr:1},onClick:r,startIcon:n.jsx(T,{}),children:"search"})}function F(e){var x;const r=g(),{resultType:o,isSparqlEngineQuery:t,currentQuery:a}=B(),s=f.useMemo(()=>M.filter(i=>{var d;return i.isRendered({currentQuery:a,isSparqlEngineQuery:t,queryError:e.queryResultError,queryResponseType:(d=e.queryResult)==null?void 0:d._queryType})}),[a,t,(x=e.queryResult)==null?void 0:x._queryType,e.queryResultError]),u=f.useMemo(()=>new Set(s.map(({path:i})=>i)),[s]),h=o==="results";return n.jsx(S,{visible:h,children:n.jsxs(m,{direction:"column",sx:{width:1,height:1,position:"relative"},children:[n.jsxs(m,{direction:"row",sx:{borderBottom:1,borderColor:"divider"},children:[n.jsx(Q,{datacy:"result-tabs",sx:{minHeight:"40px",flexGrow:1,"& .MuiTabs-flexContainer":{height:1},"& .MuiButtonBase-root":{minHeight:"40px"}},value:u.has(o)?o:!1,children:s.map(({path:i,label:d,Component:b,disabled:p=()=>!1})=>n.jsx(q,{sx:{pb:0,pt:0},size:"medium",value:i,label:n.jsx(b,{queryResult:e.queryResult,queryResultError:e.queryResultError,children:d}),onClick:()=>{r(i)},disabled:p(e)},i))}),h?n.jsx(N,{disabled:!!e.queryResultError||!e.queryResult}):null]}),n.jsx(H,{sx:{flexGrow:1,overflow:"auto",textAlign:"left"},children:n.jsx(y,{context:e})})]})})}export{F as Q};
