import { ref as c, computed as f, onMounted as Ue, onBeforeUnmount as We, watch as He, openBlock as s, createElementBlock as r, normalizeClass as O, normalizeStyle as $, unref as y, renderSlot as x, createBlock as z, createCommentVNode as v, createSlots as Ee, withCtx as m, normalizeProps as Y, guardReactiveProps as j, createVNode as ke, Fragment as b, renderList as k, createElementVNode as T, toDisplayString as L, createTextVNode as Ge, nextTick as Ve } from "vue";
import { u as Re, c as we, o as qe, e as Ce, g as Ze, b as Je, d as Ke, p as E, D as _e, i as I, f as F, X as Qe, l as et, h as tt, G as lt, t as at, a as st, C as G, x as ot, q as rt, r as nt, F as N } from "./index-MWHrTFPq.js";
import { u as $e } from "./useNestedProp-CTDeT4KA.js";
import { u as ut, U as it } from "./usePrinter-CEEgHfhF.js";
import { _ as ct } from "./PackageVersion-CBKqLhAX.js";
import { L as vt } from "./Legend-CUhyETYn.js";
import { _ as ht } from "./Title-C7EOYmwp.js";
import { _ as yt } from "./Tooltip-Bip4kr-u.js";
import { D as dt } from "./DataTable-DtvVWOjy.js";
import ft from "./vue-ui-accordion-BnV2tlGp.js";
import { P as xt } from "./PenAndPaper-DtLD2Sq6.js";
import pt from "./vue-ui-skeleton-Bo8ydREb.js";
import { t as mt, u as gt } from "./useResponsive-CoxXLe23.js";
import { u as bt } from "./useUserOptionState-BIvW1Kz7.js";
import { _ as kt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const wt = ["id"], Ct = ["xmlns", "viewBox"], _t = ["x", "y", "width", "height"], $t = { key: 1 }, Mt = ["id"], At = ["stop-color"], Tt = ["stop-color"], Lt = ["stop-color"], St = { key: 2 }, zt = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Nt = { key: 3 }, Pt = ["x", "y", "fill", "font-size"], Ot = ["transform", "font-size", "fill", "font-weight"], It = { key: 5 }, Ft = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Xt = { key: 6 }, Dt = ["transform", "fill", "font-size", "text-anchor"], Yt = ["x", "y", "font-size", "fill", "font-weight"], jt = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Bt = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Ut = ["d", "stroke", "stroke-width"], Wt = ["d", "stroke", "stroke-width"], Ht = ["cx", "cy", "fill", "r"], Et = ["cx", "cy", "fill", "r", "stroke", "stroke-width"], Gt = { key: 1 }, Vt = ["x", "y", "font-size", "fill", "font-weight"], Rt = { key: 2 }, qt = ["x", "y", "font-size", "font-weight", "fill"], Zt = ["cx", "cy", "r", "onMouseenter", "onClick"], Jt = {
  key: 5,
  class: "vue-data-ui-watermark"
}, Kt = ["onClick"], Qt = ["innerHTML"], el = {
  __name: "vue-ui-history-plot",
  props: {
    config: {
      type: Object,
      default() {
        return {};
      }
    },
    dataset: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  emits: ["selectLegend", "selectDatapoint"],
  setup(Me, { expose: Ae, emit: K }) {
    const h = Me, { vue_ui_history_plot: Te } = Re(), P = c(null), Q = c(null), ee = c(0), te = c(null), le = c(0), ae = c(0), se = c(0), B = c(null), oe = c(null), X = c(we()), V = c(!1), R = c(""), g = c([]), U = c(!1), _ = c(null), D = c(!1), re = c(null), w = f({
      get: () => !!h.dataset && h.dataset.length,
      set: (t) => t
    });
    Ue(ne), We(() => {
      B.value && B.value.disconnect();
    });
    function ne() {
      if (qe(h.dataset) ? Ce({
        componentName: "VueUiHistoryPlot",
        type: "dataset"
      }) : h.dataset.forEach((t, a) => {
        Ze({
          datasetObject: t,
          requiredAttributes: ["name", "values"]
        }).forEach((l) => {
          w.value = !1, Ce({
            componentName: "VueUiHistoryPlot",
            type: "datasetSerieAttribute",
            property: l,
            index: a
          });
        });
      }), e.value.responsive) {
        const t = mt(() => {
          const { width: a, height: l } = gt({
            chart: P.value,
            title: e.value.style.chart.title.text ? Q.value : null,
            noTitle: oe.value,
            legend: e.value.style.chart.legend.show ? te.value : null,
            source: re.value
          });
          d.value.width = a, d.value.height = l, u.value.plots = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.plots.radius,
            threshold: 3,
            fallback: 3
          }), u.value.indexLabels = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.plots.indexLabels.fontSize,
            threshold: 6,
            fallback: 6
          }), u.value.labels = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.plots.labels.fontSize,
            threshold: 6,
            fallback: 6
          }), u.value.xAxisLabels = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.axes.x.labels.fontSize,
            threshold: 6,
            fallback: 6
          }), u.value.xAxisName = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.axes.x.name.fontSize,
            threshold: 6,
            fallback: 6
          }), u.value.yAxisLabels = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.axes.y.labels.fontSize,
            threshold: 6,
            fallback: 6
          }), u.value.yAxisName = N({
            relator: Math.min(a, l),
            adjuster: 600,
            source: e.value.style.chart.axes.y.name.fontSize,
            threshold: 6,
            fallback: 6
          });
        });
        B.value = new ResizeObserver(t), B.value.observe(P.value.parentNode);
      }
    }
    function ue() {
      const t = $e({
        userConfig: h.config,
        defaultConfig: Te
      });
      let a = {};
      return t.theme ? a = {
        ...$e({
          userConfig: at.vue_ui_history_plot[t.theme] || h.config,
          defaultConfig: t
        }),
        customPalette: st[t.theme] || E
      } : a = t, h.config && G(h.config, "style.chart.axes.x.scaleMin") ? a.style.chart.axes.x.scaleMin = h.config.style.chart.axes.x.scaleMin : a.style.chart.axes.x.scaleMin = null, h.config && G(h.config, "style.chart.axes.x.scaleMax") ? a.style.chart.axes.x.scaleMax = h.config.style.chart.axes.x.scaleMax : a.style.chart.axes.x.scaleMax = null, h.config && G(h.config, "style.chart.axes.y.scaleMin") ? a.style.chart.axes.y.scaleMin = h.config.style.chart.axes.y.scaleMin : a.style.chart.axes.y.scaleMin = null, h.config && G(h.config, "style.chart.axes.y.scaleMax") ? a.style.chart.axes.y.scaleMax = h.config.style.chart.axes.y.scaleMax : a.style.chart.axes.y.scaleMax = null, a;
    }
    const e = f({
      get: () => ue(),
      set: (t) => t
    }), { userOptionsVisible: q, setUserOptionsVisibility: ie, keepUserOptionState: ce } = bt({ config: e.value });
    He(() => h.config, (t) => {
      e.value = ue(), q.value = !e.value.showOnChartHover, ne(), ee.value += 1, ae.value += 1, le.value += 1, d.value.height = e.value.style.chart.height, d.value.width = e.value.style.chart.width, u.value.plots = e.value.style.chart.plots.radius, u.value.indexLabels = e.value.style.chart.plots.indexLabels.fontSize, u.value.labels = e.value.style.chart.plots.labels.fontSize, u.value.xAxisLabels = e.value.style.chart.axes.x.labels.fontSize, u.value.xAxisName = e.value.style.chart.axes.x.name.fontSize, u.value.yAxisLabels = e.value.style.chart.axes.y.labels.fontSize, u.value.yAxisName = e.value.style.chart.axes.y.name.fontSize;
    }, { deep: !0 });
    const { isPrinting: ve, isImaging: he, generatePdf: ye, generateImage: de } = ut({
      elementId: `history_plot_${X.value}`,
      fileName: e.value.style.chart.title.text || "vue-ui-history-plot"
    }), Le = f(() => e.value.userOptions.show && !e.value.style.chart.title.text), Se = f(() => Je(e.value.customPalette)), M = c({
      showTable: e.value.table.show,
      showTooltip: e.value.style.chart.tooltip.show
    }), d = c({
      height: e.value.style.chart.height,
      width: e.value.style.chart.width
    }), n = f(() => {
      const t = e.value.style.chart.padding.left, a = e.value.style.chart.padding.top;
      return {
        left: t,
        top: a,
        right: d.value.width - e.value.style.chart.padding.right,
        bottom: d.value.height - e.value.style.chart.padding.bottom,
        width: d.value.width - t - e.value.style.chart.padding.right,
        height: d.value.height - a - e.value.style.chart.padding.bottom
      };
    }), u = c({
      plots: e.value.style.chart.plots.radius,
      indexLabels: e.value.style.chart.plots.indexLabels.fontSize,
      labels: e.value.style.chart.plots.labels.fontSize,
      xAxisLabels: e.value.style.chart.axes.x.labels.fontSize,
      xAxisName: e.value.style.chart.axes.x.name.fontSize,
      yAxisLabels: e.value.style.chart.axes.y.labels.fontSize,
      yAxisName: e.value.style.chart.axes.y.name.fontSize
    }), A = f(() => w.value ? h.dataset.map((t, a) => ({
      ...t,
      color: t.color ? Ke(t.color) : Se.value[a] || E[a] || E[a % E.length],
      seriesIndex: a
    })) : []), ze = f(() => w.value ? Math.max(...A.value.filter((t) => !g.value.includes(t.seriesIndex)).flatMap((t) => t.values.map((a) => a.x))) : 1), Ne = f(() => {
      if (!w.value) return 1;
      const t = Math.min(...A.value.filter((a) => !g.value.includes(a.seriesIndex)).flatMap((a) => a.values.map((l) => l.x)));
      return t < 0 ? t : 0;
    }), Pe = f(() => w.value ? Math.max(...A.value.filter((t) => !g.value.includes(t.seriesIndex)).flatMap((t) => t.values.map((a) => a.y))) : 1), Oe = f(() => {
      if (!w.value) return 1;
      const t = Math.min(...A.value.filter((a) => !g.value.includes(a.seriesIndex)).flatMap((a) => a.values.map((l) => l.y)));
      return t < 0 ? t : 0;
    }), p = f(() => {
      const t = _e(
        e.value.style.chart.axes.x.scaleMin === null ? Ne.value : e.value.style.chart.axes.x.scaleMin,
        e.value.style.chart.axes.x.scaleMax === null ? ze.value : e.value.style.chart.axes.x.scaleMax,
        e.value.style.chart.axes.x.ticks
      ), a = _e(
        e.value.style.chart.axes.y.scaleMin === null ? Oe.value : e.value.style.chart.axes.y.scaleMin,
        e.value.style.chart.axes.y.scaleMax === null ? Pe.value : e.value.style.chart.axes.y.scaleMax,
        e.value.style.chart.axes.y.ticks
      );
      return {
        x: t,
        y: a,
        tickX: t.ticks.map((l) => ({
          x: n.value.left + (l - t.min) / (t.max - t.min) * n.value.width,
          y1: n.value.top,
          y2: n.value.bottom,
          value: l
        })),
        tickY: a.ticks.map((l) => ({
          y: n.value.bottom - (l - a.min) / (a.max - a.min) * n.value.height,
          x1: n.value.left,
          x2: n.value.right,
          value: l
        }))
      };
    });
    function Ie(t) {
      const a = p.value.x.min < 0 ? Math.abs(p.value.x.min) : p.value.x.min > 0 ? -p.value.x.min : 0;
      return n.value.left + ((t || 0) + a) / (p.value.x.max + a) * n.value.width;
    }
    function Fe(t) {
      const a = p.value.y.min < 0 ? Math.abs(p.value.y.min) : p.value.y.min > 0 ? -p.value.y.min : 0;
      return n.value.bottom - ((t || 0) + a) / (p.value.y.max + a) * n.value.height;
    }
    const S = f(() => A.value.filter((t) => !g.value.includes(t.seriesIndex)).map((t, a) => {
      const l = t.values.map((o, C) => ({
        valueX: o.x,
        valueY: o.y,
        label: o.label,
        x: Ie(o.x),
        y: Fe(o.y),
        color: t.color,
        seriesName: t.name,
        id: we()
      })), i = l.map((o) => `${o.x},${o.y} `).join("").trim();
      return {
        ...t,
        plots: l,
        path: `M${i}`
      };
    }));
    function fe(t) {
      g.value.includes(t) ? g.value = g.value.filter((a) => a !== t) : g.value.push(t);
    }
    const xe = f(() => A.value.map((t) => ({
      ...t,
      opacity: g.value.includes(t.seriesIndex) ? 0.5 : 1,
      segregate: () => fe(t.seriesIndex),
      isSegregated: g.value.includes(t.seriesIndex),
      shape: "circle"
    }))), Xe = f(() => ({
      cy: "history-plot-div-legend",
      backgroundColor: e.value.style.chart.legend.backgroundColor,
      color: e.value.style.chart.legend.color,
      fontSize: e.value.style.chart.legend.fontSize,
      paddingBottom: 12,
      fontWeight: e.value.style.chart.legend.bold ? "bold" : ""
    }));
    function De(t) {
      K("selectDatapoint", t);
    }
    function pe(t) {
      K("selectLegend", {
        ...t,
        isSegregated: !t.isSegregated,
        opacity: t.isSegregated ? 1 : 0.5
      });
    }
    function Ye(t) {
      U.value = t, se.value += 1;
    }
    const Z = c(null);
    function je({ datapoint: t, plotIndex: a, seriesIndex: l }) {
      Z.value = { datapoint: t, seriesIndex: l, plotIndex: a, config: e.value, series: A.value }, _.value = t;
      const i = e.value.style.chart.tooltip.customFormat;
      if (D.value = !1, ot(i))
        try {
          const o = i({
            seriesIndex: l,
            datapoint: t,
            plotIndex: a,
            series: A.value,
            config: e.value
          });
          typeof o == "string" && (R.value = o, D.value = !0);
        } catch {
          console.warn("Custom format cannot be applied."), D.value = !1;
        }
      if (!D.value) {
        let o = "";
        o += `<div style="display:flex;flex-direction:row;gap:6px;align-items:center;border-bottom:1px solid ${e.value.style.chart.tooltip.borderColor};margin-bottom:3px;padding-bottom:6px;"><svg viewBox="0 0 12 12" height="14" width="14"><circle cx="6" cy="6" r="6" stroke="none" fill="${t.color}"/></svg><span>${t.seriesName}</span></div>`, o += `<div>${t.label}</div>`, o += `<div>${e.value.style.chart.axes.x.name.text || "x"}: ${I(
          e.value.style.chart.axes.x.labels.formatter,
          t.valueX,
          F({
            p: e.value.style.chart.axes.x.labels.prefix,
            v: t.valueX,
            s: e.value.style.chart.axes.x.labels.suffix,
            r: e.value.style.chart.axes.x.labels.rounding
          })
        )}</div>`, o += `<div>${e.value.style.chart.axes.y.name.text || "y"}: ${I(
          e.value.style.chart.axes.y.labels.formatter,
          t.valueY,
          F({
            p: e.value.style.chart.axes.y.labels.prefix,
            v: t.valueY,
            s: e.value.style.chart.axes.y.labels.suffix,
            r: e.value.style.chart.axes.y.labels.rounding
          })
        )}</div>`, R.value = `<div>${o}</div>`;
      }
      V.value = !0;
    }
    f(() => ({ head: S.value.map((a) => ({
      name: a.name,
      color: a.color
    })) }));
    const W = f(() => {
      const t = [
        e.value.table.columnNames.series,
        e.value.table.columnNames.datapoint,
        e.value.table.columnNames.x,
        e.value.table.columnNames.y
      ], a = S.value.flatMap((i) => i.plots.map((o) => [
        {
          color: o.color,
          name: o.seriesName
        },
        o.label,
        I(
          e.value.style.chart.axes.x.labels.formatter,
          o.valueX,
          F({
            p: e.value.style.chart.axes.x.labels.prefix,
            v: o.valueX,
            s: e.value.style.chart.axes.x.labels.suffix,
            r: e.value.style.chart.axes.x.labels.rounding
          })
        ),
        I(
          e.value.style.chart.axes.y.labels.formatter,
          o.valueY,
          F({
            p: e.value.style.chart.axes.y.labels.prefix,
            v: o.valueY,
            s: e.value.style.chart.axes.y.labels.suffix,
            r: e.value.style.chart.axes.y.labels.rounding
          })
        )
      ])), l = {
        th: {
          backgroundColor: e.value.table.th.backgroundColor,
          color: e.value.table.th.color,
          outline: e.value.table.th.outline
        },
        td: {
          backgroundColor: e.value.table.td.backgroundColor,
          color: e.value.table.td.color,
          outline: e.value.table.td.outline
        },
        breakpoint: e.value.table.responsiveBreakpoint
      };
      return {
        head: t,
        body: a,
        config: l,
        colNames: t
      };
    });
    function me() {
      Ve(() => {
        const t = [
          [e.value.table.columnNames.series],
          [e.value.table.columnNames.datapoint],
          [e.value.table.columnNames.x],
          [e.value.table.columnNames.y]
        ], a = S.value.flatMap((o) => o.plots.map((C) => [
          [C.seriesName],
          [C.label],
          [C.valueX],
          [C.valueY]
        ])), l = [
          [e.value.style.chart.title.text],
          [e.value.style.chart.title.subtitle.text],
          t
        ].concat(a), i = rt(l);
        nt({
          csvContent: i,
          title: e.value.style.chart.title.text || "vue-ui-history-plot"
        });
      });
    }
    const H = c(!1);
    function J() {
      H.value = !H.value;
    }
    function ge() {
      M.value.showTable = !M.value.showTable;
    }
    function be() {
      M.value.showTooltip = !M.value.showTooltip;
    }
    function Be() {
      return S.value;
    }
    return Ae({
      getData: Be,
      generatePdf: ye,
      generateCsv: me,
      generateImage: de,
      toggleTable: ge,
      toggleTooltip: be,
      toggleAnnotator: J
    }), (t, a) => (s(), r("div", {
      id: `history_plot_${X.value}`,
      ref_key: "historyPlotChart",
      ref: P,
      class: O({ "vue-ui-history-plot": !0, "vue-data-ui-wrapper-fullscreen": U.value }),
      style: $(`background:${e.value.style.chart.backgroundColor};color:${e.value.style.chart.color};font-family:${e.value.style.fontFamily}; position: relative; ${e.value.responsive ? "height: 100%" : ""}`),
      onMouseenter: a[3] || (a[3] = () => y(ie)(!0)),
      onMouseleave: a[4] || (a[4] = () => y(ie)(!1))
    }, [
      x(t.$slots, "userConfig", {}, void 0, !0),
      e.value.userOptions.buttons.annotator ? (s(), z(xt, {
        key: 0,
        parent: P.value,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        active: H.value,
        onClose: J
      }, null, 8, ["parent", "backgroundColor", "color", "active"])) : v("", !0),
      Le.value ? (s(), r("div", {
        key: 1,
        ref_key: "noTitle",
        ref: oe,
        class: "vue-data-ui-no-title-space",
        style: "height:36px; width: 100%;background:transparent"
      }, null, 512)) : v("", !0),
      e.value.style.chart.title.text ? (s(), r("div", {
        key: 2,
        ref_key: "chartTitle",
        ref: Q,
        class: "vue-ui-xy-title",
        style: $(`font-family:${e.value.style.fontFamily}`)
      }, [
        (s(), z(ht, {
          key: `title_${ee.value}`,
          config: {
            title: {
              cy: "history-plot-div-title",
              ...e.value.style.chart.title
            },
            subtitle: {
              cy: "history-plot-div-subtitle",
              ...e.value.style.chart.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ], 4)) : v("", !0),
      e.value.userOptions.show && w.value && (y(ce) || y(q)) ? (s(), z(it, {
        ref: "details",
        key: `user_option_${se.value}`,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isPrinting: y(ve),
        isImaging: y(he),
        uid: X.value,
        hasTooltip: e.value.style.chart.tooltip.show && e.value.userOptions.buttons.tooltip,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasImg: e.value.userOptions.buttons.img,
        hasXls: e.value.userOptions.buttons.csv,
        hasTable: e.value.userOptions.buttons.table,
        hasLabel: !1,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        isFullscreen: U.value,
        chartElement: P.value,
        position: e.value.userOptions.position,
        isTooltip: M.value.showTooltip,
        titles: { ...e.value.userOptions.buttonTitles },
        hasAnnotator: e.value.userOptions.buttons.annotator,
        isAnnotation: H.value,
        onToggleFullscreen: Ye,
        onGeneratePdf: y(ye),
        onGenerateCsv: me,
        onGenerateImage: y(de),
        onToggleTable: ge,
        onToggleTooltip: be,
        onToggleAnnotator: J,
        style: $({
          visibility: y(ce) ? y(q) ? "visible" : "hidden" : "visible"
        })
      }, Ee({ _: 2 }, [
        t.$slots.optionTooltip ? {
          name: "optionTooltip",
          fn: m(() => [
            x(t.$slots, "optionTooltip", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        t.$slots.optionPdf ? {
          name: "optionPdf",
          fn: m(() => [
            x(t.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        t.$slots.optionCsv ? {
          name: "optionCsv",
          fn: m(() => [
            x(t.$slots, "optionCsv", {}, void 0, !0)
          ]),
          key: "2"
        } : void 0,
        t.$slots.optionImg ? {
          name: "optionImg",
          fn: m(() => [
            x(t.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "3"
        } : void 0,
        t.$slots.optionTable ? {
          name: "optionTable",
          fn: m(() => [
            x(t.$slots, "optionTable", {}, void 0, !0)
          ]),
          key: "4"
        } : void 0,
        t.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: m(({ toggleFullscreen: l, isFullscreen: i }) => [
            x(t.$slots, "optionFullscreen", Y(j({ toggleFullscreen: l, isFullscreen: i })), void 0, !0)
          ]),
          key: "5"
        } : void 0,
        t.$slots.optionAnnotator ? {
          name: "optionAnnotator",
          fn: m(({ toggleAnnotator: l, isAnnotator: i }) => [
            x(t.$slots, "optionAnnotator", Y(j({ toggleAnnotator: l, isAnnotator: i })), void 0, !0)
          ]),
          key: "6"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasTooltip", "hasPdf", "hasImg", "hasXls", "hasTable", "hasFullscreen", "isFullscreen", "chartElement", "position", "isTooltip", "titles", "hasAnnotator", "isAnnotation", "onGeneratePdf", "onGenerateImage", "style"])) : v("", !0),
      w.value ? (s(), r("svg", {
        key: 4,
        xmlns: y(Qe),
        viewBox: `0 0 ${d.value.width < 0 ? 0.1 : d.value.width} ${d.value.height < 0 ? 0.1 : d.value.height}`,
        style: $(`max-width:100%;overflow:visible;background:transparent;color:${e.value.style.chart.color}`)
      }, [
        ke(ct),
        t.$slots["chart-background"] ? (s(), r("foreignObject", {
          key: 0,
          x: n.value.left,
          y: n.value.top,
          width: n.value.width <= 0 ? 10 : n.value.width,
          height: n.value.height <= 0 ? 10 : n.value.height,
          style: {
            pointerEvents: "none"
          }
        }, [
          x(t.$slots, "chart-background", {}, void 0, !0)
        ], 8, _t)) : v("", !0),
        e.value.style.chart.plots.gradient.show ? (s(), r("defs", $t, [
          (s(!0), r(b, null, k(S.value, (l, i) => (s(), r("radialGradient", {
            id: `gradient_${i}_${X.value}`,
            fy: "30%"
          }, [
            T("stop", {
              offset: "10%",
              "stop-color": y(et)(l.color, e.value.style.chart.plots.gradient.intensity / 100)
            }, null, 8, At),
            T("stop", {
              offset: "90%",
              "stop-color": y(tt)(l.color, 0.1)
            }, null, 8, Tt),
            T("stop", {
              offset: "100%",
              "stop-color": l.color
            }, null, 8, Lt)
          ], 8, Mt))), 256))
        ])) : v("", !0),
        e.value.style.chart.grid.verticalLines.show ? (s(), r("g", St, [
          (s(!0), r(b, null, k(p.value.tickX, (l) => (s(), r("line", {
            x1: l.x,
            x2: l.x,
            y1: l.y1,
            y2: l.y2,
            stroke: e.value.style.chart.grid.verticalLines.stroke,
            "stroke-width": e.value.style.chart.grid.verticalLines.strokeWidth,
            "stroke-linecap": "round"
          }, null, 8, zt))), 256))
        ])) : v("", !0),
        e.value.style.chart.axes.y.labels.show ? (s(), r("g", Nt, [
          (s(!0), r(b, null, k(p.value.tickY, (l) => (s(), r("text", {
            x: n.value.left + e.value.style.chart.axes.y.labels.offsetX - 4,
            y: l.y + u.value.yAxisLabels / 3,
            fill: e.value.style.chart.axes.y.labels.color,
            "font-size": u.value.yAxisLabels,
            "text-anchor": "end"
          }, L(y(I)(
            e.value.style.chart.axes.y.labels.formatter,
            l.value,
            y(F)({
              p: e.value.style.chart.axes.y.labels.prefix,
              v: l.value,
              s: e.value.style.chart.axes.y.labels.suffix,
              r: e.value.style.chart.axes.y.labels.rounding
            })
          )), 9, Pt))), 256))
        ])) : v("", !0),
        e.value.style.chart.axes.y.name.text ? (s(), r("text", {
          key: 4,
          transform: `translate(${e.value.style.chart.axes.y.name.offsetX + u.value.yAxisName}, ${d.value.height / 2 + e.value.style.chart.axes.y.name.offsetY}), rotate(-90)`,
          "font-size": u.value.yAxisName,
          fill: e.value.style.chart.axes.y.name.color,
          "font-weight": e.value.style.chart.axes.y.name.bold ? "bold" : "normal",
          "text-anchor": "middle"
        }, L(e.value.style.chart.axes.y.name.text), 9, Ot)) : v("", !0),
        e.value.style.chart.grid.horizontalLines.show ? (s(), r("g", It, [
          (s(!0), r(b, null, k(p.value.tickY, (l) => (s(), r("line", {
            x1: l.x1,
            x2: l.x2,
            y1: l.y,
            y2: l.y,
            stroke: e.value.style.chart.grid.horizontalLines.stroke,
            "stroke-width": e.value.style.chart.grid.horizontalLines.strokeWidth,
            "stroke-linecap": "round"
          }, null, 8, Ft))), 256))
        ])) : v("", !0),
        e.value.style.chart.axes.x.labels.show ? (s(), r("g", Xt, [
          (s(!0), r(b, null, k(p.value.tickX, (l) => (s(), r("text", {
            transform: `translate(${l.x}, ${n.value.bottom + e.value.style.chart.axes.x.labels.offsetY + u.value.xAxisLabels}), rotate(${e.value.style.chart.axes.x.labels.rotation})`,
            fill: e.value.style.chart.axes.x.labels.color,
            "font-size": u.value.xAxisLabels,
            "text-anchor": e.value.style.chart.axes.x.labels.rotation > 0 ? "start" : e.value.style.chart.axes.x.labels.rotation < 0 ? "end" : "middle"
          }, L(y(I)(
            e.value.style.chart.axes.x.labels.formatter,
            l.value,
            y(F)({
              p: e.value.style.chart.axes.x.labels.prefix,
              v: l.value,
              s: e.value.style.chart.axes.x.labels.suffix,
              r: e.value.style.chart.axes.x.labels.rounding
            })
          )), 9, Dt))), 256))
        ])) : v("", !0),
        e.value.style.chart.axes.x.name.text ? (s(), r("text", {
          key: 7,
          x: d.value.width / 2 + e.value.style.chart.axes.x.name.offsetX,
          y: d.value.height + e.value.style.chart.axes.x.name.offsetY,
          "font-size": u.value.xAxisName,
          fill: e.value.style.chart.axes.x.name.color,
          "font-weight": e.value.style.chart.axes.x.name.bold ? "bold" : "normal",
          "text-anchor": "middle"
        }, L(e.value.style.chart.axes.x.name.text), 9, Yt)) : v("", !0),
        e.value.style.chart.grid.xAxis.show ? (s(), r("line", {
          key: 8,
          x1: n.value.left,
          x2: n.value.left + n.value.width,
          y1: n.value.bottom,
          y2: n.value.bottom,
          stroke: e.value.style.chart.grid.xAxis.stroke,
          "stroke-width": e.value.style.chart.grid.xAxis.strokeWidth,
          "stroke-linecap": "round"
        }, null, 8, jt)) : v("", !0),
        e.value.style.chart.grid.yAxis.show ? (s(), r("line", {
          key: 9,
          x1: n.value.left,
          x2: n.value.left,
          y1: n.value.top,
          y2: n.value.bottom,
          stroke: e.value.style.chart.grid.yAxis.stroke,
          "stroke-width": e.value.style.chart.grid.yAxis.strokeWidth,
          "stroke-linecap": "round"
        }, null, 8, Bt)) : v("", !0),
        (s(!0), r(b, null, k(S.value, (l, i) => (s(), r("g", null, [
          e.value.style.chart.paths.show ? (s(), r("g", {
            key: 0,
            style: $({
              opacity: _.value === null ? 1 : 0.3
            })
          }, [
            T("path", {
              d: l.path,
              stroke: e.value.style.chart.backgroundColor,
              "stroke-width": e.value.style.chart.paths.strokeWidth + 4,
              fill: "none",
              "stroke-linecap": "round",
              "stroke-linejoin": "round",
              class: O({ animated: e.value.useCssAnimation })
            }, null, 10, Ut),
            T("path", {
              d: l.path,
              stroke: e.value.style.chart.paths.useSerieColor ? l.color : e.value.style.chart.paths.stroke,
              "stroke-width": e.value.style.chart.paths.strokeWidth,
              fill: "none",
              "stroke-linecap": "round",
              "stroke-linejoin": "round",
              class: O({ animated: e.value.useCssAnimation })
            }, null, 10, Wt)
          ], 4)) : v("", !0),
          (s(!0), r(b, null, k(l.plots, (o) => (s(), r("circle", {
            cx: o.x,
            cy: o.y,
            fill: e.value.style.chart.backgroundColor,
            r: u.value.plots,
            stroke: "none"
          }, null, 8, Ht))), 256)),
          (s(!0), r(b, null, k(l.plots, (o) => (s(), r("circle", {
            cx: o.x,
            cy: o.y,
            fill: e.value.style.chart.plots.gradient.show ? `url(#gradient_${i}_${X.value})` : o.color,
            r: u.value.plots,
            stroke: e.value.style.chart.plots.stroke,
            "stroke-width": e.value.style.chart.plots.strokeWidth,
            class: O({ animated: e.value.useCssAnimation }),
            style: $({
              opacity: _.value === null || _.value.id === o.id ? 1 : 0.3,
              transition: "opacity 0.2s ease-in-out"
            })
          }, null, 14, Et))), 256)),
          e.value.style.chart.plots.labels.show ? (s(), r("g", Gt, [
            (s(!0), r(b, null, k(l.plots, (o) => (s(), r("text", {
              x: o.x + e.value.style.chart.plots.labels.offsetX,
              y: o.y + e.value.style.chart.plots.labels.offsetY + u.value.plots + u.value.labels,
              "font-size": u.value.labels,
              fill: e.value.style.chart.plots.labels.color,
              "font-weight": e.value.style.chart.plots.labels.bold ? "bold" : "normal",
              "text-anchor": "middle",
              class: O({ animated: e.value.useCssAnimation }),
              style: $({
                opacity: _.value === null || _.value.id === o.id ? 1 : 0.3,
                transition: "opacity 0.2s ease-in-out"
              })
            }, L(o.label), 15, Vt))), 256))
          ])) : v("", !0),
          e.value.style.chart.plots.indexLabels.show ? (s(), r("g", Rt, [
            (s(!0), r(b, null, k(l.plots, (o, C) => (s(), r("text", {
              x: o.x + e.value.style.chart.plots.indexLabels.offsetX,
              y: o.y + e.value.style.chart.plots.indexLabels.offsetY + u.value.indexLabels / 3,
              "font-size": u.value.indexLabels,
              "font-weight": e.value.style.chart.plots.indexLabels.bold ? "bold" : "normal",
              fill: e.value.style.chart.plots.indexLabels.adaptColorToBackground ? y(lt)(l.color) : e.value.style.chart.plots.indexLabels.color,
              "text-anchor": "middle",
              class: O({ animated: e.value.useCssAnimation }),
              style: $({
                opacity: _.value === null || _.value.id === o.id ? 1 : 0.3,
                transition: "opacity 0.2s ease-in-out"
              })
            }, L(e.value.style.chart.plots.indexLabels.startAtZero ? C : C + 1), 15, qt))), 256))
          ])) : v("", !0)
        ]))), 256)),
        (s(!0), r(b, null, k(S.value, (l) => (s(), r("g", null, [
          (s(!0), r(b, null, k(l.plots, (i, o) => (s(), r("circle", {
            cx: i.x,
            cy: i.y,
            fill: "transparent",
            r: u.value.plots,
            stroke: "none",
            onMouseenter: (C) => je({
              datapoint: i,
              plotIndex: o,
              seriesIndex: l.seriesIndex
            }),
            onMouseleave: a[0] || (a[0] = (C) => {
              V.value = !1, _.value = null;
            }),
            onClick: () => De(i)
          }, null, 40, Zt))), 256))
        ]))), 256)),
        x(t.$slots, "svg", { svg: d.value }, void 0, !0)
      ], 12, Ct)) : v("", !0),
      t.$slots.watermark ? (s(), r("div", Jt, [
        x(t.$slots, "watermark", Y(j({ isPrinting: y(ve) || y(he) })), void 0, !0)
      ])) : v("", !0),
      w.value ? v("", !0) : (s(), z(pt, {
        key: 6,
        config: {
          type: "historyPlot",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            historyPlot: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"])),
      T("div", {
        ref_key: "chartLegend",
        ref: te
      }, [
        e.value.style.chart.legend.show && w.value ? (s(), z(vt, {
          key: `legend_${le.value}`,
          legendSet: xe.value,
          config: Xe.value,
          onClickMarker: a[1] || (a[1] = ({ legend: l }) => {
            fe(l.seriesIndex), pe(l);
          })
        }, {
          item: m(({ legend: l, index: i }) => [
            T("div", {
              onClick: (o) => {
                l.segregate(), pe(l);
              },
              style: $(`opacity:${g.value.includes(l.seriesIndex) ? 0.5 : 1}`)
            }, L(l.name), 13, Kt)
          ]),
          _: 1
        }, 8, ["legendSet", "config"])) : x(t.$slots, "legend", {
          key: 1,
          legend: xe.value
        }, void 0, !0)
      ], 512),
      t.$slots.source ? (s(), r("div", {
        key: 7,
        ref_key: "source",
        ref: re,
        dir: "auto"
      }, [
        x(t.$slots, "source", {}, void 0, !0)
      ], 512)) : v("", !0),
      ke(yt, {
        show: M.value.showTooltip && V.value,
        backgroundColor: e.value.style.chart.tooltip.backgroundColor,
        color: e.value.style.chart.tooltip.color,
        fontSize: e.value.style.chart.tooltip.fontSize,
        borderRadius: e.value.style.chart.tooltip.borderRadius,
        borderColor: e.value.style.chart.tooltip.borderColor,
        borderWidth: e.value.style.chart.tooltip.borderWidth,
        backgroundOpacity: e.value.style.chart.tooltip.backgroundOpacity,
        position: e.value.style.chart.tooltip.position,
        offsetY: e.value.style.chart.tooltip.offsetY,
        parent: P.value,
        content: R.value,
        isCustom: D.value,
        isFullscreen: U.value
      }, {
        "tooltip-before": m(() => [
          x(t.$slots, "tooltip-before", Y(j({ ...Z.value })), void 0, !0)
        ]),
        "tooltip-after": m(() => [
          x(t.$slots, "tooltip-after", Y(j({ ...Z.value })), void 0, !0)
        ]),
        _: 3
      }, 8, ["show", "backgroundColor", "color", "fontSize", "borderRadius", "borderColor", "borderWidth", "backgroundOpacity", "position", "offsetY", "parent", "content", "isCustom", "isFullscreen"]),
      w.value ? (s(), z(ft, {
        key: 8,
        hideDetails: "",
        config: {
          open: M.value.showTable,
          maxHeight: 1e4,
          body: {
            backgroundColor: e.value.style.chart.backgroundColor,
            color: e.value.style.chart.color
          },
          head: {
            backgroundColor: e.value.style.chart.backgroundColor,
            color: e.value.style.chart.color
          }
        }
      }, {
        content: m(() => [
          (s(), z(dt, {
            key: `table_${ae.value}`,
            colNames: W.value.colNames,
            head: W.value.head,
            body: W.value.body,
            config: W.value.config,
            title: `${e.value.style.chart.title.text}${e.value.style.chart.title.subtitle.text ? ` : ${e.value.style.chart.title.subtitle.text}` : ""}`,
            onClose: a[2] || (a[2] = (l) => M.value.showTable = !1)
          }, {
            th: m(({ th: l }) => [
              T("div", {
                innerHTML: l,
                style: { display: "flex", "align-items": "center" }
              }, null, 8, Qt)
            ]),
            td: m(({ td: l }) => [
              Ge(L(l.name || l), 1)
            ]),
            _: 1
          }, 8, ["colNames", "head", "body", "config", "title"]))
        ]),
        _: 1
      }, 8, ["config"])) : v("", !0)
    ], 46, wt));
  }
}, xl = /* @__PURE__ */ kt(el, [["__scopeId", "data-v-df582d76"]]);
export {
  xl as default
};
