import { computed as A, unref as a, ref as y, watch as g } from "vue";
const T = ["confirmed", "unconfirmed"];
function w(n) {
  return T.includes(n);
}
function B(n) {
  const e = n == null ? void 0 : n.status;
  return w(e) ? `status-${e}` : null;
}
function C(n) {
  return (n == null ? void 0 : n.status) === "confirmed";
}
function E(n) {
  return (n == null ? void 0 : n.status) === "unconfirmed";
}
function O(n) {
  return E(n);
}
function d(n, e) {
  return e || C(n);
}
function U(n, e) {
  return d(n, e) ? e ? "selected-indicator" : "confirmed-indicator" : null;
}
function l(n, e) {
  return !e || !(n != null && n.id) ? !1 : n.id === e;
}
function S(n, e) {
  return !(n != null && n.id) || !(e != null && e.length) ? !1 : e.includes(n.id);
}
function v(n, e) {
  return l(n, e.confirmingAttributeId) || d(n, e.isSelected);
}
function F(n, e) {
  return S(n, e.blockedAttributeIds) ? !l(n, e.confirmingAttributeId) && !d(n, e.isSelected) : !1;
}
function z(n, e) {
  return l(n, e.confirmingAttributeId) ? "confirming" : S(n, e.blockedAttributeIds) ? "blocked" : v(n, e) ? e.isSelected ? "selected" : C(n) ? "confirmed" : null : null;
}
function L(n, e, c) {
  const s = z(n, c);
  return !s || !e ? "" : e[s] ?? "";
}
function _({
  contactAttributes: n,
  panelChannelTypes: e,
  frozenAttribute: c
}) {
  const s = A(() => a(n) ?? []), f = A(() => a(e) ?? []), m = (o) => Object.fromEntries(o.map((i) => [i, []])), p = y(
    m(f.value)
  ), t = () => {
    const o = f.value, i = m(o), u = new Set(o);
    s.value.forEach((r) => {
      if (!(!r || !r.type)) {
        if (r.type === "telegram") {
          u.has("telegram") && i.telegram.push(r);
          return;
        }
        if (r.type === "max") {
          u.has("max") && i.max.push(r);
          return;
        }
        if (r.type === "phone") {
          ["whatsapp", "sms", "phone"].forEach((h) => {
            u.has(h) && i[h].push(r);
          });
          return;
        }
        u.has(r.type) && i[r.type] && i[r.type].push(r);
      }
    }), p.value = i;
  };
  return g(s, t, { deep: !0, immediate: !0 }), g(f, t), {
    organizedContactAttributes: p,
    organizeContactAttributes: t,
    isAttributeFrozen: (o) => {
      const i = c.value;
      return !o || !(i != null && i.id) ? !1 : o.id === i.id;
    }
  };
}
export {
  T as CONTACT_ATTRIBUTE_STATUSES,
  U as getAttributeCheckIndicatorClass,
  z as getAttributeIndicatorTooltipKey,
  L as getAttributeIndicatorTooltipText,
  B as getAttributeStatusClass,
  S as isAttributeBlocked,
  C as isAttributeConfirmed,
  l as isAttributeConfirming,
  E as isAttributeUnconfirmed,
  w as isContactAttributeStatus,
  O as needsAttributeConfirmation,
  d as shouldShowAttributeCheckmark,
  v as shouldShowAttributeIndicator,
  F as shouldShowBlockedIndicatorSlot,
  _ as useCommunicationAttributes
};
