import { DtIconChevronUp as r } from "@dialpad/dialtone-icons/vue2";
import a, { warnIfUnmounted as l } from "../../common/utils/index.js";
import { DialtoneLocalization as i } from "../../localization/index.js";
import { n as s } from "../../_plugin-vue2_normalizer-DSLOjnn3.js";
import { CALLBAR_BUTTON_VALID_WIDTH_SIZE as d } from "../callbar-button/callbar-button-constants.js";
import p from "../button/button.js";
import c from "../dropdown/dropdown.js";
import u from "../callbar-button/callbar-button.js";
const f = {
  name: "DtRecipeCallbarButtonWithDropdown",
  components: { DtRecipeCallbarButton: u, DtDropdown: c, DtButton: p, DtIconChevronUp: r },
  /* inheritAttrs: false is generally an option we want to set on library
   components. This allows any attributes passed in that are not recognized
   as props to be passed down to another element or component using v-bind:$attrs
   more info: https://vuejs.org/v2/api/#inheritAttrs */
  inheritAttrs: !1,
  props: {
    /**
     * Id for the item.
     */
    id: {
      type: String,
      default() {
        return a.getUniqueString();
      }
    },
    /**
     * Aria label for the button. If empty, it takes its value from the default slot.
     */
    ariaLabel: {
      type: String,
      default: null,
      validator: (e) => e || (void 0).$slots.default
    },
    /**
     * The direction the dropdown displays relative to the anchor.
     * @values 'bottom', 'bottom-start', 'bottom-end',
     *         'right', 'right-start', 'right-end',
     *         'left', 'left-start', 'left-end',
     *         'top', 'top-start', 'top-end'
     * @default 'top'
     */
    placement: {
      type: String,
      default: "top"
    },
    /**
     * If the dropdown does not fit in the direction described by "placement",
     * it will attempt to change it's direction to the "fallbackPlacements".
     *
     * @values top, top-start, top-end,
     * right, right-start, right-end,
     * left, left-start, left-end,
     * bottom, bottom-start, bottom-end,
     * auto, auto-start, auto-end
     * */
    fallbackPlacements: {
      type: Array,
      default: () => ["auto"]
    },
    /**
     * Determines whether the button should be disabled
     * default is false.
     * @values true, false
     */
    disabled: {
      type: Boolean,
      default: !1
    },
    /**
     * Forces showing the arrow, even if the button is disabled.
     * default is false
     * @values true, false
     */
    forceShowArrow: {
      type: Boolean,
      default: !1
    },
    /**
     * Determines whether the button should have active styling
     * default is false.
     * @values true, false
     * @see https://dialtone.dialpad.com/components/button/
     */
    active: {
      type: Boolean,
      default: !1
    },
    /**
     * Determines whether the button should have danger styling
     * default is false.
     * @values true, false
     * @see https://dialtone.dialpad.com/components/button/
     */
    danger: {
      type: Boolean,
      default: !1
    },
    /**
     * Additional class name for the button wrapper element.
     */
    buttonClass: {
      type: [String, Array, Object],
      default: ""
    },
    /**
     * Additional class name for the button text.
     */
    textClass: {
      type: [String, Array, Object],
      default: ""
    },
    /*
     * Width size. Valid values are: 'xl', 'lg', 'md' and 'sm'.
     */
    buttonWidthSize: {
      type: String,
      default: "xl",
      validator: (e) => d.includes(e)
    },
    /**
     * Whether the tooltip has an inverted background color.
     * @values true, false
     */
    invertedTooltip: {
      type: Boolean,
      default: !1
    },
    /**
     * Use this if you would like to manually override the logic for when the tooltip shows.
     * Otherwise it will just show on hover/focus.
     * @values null, true, false
     */
    showTooltip: {
      type: Boolean,
      default: null
    },
    /**
     * The message that displays in the tooltip. This will be overridden by the tooltip slot.
     */
    tooltipText: {
      type: String,
      default: void 0
    },
    /**
     * Whether there is a delay before the tooltip shows on hover/focus.
     * @values true, false
     */
    tooltipDelay: {
      type: Boolean,
      default: void 0
    }
  },
  emits: [
    /**
     * Emitted when the arrow is clicked
     */
    "arrow-click",
    /**
     * Native click event
     *
     * @event click
     * @type {PointerEvent | KeyboardEvent}
     */
    "click",
    /**
     * Emitted when modal dropdown is opened or closed.
     */
    "opened"
  ],
  data() {
    return {
      open: !1,
      i18n: new i()
    };
  },
  computed: {
    showArrowButton() {
      return this.forceShowArrow || !this.disabled;
    },
    isCompactMode() {
      return this.buttonWidthSize === "sm" || this.buttonWidthSize === "md";
    },
    arrowButtonLabel() {
      return this.i18n.$t("DIALTONE_CALLBAR_BUTTON_WITH_DROPDOWN_ARROW_BUTTON_ARIA_LABEL");
    }
  },
  mounted() {
    l(this.$el, this.$options.name);
  },
  methods: {
    arrowClick(e) {
      return this.$emit("arrow-click", e), this.toggleOpen();
    },
    toggleOpen() {
      return this.open = !this.open;
    },
    syncOpenState() {
      this.open = this.openDropdown;
    },
    buttonClick(e) {
      this.$listeners.click ? this.$emit("click", e) : this.arrowClick(e);
    },
    onModalIsOpened(e) {
      this.open = e, this.$emit("opened", e);
    }
  }
};
var b = function() {
  var t = this, o = t._self._c;
  return o("div", { staticClass: "dt-recipe--callbar-button-with-dropdown" }, [o("dt-recipe-callbar-button", { staticClass: "dt-recipe--callbar-button-with-dropdown--main-button", attrs: { active: t.active, "aria-label": t.ariaLabel, "button-class": t.buttonClass, "button-width-size": t.buttonWidthSize, danger: t.danger, disabled: t.disabled, "inverted-tooltip": t.invertedTooltip, "show-tooltip": t.showTooltip, "text-class": t.textClass, "tooltip-delay": t.tooltipDelay, "tooltip-text": t.tooltipText }, on: { click: t.buttonClick }, scopedSlots: t._u([{ key: "icon", fn: function() {
    return [t._t("icon")];
  }, proxy: !0 }, { key: "tooltip", fn: function() {
    return [t._t("tooltip")];
  }, proxy: !0 }], null, !0) }, [t._t("default")], 2), t.showArrowButton ? o("dt-dropdown", t._b({ staticClass: "dt-recipe--callbar-button-with-dropdown--dropdown-wrapper", attrs: { id: t.id, modal: !1, "fallback-placements": t.fallbackPlacements, open: t.open, placement: t.placement, padding: "none" }, on: { opened: t.onModalIsOpened }, scopedSlots: t._u([{ key: "anchor", fn: function() {
    return [o("dt-button", { class: [
      "dt-recipe--callbar-button-with-dropdown--arrow",
      { "dt-recipe--callbar-button-with-dropdown--arrow--large": !t.isCompactMode }
    ], attrs: { active: t.open, circle: !0, importance: "clear", size: "lg", "aria-label": t.arrowButtonLabel, title: t.arrowButtonLabel, width: "2rem" }, on: { click: t.arrowClick }, scopedSlots: t._u([{ key: "icon", fn: function() {
      return [o("dt-icon-chevron-up", { staticClass: "dt-recipe--callbar-button-with-dropdown--arrow__icon", attrs: { size: "200" } })];
    }, proxy: !0 }], null, !1, 887776886) })];
  }, proxy: !0 }, { key: "list", fn: function({ close: n }) {
    return [t._t("list", null, { close: n })];
  } }], null, !0) }, "dt-dropdown", t.$attrs, !1)) : t._e()], 1);
}, w = [], m = /* @__PURE__ */ s(
  f,
  b,
  w
);
const A = m.exports;
export {
  A as default
};
//# sourceMappingURL=callbar-button-with-dropdown.js.map
