"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const index = require("../../../../../components/Pages/Flipper/index.vue.js");
const runtimeCore_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const runtimeDom_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js");
const reactivity_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js");
const _hoisted_1 = { key: 0 };
const _hoisted_2 = { key: 1 };
const _hoisted_3 = { key: 1 };
const _hoisted_4 = { key: 2 };
const _hoisted_5 = { key: 3 };
const _hoisted_6 = { key: 4 };
const _hoisted_7 = { key: 5 };
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    chartConfig: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const props = __props;
    runtimeDom_esmBundler.useCssVars((_ctx) => ({
      "a0c42b24": `${reactivity_esmBundler.unref(w)}px`,
      "a26aec42": `${reactivity_esmBundler.unref(h)}px`,
      "225bc0d6": `${reactivity_esmBundler.unref(flipperWidth)}px`,
      "bd636264": `${reactivity_esmBundler.unref(flipperHeight)}px`,
      "48414a19": reactivity_esmBundler.unref(flipperTextColor)
    }));
    const { w, h } = reactivity_esmBundler.toRefs(props.chartConfig.attr);
    const {
      dataset,
      useEndDate,
      endDate,
      style,
      showDay,
      flipperBgColor,
      flipperTextColor,
      flipperWidth,
      flipperHeight,
      flipperRadius,
      flipperGap,
      flipperType,
      flipperSpeed
    } = reactivity_esmBundler.toRefs(props.chartConfig.option);
    const countdownRef = reactivity_esmBundler.ref();
    const countdownActive = reactivity_esmBundler.ref(false);
    const totalDuration = reactivity_esmBundler.ref(dataset.value * 1e3);
    const daysFlipperData = reactivity_esmBundler.ref([]);
    const hoursFlipperData = reactivity_esmBundler.ref([]);
    const minutesFlipperData = reactivity_esmBundler.ref([]);
    const secondsFlipperData = reactivity_esmBundler.ref([]);
    const getFlipperData = (val) => {
      const len = Math.max(val.toString().length, 2);
      return val.toString().padStart(len, "0").split("");
    };
    const updateDatasetHandler = (hours, minutes, seconds) => {
      const days = Math.floor(hours / 24);
      daysFlipperData.value = getFlipperData(days);
      hoursFlipperData.value = getFlipperData(showDay.value ? hours % 24 : hours);
      minutesFlipperData.value = getFlipperData(minutes);
      secondsFlipperData.value = getFlipperData(seconds);
    };
    const renderCountdown = ({ hours, minutes, seconds }) => {
      updateDatasetHandler(hours, minutes, seconds);
    };
    const updateTotalDuration = () => {
      var _a, _b;
      try {
        countdownActive.value = false;
        totalDuration.value = useEndDate.value ? endDate.value - (/* @__PURE__ */ new Date()).getTime() : dataset.value * 1e3;
        ((_a = countdownRef.value) == null ? void 0 : _a.reset) && ((_b = countdownRef.value) == null ? void 0 : _b.reset());
        countdownActive.value = true;
      } catch (error) {
        console.log(error);
      }
    };
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.dataset,
      () => {
        updateTotalDuration();
      },
      {
        immediate: true
      }
    );
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.endDate,
      () => {
        updateTotalDuration();
      },
      {
        immediate: true
      }
    );
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.useEndDate,
      () => {
        updateTotalDuration();
      },
      {
        immediate: true
      }
    );
    runtimeCore_esmBundler.onMounted(() => {
      updateTotalDuration();
    });
    return (_ctx, _cache) => {
      const _component_n_countdown = runtimeCore_esmBundler.resolveComponent("n-countdown");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", null, [
        runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_countdown, {
          ref_key: "countdownRef",
          ref: countdownRef,
          duration: totalDuration.value,
          render: renderCountdown,
          active: countdownActive.value
        }, null, 8, ["duration", "active"]), [
          [runtimeDom_esmBundler.vShow, false]
        ]),
        runtimeCore_esmBundler.createVNode(_component_n_space, {
          class: "go-decorates-more-countdown",
          size: reactivity_esmBundler.unref(flipperGap),
          align: "center",
          justify: "center"
        }, {
          default: runtimeCore_esmBundler.withCtx(() => [
            reactivity_esmBundler.unref(showDay) ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, { key: 0 }, [
              (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(daysFlipperData.value, (item, index$1) => {
                return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index.default), {
                  count: item,
                  width: reactivity_esmBundler.unref(flipperWidth),
                  height: reactivity_esmBundler.unref(flipperHeight),
                  "front-color": reactivity_esmBundler.unref(flipperTextColor),
                  "back-color": reactivity_esmBundler.unref(flipperBgColor),
                  radius: reactivity_esmBundler.unref(flipperRadius),
                  "flip-type": reactivity_esmBundler.unref(flipperType),
                  duration: reactivity_esmBundler.unref(flipperSpeed),
                  key: index$1,
                  class: "go-d-block"
                }, null, 8, ["count", "width", "height", "front-color", "back-color", "radius", "flip-type", "duration"]);
              }), 128)),
              reactivity_esmBundler.unref(style) === "时分秒" ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_1, "天")) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_2, ":"))
            ], 64)) : runtimeCore_esmBundler.createCommentVNode("", true),
            (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(hoursFlipperData.value, (item, index$1) => {
              return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index.default), {
                count: item,
                width: reactivity_esmBundler.unref(flipperWidth),
                height: reactivity_esmBundler.unref(flipperHeight),
                "front-color": reactivity_esmBundler.unref(flipperTextColor),
                "back-color": reactivity_esmBundler.unref(flipperBgColor),
                radius: reactivity_esmBundler.unref(flipperRadius),
                "flip-type": reactivity_esmBundler.unref(flipperType),
                duration: reactivity_esmBundler.unref(flipperSpeed),
                key: index$1,
                class: "go-d-block"
              }, null, 8, ["count", "width", "height", "front-color", "back-color", "radius", "flip-type", "duration"]);
            }), 128)),
            reactivity_esmBundler.unref(style) === "时分秒" ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_3, "时")) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_4, ":")),
            (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(minutesFlipperData.value, (item, index$1) => {
              return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index.default), {
                count: item,
                width: reactivity_esmBundler.unref(flipperWidth),
                height: reactivity_esmBundler.unref(flipperHeight),
                "front-color": reactivity_esmBundler.unref(flipperTextColor),
                "back-color": reactivity_esmBundler.unref(flipperBgColor),
                radius: reactivity_esmBundler.unref(flipperRadius),
                "flip-type": reactivity_esmBundler.unref(flipperType),
                duration: reactivity_esmBundler.unref(flipperSpeed),
                key: index$1,
                class: "go-d-block"
              }, null, 8, ["count", "width", "height", "front-color", "back-color", "radius", "flip-type", "duration"]);
            }), 128)),
            reactivity_esmBundler.unref(style) === "时分秒" ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_5, "分")) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_6, ":")),
            (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(secondsFlipperData.value, (item, index$1) => {
              return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index.default), {
                count: item,
                width: reactivity_esmBundler.unref(flipperWidth),
                height: reactivity_esmBundler.unref(flipperHeight),
                "front-color": reactivity_esmBundler.unref(flipperTextColor),
                "back-color": reactivity_esmBundler.unref(flipperBgColor),
                radius: reactivity_esmBundler.unref(flipperRadius),
                "flip-type": reactivity_esmBundler.unref(flipperType),
                duration: reactivity_esmBundler.unref(flipperSpeed),
                key: index$1,
                class: "go-d-block"
              }, null, 8, ["count", "width", "height", "front-color", "back-color", "radius", "flip-type", "duration"]);
            }), 128)),
            reactivity_esmBundler.unref(style) === "时分秒" ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_7, "秒")) : runtimeCore_esmBundler.createCommentVNode("", true)
          ]),
          _: 1
        }, 8, ["size"])
      ]);
    };
  }
});
exports.default = _sfc_main;
