import{X as v,j as e,M as C,S as E,B as u}from"./vendor-mui-CBBEb17G.js";import{a as x}from"./vendor-react-BBazpZul.js";import{e as R,aR as B,aS as D,c as s,c$ as h,aP as m}from"./index-IP_FWtso.js";import"./vendor-utils-BveVE6Uf.js";const T=({onRefresh:f,onSearch:j,searchLabel:d,title:l,classes:t,className:g,refreshContent:w,searchContent:b,children:F})=>{const{userType:p}=R(r=>r.user),[n,a]=x.useState(""),[o,c]=x.useState(!1),S=v("(max-width:500px)"),i=()=>{j(n)},y=()=>{a(""),c(!1),f()},N=()=>S?e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsx("span",{className:s("px-[20px] py-[4px] text-center text-white !font-bold",(+p===h.accountant,"bg-[#6DC9FF]")),style:{borderRadius:"15px 15px 0 0",whiteSpace:"nowrap"},children:l}),e.jsx(m,{sx:{".MuiInputBase-root":{borderRadius:"0 15px 15px 15px !important",marginTop:"5px"}},className:t==null?void 0:t.textField,onChange:r=>a(r),value:n,label:d,placeholder:"جستجو...",fullWidth:!0,error:o,onKeyDown:r=>{r.key==="Enter"&&i()}})]}):e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsx("div",{className:s("w-[300px] rounded-md px-[20px] py-[4px] text-white !font-bold bg-gradient-to-r text-center",(+p===h.accountant,"bg-[#6DC9FF]")),children:l}),e.jsx(m,{sx:{".MuiInputBase-root":{borderRadius:""},minWidth:"150px"},className:t==null?void 0:t.textField,onChange:r=>a(r),value:n,label:d,placeholder:"جستجو...",fullWidth:!0,error:o,onKeyDown:r=>{r.key==="Enter"&&i()}})]});return x.useEffect(()=>{n&&o&&c(!1)},[n]),e.jsx(C,{item:!0,container:!0,className:` relative ${g}`,children:e.jsx("div",{children:e.jsxs(E,{justifyContent:"start",direction:"column",alignItems:"end",spacing:1,sx:{width:"100%"},children:[N(),F,e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{onClick:i,variant:"contained",color:"primary",className:`!min-w-[40px] h-[34px] !rounded-[15px] ${t==null?void 0:t.searchBtn}`,children:b||e.jsx(B,{})}),e.jsx(u,{onClick:y,variant:"contained",color:"info",className:`!min-w-[40px]  h-[34px] !rounded-[15px] ${t==null?void 0:t.refreshBtn}`,children:w||e.jsx(D,{})})]})]})})})};export{T as P};
