import{jsxs as n,jsx as o}from"react/jsx-runtime";import{T as h}from"./table-header-DXTJ1r7-.js";import{aD as T,aE as C,aF as c,c as R,aG as d}from"./ui-components-B24mpb8o.js";import{useReactTable as w,getFilteredRowModel as M,getSortedRowModel as N,getCoreRowModel as S,flexRender as x}from"@tanstack/react-table";import*as F from"react";import y from"./blogs-table-columns-R2OpmtLM.js";import D from"./categories-table-columns-CnxipLFz.js";import j from"./courses-table-columns-BQ4ep6nS.js";import v from"./instructors-table-columns-NXoZHDYh.js";import B from"./table-filter-h0ofTU44.js";import k from"./table-footer-D5myFeWO.js";import"next-themes";import"sonner";import"@radix-ui/react-label";import"class-variance-authority";import"@radix-ui/react-checkbox";import"lucide-react";import"@radix-ui/react-avatar";import"@radix-ui/react-dropdown-menu";import"@radix-ui/react-scroll-area";import"@radix-ui/react-popover";import"@radix-ui/react-radio-group";import"@radix-ui/react-dialog";import"@radix-ui/react-slot";import"clsx";import"@radix-ui/react-separator";import"@radix-ui/react-tooltip";import"@radix-ui/react-tabs";import"@radix-ui/react-accordion";import"@radix-ui/react-progress";import"@radix-ui/react-select";import"cmdk";import"@radix-ui/react-switch";import"react-day-picker";import"@radix-ui/react-slider";import"embla-carousel-react";import"@radix-ui/react-toggle-group";import"vaul";import"tailwind-merge";import"@inertiajs/react";import"./table-page-size-B94DPeOD.js";import"./route-D0xh7FtZ.js";import"./debounce-CWHP_ANh.js";const Mo=({type:a,title:u,data:t,selectedIds:e=[],onCourseSelect:l})=>{var p;const s="frontend.api",g=()=>{switch(a){case"courses":return j();case"instructors":return v();case"blogs":return y();default:return D()}},[b,f]=F.useState([]),i=w({data:t.data,columns:g(),onSortingChange:f,getCoreRowModel:S(),getSortedRowModel:N(),getFilteredRowModel:M(),state:{sorting:b}});return n("div",{children:[o(B,{data:t,title:u,searchKey:a,globalSearch:!0,tablePageSizes:[10,15,20,25],routeName:s}),n(T,{className:"border-border border-y",children:[o(h,{table:i}),o(C,{children:(p=i.getRowModel().rows)!=null&&p.length?i.getRowModel().rows.map(r=>o(c,{"data-state":r.getIsSelected()&&"selected",className:R("hover:bg-muted cursor-pointer",(e==null?void 0:e.includes(Number(r.original.id)))&&"bg-secondary-light"),onClick:()=>l&&l(Number(r.original.id)),children:r.getVisibleCells().map(m=>o(d,{children:x(m.column.columnDef.cell,m.getContext())},m.id))},r.id)):o(c,{children:o(d,{className:"h-24 text-center",children:"No results."})})})]}),o(k,{className:"p-4",routeName:s,paginationInfo:t})]})};export{Mo as default};
