import { defineComponent as $, ref as c, computed as y, onMounted as z, openBlock as r, createElementBlock as d, createElementVNode as i, withModifiers as D, toDisplayString as m, unref as b, Fragment as w, renderList as C, normalizeClass as I, normalizeStyle as U, withDirectives as A, vModelText as O, createCommentVNode as j } from "vue";
import { R as q, L as G } from "./index-70037f84.mjs";
import "pinia";
import "dayjs";
const J = {
  class: "cds-datepicker",
  ref: "drop"
}, K = { class: "cds-datepicker__header" }, P = ["onClick", "innerHTML"], Q = { class: "cds-datepicker__header-body" }, W = ["onClick", "innerHTML"], X = { class: "cds-datepicker__week-days" }, Z = { class: "cds-datepicker__days cds-datepicker__days--week" }, ee = { class: "cds-datepicker__day" }, te = { class: "cds-datepicker__days" }, ae = ["onClick"], le = {
  key: 0,
  class: "cds-datepicker__time"
}, ne = ["onClick"], L = "1", de = /* @__PURE__ */ $({
  __name: "index",
  props: {
    date: { default: null },
    format: { default: null },
    range: { type: Boolean, default: !1 },
    showTime: { type: Boolean, default: !1 },
    maxStart: { default: null },
    maxEnd: { default: null }
  },
  emits: ["select", "close"],
  setup(S, { emit: M }) {
    const x = S, T = { Right: q, Left: G }, u = /* @__PURE__ */ new Date(), t = c(u.getMonth()), n = c(u.getFullYear());
    let f = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"], F = [
      "Январь",
      "Февраль",
      "Март",
      "Апрель",
      "Май",
      "Июнь",
      "Июль",
      "Август",
      "Сентябрь",
      "Октябрь",
      "Ноябрь",
      "Декабрь"
    ];
    const H = y(() => {
      +L == 0 ? f = ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"] : f = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"];
    });
    u.getDate();
    const h = c("00:00"), s = c();
    c(null);
    const g = c(0), _ = c(0), p = c(0), k = y(() => {
      const e = { month: 0, year: 0, day: 0 };
      if (!s.value)
        return e;
      const l = new Date(s.value);
      return {
        month: l.getMonth(),
        year: l.getFullYear(),
        day: l.getDate()
      };
    }), B = y(() => {
      const e = [];
      let l = 0;
      e[l] = [];
      let v = new Date(n.value, t.value + 1, 0).getDate();
      for (let a = 1; a <= v; a++)
        if (Number(new Date(n.value, t.value, a).getDay()) !== Number(L)) {
          const o = { index: a };
          e[l].push(o), a === u.getDate() && n.value === u.getFullYear() && t.value === u.getMonth() && (o.current = !0), (new Date(n.value, t.value, a).getDay() === 6 || new Date(n.value, t.value, a).getDay() === 0) && (o.weekend = "var(--cds-color-danger)");
        } else {
          l++, e[l] = [];
          const o = { index: a };
          e[l].push(o), a === u.getDate() && n.value === u.getFullYear() && t.value === u.getMonth() && (o.current = !0), (new Date(n.value, t.value, a).getDay() === 6 || new Date(n.value, t.value, a).getDay() === 0) && (o.weekend = "var(--cds-color-danger)");
        }
      if (e[0].length > 0)
        for (let a = e[0].length; a < 7; a++)
          e[0].unshift("");
      return H.value, e;
    }), N = () => {
      t.value--, t.value < 0 && (t.value = 12, t.value--, n.value--);
    }, Y = () => {
      t.value++, t.value > 11 && (t.value = -1, t.value++, n.value++);
    }, E = () => {
      if (!h.value)
        return;
      const e = h.value.split(":");
      _.value = +e[0], p.value = +e[1];
    }, R = (e) => {
      if (!e)
        return;
      g.value = e;
      const l = new Date(n.value, t.value, g.value, 0, 0);
      s.value = l.toUTCString(), x.showTime || M("select", s.value);
    }, V = () => {
      const e = new Date(n.value, t.value, g.value, _.value, p.value);
      s.value = e.toISOString(), M("select", s.value);
    };
    return z(() => {
      s.value = new Date(x.date || ""), _.value = s.value.getHours(), p.value = s.value.getMinutes();
      const e = _.value > 9 ? _.value : "0" + _.value, l = p.value > 9 ? p.value : "0" + p.value;
      h.value = `${e}:${l}`;
    }), (e, l) => (r(), d("div", J, [
      i("div", K, [
        i("button", {
          class: "cds-datepicker__header-nav",
          onClick: D(N, ["prevent"]),
          innerHTML: T.Left
        }, null, 8, P),
        i("div", Q, m(b(F)[t.value]) + " " + m(n.value), 1),
        i("button", {
          class: "cds-datepicker__header-nav",
          onClick: D(Y, ["prevent"]),
          innerHTML: T.Right
        }, null, 8, W)
      ]),
      i("div", X, [
        i("div", Z, [
          (r(!0), d(w, null, C(b(f), (v) => (r(), d("div", ee, m(v), 1))), 256))
        ]),
        (r(!0), d(w, null, C(B.value, (v) => (r(), d("div", te, [
          (r(!0), d(w, null, C(v, (a, o) => (r(), d("div", {
            class: I(["cds-datepicker__day", {
              "cds-datepicker__day--selected": k.value.day === a.index && k.value.month === t.value && k.value.year === n.value,
              "cds-datepicker__day--current": a.current
            }]),
            onClick: (se) => R(a.index),
            style: U({ color: a.weekend })
          }, m(a.index), 15, ae))), 256))
        ]))), 256)),
        s.value && !e.range && e.showTime ? (r(), d("div", le, [
          A(i("input", {
            type: "time",
            onInput: E,
            class: "cds-input",
            "onUpdate:modelValue": l[0] || (l[0] = (v) => h.value = v)
          }, null, 544), [
            [O, h.value]
          ]),
          i("button", {
            onClick: D(V, ["prevent"]),
            class: "cds-btn cds-btn--success cds-btn--fill"
          }, "Выбрать ", 8, ne)
        ])) : j("", !0)
      ])
    ], 512));
  }
});
export {
  de as default
};
//# sourceMappingURL=index-d128a740.mjs.map
