import{j as e}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89263.js";import{a as n}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89262.js";import{A as E,L as k}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892612.js";import{V as A,z as g}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";import{a as L,q as B}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892625.js";import{u as T}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89264.js";import{D as R,E as M,H as S,I as N,K as H}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89268.js";import{I as O}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926233.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89266.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89269.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892610.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89267.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892620.js";const U=({selectAll:d,pesquisar:i,setSelecionados:y,tabId:v})=>{const{userTabs:w}=L(),[m,h]=n.useState([]),{language:b}=T(),[l,u]=n.useState([]),f=A(t=>t.user);n.useEffect(()=>{const t=async()=>{let s;switch(v){case 1:s=await g.Chat("List");break;case 2:s=await g.Chat("List","onlyGroups");break;case 3:s=await g.Chat("List","nao-lido");break;case 4:s=await g.Chat("List","1:1");break;case 5:s=await g.Chat("List",{type:"tab_atendentes",user:f});break}u(s),h(s)},a=w.find(s=>s.id===v);a?(u(a.chats),h(a.chats)):t()},[m]),n.useEffect(()=>{if(i.length===0)u(m);else{let t=[];m.forEach(a=>{(a.id.includes(i)||a.name?.toUpperCase().includes(i.toUpperCase()))&&t.push(a)}),u(t)}},[i]);const[x,p]=n.useState(new Set);n.useEffect(()=>{if(d)p(new Set);else{const t=l.map(a=>a.id);p(new Set(t))}},[d]);const o=t=>{p(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})};n.useEffect(()=>{y(m.filter(t=>x.has(t.id)))},[x]);const j=({index:t,key:a,style:s})=>{const r=l[t];if(r)return e.jsx("li",{style:s,children:e.jsx("div",{className:"form-control",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(H,{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(E,{children:({width:t,height:a})=>e.jsx(k,{width:t,height:a,rowCount:l.length,rowHeight:32,rowRenderer:j})})})}),C=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?b.nenhumContatoEncontrado:b.carregando,"  "]})})})})})})});return l.length!==0?_:C};function Z({tabId:d,aba_System:i}){const{userTabs:y,setCopyChats:v,setMoveChats:w}=L(),{openRendertype:m,close:h}=B(),b=A(c=>c.session),[l,u]=n.useState(""),[f,x]=n.useState(!0),p=()=>{x(!f)},{language:o}=T(),[j,_]=n.useState([]),[C,t]=n.useState(y.find(c=>c.id!==d)?.id);j.length>5&&!b.is_premium&&m("user_free");const a=async()=>{h(),v(j,C),N({type:"Success",message:o.sucessCopyContact,position:"top-right"})},s=async()=>{h(),w(j,d,C),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(O,{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(U,{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:C,onChange:c=>t(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:s}),e.jsx(S,{name:o.menu_moreAba_copyContact_placeButtonCopy,funcao:a})]})]})}export{Z as default};
