import { useCssVars as K, ref as f, computed as d, watch as L, onMounted as Y, onBeforeUnmount as ee, openBlock as v, createElementBlock as h, createElementVNode as i, normalizeStyle as S, createVNode as te, renderSlot as le, createCommentVNode as C, unref as ae, Fragment as F, renderList as R, withDirectives as E, vModelText as P, toDisplayString as A, pushScopeId as ie, popScopeId as ne } from "vue";
import oe from "./BaseIcon-B2vcsAEz.js";
import { t as ue, u as re } from "./useResponsive-CoxXLe23.js";
import { c as se, R as V, Q as B, X as de } from "./index-CFiXy4nY.js";
import { _ as me } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const O = (t) => (ie("data-v-ed77abe8"), t = t(), ne(), t), ce = {
  "data-html2canvas-ignore": "",
  style: { padding: "0 24px" },
  class: "vue-data-ui-zoom"
}, ve = {
  class: "vue-data-ui-slicer-labels",
  style: { position: "relative", "z-index": "1", "pointer-events": "none" }
}, he = {
  key: 0,
  style: { width: "100%", position: "relative" }
}, pe = {
  key: 0,
  class: "minimap",
  style: { width: "100%" }
}, fe = ["xmlns", "viewBox"], xe = ["id"], ye = ["stop-color"], ge = /* @__PURE__ */ O(() => /* @__PURE__ */ i("stop", {
  offset: "100%",
  "stop-color": "transparent"
}, null, -1)), be = ["d", "stroke"], Se = ["x", "width", "height", "fill", "rx"], ke = ["d", "fill"], Ce = ["x", "width", "height", "rx", "fill"], we = ["x", "width", "height", "fill", "rx"], Ne = ["d", "fill"], $e = ["d", "stroke"], Me = ["cx", "cy", "stroke", "fill"], Le = ["cx", "cy", "stroke", "fill"], Ie = ["x1", "x2", "y2", "stroke"], ze = ["x", "height", "width", "onMouseenter"], Fe = /* @__PURE__ */ O(() => /* @__PURE__ */ i("div", { class: "slider-track" }, null, -1)), Re = ["min", "max"], Ee = ["min", "max"], Pe = {
  __name: "Slicer",
  props: {
    background: {
      type: String,
      default: "#FFFFFF"
    },
    borderColor: {
      type: String,
      default: "#FFFFFF"
    },
    fontSize: {
      type: Number,
      default: 14
    },
    labelLeft: {
      type: String,
      default: ""
    },
    labelRight: {
      type: String,
      default: ""
    },
    textColor: {
      type: String,
      default: "#1A1A1A"
    },
    inputColor: {
      type: String,
      default: "#1A1A1A"
    },
    max: {
      type: Number,
      default: 0
    },
    min: {
      type: Number,
      default: 0
    },
    selectColor: {
      type: String,
      default: "#4A4A4A"
    },
    useResetSlot: {
      type: Boolean,
      default: !1
    },
    valueStart: {
      type: [Number, String],
      default: 0
    },
    valueEnd: {
      type: [Number, String],
      default: 0
    },
    minimap: {
      type: Array,
      default: []
    },
    smoothMinimap: {
      type: Boolean,
      default: !1
    },
    minimapSelectedColor: {
      type: String,
      default: "#1f77b4"
    },
    minimapSelectionRadius: {
      type: Number,
      default: 12
    },
    minimapLineColor: {
      type: String,
      default: "#2D353C"
    },
    minimapSelectedColorOpacity: {
      type: Number,
      default: 0.2
    },
    minimapSelectedIndex: {
      type: Number,
      default: null
    },
    minimapIndicatorColor: {
      type: String,
      default: "#2D353C"
    }
  },
  emits: ["update:start", "update:end", "reset", "trapMouse"],
  setup(t, { emit: x }) {
    const e = t;
    K((l) => ({
      "724603fa": U.value,
      "0a3b8c6e": g.value,
      "31bae142": W.value,
      "2b1e64c4": t.selectColor,
      "7b29392c": T.value
    }));
    const u = f(e.min), r = f(e.max), y = d(() => !!e.minimap.length), w = f(se()), D = d(() => {
      const l = e.max - e.min, n = (u.value - e.min) / l * 100, o = (r.value - e.min) / l * 100;
      return {
        left: `${n}%`,
        width: `${o - n}%`,
        background: e.selectColor
      };
    }), U = d(() => e.inputColor), T = d(() => e.background), W = d(() => `${e.selectColor}33`), g = d(() => e.borderColor), I = d(() => {
      let l = [];
      for (let n = 0; n < e.minimap.length; n += 1)
        l.push(n);
      return l;
    });
    function z() {
      x("reset");
    }
    function X() {
      Number(u.value) > Number(r.value) - 1 && (u.value = Number(r.value) - 1), x("update:start", Number(u.value));
    }
    function j() {
      Number(r.value) < Number(u.value) + 1 && (r.value = Number(u.value) + 1), x("update:end", Number(r.value));
    }
    L(
      () => e.min,
      (l) => {
        Number(u.value) < Number(l) && (u.value = Number(l)), Number(r.value) < Number(l) && (r.value = Number(l));
      }
    ), L(
      () => e.max,
      (l) => {
        Number(u.value) > Number(l) && (u.value = Number(l)), Number(r.value) > Number(l) && (r.value = Number(l));
      }
    );
    const N = f(null), a = f({
      width: 1,
      height: 1
    }), k = f(null);
    Y(() => {
      if (y.value) {
        const l = ue(() => {
          const { width: n, height: o } = re({
            chart: N.value
          });
          a.value.width = n, a.value.height = o - 47;
        });
        k.value = new ResizeObserver(l), k.value.observe(N.value);
      }
    }), ee(() => {
      k.value && k.value.disconnect();
    });
    const s = d(() => e.minimap.length ? a.value.width / e.minimap.length : 0), m = d(() => {
      if (!e.minimap.length) return [];
      const l = Math.max(...e.minimap), n = Math.min(...e.minimap) - 10, o = l - (n > 0 ? 0 : n), c = e.minimap.map((_, H) => {
        const J = _ - n;
        return {
          x: a.value.width / e.minimap.length * H + s.value / 2,
          y: a.value.height - J / o * (a.value.height * 0.9)
        };
      }), $ = e.smoothMinimap ? V(c) : B(c), M = [...c].slice(e.valueStart, e.valueEnd), Q = e.smoothMinimap ? V(M) : B(M);
      return {
        fullSet: $,
        selectionSet: Q,
        sliced: M,
        firstPlot: c[e.valueStart],
        lastPlot: c[e.valueEnd - 1]
      };
    }), p = d(() => ({
      x: s.value * u.value + s.value / 2,
      width: a.value.width * ((r.value - u.value) / e.max) - s.value
    })), Z = d(() => ({
      left: 0,
      color: e.textColor,
      fontSize: `${e.fontSize}px`,
      top: y.value ? "28px" : "-28px",
      pointerEvents: "none"
    })), q = d(() => ({
      right: 0,
      color: e.textColor,
      fontSize: `${e.fontSize}px`,
      top: y.value ? "28px" : "-28px",
      direction: "rtl",
      pointerEvents: "none"
    })), b = f(e.minimapSelectedIndex);
    L(() => e.minimapSelectedIndex, (l) => {
      b.value = l + e.valueStart;
    }, { immediate: !0 });
    function G(l) {
      b.value = l, l >= e.valueStart && l < e.valueEnd && x("trapMouse", l - e.valueStart);
    }
    return (l, n) => (v(), h("div", ce, [
      i("div", ve, [
        t.valueStart > 0 || t.valueEnd < t.max ? (v(), h("div", he, [
          t.useResetSlot ? le(l.$slots, "reset-action", {
            key: 1,
            reset: z
          }, void 0, !0) : (v(), h("button", {
            key: 0,
            "data-cy-reset": "",
            tabindex: "0",
            role: "button",
            class: "vue-data-ui-refresh-button",
            style: S({
              top: y.value ? "36px" : "-16px",
              pointerEvents: "all !important"
            }),
            onClick: z
          }, [
            te(oe, {
              name: "refresh",
              stroke: t.textColor
            }, null, 8, ["stroke"])
          ], 4))
        ])) : C("", !0)
      ]),
      i("div", {
        class: "double-range-slider",
        ref_key: "minimapWrapper",
        ref: N,
        style: { "z-index": "0" }
      }, [
        y.value ? (v(), h("div", pe, [
          (v(), h("svg", {
            xmlns: ae(de),
            viewBox: `0 0 ${a.value.width < 0 ? 0 : a.value.width} ${a.value.height < 0 ? 0 : a.value.height}`
          }, [
            i("defs", null, [
              i("linearGradient", {
                id: w.value,
                x1: "0%",
                y1: "0%",
                x2: "0%",
                y2: "100%"
              }, [
                i("stop", {
                  offset: "0%",
                  "stop-color": `${t.minimapLineColor}50`
                }, null, 8, ye),
                ge
              ], 8, xe)
            ]),
            i("path", {
              d: `M${m.value.fullSet}`,
              stroke: `${t.minimapLineColor}`,
              fill: "none",
              "stroke-width": "1",
              "stroke-linecap": "round",
              "stroke-linejoin": "round",
              style: { opacity: "1" }
            }, null, 8, be),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: Math.max(a.value.height, 0),
              y: 0,
              fill: g.value,
              rx: t.minimapSelectionRadius,
              stroke: "none"
            }, null, 8, Se),
            i("path", {
              d: `M${s.value / 2},${Math.max(a.value.height, 0)} ${m.value.fullSet} L${a.value.width - s.value / 2},${Math.max(a.value.height, 0)}Z`,
              fill: `url(#${w.value})`,
              stroke: "none",
              style: { opacity: "1" }
            }, null, 8, ke),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: Math.max(a.value.height, 0),
              y: 0,
              rx: t.minimapSelectionRadius,
              fill: g.value
            }, null, 8, Ce),
            i("rect", {
              x: p.value.x,
              width: p.value.width < 0 ? 0 : p.value.width,
              height: Math.max(a.value.height, 0),
              y: 0,
              fill: t.minimapSelectedColor,
              rx: t.minimapSelectionRadius,
              style: S({
                opacity: t.minimapSelectedColorOpacity
              })
            }, null, 12, we),
            i("path", {
              d: `M${m.value.sliced[0].x},${Math.max(a.value.height, 0)} ${m.value.selectionSet} L${m.value.sliced.at(-1).x},${Math.max(a.value.height, 0)}Z`,
              fill: `url(#${w.value})`,
              stroke: "none",
              style: { opacity: "1" }
            }, null, 8, Ne),
            i("path", {
              d: `M ${m.value.selectionSet}`,
              stroke: `${t.minimapLineColor}`,
              fill: "transparent",
              "stroke-width": "2",
              "stroke-linecap": "round",
              "stroke-linejoin": "round"
            }, null, 8, $e),
            i("circle", {
              cx: m.value.firstPlot.x,
              cy: m.value.firstPlot.y,
              "stroke-width": "0.5",
              stroke: g.value,
              r: "3",
              fill: t.minimapLineColor
            }, null, 8, Me),
            i("circle", {
              cx: m.value.lastPlot.x,
              cy: m.value.lastPlot.y,
              "stroke-width": "0.5",
              stroke: g.value,
              r: "3",
              fill: t.minimapLineColor
            }, null, 8, Le),
            b.value !== null ? (v(!0), h(F, { key: 0 }, R(I.value, (o, c) => (v(), h("g", null, [
              b.value === o && o >= t.valueStart && o < t.valueEnd ? (v(), h("line", {
                key: 0,
                x1: s.value * c + s.value / 2,
                x2: s.value * c + s.value / 2,
                y1: 0,
                y2: Math.max(a.value.height, 0),
                stroke: t.minimapIndicatorColor,
                "stroke-linecap": "round",
                "stroke-dasharray": "2",
                "stroke-width": "1"
              }, null, 8, Ie)) : C("", !0)
            ]))), 256)) : C("", !0),
            (v(!0), h(F, null, R(I.value, (o, c) => (v(), h("rect", {
              x: s.value * c,
              y: 0,
              height: Math.max(a.value.height, 0),
              width: s.value < 0 ? 0 : s.value,
              fill: "transparent",
              style: { "pointer-events": "all !important" },
              onMouseenter: ($) => G(o),
              onMouseleave: n[0] || (n[0] = ($) => {
                b.value = null, x("trapMouse", null);
              })
            }, null, 40, ze))), 256))
          ], 8, fe))
        ])) : C("", !0),
        Fe,
        i("div", {
          class: "range-highlight",
          style: S(D.value)
        }, null, 4),
        E(i("input", {
          type: "range",
          class: "range-left",
          min: t.min,
          max: t.max,
          "onUpdate:modelValue": n[1] || (n[1] = (o) => u.value = o),
          onInput: X
        }, null, 40, Re), [
          [P, u.value]
        ]),
        i("div", {
          class: "thumb-label thumb-label-left",
          style: S(Z.value)
        }, A(t.labelLeft), 5),
        E(i("input", {
          type: "range",
          class: "range-right",
          min: t.min,
          max: t.max,
          "onUpdate:modelValue": n[2] || (n[2] = (o) => r.value = o),
          onInput: j
        }, null, 40, Ee), [
          [P, r.value]
        ]),
        i("div", {
          class: "thumb-label thumb-label-right",
          style: S(q.value)
        }, A(t.labelRight), 5)
      ], 512)
    ]));
  }
}, Ue = /* @__PURE__ */ me(Pe, [["__scopeId", "data-v-ed77abe8"]]);
export {
  Ue as S
};
