import { j as e } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a53.js";
import {
  Q as le,
  R as ue,
  T as de,
  U as pe,
  V as fe,
  W as me,
  X as V,
  Y as G,
  Z as q,
  A as ge,
  _ as xe,
  $ as W,
  a0 as B,
  a1 as _e,
  a2 as he,
  a3 as ve,
  a4 as Ee,
  a5 as be,
  a6 as ye,
  a7 as Ce,
  a8 as je,
  a9 as we,
  aa as Se,
  ab as Ae,
  G as ke,
  q as ae,
  r as Le,
  x as Pe,
  y as ze,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a525.js";
import {
  u as y,
  r as Ne,
  P as f,
  o as $,
  p as Me,
  f as Re,
  e as T,
  V as U,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a54.js";
import {
  f as Fe,
  u as te,
  g as De,
  h as Te,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a522.js";
import { u as Ie } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5120.js";
import {
  z as D,
  V as N,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a55.js";
import {
  c as se,
  a as c,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a52.js";
import {
  u as S,
  a as z,
  E as x,
  C as w,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5121.js";
import {
  a1 as H,
  a2 as Y,
  a3 as J,
  a4 as K,
  a5 as Q,
  I as d,
  _ as E,
  a6 as $e,
  f as Ue,
  a7 as Oe,
  u as Ve,
  a8 as Ge,
  a9 as qe,
  aa as We,
  ab as Be,
  ac as He,
  ad as Ye,
  ae as Je,
  af as Ke,
  ag as Qe,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a58.js";
import { a as Xe } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a546.js";
import { j as Ze } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a571.js";
import { B as ea } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5122.js";
import { I as aa } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5123.js";
import { u as R } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a556.js";
import { x as ta } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a57.js";
import { w as sa } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5124.js";
import { S as na } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a545.js";
import { V as oa } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5125.js";
import { d as ra } from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a544.js";
import {
  A as ia,
  p as ca,
  q as la,
} from "./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a557.js";
const ne = se((a, o) => ({
  steps: [
    { key: "contatos", label: y.getState().language.step_contatos, icon: H },
    { key: "acoes", label: y.getState().language.step_acoes, icon: Y },
    { key: "revisao", label: y.getState().language.step_revisao, icon: J },
    { key: "envio", label: y.getState().language.step_envio, icon: K },
    {
      key: "resultados",
      label: y.getState().language.step_resultados,
      icon: Q,
    },
  ],
  currentStep: "contatos",
  setCurrentStep: (n) => a({ currentStep: n }),
  updateStepsLabels: (n) =>
    a({
      steps: [
        { key: "contatos", label: n.step_contatos, icon: H },
        { key: "acoes", label: n.step_acoes, icon: Y },
        { key: "revisao", label: n.step_revisao, icon: J },
        { key: "envio", label: n.step_envio, icon: K },
        { key: "resultados", label: n.step_resultados, icon: Q },
      ],
    }),
}));
y.subscribe((a, o) => {
  a.language !== o.language && ne.getState().updateStepsLabels(a.language);
});
function ua(a) {
  return a != null && a.trim().length > 0;
}
function A(a, o) {
  S.setState((n) => {
    const i = new Map(n.executions),
      s = i.get(a);
    return (s && i.set(a, { ...s, ...o }), { executions: i });
  });
}
function I(a) {
  return S.getState().executions.get(a);
}
function da(a) {
  const { campaigns: o } = z.getState();
  return o.find((n) => n.id === a);
}
const X = (a) => new Promise((o) => setTimeout(o, a)),
  pa = async () => {
    try {
      const a = await D.Conn("getMyUserId");
      if (!a) throw new Error("ID do usuário não encontrado");
      const o = await D.Contact("get", a);
      if (!o) throw new Error("Não foi possível obter o contato do usuário");
      const n = await D.Contact("getProfilePictureUrl", a);
      return {
        id: o.id.toString(),
        name: o.name || o.pushname || "Eu",
        avatarUrl: n || "",
        phone: o.id.user,
      };
    } catch (a) {
      throw (
        console.error("Erro ao obter contato do usuário:", a),
        new Error(
          `Falha ao carregar informações do usuário: ${a instanceof Error ? a.message : "Erro desconhecido"}`,
        )
      );
    }
  };
async function fa({
  userID: a,
  acao: o,
  assiantura: n,
  remetente: i,
  campaignId: s,
  resumeFromActionIndex: m = 0,
}) {
  const { addMonitor: _, deleteMonitor: r, updateMonitor: v } = le.getState(),
    l = [],
    g = Ne();
  _({
    id: g,
    userID: a,
    sendAction: "Actived",
    remetente: i,
    actionsTam: o.length,
    actionIndice: m,
    activeAction: o[m],
  });
  try {
    for (const [h, t] of o.entries()) {
      if (h < m) continue;
      const k = S.getState();
      if (s) {
        if (!k.executions.get(s))
          return (r(g), { status: "execution_not_found" });
        if (k.shouldCancelExecution(s)) return (r(g), { status: "cancelled" });
        if (k.shouldPauseExecution(s))
          return (
            A(s, {
              currentActionIndex: h,
              status: x.PAUSED,
              pausedAt: new Date(),
              shouldPause: !1,
              isAutoPause: !1,
              autoPauseEndsAt: void 0,
            }),
            r(g),
            { status: "paused", actionIndex: h }
          );
      }
      if (!v(g, h, t)) {
        l.push(!1);
        break;
      }
      s && A(s, { currentActionIndex: h });
      try {
        switch (t.type) {
          case "txt":
            l.push(await Ae(f(a), t.propriedades, n));
            break;
          case "image":
            l.push(await Se(f(a), t.propriedades, n));
            break;
          case "video":
            l.push(await we(f(a), t.propriedades, n));
            break;
          case "audio":
            l.push(await je(f(a), t.propriedades));
            break;
          case "doc":
            l.push(await Ce(f(a), t.propriedades));
            break;
          case "pix":
            l.push(await ye(f(a), t.propriedades));
            break;
          case "groupInvite":
            l.push(await be(f(a), t.propriedades));
            break;
          case "contact":
            l.push(await Ee(f(a), t.propriedades));
            break;
          case "linkPreview":
            l.push(await ve(f(a), t.propriedades));
            break;
          case "sticker":
            l.push(await he(f(a), t.propriedades));
            break;
          case "addCRM":
            await _e($(a), t.propriedades.crmID, t.propriedades.abaID);
            break;
          case "removeCRM":
            await B($(a), !1, t.propriedades.crmID, t.propriedades.abaID);
            break;
          case "removeAllCRM":
            await B($(a), !0);
            break;
          case "addLabel":
            await W(f(a), t.propriedades.labelID, "add");
            break;
          case "removeLabel":
            await W(f(a), t.propriedades.labelID, "remove");
            break;
          case "removeAllLabel":
            await xe(f(a));
            break;
          case "timer":
            await ge(t.propriedades.segundos);
            break;
          case "composing":
            await q(f(a), t.propriedades.segundos, "txt");
            break;
          case "recording":
            await q(f(a), t.propriedades.segundos, "audio");
            break;
          case "arquivar":
            await G(f(a));
            break;
          case "desarquivar":
            await G(f(a), !0);
            break;
          case "fixarChat":
            await V(f(a), "pin");
            break;
          case "desfixarChat":
            await V(f(a), "unpin");
            break;
          case "marcarNaoLido":
            await me(f(a));
            break;
          case "transferir":
            await fe(f(a), t.propriedades);
            break;
          case "bloquear":
            await pe(f(a));
            break;
          case "respostaRapida":
            await de(f(a), t.propriedades.respostaRapidaID, n);
            break;
          case "list":
            await ue(f(a), t.propriedades);
            break;
          default:
            console.warn(`No handler found for action type: ${t.type}`);
            break;
        }
      } catch (L) {
        const P = L instanceof Error ? L.message : "Erro desconhecido na ação";
        return (
          console.error(`Erro na ação ${t.type} (índice ${h}) para ${a}:`, L),
          r(g),
          { status: "error", message: `Erro na ação "${t.type}": ${P}` }
        );
      }
    }
    return (
      r(g),
      l.length === 0 || l.every((h) => h && h.id)
        ? { status: "success" }
        : { status: "error", message: "Erro ao executar uma ou mais ações." }
    );
  } catch (b) {
    const h = b instanceof Error ? b.message : "Erro desconhecido";
    return (
      console.error(`Erro geral ao executar ações para ${a}:`, b),
      r(g),
      { status: "error", message: `Erro geral: ${h}` }
    );
  }
}
async function O({
  campaign: a,
  type: o,
  resumeFromIndex: n = 0,
  isResume: i = !1,
}) {
  const s = y.getState().language,
    { actions: m, config: _, id: r } = a,
    { interval: v, pause: l, signature: g } = _,
    { seconds: b } = v,
    { every: h, durationSeconds: t } = l,
    { disabled: k, useCustomName: L, customName: P } = g,
    { updateCampaign: C } = z.getState(),
    u = S.getState(),
    p = I(r);
  if (p && p.status === x.RUNNING && !i) {
    d({ type: "Info", message: s.send_campanha_ja_em_execucao });
    return;
  }
  if (i && p && p.status === x.RUNNING) return;
  const F = o === "test" ? [await pa()] : a.selectedContacts,
    oe = p?.currentActionIndex || 0;
  (i
    ? A(r, {
        status: x.RUNNING,
        shouldPause: !1,
        shouldCancel: !1,
        isAutoPause: !1,
        autoPauseEndsAt: void 0,
      })
    : u.startExecution(r, F.length, m.length, o),
    C(r, { status: w.SENDING }),
    ne.getState().setCurrentStep("envio"),
    d({
      type: "Info",
      message: i ? s.send_retomando_envio : s.send_iniciando_envio,
    }));
  try {
    for (let j = n; j < F.length; j++) {
      const M = F[j];
      if (u.shouldCancelExecution(r)) {
        (A(r, {
          status: x.CANCELLED,
          completedAt: new Date(),
          shouldCancel: !1,
        }),
          C(r, { status: w.DRAFT }),
          d({ type: "Info", message: s.send_campanha_cancelada }));
        return;
      }
      const re = {
          desativar: k,
          personalizar: L && ua(P),
          nome: P?.trim() || "",
        },
        ie = j === n ? oe : 0;
      switch (
        (
          await fa({
            userID: M.id,
            acao: m,
            assiantura: re,
            remetente: "useAcaoEnvioEmMassaNew",
            campaignId: r,
            resumeFromActionIndex: ie,
          })
        ).status
      ) {
        case "cancelled":
          (A(r, {
            status: x.CANCELLED,
            completedAt: new Date(),
            shouldCancel: !1,
          }),
            C(r, { status: w.DRAFT }),
            d({ type: "Info", message: s.send_campanha_cancelada }));
          return;
        case "paused":
          (C(r, { status: w.PAUSED }),
            d({ type: "Info", message: s.campanha_pausada }));
          return;
        case "execution_not_found":
          (C(r, { status: w.DRAFT }),
            d({
              type: "Error",
              message: s.send_erro_desconhecido || "Execução não encontrada",
            }));
          return;
        case "error":
          u.updateProgress(r, j + 1, !1, M);
          break;
        case "success":
          u.updateProgress(r, j + 1, !0, M);
          break;
      }
      if (j < F.length - 1) {
        if ((await X(b * 1e3), u.shouldCancelExecution(r))) {
          (A(r, {
            status: x.CANCELLED,
            completedAt: new Date(),
            shouldCancel: !1,
          }),
            C(r, { status: w.DRAFT }),
            d({ type: "Info", message: s.send_campanha_cancelada }));
          return;
        }
        if ((j + 1) % h === 0) {
          const ce = new Date(Date.now() + t * 1e3);
          if (
            (A(r, {
              status: x.PAUSED,
              isAutoPause: !0,
              autoPauseEndsAt: ce,
              pausedAt: new Date(),
            }),
            d({
              type: "Info",
              message: `${s.send_pausa_apos_envios} ${t}s ${s.send_apos} ${h} ${s.send_envios}`,
            }),
            await X(t * 1e3),
            u.shouldCancelExecution(r))
          ) {
            (A(r, {
              status: x.CANCELLED,
              completedAt: new Date(),
              shouldCancel: !1,
            }),
              C(r, { status: w.DRAFT }),
              d({ type: "Info", message: s.send_campanha_cancelada }));
            return;
          }
          if (u.shouldPauseExecution(r)) {
            A(r, { isAutoPause: !1, autoPauseEndsAt: void 0 });
            return;
          }
          A(r, { status: x.RUNNING, isAutoPause: !1, autoPauseEndsAt: void 0 });
        }
      }
    }
    (u.completeExecution(r),
      C(r, { status: w.SENT }),
      d({
        type: "Success",
        message: `${s.send_campanha_concluida} ${F.length} ${s.send_contatos_processados}`,
      }));
  } catch (j) {
    const M = j instanceof Error ? j : new Error(s.send_erro_desconhecido);
    (u.failExecution(r, M.message),
      C(r, { status: w.FAILED }),
      d({ type: "Error", message: `${s.send_erro_ao_enviar} ${M.message}` }));
  }
}
async function ma(a) {
  const o = y.getState().language,
    n = da(a),
    i = I(a);
  if (!n) {
    d({ type: "Error", message: o.resume_campanha_nao_encontrada });
    return;
  }
  if (!i) {
    d({ type: "Error", message: o.resume_estado_execucao_nao_encontrado });
    return;
  }
  if (i.status !== x.PAUSED) {
    d({ type: "Info", message: o.resume_campanha_nao_pausada });
    return;
  }
  await O({
    campaign: n,
    type: "full",
    resumeFromIndex: i.currentContactIndex,
    isResume: !0,
  });
}
function ga(a) {
  const o = y.getState().language,
    n = I(a);
  if (!n) {
    d({ type: "Error", message: o.pause_campanha_nao_encontrada });
    return;
  }
  if (n.status !== x.RUNNING) {
    d({ type: "Info", message: o.pause_campanha_nao_em_execucao });
    return;
  }
  if (n.shouldPause) {
    d({ type: "Info", message: o.pause_pausa_ja_solicitada });
    return;
  }
  (S.getState().requestPause(a),
    d({ type: "Info", message: o.pause_pausando_apos_acao_atual }));
}
function Z(a, o = !1) {
  const n = y.getState().language,
    i = I(a);
  if (o) {
    (S.getState().forceCancel(a),
      d({ type: "Info", message: n.sua_campanha_foi_cancelada }));
    return;
  }
  if (!i) {
    d({ type: "Error", message: n.cancel_campanha_nao_encontrada });
    return;
  }
  if (i.status === x.COMPLETED || i.status === x.CANCELLED) {
    d({ type: "Info", message: n.cancel_campanha_ja_finalizada });
    return;
  }
  if (i.shouldCancel) {
    d({ type: "Info", message: n.cancel_cancelamento_ja_solicitado });
    return;
  }
  (S.getState().requestCancel(a),
    d({ type: "Info", message: n.cancel_cancelando_apos_acao_atual }));
}
const xa = se()(
  Me(
    (a) => ({
      reports: [],
      addReport: (o) => a((n) => ({ reports: [...n.reports, o] })),
      removeReport: (o) =>
        a((n) => ({ reports: n.reports.filter((i) => i.campaignId !== o) })),
    }),
    {
      name: "useReportCampaign-store",
      storage: Re(() => ke("ReportCampaignDB", "useReportCampaignStore")),
    },
  ),
);
function ee(a) {
  const o = {
    campaignId: a.campaignId,
    startedAt: a.startedAt,
    totalActions: a.totalActions,
    totalContacts: a.totalContacts,
    successContacts: a.successContacts,
    failedContacts: a.failedContacts,
    completedAt: a.completedAt,
    totalExecutions: a.totalContacts * a.totalActions,
  };
  xa.getState().addReport(o);
}
function _a(a) {
  const [o, n] = c.useState(!1),
    i = y((u) => u.language),
    s = z((u) => u.campaigns.find((p) => p.id === a)),
    { updateCampaign: m } = z.getState(),
    _ = S((u) => u.executions.get(a)),
    r = N((u) => u.session),
    v = N((u) => u.user),
    l =
      !r.is_premium ||
      (v.user_premium?.teste === "1" &&
        v.user_premium?.allow_env_massa !== "true"),
    g =
      !_ ||
      _.status === x.COMPLETED ||
      _.status === x.CANCELLED ||
      _.status === x.FAILED,
    { clearExecution: b } = S.getState();
  return {
    campaign: s,
    execution: _,
    isLoading: o,
    actions: {
      sendTest: async () => {
        if (s) {
          n(!0);
          try {
            if (!g)
              throw (
                d({ type: "Error", message: i.erro_iniciar_campanha }),
                new Error(
                  "Cannot start campaign: Campaign is already running or paused.",
                )
              );
            b(s.id);
            const u = z.getState().campaigns.find((p) => p.id === s.id);
            (await O({ campaign: u, type: "test" }),
              ee(S.getState().executions.get(u.id)));
          } finally {
            n(!1);
          }
        }
      },
      sendFull: async () => {
        if (s) {
          n(!0);
          try {
            if (!g)
              throw (
                d({ type: "Error", message: i.erro_iniciar_campanha }),
                new Error(
                  "Cannot start campaign: Campaign is already running or paused.",
                )
              );
            if (l && s.selectedContacts.length > 5) {
              const p = s.selectedContacts.slice(0, 5);
              m(s.id, { selectedContacts: p });
            }
            b(s.id);
            const u = z.getState().campaigns.find((p) => p.id === s.id);
            (await O({ campaign: u, type: "full" }),
              ee(S.getState().executions.get(u.id)));
          } finally {
            n(!1);
          }
        }
      },
      pause: () => {
        ga(a);
      },
      resume: async () => {
        n(!0);
        try {
          await ma(a);
        } finally {
          n(!1);
        }
      },
      cancel: () => {
        Z(a);
      },
      forceCancel: () => {
        (Z(a, !0), m(a, { status: w.DRAFT }));
      },
    },
    canStart: g,
    isRunning: _?.status === x.RUNNING,
    isPaused: _?.status === x.PAUSED,
    isCompleted: _?.status === x.COMPLETED,
    isCancelled: _?.status === x.CANCELLED,
  };
}
const ha = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5106.js",
        )
      ),
    [],
  ),
);
function va() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(ha, {}),
  });
}
const Ea = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5107.js",
        )
      ).then((a) => a.i),
    [],
  ),
);
function ba() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Ea, {}),
  });
}
const ya = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5108.js",
        )
      ),
    [],
  ),
);
function Ca() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(ya, {}),
  });
}
const ja = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5109.js",
        )
      ),
    [],
  ),
);
function wa() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(ja, {}),
  });
}
const Sa = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5110.js",
        )
      ),
    [],
  ),
);
function Aa() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Sa, {}),
  });
}
const ka = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5111.js",
        )
      ),
    [],
  ),
);
function La() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(ka, {}),
  });
}
const Pa = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5112.js",
        )
      ).then((a) => a.i),
    [],
  ),
);
function za() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Pa, {}),
  });
}
const Na = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5113.js",
        )
      ),
    [],
  ),
);
function Ma() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Na, {}),
  });
}
const Ra = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5114.js",
        )
      ),
    [],
  ),
);
function Fa() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Ra, {}),
  });
}
const Da = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5115.js",
        )
      ),
    [],
  ),
);
function Ta() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Da, {}),
  });
}
function Ia(a) {
  return $e({
    attr: {
      version: "1.1",
      x: "0px",
      y: "0px",
      viewBox: "0 0 48 48",
      enableBackground: "new 0 0 48 48",
    },
    child: [
      {
        tag: "path",
        attr: {
          fill: "#FFC107",
          d: `M43.611,20.083H42V20H24v8h11.303c-1.649,4.657-6.08,8-11.303,8c-6.627,0-12-5.373-12-12\r
	c0-6.627,5.373-12,12-12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C12.955,4,4,12.955,4,24\r
	c0,11.045,8.955,20,20,20c11.045,0,20-8.955,20-20C44,22.659,43.862,21.35,43.611,20.083z`,
        },
        child: [],
      },
      {
        tag: "path",
        attr: {
          fill: "#FF3D00",
          d: `M6.306,14.691l6.571,4.819C14.655,15.108,18.961,12,24,12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657\r
	C34.046,6.053,29.268,4,24,4C16.318,4,9.656,8.337,6.306,14.691z`,
        },
        child: [],
      },
      {
        tag: "path",
        attr: {
          fill: "#4CAF50",
          d: `M24,44c5.166,0,9.86-1.977,13.409-5.192l-6.19-5.238C29.211,35.091,26.715,36,24,36\r
	c-5.202,0-9.619-3.317-11.283-7.946l-6.522,5.025C9.505,39.556,16.227,44,24,44z`,
        },
        child: [],
      },
      {
        tag: "path",
        attr: {
          fill: "#1976D2",
          d: `M43.611,20.083H42V20H24v8h11.303c-0.792,2.237-2.231,4.166-4.087,5.571\r
	c0.001-0.001,0.002-0.001,0.003-0.002l6.19,5.238C36.971,39.205,44,34,44,24C44,22.659,43.862,21.35,43.611,20.083z`,
        },
        child: [],
      },
    ],
  })(a);
}
function $a() {
  return e.jsx("svg", {
    xmlns: "http://www.w3.org/2000/svg",
    fill: "currentColor",
    width: "20",
    height: "20",
    viewBox: "0 0 24 24",
    style: { display: "inline-block" },
    children: e.jsx("path", {
      fill: "currentColor",
      d: "M2.001 9.352c0 1.873.849 2.943 1.683 3.943.031 1 .085 1.668-.333 3.183 1.748-.558 2.038-.778 3.008-1.374 1 .244 1.474.381 2.611.491-.094.708-.081 1.275.055 2.023-.752-.06-1.528-.178-2.33-.374-1.397.857-4.481 1.725-6.649 2.115.811-1.595 1.708-3.785 1.661-5.312-1.09-1.305-1.705-2.984-1.705-4.695-.001-4.826 4.718-8.352 9.999-8.352 5.237 0 9.977 3.484 9.998 8.318-.644-.175-1.322-.277-2.021-.314-.229-3.34-3.713-6.004-7.977-6.004-4.411 0-8 2.85-8 6.352zm20.883 10.169c-.029 1.001.558 2.435 1.088 3.479-1.419-.258-3.438-.824-4.352-1.385-.772.188-1.514.274-2.213.274-3.865 0-6.498-2.643-6.498-5.442 0-3.174 3.11-5.467 6.546-5.467 3.457 0 6.546 2.309 6.546 5.467 0 1.12-.403 2.221-1.117 3.074zm-7.563-3.021c0-.453-.368-.82-.82-.82s-.82.367-.82.82.368.82.82.82.82-.367.82-.82zm3 0c0-.453-.368-.82-.82-.82s-.82.367-.82.82.368.82.82.82.82-.367.82-.82zm3 0c0-.453-.368-.82-.82-.82s-.82.367-.82.82.368.82.82.82.82-.367.82-.82z",
    }),
  });
}
function Ua() {
  const { language: a } = y(),
    { statusEnvio: o, chats: n } = Ie(),
    s = z((p) => p.campaigns).find((p) => p.status === w.SENDING),
    { isRunning: m, execution: _, isPaused: r } = _a(s?.id),
    { open: v } = ae.getState(),
    { open: l } = Le.getState(),
    { open: g } = Fe.getState(),
    b = N((p) => p.session),
    { setMenuContent: h } = Pe.getState(),
    { iawascript: t, referral: k } = T(
      R((p) => ({
        iawascript: p.getUrl("principais", "iawascript"),
        referral: p.getUrl("principais", "referral"),
      })),
    ),
    L = m || r || o.estado === "Atived" || o.estado === "Paused",
    P = (_?.totalContacts ?? 0) - (_?.currentContactIndex ?? 0),
    C = e.jsxs(e.Fragment, {
      children: [
        L &&
          e.jsx("div", {
            className: "relative",
            children: e.jsx("div", {
              className: "absolute -top-[10px] left-[20px]",
              children: e.jsx("span", {
                className:
                  "abaTam border border-[#ffffff52] border-solid rounded-full p-1 shadow-lg text-[12px] bg-[var(--primaria)]",
                children: e.jsx("em", {
                  className: "text-[#ffffffd4] font-bold",
                  children: n?.length || P,
                }),
              }),
            }),
          }),
        e.jsx("span", {
          id: "icoCampaign",
          children: e.jsx(Xe, {
            size: 20,
            className: Ue(
              (o.estado === "Atived" || m) && "text-[var(--wds-teal-500)]",
              (o.estado === "Paused" || r) && "text-[goldenrod]",
              m && "text-[var(--wds-teal-500)]",
            ),
          }),
        }),
      ],
    });
  return [
    {
      id: "crm",
      name: "CRM",
      icon: e.jsx(Oe, { size: 22 }),
      function: () => chrome.runtime.sendMessage({ message: "CRM" }),
    },
    {
      id: "quick_replies",
      name: a.quickReply,
      icon: e.jsx(Ve, { size: 20 }),
      function: () => h("children", "respostasRapidas"),
    },
    {
      id: "env_massa",
      name: a.envioMassa,
      icon: C,
      function: () => g(e.jsx(ba, {})),
    },
    {
      id: "ia",
      name: "Agente IA",
      icon: e.jsx(aa, { color: "var(--ico-color)" }),
      disabled: !t.active,
      function: () =>
        window.open(
          `${t.link}${b.is_premium ? "/?clientePremium" : ""}`,
          "_blank",
        ),
    },
    {
      id: "calendar",
      name: a.centralDeAgendamentos,
      icon: e.jsx(ta, { size: 20 }),
      function: () => g(e.jsx(va, {})),
    },
    {
      id: "flow",
      name: a.fluxo,
      icon: e.jsx(Ge, { size: 20 }),
      function: () => chrome.runtime.sendMessage({ message: "FLOW" }),
    },
    {
      id: "funnil_crm",
      name: a.funilCRM,
      icon: e.jsx(qe, { size: 20 }),
      function: () => chrome.runtime.sendMessage({ message: "funnil" }),
    },
    {
      id: "att_atendimento",
      name: a.autoAtendimento,
      icon: e.jsx(We, { size: 22 }),
      function: () => v(e.jsx(Ca, {})),
    },
    {
      id: "follow_up",
      name: a.followUp,
      icon: e.jsx(Be, { size: 22 }),
      function: () => v(e.jsx(wa, {})),
    },
    {
      id: "status",
      name: a.status,
      icon: e.jsx(He, { size: 22 }),
      function: () => v(e.jsx(za, {})),
    },
    {
      id: "api",
      name: "API",
      icon: e.jsx(Ye, { size: 22 }),
      function: () => v(e.jsx(Fa, {}), !1),
    },
    {
      id: "webhook",
      name: "WebHook",
      icon: e.jsx(Je, { size: 20 }),
      function: () => v(e.jsx(Ma, {})),
    },
    {
      id: "links",
      name: a.links,
      icon: e.jsx(Ze, { size: 20 }),
      function: () => v(e.jsx(La, {})),
    },
    {
      id: "start_chat",
      name: a.start_chat,
      icon: e.jsx($a, {}),
      function: () => v(e.jsx(Aa, {})),
    },
    {
      id: "afiliate_link",
      name: a.indiqueEGanhe,
      icon: e.jsx(ea, { size: 20 }),
      disabled: !k.active,
      function: () => window.open(k.link, "_blank"),
    },
    {
      id: "google_funcs",
      name: a.att_google,
      icon: e.jsx(Ia, { size: 20 }),
      function: (p) => l(e.jsx(Ta, {}), { placement: "right" }, p.target),
    },
  ];
}
function Oa() {
  const { activeMenu: a } = ze(),
    { config: o } = T(R((s) => ({ config: s.config }))),
    { openWithGetEvents: n } = te(
      R((s) => ({ openWithGetEvents: s.openWithGetEvents })),
    );
  return e.jsxs("div", {
    className: "flex flex-col items-center gap-2",
    children: [
      e.jsx("div", {
        className: "lg:tooltip  lg:tooltip-right mb-2",
        "data-tip": o.name,
        children: e.jsx("div", {
          className: "pulse cursor-pointer rounded-full w-9 h-9 shadow-lg",
          children: e.jsx("span", {
            children: e.jsx("img", {
              src: chrome.runtime.getURL("label/icons/plugin/icon.png"),
              className: "w-10 rounded-full select-none",
              draggable: !1,
            }),
          }),
        }),
      }),
      e.jsx("div", {
        className:
          "flex flex-col items-center gap-2 w-full overflow-y-auto overflow-x-hidden scroll_bar",
        style: { height: "calc(100vh - 350px)" },
        children: Ua().map(
          (s) =>
            !s.disabled &&
            a[s.id] !== !1 &&
            e.jsx(
              "div",
              {
                onClick: (m) => {
                  (s.function(m), sa(s.id));
                },
                ...n(s.name, { placement: "right" }),
                children: e.jsx("div", {
                  className:
                    "menu-item pulse cursor-pointer rounded-[10px] bg-[var(--ico-border-color)] p-2 text-[var(--ico-color)]",
                  children: s.icon,
                }),
              },
              s.id,
            ),
        ),
      }),
    ],
  });
}
const Va = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5116.js",
        )
      ),
    [],
  ),
);
function Ga() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Va, {}),
  });
}
const qa = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5117.js",
        )
      ).then((a) => a.i),
    [],
  ),
);
function Wa() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(qa, {}),
  });
}
const Ba = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5118.js",
        )
      ),
    [],
  ),
);
function Ha() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Ba, {}),
  });
}
const Ya = (a) => {
  /*const { user: o, session: n } = N.getState(),
    { config: i } = T.getState();
  let s = n.is_auth
    ? `${U.painel_cliente}/${i.chromeStoreID}/auth-painel?token=${o.bearer_token}`
    : `${U.painel_cliente}/${i.chromeStoreID}/login`;
  (a && (s += `&page=${encodeURIComponent(a)}`), window.open(s, "_blank"));*/
  //NOTA ET redirecciona a la nueva web deseada
  window.open("https://www.relaccion.com/relaccion-lite-plus/panel", "_blank");
};
function Ja({
  size: a = "w-5 h-5",
  className: o = "",
  textSize: n = "text-sm",
}) {
  const i = N((r) => r.auth_google),
    s = N((r) => r.user),
    [m, _] = c.useState(null);
  return (
    c.useEffect(() => {
      let r = !0;
      async function v() {
        try {
          const l = await D.Conn("getMyUserId");
          if (!l) return;
          const g = await D.Contact("getProfilePictureUrl", l);
          r && _(g || null);
        } catch (l) {
          console.error(l);
        }
      }
      return (
        v(),
        () => {
          r = !1;
        }
      );
    }, []),
    e.jsxs(ia, {
      className: `${a} rounded-full bg-[var(--primaria)] flex items-center justify-center overflow-hidden ${o}`,
      children: [
        e.jsx(ca, {
          src: i?.picture || m || void 0,
          alt: "picture_user",
          className: "object-cover w-full h-full",
          crossOrigin: "anonymous",
          referrerPolicy: "no-referrer",
        }),
        e.jsx(la, {
          className: `w-full h-full bg-[var(--primaria)] text-black flex items-center justify-center font-bold ${n}`,
          children: s?.name?.charAt(0)?.toUpperCase(),
        }),
      ],
    })
  );
}
const Ka = c.lazy(() =>
  __vitePreload(
    () =>
      import(
        chrome.runtime.getURL(
          "content/assets/js/v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5119.js",
        )
      ),
    [],
  ),
);
function Qa() {
  return e.jsx(c.Suspense, {
    fallback: e.jsx(e.Fragment, {}),
    children: e.jsx(Ka, {}),
  });
}
function Xa() {
  const a = y((t) => t.language),
    o = ae((t) => t.openModal),
    n = De((t) => t.open),
    i = Te((t) => t.notifyNotVisualized),
    { config: s, youtube: m } = T(
      R((t) => ({
        config: t.config,
        youtube: t.getUrl("redes_sociais", "youtube"),
      })),
    ),
    {
      session: _,
      user: r,
      logout: v,
    } = N(R((t) => ({ session: t.session, user: t.user, logout: t.logout }))),
    { openWithGetEvents: l } = te(
      R((t) => ({ openWithGetEvents: t.openWithGetEvents })),
    ),
    g = e.jsxs("div", {
      children: [
        i > 0 &&
          e.jsx("div", {
            className: "relative",
            children: e.jsx("div", {
              className: "absolute -top-3 -right-4",
              children: e.jsx("span", {
                className:
                  "abaTam border border-[#ffffff52] border-solid rounded-full p-1 shadow-lg text-[12px] bg-[var(--primaria)] ",
                children: e.jsx("em", {
                  className: "text-[#ffffffd4] font-bold",
                  children: i,
                }),
              }),
            }),
          }),
        e.jsx(na, { size: 20 }),
      ],
    }),
    b = [
      {
        id: 1,
        name: `${a.meuPerfil}, ${s.primeiroNome}`,
        icon: e.jsx(Ja, { size: "w-8 h-8 " }),
        function: () => o({ type: "not_structure", modal: e.jsx(Qa, {}) }),
      },
      {
        id: 2,
        name: a.configAgendamento_title,
        icon: e.jsx(ra, { size: 20 }),
        function: () => n(e.jsx(Wa, {})),
      },
      {
        id: 3,
        name: a.notifications,
        icon: g,
        function: () => n(e.jsx(Ga, {})),
      },
      {
        id: 4,
        name: a.func_menu,
        icon: e.jsx(oa, { size: 20 }),
        function: () => n(e.jsx(Ha, {})),
      },
      {
        id: 5,
        name: "Panel Clientes",
        icon: e.jsx(Ke, { size: 20 }),
        function: () => Ya(),
      },
    ];
  return e.jsxs("div", {
    className: "flex flex-col items-center gap-2 mb-4",
    children: [
      m.active &&
        e.jsx("div", {
          onClick: () => window.open(m.link, "_blank"),
          className: "lg:tooltip lg:tooltip-right cursor-pointer",
          "data-tip": a.tutoriais,
          children: e.jsx("span", {
            className: "pulse",
            children: e.jsx(Qe, { className: "text-[red]", size: 26 }),
          }),
        }),
      b.reverse().map((t) =>
        e.jsx(e.Fragment, {
          children:
            t.id !== 1
              ? e.jsx(
                  "div",
                  {
                    onClick: t.function,
                    ...l(t.name, { placement: "right" }),
                    children: e.jsx("div", {
                      className:
                        "menu-item pulse cursor-pointer rounded-[10px]  bg-[var(--ico-border-color)] p-2 text-[var(--ico-color)]",
                      children: t.icon,
                    }),
                  },
                  t.id,
                )
              : e.jsx(
                  "div",
                  {
                    className: "cursor-pointer rounded-[10px]",
                    onClick: t.function,
                    ...l(t.name, { placement: "right" }),
                    children: t.icon,
                  },
                  t.id,
                ),
        }),
      ),
      e.jsx("div", {
        className:
          "badge badge-sm badge-ghost text-xs text-base-content/60 font-semibold font-rounded",
        children: U.version,
      }),
    ],
  });
}
function Za() {
  return e.jsx("section", {
    "data-id": "Menu",
    children: e.jsx("div", {
      className: "w-[60px] h-[100vh] absolute z-[401] bg-[var(--menu-color)]",
      children: e.jsxs("div", {
        className:
          "animate__animated animate__fadeInLeft h-full my-2 flex flex-col justify-between gap-2",
        children: [e.jsx(Oa, {}), e.jsx(Xa, {})],
      }),
    }),
  });
}
const bt = Object.freeze(
  Object.defineProperty({ __proto__: null, default: Za }, Symbol.toStringTag, {
    value: "Module",
  }),
);
export {
  Ca as A,
  ba as E,
  wa as F,
  Ua as R,
  za as S,
  Ja as U,
  _a as a,
  xa as b,
  pa as g,
  bt as i,
  Ya as o,
  ne as u,
};
