import{u as p}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";import{ai as s,m as i,P as r}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892625.js";function D(t){const e=p.getState().whatsappID,a=s(t),n=i.getState().atendimentos.find(o=>s(o.chatID)===a&&!!o.whatsappID&&o.whatsappID!==e);if(n?.whatsappID)return n.whatsappID;const{activeTrasferencia:I,trasferencias:c}=r.getState();return[I,...c].filter(o=>o!=null).find(o=>s(o.chatID)===a&&!!o.atendimentoWhatsappID&&o.atendimentoWhatsappID!==e)?.atendimentoWhatsappID}function f(t,e){const a=s(t),n=p.getState().whatsappID,I=e?.atendimentoWhatsappID??D(a)??n;i.getState().send_atendimento(a,"Finalizado",I),r.getState().finalizarAtendimento(a)}function l(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().send_atendimento(e,"Ativo",n),i.getState().socket?.emit("inbox:accept",{whatsappID:n,chatID:e,fromUserId:t.remetenteID}),r.getState().removerTransferenciaInbox(t.chatID)}function g(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().socket?.emit("inbox:dismiss",{whatsappID:n,chatID:e,...t.inboxDocId?{inboxId:t.inboxDocId}:{}}),r.getState().removerTransferenciaInbox(t.chatID)}function w(t){const e=s(t.chatID),a=p.getState().whatsappID,n=t.atendimentoWhatsappID??a;i.getState().socket?.emit("inbox:remove-done",{...t.inboxDocId?{inboxId:t.inboxDocId}:{},whatsappID:n,chatID:e}),typeof t.finalizadoEm=="number"&&r.getState().removerTransferenciaDoHistorico(t.finalizadoEm)}export{l as a,g as d,f as e,w as r};
