@vue-js-cron/light
Version:
lightweight vue.js cron editor
1,979 lines • 58 kB
JavaScript
import { defineComponent as X, watch as g, ref as k, computed as fe, openBlock as O, createElementBlock as V, createElementVNode as I, normalizeClass as se, createTextVNode as Ce, toDisplayString as L, createCommentVNode as Z, Fragment as _, renderList as te, withModifiers as be, resolveComponent as Ae, createVNode as oe } from "vue";
var We = Object.defineProperty, Oe = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, d = (e, t, n) => (Oe(e, typeof t != "symbol" ? t + "" : t, n), n), j = /* @__PURE__ */ ((e) => (e.Any = "any", e.Value = "value", e.Range = "range", e.Step = "step", e.RangeStep = "rangeStep", e.Combined = "combined", e.NoSpecific = "noSpecific", e))(j || {}), R = /* @__PURE__ */ ((e) => (e.Prefix = "prefix", e.Suffix = "suffix", e.Text = "text", e))(R || {});
class Ve {
constructor(t) {
d(this, "field"), d(this, "itemMap"), this.field = t, this.itemMap = this.field.items.reduce(
(n, i) => (n[i.value] = i, n),
{}
);
}
get id() {
return this.field.id;
}
get items() {
return this.field.items;
}
get onChange() {
return this.field.onChange;
}
get segmentFactories() {
return this.field.segmentFactories;
}
get min() {
return this.items[0].value;
}
get max() {
return this.items[this.items.length - 1].value;
}
getItem(t) {
return this.itemMap[t];
}
}
function Te(e, t, n = 1) {
const i = [];
for (let r = e; r <= t; r += n)
i.push(r);
return i;
}
class qe {
constructor(t, n, i = 1) {
return d(this, "start"), d(this, "end"), d(this, "step"), this.start = t, this.end = n, this.step = i, new Proxy(this, {
get: function(r, a) {
const s = typeof a == "string" ? parseInt(a) : a;
return typeof s == "number" && s >= 0 && s <= r.length ? r.start + r.step * s : Reflect.get(r, a);
}
});
}
get length() {
return (this.end - this.start) / this.step + 1;
}
[Symbol.iterator]() {
let t = -1;
return {
next: () => ({ value: this[++t], done: this[t + 1] === void 0 })
};
}
}
function E(e, t, n = (r) => r + "", i = (r) => r + "") {
const r = [];
for (const a of new qe(e, t))
r.push({
text: n(a),
alt: i(a),
value: a
});
return r;
}
function je(e, t = "crontab") {
const n = (r, a = !1) => new Date(2021, r - 1, 1).toLocaleDateString(e, {
month: a ? "short" : "long"
}), i = (r, a = !1) => new Date(2021, 0, 3 + r).toLocaleDateString(e, {
weekday: a ? "short" : "long"
});
return {
secondItems: E(0, 59, (r) => Q(r, 2)),
minuteItems: E(0, 59, (r) => Q(r, 2)),
hourItems: E(0, 23, (r) => Q(r, 2)),
dayItems: E(1, 31),
monthItems: E(1, 12, n, (r) => n(r, !0)),
dayOfWeekItems: t === "quartz" ? E(
1,
7,
(r) => i(r - 1),
(r) => i(r - 1, !0)
) : E(0, 6, i, (r) => i(r, !0))
};
}
function Q(e, t) {
const n = e + "";
return n.length < t ? new Array(t - n.length).fill("0").join("") + e : n;
}
function H(e) {
return e && typeof e == "object" && !Array.isArray(e);
}
function ne(e, ...t) {
if (!H(e) || t.length === 0)
return;
const n = t.shift();
if (H(n))
for (const [i, r] of Object.entries(n))
H(r) ? (H(e[i]) || (e[i] = {}), ne(e[i], n[i])) : e[i] = n[i];
return t.length > 0 && ne(e, ...t), e;
}
function de(e, ...t) {
if (t.length === 0)
return e;
for (const n of t[0])
if (n in e) {
const i = de(e[n], ...t.slice(1));
if (i !== void 0)
return i;
}
}
function Me(e) {
for (let t = 1; t < e.length; t++)
if (e[t - 1] + 1 !== e[t])
return !1;
return !0;
}
function $e() {
throw new Error("not implemented");
}
function Ee(e, t, n = !0) {
const i = [];
for (let r = 0; r < e.length; r += t) {
const a = e.slice(r, r + t);
for (; n && a.length < t; )
a.push(null);
i.push(a);
}
return i;
}
class Y {
constructor(t) {
d(this, "field"), d(this, "type", j.NoSpecific), this.field = t;
}
toCron() {
return "?";
}
toArray() {
return [];
}
get items() {
return {};
}
static fromString(t, n) {
return t !== "?" ? null : new Y(n);
}
}
class M {
constructor(t) {
d(this, "field"), d(this, "type", j.Any), this.field = t;
}
toCron() {
return "*";
}
toArray() {
return [];
}
get items() {
return {};
}
static fromString(t, n) {
return t !== "*" ? null : new M(n);
}
static fromArray(t, n) {
const { items: i } = n;
if (t.length === 0)
return new M(n);
if (t.length !== i.length)
return null;
for (const r of i)
if (!t.includes(r.value))
return null;
return Me(i.map((r) => r.value)) ? new M(n) : null;
}
}
const ce = class re {
constructor(t, n, i) {
d(this, "field"), d(this, "type", j.Range), d(this, "start"), d(this, "end"), this.field = t, this.start = n, this.end = i;
}
toCron() {
return `${this.start}-${this.end}`;
}
toArray() {
const t = this.start, n = this.end;
return Te(t, n);
}
get items() {
return {
start: this.field.itemMap[this.start],
end: this.field.itemMap[this.end]
};
}
static fromString(t, n) {
if (!re.re.test(t))
return null;
const { min: i, max: r } = n, a = t.split("-"), s = parseInt(a[0]), o = parseInt(a[1]);
return s > o || s < i || o > r ? null : new re(n, s, o);
}
};
d(ce, "re", /^\d+-\d+$/);
let G = ce;
function le(e, t, n) {
const i = [];
for (let r = t; r <= n; r += e)
i.push(r);
return i;
}
const me = class B {
constructor(t, n, i, r) {
d(this, "field"), d(this, "step"), d(this, "start"), d(this, "end"), this.field = t, this.step = n, this.start = i ?? t.min, this.end = r ?? t.max;
}
get type() {
const { min: t, max: n } = this.field;
return this.start !== t || n - this.end >= this.step ? j.RangeStep : j.Step;
}
toCron() {
return this.type == j.RangeStep ? `${this.start}-${this.end}/${this.step}` : `*/${this.step}`;
}
toArray() {
return le(this.step, this.start, this.end);
}
get items() {
return {
step: this.field.itemMap[this.step],
start: this.field.itemMap[this.start],
end: this.field.itemMap[this.end]
};
}
static fromString(t, n) {
if (!B.re.test(t))
return null;
const [i, r] = t.split("/"), a = parseInt(r);
if (a > n.items.length)
return null;
const s = t.split("-").map((x) => parseInt(x)), o = i == "*" ? n.min : s[0], l = i == "*" ? n.max : s[1];
return le(a, o, l).length == 0 ? null : new B(n, a, o, l);
}
static fromArray(t, n) {
if (t.length < 3)
return null;
const i = t[1] - t[0];
if (i <= 1)
return null;
for (let r = 2; r < t.length; r++)
if (t[r] - t[r - 1] != i)
return null;
return new B(n, i, t[0], t[t.length - 1]);
}
};
d(me, "re", /^(\*|\d+-\d+)\/\d+$/);
let K = me;
class P {
constructor(t, n) {
d(this, "field"), d(this, "type", j.Value), d(this, "value"), this.field = t, this.value = n;
}
toCron() {
return `${this.value}`;
}
toArray() {
return [this.value];
}
get items() {
return {
value: this.field.itemMap[this.value]
};
}
static fromString(t, n) {
const { min: i, max: r } = n, a = parseInt(t);
return String(a) === t && a >= i && a <= r ? new P(n, a) : null;
}
static fromArray(t, n) {
const { min: i, max: r } = n;
if (t.length != 1)
return null;
const a = t[0];
return a < i || a > r ? null : a;
}
}
const he = class J {
constructor(t, n = []) {
d(this, "field"), d(this, "segments"), this.field = t, this.segments = n;
}
get type() {
return this.segments.length == 1 ? this.segments[0].type : j.Range;
}
addSegment(t) {
this.segments.push(t);
}
toCron() {
return this.segments.map((t) => t.toCron()).join(",");
}
toArray() {
const t = /* @__PURE__ */ new Set();
for (const n of this.segments)
n.toArray().forEach((i) => t.add(i));
return Array.from(t);
}
get items() {
return $e();
}
static fromString(t, n) {
const i = n.segmentFactories ?? J.segmentFactories;
let r = [];
for (const a of t.split(",")) {
if (a === "*") {
r = [new M(n)];
break;
}
let s = null;
for (const o of i)
if (s = o(a, n), s !== null)
break;
if (s === null)
return null;
r.push(s);
}
return new J(n, r);
}
static fromArray(t, n) {
const { min: i, max: r } = n, a = t[0], s = t[t.length - 1];
if (a < i || s > r)
return null;
const o = [];
let l = 0;
for (let x = 0; x < t.length; x++)
(t[x + 1] === void 0 || t[x + 1] - t[x] > 1) && (x === l ? o.push(new P(n, t[l])) : o.push(new G(n, t[l], t[x])), l = x + 1);
return new J(n, o);
}
};
d(he, "segmentFactories", [
M.fromString,
K.fromString,
G.fromString,
P.fromString
]);
let ie = he;
function ue(e, t) {
return ie.fromString(e, t);
}
function Ie(e, t) {
for (const n of [
M.fromArray,
K.fromArray,
ie.fromArray
]) {
const i = n(e, t);
if (i != null)
return i;
}
return null;
}
/*!
* mustache.js - Logic-less {{mustache}} templates with JavaScript
* http://github.com/janl/mustache.js
*/
var Re = Object.prototype.toString, D = Array.isArray || function(e) {
return Re.call(e) === "[object Array]";
};
function ae(e) {
return typeof e == "function";
}
function Le(e) {
return D(e) ? "array" : typeof e;
}
function ee(e) {
return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
}
function pe(e, t) {
return e != null && typeof e == "object" && t in e;
}
function Pe(e, t) {
return e != null && typeof e != "object" && e.hasOwnProperty && e.hasOwnProperty(t);
}
var Ue = RegExp.prototype.test;
function De(e, t) {
return Ue.call(e, t);
}
var Fe = /\S/;
function Ne(e) {
return !De(Fe, e);
}
var He = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/",
"`": "`",
"=": "="
};
function ze(e) {
return String(e).replace(/[&<>"'`=\/]/g, function(t) {
return He[t];
});
}
var Be = /\s*/, Je = /\s+/, xe = /\s*=/, _e = /\s*\}/, Ye = /#|\^|\/|>|\{|&|=|!/;
function Ge(e, t) {
if (!e)
return [];
var n = !1, i = [], r = [], a = [], s = !1, o = !1, l = "", x = 0;
function h() {
if (s && !o)
for (; a.length; )
delete r[a.pop()];
else
a = [];
s = !1, o = !1;
}
var v, y, q;
function T(A) {
if (typeof A == "string" && (A = A.split(Je, 2)), !D(A) || A.length !== 2)
throw new Error("Invalid tags: " + A);
v = new RegExp(ee(A[0]) + "\\s*"), y = new RegExp("\\s*" + ee(A[1])), q = new RegExp("\\s*" + ee("}" + A[1]));
}
T(t || W.tags);
for (var u = new N(e), c, p, m, b, $, f; !u.eos(); ) {
if (c = u.pos, m = u.scanUntil(v), m)
for (var S = 0, w = m.length; S < w; ++S)
b = m.charAt(S), Ne(b) ? (a.push(r.length), l += b) : (o = !0, n = !0, l += " "), r.push(["text", b, c, c + 1]), c += 1, b === `
` && (h(), l = "", x = 0, n = !1);
if (!u.scan(v))
break;
if (s = !0, p = u.scan(Ye) || "name", u.scan(Be), p === "=" ? (m = u.scanUntil(xe), u.scan(xe), u.scanUntil(y)) : p === "{" ? (m = u.scanUntil(q), u.scan(_e), u.scanUntil(y), p = "&") : m = u.scanUntil(y), !u.scan(y))
throw new Error("Unclosed tag at " + u.pos);
if (p == ">" ? $ = [p, m, c, u.pos, l, x, n] : $ = [p, m, c, u.pos], x++, r.push($), p === "#" || p === "^")
i.push($);
else if (p === "/") {
if (f = i.pop(), !f)
throw new Error('Unopened section "' + m + '" at ' + c);
if (f[1] !== m)
throw new Error('Unclosed section "' + f[1] + '" at ' + c);
} else
p === "name" || p === "{" || p === "&" ? o = !0 : p === "=" && T(m);
}
if (h(), f = i.pop(), f)
throw new Error('Unclosed section "' + f[1] + '" at ' + u.pos);
return Xe(Ke(r));
}
function Ke(e) {
for (var t = [], n, i, r = 0, a = e.length; r < a; ++r)
n = e[r], n && (n[0] === "text" && i && i[0] === "text" ? (i[1] += n[1], i[3] = n[3]) : (t.push(n), i = n));
return t;
}
function Xe(e) {
for (var t = [], n = t, i = [], r, a, s = 0, o = e.length; s < o; ++s)
switch (r = e[s], r[0]) {
case "#":
case "^":
n.push(r), i.push(r), n = r[4] = [];
break;
case "/":
a = i.pop(), a[5] = r[2], n = i.length > 0 ? i[i.length - 1][4] : t;
break;
default:
n.push(r);
}
return t;
}
function N(e) {
this.string = e, this.tail = e, this.pos = 0;
}
N.prototype.eos = function() {
return this.tail === "";
};
N.prototype.scan = function(e) {
var t = this.tail.match(e);
if (!t || t.index !== 0)
return "";
var n = t[0];
return this.tail = this.tail.substring(n.length), this.pos += n.length, n;
};
N.prototype.scanUntil = function(e) {
var t = this.tail.search(e), n;
switch (t) {
case -1:
n = this.tail, this.tail = "";
break;
case 0:
n = "";
break;
default:
n = this.tail.substring(0, t), this.tail = this.tail.substring(t);
}
return this.pos += n.length, n;
};
function U(e, t) {
this.view = e, this.cache = { ".": this.view }, this.parent = t;
}
U.prototype.push = function(e) {
return new U(e, this);
};
U.prototype.lookup = function(e) {
var t = this.cache, n;
if (t.hasOwnProperty(e))
n = t[e];
else {
for (var i = this, r, a, s, o = !1; i; ) {
if (e.indexOf(".") > 0)
for (r = i.view, a = e.split("."), s = 0; r != null && s < a.length; )
s === a.length - 1 && (o = pe(r, a[s]) || Pe(r, a[s])), r = r[a[s++]];
else
r = i.view[e], o = pe(i.view, e);
if (o) {
n = r;
break;
}
i = i.parent;
}
t[e] = n;
}
return ae(n) && (n = n.call(this.view)), n;
};
function C() {
this.templateCache = {
_cache: {},
set: function(e, t) {
this._cache[e] = t;
},
get: function(e) {
return this._cache[e];
},
clear: function() {
this._cache = {};
}
};
}
C.prototype.clearCache = function() {
typeof this.templateCache < "u" && this.templateCache.clear();
};
C.prototype.parse = function(e, t) {
var n = this.templateCache, i = e + ":" + (t || W.tags).join(":"), r = typeof n < "u", a = r ? n.get(i) : void 0;
return a == null && (a = Ge(e, t), r && n.set(i, a)), a;
};
C.prototype.render = function(e, t, n, i) {
var r = this.getConfigTags(i), a = this.parse(e, r), s = t instanceof U ? t : new U(t, void 0);
return this.renderTokens(a, s, n, e, i);
};
C.prototype.renderTokens = function(e, t, n, i, r) {
for (var a = "", s, o, l, x = 0, h = e.length; x < h; ++x)
l = void 0, s = e[x], o = s[0], o === "#" ? l = this.renderSection(s, t, n, i, r) : o === "^" ? l = this.renderInverted(s, t, n, i, r) : o === ">" ? l = this.renderPartial(s, t, n, r) : o === "&" ? l = this.unescapedValue(s, t) : o === "name" ? l = this.escapedValue(s, t, r) : o === "text" && (l = this.rawValue(s)), l !== void 0 && (a += l);
return a;
};
C.prototype.renderSection = function(e, t, n, i, r) {
var a = this, s = "", o = t.lookup(e[1]);
function l(v) {
return a.render(v, t, n, r);
}
if (o) {
if (D(o))
for (var x = 0, h = o.length; x < h; ++x)
s += this.renderTokens(e[4], t.push(o[x]), n, i, r);
else if (typeof o == "object" || typeof o == "string" || typeof o == "number")
s += this.renderTokens(e[4], t.push(o), n, i, r);
else if (ae(o)) {
if (typeof i != "string")
throw new Error("Cannot use higher-order sections without the original template");
o = o.call(t.view, i.slice(e[3], e[5]), l), o != null && (s += o);
} else
s += this.renderTokens(e[4], t, n, i, r);
return s;
}
};
C.prototype.renderInverted = function(e, t, n, i, r) {
var a = t.lookup(e[1]);
if (!a || D(a) && a.length === 0)
return this.renderTokens(e[4], t, n, i, r);
};
C.prototype.indentPartial = function(e, t, n) {
for (var i = t.replace(/[^ \t]/g, ""), r = e.split(`
`), a = 0; a < r.length; a++)
r[a].length && (a > 0 || !n) && (r[a] = i + r[a]);
return r.join(`
`);
};
C.prototype.renderPartial = function(e, t, n, i) {
if (n) {
var r = this.getConfigTags(i), a = ae(n) ? n(e[1]) : n[e[1]];
if (a != null) {
var s = e[6], o = e[5], l = e[4], x = a;
o == 0 && l && (x = this.indentPartial(a, l, s));
var h = this.parse(x, r);
return this.renderTokens(h, t, n, x, i);
}
}
};
C.prototype.unescapedValue = function(e, t) {
var n = t.lookup(e[1]);
if (n != null)
return n;
};
C.prototype.escapedValue = function(e, t, n) {
var i = this.getConfigEscape(n) || W.escape, r = t.lookup(e[1]);
if (r != null)
return typeof r == "number" && i === W.escape ? String(r) : i(r);
};
C.prototype.rawValue = function(e) {
return e[1];
};
C.prototype.getConfigTags = function(e) {
return D(e) ? e : e && typeof e == "object" ? e.tags : void 0;
};
C.prototype.getConfigEscape = function(e) {
if (e && typeof e == "object" && !D(e))
return e.escape;
};
var W = {
name: "mustache.js",
version: "4.2.0",
tags: ["{{", "}}"],
clearCache: void 0,
escape: void 0,
parse: void 0,
render: void 0,
Scanner: void 0,
Context: void 0,
Writer: void 0,
/**
* Allows a user to override the default caching strategy, by providing an
* object with set, get and clear methods. This can also be used to disable
* the cache by setting it to the literal `undefined`.
*/
set templateCache(e) {
F.templateCache = e;
},
/**
* Gets the default or overridden caching object from the default writer.
*/
get templateCache() {
return F.templateCache;
}
}, F = new C();
W.clearCache = function() {
return F.clearCache();
};
W.parse = function(e, t) {
return F.parse(e, t);
};
W.render = function(e, t, n, i) {
if (typeof e != "string")
throw new TypeError('Invalid template! Template should be a "string" but "' + Le(e) + '" was given as the first argument for mustache#render(template, view, partials)');
return F.render(e, t, n, i);
};
W.escape = ze;
W.Scanner = N;
W.Context = U;
W.Writer = C;
const Ze = {
"*": {
prefix: "每",
suffix: "",
text: "未知",
"*": {
any: { text: "每 {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "每 {{step.value}}" }
},
month: {
"*": { prefix: "的" },
any: { text: "每月" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "的" },
any: { text: "每日" },
value: { text: "{{value.alt}}号" },
range: { text: "{{start.alt}}号-{{end.alt}}号" },
noSpecific: {
text: "无特定日期"
}
},
dayOfWeek: {
"*": { prefix: "的" },
any: { text: "一周的每一天" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "无特定星期几"
}
},
hour: {
"*": { prefix: "的" },
any: { text: "每小时" }
},
minute: {
"*": { prefix: ":" },
any: { text: "每分钟" }
},
second: {
"*": { prefix: ":" },
any: { text: "每秒" }
}
},
minute: {
text: "分"
},
hour: {
text: "小时",
minute: {
"*": {
prefix: ":",
suffix: "分钟"
},
any: { text: "每" }
}
},
day: {
text: "天"
},
week: {
text: "周",
dayOfWeek: {
"*": { prefix: "的" },
any: { text: "每天" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
}
},
month: {
text: "月",
dayOfWeek: {
"*": { prefix: "和" }
},
day: {
"*": { prefix: "的" }
}
},
year: {
text: "年",
dayOfWeek: {
"*": { prefix: "和" }
}
},
//quartz format
"q-second": {
text: "秒"
},
"q-minute": {
text: "分钟",
second: {
"*": {
prefix: ":",
suffix: "秒"
},
any: { text: "每" }
}
},
"q-hour": {
text: "小时",
minute: {
"*": {
prefix: ":"
}
}
}
}, Qe = {
"*": {
prefix: "Hver",
suffix: "",
text: "Ukendt",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "hver {{step.value}}" }
},
month: {
"*": { prefix: "i" },
any: { text: "hver måned" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "og" },
any: { text: "hver dag i måneden" },
value: { text: "{{value.alt}}." },
range: { text: "{{start.alt}}.-{{end.alt}}." },
noSpecific: {
text: "ingen specifik dag"
}
},
dayOfWeek: {
"*": { prefix: "på" },
any: { text: "hver dag i ugen" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "ingen specifik dag i ugen"
}
},
hour: {
"*": { prefix: "klokken" },
any: { text: "hver time" }
},
minute: {
"*": { prefix: ":" },
any: { text: "hvert minut" }
},
second: {
"*": { prefix: ":" },
any: { text: "hvert sekund" }
}
},
second: {
prefix: "Hvert"
},
minute: {
prefix: "Hvert",
text: "Minut"
},
hour: {
text: "Time",
minute: {
"*": {
prefix: "ved",
suffix: "minutter"
},
any: { text: "alle" }
}
},
day: {
text: "Dag"
},
week: {
text: "Uge"
},
month: {
text: "Måned",
dayOfWeek: {
"*": { prefix: "og" }
}
},
year: {
prefix: "Hvert",
text: "År",
dayOfWeek: {
"*": { prefix: "og" }
}
},
// quartz format
"q-second": {
text: "Sekund"
},
"q-minute": {
text: "Minut",
second: {
"*": {
suffix: "sekund(er)"
},
any: { text: "hvert" }
}
},
"q-hour": {
text: "Time",
minute: {
"*": {
prefix: "på"
}
}
}
}, et = {
"*": {
prefix: "Jede",
suffix: "",
text: "Unknown",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "alle {{step.value}}" }
},
month: {
"*": { prefix: "im" },
any: {
prefix: "in",
text: "jedem Monat"
},
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "den" },
any: {
prefix: "an",
text: "jedem Tag"
},
step: {
prefix: "",
text: "alle {{step.value}} Tage"
},
noSpecific: {
prefix: "an",
text: "keinem bestimmten Tag"
}
},
dayOfWeek: {
"*": { prefix: "am" },
any: {
prefix: "an",
text: "jedem Wochentag"
},
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
prefix: "und",
text: "keinem bestimmten Wochentag"
}
},
hour: {
"*": { prefix: "um" },
any: {
prefix: "zu",
text: "jeder Stunde"
},
step: {
prefix: "",
text: "alle {{step.value}} Stunden"
}
},
minute: {
"*": { prefix: ":" },
any: { text: "jede Minute" },
step: {
prefix: "",
text: "alle {{step.value}} Minuten"
}
},
second: {
"*": { prefix: ":" },
any: { text: "jede Sekunde" },
step: {
prefix: "",
text: "alle {{step.value}} Sekunden"
}
}
},
minute: {
text: "Minute"
},
hour: {
text: "Stunde",
minute: {
"*": {
prefix: "zu",
suffix: "Minute(n)"
},
any: { text: "jeder" }
}
},
day: {
prefix: "Jeden",
text: "Tag"
},
week: {
text: "Woche"
},
month: {
prefix: "Jedes",
text: "Monat"
},
year: {
prefix: "Jedes",
text: "Jahr"
},
//quartz format
"q-second": {
text: "Sekunde"
},
"q-minute": {
text: "Minute",
second: {
"*": {
prefix: "und"
}
}
},
"q-hour": {
text: "Stunde",
minute: {
"*": {
prefix: "und"
}
},
second: {
"*": {
prefix: "und"
}
}
}
}, tt = {
"*": {
prefix: "Every",
suffix: "",
text: "Unknown",
"*": {
any: { text: "every {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "every {{step.value}}" },
rangeStep: { text: "{{start.text}}-{{end.text}}/{{step.value}}" }
},
month: {
"*": { prefix: "in" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
rangeStep: { text: "{{start.alt}}-{{end.alt}}/{{step.value}}" }
},
day: {
"*": { prefix: "on" },
noSpecific: {
text: "no specific day"
}
},
dayOfWeek: {
"*": { prefix: "on" },
any: { text: "every day of the week" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
rangeStep: { text: "{{start.alt}}-{{end.alt}}/{{step.value}}" },
noSpecific: {
text: "no specific day of the week"
}
},
hour: {
"*": { prefix: "at" }
},
minute: {
"*": { prefix: ":" }
},
second: {
"*": { prefix: ":" }
}
},
minute: {
text: "Minute"
},
hour: {
text: "Hour",
minute: {
"*": {
prefix: "at",
suffix: "minute(s)"
},
any: { text: "every" }
}
},
day: {
text: "Day"
},
week: {
text: "Week"
},
month: {
text: "Month",
dayOfWeek: {
"*": { prefix: "and" }
}
},
year: {
text: "Year",
dayOfWeek: {
"*": { prefix: "and" }
}
},
//quartz format
"q-second": {
text: "Second"
},
"q-minute": {
text: "Minute",
second: {
"*": {
prefix: "at",
suffix: "second(s)"
},
any: { text: "every" }
}
},
"q-hour": {
text: "Hour",
minute: {
"*": {
prefix: "at"
}
}
}
}, nt = {
"*": {
prefix: "todos los",
suffix: "",
text: "Desconocido",
"*": {
any: { text: "todos los {{ field.id }}" },
value: { text: "{{ value.text }}" },
range: { text: "{{ start.text }}-{{ end.text }}" },
step: { text: "todos/as {{ step.value }}" }
},
month: {
"*": { prefix: "en" },
any: { text: "todos los meses" },
value: { text: "{{ value.alt }}" },
range: { text: "{{ start.alt }}-{{ end.alt }}" }
},
day: {
"*": { prefix: "en" },
any: { text: "todos los días" },
value: { text: "los días {{ value.alt }}" }
},
dayOfWeek: {
"*": { prefix: "de" },
any: { text: "todos los días de la semana" },
value: { text: "los {{ value.alt }}" },
range: { text: "{{ start.alt }}-{{ end.alt }}" }
},
hour: {
"*": { prefix: "a" },
any: { text: "todas las horas" },
value: { text: "las {{ value.text }}" }
},
minute: {
"*": { prefix: ":" },
any: { text: "todos los minutos" }
}
},
minute: {
prefix: "todos los",
text: "minutos"
},
hour: {
prefix: "todas las",
text: "horas",
minute: {
"*": {
prefix: "a los",
suffix: "minutos"
},
any: { text: "todos", prefix: "a", suffix: "los minutos" }
}
},
day: {
text: "Días"
},
week: {
text: "Semanas"
},
month: {
text: "Meses",
dayOfWeek: {
"*": { prefix: "y" }
}
},
year: {
text: "años",
dayOfWeek: {
"*": { prefix: "y" }
}
}
}, rt = {
"*": {
prefix: "Toutes",
suffix: "",
text: "Inconnu",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "tous les {{step.value}}" }
},
month: {
"*": { prefix: "en" },
any: { prefix: "en", text: "tous les mois" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "le" },
any: { prefix: "à", text: "tous les jours" },
step: { prefix: "", text: "tous les {{step.value}} jours" },
noSpecific: { prefix: "à", text: "aucun jour particulier" }
},
dayOfWeek: {
"*": { prefix: "le" },
any: { prefix: "à", text: "tous les jours de la semaine" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "et", text: "aucun jour de la semaine particulier" }
},
hour: {
"*": { prefix: "à" },
any: { prefix: "à", text: "toutes les heures" },
step: { prefix: "", text: "toutes les {{step.value}} heures" }
},
minute: {
"*": { prefix: ":" },
any: { text: "toutes les minutes" },
step: { prefix: "", text: "toutes les {{step.value}} minutes" }
},
second: {
"*": { prefix: ":" },
any: { text: "toutes les secondes" },
step: { prefix: "", text: "toutes les {{step.value}} secondes" }
}
},
minute: { text: "Minute" },
hour: {
text: "Heure",
minute: { "*": { prefix: "à", suffix: "minute(s)" }, any: { text: "toutes" } }
},
day: { prefix: "Tous", text: "Jour" },
week: { text: "Semaine" },
month: { prefix: "Tous", text: "Mois" },
year: { prefix: "Tous", text: "Année" },
//quartz format
"q-second": { text: "Seconde" },
"q-minute": { text: "Minute", second: { "*": { prefix: "et" } } },
"q-hour": { text: "Heure", minute: { "*": { prefix: "et" } }, second: { "*": { prefix: "et" } } }
}, it = {
"*": {
prefix: "בכל",
suffix: "",
text: "לא ידוע",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "כל {{step.value}}" }
},
month: {
"*": { prefix: "ב" },
any: { text: "כל חודש" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "ב" },
any: { text: "כל יום" },
value: { text: "יום {{value.alt}} לחודש" },
noSpecific: {
text: "ללא יום מוגדר"
}
},
dayOfWeek: {
"*": { prefix: "ב" },
any: { text: "כל יום מימות השבוע" },
value: { text: "ימי {{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: {
text: "ללא יום בשבוע מוגדר"
}
},
hour: {
"*": { prefix: "ב" },
any: { text: "כל שעה" },
value: { text: "שעה {{value.text}}" }
},
minute: {
"*": { prefix: ":" },
any: { text: "כל דקה" }
},
second: {
"*": { prefix: ":" },
any: { text: "כל שניה" }
}
},
minute: {
text: "דקה"
},
hour: {
text: "שעה",
minute: {
"*": {
prefix: "ב",
suffix: "דקות"
},
any: { text: "כל" }
}
},
day: {
text: "יום"
},
week: {
text: "שבוע"
},
month: {
text: "חודש",
dayOfWeek: {
"*": { prefix: "ו" }
}
},
year: {
text: "שנה",
dayOfWeek: {
"*": { prefix: "ו" }
}
},
//quartz format
"q-second": {
text: "שניה"
},
"q-minute": {
text: "דקה",
second: {
"*": {
prefix: "ב",
suffix: "שניות"
},
any: { text: "כל" }
}
},
"q-hour": {
text: "שעה",
minute: {
"*": {
prefix: "ב"
}
}
}
}, at = {
"*": {
prefix: "हर",
suffix: "",
text: "अज्ञात",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}} हर" }
},
month: {
"*": { prefix: "में" },
any: { prefix: "के", text: "हर महीने" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "के" },
any: { prefix: "पर", text: "हर दिन" },
step: { prefix: "", text: "{{step.value}} दिन हर" },
noSpecific: { prefix: "पर", text: "कोई विशेष दिन नहीं" }
},
dayOfWeek: {
"*": { prefix: "पर" },
any: { prefix: "पर", text: "हर सप्ताह" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "और", text: "कोई विशेष सप्ताह नहीं" }
},
hour: {
"*": { prefix: "को" },
any: { prefix: "पर", text: "हर घंटे" },
step: { prefix: "", text: "{{step.value}} घंटे हर" }
},
minute: {
"*": { prefix: ":" },
any: { text: "हर मिनट" },
step: { prefix: "", text: "{{step.value}} मिनट हर" }
},
second: {
"*": { prefix: ":" },
any: { text: "हर सेकंड" },
step: { prefix: "", text: "{{step.value}} सेकंड हर" }
}
},
minute: { text: "मिनट" },
hour: { text: "घंटा", minute: { "*": { prefix: "पर", suffix: "मिनट" }, any: { text: "हर" } } },
day: { prefix: "हर", text: "दिन" },
week: { text: "सप्ताह" },
month: { prefix: "हर", text: "महीना" },
year: { prefix: "हर", text: "साल" },
//quartz format
"q-second": { text: "सेकंड" },
"q-minute": { text: "मिनट", second: { "*": { prefix: "और" } } },
"q-hour": { text: "घंटा", minute: { "*": { prefix: "और" } }, second: { "*": { prefix: "और" } } }
}, st = {
"*": {
prefix: "毎",
suffix: "",
text: "不明",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}}ごとに" }
},
month: {
"*": { prefix: "に" },
any: { prefix: "の", text: "毎月" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎日" },
step: { prefix: "", text: "{{step.value}}日ごとに" },
noSpecific: { prefix: "に", text: "特定の日はなし" }
},
dayOfWeek: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎週" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "と", text: "特定の曜日はなし" }
},
hour: {
"*": { prefix: "の" },
any: { prefix: "に", text: "毎時" },
step: { prefix: "", text: "{{step.value}}時間ごとに" }
},
minute: {
"*": { prefix: ":" },
any: { text: "毎分" },
step: { prefix: "", text: "{{step.value}}分ごとに" }
},
second: {
"*": { prefix: ":" },
any: { text: "毎秒" },
step: { prefix: "", text: "{{step.value}}秒ごとに" }
}
},
minute: { text: "分" },
hour: { text: "時", minute: { "*": { prefix: "に", suffix: "分" }, any: { text: "毎" } } },
day: { prefix: "毎", text: "日" },
week: { text: "週" },
month: { prefix: "毎", text: "月" },
year: { prefix: "毎", text: "年" },
//quartz format
"q-second": { text: "秒" },
"q-minute": { text: "分", second: { "*": { prefix: "と" } } },
"q-hour": { text: "時", minute: { "*": { prefix: "と" } }, second: { "*": { prefix: "と" } } }
}, ot = {
"*": {
prefix: "매",
suffix: "",
text: "알 수 없음",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "{{step.value}}마다" }
},
month: {
"*": { prefix: "에" },
any: { prefix: "의", text: "매월" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매일" },
step: { prefix: "", text: "{{step.value}}일마다" },
noSpecific: { prefix: "에", text: "특정한 날 없음" }
},
dayOfWeek: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매주" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "과", text: "특정한 요일 없음" }
},
hour: {
"*": { prefix: "의" },
any: { prefix: "에", text: "매시" },
step: { prefix: "", text: "{{step.value}}시간마다" }
},
minute: {
"*": { prefix: ":" },
any: { text: "매분" },
step: { prefix: "", text: "{{step.value}}분마다" }
},
second: {
"*": { prefix: ":" },
any: { text: "매초" },
step: { prefix: "", text: "{{step.value}}초마다" }
}
},
minute: { text: "분" },
hour: { text: "시", minute: { "*": { prefix: "에", suffix: "분" }, any: { text: "매" } } },
day: { prefix: "매", text: "일" },
week: { text: "주" },
month: { prefix: "매", text: "월" },
year: { prefix: "매", text: "년" },
//quartz format
"q-second": { text: "초" },
"q-minute": { text: "분", second: { "*": { prefix: "와" } } },
"q-hour": { text: "시", minute: { "*": { prefix: "와" } }, second: { "*": { prefix: "와" } } }
}, lt = {
"*": {
prefix: "Todo(a)",
suffix: "",
text: "Desconhecido",
"*": {
any: { text: "todo {{field.id}}" },
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "todo {{step.value}}" }
},
month: {
"*": { prefix: "de" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
any: { text: "todo mês" }
},
day: {
"*": { prefix: "no(s) dia(s)" },
any: { text: "todos" }
},
dayOfWeek: {
"*": { prefix: "de" },
any: { text: "todos dias da semana" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
hour: {
"*": { prefix: "às" },
any: { text: "cada hora" }
},
minute: {
"*": { prefix: ":" },
any: { text: "cada minuto" }
}
},
minute: {
text: "Minuto"
},
hour: {
text: "Hora",
minute: {
"*": {
prefix: "e",
suffix: "minuto(s)"
},
any: { text: "cada" }
}
},
day: {
text: "Dia"
},
week: {
text: "Semana"
},
month: {
text: "Mês",
dayOfWeek: {
"*": { prefix: "e de" }
}
},
year: {
text: "Ano",
dayOfWeek: {
"*": { prefix: "e de" }
}
}
}, ut = {
"*": {
prefix: "Каждый",
suffix: "",
text: "Неизвестно",
"*": {
value: { text: "{{value.text}}" },
range: { text: "{{start.text}}-{{end.text}}" },
step: { text: "каждый {{step.value}}" }
},
month: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждом месяце" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" }
},
day: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждый день" },
step: { prefix: "", text: "каждые {{step.value}} дня" },
noSpecific: { prefix: "в", text: "нет определенного дня" }
},
dayOfWeek: {
"*": { prefix: "по" },
any: { prefix: "по", text: "каждому дню недели" },
value: { text: "{{value.alt}}" },
range: { text: "{{start.alt}}-{{end.alt}}" },
noSpecific: { prefix: "и", text: "нет определенного дня недели" }
},
hour: {
"*": { prefix: "в" },
any: { prefix: "в", text: "каждый час" },
step: { prefix: "", text: "каждые {{step.value}} часа" }
},
minute: {
"*": { prefix: ":" },
any: { text: "каждую минуту" },
step: { prefix: "", text: "каждые {{step.value}} минуты" }
},
second: {
"*": { prefix: ":" },
any: { text: "каждую секунду" },
step: { prefix: "", text: "каждые {{step.value}} секунды" }
}
},
minute: { text: "Минута" },
hour: {
text: "Час",
minute: { "*": { prefix: "в", suffix: "минут(а/ы)" }, any: { text: "каждый" } }
},
day: { prefix: "Каждый", text: "День" },
week: { text: "Неделя" },
month: { prefix: "Каждый", text: "Месяц" },
year: { prefix: "Каждый", text: "Год" },
//quartz format
"q-second": { text: "Секунда" },
"q-minute": { text: "Минута", second: { "*": { prefix: "и" } } },
"q-hour": { text: "Час", minute: { "*": { prefix: "и" } }, second: { "*": { prefix: "и" } } }
}, z = {
empty: {},
en: tt,
de: et,
pt: lt,
es: nt,
da: Qe,
zh: Ze,
he: it,
ru: ut,
fr: rt,
hi: at,
ja: st,
ko: ot
};
class pt {
constructor(t) {
d(this, "dict"), this.dict = t;
}
/**
* Gets a localization template by traversing the dictionary using provided keys.
* @param keys - Array of keys to traverse through the localization dictionary
* @returns The found template string or empty string if not found
*/
getTemplate(...t) {
const n = t.map((i) => [i, "*"]);
return de(this.dict, ...n) || "";
}
/**
* Renders a localization template with the provided parameters using Mustache.
* @param periodId - The period identifier (e.g. 'year', 'month')
* @param fieldId - The field identifier (e.g. 'hour', 'minute')
* @param fieldPattern - The pattern type of the field
* @param position - The text position
* @param params - Parameters to be interpolated into the template
* @returns The rendered localization string
*/
render(t, n, i, r, a) {
const s = this.getTemplate(t, n, i, r);
return W.render(s, a || {});
}
}
function xt(e, t) {
const [n] = e.split("-"), i = z[e.toLowerCase()] || z[n.toLowerCase()] || z.en, r = ne({}, z.en, i, t || {});
return new pt(r);
}
function ft(e) {
const { period: t, field: n, initialCron: i = "*", l10n: r } = e, a = k(i), s = k(""), o = k([]), l = k(""), x = k(""), h = k(""), v = (u) => {
const c = u instanceof ie ? u.segments : [u];
l.value = c.map((p) => r.render(t.value.id, n.id, p.type, R.Text, {
field: n,
...p.items
})).join(","), x.value = r.getTemplate(t.value.id, n.id, u.type, R.Prefix), h.value = r.getTemplate(t.value.id, n.id, u.type, R.Suffix);
}, y = (u) => {
const c = ue(u, n);
c != null ? (o.value = c.toArray(), v(c)) : s.value = `${u} is not a valid cron segment (${n.id})`;
}, q = (u) => {
if (a.value == "?" && u.length == 0)
return;
const c = Ie(u, n);
c != null ? (a.value = c.toCron(), v(c)) : s.value = `failed to convert ${u} to cron (${n.id})`;
};
y(i);
const T = (u) => {
const c = Array.from(u).sort((p, m) => p > m ? 1 : -1);
o.value = c;
};
return g(a, (u) => {
y(u);
}), g(o, (u) => {
q(u);
}), g(t, () => {
const u = ue(a.value, n);
u != null && v(u);
}), {
id: n.id,
items: n.items,
cron: a,
selected: o,
error: s,
select: T,
text: l,
prefix: x,
suffix: h
};
}
function ve(e, t = "*") {
return new Array(e).fill(t).join(" ");
}
function dt(e) {
return e !== void 0;
}
class ct {
constructor() {
d(this, "locale", "en"), d(this, "format", "crontab");
}
initialValue(t, n = "*") {
return ve(t, n);
}
fields(t, n) {
const i = t == "quartz" || t == "spring", r = je(n, t), a = (s) => (o, { segmentMap: l }) => {
if (o.cron.value == "?")
return;
const x = l.get(s);
x && (x.cron.value = "?");
};
return [
...i ? [{ id: "second", items: r.secondItems }] : [],
{ id: "minute", items: r.minuteItems },
{ id: "hour", items: r.hourItems },
{
id: "day",
items: r.dayItems,
onChange: i ? a("dayOfWeek") : void 0,
segmentFactories: i ? [
M.fromString,
Y.fromString,
K.fromString,
G.fromString,
P.fromString
] : void 0
},
{ id: "month", items: r.monthItems },
{
id: "dayOfWeek",
items: r.dayOfWeekItems,
onChange: i ? a("day") : void 0,
segmentFactories: i ? [
M.fromString,
Y.fromString,
K.fromString,
G.fromString,
P.fromString
] : void 0
}
];
}
periods(t) {
const n = t == "quartz" || t == "spring", i = n ? [{ id: "q-second", value: [] }] : [], r = n ? ["second"] : [], a = n ? "q-" : "";
return [
...i,
{ id: a + "minute", value: [...r] },
{ id: a + "hour", value: ["minute", ...r] },
{ id: "day", value: ["hour", "minute", ...r] },
{ id: "week", value: ["dayOfWeek", "hour", "minute", ...r] },
{ id: "month", value: ["day", "dayOfWeek", "hour", "minute", ...r] },
{ id: "year", value: ["month", "day", "dayOfWeek", "hour", "minute", ...r] }
];
}
}
function mt(e, t, n) {
const i = t.split(" ");
if (i.length !== n.length)
return;
const r = n.filter((a, s) => !["*", "?"].includes(i[s])).map((a) => a.id);
return e.find((a) => {
const s = new Set(a.value);
return r.every((o) => s.has(o));
});
}
function ht(e) {
const t = new ct(), n = e.locale ?? t.locale, i = e.format ?? t.format, { customLocale: r, fields: a = t.fields(i, n) } = e, s = e.initialValue ?? t.initialValue(a.length), o = xt(n, r), l = (e.periods ?? t.periods(i)).map((f) => ({
...f,
text: f.text ?? o.getTemplate(f.id, R.Text)
})), x = (e.initialPeriod ? l.find((f) => f.id == e.initialPeriod) : void 0) ?? mt([...l].reverse(), s, a) ?? l[l.length - 1], h = k(s), v = k(""), y = k(x), q = k(""), T = k(""), u = a.map((f) => ft({ field: new Ve(f), l10n: o, period: y })), c = new Map(u.map((f) => [f.id, f])), p = fe(() => y.value.value.map((f) => {
const S = c.get(f);
if (dt(S))
return S;
throw Error("${fieldId} not found");
})), m = (f) => {
if (!f) {
h.value = ve(a.length);
return;
}
const S = f.split(" ");
if (S.length !== a.length) {
v.value = "invalid pattern";
return;
}
for (let w = 0; w < S.length; w++)
u[w].cron.value != S[w] && (u[w].cron.value = S[w]);
v.value = "";
};
m(s);
const b = () => {
h.value = u.map((f) => y.value.value.includes(f.id) || f.cron.value == "?" ? f.cron.value : "*").join(" ");
}, $ = () => {
q.value = o.getTemplate(y.value.id, R.Prefix), T.value = o.getTemplate(y.value.id, R.Suffix);
};
return $(), g(h, m), g(y, () => {
b(), $();
}), u.forEach((f, S) => {
g(f.cron, () => {
var w, A;
(A = (w = a[S]).onChange) == null || A.call(w, f, { segmentMap: c }), b();
}), g(f.error, (w) => {
v.value = w;
});
}), {
cron: h,
error: v,
segments: u,
selected: p,
period: {
select: (f) => {
const S = l.map((w) => w.id).indexOf(f);
S != -1 && (y.value = l[S]);
},
selected: y,
items: l,
prefix: q,
suffix: T
}
};
}
function ye(e, { emit: t }) {
const n = {
...e,
initialValue: e.modelValue,
initialPeriod: e.period
}, i = ht(n);
return g(
() => e.modelValue,
(r) => {
r && (i.cron.value = r);
}
), g(
() => e.period,
(r) => {
r && i.period.select(r);
}
), g(i.cron, (r) => {
t("update:model-value", r);
}), g(i.period.selected, (r) => {
t("update:period", r.id);
}), g(i.error, (r) => {
t("error", r);
}), i;
}
const ge = () => ({
/**
* The value of the cron expression
*
* @defaultValue crontab: `* * * * *`, quartz: `* * * * * *`
*/
modelValue: {
type: String
},
/**
* The id of a period to select
*
* @defaultValue last entry of `CronCoreProps.periods`
*/
period: {
type: String
},
/**
* The format of the cron expression, either crontab or quartz
*
* @defaultValue `crontab`
*/
format: {
type: String
},
/**
* The locale of the component, such as `en`, `de`, etc.
*
* @defaultValue `en`
*/
locale: {
type: String
},
/** The segments of the cron expression, such as second, minute, hour, etc. */
fields: {
type: Array
},
/** The periods to select, e.g. Every month, day, etc. */
periods: {
type: Array
},
/** The custom locale object, used to override values of the current {@link Localization} */
customLocale: {
type: Object
},
/** Number of columns in the dropdown,
* e.g. the possible values of minute (0-59) will be displayed in a grid with 5 columns
*
* @defaultValue
* ```
* {
* second: 5,
* minute: 5,
* hour: 4,
* day: 4,
* }
* ```
*/
cols: {
type: Object,
default: () => ({
second: 5,
minute: 5,
hour: 4,
day: 4
})
},
/** Disable the cron editor */
disabled: {
type: Boolean,
default: !1
}
});
X({
name: "VueCronCore",
props: ge(),
emits: ["update:model-value", "update:period", "error"],
setup(e, t) {
const { error: n, selected: i, period: r } = ye(e, t);
return () => {
var a, s;
const o = {
error: n,
fields: i.value.map((l) => ({
id: l.id,
items: l.items,
cron: l.cron.value,
selectedStr: l.text.value,
events: {
"update:model-value": l.select
},
attrs: {
modelValue: l.selected.value
},
prefix: l.prefix.value,
suffix: l.suffix.value
})),
period: {
attrs: {
modelValue: r.selected.value.id
},
events: {
"update:model-value": r.select
},
items: r.items,
prefix: r.prefix.value,
suffix: r.suffix.value
}
};
return (s = (a = t.slots).default) == null ? void 0 : s.call(a, o);
};
}
});
function vt(e) {
const { items: t } = e, n = /* @__PURE__ */ new Set(), i = k(0), r = () => {
i.value = i.value + 1;
}, a = (l) => {
t.indexOf(l) != -1 && (n.add(l), r());
}, s = (l) => n.has(l), o = (l) => {
n.delete(l) && r();
};
return {
values: n,
add: a,
toggle: (l) => {
s(l) ? o(l) : a(l);
},
remove: o,
clear: () => {
n.clear(), r();
},
updated: i,
equals: (l) => {
if (l.le