import{a as C,eh as L,r as i,j as e,B as v,Q as u,S as V,b as T,bE as f,_ as M}from"./index-60a3c753.js";import{c as k}from"./componentStyles-7753bbb9.js";/* empty css                   */import{S as I}from"./ScrollableList-1962b023.js";import{E as D}from"./EmptyData-7c42e375.js";import{u as H}from"./index-a99c9f65.js";import{T as O}from"./index-7e55cf46.js";const R=({list:o,loading:m,pageParams:x,fetchapi:a,children:d,renderItemCard:s})=>{const l=C(n=>n.customise.sidenav.showMobileMenu),{id:p}=L();i.useState(null),i.useState(0),i.useState(!1);const h=H(n=>n.breakpoints.down("md")),g=e.jsx(u,{size:{xs:12,md:4,lg:3.5,xl:l?3.5:3},children:e.jsx(I,{list:o,loading:m,params:x,fetchapi:a,styles:{maxHeight:"calc(100vh - 270px)"},renderItem:(n,c)=>e.jsx(v,{mb:1,marginInlineStart:-1,marginInlineEnd:-1,children:s(n,c)})})});return e.jsx(v,{sx:{display:"flex",flexDirection:"column"},children:e.jsxs(u,{container:!0,spacing:1,children:[!h&&g,e.jsx(u,{size:{xs:12,md:8,lg:8.5,xl:l?8.5:9},children:e.jsx(V,{sx:{maxHeight:"calc(100vh - 270px)",overflow:"auto"},children:p?d:e.jsx(D,{message:"Please Select a record"})})})]})})},J=({data:o,columns:m=[],rows:x=[],loading:a,count:d,pageParams:s,showPagination:l,containerHeight:p,handleSort:h,handleChangePage:g,handleChangeRowsPerPage:n,fetchapi:c,children:z,renderItemCard:b})=>{var y;T();const[j,S]=i.useState([]),[r,E]=i.useState(localStorage.getItem("view")||"list");return i.useMemo(()=>{if(r!=="list")if(s.page==1)S(o);else{const t=j.concat(o);S(t)}else S([])},[o,r,s.page]),i.useEffect(()=>{const t=w=>{E(w.detail||"list")};return window.addEventListener("viewChange",t),()=>window.removeEventListener("viewChange",t)},[]),i.useEffect(()=>{const t=localStorage.getItem("view");t!==r&&E(t||"list")},[localStorage.getItem("view")]),e.jsxs(e.Fragment,{children:[e.jsx(f,{in:r==="list",timeout:300,unmountOnExit:!0,children:e.jsx(M,{sx:{borderRadius:"5px"},children:e.jsx(O,{count:d,columns:m,rows:x,loading:a,page:s.page,pageSize:s.page_size,handleSort:h,handleChangePage:g,handleChangeRowsPerPage:n,showPagination:l,containerHeight:p})})}),e.jsx(f,{in:r==="thumbnail",timeout:300,unmountOnExit:!0,children:e.jsx(M,{sx:t=>({bgcolor:t.palette.background.default}),children:e.jsx(R,{list:j,loading:a,pageParams:s,fetchapi:c,renderItemCard:b,children:z})})}),e.jsx(f,{in:r==="grid",timeout:300,unmountOnExit:!0,children:e.jsx(v,{children:e.jsx(I,{styles:{...(y=k)==null?void 0:y.ResponsiveGrid,maxHeight:"calc(100vh - 300px)",gap:"16px !important"},list:j,loading:a,params:s,fetchapi:c,renderItem:(t,w)=>e.jsx(u,{size:{xs:12,md:6,lg:4,xl:3},children:b(t,w)})})})})]})};export{J as M};
