import{j as e,y as B,H as R,Q as T,Y as H}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b10.js";import{a as o}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b4.js";import{A as U,L as M}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b5.js";import{a as L,o as O,n as P}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b23.js";import{u as k,b as z}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b19.js";import{I as F}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b222.js";import{W as _}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b18.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b8.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b7.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b6.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b9.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b2.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b3.js";const I=({selectAll:u,pesquisar:a,setSelecionados:g,tabId:p})=>{const{userTabs:h}=L(),j=z.getState().isBusiness,[l,C]=o.useState([]);o.useEffect(()=>{(async()=>{const s=await _.Chat("List"),n=await _.Contact("List","onlyMyContacts"),c=j?await _.Contact("List","allLabels"):[],v=h.find(r=>r.id===p),N=(v==null?void 0:v.chats.map(r=>({id:r.id,name:r.id})))??[],E=s.concat(n).concat(c).concat(N),w=[],y=new Set;E.forEach(r=>{r.id&&!y.has(r.id)&&(y.add(r.id),w.push(r))}),f(w),C(w)})()},[]);const[i,f]=o.useState([]);o.useEffect(()=>{if(a.length===0)f(l);else{let t=[];l.forEach(s=>{var n;(s.id.includes(a)||(n=s.name)!=null&&n.toUpperCase().includes(a.toUpperCase()))&&t.push(s)}),f(t)}},[a]);const[d,m]=o.useState(new Set);o.useEffect(()=>{if(u)m(new Set);else{const t=i.map(s=>s.id);m(new Set(t))}},[u]);const x=t=>{m(s=>{const n=new Set(s);return n.has(t)?n.delete(t):n.add(t),n})};o.useEffect(()=>{h.forEach(t=>{t.id===p&&t.chats.forEach(s=>{x(s.id)})})},[h]),o.useEffect(()=>{g(l.filter(t=>d.has(t.id)))},[l,d]);const S=({index:t,key:s,style:n})=>{const c=i[t];if(c)return e.jsx("li",{style:n,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(H,{id:c.id,estado:d.has(c.id),checkedUpdade:()=>x(c.id)}),e.jsx("span",{className:"flex-[inherit] overflow-hidden text-ellipsis whitespace-nowrap",children:e.jsx("strong",{children:c.name})}),e.jsx("span",{children:c.id})]})})},c.id)},b=e.jsx("div",{className:"w-full pt-2",children:e.jsx("ul",{className:"gap-2 overflow-y-auto overflow-x-hidden justify-center",style:{maxHeight:"calc(100vh - 240px)",minHeight:"60px",height:`${i.length*32}px`},children:e.jsx(U,{children:({width:t,height:s})=>e.jsx(M,{width:t,height:s,rowCount:i.length,rowHeight:32,rowRenderer:S})})})}),A=e.jsx("div",{children:e.jsx("ul",{children:e.jsx("div",{style:{maxHeight:"calc(100vh - 300px)"},className:"grid overflow-auto mt-4 gap-1",children:e.jsx("li",{children:e.jsx("div",{children:e.jsx("span",{className:"w-full flex justify-center p-4",children:e.jsxs("strong",{children:[" ",a.length!==0?"Nenhum Contact encontrado":"Carregando...","  "]})})})})})})});return i.length!==0?b:A};function se({tabId:u}){const{language:a}=k(),{setChatsTab:g}=L(),{openRendertype:p,close:h}=O(),{user:j}=P(),[l,C]=o.useState(""),[i,f]=o.useState(!0),d=()=>{f(!i)},[m,x]=o.useState([]);m.length>5&&!j.estado&&p("user_free");const S=async()=>{h(),g(m,u)};return e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(B,{children:a.menu_moreAba_addContact_title}),e.jsx(R,{children:a.menu_moreAba_addContact_subTitle}),e.jsx(F,{inpPlaceTxt:a.menu_moreAba_addContact_placeContact,inpValue:l,inpSetValue:C,selectAll:i,btnConfirmName:a.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:d,btnNegacaoName:a.menu_moreAba_removeAll,btnNegacaoFuncao:d}),e.jsx(I,{selectAll:i,pesquisar:l,setSelecionados:x,tabId:u}),e.jsx("div",{className:"flex justify-end p-2",children:e.jsx(T,{name:a.menu_moreAba_addContact_placeButtonSave,funcao:S})})]})}export{se as default};
