import { defineComponent as T, computed as D, ref as y, watchEffect as C, createElementBlock as F, openBlock as v, Fragment as _, createBlock as g, createCommentVNode as w } from "vue";
/* empty css                                     */
/* empty css                                     */
import "../../../Interaction/components/Tabs/index.mjs";
import "../../../Interaction/components/Tabs-icon/index.mjs";
import "../../../Interaction/components/Button/index.mjs";
import "../../../Interaction/components/DatePicker/index.mjs";
import "../../../Interaction/components/DatePickerRange/index.mjs";
import "../../../Interaction/components/Switch/index.mjs";
import "../../../Interaction/components/Input/index.mjs";
import "../../../Interaction/components/Select/index.mjs";
import "../../../Interaction/components/Slider/index.mjs";
import "../List/index.mjs";
import "../Text/index.mjs";
import "../TextDynamic/index.mjs";
import "../TableBasic/index.mjs";
import "../TableScroll/index.mjs";
import "../RowScroll/index.mjs";
import "../RealTime/index.mjs";
import "../OverNumber/index.mjs";
import "./index.mjs";
import "../TextCarousel/index.mjs";
import "../../../Media/components/Audio/index.mjs";
import "../../../Media/components/Video/index.mjs";
import "../../../Media/components/Carousel/index.mjs";
import "../../../Media/components/Flv/index.mjs";
import "../../../Media/components/Iframe/index.mjs";
import "../../../Media/components/IframeCarousel/index.mjs";
import "../../../Media/components/Image/index.mjs";
import "../../../Media/components/ImageDynamic/index.mjs";
import "../../../Media/components/M3u8/index.mjs";
import "../../../Media/components/Wavesurfer/index.mjs";
import "../../../Media/components/Weather/index.mjs";
import "../../../Media/components/Qrcode/index.mjs";
import "../../../Chart/components/bar/basic/index.mjs";
import "../../../Chart/components/bar/animation/index.mjs";
import "../../../Chart/components/bar/contrast/index.mjs";
import "../../../Chart/components/bar/contrast2/index.mjs";
import "../../../Chart/components/bar/contrast3/index.mjs";
import "../../../Chart/components/bar/gradient-column-chart/index.mjs";
import "../../../Chart/components/bar/horizontal/index.mjs";
import "../../../Chart/components/bar/horizontal-stack/index.mjs";
import "../../../Chart/components/bar/line-bar/index.mjs";
import "../../../Chart/components/bar/line-bar2/index.mjs";
import "../../../Chart/components/bar/loop/index.mjs";
import "../../../Chart/components/bar/mini/index.mjs";
import "../../../Chart/components/bar/polar/index.mjs";
import "../../../Chart/components/bar/polar-stack/index.mjs";
import "../../../Chart/components/bar/polar2/index.mjs";
import "../../../Chart/components/bar/radius-circle/index.mjs";
import "../../../Chart/components/bar/rank/index.mjs";
import "../../../Chart/components/bar/segmented-progress/index.mjs";
import "../../../Chart/components/bar/spire/index.mjs";
import "../../../Chart/components/bar/stack/index.mjs";
import "../../../Chart/components/bar/stack-line/index.mjs";
import "../../../Chart/components/bar/stack2/index.mjs";
import "../../../Chart/components/bar/stack3/index.mjs";
import "../../../Chart/components/bar/staggered/index.mjs";
import "../../../Chart/components/bar/three/index.mjs";
import "../../../Chart/components/bar/waterfall/index.mjs";
import "../../../Chart/components/bar/zebra/index.mjs";
import "../../../Chart/components/line/area-gradient/index.mjs";
import "../../../Chart/components/line/area-highlight/index.mjs";
import "../../../Chart/components/line/area-highlight2/index.mjs";
import "../../../Chart/components/line/basic/index.mjs";
import "../../../Chart/components/line/bump/index.mjs";
import "../../../Chart/components/line/dashed/index.mjs";
import "../../../Chart/components/line/ladder/index.mjs";
import "../../../Chart/components/line/logarithm/index.mjs";
import "../../../Chart/components/line/multix/index.mjs";
import "../../../Chart/components/line/polar-double/index.mjs";
import "../../../Chart/components/line/rain-flow/index.mjs";
import "../../../Chart/components/line/scale/index.mjs";
import "../../../Chart/components/line/smooth/index.mjs";
import "../../../Chart/components/line/smooth-area/index.mjs";
import "../../../Chart/components/line/stack/index.mjs";
import "../../../Chart/components/line/stack-area/index.mjs";
import "../../../Chart/components/line/temp/index.mjs";
import "../../../Chart/components/line/vertical/index.mjs";
import "../../../Chart/components/map/basic/index.mjs";
import "../../../Chart/components/map/bmap-basic/index.mjs";
import "../../../Chart/components/map/bmap-heatmap/index.mjs";
import "../../../Chart/components/map/bmap-rich/index.mjs";
import "../../../Chart/components/map/customize/index.mjs";
import "../../../Chart/components/map/lines/index.mjs";
import "../../../Chart/components/map/scatter/index.mjs";
import "../../../Chart/components/pie/3d/index.mjs";
import "../../../Chart/components/pie/basic/index.mjs";
import "../../../Chart/components/pie/basic2/index.mjs";
import "../../../Chart/components/pie/customized/index.mjs";
import "../../../Chart/components/pie/index/index.mjs";
import "../../../Chart/components/pie/interval/index.mjs";
import "../../../Chart/components/pie/legend-scroll/index.mjs";
import "../../../Chart/components/pie/radius/index.mjs";
import "../../../Chart/components/pie/rose/index.mjs";
import "../../../Chart/components/pie/round/index.mjs";
import "../../../Chart/components/pie/sunburst/index.mjs";
import "../../../Chart/components/scatter/basic/index.mjs";
import "../../../Chart/components/scatter/basic2/index.mjs";
import "../../../Chart/components/scatter/bubble/index.mjs";
import "../../../Chart/components/scatter/ripples/index.mjs";
import "../../../Chart/components/other/candlestick-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic2/index.mjs";
import "../../../Chart/components/other/sunburst-basic3/index.mjs";
import "../../../Chart/components/other/sunburst-basic4/index.mjs";
import "../../../Chart/components/other/sunburst-book/index.mjs";
import "../../../Chart/components/other/sunburst-flavors/index.mjs";
import "../../../Chart/components/other/sunburst-radius/index.mjs";
import "../../../Chart/components/other/funnel/index.mjs";
import "../../../Chart/components/other/funnel-contrast/index.mjs";
import "../../../Chart/components/other/funnel-split/index.mjs";
import "../../../Chart/components/other/funnel2/index.mjs";
import "../../../Chart/components/other/force/index.mjs";
import "../../../Chart/components/other/force2/index.mjs";
import "../../../Chart/components/other/gauge/index.mjs";
import "../../../Chart/components/other/gauge-grade/index.mjs";
import "../../../Chart/components/other/gauge-stage/index.mjs";
import "../../../Chart/components/other/graph-basic/index.mjs";
import "../../../Chart/components/other/graph-basic2/index.mjs";
import "../../../Chart/components/other/graph-calendar/index.mjs";
import "../../../Chart/components/other/circular-graph/index.mjs";
import "../../../Chart/components/other/heatmap/index.mjs";
import "../../../Chart/components/other/liquidfill/index.mjs";
import "../../../Chart/components/other/parallel-basic/index.mjs";
import "../../../Chart/components/other/parallel-mul/index.mjs";
import "../../../Chart/components/other/radar-stack/index.mjs";
import "../../../Chart/components/other/tree/index.mjs";
import "../../../Chart/components/other/tree-line/index.mjs";
import "../../../Chart/components/other/word-cloud/index.mjs";
import "../../../Chart/components/other/treemap/index.mjs";
import "../../../Chart/components/other/treemap-basic/index.mjs";
import "../../../Chart/components/other/label-gauge/index.mjs";
import "../../../Chart/components/other/grid-percentage/index.mjs";
import "../../../Chart/components/other/radar/index.mjs";
import "../../../Commons/components/CustomComponentRender/index.mjs";
import "../../../Commons/components/Graphical/index.mjs";
import "../../../Commons/components/Svg/index.mjs";
import "../../../Commons/components/ModelViewer/index.mjs";
import "../../../Commons/components/VrVideo/index.mjs";
import "../../../Commons/components/VrPhoto/index.mjs";
import "../../../Commons/components/Babylon/index.mjs";
import "../../../Commons/components/Echarts/index.mjs";
import "../../../Commons/components/GSViewer/index.mjs";
import "../../../Scene/components/Amap2d/index.mjs";
import "../../../Scene/components/Amap3d/index.mjs";
import "../../../Scene/components/Default/index.mjs";
import "../../../Scene/components/Map2d/index.mjs";
import "../../../Scene/components/Map3d/index.mjs";
import "../../../Scene/components/UeIframe/index.mjs";
import "../../../Scene/components/UeShj/index.mjs";
import "../../../Scene/components/UnityIframe/index.mjs";
import "../../../Scene/components/UnityWebgl/index.mjs";
import "../../../Scene/components/Vr/index.mjs";
import "../../../Scene/components/Earth/index.mjs";
import "lodash";
import { SHJParseEvent as H } from "../../../../commons/plugins/event/index.mjs";
import "../../../../commons/plugins/datasource/utils/request.mjs";
import "mqtt";
import "nanoid";
import { upgradeCountDown as A } from "./version.mjs";
import S from "../../../../commons/components/Text.vue.mjs";
const B = T({ name: "ShjCountDown" }), qo = /* @__PURE__ */ T({
  ...B,
  props: {
    option: {},
    useEvents: {}
  },
  emits: ["on-end", "on-start"],
  setup(f, { expose: Y, emit: E }) {
    const b = E, x = window.requestAnimationFrame, o = D(() => A(f.option)), c = y(0), r = y(0), i = D(() => ({
      showMillisecond: o.value.base.settings.format.includes("SSS"),
      showYear: o.value.base.settings.format.includes("Y"),
      showMonth: o.value.base.settings.format.includes("M"),
      showDay: o.value.base.settings.format.includes("D"),
      showHour: o.value.base.settings.format.includes("H"),
      showMinute: o.value.base.settings.format.includes("m"),
      showSecond: o.value.base.settings.format.includes("s")
    }));
    function p(e) {
      return e < 10 ? "0" + e : String(e);
    }
    function k(e) {
      if (e === null)
        return "--";
      let t = o.value.base.settings.format, d = 0;
      i.value.showMillisecond && (d = e % 1e3, t = t.replace("SSS", "0".repeat(3 - String(d).length) + d)), e = Math.floor(e / 1e3);
      let s = 0;
      i.value.showYear ? (s = Math.floor(e / (60 * 60 * 24 * 30 * 12)), t = t.includes("YY") ? t.replace("YY", p(s)) : t.replace("Y", String(s))) : s = 0;
      let l = 0;
      i.value.showMonth ? (e = e - s * 60 * 60 * 24 * 30 * 12, l = Math.floor(e / (60 * 60 * 24 * 30)), t = t.includes("MM") ? t.replace("MM", p(l)) : t.replace("M", String(l))) : l = 0;
      let a = 0;
      i.value.showDay ? (e = e - l * 60 * 60 * 24 * 30, a = Math.floor(e / (60 * 60 * 24)), t = t.includes("DD") ? t.replace("DD", p(a)) : t.replace("D", String(a))) : a = 0;
      let n = 0;
      i.value.showHour ? (e = e - a * 60 * 60 * 24, n = Math.floor(e / (60 * 60)), t = t.includes("HH") ? t.replace("HH", p(n)) : t.replace("H", String(n))) : n = 0;
      let u = 0;
      i.value.showMinute ? (e = e - n * 60 * 60, u = Math.floor(e / 60), t = t.includes("mm") ? t.replace("mm", p(u)) : t.replace("m", String(u))) : u = 0;
      let h = 0;
      return i.value.showSecond && (h = e - u * 60, t = t.includes("ss") ? t.replace("ss", p(h)) : t.replace("s", String(h))), t;
    }
    function M() {
      r.value !== null && (c.value > Date.now() ? (r.value = c.value - Date.now(), x(M)) : (r.value = 0, b("on-end"), H.parseEvents(f.useEvents, "end-count-down", null)));
    }
    const m = () => {
      b("on-start"), H.parseEvents(f.useEvents, "on-start", null), r.value = 0, Number.isFinite(o.value.base.settings.value) ? (o.value.base.settings.future ? o.value.base.settings.value >= Date.now() && (c.value = o.value.base.settings.value) : o.value.base.settings.value >= 0 && (c.value = o.value.base.settings.value + Date.now()), x(M)) : r.value = null;
    };
    return C(() => {
      o.value.base.settings.autoStart ? m() : r.value = null;
    }), Y({
      start: () => m(),
      startAgain: () => m(),
      refresh: () => m(),
      refreshView: () => m(),
      refreshData: () => m()
    }), (e, t) => (v(), F(_, null, [
      o.value.base.settings.finishedText && r.value === 0 && r.value !== null ? (v(), g(S, {
        key: 0,
        text: o.value.base.settings.finishedText,
        textStyle: o.value.base.textStyle
      }, null, 8, ["text", "textStyle"])) : w("", !0),
      o.value.base.settings.defaultText && r.value === null ? (v(), g(S, {
        key: 1,
        text: o.value.base.settings.defaultText,
        textStyle: o.value.base.textStyle
      }, null, 8, ["text", "textStyle"])) : w("", !0),
      Number.isFinite(r.value) && r.value > 0 ? (v(), g(S, {
        key: 2,
        text: k(r.value),
        textStyle: o.value.base.textStyle
      }, null, 8, ["text", "textStyle"])) : w("", !0)
    ], 64));
  }
});
export {
  qo as default
};
