import { useCssVars as ye, computed as h, onMounted as fe, ref as g, watch as ge, openBlock as l, createElementBlock as u, normalizeClass as P, normalizeStyle as me, createBlock as F, createCommentVNode as i, unref as v, createSlots as pe, withCtx as I, renderSlot as m, normalizeProps as G, guardReactiveProps as V, createVNode as ke, createElementVNode as d, Fragment as O, renderList as K, toDisplayString as be } from "vue";
import { u as _e, o as xe, e as Q, g as we, c as Ce, t as $e, a as Pe, p as _, b as Fe, v as f, d as A, X as Ie, s as Oe, i as Ae, f as Ye } from "./index-Cm2_6s9o.js";
import { _ as Ne } from "./Title-Coit3NcT.js";
import { u as Me, U as Te } from "./usePrinter-Cx8U1e30.js";
import Se from "./vue-ui-skeleton-BUS6A44x.js";
import { u as Z } from "./useNestedProp-BYPZJNhi.js";
import { _ as Ue } from "./PackageVersion-CTMY4zeY.js";
import { P as qe } from "./PenAndPaper-DJ_d10S-.js";
import { _ as Le } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const Ge = ["id"], Ve = {
  key: 1,
  ref: "noTitle",
  class: "vue-data-ui-no-title-space",
  style: "height:36px; width: 100%;background:transparent"
}, We = {
  key: 2,
  style: "width:100%"
}, Ee = ["xmlns", "viewBox"], ze = {
  id: "vueUiPill",
  clipPathUnits: "objectBoundingBox"
}, Be = ["fill"], je = ["id"], De = ["stop-color"], He = ["stop-color"], Xe = ["stop-color"], Re = { "clip-path": "url(#vueUiPill)" }, Je = ["x", "y", "height", "width"], Ke = ["x", "y", "height", "width", "fill"], Qe = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], Ze = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], et = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], tt = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], st = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], ot = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], at = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], lt = ["x1", "x2", "y1", "y2", "stroke-width", "stroke"], rt = ["x", "y", "height", "width"], ut = ["y", "x", "fill", "font-size", "font-weight"], nt = {
  key: 5,
  class: "vue-data-ui-watermark"
}, it = {
  key: 6,
  ref: "source",
  dir: "auto"
}, ct = {
  __name: "vue-ui-thermometer",
  props: {
    dataset: {
      type: Object,
      default() {
        return {};
      }
    },
    config: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  setup(x, { expose: ee }) {
    const a = x;
    ye((s) => ({
      "000db494": ue.value,
      "2865ccd0": re.value,
      10843485: le.value
    }));
    const { vue_ui_thermometer: te } = _e(), Y = h(() => !!a.dataset && Object.keys(a.dataset).length);
    fe(() => {
      W();
    });
    function W() {
      xe(a.dataset) ? Q({
        componentName: "VueUiThermometer",
        type: "dataset"
      }) : we({
        datasetObject: a.dataset,
        requiredAttributes: ["value", "from", "to"]
      }).forEach((s) => {
        Q({
          componentName: "VueUiThermometer",
          type: "datasetAttribute",
          property: s
        });
      });
    }
    const p = g(Ce()), N = g(null), E = g(0), z = g(0), e = h({
      get: () => B(),
      set: (s) => s
    });
    function B() {
      const s = Z({
        userConfig: a.config,
        defaultConfig: te
      });
      return s.theme ? {
        ...Z({
          userConfig: $e.vue_ui_thermometer[s.theme] || a.config,
          defaultConfig: s
        }),
        customPalette: Pe[s.theme] || _
      } : s;
    }
    ge(() => a.config, (s) => {
      e.value = B(), W(), z.value += 1;
    }, { deep: !0 });
    const { isPrinting: j, isImaging: D, generatePdf: H, generateImage: X } = Me({
      elementId: `thermometer__${p.value}`,
      fileName: e.value.style.title.text || "vue-ui-thermometer"
    }), se = h(() => e.value.userOptions.show && !e.value.style.title.text), w = h(() => Fe(e.value.customPalette)), oe = h(() => e.value.style.chart.thermometer.width), y = h(() => a.dataset.steps || 10), c = g({
      top: e.value.style.chart.padding.top,
      left: e.value.style.chart.padding.left,
      right: e.value.style.chart.padding.right,
      bottom: e.value.style.chart.padding.bottom
    });
    function C(s, n, t) {
      const r = [], q = R(s), L = R(n);
      for (let b = 0; b < t; b++) {
        const ce = M(q.red, L.red, b, t), he = M(q.green, L.green, b, t), de = M(q.blue, L.blue, b, t), ve = `#${T(ce)}${T(he)}${T(de)}`;
        r.push(ve);
      }
      return r;
    }
    function R(s) {
      const n = s.slice(1);
      return {
        red: parseInt(n.slice(0, 2), 16),
        green: parseInt(n.slice(2, 4), 16),
        blue: parseInt(n.slice(4, 6), 16)
      };
    }
    function M(s, n, t, r) {
      return Math.round(s + (n - s) * t / r);
    }
    function T(s) {
      return s.toString(16).padStart(2, "0");
    }
    const o = h(() => {
      const s = oe.value + c.value.left + c.value.right, n = e.value.style.chart.height;
      return {
        width: s,
        left: c.value.left,
        right: s - c.value.right,
        top: c.value.top,
        bottom: n - c.value.bottom,
        height: n
      };
    }), ae = h(() => o.value), S = h(() => {
      const s = f(a.dataset.from) < 0 ? Math.abs(f(a.dataset.from)) : f(a.dataset.from), n = f(a.dataset.to) < 0 ? Math.abs(f(a.dataset.to)) : f(a.dataset.to);
      let t = 0;
      return f(a.dataset.to) > 0 ? t = s + n : s > n ? t = s - n : t = n - s, (1 - (Math.abs(f(a.dataset.from)) + f(a.dataset.value)) / t) * (o.value.height - c.value.top - c.value.bottom);
    }), le = h(() => `${S.value}px`), re = h(() => `${o.value.height - e.value.style.chart.padding.bottom - c.value.top}px`), ue = h(() => `${e.value.style.chart.animation.speedMs}ms`), ne = h(() => {
      if (a.dataset.colors) {
        if (!a.dataset.colors.from)
          return C(w.value[0] || _[0], A(a.dataset.colors.to), y.value || 10);
        if (!a.dataset.colors.to)
          return C(A(a.dataset.colors.from), w.value[1] || _[1], y.value || 10);
      } else
        return C(w.value[1] || _[1], w.value[0] || _[0], y.value || 10);
      return C(A(a.dataset.colors.from), A(a.dataset.colors.to), y.value || 10);
    }), J = h(() => {
      const s = [];
      let n = 0;
      const t = o.value.height - c.value.top - c.value.bottom;
      for (let r = 0; r < t - 1; r += t / y.value)
        s.push({
          x: o.value.left,
          y: o.value.top + r,
          qYLess: o.value.top + r + t / y.value / 4,
          halfY: o.value.top + r + t / y.value / 2,
          qYMore: o.value.top + r + t / y.value / 4 * 3,
          color: ne.value[n],
          height: t / y.value
        }), n += 1;
      return s;
    }), k = g(!1);
    function ie(s) {
      k.value = s, E.value += 1;
    }
    const $ = g(!1);
    function U() {
      $.value = !$.value;
    }
    return ee({
      generatePdf: H,
      generateImage: X,
      toggleAnnotator: U
    }), (s, n) => (l(), u("div", {
      ref_key: "thermoChart",
      ref: N,
      class: P(`vue-ui-thermometer ${k.value ? "vue-data-ui-wrapper-fullscreen" : ""}`),
      style: me(`width:100%;background:${e.value.style.chart.backgroundColor};color:${e.value.style.chart.color};font-family:${e.value.style.fontFamily}`),
      id: `thermometer__${p.value}`
    }, [
      e.value.userOptions.buttons.annotator ? (l(), F(qe, {
        key: 0,
        parent: N.value,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        active: $.value,
        onClose: U
      }, null, 8, ["parent", "backgroundColor", "color", "active"])) : i("", !0),
      se.value ? (l(), u("div", Ve, null, 512)) : i("", !0),
      e.value.style.title.text ? (l(), u("div", We, [
        (l(), F(Ne, {
          key: `title_${z.value}`,
          config: {
            title: {
              cy: "thermometer-div-title",
              ...e.value.style.title
            },
            subtitle: {
              cy: "thermometer-div-subtitle",
              ...e.value.style.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ])) : i("", !0),
      e.value.userOptions.show && Y.value ? (l(), F(Te, {
        ref: "details",
        key: `user_options_${E.value}`,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isImaging: v(D),
        isPrinting: v(j),
        uid: p.value,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasImg: e.value.userOptions.buttons.img,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        hasXls: !1,
        isFullscreen: k.value,
        titles: { ...e.value.userOptions.buttonTitles },
        chartElement: N.value,
        position: e.value.userOptions.position,
        hasAnnotator: e.value.userOptions.buttons.annotator,
        isAnnotation: $.value,
        onToggleFullscreen: ie,
        onGeneratePdf: v(H),
        onGenerateImage: v(X),
        onToggleAnnotator: U
      }, pe({ _: 2 }, [
        s.$slots.optionPdf ? {
          name: "optionPdf",
          fn: I(() => [
            m(s.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        s.$slots.optionImg ? {
          name: "optionImg",
          fn: I(() => [
            m(s.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        s.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: I(({ toggleFullscreen: t, isFullscreen: r }) => [
            m(s.$slots, "optionFullscreen", G(V({ toggleFullscreen: t, isFullscreen: r })), void 0, !0)
          ]),
          key: "2"
        } : void 0,
        s.$slots.optionAnnotator ? {
          name: "optionAnnotator",
          fn: I(({ toggleAnnotator: t, isAnnotator: r }) => [
            m(s.$slots, "optionAnnotator", G(V({ toggleAnnotator: t, isAnnotator: r })), void 0, !0)
          ]),
          key: "3"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isImaging", "isPrinting", "uid", "hasPdf", "hasImg", "hasFullscreen", "isFullscreen", "titles", "chartElement", "position", "hasAnnotator", "isAnnotation", "onGeneratePdf", "onGenerateImage"])) : i("", !0),
      Y.value ? (l(), u("svg", {
        key: 4,
        xmlns: v(Ie),
        class: P({ "vue-data-ui-fullscreen--on": k.value, "vue-data-ui-fulscreen--off": !k.value }),
        width: "100%",
        viewBox: `0 0 ${o.value.width} ${o.value.height}`,
        style: "background:transparent"
      }, [
        ke(Ue),
        d("defs", null, [
          d("clipPath", ze, [
            d("rect", {
              x: "0",
              y: "0",
              width: "1",
              height: "1",
              rx: "0.5",
              ry: "0.07",
              fill: e.value.style.chart.backgroundColor
            }, null, 8, Be)
          ]),
          (l(!0), u(O, null, K(J.value, (t, r) => (l(), u("linearGradient", {
            id: `vueUiThermometerGradient_${r}_${p.value}`,
            x1: "0%",
            y1: "0%",
            x2: "100%",
            y2: "0%"
          }, [
            d("stop", {
              offset: "0%",
              "stop-color": t.color
            }, null, 8, De),
            d("stop", {
              offset: "50%",
              "stop-color": v(Oe)(t.color, 100 - e.value.style.chart.graduations.gradient.intensity)
            }, null, 8, He),
            d("stop", {
              offset: "100%",
              "stop-color": t.color
            }, null, 8, Xe)
          ], 8, je))), 256))
        ]),
        d("g", Re, [
          d("rect", {
            x: o.value.left,
            y: o.value.top,
            height: o.value.height - c.value.top - c.value.bottom,
            width: o.value.width - c.value.left - c.value.right,
            fill: "#FFFFFF"
          }, null, 8, Je),
          (l(!0), u(O, null, K(J.value, (t, r) => (l(), u("g", {
            key: `graduation_${r}`
          }, [
            d("rect", {
              x: t.x,
              y: t.y,
              height: t.height,
              width: o.value.width - e.value.style.chart.padding.left - e.value.style.chart.padding.right,
              fill: e.value.style.chart.graduations.gradient.show ? `url(#vueUiThermometerGradient_${r}_${p.value})` : t.color,
              "shape-rendering": "crispEdges"
            }, null, 8, Ke),
            e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
              key: 0,
              x1: t.x,
              x2: t.x + 10,
              y1: t.y,
              y2: t.y,
              "stroke-width": e.value.style.chart.graduations.strokeWidth,
              stroke: e.value.style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, Qe)) : i("", !0),
            e.value.style.chart.graduations.showIntermediate ? (l(), u(O, { key: 1 }, [
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 0,
                x1: t.x,
                x2: t.x + 5,
                y1: t.halfY,
                y2: t.halfY,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, Ze)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 1,
                x1: t.x,
                x2: t.x + 2.5,
                y1: t.qYLess,
                y2: t.qYLess,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, et)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "left"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 2,
                x1: t.x,
                x2: t.x + 2.5,
                y1: t.qYMore,
                y2: t.qYMore,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, tt)) : i("", !0)
            ], 64)) : i("", !0),
            e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
              key: 2,
              x1: o.value.right,
              x2: o.value.right - 10,
              y1: t.y,
              y2: t.y,
              "stroke-width": e.value.style.chart.graduations.strokeWidth,
              stroke: e.value.style.chart.graduations.stroke,
              "stroke-linecap": "round"
            }, null, 8, st)) : i("", !0),
            e.value.style.chart.graduations.showIntermediate ? (l(), u(O, { key: 3 }, [
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 0,
                x1: o.value.right,
                x2: o.value.right - 5,
                y1: t.halfY,
                y2: t.halfY,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, ot)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 1,
                x1: o.value.right,
                x2: o.value.right - 2.5,
                y1: t.qYLess,
                y2: t.qYLess,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, at)) : i("", !0),
              e.value.style.chart.graduations.show && ["both", "right"].includes(e.value.style.chart.graduations.sides) ? (l(), u("line", {
                key: 2,
                x1: o.value.right,
                x2: o.value.right - 2.5,
                y1: t.qYMore,
                y2: t.qYMore,
                "stroke-width": e.value.style.chart.graduations.strokeWidth / 2,
                stroke: e.value.style.chart.graduations.stroke,
                "stroke-linecap": "round"
              }, null, 8, lt)) : i("", !0)
            ], 64)) : i("", !0)
          ]))), 128)),
          d("rect", {
            class: P({ "vue-ui-thermometer-temperature": e.value.style.chart.animation.use }),
            x: o.value.left,
            y: o.value.top,
            height: S.value,
            width: o.value.width - e.value.style.chart.padding.left - e.value.style.chart.padding.right,
            fill: "#FFFFFF66"
          }, null, 10, rt)
        ]),
        d("text", {
          class: P({ "vue-ui-thermometer-temperature-value": e.value.style.chart.animation.use }),
          y: S.value + o.value.top + e.value.style.chart.label.fontSize / 3,
          x: o.value.left - 10,
          "text-anchor": "end",
          fill: e.value.style.chart.label.color,
          "font-size": e.value.style.chart.label.fontSize,
          "font-weight": e.value.style.chart.label.bold ? "bold" : "normal"
        }, be(v(Ae)(
          e.value.style.chart.label.formatter,
          x.dataset.value,
          v(Ye)({
            p: e.value.style.chart.label.prefix,
            v: x.dataset.value,
            s: e.value.style.chart.label.suffix,
            r: e.value.style.chart.label.rounding
          }),
          { datapoint: x.dataset }
        )), 11, ut),
        m(s.$slots, "svg", { svg: ae.value }, void 0, !0)
      ], 10, Ee)) : i("", !0),
      s.$slots.watermark ? (l(), u("div", nt, [
        m(s.$slots, "watermark", G(V({ isPrinting: v(j) || v(D) })), void 0, !0)
      ])) : i("", !0),
      s.$slots.source ? (l(), u("div", it, [
        m(s.$slots, "source", {}, void 0, !0)
      ], 512)) : i("", !0),
      Y.value ? i("", !0) : (l(), F(Se, {
        key: 7,
        config: {
          type: "thermometer",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            thermometer: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"]))
    ], 14, Ge));
  }
}, bt = /* @__PURE__ */ Le(ct, [["__scopeId", "data-v-8a73571f"]]);
export {
  bt as default
};
