import { ref as b, onMounted as q, onBeforeUnmount as H, withDirectives as G, openBlock as t, createElementBlock as i, normalizeStyle as d, createElementVNode as z, withModifiers as J, withKeys as Q, createVNode as R, normalizeClass as y, renderSlot as m, Fragment as B, createBlock as g, toDisplayString as $, createCommentVNode as s, normalizeProps as D, mergeProps as U, unref as Y } from "vue";
import r from "./BaseIcon-ZChy8GeS.js";
import { _ as Z } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const p = {
  beforeMount(e, f) {
    e.clickOutsideEvent = function(a) {
      e === a.target || e.contains(a.target) || f.value(a);
    }, document.addEventListener("click", e.clickOutsideEvent);
  },
  unmounted(e) {
    document.removeEventListener("click", e.clickOutsideEvent);
  }
}, _ = ["title", "onClick", "onKeypress"], ee = ["data-open"], te = {
  __name: "UserOptions",
  props: {
    hasPdf: {
      type: Boolean,
      default: !0
    },
    hasXls: {
      type: Boolean,
      default: !0
    },
    hasImg: {
      type: Boolean,
      default: !1
    },
    hasLabel: {
      type: Boolean,
      default: !1
    },
    isLabelActive: {
      type: Boolean,
      default: !1
    },
    hasTable: {
      type: Boolean,
      default: !1
    },
    hasSort: {
      type: Boolean,
      default: !1
    },
    hasStack: {
      type: Boolean,
      default: !1
    },
    hasTooltip: {
      type: Boolean,
      default: !1
    },
    color: {
      type: String
    },
    backgroundColor: {
      type: String
    },
    isPrinting: {
      type: Boolean,
      default: !1
    },
    isImaging: {
      type: Boolean,
      default: !1
    },
    title: {
      type: String
    },
    uid: {
      type: String
    },
    hasFullscreen: {
      type: Boolean,
      default: !1
    },
    chartElement: {
      type: HTMLElement,
      default: null
    },
    isFullscreen: {
      type: Boolean,
      default: !1
    },
    isStacked: {
      type: Boolean,
      default: !1
    },
    isTooltip: {
      type: Boolean,
      default: !1
    },
    hasAnimation: {
      type: Boolean,
      default: !1
    },
    isAnimation: {
      type: Boolean,
      default: !1
    },
    titles: {
      type: Object,
      default() {
        return {};
      }
    },
    showTooltips: {
      type: Boolean,
      default: !0
    },
    zIndex: {
      type: Number,
      default: 1
    },
    noOffset: {
      type: Boolean,
      default: !0
    },
    position: {
      type: String,
      default: "right"
    }
  },
  emits: ["generatePdf", "generateCsv", "generateImage", "toggleTable", "toggleLabels", "toggleSort", "toggleFullscreen", "toggleStack", "toggleTooltip", "toggleAnimation"],
  setup(e, { emit: f }) {
    const a = e;
    function h() {
      f("generatePdf");
    }
    function C() {
      f("generateCsv");
    }
    function S() {
      f("generateImage");
    }
    const T = b(!1);
    function I() {
      T.value = !T.value, f("toggleTable");
    }
    const v = b(!1), x = b(!0);
    function L() {
      c.value = window.innerWidth > 600, v.value = !v.value, v.value && (x.value = !1);
    }
    function K() {
      a.isPrinting || a.isImaging || (v.value = !1);
    }
    function N() {
      v.value && K();
    }
    const E = b(a.isLabelActive);
    function V() {
      E.value = !E.value, f("toggleLabels");
    }
    const M = b(a.isAnimation);
    function w() {
      M.value = !M.value, f("toggleAnimation");
    }
    function j() {
      f("toggleSort");
    }
    const F = b(a.isStacked);
    function W() {
      F.value = !F.value, f("toggleStack");
    }
    const O = b(a.isTooltip);
    function X() {
      O.value = !O.value, f("toggleTooltip");
    }
    const k = b(!1);
    function A(l) {
      a.chartElement && (l === "in" ? (k.value = !0, a.chartElement.requestFullscreen(), f("toggleFullscreen", !0)) : (k.value = !1, document && document.exitFullscreen(), f("toggleFullscreen", !1)));
    }
    function P(l) {
      document.fullscreenElement ? k.value = !0 : k.value = !1;
    }
    q(() => {
      document.addEventListener("fullscreenchange", P);
    }), H(() => {
      document.removeEventListener("fullscreenchange", P);
    });
    const c = b(window.innerWidth > 600), n = b({
      tooltip: !1,
      pdf: !1,
      csv: !1,
      img: !1,
      table: !1,
      labels: !1,
      sort: !1,
      stack: !1,
      fullscreen: !1,
      animation: !1
    });
    return (l, o) => G((t(), i("div", {
      "data-html2canvas-ignore": "",
      class: "vue-ui-user-options",
      style: d(`z-index: ${e.zIndex}; height: 34px; position: ${k.value ? "fixed" : "absolute"}; top: 0; ${e.position === "right" ? `right:${k.value ? "12px" : "0"}` : `left:${k.value ? "12px" : "0"}`}; padding: 4px; background:transparent;`)
    }, [
      z("div", {
        tabindex: "0",
        title: v.value ? e.titles.close || "" : e.titles.open || "",
        style: d(`width:32px; position: absolute; top: 0;${e.position === "right" ? `right: ${e.noOffset ? 0 : 4}px` : `left: ${e.noOffset ? 0 : 4}px`}; padding: 0 0px; display: flex; align-items:center;justify-content:center;height: 36px;  cursor:pointer; background:transparent`),
        onClick: J(L, ["stop"]),
        onKeypress: Q(L, ["enter"])
      }, [
        R(r, {
          name: v.value ? "close" : "menu",
          stroke: e.color,
          "stroke-width": 2
        }, null, 8, ["name", "stroke"])
      ], 44, _),
      z("div", {
        "data-open": v.value,
        class: y({ "vue-ui-user-options-drawer": !0 }),
        style: d(`background:${e.backgroundColor}; ${e.position === "right" ? `right: ${e.noOffset ? 0 : 4}px` : `left: ${e.noOffset ? 0 : 4}px`}`)
      }, [
        e.hasTooltip ? (t(), i("button", {
          key: 0,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: X,
          onMouseenter: o[0] || (o[0] = (u) => n.value.tooltip = !0),
          onMouseout: o[1] || (o[1] = (u) => n.value.tooltip = !1)
        }, [
          l.$slots.optionTooltip ? m(l.$slots, "optionTooltip", { key: 0 }, void 0, !0) : (t(), i(B, { key: 1 }, [
            O.value ? (t(), g(r, {
              key: 0,
              name: "tooltip",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), g(r, {
              key: 1,
              name: "tooltipDisabled",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.tooltip && !l.$slots.optionTooltip ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-left-visible": e.position === "left" && n.value.tooltip, "button-info-right-visible": e.position === "right" && n.value.tooltip }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.tooltip), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasPdf ? (t(), i("button", {
          key: 1,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: h,
          onMouseenter: o[2] || (o[2] = (u) => n.value.pdf = !0),
          onMouseout: o[3] || (o[3] = (u) => n.value.pdf = !1)
        }, [
          l.$slots.optionPdf ? m(l.$slots, "optionPdf", { key: 0 }, void 0, !0) : (t(), i(B, { key: 1 }, [
            e.isPrinting ? (t(), g(r, {
              key: 0,
              name: "spin",
              isSpin: "",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), g(r, {
              key: 1,
              name: "pdf",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.pdf && !l.$slots.optionPdf ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.pdf, "button-info-left-visible": e.position === "left" && n.value.pdf }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.pdf), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasXls ? (t(), i("button", {
          key: 2,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: C,
          onMouseenter: o[4] || (o[4] = (u) => n.value.csv = !0),
          onMouseout: o[5] || (o[5] = (u) => n.value.csv = !1)
        }, [
          l.$slots.optionCsv ? m(l.$slots, "optionCsv", { key: 0 }, void 0, !0) : (t(), g(r, {
            key: 1,
            name: "excel",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["stroke"])),
          c.value && e.titles.csv && !l.$slots.optionCsv ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.csv, "button-info-left-visible": e.position === "left" && n.value.csv }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.csv), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasImg ? (t(), i("button", {
          key: 3,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: S,
          onMouseenter: o[6] || (o[6] = (u) => n.value.img = !0),
          onMouseout: o[7] || (o[7] = (u) => n.value.img = !1)
        }, [
          l.$slots.optionImg ? m(l.$slots, "optionImg", { key: 0 }, void 0, !0) : (t(), i(B, { key: 1 }, [
            e.isImaging ? (t(), g(r, {
              key: 0,
              name: "spin",
              isSpin: "",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), g(r, {
              key: 1,
              name: "image",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.img && !l.$slots.optionImg ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.img, "button-info-left-visible": e.position === "left" && n.value.img }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.img), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasTable ? (t(), i("button", {
          key: 4,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: I,
          onMouseenter: o[8] || (o[8] = (u) => n.value.table = !0),
          onMouseout: o[9] || (o[9] = (u) => n.value.table = !1)
        }, [
          l.$slots.optionTable ? m(l.$slots, "optionTable", { key: 0 }, void 0, !0) : (t(), g(r, {
            key: 1,
            name: T.value ? "tableClose" : "tableOpen",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["name", "stroke"])),
          c.value && e.titles.table && !l.$slots.optionTable ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.table, "button-info-left-visible": e.position === "left" && n.value.table }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.table), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasLabel ? (t(), i("button", {
          key: 5,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: V,
          onMouseenter: o[10] || (o[10] = (u) => n.value.labels = !0),
          onMouseout: o[11] || (o[11] = (u) => n.value.labels = !1)
        }, [
          l.$slots.optionLabels ? m(l.$slots, "optionLabels", { key: 0 }, void 0, !0) : (t(), g(r, {
            key: 1,
            name: E.value ? "labelClose" : "labelOpen",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["name", "stroke"])),
          c.value && e.titles.labels && !l.$slots.optionLabels ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.labels, "button-info-left-visible": e.position === "left" && n.value.labels }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.labels), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasSort ? (t(), i("button", {
          key: 6,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: j,
          onMouseenter: o[12] || (o[12] = (u) => n.value.sort = !0),
          onMouseout: o[13] || (o[13] = (u) => n.value.sort = !1)
        }, [
          l.$slots.optionSort ? m(l.$slots, "optionSort", { key: 0 }, void 0, !0) : (t(), g(r, {
            key: 1,
            name: "sort",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["stroke"])),
          c.value && e.titles.sort && !l.$slots.optionSort ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.sort, "button-info-left-visible": e.position === "left" && n.value.sort }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.sort), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasStack ? (t(), i("button", {
          key: 7,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: W,
          onMouseenter: o[14] || (o[14] = (u) => n.value.stack = !0),
          onMouseout: o[15] || (o[15] = (u) => n.value.stack = !1)
        }, [
          l.$slots.optionStack ? m(l.$slots, "optionStack", { key: 0 }, void 0, !0) : (t(), i(B, { key: 1 }, [
            F.value ? (t(), g(r, {
              key: 0,
              name: "unstack",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), g(r, {
              key: 1,
              name: "stack",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.stack && !l.$slots.optionStack ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.stack, "button-info-left-visible": e.position === "left" && n.value.stack }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.stack), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasFullscreen ? (t(), i("button", {
          key: 8,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onMouseenter: o[16] || (o[16] = (u) => n.value.fullscreen = !0),
          onMouseout: o[17] || (o[17] = (u) => n.value.fullscreen = !1),
          onClick: o[18] || (o[18] = (u) => A(k.value ? "out" : "in"))
        }, [
          l.$slots.optionFullscreen ? m(l.$slots, "optionFullscreen", D(U({ key: 0 }, { toggleFullscreen: A, isFullscreen: k.value })), void 0, !0) : (t(), i(B, { key: 1 }, [
            k.value ? (t(), g(r, {
              key: 0,
              name: "exitFullscreen",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : s("", !0),
            k.value ? s("", !0) : (t(), g(r, {
              key: 1,
              name: "fullscreen",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.fullscreen && !l.$slots.optionFullscreen ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.fullscreen, "button-info-left-visible": e.position === "left" && n.value.fullscreen }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.fullscreen), 7)) : s("", !0)
        ], 32)) : s("", !0),
        e.hasAnimation ? (t(), i("button", {
          key: 9,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onMouseenter: o[19] || (o[19] = (u) => n.value.animation = !0),
          onMouseout: o[20] || (o[20] = (u) => n.value.animation = !1),
          onClick: w
        }, [
          l.$slots.optionAnimation ? m(l.$slots, "optionAnimation", D(U({ key: 0 }, { toggleAnimation: w, isAnimated: M.value })), void 0, !0) : (t(), i(B, { key: 1 }, [
            M.value ? (t(), g(r, {
              key: 0,
              name: "play",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : s("", !0),
            M.value ? s("", !0) : (t(), g(r, {
              key: 1,
              name: "pause",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          c.value && e.titles.fullscreen && !l.$slots.optionAnimation ? (t(), i("div", {
            key: 2,
            dir: "auto",
            class: y({ "button-info-left": e.position === "left", "button-info-right": e.position === "right", "button-info-right-visible": e.position === "right" && n.value.animation, "button-info-left-visible": e.position === "left" && n.value.animation }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.animation), 7)) : s("", !0)
        ], 32)) : s("", !0)
      ], 12, ee)
    ], 4)), [
      [Y(p), N]
    ]);
  }
}, ie = /* @__PURE__ */ Z(te, [["__scopeId", "data-v-202b6e85"]]);
function se({
  elementId: e,
  fileName: f,
  canPrint: a = !0
}) {
  const h = b(!1), C = b(!1), S = b(null);
  async function T() {
    !a || h.value || (h.value = !0, clearTimeout(S.value), S.value = setTimeout(async () => {
      if (a)
        try {
          const { default: v } = await import("./pdf-B7oVat64.js");
          await v({
            domElement: document.getElementById(e),
            fileName: f
          });
        } catch (v) {
          console.error("Error generating PDF:", v);
        } finally {
          h.value = !1;
        }
    }, 100));
  }
  async function I() {
    !a || C.value || (C.value = !0, clearTimeout(S.value), S.value = setTimeout(async () => {
      if (a)
        try {
          const { default: v } = await import("./img-DGzWcJ4Y.js");
          await v({
            domElement: document.getElementById(e),
            fileName: f,
            format: "png"
          });
        } catch (v) {
          console.error("Error generating image:", v);
        } finally {
          C.value = !1;
        }
    }, 100));
  }
  return {
    generatePdf: T,
    generateImage: I,
    isPrinting: h,
    isImaging: C
  };
}
export {
  ie as U,
  se as u
};
