import{r as l,j as e,K as j,w as b,J as w,M as C}from"./index-G4l7qcMm.js";import{C as S}from"./choose-partition-tmVN7Yw-.js";import{B as c,a as v}from"./browse-Ypk-yEjt.js";import{F as y}from"./Stack-Cwu0vGSf.js";import{I as A,S as I,M as D,F as E}from"./Tooltip-DDkR3tcv.js";import{D as P}from"./DataGrid-DyFuY0s8.js";import"./Input-BJwdycW3.js";import"./toPropertyKey-DCwh5dYN.js";import"./FormControlLabel-Ckn-i3Sp.js";import"./Checkbox-vyYUPBbX.js";const H=t=>{const o=t.item.data.attributes.structure.npartitions,[n,s]=l.useState(0),[i,a]=l.useState([]),[m,u]=l.useState(!1),d=t.item.data.attributes.structure.columns;l.useEffect(()=>{const r=new AbortController,g=t.item.data.links.partition.replace("{index}",n);async function p(){const x=(await v.get(`${g}&format=application/json-seq`,{signal:r.signal})).data.split(`
`).map(f=>JSON.parse(f));a(x),u(!0)}return p(),()=>{r.abort()}},[t.segments,t.item.data.links.full,t.item.data.links.partition,n]);const h=r=>{a([]),u(!1),s(r)};return e.jsx(c,{sx:{my:4},children:e.jsxs(j,{maxWidth:"lg",children:[e.jsx(T,{segments:t.segments,columns:d}),e.jsxs(c,{width:"100%",mt:5,children:[e.jsx(b,{id:"table-title",variant:"h6",component:"h2",children:"Table"}),o>1?e.jsxs(c,{children:[e.jsxs(w,{severity:"info",children:["This large table is available in ",e.jsx("em",{children:"partitions"})," (chunks of rows) because the full table may be slow to download and display.",e.jsx("br",{}),'In the "Download" tab, you can request the full table as a single file if you wish.']}),e.jsx(S,{npartitions:o,value:n,setValue:h})]}):"",e.jsx(F,{rows:i,columns:d,loading:!m})]})]})})},T=t=>{let o=C();const n=s=>{const i=s.target.value;o(`/browse${t.segments.map(function(a){return"/"+a}).join("")}/${i}`)};return e.jsx(c,{children:e.jsxs(y,{children:[e.jsx(A,{id:"column-select-helper-label",children:"Go to Column"}),e.jsx(I,{labelId:"column-select-label",id:"column-select",value:"",label:"Column",onChange:n,children:t.columns.map(s=>e.jsx(D,{value:s,children:s},`column-${s}`))}),e.jsx(E,{children:"Access a single column as an Array."})]})})},k=10,F=t=>{const[o,n]=l.useState(k),s=t.columns.map(a=>({field:a,headerName:a,width:200})),i=t.rows.map((a,m)=>(a.id=m,a));return e.jsx(P,{...t.loading?{loading:!0}:{},rows:i,columns:s,pagination:!0,paginationModel:{pageSize:o,page:0},pageSizeOptions:[10,30,100],onPaginationModelChange:a=>n(a.pageSize),autoHeight:!0})};export{H as default};
