import{j as e}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0286.js";import{a as n}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0282.js";import{A as k,L as E}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b02812.js";import{b as A,u as L}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0285.js";import{u as T,k as B}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b02821.js";import{a as R,b as M,c as S,I as N,e as P}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0288.js";import{I as H}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b028223.js";import{W as C}from"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0283.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b028.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0284.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b02820.js";import"./v_7_4_3_48_026858c9-0735-4edd-ae06-f5f59030b0287.js";const O=({selectAll:d,pesquisar:i,setSelecionados:y,tabId:b})=>{const{userTabs:w}=T(),[m,h]=n.useState([]),{language:v}=L(),[l,u]=n.useState([]),f=A(s=>s.user);n.useEffect(()=>{const s=async()=>{let t;switch(b){case 1:t=await C.Chat("List");break;case 2:t=await C.Chat("List","onlyGroups");break;case 3:t=await C.Chat("List","nao-lido");break;case 4:t=await C.Chat("List","1:1");break;case 5:t=await C.Chat("List",{type:"tab_atendentes",user:f});break}u(t),h(t)},a=w.find(t=>t.id===b);a?(u(a.chats),h(a.chats)):s()},[m]),n.useEffect(()=>{if(i.length===0)u(m);else{let s=[];m.forEach(a=>{(a.id.includes(i)||a.name?.toUpperCase().includes(i.toUpperCase()))&&s.push(a)}),u(s)}},[i]);const[x,p]=n.useState(new Set);n.useEffect(()=>{if(d)p(new Set);else{const s=l.map(a=>a.id);p(new Set(s))}},[d]);const o=s=>{p(a=>{const t=new Set(a);return t.has(s)?t.delete(s):t.add(s),t})};n.useEffect(()=>{y(m.filter(s=>x.has(s.id)))},[x]);const g=({index:s,key:a,style:t})=>{const r=l[s];if(r)return e.jsx("li",{style:t,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(P,{id:r.id,estado:x.has(r.id),checkedUpdade:()=>o(r.id)}),e.jsx("span",{className:"flex-[inherit] overflow-hidden text-ellipsis whitespace-nowrap",children:e.jsx("strong",{children:r.name})}),e.jsx("span",{children:r.id})]})})},r.id)},_=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 - 340px)",minHeight:"60px",height:`${l.length*32}px`},children:e.jsx(k,{children:({width:s,height:a})=>e.jsx(E,{width:s,height:a,rowCount:l.length,rowHeight:32,rowRenderer:g})})})}),j=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:[" ",i.length!==0?v.nenhumContatoEncontrado:v.carregando,"  "]})})})})})})});return l.length!==0?_:j};function X({tabId:d,aba_System:i}){const{userTabs:y,setCopyChats:b,setMoveChats:w}=T(),{openRendertype:m,close:h}=B(),v=A(c=>c.session),[l,u]=n.useState(""),[f,x]=n.useState(!0),p=()=>{x(!f)},{language:o}=L(),[g,_]=n.useState([]),[j,s]=n.useState(y.find(c=>c.id!==d)?.id);g.length>5&&!v.is_premium&&m("user_free");const a=async()=>{h(),b(g,j),N({type:"Success",message:o.sucessCopyContact,position:"top-right"})},t=async()=>{h(),w(g,d,j),N({type:"Success",message:o.contatosMovidosParaAbaSelecionada,position:"top-right"})};return e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(R,{children:o.menu_moreAba_copyContact_title}),e.jsx(M,{children:o.menu_moreAba_copyContact_subTitle}),e.jsx(H,{inpPlaceTxt:o.menu_moreAba_copyContact_placeContact,inpValue:l,inpSetValue:u,selectAll:f,btnConfirmName:o.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:p,btnNegacaoName:o.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(O,{selectAll:f,pesquisar:l,setSelecionados:_,tabId:d}),e.jsxs("div",{className:"py-4 form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:o.menu_moreAba_copyContact_selectDestiny})}),e.jsx("select",{className:"!py-0 select select-bordered !select-sm w-full",value:j,onChange:c=>s(c.target.value),children:y.map(c=>c.id==d?void 0:e.jsx("option",{value:c.id,children:c.tag}))})]}),e.jsxs("div",{className:(i?"justify-end":"justify-around")+" flex p-2",children:[!i&&e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonMove,funcao:t}),e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonCopy,funcao:a})]})]})}export{X as default};
