import { defineComponent as V, useCssVars as $, computed as P, ref as C, onMounted as S, nextTick as B, createElementBlock as y, openBlock as b, createVNode as N, unref as w, normalizeStyle as R, withCtx as Y, createElementVNode as r, createCommentVNode as O, Fragment as x } from "vue";
import j from "@vuepic/vue-datepicker";
import { nanoid as D } from "nanoid";
import a from "dayjs";
import "dayjs/locale/zh-cn";
import H from "dayjs/plugin/relativeTime";
import { useWatch as q } from "./hooks/useWatch.mjs";
/* empty css                       */
/* empty css                       */
import "../../../components/Interaction/components/Tabs/index.mjs";
import "../../../components/Interaction/components/Tabs-icon/index.mjs";
import "../../../components/Interaction/components/Button/index.mjs";
import "../../../components/Interaction/components/DatePicker/index.mjs";
import "../../../components/Interaction/components/DatePickerRange/index.mjs";
import "../../../components/Interaction/components/Switch/index.mjs";
import "../../../components/Interaction/components/Input/index.mjs";
import "../../../components/Interaction/components/Select/index.mjs";
import "../../../components/Interaction/components/Slider/index.mjs";
import "../../../components/Text/components/List/index.mjs";
import "../../../components/Text/components/Text/index.mjs";
import "../../../components/Text/components/TextDynamic/index.mjs";
import "../../../components/Text/components/TableBasic/index.mjs";
import "../../../components/Text/components/TableScroll/index.mjs";
import "../../../components/Text/components/RowScroll/index.mjs";
import "../../../components/Text/components/RealTime/index.mjs";
import "../../../components/Text/components/OverNumber/index.mjs";
import "../../../components/Text/components/CountDown/index.mjs";
import "../../../components/Text/components/TextCarousel/index.mjs";
import "../../../components/Media/components/Audio/index.mjs";
import "../../../components/Media/components/Video/index.mjs";
import "../../../components/Media/components/VideoDynamic/index.mjs";
import "../../../components/Media/components/Carousel/index.mjs";
import "../../../components/Media/components/Flv/index.mjs";
import "../../../components/Media/components/Iframe/index.mjs";
import "../../../components/Media/components/IframeCarousel/index.mjs";
import "../../../components/Media/components/Image/index.mjs";
import "../../../components/Media/components/ImageDynamic/index.mjs";
import "../../../components/Media/components/M3u8/index.mjs";
import "../../../components/Media/components/Wavesurfer/index.mjs";
import "../../../components/Media/components/Weather/index.mjs";
import "../../../components/Media/components/Qrcode/index.mjs";
import "../../../components/Chart/components/bar/basic/index.mjs";
import "../../../components/Chart/components/bar/animation/index.mjs";
import "../../../components/Chart/components/bar/contrast/index.mjs";
import "../../../components/Chart/components/bar/contrast2/index.mjs";
import "../../../components/Chart/components/bar/contrast3/index.mjs";
import "../../../components/Chart/components/bar/gradient-column-chart/index.mjs";
import "../../../components/Chart/components/bar/horizontal/index.mjs";
import "../../../components/Chart/components/bar/horizontal-stack/index.mjs";
import "../../../components/Chart/components/bar/line-bar/index.mjs";
import "../../../components/Chart/components/bar/line-bar2/index.mjs";
import "../../../components/Chart/components/bar/loop/index.mjs";
import "../../../components/Chart/components/bar/mini/index.mjs";
import "../../../components/Chart/components/bar/polar/index.mjs";
import "../../../components/Chart/components/bar/polar-stack/index.mjs";
import "../../../components/Chart/components/bar/polar2/index.mjs";
import "../../../components/Chart/components/bar/radius-circle/index.mjs";
import "../../../components/Chart/components/bar/rank/index.mjs";
import "../../../components/Chart/components/bar/segmented-progress/index.mjs";
import "../../../components/Chart/components/bar/spire/index.mjs";
import "../../../components/Chart/components/bar/stack/index.mjs";
import "../../../components/Chart/components/bar/stack-line/index.mjs";
import "../../../components/Chart/components/bar/stack2/index.mjs";
import "../../../components/Chart/components/bar/stack3/index.mjs";
import "../../../components/Chart/components/bar/staggered/index.mjs";
import "../../../components/Chart/components/bar/three/index.mjs";
import "../../../components/Chart/components/bar/waterfall/index.mjs";
import "../../../components/Chart/components/bar/zebra/index.mjs";
import "../../../components/Chart/components/line/area-gradient/index.mjs";
import "../../../components/Chart/components/line/area-highlight/index.mjs";
import "../../../components/Chart/components/line/area-highlight2/index.mjs";
import "../../../components/Chart/components/line/basic/index.mjs";
import "../../../components/Chart/components/line/bump/index.mjs";
import "../../../components/Chart/components/line/dashed/index.mjs";
import "../../../components/Chart/components/line/ladder/index.mjs";
import "../../../components/Chart/components/line/logarithm/index.mjs";
import "../../../components/Chart/components/line/multix/index.mjs";
import "../../../components/Chart/components/line/polar-double/index.mjs";
import "../../../components/Chart/components/line/rain-flow/index.mjs";
import "../../../components/Chart/components/line/scale/index.mjs";
import "../../../components/Chart/components/line/smooth/index.mjs";
import "../../../components/Chart/components/line/smooth-area/index.mjs";
import "../../../components/Chart/components/line/stack/index.mjs";
import "../../../components/Chart/components/line/stack-area/index.mjs";
import "../../../components/Chart/components/line/temp/index.mjs";
import "../../../components/Chart/components/line/vertical/index.mjs";
import "../../../components/Chart/components/map/basic/index.mjs";
import "../../../components/Chart/components/map/bmap-basic/index.mjs";
import "../../../components/Chart/components/map/bmap-heatmap/index.mjs";
import "../../../components/Chart/components/map/bmap-rich/index.mjs";
import "../../../components/Chart/components/map/customize/index.mjs";
import "../../../components/Chart/components/map/lines/index.mjs";
import "../../../components/Chart/components/map/scatter/index.mjs";
import "../../../components/Chart/components/pie/3d/index.mjs";
import "../../../components/Chart/components/pie/basic/index.mjs";
import "../../../components/Chart/components/pie/basic2/index.mjs";
import "../../../components/Chart/components/pie/customized/index.mjs";
import "../../../components/Chart/components/pie/index/index.mjs";
import "../../../components/Chart/components/pie/interval/index.mjs";
import "../../../components/Chart/components/pie/legend-scroll/index.mjs";
import "../../../components/Chart/components/pie/radius/index.mjs";
import "../../../components/Chart/components/pie/rose/index.mjs";
import "../../../components/Chart/components/pie/round/index.mjs";
import "../../../components/Chart/components/pie/sunburst/index.mjs";
import "../../../components/Chart/components/scatter/basic/index.mjs";
import "../../../components/Chart/components/scatter/basic2/index.mjs";
import "../../../components/Chart/components/scatter/bubble/index.mjs";
import "../../../components/Chart/components/scatter/ripples/index.mjs";
import "../../../components/Chart/components/other/candlestick-basic/index.mjs";
import "../../../components/Chart/components/other/sunburst-basic/index.mjs";
import "../../../components/Chart/components/other/sunburst-basic2/index.mjs";
import "../../../components/Chart/components/other/sunburst-basic3/index.mjs";
import "../../../components/Chart/components/other/sunburst-basic4/index.mjs";
import "../../../components/Chart/components/other/sunburst-book/index.mjs";
import "../../../components/Chart/components/other/sunburst-flavors/index.mjs";
import "../../../components/Chart/components/other/sunburst-radius/index.mjs";
import "../../../components/Chart/components/other/funnel/index.mjs";
import "../../../components/Chart/components/other/funnel-contrast/index.mjs";
import "../../../components/Chart/components/other/funnel-split/index.mjs";
import "../../../components/Chart/components/other/funnel2/index.mjs";
import "../../../components/Chart/components/other/force/index.mjs";
import "../../../components/Chart/components/other/force2/index.mjs";
import "../../../components/Chart/components/other/gauge/index.mjs";
import "../../../components/Chart/components/other/gauge-grade/index.mjs";
import "../../../components/Chart/components/other/gauge-stage/index.mjs";
import "../../../components/Chart/components/other/graph-basic/index.mjs";
import "../../../components/Chart/components/other/graph-basic2/index.mjs";
import "../../../components/Chart/components/other/graph-calendar/index.mjs";
import "../../../components/Chart/components/other/circular-graph/index.mjs";
import "../../../components/Chart/components/other/heatmap/index.mjs";
import "../../../components/Chart/components/other/liquidfill/index.mjs";
import "../../../components/Chart/components/other/parallel-basic/index.mjs";
import "../../../components/Chart/components/other/parallel-mul/index.mjs";
import "../../../components/Chart/components/other/radar-stack/index.mjs";
import "../../../components/Chart/components/other/tree/index.mjs";
import "../../../components/Chart/components/other/tree-line/index.mjs";
import "../../../components/Chart/components/other/word-cloud/index.mjs";
import "../../../components/Chart/components/other/treemap/index.mjs";
import "../../../components/Chart/components/other/treemap-basic/index.mjs";
import "../../../components/Chart/components/other/label-gauge/index.mjs";
import "../../../components/Chart/components/other/grid-percentage/index.mjs";
import "../../../components/Chart/components/other/radar/index.mjs";
import "../../../components/Commons/components/CustomComponentRender/index.mjs";
import "../../../components/Commons/components/Graphical/index.mjs";
import "../../../components/Commons/components/Svg/index.mjs";
import "../../../components/Commons/components/ModelViewer/index.mjs";
import "../../../components/Commons/components/VrVideo/index.mjs";
import "../../../components/Commons/components/VrPhoto/index.mjs";
import "../../../components/Commons/components/Babylon/index.mjs";
import "../../../components/Commons/components/Echarts/index.mjs";
import "../../../components/Commons/components/GSViewer/index.mjs";
import "../../../components/Scene/components/Amap2d/index.mjs";
import "../../../components/Scene/components/Amap3d/index.mjs";
import "../../../components/Scene/components/Default/index.mjs";
import "../../../components/Scene/components/Map2d/index.mjs";
import "../../../components/Scene/components/Map3d/index.mjs";
import "../../../components/Scene/components/UeIframe/index.mjs";
import "../../../components/Scene/components/UeShj/index.mjs";
import "../../../components/Scene/components/UnityIframe/index.mjs";
import "../../../components/Scene/components/UnityWebgl/index.mjs";
import "../../../components/Scene/components/Vr/index.mjs";
import "../../../components/Scene/components/Earth/index.mjs";
import { SHJDatasourceV2 as z } from "../../plugins/datasource/index.mjs";
import { SHJParseEvent as u } from "../../plugins/event/index.mjs";
import "lodash";
import { Utils as I } from "../../utils/utils.mjs";
import "@vuepic/vue-datepicker/dist/main.css";
import { upgradeDatePicker as L } from "./version.mjs";
const F = { class: "left-sidebar" }, Qo = /* @__PURE__ */ V({
  __name: "index",
  props: {
    option: {},
    sources: {},
    useEvents: {}
  },
  emits: ["on-change", "on-complete"],
  setup(m, { expose: E, emit: T }) {
    $((i) => ({
      d8834bfc: t.value.style.backgroundColor,
      "5842b723": t.value.style.textColor,
      "6bd8703a": t.value.style.hoverColor,
      "38022b8d": t.value.style.hoverTextColor,
      "257e5318": t.value.style.primaryColor,
      b88d8f50: t.value.style.primaryDisabledColor,
      "65f8e4c7": t.value.style.primaryTextColor,
      "78ea9982": t.value.style.secondaryColor,
      "76fe8844": t.value.style.borderColor,
      "34efbae5": t.value.style.menuBorderColor,
      "79ea4950": t.value.style.borderColorHover,
      "7a233218": t.value.style.borderColorFocus,
      "444b0698": t.value.style.disabledColor,
      "0a2b16fe": t.value.style.scrollBarBackground,
      b544efa0: t.value.style.scrollBarColor,
      "08ccbd13": t.value.style.successColor,
      "17d498af": t.value.style.successColorDisabled,
      "2b5588ad": t.value.style.dangerColor,
      "3e4cbc01": t.value.style.disabledColorText,
      "450ef37c": t.value.style.highlightColor,
      b319d374: t.value.style.loader,
      "011ffcca": t.value.style.fontSize + "px",
      "228dcac4": t.value.style.inputBackgroundColor,
      "51d589af": t.value.style.inputHeight + "px"
    })), a.extend(H), a.locale("zh-cn");
    const t = P(() => L(m.option)), d = T, o = C(), g = C(D()), k = () => g.value = D(), v = () => {
      z.parse({
        sources: m.sources,
        callback: ({ data: i }) => {
          try {
            if (o.value = i[0].data[0].date, u.parseEvents(m.useEvents, "dataListener", o.value), t.value.config.range) {
              const e = {
                startTime: o.value[0],
                endTime: o.value[1],
                formattedData: {
                  startTime: p(
                    o.value[0],
                    t.value.config.format
                  ),
                  endTime: p(
                    o.value[1],
                    t.value.config.format
                  )
                }
              };
              d("on-complete", e), u.parseEvents(m.useEvents, "on-complete", e);
            } else {
              const e = {
                data: o.value,
                formattedData: p(
                  o.value,
                  t.value.config.format
                )
              };
              d("on-complete", e), u.parseEvents(m.useEvents, "on-complete", e);
            }
          } catch {
            u.parseEvents(m.useEvents, "dataListener", null);
          }
        }
      });
    }, p = (i, e) => {
      if (!i || !e) return i;
      try {
        const s = a(i);
        return s.isValid() ? s.format(
          e.replace(/yyyy/g, "YYYY").replace(/dd/g, "DD")
        ) : i;
      } catch {
        return i;
      }
    }, f = (i) => {
      if (o.value = i, t.value.config.range) {
        const s = {
          startTime: o.value[0],
          endTime: o.value[1],
          formattedData: {
            startTime: p(o.value[0], t.value.config.format),
            endTime: p(o.value[1], t.value.config.format)
          }
        };
        d("on-change", s), u.parseEvents(m.useEvents, "on-change", s);
        return;
      }
      const e = {
        data: o.value,
        formattedData: p(o.value, t.value.config.format)
      };
      d("on-change", e), u.parseEvents(m.useEvents, "on-change", e);
    }, c = (i) => {
      i === "today" ? o.value = a() : i === "yesterday" ? o.value = a().subtract(1, "day") : i === "before-yesterday" && (o.value = a().subtract(2, "day")), f(o.value);
    }, n = (i) => {
      i === "today" ? o.value = [a().startOf("day"), a().endOf("day")] : i === "yesterday" ? o.value = [
        a().subtract(1, "day").startOf("day"),
        a().subtract(1, "day").endOf("day")
      ] : i === "before-yesterday" ? o.value = [
        a().subtract(2, "day").startOf("day"),
        a().subtract(2, "day").endOf("day")
      ] : i === "week" ? o.value = [a().startOf("week"), a().endOf("week")] : i === "last-month" ? o.value = [
        a().subtract(1, "month").startOf("month"),
        a().subtract(1, "month").endOf("month")
      ] : i === "month" ? o.value = [a().startOf("month"), a().endOf("month")] : i === "last-7" ? o.value = [
        a().subtract(7, "day").startOf("day"),
        a().endOf("day")
      ] : i === "last-15" ? o.value = [
        a().subtract(15, "day").startOf("day"),
        a().endOf("day")
      ] : i === "last-30" ? o.value = [
        a().subtract(30, "day").startOf("day"),
        a().endOf("day")
      ] : i === "last-365" && (o.value = [
        a().subtract(365, "day").startOf("day"),
        a().endOf("day")
      ]), f(o.value);
    };
    return S(() => {
      B(() => {
        v();
      });
    }), q({ option: t.value, sources: m.sources }, v, k), E({
      refresh: () => v(),
      refreshView: () => k(),
      refreshData: () => v()
    }), (i, e) => (b(), y("div", {
      key: g.value,
      class: "date-picker"
    }, [
      N(w(j), {
        modelValue: o.value,
        "onUpdate:modelValue": [
          e[13] || (e[13] = (s) => o.value = s),
          f
        ],
        range: t.value.config.range,
        "multi-calendars": t.value.config.multiCalendars,
        "month-picker": t.value.config.monthPicker,
        "time-picker": t.value.config.timePicker,
        "year-picker": t.value.config.yearPicker,
        "week-picker": t.value.config.weekPicker,
        "quarter-picker": t.value.config.quarterPicker,
        inline: t.value.config.inline,
        "auto-apply": t.value.config.autoApply,
        clearable: t.value.config.clearable,
        placeholder: t.value.config.placeholder,
        disabled: t.value.config.disabled,
        readonly: t.value.config.readonly,
        format: t.value.config.format,
        "action-row": {
          showNow: t.value.config.actionRow.showNow,
          showPreview: t.value.config.actionRow.showPreview,
          showSelect: t.value.config.actionRow.showSelect,
          showCancel: t.value.config.actionRow.showCancel
        },
        "disable-year-select": t.value.config.disableYearSelect,
        "enable-time-picker": t.value.config.enableTimePicker,
        "enable-seconds": t.value.config.enableSeconds,
        "time-picker-inline": t.value.config.timePickerInline,
        "now-button-label": t.value.config.nowButtonLabel,
        "cancel-text": t.value.config.cancelText,
        "select-text": t.value.config.selectText,
        "hide-input-icon": t.value.config.hideInputIcon,
        class: "date-picker-container",
        style: R(w(I).json2cssObject(t.value.style, "dp"))
      }, {
        "left-sidebar": Y((s) => [
          r("div", F, [
            t.value.config.range ? O("", !0) : (b(), y(x, { key: 0 }, [
              r("div", {
                class: "left-sidebar-item",
                onClick: e[0] || (e[0] = (l) => c("today"))
              }, e[14] || (e[14] = [
                r("span", null, "今天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[1] || (e[1] = (l) => c("yesterday"))
              }, e[15] || (e[15] = [
                r("span", null, "昨天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[2] || (e[2] = (l) => c("before-yesterday"))
              }, e[16] || (e[16] = [
                r("span", null, "前天", -1)
              ]))
            ], 64)),
            t.value.config.range ? (b(), y(x, { key: 1 }, [
              r("div", {
                class: "left-sidebar-item",
                onClick: e[3] || (e[3] = (l) => n("today"))
              }, e[17] || (e[17] = [
                r("span", null, "今日", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[4] || (e[4] = (l) => n("yesterday"))
              }, e[18] || (e[18] = [
                r("span", null, "昨日", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[5] || (e[5] = (l) => n("before-yesterday"))
              }, e[19] || (e[19] = [
                r("span", null, "前天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[6] || (e[6] = (l) => n("week"))
              }, e[20] || (e[20] = [
                r("span", null, "本周", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[7] || (e[7] = (l) => n("last-month"))
              }, e[21] || (e[21] = [
                r("span", null, "上一月", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[8] || (e[8] = (l) => n("month"))
              }, e[22] || (e[22] = [
                r("span", null, "本月", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[9] || (e[9] = (l) => n("last-7"))
              }, e[23] || (e[23] = [
                r("span", null, "近7天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[10] || (e[10] = (l) => n("last-15"))
              }, e[24] || (e[24] = [
                r("span", null, "近15天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[11] || (e[11] = (l) => n("last-30"))
              }, e[25] || (e[25] = [
                r("span", null, "近30天", -1)
              ])),
              r("div", {
                class: "left-sidebar-item",
                onClick: e[12] || (e[12] = (l) => n("last-365"))
              }, e[26] || (e[26] = [
                r("span", null, "近365天", -1)
              ]))
            ], 64)) : O("", !0)
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "range", "multi-calendars", "month-picker", "time-picker", "year-picker", "week-picker", "quarter-picker", "inline", "auto-apply", "clearable", "placeholder", "disabled", "readonly", "format", "action-row", "disable-year-select", "enable-time-picker", "enable-seconds", "time-picker-inline", "now-button-label", "cancel-text", "select-text", "hide-input-icon", "style"])
    ]));
  }
});
export {
  Qo as default
};
