import{a as C,ek as L,r as i,j as e,B as v,P as u,Q as V,b as k,bG as f,_ as M}from"./index-d2b25495.js";import{c as T}from"./componentStyles-0e851d91.js";/* empty css                   */import{S as I}from"./ScrollableList-fc1de312.js";import{E as D}from"./EmptyData-c0636520.js";import{u as G}from"./index-1249dfe4.js";import{T as H}from"./index-75fca24c.js";const O=({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=G(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;k();const[j,w]=i.useState([]),[r,E]=i.useState(localStorage.getItem("view")||"list");return i.useMemo(()=>{if(r!=="list")if(s.page==1)w(o);else{const t=j.concat(o);w(t)}else w([])},[o,r,s.page]),i.useEffect(()=>{const t=S=>{E(S.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(H,{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(O,{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=T)==null?void 0:y.ResponsiveGrid,maxHeight:"calc(100vh - 300px)",gap:"16px !important"},list:j,loading:a,params:s,fetchapi:c,renderItem:(t,S)=>e.jsx(u,{size:{xs:12,md:6,lg:4,xl:3},children:b(t,S)})})})})]})};export{J as M};
