import { defineComponent, ref, computed, watch, openBlock, createElementBlock, createVNode, unref, withCtx, Fragment, renderList, createBlock } from "vue";
import Select from "../common/base/Select/index.mjs";
import OPtion from "../common/base/Option/index.mjs";
import { useI18n } from "../../locales/index.mjs";
const _hoisted_1 = { class: "container" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "DurationTimePicker",
  props: {
    modelValue: {}
  },
  emits: ["input"],
  setup(__props, { emit: __emit }) {
    const { t } = useI18n();
    const props = __props;
    const emit = __emit;
    const selectedTime = ref(props.modelValue);
    const timeOptions = computed(() => {
      const options = [];
      for (let i = 15; i < 60; i += 15) {
        options.push({ value: i * 60, label: `${i} ${t("minutes")}` });
      }
      for (let i = 1; i < 24; i++) {
        options.push({ value: i * 60 * 60, label: `${i} ${t("hours")}` });
      }
      return options;
    });
    const updateTime = () => {
      emit("input", selectedTime.value);
    };
    watch(
      selectedTime,
      () => {
        updateTime();
      },
      {
        immediate: true
      }
    );
    watch(
      () => props.modelValue,
      (newValue) => {
        selectedTime.value = newValue;
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(Select), {
          modelValue: selectedTime.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedTime.value = $event),
          theme: "white",
          teleported: false,
          "custom-select-content-style": { "font-weight": 400 },
          value: selectedTime.value,
          onInput: _cache[1] || (_cache[1] = ($event) => selectedTime.value = $event)
        }, {
          default: withCtx(() => [
            (openBlock(true), createElementBlock(Fragment, null, renderList(timeOptions.value, (time) => {
              return openBlock(), createBlock(unref(OPtion), {
                key: time.value,
                theme: "white",
                value: time.value,
                label: time.label,
                "custom-option-content-style": { "font-weight": 400 }
              }, null, 8, ["value", "label"]);
            }), 128))
          ]),
          _: 1
        }, 8, ["modelValue", "value"])
      ]);
    };
  }
});
export {
  _sfc_main as default
};
