import{j as e}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67155.js";import{r as s}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b6715.js";import{b as w,u as x}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67154.js";import{m as v}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671523.js";import{o as A,p as N,r as S,u as I,I as y}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67157.js";import{I as B}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b6715213.js";import{W as h}from"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67152.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67153.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67159.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671510.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67158.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b671520.js";import"./v_7_4_3_42_40a29d0b-9b36-4e19-997c-87ed486b67156.js";const E=async(a,l)=>{const m=x.getState().language,r=v.getState().close;a=a.map(i=>i.id.length>17?i.id+"@g.us":i.id+"@c.us"),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:l,type:"add"}}),r(),y({type:"Success",message:m.menu_moreAba_contatosCopiados,position:"top-right"})},O=async(a,l,m)=>{const r=x.getState().language,i=v.getState().close;a=a.map(o=>o.id.length>17?o.id+"@g.us":o.id+"@c.us"),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:m,type:"remove"}}),await h.Labels("addOrRemoveLabels",{id:a,label:{labelId:l,type:"add"}}),i(),y({type:"Success",message:r.menu_moreAba_contatosMovidos,position:"top-right"})},R=({selectAll:a,pesquisar:l,setSelecionados:m,id:r})=>{const{language:i}=x(),[o,_]=s.useState([]),[p,n]=s.useState([]);s.useEffect(()=>{(async()=>{const t=await h.Contact("List",{type:"withLabels",id:r});n(t),_(t)})()},[]),s.useEffect(()=>{if(l.length===0)n(o);else{let t=[];o.forEach(c=>{(c.id.includes(l)||c.name?.toUpperCase().includes(l.toUpperCase()))&&t.push(c)}),n(t)}},[l]);const[u,g]=s.useState(new Set);s.useEffect(()=>{if(a)g(new Set);else{const t=p.map(c=>c.id);g(new Set(t))}},[a]);const j=t=>{g(c=>{const f=new Set(c);return f.has(t)?f.delete(t):f.add(t),f})};s.useEffect(()=>{m(o.filter(t=>u.has(t.id)))},[u]);const C=p.map(t=>e.jsx("li",{children:e.jsx("div",{className:"form-control animate__animated animate__fadeInDownBig",children:e.jsxs("label",{className:"cursor-pointer label gap-2 justify-start",children:[e.jsx(I,{id:t.id,estado:u.has(t.id),checkedUpdade:()=>j(t.id)}),e.jsx("span",{children:e.jsx("strong",{children:t.name})}),e.jsx("span",{children:t.id})]})})},t.id));return e.jsx("div",{children:e.jsx("ul",{children:e.jsxs("div",{style:{maxHeight:"calc(100vh - 400px)"},className:"grid overflow-auto mt-4 gap-1",children:[p.length===0?e.jsx("li",{children:e.jsx("div",{children:e.jsxs("span",{className:"w-full text-center p-4",children:[" ",e.jsx("strong",{children:i.menu_moreAba_copyContact_noContact})," "]})})}):void 0,C]})})})};function J({id:a}){const{openRendertype:l}=v(),m=w(d=>d.session),[r,i]=s.useState(""),[o,_]=s.useState(!0),p=()=>{_(!o)},{language:n}=x(),[u,g]=s.useState([]),[j,C]=s.useState([]),[t,c]=s.useState([]);return s.useEffect(()=>{(async()=>{let b=await h.Labels("getAllLabels");b=b.filter(L=>L.id!==a),c(b[0]),C(b)})()},[]),u.length>5&&!m.is_premium&&l("user_free"),e.jsxs("div",{className:"w-[508px] h-fit",children:[e.jsx(A,{children:n.menu_moreAba_copyContactForOtherLB}),e.jsx(N,{children:"Selecione os contatos para copiar desta etiqueta"}),e.jsx(B,{inpPlaceTxt:n.menu_moreAba_copyContact_placeContact,inpValue:r,inpSetValue:i,selectAll:o,btnConfirmName:n.menu_moreAba_addContact_placeButtonSelectAll,btnConfirmFuncao:p,btnNegacaoName:n.menu_moreAba_removeAll,btnNegacaoFuncao:p}),e.jsx(R,{selectAll:o,pesquisar:r,setSelecionados:g,id:a}),e.jsxs("div",{className:"py-4 form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:n.menu_moreAba_copyContact_selectDestiny})}),e.jsx("select",{className:"!py-0 select select-bordered !select-sm w-full",value:t.id,onChange:d=>c(d.target.value),children:j.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id))})]}),e.jsxs("div",{className:"justify-around flex p-2",children:[e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonMove,funcao:()=>O(u,t,a)}),e.jsx(S,{name:n.menu_moreAba_copyContact_placeButtonCopy,funcao:()=>E(u,t)})]})]})}export{J as default};
