import { needsAttributeConfirmation as o } from "./useCommunicationAttributes.js";
function H({
  activeChannelType: l,
  channels: t,
  selectedChannel: s,
  selectedChannelType: v,
  hoveredAttribute: S,
  confirmingAttributeId: c,
  isAttributeBlocked: u,
  closeMenu: a,
  hasMultipleChannels: q,
  getSingleChannelForType: x,
  getAvailableChannels: P,
  isChannelEmpty: d,
  isNewDialog: h,
  showDefaultChannelTooltipWithTimer: C,
  clearDefaultChannelTooltip: p,
  emit: f
}) {
  const i = (n, e, r) => {
    u(n) || (c.value = n.id, f("confirm-attribute", {
      attributeId: n.id,
      channelId: e,
      channelType: r,
      attribute: n
    }));
  }, b = (n, e, r) => {
    if (o(n)) {
      i(n, e, r);
      return;
    }
    A(n, e);
  }, m = (n) => {
    if (!(!n || u(n))) {
      if (o(n)) {
        i(n, "", "phone");
        return;
      }
      f("phone-call", {
        attributeId: n.id,
        phoneNumber: n.data
      }), a();
    }
  }, A = (n, e) => {
    f("select-attribute-channel", {
      attributeId: n.id,
      channelId: e
    }), v.value = l.value, s.value = t.value.find((r) => r.channelId === e) ?? {}, d(e) && h.value ? C() : p(), a();
  };
  return {
    handlePhoneCall: m,
    handleAttributeClick: (n) => {
      if (c.value || u(n))
        return;
      const e = l.value;
      if (e) {
        if (e === "phone") {
          m(n);
          return;
        }
        if (!q(e)) {
          const r = x(e);
          r && b(n, r.channelId, e);
        }
      }
    },
    selectSingleChannel: A,
    selectChannel: (n) => {
      const e = S.value, r = l.value;
      if (!e || !r || u(e)) {
        a();
        return;
      }
      if (o(e)) {
        i(e, n, r);
        return;
      }
      f("select-attribute-channel", {
        attributeId: e.id,
        channelId: n
      }), v.value = r, s.value = t.value.find((g) => g.channelId === n) ?? {}, d(n) && h.value ? C() : p(), a();
    },
    availableChannels: () => {
      const n = l.value;
      return n ? P(n) : [];
    }
  };
}
export {
  H as useCommunicationActions
};
