import p from "clipboard-copy";
import { resolveComponent as n, resolveDirective as l, withDirectives as s, createBlock as r, openBlock as a, mergeProps as d } from "vue";
import { _ as u } from "./install-BuMO14Rb.js";
let e = null;
const m = {
  name: "WtCopyAction",
  /**
   * @emits {Event} click - Fires when copy button is clicked
   */
  props: {
    /**
     * Value to be copied
     * @type {string}
     * @required
     */
    value: {
      type: String
    },
    /**
     * Value for tooltips before/after copying. Should have "copy" and "copied" properties
     * @type {Object}
     * @default {}
     */
    tooltips: {
      type: Object,
      default: () => ({})
    }
  },
  data: () => ({
    copied: !1
  }),
  computed: {
    copyTooltip() {
      return this.tooltips.copy || this.$t("webitelUI.copyAction.copy");
    },
    copiedTooltip() {
      return this.tooltips.copied || this.$t("webitelUI.copyAction.copied");
    }
  },
  methods: {
    async copy() {
      await p(this.value), this.copied = this.value, e && window.clearTimeout(e), e = setTimeout(() => {
        this.copied = null;
      }, 1500);
    }
  }
};
function y(o, _, f, h, w, t) {
  const i = n("wt-icon-btn"), c = l("tooltip");
  return s((a(), r(i, d(o.$attrs, {
    icon: o.copied ? "done" : "copy",
    class: "copy-action"
  }, { onClick: t.copy }), null, 16, ["icon", "onClick"])), [
    [c, o.copied ? t.copiedTooltip : t.copyTooltip]
  ]);
}
const C = /* @__PURE__ */ u(m, [["render", y]]);
export {
  C as default
};
