UNPKG

@digitalcrafted/vue-scheduler

Version:

A Vue 3 scheduler component with day/week/month/year views for displaying calendar events

1,303 lines (1,302 loc) 47.7 kB
import { ref as gt, computed as X, watch as _t, defineComponent as ot, createElementBlock as _, openBlock as b, createElementVNode as T, createCommentVNode as ut, toDisplayString as K, Fragment as N, renderList as j, normalizeStyle as st, unref as A, createBlock as it, createVNode as pt, normalizeClass as yt } from "vue"; var ft = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function ht(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Yt = { exports: {} }; (function(e, r) { (function(o, n) { e.exports = n(); })(ft, function() { var o = 1e3, n = 6e4, u = 36e5, $ = "millisecond", m = "second", p = "minute", s = "hour", h = "day", a = "week", t = "month", d = "quarter", f = "year", M = "date", g = "Invalid Date", v = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, Y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, S = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(D) { var l = ["th", "st", "nd", "rd"], i = D % 100; return "[" + D + (l[(i - 20) % 10] || l[i] || l[0]) + "]"; } }, x = function(D, l, i) { var y = String(D); return !y || y.length >= l ? D : "" + Array(l + 1 - y.length).join(i) + D; }, F = { s: x, z: function(D) { var l = -D.utcOffset(), i = Math.abs(l), y = Math.floor(i / 60), c = i % 60; return (l <= 0 ? "+" : "-") + x(y, 2, "0") + ":" + x(c, 2, "0"); }, m: function D(l, i) { if (l.date() < i.date()) return -D(i, l); var y = 12 * (i.year() - l.year()) + (i.month() - l.month()), c = l.clone().add(y, t), w = i - c < 0, k = l.clone().add(y + (w ? -1 : 1), t); return +(-(y + (i - c) / (w ? c - k : k - c)) || 0); }, a: function(D) { return D < 0 ? Math.ceil(D) || 0 : Math.floor(D); }, p: function(D) { return { M: t, y: f, w: a, d: h, D: M, h: s, m: p, s: m, ms: $, Q: d }[D] || String(D || "").toLowerCase().replace(/s$/, ""); }, u: function(D) { return D === void 0; } }, C = "en", V = {}; V[C] = S; var B = "$isDayjsObject", Z = function(D) { return D instanceof R || !(!D || !D[B]); }, I = function D(l, i, y) { var c; if (!l) return C; if (typeof l == "string") { var w = l.toLowerCase(); V[w] && (c = w), i && (V[w] = i, c = w); var k = l.split("-"); if (!c && k.length > 1) return D(k[0]); } else { var O = l.name; V[O] = l, c = O; } return !y && c && (C = c), c || !y && C; }, L = function(D, l) { if (Z(D)) return D.clone(); var i = typeof l == "object" ? l : {}; return i.date = D, i.args = arguments, new R(i); }, E = F; E.l = I, E.i = Z, E.w = function(D, l) { return L(D, { locale: l.$L, utc: l.$u, x: l.$x, $offset: l.$offset }); }; var R = function() { function D(i) { this.$L = I(i.locale, null, !0), this.parse(i), this.$x = this.$x || i.x || {}, this[B] = !0; } var l = D.prototype; return l.parse = function(i) { this.$d = function(y) { var c = y.date, w = y.utc; if (c === null) return /* @__PURE__ */ new Date(NaN); if (E.u(c)) return /* @__PURE__ */ new Date(); if (c instanceof Date) return new Date(c); if (typeof c == "string" && !/Z$/i.test(c)) { var k = c.match(v); if (k) { var O = k[2] - 1 || 0, W = (k[7] || "0").substring(0, 3); return w ? new Date(Date.UTC(k[1], O, k[3] || 1, k[4] || 0, k[5] || 0, k[6] || 0, W)) : new Date(k[1], O, k[3] || 1, k[4] || 0, k[5] || 0, k[6] || 0, W); } } return new Date(c); }(i), this.init(); }, l.init = function() { var i = this.$d; this.$y = i.getFullYear(), this.$M = i.getMonth(), this.$D = i.getDate(), this.$W = i.getDay(), this.$H = i.getHours(), this.$m = i.getMinutes(), this.$s = i.getSeconds(), this.$ms = i.getMilliseconds(); }, l.$utils = function() { return E; }, l.isValid = function() { return this.$d.toString() !== g; }, l.isSame = function(i, y) { var c = L(i); return this.startOf(y) <= c && c <= this.endOf(y); }, l.isAfter = function(i, y) { return L(i) < this.startOf(y); }, l.isBefore = function(i, y) { return this.endOf(y) < L(i); }, l.$g = function(i, y, c) { return E.u(i) ? this[y] : this.set(c, i); }, l.unix = function() { return Math.floor(this.valueOf() / 1e3); }, l.valueOf = function() { return this.$d.getTime(); }, l.startOf = function(i, y) { var c = this, w = !!E.u(y) || y, k = E.p(i), O = function(G, z) { var q = E.w(c.$u ? Date.UTC(c.$y, z, G) : new Date(c.$y, z, G), c); return w ? q : q.endOf(h); }, W = function(G, z) { return E.w(c.toDate()[G].apply(c.toDate("s"), (w ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(z)), c); }, H = this.$W, U = this.$M, Q = this.$D, nt = "set" + (this.$u ? "UTC" : ""); switch (k) { case f: return w ? O(1, 0) : O(31, 11); case t: return w ? O(1, U) : O(0, U + 1); case a: var tt = this.$locale().weekStart || 0, at = (H < tt ? H + 7 : H) - tt; return O(w ? Q - at : Q + (6 - at), U); case h: case M: return W(nt + "Hours", 0); case s: return W(nt + "Minutes", 1); case p: return W(nt + "Seconds", 2); case m: return W(nt + "Milliseconds", 3); default: return this.clone(); } }, l.endOf = function(i) { return this.startOf(i, !1); }, l.$set = function(i, y) { var c, w = E.p(i), k = "set" + (this.$u ? "UTC" : ""), O = (c = {}, c[h] = k + "Date", c[M] = k + "Date", c[t] = k + "Month", c[f] = k + "FullYear", c[s] = k + "Hours", c[p] = k + "Minutes", c[m] = k + "Seconds", c[$] = k + "Milliseconds", c)[w], W = w === h ? this.$D + (y - this.$W) : y; if (w === t || w === f) { var H = this.clone().set(M, 1); H.$d[O](W), H.init(), this.$d = H.set(M, Math.min(this.$D, H.daysInMonth())).$d; } else O && this.$d[O](W); return this.init(), this; }, l.set = function(i, y) { return this.clone().$set(i, y); }, l.get = function(i) { return this[E.p(i)](); }, l.add = function(i, y) { var c, w = this; i = Number(i); var k = E.p(y), O = function(U) { var Q = L(w); return E.w(Q.date(Q.date() + Math.round(U * i)), w); }; if (k === t) return this.set(t, this.$M + i); if (k === f) return this.set(f, this.$y + i); if (k === h) return O(1); if (k === a) return O(7); var W = (c = {}, c[p] = n, c[s] = u, c[m] = o, c)[k] || 1, H = this.$d.getTime() + i * W; return E.w(H, this); }, l.subtract = function(i, y) { return this.add(-1 * i, y); }, l.format = function(i) { var y = this, c = this.$locale(); if (!this.isValid()) return c.invalidDate || g; var w = i || "YYYY-MM-DDTHH:mm:ssZ", k = E.z(this), O = this.$H, W = this.$m, H = this.$M, U = c.weekdays, Q = c.months, nt = c.meridiem, tt = function(z, q, et, rt) { return z && (z[q] || z(y, w)) || et[q].slice(0, rt); }, at = function(z) { return E.s(O % 12 || 12, z, "0"); }, G = nt || function(z, q, et) { var rt = z < 12 ? "AM" : "PM"; return et ? rt.toLowerCase() : rt; }; return w.replace(Y, function(z, q) { return q || function(et) { switch (et) { case "YY": return String(y.$y).slice(-2); case "YYYY": return E.s(y.$y, 4, "0"); case "M": return H + 1; case "MM": return E.s(H + 1, 2, "0"); case "MMM": return tt(c.monthsShort, H, Q, 3); case "MMMM": return tt(Q, H); case "D": return y.$D; case "DD": return E.s(y.$D, 2, "0"); case "d": return String(y.$W); case "dd": return tt(c.weekdaysMin, y.$W, U, 2); case "ddd": return tt(c.weekdaysShort, y.$W, U, 3); case "dddd": return U[y.$W]; case "H": return String(O); case "HH": return E.s(O, 2, "0"); case "h": return at(1); case "hh": return at(2); case "a": return G(O, W, !0); case "A": return G(O, W, !1); case "m": return String(W); case "mm": return E.s(W, 2, "0"); case "s": return String(y.$s); case "ss": return E.s(y.$s, 2, "0"); case "SSS": return E.s(y.$ms, 3, "0"); case "Z": return k; } return null; }(z) || k.replace(":", ""); }); }, l.utcOffset = function() { return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); }, l.diff = function(i, y, c) { var w, k = this, O = E.p(y), W = L(i), H = (W.utcOffset() - this.utcOffset()) * n, U = this - W, Q = function() { return E.m(k, W); }; switch (O) { case f: w = Q() / 12; break; case t: w = Q(); break; case d: w = Q() / 3; break; case a: w = (U - H) / 6048e5; break; case h: w = (U - H) / 864e5; break; case s: w = U / u; break; case p: w = U / n; break; case m: w = U / o; break; default: w = U; } return c ? w : E.a(w); }, l.daysInMonth = function() { return this.endOf(t).$D; }, l.$locale = function() { return V[this.$L]; }, l.locale = function(i, y) { if (!i) return this.$L; var c = this.clone(), w = I(i, y, !0); return w && (c.$L = w), c; }, l.clone = function() { return E.w(this.$d, this); }, l.toDate = function() { return new Date(this.valueOf()); }, l.toJSON = function() { return this.isValid() ? this.toISOString() : null; }, l.toISOString = function() { return this.$d.toISOString(); }, l.toString = function() { return this.$d.toUTCString(); }, D; }(), J = R.prototype; return L.prototype = J, [["$ms", $], ["$s", m], ["$m", p], ["$H", s], ["$W", h], ["$M", t], ["$y", f], ["$D", M]].forEach(function(D) { J[D[1]] = function(l) { return this.$g(l, D[0], D[1]); }; }), L.extend = function(D, l) { return D.$i || (D(l, R, L), D.$i = !0), L; }, L.locale = I, L.isDayjs = Z, L.unix = function(D) { return L(1e3 * D); }, L.en = V[C], L.Ls = V, L.p = {}, L; }); })(Yt); var Vt = Yt.exports; const ct = /* @__PURE__ */ ht(Vt); var Ot = { exports: {} }; (function(e, r) { (function(o, n) { e.exports = n(); })(ft, function() { var o = "minute", n = /[+-]\d\d(?::?\d\d)?/g, u = /([+-]|\d\d)/g; return function($, m, p) { var s = m.prototype; p.utc = function(g) { var v = { date: g, utc: !0, args: arguments }; return new m(v); }, s.utc = function(g) { var v = p(this.toDate(), { locale: this.$L, utc: !0 }); return g ? v.add(this.utcOffset(), o) : v; }, s.local = function() { return p(this.toDate(), { locale: this.$L, utc: !1 }); }; var h = s.parse; s.parse = function(g) { g.utc && (this.$u = !0), this.$utils().u(g.$offset) || (this.$offset = g.$offset), h.call(this, g); }; var a = s.init; s.init = function() { if (this.$u) { var g = this.$d; this.$y = g.getUTCFullYear(), this.$M = g.getUTCMonth(), this.$D = g.getUTCDate(), this.$W = g.getUTCDay(), this.$H = g.getUTCHours(), this.$m = g.getUTCMinutes(), this.$s = g.getUTCSeconds(), this.$ms = g.getUTCMilliseconds(); } else a.call(this); }; var t = s.utcOffset; s.utcOffset = function(g, v) { var Y = this.$utils().u; if (Y(g)) return this.$u ? 0 : Y(this.$offset) ? t.call(this) : this.$offset; if (typeof g == "string" && (g = function(C) { C === void 0 && (C = ""); var V = C.match(n); if (!V) return null; var B = ("" + V[0]).match(u) || ["-", 0, 0], Z = B[0], I = 60 * +B[1] + +B[2]; return I === 0 ? 0 : Z === "+" ? I : -I; }(g), g === null)) return this; var S = Math.abs(g) <= 16 ? 60 * g : g; if (S === 0) return this.utc(v); var x = this.clone(); if (v) return x.$offset = S, x.$u = !1, x; var F = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset(); return (x = this.local().add(S + F, o)).$offset = S, x.$x.$localOffset = F, x; }; var d = s.format; s.format = function(g) { var v = g || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : ""); return d.call(this, v); }, s.valueOf = function() { var g = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()); return this.$d.valueOf() - 6e4 * g; }, s.isUTC = function() { return !!this.$u; }, s.toISOString = function() { return this.toDate().toISOString(); }, s.toString = function() { return this.toDate().toUTCString(); }; var f = s.toDate; s.toDate = function(g) { return g === "s" && this.$offset ? p(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : f.call(this); }; var M = s.diff; s.diff = function(g, v, Y) { if (g && this.$u === g.$u) return M.call(this, g, v, Y); var S = this.local(), x = p(g).local(); return M.call(S, x, v, Y); }; }; }); })(Ot); var Pt = Ot.exports; const It = /* @__PURE__ */ ht(Pt); var Tt = { exports: {} }; (function(e, r) { (function(o, n) { e.exports = n(); })(ft, function() { var o = "day"; return function(n, u, $) { var m = function(h) { return h.add(4 - h.isoWeekday(), o); }, p = u.prototype; p.isoWeekYear = function() { return m(this).year(); }, p.isoWeek = function(h) { if (!this.$utils().u(h)) return this.add(7 * (h - this.isoWeek()), o); var a, t, d, f, M = m(this), g = (a = this.isoWeekYear(), t = this.$u, d = (t ? $.utc : $)().year(a).startOf("year"), f = 4 - d.isoWeekday(), d.isoWeekday() > 4 && (f += 7), d.add(f, o)); return M.diff(g, "week") + 1; }, p.isoWeekday = function(h) { return this.$utils().u(h) ? this.day() || 7 : this.day(this.day() % 7 ? h : h - 7); }; var s = p.startOf; p.startOf = function(h, a) { var t = this.$utils(), d = !!t.u(a) || a; return t.p(h) === "isoweek" ? d ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : s.bind(this)(h, a); }; }; }); })(Tt); var Ut = Tt.exports; const Nt = /* @__PURE__ */ ht(Ut); var Et = { exports: {} }; (function(e, r) { (function(o, n) { e.exports = n(); })(ft, function() { return function(o, n, u) { var $ = n.prototype, m = function(t) { return t && (t.indexOf ? t : t.s); }, p = function(t, d, f, M, g) { var v = t.name ? t : t.$locale(), Y = m(v[d]), S = m(v[f]), x = Y || S.map(function(C) { return C.slice(0, M); }); if (!g) return x; var F = v.weekStart; return x.map(function(C, V) { return x[(V + (F || 0)) % 7]; }); }, s = function() { return u.Ls[u.locale()]; }, h = function(t, d) { return t.formats[d] || function(f) { return f.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(M, g, v) { return g || v.slice(1); }); }(t.formats[d.toUpperCase()]); }, a = function() { var t = this; return { months: function(d) { return d ? d.format("MMMM") : p(t, "months"); }, monthsShort: function(d) { return d ? d.format("MMM") : p(t, "monthsShort", "months", 3); }, firstDayOfWeek: function() { return t.$locale().weekStart || 0; }, weekdays: function(d) { return d ? d.format("dddd") : p(t, "weekdays"); }, weekdaysMin: function(d) { return d ? d.format("dd") : p(t, "weekdaysMin", "weekdays", 2); }, weekdaysShort: function(d) { return d ? d.format("ddd") : p(t, "weekdaysShort", "weekdays", 3); }, longDateFormat: function(d) { return h(t.$locale(), d); }, meridiem: this.$locale().meridiem, ordinal: this.$locale().ordinal }; }; $.localeData = function() { return a.bind(this)(); }, u.localeData = function() { var t = s(); return { firstDayOfWeek: function() { return t.weekStart || 0; }, weekdays: function() { return u.weekdays(); }, weekdaysShort: function() { return u.weekdaysShort(); }, weekdaysMin: function() { return u.weekdaysMin(); }, months: function() { return u.months(); }, monthsShort: function() { return u.monthsShort(); }, longDateFormat: function(d) { return h(t, d); }, meridiem: t.meridiem, ordinal: t.ordinal }; }, u.months = function() { return p(s(), "months"); }, u.monthsShort = function() { return p(s(), "monthsShort", "months", 3); }, u.weekdays = function(t) { return p(s(), "weekdays", null, null, t); }, u.weekdaysShort = function(t) { return p(s(), "weekdaysShort", "weekdays", 3, t); }, u.weekdaysMin = function(t) { return p(s(), "weekdaysMin", "weekdays", 2, t); }; }; }); })(Et); var jt = Et.exports; const zt = /* @__PURE__ */ ht(jt); var Ct = { exports: {} }; (function(e, r) { (function(o, n) { e.exports = n(); })(ft, function() { var o = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, n = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, u = /\d/, $ = /\d\d/, m = /\d\d?/, p = /\d*[^-_:/,()\s\d]+/, s = {}, h = function(v) { return (v = +v) + (v > 68 ? 1900 : 2e3); }, a = function(v) { return function(Y) { this[v] = +Y; }; }, t = [/[+-]\d\d:?(\d\d)?|Z/, function(v) { (this.zone || (this.zone = {})).offset = function(Y) { if (!Y || Y === "Z") return 0; var S = Y.match(/([+-]|\d\d)/g), x = 60 * S[1] + (+S[2] || 0); return x === 0 ? 0 : S[0] === "+" ? -x : x; }(v); }], d = function(v) { var Y = s[v]; return Y && (Y.indexOf ? Y : Y.s.concat(Y.f)); }, f = function(v, Y) { var S, x = s.meridiem; if (x) { for (var F = 1; F <= 24; F += 1) if (v.indexOf(x(F, 0, Y)) > -1) { S = F > 12; break; } } else S = v === (Y ? "pm" : "PM"); return S; }, M = { A: [p, function(v) { this.afternoon = f(v, !1); }], a: [p, function(v) { this.afternoon = f(v, !0); }], Q: [u, function(v) { this.month = 3 * (v - 1) + 1; }], S: [u, function(v) { this.milliseconds = 100 * +v; }], SS: [$, function(v) { this.milliseconds = 10 * +v; }], SSS: [/\d{3}/, function(v) { this.milliseconds = +v; }], s: [m, a("seconds")], ss: [m, a("seconds")], m: [m, a("minutes")], mm: [m, a("minutes")], H: [m, a("hours")], h: [m, a("hours")], HH: [m, a("hours")], hh: [m, a("hours")], D: [m, a("day")], DD: [$, a("day")], Do: [p, function(v) { var Y = s.ordinal, S = v.match(/\d+/); if (this.day = S[0], Y) for (var x = 1; x <= 31; x += 1) Y(x).replace(/\[|\]/g, "") === v && (this.day = x); }], w: [m, a("week")], ww: [$, a("week")], M: [m, a("month")], MM: [$, a("month")], MMM: [p, function(v) { var Y = d("months"), S = (d("monthsShort") || Y.map(function(x) { return x.slice(0, 3); })).indexOf(v) + 1; if (S < 1) throw new Error(); this.month = S % 12 || S; }], MMMM: [p, function(v) { var Y = d("months").indexOf(v) + 1; if (Y < 1) throw new Error(); this.month = Y % 12 || Y; }], Y: [/[+-]?\d+/, a("year")], YY: [$, function(v) { this.year = h(v); }], YYYY: [/\d{4}/, a("year")], Z: t, ZZ: t }; function g(v) { var Y, S; Y = v, S = s && s.formats; for (var x = (v = Y.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function(L, E, R) { var J = R && R.toUpperCase(); return E || S[R] || o[R] || S[J].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(D, l, i) { return l || i.slice(1); }); })).match(n), F = x.length, C = 0; C < F; C += 1) { var V = x[C], B = M[V], Z = B && B[0], I = B && B[1]; x[C] = I ? { regex: Z, parser: I } : V.replace(/^\[|\]$/g, ""); } return function(L) { for (var E = {}, R = 0, J = 0; R < F; R += 1) { var D = x[R]; if (typeof D == "string") J += D.length; else { var l = D.regex, i = D.parser, y = L.slice(J), c = l.exec(y)[0]; i.call(E, c), L = L.replace(c, ""); } } return function(w) { var k = w.afternoon; if (k !== void 0) { var O = w.hours; k ? O < 12 && (w.hours += 12) : O === 12 && (w.hours = 0), delete w.afternoon; } }(E), E; }; } return function(v, Y, S) { S.p.customParseFormat = !0, v && v.parseTwoDigitYear && (h = v.parseTwoDigitYear); var x = Y.prototype, F = x.parse; x.parse = function(C) { var V = C.date, B = C.utc, Z = C.args; this.$u = B; var I = Z[1]; if (typeof I == "string") { var L = Z[2] === !0, E = Z[3] === !0, R = L || E, J = Z[2]; E && (J = Z[2]), s = this.$locale(), !L && J && (s = S.Ls[J]), this.$d = function(y, c, w, k) { try { if (["x", "X"].indexOf(c) > -1) return new Date((c === "X" ? 1e3 : 1) * y); var O = g(c)(y), W = O.year, H = O.month, U = O.day, Q = O.hours, nt = O.minutes, tt = O.seconds, at = O.milliseconds, G = O.zone, z = O.week, q = /* @__PURE__ */ new Date(), et = U || (W || H ? 1 : q.getDate()), rt = W || q.getFullYear(), vt = 0; W && !H || (vt = H > 0 ? H - 1 : q.getMonth()); var mt, $t = Q || 0, Dt = nt || 0, Mt = tt || 0, wt = at || 0; return G ? new Date(Date.UTC(rt, vt, et, $t, Dt, Mt, wt + 60 * G.offset * 1e3)) : w ? new Date(Date.UTC(rt, vt, et, $t, Dt, Mt, wt)) : (mt = new Date(rt, vt, et, $t, Dt, Mt, wt), z && (mt = k(mt).week(z).toDate()), mt); } catch { return /* @__PURE__ */ new Date(""); } }(V, I, B, S), this.init(), J && J !== !0 && (this.$L = this.locale(J).$L), R && V != this.format(I) && (this.$d = /* @__PURE__ */ new Date("")), s = {}; } else if (I instanceof Array) for (var D = I.length, l = 1; l <= D; l += 1) { Z[1] = I[l - 1]; var i = S.apply(this, Z); if (i.isValid()) { this.$d = i.$d, this.$L = i.$L, this.init(); break; } l === D && (this.$d = /* @__PURE__ */ new Date("")); } else F.call(this, C); }; }; }); })(Ct); var Zt = Ct.exports; const Rt = /* @__PURE__ */ ht(Zt); ct.extend(It); ct.extend(Nt); ct.extend(zt); ct.extend(Rt); function P(e) { return ct(e); } function bt(e) { return P(e).format("YYYY-MM-DD"); } function xt(e) { return P(e).startOf("day"); } function Lt(e) { return P(e).endOf("day"); } function Bt(e) { return P(e).startOf("isoWeek"); } function Jt(e) { return P(e).startOf("month"); } function Qt(e) { return P(e).endOf("month"); } function Kt(e) { const r = P(e); return { start: r.startOf("day").toDate(), end: r.endOf("day").toDate() }; } function Xt(e) { const r = P(e); return { start: r.startOf("isoWeek").toDate(), end: r.endOf("isoWeek").toDate() }; } function qt(e) { const r = P(e); return { start: r.startOf("month").toDate(), end: r.endOf("month").toDate() }; } function Gt(e) { const r = P(e); return { start: r.startOf("year").toDate(), end: r.endOf("year").toDate() }; } function te(e, r) { const o = P(e); switch (r) { case "day": return o.subtract(1, "day").toDate(); case "week": return o.subtract(1, "week").toDate(); case "month": return o.subtract(1, "month").toDate(); case "year": return o.subtract(1, "year").toDate(); } } function ee(e, r) { const o = P(e); switch (r) { case "day": return o.add(1, "day").toDate(); case "week": return o.add(1, "week").toDate(); case "month": return o.add(1, "month").toDate(); case "year": return o.add(1, "year").toDate(); } } function ne(e, r, o) { const n = P(e); switch (o && ct.locale(o), r) { case "day": return n.format("MMMM D, YYYY"); case "week": const u = n.startOf("isoWeek"), $ = n.endOf("isoWeek"); return u.month() === $.month() ? `Week of ${u.format("MMM D")} - ${$.format( "D, YYYY" )}` : `Week of ${u.format("MMM D")} - ${$.format( "MMM D, YYYY" )}`; case "month": return n.format("MMMM YYYY"); case "year": return n.format("YYYY"); } } function re(e) { const r = Bt(e), o = []; for (let n = 0; n < 7; n++) o.push(r.add(n, "day").toDate()); return o; } function Wt(e) { const r = Jt(e), o = Qt(e), n = r.startOf("isoWeek"), u = o.endOf("isoWeek"), $ = []; let m = n; for (; m.isBefore(u) || m.isSame(u, "day"); ) $.push(m.toDate()), m = m.add(1, "day"); return $; } function kt(e, r) { return P(e).isSame(P(r), "day"); } function se(e, r = "week", o) { const n = gt( e ? P(e).toDate() : /* @__PURE__ */ new Date() ), u = gt(r), $ = X(() => ne(n.value, u.value, o)), m = X(() => { switch (u.value) { case "day": return Kt(n.value); case "week": return Xt(n.value); case "month": return qt(n.value); case "year": return Gt(n.value); } }); return { currentDate: n, viewMode: u, periodLabel: $, dateRange: m, goToToday: () => { n.value = /* @__PURE__ */ new Date(); }, goToPrevious: () => { n.value = te(n.value, u.value); }, goToNext: () => { n.value = ee(n.value, u.value); }, setViewMode: (d) => { u.value = d; }, setCurrentDate: (d) => { n.value = d; } }; } function St(e) { const r = P(e.start), o = e.end ? P(e.end) : r, n = r.toDate(), u = o.toDate(), $ = r.hour() !== 0 || r.minute() !== 0 || r.second() !== 0, m = e.end ? o.hour() !== 0 || o.minute() !== 0 || o.second() !== 0 : !1, p = !$ && !m, s = Math.ceil( (u.getTime() - n.getTime()) / (1e3 * 60 * 60 * 24) ) || 1; return { ...e, startDate: n, endDate: u, isAllDay: p, duration: s }; } function ae(e, r) { const o = e.startDate, n = e.endDate || e.startDate; return o <= r.end && n >= r.start; } function At(e, r) { return e.filter((o) => ae(o, r)); } function lt(e, r) { const o = xt(r).toDate(), n = Lt(r).toDate(); return At(e, { start: o, end: n }); } function oe(e) { return e.duration > 1 || !ie(e.startDate, e.endDate); } function ie(e, r) { return bt(e) === bt(r); } function Ht(e, r) { const o = xt(r).toDate(), n = Lt(r).toDate(); return e.endDate < o || e.startDate > n ? null : { ...e, startDate: e.startDate > o ? e.startDate : o, endDate: e.endDate < n ? e.endDate : n }; } function Ft(e, r, o = 60) { const n = xt(r).toDate(); if (e.isAllDay) return { top: 0, height: 30 }; const u = e.startDate, $ = e.endDate || e.startDate, m = (u.getTime() - n.getTime()) / (1e3 * 60), p = ($.getTime() - n.getTime()) / (1e3 * 60), s = o / 60, h = Math.max(0, m * s), a = Math.max(20, (p - m) * s); return { top: h, height: a }; } function ue(e, r) { const o = gt([]), n = gt(!1), u = typeof e == "function", $ = async () => { if (!u) { o.value = e.map(St); return; } n.value = !0; try { e({ dateRange: r.value, setEvents: (s) => { o.value = s.map(St), n.value = !1; } }); } catch (p) { console.error("Error loading events:", p), n.value = !1; } }, m = X(() => At(o.value, r.value)); return u && _t( r, () => { $(); }, { deep: !0 } ), $(), { events: o, visibleEvents: m, loading: n, reload: $ }; } const le = { class: "flex items-center justify-between p-4 border-b bg-white" }, ce = { class: "flex items-center gap-2" }, de = { class: "flex-1 text-center" }, fe = { class: "text-lg font-semibold text-gray-900" }, he = { key: 0, class: "flex items-center gap-2" }, ve = ["value", "checked", "onChange"], me = { class: "text-sm text-gray-700" }, ye = /* @__PURE__ */ ot({ __name: "Header", props: { periodLabel: {}, currentViewMode: {}, todayLabel: { default: "today" }, hideViewModeSelector: { type: Boolean, default: !1 } }, emits: ["previous", "today", "next", "viewModeChange"], setup(e) { const r = [ { value: "day", label: "day" }, { value: "week", label: "week" }, { value: "month", label: "month" }, { value: "year", label: "year" } ]; return (o, n) => (b(), _("div", le, [ T("div", ce, [ T("button", { onClick: n[0] || (n[0] = (u) => o.$emit("previous")), class: "px-3 py-1 border rounded hover:bg-gray-50 text-gray-700", type: "button" }, " < "), T("button", { onClick: n[1] || (n[1] = (u) => o.$emit("today")), class: "px-3 py-1 border rounded hover:bg-gray-50 text-gray-700 text-sm", type: "button" }, K(e.todayLabel), 1), T("button", { onClick: n[2] || (n[2] = (u) => o.$emit("next")), class: "px-3 py-1 border rounded hover:bg-gray-50 text-gray-700", type: "button" }, " > ") ]), T("div", de, [ T("h4", fe, K(e.periodLabel), 1) ]), e.hideViewModeSelector ? ut("", !0) : (b(), _("div", he, [ (b(), _(N, null, j(r, (u) => T("label", { key: u.value, class: "flex items-center cursor-pointer" }, [ T("input", { type: "radio", value: u.value, checked: e.currentViewMode === u.value, onChange: ($) => o.$emit("viewModeChange", u.value), class: "mr-1" }, null, 40, ve), T("span", me, K(u.label), 1) ])), 64)) ])) ])); } }), ge = ["title"], dt = /* @__PURE__ */ ot({ __name: "EventRenderer", props: { event: {} }, setup(e) { const r = e, o = X(() => { const $ = (r.event.bgColor || "#3498db").replace("#", ""), m = parseInt($.substr(0, 2), 16), p = parseInt($.substr(2, 2), 16), s = parseInt($.substr(4, 2), 16); return (m * 299 + p * 587 + s * 114) / 1e3 > 155 ? "#000000" : "#ffffff"; }), n = X(() => { const u = P(r.event.start), $ = r.event.end ? P(r.event.end) : u; if (r.event.isAllDay) return r.event.duration > 1 ? `${r.event.label} - ${u.format("MMM D")} to ${$.format( "MMM D, YYYY" )}` : `${r.event.label} - ${u.format("MMM D, YYYY")}`; const m = `${u.format("h:mm A")} - ${$.format("h:mm A")}`; return r.event.duration > 1 ? `${r.event.label} - ${u.format("MMM D")} to ${$.format( "MMM D" )}, ${m}` : `${r.event.label} - ${u.format("MMM D, YYYY")}, ${m}`; }); return (u, $) => (b(), _("div", { style: st({ backgroundColor: e.event.bgColor || "#3498db", color: o.value, padding: "2px 6px", borderRadius: "4px", fontSize: "12px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", cursor: "default" }), title: n.value, class: "event-item" }, K(e.event.label), 13, ge)); } }), pe = { class: "h-full overflow-y-auto" }, $e = { class: "relative" }, De = { class: "absolute left-0 top-0 w-20 border-r bg-gray-50" }, Me = { key: 0, class: "ml-20 border-b bg-gray-50 p-2 min-h-[40px]" }, we = { class: "flex flex-wrap gap-1" }, be = { class: "ml-20 relative" }, xe = { class: "absolute inset-0" }, ke = /* @__PURE__ */ ot({ __name: "DayView", props: { date: {}, events: {} }, setup(e) { const r = e, o = Array.from({ length: 24 }, (s, h) => h), n = (s) => s === 0 ? "12 AM" : s < 12 ? `${s} AM` : s === 12 ? "12 PM" : `${s - 12} PM`, u = X(() => lt(r.events, r.date)), $ = X(() => u.value.filter((s) => s.isAllDay)), m = X(() => u.value.filter((s) => !s.isAllDay)), p = (s) => { const h = Ft( s, r.date, 64 // 64px per hour (4rem) ); return { top: `${h.top}px`, height: `${h.height}px` }; }; return (s, h) => (b(), _("div", pe, [ T("div", $e, [ T("div", De, [ (b(!0), _(N, null, j(A(o), (a) => (b(), _("div", { key: a, class: "h-16 border-b text-xs text-gray-600 p-2" }, K(n(a)), 1))), 128)) ]), $.value.length > 0 ? (b(), _("div", Me, [ T("div", we, [ (b(!0), _(N, null, j($.value, (a) => (b(), it(dt, { key: a.id || a.label, event: a }, null, 8, ["event"]))), 128)) ]) ])) : ut("", !0), T("div", be, [ T("div", xe, [ (b(!0), _(N, null, j(A(o), (a) => (b(), _("div", { key: a, class: "absolute w-full border-b border-gray-200", style: st({ top: `${a * 64}px` }) }, null, 4))), 128)), (b(!0), _(N, null, j(m.value, (a) => (b(), _("div", { key: a.id || a.label, class: "absolute left-0 right-0 px-1", style: st(p(a)) }, [ pt(dt, { event: a }, null, 8, ["event"]) ], 4))), 128)) ]), T("div", { style: st({ height: `${A(o).length * 64}px` }) }, null, 4) ]) ]) ])); } }), Se = { class: "h-full overflow-y-auto" }, _e = { class: "relative" }, Ye = { class: "flex border-b bg-gray-50 sticky top-0 z-10" }, Oe = { class: "text-xs text-gray-600" }, Te = { key: 0, class: "flex border-b bg-gray-50 min-h-[40px]" }, Ee = { class: "flex flex-wrap gap-1" }, Ce = { class: "relative" }, Le = { class: "absolute inset-0 flex" }, We = { class: "w-20 border-r bg-gray-50" }, Ae = /* @__PURE__ */ ot({ __name: "WeekView", props: { date: {}, events: {} }, setup(e) { const r = e, o = Array.from({ length: 24 }, (t, d) => d), n = X(() => re(r.date)), u = (t) => t === 0 ? "12 AM" : t < 12 ? `${t} AM` : t === 12 ? "12 PM" : `${t - 12} PM`, $ = (t) => t.toLocaleDateString("en-US", { weekday: "short" }), m = (t) => t.getDate().toString(), p = (t) => lt(r.events, t).filter((f) => f.isAllDay), s = (t) => lt(r.events, t).filter((f) => !f.isAllDay), h = X(() => n.value.some((t) => p(t).length > 0)), a = (t, d) => { const f = Ht(t, d); if (!f) return { display: "none" }; const M = Ft(f, d, 64); return { top: `${M.top}px`, height: `${M.height}px` }; }; return (t, d) => (b(), _("div", Se, [ T("div", _e, [ T("div", Ye, [ d[0] || (d[0] = T("div", { class: "w-20 border-r" }, null, -1)), (b(!0), _(N, null, j(n.value, (f) => (b(), _("div", { key: f.toISOString(), class: "flex-1 border-r p-2 text-center text-sm font-medium text-gray-700" }, [ T("div", null, K($(f)), 1), T("div", Oe, K(m(f)), 1) ]))), 128)) ]), h.value ? (b(), _("div", Te, [ d[1] || (d[1] = T("div", { class: "w-20 border-r" }, null, -1)), (b(!0), _(N, null, j(n.value, (f) => (b(), _("div", { key: f.toISOString(), class: "flex-1 border-r p-1" }, [ T("div", Ee, [ (b(!0), _(N, null, j(p(f), (M) => (b(), it(dt, { key: M.id || `${M.label}-${f.toISOString()}`, event: M }, null, 8, ["event"]))), 128)) ]) ]))), 128)) ])) : ut("", !0), T("div", Ce, [ T("div", Le, [ T("div", We, [ (b(!0), _(N, null, j(A(o), (f) => (b(), _("div", { key: f, class: "h-16 border-b text-xs text-gray-600 p-2" }, K(u(f)), 1))), 128)) ]), (b(!0), _(N, null, j(n.value, (f) => (b(), _("div", { key: f.toISOString(), class: "flex-1 border-r relative" }, [ (b(!0), _(N, null, j(A(o), (M) => (b(), _("div", { key: M, class: "absolute w-full border-b border-gray-200", style: st({ top: `${M * 64}px` }) }, null, 4))), 128)), (b(!0), _(N, null, j(s(f), (M) => (b(), _("div", { key: M.id || `${M.label}-${f.toISOString()}`, class: "absolute left-0 right-0 px-1", style: st(a(M, f)) }, [ pt(dt, { event: M }, null, 8, ["event"]) ], 4))), 128)), T("div", { style: st({ height: `${A(o).length * 64}px` }) }, null, 4) ]))), 128)) ]) ]) ]) ])); } }), He = { class: "h-full overflow-y-auto" }, Fe = { class: "grid grid-cols-7 border-b bg-gray-50 sticky top-0 z-10" }, Ve = { class: "grid grid-cols-7 relative" }, Pe = { class: "space-y-1 relative", style: { overflow: "visible", "z-index": "10" } }, Ie = { key: 0, class: "text-xs text-gray-500 mt-1" }, Ue = /* @__PURE__ */ ot({ __name: "MonthView", props: { date: {}, events: {} }, setup(e) { const r = e, o = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], n = X(() => Wt(r.date)), u = (h) => h.getMonth() === r.date.getMonth() && h.getFullYear() === r.date.getFullYear(), $ = (h) => { const a = /* @__PURE__ */ new Date(); return h.getDate() === a.getDate() && h.getMonth() === a.getMonth() && h.getFullYear() === a.getFullYear(); }, m = (h) => lt(r.events, h).map((t) => Ht(t, h)).filter((t) => t !== null), p = (h, a) => { const t = lt(r.events, h), d = []; return t.forEach((f, M) => { const g = String(f.id || `${f.label}-${bt(h)}-${M}`); if (oe(f)) { const v = new Date(f.startDate); if (v.setHours(0, 0, 0, 0), new Date(h).setHours(0, 0, 0, 0), kt(f.startDate, h) || v < n.value[0] && a === 0) { const x = s(f, a); if (x.span > 0 && x.span <= 7) { const C = (x.span - 1) * 1, V = x.span > 1 ? `calc(${x.span} * 100% + ${C}px)` : "100%"; d.push({ event: f, key: g, spanStyle: { width: V, marginRight: x.span > 1 ? `-${C}px` : "0", position: "relative", zIndex: "5" }, spanClass: "" }); } } } else d.push({ event: f, key: g, spanStyle: {}, spanClass: "" }); }), d.slice(0, 3); }, s = (h, a) => { const t = new Date(h.startDate); t.setHours(0, 0, 0, 0); const d = new Date(h.endDate); d.setHours(23, 59, 59, 999); let f = a; if (t < n.value[0]) f = 0; else for (let S = 0; S < n.value.length; S++) if (kt(n.value[S], t)) { f = S; break; } let M = 1; for (let S = f + 1; S < n.value.length; S++) { const x = n.value[S], F = new Date(x); F.setHours(0, 0, 0, 0); const C = new Date(x); if (C.setHours(23, 59, 59, 999), t <= C && d >= F) M++; else break; } const Y = Math.floor(f / 7) * 7 + 7 - f; return { span: Math.min(M, Y), startIndex: f }; }; return (h, a) => (b(), _("div", He, [ T("div", Fe, [ (b(), _(N, null, j(o, (t) => T("div", { key: t, class: "p-2 text-center text-sm font-medium text-gray-700 border-r last:border-r-0" }, K(t), 1)), 64)) ]), T("div", Ve, [ (b(!0), _(N, null, j(n.value, (t, d) => (b(), _("div", { key: t.toISOString(), class: yt([ "min-h-[100px] border-b border-r p-2 relative", u(t) ? "bg-white" : "bg-gray-50", $(t) ? "ring-2 ring-blue-500" : "" ]), style: { overflow: "visible" } }, [ T("div", { class: yt([ "text-sm mb-1", u(t) ? "text-gray-900" : "text-gray-400", $(t) ? "font-bold text-blue-600" : "" ]) }, K(t.getDate()), 3), T("div", Pe, [ (b(!0), _(N, null, j(p(t, d), (f) => (b(), _("div", { key: f.key, style: st(f.spanStyle), class: yt(f.spanClass) }, [ pt(dt, { event: f.event }, null, 8, ["event"]) ], 6))), 128)), m(t).length > 3 ? (b(), _("div", Ie, " +" + K(m(t).length - 3) + " more ", 1)) : ut("", !0) ]) ], 2))), 128)) ]) ])); } }), Ne = { class: "h-full overflow-y-auto p-4" }, je = { class: "grid grid-cols-4 gap-4" }, ze = { class: "text-center font-semibold mb-2 text-sm" }, Ze = { class: "grid grid-cols-7 gap-1 mb-1" }, Re = { class: "grid grid-cols-7 gap-1" }, Be = /* @__PURE__ */ ot({ __name: "YearView", props: { date: {}, events: {} }, setup(e) { const r = e, o = ["M", "T", "W", "T", "F", "S", "S"], n = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], u = X(() => { const s = r.date.getFullYear(); return Array.from({ length: 12 }, (h, a) => { const t = new Date(s, a, 1), d = Wt(t), f = d[0].getDay(), M = [], g = f === 0 ? 6 : f - 1; for (let v = 0; v < g; v++) M.push(/* @__PURE__ */ new Date(0)); return { month: a, name: n[a], days: [...M, ...d] }; }); }), $ = (s, h) => s.getTime() === 0 ? !1 : s.getMonth() === h, m = (s, h) => { const a = /* @__PURE__ */ new Date(); return s.getDate() === a.getDate() && s.getMonth() === a.getMonth() && s.getFullYear() === a.getFullYear() && h === a.getMonth(); }, p = (s) => s.getTime() === 0 ? !1 : lt(r.events, s).length > 0; return (s, h) => (b(), _("div", Ne, [ T("div", je, [ (b(!0), _(N, null, j(u.value, (a) => (b(), _("div", { key: a.month, class: "border rounded p-2" }, [ T("div", ze, K(a.name), 1), T("div", Ze, [ (b(), _(N, null, j(o, (t) => T("div", { key: t, class: "text-xs text-center text-gray-600" }, K(t), 1)), 64)) ]), T("div", Re, [ (b(!0), _(N, null, j(a.days, (t, d) => (b(), _("div", { key: `${a.month}-${d}`, class: yt([ "text-xs p-1 min-h-[24px] flex items-center justify-center rounded", t.getTime() === 0 ? "bg-transparent" : $(t, a.month) ? m(t, a.month) ? "bg-blue-500 text-white font-bold" : "bg-white text-gray-900" : "bg-gray-50 text-gray-400", t.getTime() !== 0 && p(t) ? "ring-1 ring-blue-300" : "" ]) }, K(t.getTime() !== 0 ? t.getDate() : ""), 3))), 128)) ]) ]))), 128)) ]) ])); } }), Je = { class: "vue-scheduler flex flex-col h-full" }, Qe = { class: "flex-1 relative overflow-hidden" }, Ke = { key: 0, class: "absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center" }, Ge = /* @__PURE__ */ ot({ __name: "Scheduler", props: { events: {}, initialDate: {}, viewMode: { default: "week" }, dateLocale: { default: void 0 }, translations: { default: () => ({}) }, hideViewModeSelector: { type: Boolean, default: !1 } }, setup(e) { const r = e, { currentDate: o, viewMode: n, periodLabel: u, dateRange: $, goToToday: m, goToPrevious: p, goToNext: s, setViewMode: h } = se(r.initialDate, r.viewMode, r.dateLocale), { visibleEvents: a, loading: t } = ue(r.events, $); _t( () => r.viewMode, (M) => { M && M !== n.value && h(M); } ); const d = X(() => { var M; return ((M = r.translations) == null ? void 0 : M["header.today"]) || "today"; }), f = (M) => { h(M); }; return (M, g) => (b(), _("div", Je, [ pt(ye, { "period-label": A(u), "current-view-mode": A(n), "today-label": d.value, "hide-view-mode-selector": r.hideViewModeSelector, onPrevious: A(p), onToday: A(m), onNext: A(s), onViewModeChange: f }, null, 8, ["period-label", "current-view-mode", "today-label", "hide-view-mode-selector", "onPrevious", "onToday", "onNext"]), T("div", Qe, [ A(n) === "day" ? (b(), it(ke, { key: 0, date: A(o), events: A(a) }, null, 8, ["date", "events"])) : A(n) === "week" ? (b(), it(Ae, { key: 1, date: A(o), events: A(a) }, null, 8, ["date", "events"])) : A(n) === "month" ? (b(), it(Ue, { key: 2, date: A(o), events: A(a) }, null, 8, ["date", "events"])) : A(n) === "year" ? (b(), it(Be, { key: 3, date: A(o), events: A(a) }, null, 8, ["date", "events"])) : ut("", !0) ]), A(t) ? (b(), _("div", Ke, [...g[0] || (g[0] = [ T("div", { class: "text-gray-600" }, "Loading events...", -1) ])])) : ut("", !0) ])); } }); export { Ge as Scheduler, Ge as default, ue as useEvents, se as useScheduler };