import{r as c,j as t}from"./vendor-react-wBh_31cN.js";import{d as l}from"./index-BKr2rJhV.js";import{ac as b,ad as p}from"./vendor-icons-BUUmD6ht.js";const i=c.createContext({stickyHeader:!1});function N({className:a,stickyHeader:e=!1,wrapperClassName:r,...n}){const s=c.useMemo(()=>({stickyHeader:e}),[e]);return t.jsx(i.Provider,{value:s,children:t.jsx("div",{"data-slot":"table-wrapper",className:l("@container/table relative w-full overflow-auto rounded-md border border-border",r),children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm border-collapse",a),...n})})})}function C({className:a,...e}){const{stickyHeader:r}=c.useContext(i);return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b bg-muted/50",r&&"sticky top-0 z-10 bg-muted [&_th]:shadow-[inset_0_-1px_0_var(--border)]",a),...e})}function T({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function f({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b border-border transition-colors hover:bg-accent data-[state=selected]:bg-muted",a),...e})}const m="min-w-[140px] max-w-[280px] w-full @max-3xl/table:max-w-[200px] @max-2xl/table:max-w-[160px] @max-xl/table:max-w-[140px]",u="w-full max-w-[400px] @max-4xl/table:max-w-[280px] @max-3xl/table:max-w-[200px] @max-2xl/table:max-w-[140px]";function y({className:a,sortable:e,sortDirection:r,onSort:n,primary:s,truncate:o,children:x,...d}){return t.jsx("th",{"data-slot":"table-head",className:l("h-9 px-3 text-left align-middle text-xs font-bold text-muted-foreground whitespace-nowrap",e&&"cursor-pointer select-none",s&&m,o&&u,a),onClick:e?n:void 0,...d,children:t.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[t.jsx("span",{className:"truncate",children:x}),e&&t.jsxs("span",{className:"inline-flex flex-col items-center -space-y-1 shrink-0",children:[t.jsx(b,{className:l("size-3",r==="asc"?"text-primary":"text-muted-foreground/40")}),t.jsx(p,{className:l("size-3",r==="desc"?"text-primary":"text-muted-foreground/40")})]})]})})}function h({children:a}){const e=c.useRef(null),[r,n]=c.useState(!1),s=c.useCallback(()=>{const o=e.current;o&&n(o.scrollHeight-o.clientHeight-o.scrollTop>1)},[]);return c.useEffect(()=>{const o=e.current;if(!o)return;s();const x=new ResizeObserver(s);return x.observe(o),()=>x.disconnect()},[s]),t.jsx("div",{ref:e,onScroll:s,onMouseEnter:s,className:l("truncate max-h-5 cell-scrollbar transition-[max-height] duration-200 ease-out group-hover/row:max-h-[50vh] group-hover/row:overflow-auto group-hover/row:whitespace-normal group-hover/row:break-words",r&&"group-hover/row:cell-fade-bottom"),children:a})}function w({className:a,primary:e,truncate:r,expandOnHover:n,children:s,...o}){const x=r||n;let d=s;return n?d=t.jsx(h,{children:s}):r&&(d=t.jsx("div",{className:"truncate",children:s})),t.jsx("td",{"data-slot":"table-cell",className:l("px-3 py-2 align-middle text-xs whitespace-nowrap",e&&m,x&&u,n&&"align-top transition-colors hover:bg-primary/15",a),...o,children:d})}function _({colSpan:a,children:e,className:r}){return t.jsx(f,{className:"hover:bg-transparent",children:t.jsx(w,{colSpan:a,className:l("h-24 text-center text-muted-foreground",r),children:e??"No results."})})}export{N as T,C as a,f as b,y as c,T as d,w as e,_ as f};
