import { c as M, w as T } from "./utils-BjwmJovq.js"; import { defineComponent as k, ref as h, computed as N, createVNode as C, mergeProps as b } from "vue"; import { i as B, P as F } from "./vendor-BuMp2M9h.js"; const H = { type: Boolean, default: !0 }, A = [Number, String], g = (e) => ({ type: A, default: e }), E = Object.assign( {}, { modelValue: { type: Array, default: () => [] }, filter: Function, formatter: { type: Function, default: (e, a) => a }, loading: Boolean, readonly: Boolean, allowHtml: Boolean, title: String, cancelButtonText: String, confirmButtonText: String, optionHeight: g(44), showToolbar: H, swipeDuration: g(1e3), visibleOptionNum: g(6) } ); function $(e, a) { if (e < 0) return []; const o = Array(e); let c = -1; for (; ++c < e; ) o[c] = a(c); return o; } function j(e, a = 2) { let o = e + ""; for (; o.length < a; ) o = "0" + o; return o; } const l = (e, a, o, c, r, f) => { const n = $(a - e + 1, (m) => { const s = j(e + m); return c(o, { text: s, value: s }); }); return r ? r(o, n, f) : n; }, X = (e, a) => 32 - new Date(e, a - 1, 32).getDate(), i = (e) => e < 10 ? `0${e}` : `${e}`, [I] = M("datetime-picker"), R = Object.assign({}, E, { minYear: { type: Number, validator: (e) => e > 1970, default: (/* @__PURE__ */ new Date()).getFullYear() - 15 }, maxYear: { type: Number, default: (/* @__PURE__ */ new Date()).getFullYear() + 15 }, columnsType: { type: Array, default: () => ["year", "month", "day", "hour", "minute", "second"] } }), U = /* @__PURE__ */ k({ name: I, props: R, emits: ["confirm", "cancel", "change", "update:modelValue"], setup(e, { emit: a, slots: o, expose: c }) { const r = /* @__PURE__ */ new Date(), f = [String(r.getFullYear()), i(r.getMonth() + 1), i(r.getDate()), i(r.getHours()), i(r.getMinutes()), i(r.getSeconds())], n = h(B(e.modelValue) ? f : e.modelValue), m = h(), s = () => { const t = e.minYear, u = e.maxYear; return l(t, u, "year", e.formatter, e == null ? void 0 : e.filter, n.value); }, y = () => l(1, 12, "month", e.formatter, e == null ? void 0 : e.filter, n.value), v = () => { const t = n.value[0], u = n.value[1], d = 1, V = X(t ? +t : e.minYear, u ? +u : 1); return l(d, V, "day", e.formatter, e == null ? void 0 : e.filter, n.value); }, D = () => l(0, 23, "hour", e.formatter, e == null ? void 0 : e.filter, n.value), w = () => l(0, 59, "minute", e.formatter, e == null ? void 0 : e.filter, n.value), P = () => l(0, 59, "second", e.formatter, e == null ? void 0 : e.filter, n.value), x = N(() => { const t = [], u = e.columnsType.map((d) => { switch (d) { case "year": return s(); case "month": return y(); case "day": return v(); case "hour": return D(); case "minute": return w(); case "second": return P(); default: throw new Error(`[Vant] DateTimePicker: unsupported columns type: ${d}`); } }); return t.concat(u); }), Y = (...t) => { a("update:modelValue", n.value), a("change", ...t); }, O = (...t) => a("cancel", ...t), S = (...t) => a("confirm", ...t); return c({ confirm: () => { var t; return (t = m.value) == null ? void 0 : t.confirm(); }, getSelectedDate: () => n.value }), () => C(F, b({ ref: m, modelValue: n.value, "onUpdate:modelValue": (t) => n.value = t, columns: x.value }, e, { onConfirm: S, onCancel: O, onChange: Y }), o); } }), K = T(U); export { K as X };