import{j as e,p as h,Y as P,Z as b,$ as R,U as c,V as a,a0 as j,a8 as g,S as E,o as I}from"./vendor-mui-CBBEb17G.js";import{dP as $,aT as B,dM as N,dN as G,dO as V,ao as z,I as U}from"./index-IP_FWtso.js";import{a as p}from"./vendor-react-BBazpZul.js";const D=({onSelect:v,isSalamatInsurance:x,loading:w,searchList:l,searchQuery:i,serviceType:f,onLoad:S,pageNumber:C,pageSize:T,totalCount:m,selectedParaClinic:d,showAdd:k=!0})=>{const[o,t]=p.useState(),y=s=>{const r={name:`${s.interfaceName}@${s.fullName}`,srvCode:s.nationalNumber,id:s.nationalNumber,nationalNumber:s.nationalNumber,srvType:f,count:1,loincCode:s.loincCode};o!=null&&o.some(n=>n.id===r.id)?t(o.filter(n=>n.id!=r.id)):t(n=>[...n??[],r])},H=s=>{const r={srvName:s.srvName,srvCode:s.srvCode,parGrpCode:s.parGrpCode,srvType:s.srvType,id:s.id,wsSrvCode:s.wsSrvCode,parGrpRem:s.parGrpRem,count:1,loincCode:s.loincCode};o!=null&&o.some(n=>n.wsSrvCode===r.wsSrvCode)?t(o.filter(n=>n.wsSrvCode!=r.wsSrvCode)):t(n=>[...n??[],r])},u=s=>{x?y(s):H(s)};return p.useEffect(()=>{d&&t(d)},[d]),e.jsxs(h,{className:"relative h-[calc(100%-90px)] min-h-[300px]  border rounded-lg overflow-auto",children:[w&&e.jsx($,{}),e.jsxs("div",{className:"m-2",children:[e.jsx(B,{color:"success"}),e.jsx("span",{className:"font-bold mr-1",children:"نتیجه جستجو"})]}),e.jsx(P,{className:`absolute top-[40px] bottom-0 left-0 rhigt-0 ${m?"!mb-[55px]":"mb-1"} overflow-auto`,children:e.jsxs(b,{stickyHeader:!0,size:"small",children:[e.jsx(R,{sx:{borderRadius:"12px"},children:e.jsxs(c,{children:[e.jsx(a,{width:30,align:"center",className:"!bg-blue-800 !text-white"}),e.jsx(a,{className:"!bg-blue-800 !text-white min-w-[80px]",children:"کد خدمت"}),e.jsx(a,{className:"!bg-blue-800 !text-white",children:"نام خدمت"}),e.jsx(a,{className:"!bg-blue-800 !text-white",children:"توضیحات"})]})}),e.jsx(j,{children:x?l==null?void 0:l.map(s=>e.jsxs(c,{hover:!0,className:"!cursor-pointer",onClick:()=>u(s),sx:{"&:hover":{backgroundColor:"#c1eeff !important"}},children:[e.jsx(a,{className:"!py-0",children:e.jsx(g,{className:"!p-0 !m-0",checked:!!(o!=null&&o.some(r=>r.nationalNumber==s.nationalNumber))})}),e.jsx(a,{children:s.nationalNumber}),e.jsx(a,{children:e.jsx(N,{className:"cursor-pointer noselect",searchWords:[i],autoEscape:!0,textToHighlight:s.interfaceName})}),e.jsxs(a,{children:[" ",e.jsx(G,{serachQuery:i,value:s.fullName??"",maxLengthValue:45})," "]})]},s.nationalNumber)):l==null?void 0:l.map(s=>e.jsxs(c,{hover:!0,className:"!cursor-pointer",onClick:()=>u(s),sx:{"&:hover":{backgroundColor:"#c1eeff !important"}},children:[e.jsx(a,{className:"!py-0",children:e.jsx(g,{className:"!p-0 !m-0",checked:!!(o!=null&&o.some(r=>r.wsSrvCode==s.wsSrvCode))})}),e.jsx(a,{children:s.wsSrvCode}),e.jsx(a,{children:e.jsx(N,{className:"cursor-pointer noselect",searchWords:[i],autoEscape:!0,textToHighlight:s.srvName})}),e.jsx(a,{children:"---"})]},s.id))})]})}),m&&e.jsx(b,{className:"absolute bottom-0 left-0 right-0 z-10 bg-gray-50 w-full",children:e.jsx(j,{children:e.jsx(c,{children:e.jsx(V,{className:"!pr-[35%]",align:"center",totalCount:m,initialPage:C,initialRowsPerPage:T||50,onPageChange:S})})})}),k&&(o==null?void 0:o.length)&&e.jsx(h,{className:"absolute bottom-2 right-4 z-10 bg-gray-50  ",children:e.jsx(z,{className:"!bg-orange-600 animate-[bounce_2s_ease-in-out_infinite] hover:animate-none !pr-[40px] w-[250px]",children:e.jsxs(E,{direction:"row",alignItems:"center",width:"100%",children:[e.jsx(h,{onClick:()=>v(o),children:`افزودن به لیست ( ${o==null?void 0:o.length} مورد)`}),e.jsx(I,{onClick:()=>{t([])},className:"!mr-auto !text-white",children:e.jsx(U.CloseIcon,{})})]})})})]})};export{D as P};
