import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{t as n}from"./vendor-react-CAGJwf-T.js";import{t as r}from"./createLucideIcon-FT8xbHot.js";import{t as i}from"./utils-Dk_44zMo.js";import{pt as a,vt as o}from"./index-Z_bdWDpJ.js";import{a as s,i as c,n as l,o as u,t as d}from"./vendor-table-DrED5BwI.js";import{n as f,t as p}from"./Pagination-C9RclMeu.js";import{t as m}from"./EmptyState-BuyIB74a.js";import{n as h}from"./Skeleton-0UpX2lan.js";var g=r(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),_=r(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),v=r(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),y=e(t(),1),b=n();function x({columns:e,data:t,isLoading:n=!1,isFetching:r=!1,searchable:x=!0,searchPlaceholder:S=`Search...`,totalItems:C,currentPage:w=1,pageSize:T=20,totalPages:E=1,onPageChange:D,onPageSizeChange:O,onSearch:k,emptyTitle:A=`No results found`,emptyDescription:j=`Try adjusting your search or filters.`,emptyActionLabel:M,onEmptyAction:N,toolbar:P,className:F,onRowClick:I}){let[L,R]=(0,y.useState)([]),[z,B]=(0,y.useState)(``),V=l({data:t,columns:e,state:{sorting:L,globalFilter:z},onSortingChange:R,onGlobalFilterChange:B,getCoreRowModel:c(),getSortedRowModel:u(),getFilteredRowModel:s()}),H=e=>{B(e),k?.(e)},U=C??t.length,W=D&&U>0;return(0,b.jsxs)(`div`,{className:i(`flex flex-col bg-[var(--color-surface)] rounded-xl border border-[var(--color-border)] shadow-[var(--shadow-sm)] overflow-hidden`,F),children:[(x||P)&&(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3 border-b border-[var(--color-border)] flex-shrink-0`,children:[x&&(0,b.jsx)(f,{placeholder:S,value:z,onChange:H,className:`w-64`}),P&&(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:P})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto relative`,children:[r&&!n&&(0,b.jsx)(`div`,{className:`absolute inset-0 z-10 bg-[var(--color-surface)]/60 flex items-center justify-center pointer-events-none`,children:(0,b.jsx)(o,{className:`w-5 h-5 text-[var(--color-primary)] animate-spin`})}),(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 z-10`,children:V.getHeaderGroups().map(e=>(0,b.jsx)(`tr`,{className:`border-b border-[var(--color-border)]`,children:e.headers.map(e=>(0,b.jsx)(`th`,{className:i(`h-10 px-5 text-left text-[11px] font-semibold uppercase tracking-[0.06em] text-[var(--color-text-muted)]`,`bg-[var(--color-background)]`,e.column.getCanSort()&&`cursor-pointer select-none hover:text-[var(--color-text-secondary)] transition-colors`),onClick:e.column.getToggleSortingHandler(),"aria-sort":e.column.getIsSorted()===`asc`?`ascending`:e.column.getIsSorted()===`desc`?`descending`:e.column.getCanSort()?`none`:void 0,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.isPlaceholder?null:d(e.column.columnDef.header,e.getContext()),e.column.getCanSort()&&(0,b.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:e.column.getIsSorted()===`asc`?(0,b.jsx)(v,{className:`w-3 h-3`}):e.column.getIsSorted()===`desc`?(0,b.jsx)(g,{className:`w-3 h-3`}):(0,b.jsx)(_,{className:`w-3 h-3 opacity-30`})})]})},e.id))},e.id))}),(0,b.jsx)(`tbody`,{children:n?Array.from({length:5},(t,n)=>(0,b.jsx)(h,{columns:e.length},n)):V.getRowModel().rows.length>0?V.getRowModel().rows.map(e=>(0,b.jsx)(`tr`,{className:i(`border-b border-[var(--color-border-light)] last:border-0 hover:bg-slate-50/70 dark:hover:bg-slate-800/50 transition-colors`,I&&`cursor-pointer`),onClick:I?t=>{t.target.closest(`button, a, input, select, label`)||I(e.original)}:void 0,children:e.getVisibleCells().map(e=>(0,b.jsx)(`td`,{className:`px-5 py-3 text-[13px] text-[var(--color-text-secondary)]`,children:d(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:e.length,children:(0,b.jsx)(m,{icon:a,title:A,description:j,actionLabel:M,onAction:N})})})})]})]}),W&&(0,b.jsx)(`div`,{className:i(`px-5 border-t border-[var(--color-border)] flex-shrink-0`,r&&`pointer-events-none opacity-60`),children:(0,b.jsx)(p,{currentPage:w,totalPages:E,totalItems:U,pageSize:T,onPageChange:D,onPageSizeChange:O})})]})}export{x as t};