"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 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 shared_esmBundler = require("../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.js");
const _hoisted_1 = ["data-front"];
const _hoisted_2 = ["data-back"];
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    flipType: {
      type: String,
      default: () => {
        return "down";
      }
    },
    count: {
      type: [Number, String],
      default: 0
    },
    duration: {
      type: Number,
      default: 600
    },
    width: {
      type: Number,
      default: 60
    },
    height: {
      type: Number,
      default: 100
    },
    radius: {
      type: Number,
      default: 10
    },
    frontColor: {
      type: String,
      default: "#ffffff"
    },
    backColor: {
      type: String,
      default: "#000000"
    },
    borderWidth: {
      type: Number,
      default: 2
    }
  },
  setup(__props) {
    const props = __props;
    runtimeDom_esmBundler.useCssVars((_ctx) => ({
      "06b40856": props.frontColor,
      "39840b7e": props.backColor,
      "ddd97676": `${props.radius}px`,
      "43622609": `${props.width}px`,
      "4281d24c": `${props.height}px`,
      "45eb2214": `${props.height * 2}px`,
      "6026284e": `${props.borderWidth * 2}px`,
      "76a98bc6": `${props.duration / 1e3}s`
    }));
    const isFlipping = reactivity_esmBundler.ref(false);
    const frontTextFromData = reactivity_esmBundler.ref(props.count || 0);
    const backTextFromData = reactivity_esmBundler.ref(props.count || 0);
    let timeoutID = 0;
    const flip = async (front, back) => {
      if (isFlipping.value) {
        isFlipping.value = false;
        clearTimeout(timeoutID);
        await runtimeCore_esmBundler.nextTick();
        await flip(front, back);
        return;
      }
      backTextFromData.value = back;
      frontTextFromData.value = front;
      isFlipping.value = true;
      timeoutID = setTimeout(() => {
        isFlipping.value = false;
        frontTextFromData.value = back;
      }, props.duration);
    };
    runtimeCore_esmBundler.watch(
      () => props.count,
      (newVal, oldVal) => {
        flip(oldVal, newVal);
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
        class: shared_esmBundler.normalizeClass(["go-flipper", [__props.flipType, { go: isFlipping.value }]])
      }, [
        runtimeCore_esmBundler.createElementVNode("div", {
          class: "digital front",
          "data-front": frontTextFromData.value
        }, null, 8, _hoisted_1),
        runtimeCore_esmBundler.createElementVNode("div", {
          class: "digital back",
          "data-back": backTextFromData.value
        }, null, 8, _hoisted_2)
      ], 2);
    };
  }
});
exports.default = _sfc_main;
