import{j as e,P as d}from"./vendor-tanstack-BpuysabX.js";import{b4 as o,S as f,a as j,b as p,c as b,e as i,be as P,bf as v,bg as r,cm as N,bh as S,bi as w,cn as C}from"./index-CREafGO4.js";function D({className:t,...s}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",t),...s})})}function z({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:o("[&_tr]:border-b",t),...s})}function T({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-0",t),...s})}function c({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:o("bg-card dark:bg-background hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function k({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:o("text-muted-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function x({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:o("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function E({table:t,onPrefetchPage:s,onRowClick:l}){return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(D,{children:[e.jsx(z,{children:t.getHeaderGroups().map(n=>e.jsx(c,{children:n.headers.map(a=>e.jsx(k,{style:{...a.column.columnDef.maxSize&&{maxWidth:`${a.column.columnDef.maxSize}px`},...a.column.columnDef.size&&{width:`${a.column.columnDef.size}px`}},children:a.isPlaceholder?null:d(a.column.columnDef.header,a.getContext())},a.id))},n.id))}),e.jsx(T,{children:t.getRowModel().rows?.length?t.getRowModel().rows.map(n=>e.jsx(c,{"data-state":n.getIsSelected()&&"selected",className:l?"cursor-pointer hover:bg-muted":void 0,onClick:l?()=>l(n.original):void 0,children:n.getVisibleCells().map(a=>e.jsx(x,{style:{...a.column.columnDef.maxSize&&{maxWidth:`${a.column.columnDef.maxSize}px`},...a.column.columnDef.size&&{width:`${a.column.columnDef.size}px`}},children:d(a.column.columnDef.cell,a.getContext())},a.id))},n.id)):e.jsx(c,{children:e.jsx(x,{colSpan:t.getAllColumns().length,className:"h-24 text-center",children:"No results."})})})]})}),e.jsxs("div",{className:"flex flex-row justify-between items-center",children:[e.jsx(y,{table:t}),e.jsx(M,{table:t,onPrefetchPage:s})]})]})}function y({table:t}){return e.jsxs("div",{className:"flex flex-row items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Items per page"}),e.jsxs(f,{value:t.getState().pagination.pageSize.toString(),onValueChange:s=>{t.setPageSize(Number(s))},children:[e.jsx(j,{"aria-label":"Items per page",children:e.jsx(p,{placeholder:"Theme"})}),e.jsxs(b,{children:[e.jsx(i,{value:"5",children:"5"}),e.jsx(i,{value:"10",children:"10"}),e.jsx(i,{value:"25",children:"25"}),e.jsx(i,{value:"50",children:"50"})]})]})]})}function M({table:t,className:s,onPrefetchPage:l}){const n=t.getPageCount(),a=Math.min(Math.ceil(t.getState().pagination.pageIndex+1),n),u=()=>{a>1&&l?.(1)},m=()=>{a>1&&l?.(a-1)},g=()=>{a<n&&l?.(a+1)},h=()=>{a<n&&l?.(n)};return e.jsx(P,{className:o("justify-end",s),children:e.jsxs(v,{children:[e.jsxs(r,{children:[e.jsx(N,{onClick:()=>t.firstPage(),onMouseEnter:u,disabled:!t.getCanPreviousPage()}),e.jsx(S,{onClick:()=>t.previousPage(),onMouseEnter:m,disabled:!t.getCanPreviousPage()})]}),e.jsxs(r,{className:"text-sm",children:["Page ",a.toLocaleString()," of ",n.toLocaleString()]}),e.jsx(r,{children:e.jsx(w,{onClick:()=>t.nextPage(),onMouseEnter:g,disabled:!t.getCanNextPage()})}),e.jsx(r,{children:e.jsx(C,{onClick:()=>t.lastPage(),onMouseEnter:h,disabled:!t.getCanNextPage()})})]})})}export{E as D};
//# sourceMappingURL=data-table-BX7QQ1sx.js.map
