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