@stacksjs/scheduler 0.62.0 → 0.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -745
- package/dist/index.js.map +38 -0
- package/package.json +3 -6
- package/src/index.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -1,748 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/schedule.ts
|
|
3
|
-
import {log} from "@stacksjs/cli";
|
|
4
|
-
|
|
5
|
-
// src/job.ts
|
|
6
|
-
import {spawn} from "child_process";
|
|
7
|
-
|
|
8
|
-
// src/errors.ts
|
|
9
|
-
class CronError extends Error {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class ExclusiveParametersError extends CronError {
|
|
13
|
-
constructor(param1, param2) {
|
|
14
|
-
super(`You can't specify both ${param1} and ${param2}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// src/time.ts
|
|
19
|
-
import {DateTime} from "luxon";
|
|
20
|
-
|
|
21
|
-
// src/constants.ts
|
|
22
|
-
var CONSTRAINTS = Object.freeze({
|
|
23
|
-
second: [0, 59],
|
|
24
|
-
minute: [0, 59],
|
|
25
|
-
hour: [0, 23],
|
|
26
|
-
dayOfMonth: [1, 31],
|
|
27
|
-
month: [1, 12],
|
|
28
|
-
dayOfWeek: [0, 7]
|
|
29
|
-
});
|
|
30
|
-
var MONTH_CONSTRAINTS = Object.freeze({
|
|
31
|
-
1: 31,
|
|
32
|
-
2: 29,
|
|
33
|
-
3: 31,
|
|
34
|
-
4: 30,
|
|
35
|
-
5: 31,
|
|
36
|
-
6: 30,
|
|
37
|
-
7: 31,
|
|
38
|
-
8: 31,
|
|
39
|
-
9: 30,
|
|
40
|
-
10: 31,
|
|
41
|
-
11: 30,
|
|
42
|
-
12: 31
|
|
43
|
-
});
|
|
44
|
-
var PARSE_DEFAULTS = Object.freeze({
|
|
45
|
-
second: "0",
|
|
46
|
-
minute: "*",
|
|
47
|
-
hour: "*",
|
|
48
|
-
dayOfMonth: "*",
|
|
49
|
-
month: "*",
|
|
50
|
-
dayOfWeek: "*"
|
|
51
|
-
});
|
|
52
|
-
var ALIASES = Object.freeze({
|
|
53
|
-
jan: 1,
|
|
54
|
-
feb: 2,
|
|
55
|
-
mar: 3,
|
|
56
|
-
apr: 4,
|
|
57
|
-
may: 5,
|
|
58
|
-
jun: 6,
|
|
59
|
-
jul: 7,
|
|
60
|
-
aug: 8,
|
|
61
|
-
sep: 9,
|
|
62
|
-
oct: 10,
|
|
63
|
-
nov: 11,
|
|
64
|
-
dec: 12,
|
|
65
|
-
sun: 0,
|
|
66
|
-
mon: 1,
|
|
67
|
-
tue: 2,
|
|
68
|
-
wed: 3,
|
|
69
|
-
thu: 4,
|
|
70
|
-
fri: 5,
|
|
71
|
-
sat: 6
|
|
72
|
-
});
|
|
73
|
-
var TIME_UNITS_MAP = Object.freeze({
|
|
74
|
-
SECOND: "second",
|
|
75
|
-
MINUTE: "minute",
|
|
76
|
-
HOUR: "hour",
|
|
77
|
-
DAY_OF_MONTH: "dayOfMonth",
|
|
78
|
-
MONTH: "month",
|
|
79
|
-
DAY_OF_WEEK: "dayOfWeek"
|
|
80
|
-
});
|
|
81
|
-
var TIME_UNITS = Object.freeze(Object.values(TIME_UNITS_MAP));
|
|
82
|
-
var TIME_UNITS_LEN = TIME_UNITS.length;
|
|
83
|
-
var PRESETS = Object.freeze({
|
|
84
|
-
"@yearly": "0 0 0 1 1 *",
|
|
85
|
-
"@monthly": "0 0 0 1 * *",
|
|
86
|
-
"@weekly": "0 0 0 * * 0",
|
|
87
|
-
"@daily": "0 0 0 * * *",
|
|
88
|
-
"@hourly": "0 0 * * * *",
|
|
89
|
-
"@minutely": "0 * * * * *",
|
|
90
|
-
"@secondly": "* * * * * *",
|
|
91
|
-
"@weekdays": "0 0 0 * * 1-5",
|
|
92
|
-
"@weekends": "0 0 0 * * 0,6"
|
|
93
|
-
});
|
|
94
|
-
var RE_WILDCARDS = /\*/g;
|
|
95
|
-
var RE_RANGE = /^(\d+)(?:-(\d+))?(?:\/(\d+))?$/g;
|
|
96
|
-
|
|
97
|
-
// src/utils.ts
|
|
98
|
-
function getRecordKeys(record) {
|
|
99
|
-
return Object.keys(record);
|
|
100
|
-
}
|
|
101
|
-
function getTimeZoneAndOffset(timeZone, utcOffset) {
|
|
102
|
-
if (timeZone != null && utcOffset != null)
|
|
103
|
-
throw new ExclusiveParametersError("timeZone", "utcOffset");
|
|
104
|
-
if (timeZone != null)
|
|
105
|
-
return { timeZone, utcOffset: null };
|
|
106
|
-
if (utcOffset != null)
|
|
107
|
-
return { timeZone: null, utcOffset };
|
|
108
|
-
return { timeZone: null, utcOffset: null };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/time.ts
|
|
112
|
-
class CronTime {
|
|
113
|
-
source;
|
|
114
|
-
timeZone;
|
|
115
|
-
utcOffset;
|
|
116
|
-
realDate = false;
|
|
117
|
-
second = {};
|
|
118
|
-
minute = {};
|
|
119
|
-
hour = {};
|
|
120
|
-
dayOfMonth = {};
|
|
121
|
-
month = {};
|
|
122
|
-
dayOfWeek = {};
|
|
123
|
-
constructor(source, timeZone, utcOffset) {
|
|
124
|
-
if (timeZone != null && utcOffset != null)
|
|
125
|
-
throw new ExclusiveParametersError("timeZone", "utcOffset");
|
|
126
|
-
if (timeZone) {
|
|
127
|
-
const dt = DateTime.fromObject({}, { zone: timeZone });
|
|
128
|
-
if (!dt.isValid)
|
|
129
|
-
throw new CronError("Invalid timezone.");
|
|
130
|
-
this.timeZone = timeZone;
|
|
131
|
-
}
|
|
132
|
-
if (utcOffset != null)
|
|
133
|
-
this.utcOffset = utcOffset;
|
|
134
|
-
if (source instanceof Date || source instanceof DateTime) {
|
|
135
|
-
this.source = source instanceof Date ? DateTime.fromJSDate(source) : source;
|
|
136
|
-
this.realDate = true;
|
|
137
|
-
} else {
|
|
138
|
-
this.source = source;
|
|
139
|
-
this._parse(this.source);
|
|
140
|
-
this._verifyParse();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
_getWeekDay(date) {
|
|
144
|
-
return date.weekday === 7 ? 0 : date.weekday;
|
|
145
|
-
}
|
|
146
|
-
_verifyParse() {
|
|
147
|
-
const months = getRecordKeys(this.month);
|
|
148
|
-
const daysOfMonth = getRecordKeys(this.dayOfMonth);
|
|
149
|
-
let isOk = false;
|
|
150
|
-
let lastWrongMonth = null;
|
|
151
|
-
for (const m of months) {
|
|
152
|
-
const con = MONTH_CONSTRAINTS[m];
|
|
153
|
-
for (const day of daysOfMonth) {
|
|
154
|
-
if (day <= con)
|
|
155
|
-
isOk = true;
|
|
156
|
-
}
|
|
157
|
-
if (!isOk) {
|
|
158
|
-
lastWrongMonth = m;
|
|
159
|
-
console.warn(`Month '${m}' is limited to '${con}' days.`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (!isOk && lastWrongMonth !== null) {
|
|
163
|
-
const notOkCon = MONTH_CONSTRAINTS[lastWrongMonth];
|
|
164
|
-
for (const notOkDay of daysOfMonth) {
|
|
165
|
-
if (notOkDay > notOkCon) {
|
|
166
|
-
delete this.dayOfMonth[notOkDay];
|
|
167
|
-
const fixedDay = notOkDay % notOkCon;
|
|
168
|
-
this.dayOfMonth[fixedDay] = true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
sendAt(i) {
|
|
174
|
-
let date = this.realDate && this.source instanceof DateTime ? this.source : DateTime.local();
|
|
175
|
-
if (this.timeZone)
|
|
176
|
-
date = date.setZone(this.timeZone);
|
|
177
|
-
if (this.utcOffset !== undefined) {
|
|
178
|
-
const sign = this.utcOffset < 0 ? "-" : "+";
|
|
179
|
-
const offsetHours = Math.trunc(this.utcOffset / 60);
|
|
180
|
-
const offsetHoursStr = String(Math.abs(offsetHours)).padStart(2, "0");
|
|
181
|
-
const offsetMins = Math.abs(this.utcOffset - offsetHours * 60);
|
|
182
|
-
const offsetMinsStr = String(offsetMins).padStart(2, "0");
|
|
183
|
-
const utcZone = `UTC${sign}${offsetHoursStr}:${offsetMinsStr}`;
|
|
184
|
-
date = date.setZone(utcZone);
|
|
185
|
-
if (!date.isValid)
|
|
186
|
-
throw new CronError("ERROR: You specified an invalid UTC offset.");
|
|
187
|
-
}
|
|
188
|
-
if (this.realDate) {
|
|
189
|
-
if (DateTime.local() > date)
|
|
190
|
-
throw new CronError("WARNING: Date in past. Will never be fired.");
|
|
191
|
-
return date;
|
|
192
|
-
}
|
|
193
|
-
if (i === undefined || Number.isNaN(i) || i < 0) {
|
|
194
|
-
return this.getNextDateFrom(date);
|
|
195
|
-
}
|
|
196
|
-
const dates = [];
|
|
197
|
-
for (;i > 0; i--) {
|
|
198
|
-
date = this.getNextDateFrom(date);
|
|
199
|
-
dates.push(date);
|
|
200
|
-
}
|
|
201
|
-
return dates;
|
|
202
|
-
}
|
|
203
|
-
getTimeout() {
|
|
204
|
-
return Math.max(-1, this.sendAt().toMillis() - DateTime.local().toMillis());
|
|
205
|
-
}
|
|
206
|
-
toString() {
|
|
207
|
-
return this.toJSON().join(" ");
|
|
208
|
-
}
|
|
209
|
-
toJSON() {
|
|
210
|
-
return TIME_UNITS.map((unit) => {
|
|
211
|
-
return this._wcOrAll(unit);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
getNextDateFrom(start, timeZone) {
|
|
215
|
-
if (start instanceof Date)
|
|
216
|
-
start = DateTime.fromJSDate(start);
|
|
217
|
-
let date = start;
|
|
218
|
-
const firstDate = start.toMillis();
|
|
219
|
-
if (timeZone)
|
|
220
|
-
date = date.setZone(timeZone);
|
|
221
|
-
if (!this.realDate) {
|
|
222
|
-
if (date.millisecond > 0)
|
|
223
|
-
date = date.set({ millisecond: 0, second: date.second + 1 });
|
|
224
|
-
}
|
|
225
|
-
if (!date.isValid)
|
|
226
|
-
throw new CronError("ERROR: You specified an invalid date.");
|
|
227
|
-
const maxMatch = DateTime.now().plus({ years: 8 });
|
|
228
|
-
while (true) {
|
|
229
|
-
const diff = date.toMillis() - start.toMillis();
|
|
230
|
-
if (date > maxMatch) {
|
|
231
|
-
throw new CronError(`Something went wrong. No execution date was found in the next 8 years.
|
|
2
|
+
import{log as M$}from"@stacksjs/cli";import{spawn as I4}from"child_process";class z extends Error{}class a extends z{constructor(_,$){super(`You can't specify both ${_} and ${$}`)}}class u extends Error{}class C$ extends u{constructor(_){super(`Invalid DateTime: ${_.toMessage()}`)}}class F$ extends u{constructor(_){super(`Invalid Interval: ${_.toMessage()}`)}}class Z$ extends u{constructor(_){super(`Invalid Duration: ${_.toMessage()}`)}}class p extends u{}class U_ extends u{constructor(_){super(`Invalid unit ${_}`)}}class U extends u{}class c extends u{constructor(){super("Zone is an abstract class")}}var o={year:"numeric",month:"numeric",day:"numeric"},b_={year:"numeric",month:"short",day:"numeric"},HK={year:"numeric",month:"short",day:"numeric",weekday:"short"},k_={year:"numeric",month:"long",day:"numeric"},h_={year:"numeric",month:"long",day:"numeric",weekday:"long"},g_={hour:"numeric",minute:"numeric"},f_={hour:"numeric",minute:"numeric",second:"numeric"},p_={hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},c_={hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"long"},m_={hour:"numeric",minute:"numeric",hourCycle:"h23"},u_={hour:"numeric",minute:"numeric",second:"numeric",hourCycle:"h23"},l_={hour:"numeric",minute:"numeric",second:"numeric",hourCycle:"h23",timeZoneName:"short"},d_={hour:"numeric",minute:"numeric",second:"numeric",hourCycle:"h23",timeZoneName:"long"},s_={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"},i_={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},r_={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"},n_={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},EK={year:"numeric",month:"short",day:"numeric",weekday:"short",hour:"numeric",minute:"numeric"},a_={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",timeZoneName:"short"},o_={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},t_={year:"numeric",month:"long",day:"numeric",weekday:"long",hour:"numeric",minute:"numeric",timeZoneName:"long"},e_={year:"numeric",month:"long",day:"numeric",weekday:"long",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"long"};class S{get type(){throw new c}get name(){throw new c}get ianaName(){return this.name}get isUniversal(){throw new c}offsetName(_,$){throw new c}formatOffset(_,$){throw new c}offset(_){throw new c}equals(_){throw new c}get isValid(){throw new c}}var L$=null;class t extends S{static get instance(){if(L$===null)L$=new t;return L$}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(_,{format:$,locale:K}){return _$(_,$,K)}formatOffset(_,$){return l(this.offset(_),$)}offset(_){return-new Date(_).getTimezoneOffset()}equals(_){return _.type==="system"}get isValid(){return!0}}function y4(_){if(!K$[_])K$[_]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:_,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"});return K$[_]}function k4(_,$){const K=_.format($).replace(/\u200E/g,""),Q=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(K),[,q,X,B,G,J,V,E]=Q;return[B,q,X,G,J,V,E]}function h4(_,$){const K=_.formatToParts($),Q=[];for(let q=0;q<K.length;q++){const{type:X,value:B}=K[q],G=b4[X];if(X==="era")Q[G]=B;else if(!Y(G))Q[G]=parseInt(B,10)}return Q}var K$={},b4={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6},$$={};class D extends S{static create(_){if(!$$[_])$$[_]=new D(_);return $$[_]}static resetCache(){$$={},K$={}}static isValidSpecifier(_){return this.isValidZone(_)}static isValidZone(_){if(!_)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:_}).format(),!0}catch($){return!1}}constructor(_){super();this.zoneName=_,this.valid=D.isValidZone(_)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(_,{format:$,locale:K}){return _$(_,$,K,this.name)}formatOffset(_,$){return l(this.offset(_),$)}offset(_){const $=new Date(_);if(isNaN($))return NaN;const K=y4(this.name);let[Q,q,X,B,G,J,V]=K.formatToParts?h4(K,$):k4(K,$);if(B==="BC")Q=-Math.abs(Q)+1;const C=B_({year:Q,month:q,day:X,hour:G===24?0:G,minute:J,second:V,millisecond:0});let P=+$;const A=P%1000;return P-=A>=0?A:1000+A,(C-P)/60000}equals(_){return _.type==="iana"&&_.name===this.name}get isValid(){return this.valid}}function g4(_,$={}){const K=JSON.stringify([_,$]);let Q=YK[K];if(!Q)Q=new Intl.ListFormat(_,$),YK[K]=Q;return Q}function x$(_,$={}){const K=JSON.stringify([_,$]);let Q=z$[K];if(!Q)Q=new Intl.DateTimeFormat(_,$),z$[K]=Q;return Q}function f4(_,$={}){const K=JSON.stringify([_,$]);let Q=w$[K];if(!Q)Q=new Intl.NumberFormat(_,$),w$[K]=Q;return Q}function p4(_,$={}){const{base:K,...Q}=$,q=JSON.stringify([_,Q]);let X=I$[q];if(!X)X=new Intl.RelativeTimeFormat(_,$),I$[q]=X;return X}function c4(){if(L_)return L_;else return L_=new Intl.DateTimeFormat().resolvedOptions().locale,L_}function m4(_){let $=PK[_];if(!$){const K=new Intl.Locale(_);$="getWeekInfo"in K?K.getWeekInfo():K.weekInfo,PK[_]=$}return $}function u4(_){const $=_.indexOf("-x-");if($!==-1)_=_.substring(0,$);const K=_.indexOf("-u-");if(K===-1)return[_];else{let Q,q;try{Q=x$(_).resolvedOptions(),q=_}catch(G){const J=_.substring(0,K);Q=x$(J).resolvedOptions(),q=J}const{numberingSystem:X,calendar:B}=Q;return[q,X,B]}}function l4(_,$,K){if(K||$){if(!_.includes("-u-"))_+="-u";if(K)_+=`-ca-${K}`;if($)_+=`-nu-${$}`;return _}else return _}function d4(_){const $=[];for(let K=1;K<=12;K++){const Q=H.utc(2009,K,1);$.push(_(Q))}return $}function s4(_){const $=[];for(let K=1;K<=7;K++){const Q=H.utc(2016,11,13+K);$.push(_(Q))}return $}function Q$(_,$,K,Q){const q=_.listingMode();if(q==="error")return null;else if(q==="en")return K($);else return Q($)}function i4(_){if(_.numberingSystem&&_.numberingSystem!=="latn")return!1;else return _.numberingSystem==="latn"||!_.locale||_.locale.startsWith("en")||new Intl.DateTimeFormat(_.intl).resolvedOptions().numberingSystem==="latn"}var YK={},z$={},w$={},I$={},L_=null,PK={};class RK{constructor(_,$,K){this.padTo=K.padTo||0,this.floor=K.floor||!1;const{padTo:Q,floor:q,...X}=K;if(!$||Object.keys(X).length>0){const B={useGrouping:!1,...K};if(K.padTo>0)B.minimumIntegerDigits=K.padTo;this.inf=f4(_,B)}}format(_){if(this.inf){const $=this.floor?Math.floor(_):_;return this.inf.format($)}else{const $=this.floor?Math.floor(_):G_(_,3);return Z($,this.padTo)}}}class NK{constructor(_,$,K){this.opts=K,this.originalZone=void 0;let Q=void 0;if(this.opts.timeZone)this.dt=_;else if(_.zone.type==="fixed"){const X=-1*(_.offset/60),B=X>=0?`Etc/GMT+${X}`:`Etc/GMT${X}`;if(_.offset!==0&&D.create(B).valid)Q=B,this.dt=_;else Q="UTC",this.dt=_.offset===0?_:_.setZone("UTC").plus({minutes:_.offset}),this.originalZone=_.zone}else if(_.zone.type==="system")this.dt=_;else if(_.zone.type==="iana")this.dt=_,Q=_.zone.name;else Q="UTC",this.dt=_.setZone("UTC").plus({minutes:_.offset}),this.originalZone=_.zone;const q={...this.opts};q.timeZone=q.timeZone||Q,this.dtf=x$($,q)}format(){if(this.originalZone)return this.formatToParts().map(({value:_})=>_).join("");return this.dtf.format(this.dt.toJSDate())}formatToParts(){const _=this.dtf.formatToParts(this.dt.toJSDate());if(this.originalZone)return _.map(($)=>{if($.type==="timeZoneName"){const K=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...$,value:K}}else return $});return _}resolvedOptions(){return this.dtf.resolvedOptions()}}class AK{constructor(_,$,K){if(this.opts={style:"long",...K},!$&&q$())this.rtf=p4(_,K)}format(_,$){if(this.rtf)return this.rtf.format(_,$);else return MK($,_,this.opts.numeric,this.opts.style!=="long")}formatToParts(_,$){if(this.rtf)return this.rtf.formatToParts(_,$);else return[]}}var r4={firstDay:1,minimalDays:4,weekend:[6,7]};class N{static fromOpts(_){return N.create(_.locale,_.numberingSystem,_.outputCalendar,_.weekSettings,_.defaultToEN)}static create(_,$,K,Q,q=!1){const X=_||W.defaultLocale,B=X||(q?"en-US":c4()),G=$||W.defaultNumberingSystem,J=K||W.defaultOutputCalendar,V=z_(Q)||W.defaultWeekSettings;return new N(B,G,J,V,X)}static resetCache(){L_=null,z$={},w$={},I$={}}static fromObject({locale:_,numberingSystem:$,outputCalendar:K,weekSettings:Q}={}){return N.create(_,$,K,Q)}constructor(_,$,K,Q,q){const[X,B,G]=u4(_);this.locale=X,this.numberingSystem=$||B||null,this.outputCalendar=K||G||null,this.weekSettings=Q,this.intl=l4(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=q,this.fastNumbersCached=null}get fastNumbers(){if(this.fastNumbersCached==null)this.fastNumbersCached=i4(this);return this.fastNumbersCached}listingMode(){const _=this.isEnglish(),$=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return _&&$?"en":"intl"}clone(_){if(!_||Object.getOwnPropertyNames(_).length===0)return this;else return N.create(_.locale||this.specifiedLocale,_.numberingSystem||this.numberingSystem,_.outputCalendar||this.outputCalendar,z_(_.weekSettings)||this.weekSettings,_.defaultToEN||!1)}redefaultToEN(_={}){return this.clone({..._,defaultToEN:!0})}redefaultToSystem(_={}){return this.clone({..._,defaultToEN:!1})}months(_,$=!1){return Q$(this,_,D$,()=>{const K=$?{month:_,day:"numeric"}:{month:_},Q=$?"format":"standalone";if(!this.monthsCache[Q][_])this.monthsCache[Q][_]=d4((q)=>this.extract(q,K,"month"));return this.monthsCache[Q][_]})}weekdays(_,$=!1){return Q$(this,_,j$,()=>{const K=$?{weekday:_,year:"numeric",month:"long",day:"numeric"}:{weekday:_},Q=$?"format":"standalone";if(!this.weekdaysCache[Q][_])this.weekdaysCache[Q][_]=s4((q)=>this.extract(q,K,"weekday"));return this.weekdaysCache[Q][_]})}meridiems(){return Q$(this,void 0,()=>O$,()=>{if(!this.meridiemCache){const _={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[H.utc(2016,11,13,9),H.utc(2016,11,13,19)].map(($)=>this.extract($,_,"dayperiod"))}return this.meridiemCache})}eras(_){return Q$(this,_,v$,()=>{const $={era:_};if(!this.eraCache[_])this.eraCache[_]=[H.utc(-40,1,1),H.utc(2017,1,1)].map((K)=>this.extract(K,$,"era"));return this.eraCache[_]})}extract(_,$,K){const Q=this.dtFormatter(_,$),q=Q.formatToParts(),X=q.find((B)=>B.type.toLowerCase()===K);return X?X.value:null}numberFormatter(_={}){return new RK(this.intl,_.forceSimple||this.fastNumbers,_)}dtFormatter(_,$={}){return new NK(_,this.intl,$)}relFormatter(_={}){return new AK(this.intl,this.isEnglish(),_)}listFormatter(_={}){return g4(this.intl,_)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}getWeekSettings(){if(this.weekSettings)return this.weekSettings;else if(!X$())return r4;else return m4(this.locale)}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(_){return this.locale===_.locale&&this.numberingSystem===_.numberingSystem&&this.outputCalendar===_.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}var T$=null;class x extends S{static get utcInstance(){if(T$===null)T$=new x(0);return T$}static instance(_){return _===0?x.utcInstance:new x(_)}static parseSpecifier(_){if(_){const $=_.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if($)return new x(e($[1],$[2]))}return null}constructor(_){super();this.fixed=_}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${l(this.fixed,"narrow")}`}get ianaName(){if(this.fixed===0)return"Etc/UTC";else return`Etc/GMT${l(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(_,$){return l(this.fixed,$)}get isUniversal(){return!0}offset(){return this.fixed}equals(_){return _.type==="fixed"&&_.fixed===this.fixed}get isValid(){return!0}}class B$ extends S{constructor(_){super();this.zoneName=_}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function k(_,$){let K;if(Y(_)||_===null)return $;else if(_ instanceof S)return _;else if(WK(_)){const Q=_.toLowerCase();if(Q==="default")return $;else if(Q==="local"||Q==="system")return t.instance;else if(Q==="utc"||Q==="gmt")return x.utcInstance;else return x.parseSpecifier(Q)||D.create(_)}else if(h(_))return x.instance(_);else if(typeof _==="object"&&"offset"in _&&typeof _.offset==="function")return _;else return new B$(_)}function FK(_){let $=parseInt(_,10);if(isNaN($)){$="";for(let K=0;K<_.length;K++){const Q=_.charCodeAt(K);if(_[K].search(y$.hanidec)!==-1)$+=n4.indexOf(_[K]);else for(let q in CK){const[X,B]=CK[q];if(Q>=X&&Q<=B)$+=Q-X}}return parseInt($,10)}else return $}function ZK(){J_={}}function T({numberingSystem:_},$=""){const K=_||"latn";if(!J_[K])J_[K]={};if(!J_[K][$])J_[K][$]=new RegExp(`${y$[K]}${$}`);return J_[K][$]}var y$={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},CK={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},n4=y$.hanidec.replace(/[\[|\]]/g,"").split(""),J_={};var UK=()=>Date.now(),LK="system",zK=null,xK=null,wK=null,IK=60,DK,jK=null;class W{static get now(){return UK}static set now(_){UK=_}static set defaultZone(_){LK=_}static get defaultZone(){return k(LK,t.instance)}static get defaultLocale(){return zK}static set defaultLocale(_){zK=_}static get defaultNumberingSystem(){return xK}static set defaultNumberingSystem(_){xK=_}static get defaultOutputCalendar(){return wK}static set defaultOutputCalendar(_){wK=_}static get defaultWeekSettings(){return jK}static set defaultWeekSettings(_){jK=z_(_)}static get twoDigitCutoffYear(){return IK}static set twoDigitCutoffYear(_){IK=_%100}static get throwOnInvalid(){return DK}static set throwOnInvalid(_){DK=_}static resetCaches(){N.resetCache(),D.resetCache(),H.resetCache(),ZK()}}class I{constructor(_,$){this.reason=_,this.explanation=$}toMessage(){if(this.explanation)return`${this.reason}: ${this.explanation}`;else return this.reason}}function y(_,$){return new I("unit out of range",`you specified ${$} (of type ${typeof $}) as a ${_}, which is invalid`)}function G$(_,$,K){const Q=new Date(Date.UTC(_,$-1,K));if(_<100&&_>=0)Q.setUTCFullYear(Q.getUTCFullYear()-1900);const q=Q.getUTCDay();return q===0?7:q}function SK(_,$,K){return K+($_(_)?vK:OK)[$-1]}function TK(_,$){const K=$_(_)?vK:OK,Q=K.findIndex((X)=>X<$),q=$-K[Q];return{month:Q+1,day:q}}function x_(_,$){return(_-$+7)%7+1}function w_(_,$=4,K=1){const{year:Q,month:q,day:X}=_,B=SK(Q,q,X),G=x_(G$(Q,q,X),K);let J=Math.floor((B-G+14-$)/7),V;if(J<1)V=Q-1,J=__(V,$,K);else if(J>__(Q,$,K))V=Q+1,J=1;else V=Q;return{weekYear:V,weekNumber:J,weekday:G,...D_(_)}}function b$(_,$=4,K=1){const{weekYear:Q,weekNumber:q,weekday:X}=_,B=x_(G$(Q,1,$),K),G=d(Q);let J=q*7+X-B-7+$,V;if(J<1)V=Q-1,J+=d(V);else if(J>G)V=Q+1,J-=d(Q);else V=Q;const{month:E,day:C}=TK(V,J);return{year:V,month:E,day:C,...D_(_)}}function J$(_){const{year:$,month:K,day:Q}=_,q=SK($,K,Q);return{year:$,ordinal:q,...D_(_)}}function k$(_){const{year:$,ordinal:K}=_,{month:Q,day:q}=TK($,K);return{year:$,month:Q,day:q,...D_(_)}}function h$(_,$){if(!Y(_.localWeekday)||!Y(_.localWeekNumber)||!Y(_.localWeekYear)){if(!Y(_.weekday)||!Y(_.weekNumber)||!Y(_.weekYear))throw new p("Cannot mix locale-based week fields with ISO-based week fields");if(!Y(_.localWeekday))_.weekday=_.localWeekday;if(!Y(_.localWeekNumber))_.weekNumber=_.localWeekNumber;if(!Y(_.localWeekYear))_.weekYear=_.localWeekYear;return delete _.localWeekday,delete _.localWeekNumber,delete _.localWeekYear,{minDaysInFirstWeek:$.getMinDaysInFirstWeek(),startOfWeek:$.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function yK(_,$=4,K=1){const Q=I_(_.weekYear),q=O(_.weekNumber,1,__(_.weekYear,$,K)),X=O(_.weekday,1,7);if(!Q)return y("weekYear",_.weekYear);else if(!q)return y("week",_.weekNumber);else if(!X)return y("weekday",_.weekday);else return!1}function bK(_){const $=I_(_.year),K=O(_.ordinal,1,d(_.year));if(!$)return y("year",_.year);else if(!K)return y("ordinal",_.ordinal);else return!1}function g$(_){const $=I_(_.year),K=O(_.month,1,12),Q=O(_.day,1,V_(_.year,_.month));if(!$)return y("year",_.year);else if(!K)return y("month",_.month);else if(!Q)return y("day",_.day);else return!1}function f$(_){const{hour:$,minute:K,second:Q,millisecond:q}=_,X=O($,0,23)||$===24&&K===0&&Q===0&&q===0,B=O(K,0,59),G=O(Q,0,59),J=O(q,0,999);if(!X)return y("hour",$);else if(!B)return y("minute",K);else if(!G)return y("second",Q);else if(!J)return y("millisecond",q);else return!1}var OK=[0,31,59,90,120,151,181,212,243,273,304,334],vK=[0,31,60,91,121,152,182,213,244,274,305,335];function Y(_){return typeof _==="undefined"}function h(_){return typeof _==="number"}function I_(_){return typeof _==="number"&&_%1===0}function WK(_){return typeof _==="string"}function hK(_){return Object.prototype.toString.call(_)==="[object Date]"}function q$(){try{return typeof Intl!=="undefined"&&!!Intl.RelativeTimeFormat}catch(_){return!1}}function X$(){try{return typeof Intl!=="undefined"&&!!Intl.Locale&&(("weekInfo"in Intl.Locale.prototype)||("getWeekInfo"in Intl.Locale.prototype))}catch(_){return!1}}function gK(_){return Array.isArray(_)?_:[_]}function p$(_,$,K){if(_.length===0)return;return _.reduce((Q,q)=>{const X=[$(q),q];if(!Q)return X;else if(K(Q[0],X[0])===Q[0])return Q;else return X},null)[1]}function a4(_,$){return $.reduce((K,Q)=>{return K[Q]=_[Q],K},{})}function s(_,$){return Object.prototype.hasOwnProperty.call(_,$)}function z_(_){if(_==null)return null;else if(typeof _!=="object")throw new U("Week settings must be an object");else{if(!O(_.firstDay,1,7)||!O(_.minimalDays,1,7)||!Array.isArray(_.weekend)||_.weekend.some(($)=>!O($,1,7)))throw new U("Invalid week settings");return{firstDay:_.firstDay,minimalDays:_.minimalDays,weekend:Array.from(_.weekend)}}}function O(_,$,K){return I_(_)&&_>=$&&_<=K}function o4(_,$){return _-$*Math.floor(_/$)}function Z(_,$=2){const K=_<0;let Q;if(K)Q="-"+(""+-_).padStart($,"0");else Q=(""+_).padStart($,"0");return Q}function m(_){if(Y(_)||_===null||_==="")return;else return parseInt(_,10)}function i(_){if(Y(_)||_===null||_==="")return;else return parseFloat(_)}function j_(_){if(Y(_)||_===null||_==="")return;else{const $=parseFloat("0."+_)*1000;return Math.floor($)}}function G_(_,$,K=!1){const Q=10**$;return(K?Math.trunc:Math.round)(_*Q)/Q}function $_(_){return _%4===0&&(_%100!==0||_%400===0)}function d(_){return $_(_)?366:365}function V_(_,$){const K=o4($-1,12)+1,Q=_+($-K)/12;if(K===2)return $_(Q)?29:28;else return[31,null,31,30,31,30,31,31,30,31,30,31][K-1]}function B_(_){let $=Date.UTC(_.year,_.month-1,_.day,_.hour,_.minute,_.second,_.millisecond);if(_.year<100&&_.year>=0)$=new Date($),$.setUTCFullYear(_.year,_.month-1,_.day);return+$}function kK(_,$,K){return-x_(G$(_,1,$),K)+$-1}function __(_,$=4,K=1){const Q=kK(_,$,K),q=kK(_+1,$,K);return(d(_)-Q+q)/7}function O_(_){if(_>99)return _;else return _>W.twoDigitCutoffYear?1900+_:2000+_}function _$(_,$,K,Q=null){const q=new Date(_),X={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};if(Q)X.timeZone=Q;const B={timeZoneName:$,...X},G=new Intl.DateTimeFormat(K,B).formatToParts(q).find((J)=>J.type.toLowerCase()==="timezonename");return G?G.value:null}function e(_,$){let K=parseInt(_,10);if(Number.isNaN(K))K=0;const Q=parseInt($,10)||0,q=K<0||Object.is(K,-0)?-Q:Q;return K*60+q}function c$(_){const $=Number(_);if(typeof _==="boolean"||_===""||Number.isNaN($))throw new U(`Invalid unit value ${_}`);return $}function H_(_,$){const K={};for(let Q in _)if(s(_,Q)){const q=_[Q];if(q===void 0||q===null)continue;K[$(Q)]=c$(q)}return K}function l(_,$){const K=Math.trunc(Math.abs(_/60)),Q=Math.trunc(Math.abs(_%60)),q=_>=0?"+":"-";switch($){case"short":return`${q}${Z(K,2)}:${Z(Q,2)}`;case"narrow":return`${q}${K}${Q>0?`:${Q}`:""}`;case"techie":return`${q}${Z(K,2)}${Z(Q,2)}`;default:throw new RangeError(`Value format ${$} is out of range for property format`)}}function D_(_){return a4(_,["hour","minute","second","millisecond"])}function D$(_){switch(_){case"narrow":return[...e4];case"short":return[...m$];case"long":return[...t4];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}function j$(_){switch(_){case"narrow":return[..._Q];case"short":return[...l$];case"long":return[...u$];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}function v$(_){switch(_){case"narrow":return[...QQ];case"short":return[...KQ];case"long":return[...$Q];default:return null}}function fK(_){return O$[_.hour<12?0:1]}function pK(_,$){return j$($)[_.weekday-1]}function cK(_,$){return D$($)[_.month-1]}function mK(_,$){return v$($)[_.year<0?0:1]}function MK(_,$,K="always",Q=!1){const q={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},X=["hours","minutes","seconds"].indexOf(_)===-1;if(K==="auto"&&X){const C=_==="days";switch($){case 1:return C?"tomorrow":`next ${q[_][0]}`;case-1:return C?"yesterday":`last ${q[_][0]}`;case 0:return C?"today":`this ${q[_][0]}`;default:}}const B=Object.is($,-0)||$<0,G=Math.abs($),J=G===1,V=q[_],E=Q?J?V[1]:V[2]||V[1]:J?q[_][0]:_;return B?`${G} ${E} ago`:`in ${G} ${E}`}var t4=["January","February","March","April","May","June","July","August","September","October","November","December"],m$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],e4=["J","F","M","A","M","J","J","A","S","O","N","D"],u$=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],l$=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],_Q=["M","T","W","T","F","S","S"],O$=["AM","PM"],$Q=["Before Christ","Anno Domini"],KQ=["BC","AD"],QQ=["B","A"];function uK(_,$){let K="";for(let Q of _)if(Q.literal)K+=Q.val;else K+=$(Q.val);return K}var qQ={D:o,DD:b_,DDD:k_,DDDD:h_,t:g_,tt:f_,ttt:p_,tttt:c_,T:m_,TT:u_,TTT:l_,TTTT:d_,f:s_,ff:r_,fff:a_,ffff:t_,F:i_,FF:n_,FFF:o_,FFFF:e_};class L{static create(_,$={}){return new L(_,$)}static parseFormat(_){let $=null,K="",Q=!1;const q=[];for(let X=0;X<_.length;X++){const B=_.charAt(X);if(B==="'"){if(K.length>0)q.push({literal:Q||/^\s+$/.test(K),val:K});$=null,K="",Q=!Q}else if(Q)K+=B;else if(B===$)K+=B;else{if(K.length>0)q.push({literal:/^\s+$/.test(K),val:K});K=B,$=B}}if(K.length>0)q.push({literal:Q||/^\s+$/.test(K),val:K});return q}static macroTokenToFormatOpts(_){return qQ[_]}constructor(_,$){this.opts=$,this.loc=_,this.systemLoc=null}formatWithSystemDefault(_,$){if(this.systemLoc===null)this.systemLoc=this.loc.redefaultToSystem();return this.systemLoc.dtFormatter(_,{...this.opts,...$}).format()}dtFormatter(_,$={}){return this.loc.dtFormatter(_,{...this.opts,...$})}formatDateTime(_,$){return this.dtFormatter(_,$).format()}formatDateTimeParts(_,$){return this.dtFormatter(_,$).formatToParts()}formatInterval(_,$){return this.dtFormatter(_.start,$).dtf.formatRange(_.start.toJSDate(),_.end.toJSDate())}resolvedOptions(_,$){return this.dtFormatter(_,$).resolvedOptions()}num(_,$=0){if(this.opts.forceSimple)return Z(_,$);const K={...this.opts};if($>0)K.padTo=$;return this.loc.numberFormatter(K).format(_)}formatDateTimeFromString(_,$){const K=this.loc.listingMode()==="en",Q=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",q=(P,A)=>this.loc.extract(_,P,A),X=(P)=>{if(_.isOffsetFixed&&_.offset===0&&P.allowZ)return"Z";return _.isValid?_.zone.formatOffset(_.ts,P.format):""},B=()=>K?fK(_):q({hour:"numeric",hourCycle:"h12"},"dayperiod"),G=(P,A)=>K?cK(_,P):q(A?{month:P}:{month:P,day:"numeric"},"month"),J=(P,A)=>K?pK(_,P):q(A?{weekday:P}:{weekday:P,month:"long",day:"numeric"},"weekday"),V=(P)=>{const A=L.macroTokenToFormatOpts(P);if(A)return this.formatWithSystemDefault(_,A);else return P},E=(P)=>K?mK(_,P):q({era:P},"era"),C=(P)=>{switch(P){case"S":return this.num(_.millisecond);case"u":case"SSS":return this.num(_.millisecond,3);case"s":return this.num(_.second);case"ss":return this.num(_.second,2);case"uu":return this.num(Math.floor(_.millisecond/10),2);case"uuu":return this.num(Math.floor(_.millisecond/100));case"m":return this.num(_.minute);case"mm":return this.num(_.minute,2);case"h":return this.num(_.hour%12===0?12:_.hour%12);case"hh":return this.num(_.hour%12===0?12:_.hour%12,2);case"H":return this.num(_.hour);case"HH":return this.num(_.hour,2);case"Z":return X({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return X({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return X({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return _.zone.offsetName(_.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return _.zone.offsetName(_.ts,{format:"long",locale:this.loc.locale});case"z":return _.zoneName;case"a":return B();case"d":return Q?q({day:"numeric"},"day"):this.num(_.day);case"dd":return Q?q({day:"2-digit"},"day"):this.num(_.day,2);case"c":return this.num(_.weekday);case"ccc":return J("short",!0);case"cccc":return J("long",!0);case"ccccc":return J("narrow",!0);case"E":return this.num(_.weekday);case"EEE":return J("short",!1);case"EEEE":return J("long",!1);case"EEEEE":return J("narrow",!1);case"L":return Q?q({month:"numeric",day:"numeric"},"month"):this.num(_.month);case"LL":return Q?q({month:"2-digit",day:"numeric"},"month"):this.num(_.month,2);case"LLL":return G("short",!0);case"LLLL":return G("long",!0);case"LLLLL":return G("narrow",!0);case"M":return Q?q({month:"numeric"},"month"):this.num(_.month);case"MM":return Q?q({month:"2-digit"},"month"):this.num(_.month,2);case"MMM":return G("short",!1);case"MMMM":return G("long",!1);case"MMMMM":return G("narrow",!1);case"y":return Q?q({year:"numeric"},"year"):this.num(_.year);case"yy":return Q?q({year:"2-digit"},"year"):this.num(_.year.toString().slice(-2),2);case"yyyy":return Q?q({year:"numeric"},"year"):this.num(_.year,4);case"yyyyyy":return Q?q({year:"numeric"},"year"):this.num(_.year,6);case"G":return E("short");case"GG":return E("long");case"GGGGG":return E("narrow");case"kk":return this.num(_.weekYear.toString().slice(-2),2);case"kkkk":return this.num(_.weekYear,4);case"W":return this.num(_.weekNumber);case"WW":return this.num(_.weekNumber,2);case"n":return this.num(_.localWeekNumber);case"nn":return this.num(_.localWeekNumber,2);case"ii":return this.num(_.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(_.localWeekYear,4);case"o":return this.num(_.ordinal);case"ooo":return this.num(_.ordinal,3);case"q":return this.num(_.quarter);case"qq":return this.num(_.quarter,2);case"X":return this.num(Math.floor(_.ts/1000));case"x":return this.num(_.ts);default:return V(P)}};return uK(L.parseFormat($),C)}formatDurationFromString(_,$){const K=(G)=>{switch(G[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},Q=(G)=>(J)=>{const V=K(J);if(V)return this.num(G.get(V),J.length);else return J},q=L.parseFormat($),X=q.reduce((G,{literal:J,val:V})=>J?G:G.concat(V),[]),B=_.shiftTo(...X.map(K).filter((G)=>G));return uK(q,Q(B))}}function Y_(..._){const $=_.reduce((K,Q)=>K+Q.source,"");return RegExp(`^${$}\$`)}function P_(..._){return($)=>_.reduce(([K,Q,q],X)=>{const[B,G,J]=X($,q);return[{...K,...B},G||Q,J]},[{},null,1]).slice(0,2)}function R_(_,...$){if(_==null)return[null,null];for(let[K,Q]of $){const q=K.exec(_);if(q)return Q(q)}return[null,null]}function sK(..._){return($,K)=>{const Q={};let q;for(q=0;q<_.length;q++)Q[_[q]]=m($[K+q]);return[Q,null,K+q]}}function E_(_,$,K){const Q=_[$];return Y(Q)?K:m(Q)}function PQ(_,$){return[{year:E_(_,$),month:E_(_,$+1,1),day:E_(_,$+2,1)},null,$+3]}function N_(_,$){return[{hours:E_(_,$,0),minutes:E_(_,$+1,0),seconds:E_(_,$+2,0),milliseconds:j_(_[$+3])},null,$+4]}function v_(_,$){const K=!_[$]&&!_[$+1],Q=e(_[$+1],_[$+2]),q=K?null:x.instance(Q);return[{},q,$+3]}function S_(_,$){const K=_[$]?D.create(_[$]):null;return[{},K,$+1]}function AQ(_){const[$,K,Q,q,X,B,G,J,V]=_,E=$[0]==="-",C=J&&J[0]==="-",P=(A,j=!1)=>A!==void 0&&(j||A&&E)?-A:A;return[{years:P(i(K)),months:P(i(Q)),weeks:P(i(q)),days:P(i(X)),hours:P(i(B)),minutes:P(i(G)),seconds:P(i(J),J==="-0"),milliseconds:P(j_(V),C)}]}function i$(_,$,K,Q,q,X,B){const G={year:$.length===2?O_(m($)):m($),month:m$.indexOf(K)+1,day:m(Q),hour:m(q),minute:m(X)};if(B)G.second=m(B);if(_)G.weekday=_.length>3?u$.indexOf(_)+1:l$.indexOf(_)+1;return G}function CQ(_){const[,$,K,Q,q,X,B,G,J,V,E,C]=_,P=i$($,q,Q,K,X,B,G);let A;if(J)A=MQ[J];else if(V)A=0;else A=e(E,C);return[P,new x(A)]}function FQ(_){return _.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}function lK(_){const[,$,K,Q,q,X,B,G]=_;return[i$($,q,Q,K,X,B,G),x.utcInstance]}function zQ(_){const[,$,K,Q,q,X,B,G]=_;return[i$($,G,K,Q,q,X,B),x.utcInstance]}function oK(_){return R_(_,[xQ,aK],[wQ,jQ],[IQ,OQ],[DQ,vQ])}function tK(_){return R_(FQ(_),[WQ,CQ])}function eK(_){return R_(_,[ZQ,lK],[UQ,lK],[LQ,zQ])}function _4(_){return R_(_,[NQ,AQ])}function $4(_){return R_(_,[RQ,SQ])}function K4(_){return R_(_,[TQ,aK],[yQ,bQ])}var dK=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/,iK=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,XQ=`(?:${iK.source}?(?:\\[(${dK.source})\\])?)?`,d$=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,rK=RegExp(`${d$.source}${XQ}`),s$=RegExp(`(?:T${rK.source})?`),BQ=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,GQ=/(\d{4})-?W(\d\d)(?:-?(\d))?/,JQ=/(\d{4})-?(\d{3})/,VQ=sK("weekYear","weekNumber","weekDay"),HQ=sK("year","ordinal"),EQ=/(\d{4})-(\d\d)-(\d\d)/,nK=RegExp(`${d$.source} ?(?:${iK.source}|(${dK.source}))?`),YQ=RegExp(`(?: ${nK.source})?`),RQ=RegExp(`^T?${d$.source}\$`),NQ=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/,MQ={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480},WQ=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/,ZQ=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,UQ=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,LQ=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/,xQ=Y_(BQ,s$),wQ=Y_(GQ,s$),IQ=Y_(JQ,s$),DQ=Y_(rK),aK=P_(PQ,N_,v_,S_),jQ=P_(VQ,N_,v_,S_),OQ=P_(HQ,N_,v_,S_),vQ=P_(N_,v_,S_),SQ=P_(N_),TQ=Y_(EQ,YQ),yQ=Y_(nK),bQ=P_(N_,v_,S_);function r(_,$,K=!1){const Q={values:K?$.values:{..._.values,...$.values||{}},loc:_.loc.clone($.loc),conversionAccuracy:$.conversionAccuracy||_.conversionAccuracy,matrix:$.matrix||_.matrix};return new R(Q)}function B4(_,$){let K=$.milliseconds??0;for(let Q of gQ.slice(1))if($[Q])K+=$[Q]*_[Q].milliseconds;return K}function q4(_,$){const K=B4(_,$)<0?-1:1;K_.reduceRight((Q,q)=>{if(!Y($[q])){if(Q){const X=$[Q]*K,B=_[q][Q],G=Math.floor(X/B);$[q]+=G*K,$[Q]-=G*B*K}return q}else return Q},null),K_.reduce((Q,q)=>{if(!Y($[q])){if(Q){const X=$[Q]%1;$[Q]-=X,$[q]+=X*_[Q][q]}return q}else return Q},null)}function fQ(_){const $={};for(let[K,Q]of Object.entries(_))if(Q!==0)$[K]=Q;return $}var Q4="Invalid Duration",X4={weeks:{days:7,hours:168,minutes:10080,seconds:604800,milliseconds:604800000},days:{hours:24,minutes:1440,seconds:86400,milliseconds:86400000},hours:{minutes:60,seconds:3600,milliseconds:3600000},minutes:{seconds:60,milliseconds:60000},seconds:{milliseconds:1000}},kQ={years:{quarters:4,months:12,weeks:52,days:365,hours:8760,minutes:525600,seconds:31536000,milliseconds:31536000000},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:131040,seconds:7862400,milliseconds:7862400000},months:{weeks:4,days:30,hours:720,minutes:43200,seconds:2592000,milliseconds:2592000000},...X4},b=365.2425,A_=30.436875,hQ={years:{quarters:4,months:12,weeks:b/7,days:b,hours:b*24,minutes:b*24*60,seconds:b*24*60*60,milliseconds:b*24*60*60*1000},quarters:{months:3,weeks:b/28,days:b/4,hours:b*24/4,minutes:b*24*60/4,seconds:b*24*60*60/4,milliseconds:b*24*60*60*1000/4},months:{weeks:A_/7,days:A_,hours:A_*24,minutes:A_*24*60,seconds:A_*24*60*60,milliseconds:A_*24*60*60*1000},...X4},K_=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],gQ=K_.slice(0).reverse();class R{constructor(_){const $=_.conversionAccuracy==="longterm"||!1;let K=$?hQ:kQ;if(_.matrix)K=_.matrix;this.values=_.values,this.loc=_.loc||N.create(),this.conversionAccuracy=$?"longterm":"casual",this.invalid=_.invalid||null,this.matrix=K,this.isLuxonDuration=!0}static fromMillis(_,$){return R.fromObject({milliseconds:_},$)}static fromObject(_,$={}){if(_==null||typeof _!=="object")throw new U(`Duration.fromObject: argument expected to be an object, got ${_===null?"null":typeof _}`);return new R({values:H_(_,R.normalizeUnit),loc:N.fromObject($),conversionAccuracy:$.conversionAccuracy,matrix:$.matrix})}static fromDurationLike(_){if(h(_))return R.fromMillis(_);else if(R.isDuration(_))return _;else if(typeof _==="object")return R.fromObject(_);else throw new U(`Unknown duration argument ${_} of type ${typeof _}`)}static fromISO(_,$){const[K]=_4(_);if(K)return R.fromObject(K,$);else return R.invalid("unparsable",`the input "${_}" can't be parsed as ISO 8601`)}static fromISOTime(_,$){const[K]=$4(_);if(K)return R.fromObject(K,$);else return R.invalid("unparsable",`the input "${_}" can't be parsed as ISO 8601`)}static invalid(_,$=null){if(!_)throw new U("need to specify a reason the Duration is invalid");const K=_ instanceof I?_:new I(_,$);if(W.throwOnInvalid)throw new Z$(K);else return new R({invalid:K})}static normalizeUnit(_){const $={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[_?_.toLowerCase():_];if(!$)throw new U_(_);return $}static isDuration(_){return _&&_.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(_,$={}){const K={...$,floor:$.round!==!1&&$.floor!==!1};return this.isValid?L.create(this.loc,K).formatDurationFromString(this,_):Q4}toHuman(_={}){if(!this.isValid)return Q4;const $=K_.map((K)=>{const Q=this.values[K];if(Y(Q))return null;return this.loc.numberFormatter({style:"unit",unitDisplay:"long",..._,unit:K.slice(0,-1)}).format(Q)}).filter((K)=>K);return this.loc.listFormatter({type:"conjunction",style:_.listStyle||"narrow",..._}).format($)}toObject(){if(!this.isValid)return{};return{...this.values}}toISO(){if(!this.isValid)return null;let _="P";if(this.years!==0)_+=this.years+"Y";if(this.months!==0||this.quarters!==0)_+=this.months+this.quarters*3+"M";if(this.weeks!==0)_+=this.weeks+"W";if(this.days!==0)_+=this.days+"D";if(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)_+="T";if(this.hours!==0)_+=this.hours+"H";if(this.minutes!==0)_+=this.minutes+"M";if(this.seconds!==0||this.milliseconds!==0)_+=G_(this.seconds+this.milliseconds/1000,3)+"S";if(_==="P")_+="T0S";return _}toISOTime(_={}){if(!this.isValid)return null;const $=this.toMillis();if($<0||$>=86400000)return null;return _={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",..._,includeOffset:!1},H.fromMillis($,{zone:"UTC"}).toISOTime(_)}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`Duration { values: ${JSON.stringify(this.values)} }`;else return`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){if(!this.isValid)return NaN;return B4(this.matrix,this.values)}valueOf(){return this.toMillis()}plus(_){if(!this.isValid)return this;const $=R.fromDurationLike(_),K={};for(let Q of K_)if(s($.values,Q)||s(this.values,Q))K[Q]=$.get(Q)+this.get(Q);return r(this,{values:K},!0)}minus(_){if(!this.isValid)return this;const $=R.fromDurationLike(_);return this.plus($.negate())}mapUnits(_){if(!this.isValid)return this;const $={};for(let K of Object.keys(this.values))$[K]=c$(_(this.values[K],K));return r(this,{values:$},!0)}get(_){return this[R.normalizeUnit(_)]}set(_){if(!this.isValid)return this;const $={...this.values,...H_(_,R.normalizeUnit)};return r(this,{values:$})}reconfigure({locale:_,numberingSystem:$,conversionAccuracy:K,matrix:Q}={}){const X={loc:this.loc.clone({locale:_,numberingSystem:$}),matrix:Q,conversionAccuracy:K};return r(this,X)}as(_){return this.isValid?this.shiftTo(_).get(_):NaN}normalize(){if(!this.isValid)return this;const _=this.toObject();return q4(this.matrix,_),r(this,{values:_},!0)}rescale(){if(!this.isValid)return this;const _=fQ(this.normalize().shiftToAll().toObject());return r(this,{values:_},!0)}shiftTo(..._){if(!this.isValid)return this;if(_.length===0)return this;_=_.map((X)=>R.normalizeUnit(X));const $={},K={},Q=this.toObject();let q;for(let X of K_)if(_.indexOf(X)>=0){q=X;let B=0;for(let J in K)B+=this.matrix[J][X]*K[J],K[J]=0;if(h(Q[X]))B+=Q[X];const G=Math.trunc(B);$[X]=G,K[X]=(B*1000-G*1000)/1000}else if(h(Q[X]))K[X]=Q[X];for(let X in K)if(K[X]!==0)$[q]+=X===q?K[X]:K[X]/this.matrix[q][X];return q4(this.matrix,$),r(this,{values:$},!0)}shiftToAll(){if(!this.isValid)return this;return this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds")}negate(){if(!this.isValid)return this;const _={};for(let $ of Object.keys(this.values))_[$]=this.values[$]===0?0:-this.values[$];return r(this,{values:_},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(_){if(!this.isValid||!_.isValid)return!1;if(!this.loc.equals(_.loc))return!1;function $(K,Q){if(K===void 0||K===0)return Q===void 0||Q===0;return K===Q}for(let K of K_)if(!$(this.values[K],_.values[K]))return!1;return!0}}function pQ(_,$){if(!_||!_.isValid)return F.invalid("missing or invalid start");else if(!$||!$.isValid)return F.invalid("missing or invalid end");else if($<_)return F.invalid("end before start",`The end of an interval must be after its start, but you had start=${_.toISO()} and end=${$.toISO()}`);else return null}var M_="Invalid Interval";class F{constructor(_){this.s=_.start,this.e=_.end,this.invalid=_.invalid||null,this.isLuxonInterval=!0}static invalid(_,$=null){if(!_)throw new U("need to specify a reason the Interval is invalid");const K=_ instanceof I?_:new I(_,$);if(W.throwOnInvalid)throw new F$(K);else return new F({invalid:K})}static fromDateTimes(_,$){const K=W_(_),Q=W_($),q=pQ(K,Q);if(q==null)return new F({start:K,end:Q});else return q}static after(_,$){const K=R.fromDurationLike($),Q=W_(_);return F.fromDateTimes(Q,Q.plus(K))}static before(_,$){const K=R.fromDurationLike($),Q=W_(_);return F.fromDateTimes(Q.minus(K),Q)}static fromISO(_,$){const[K,Q]=(_||"").split("/",2);if(K&&Q){let q,X;try{q=H.fromISO(K,$),X=q.isValid}catch(J){X=!1}let B,G;try{B=H.fromISO(Q,$),G=B.isValid}catch(J){G=!1}if(X&&G)return F.fromDateTimes(q,B);if(X){const J=R.fromISO(Q,$);if(J.isValid)return F.after(q,J)}else if(G){const J=R.fromISO(K,$);if(J.isValid)return F.before(B,J)}}return F.invalid("unparsable",`the input "${_}" can't be parsed as ISO 8601`)}static isInterval(_){return _&&_.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(_="milliseconds"){return this.isValid?this.toDuration(...[_]).get(_):NaN}count(_="milliseconds",$){if(!this.isValid)return NaN;const K=this.start.startOf(_,$);let Q;if($?.useLocaleWeeks)Q=this.end.reconfigure({locale:K.locale});else Q=this.end;return Q=Q.startOf(_,$),Math.floor(Q.diff(K,_).get(_))+(Q.valueOf()!==this.end.valueOf())}hasSame(_){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,_):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(_){if(!this.isValid)return!1;return this.s>_}isBefore(_){if(!this.isValid)return!1;return this.e<=_}contains(_){if(!this.isValid)return!1;return this.s<=_&&this.e>_}set({start:_,end:$}={}){if(!this.isValid)return this;return F.fromDateTimes(_||this.s,$||this.e)}splitAt(..._){if(!this.isValid)return[];const $=_.map(W_).filter((X)=>this.contains(X)).sort((X,B)=>X.toMillis()-B.toMillis()),K=[];let{s:Q}=this,q=0;while(Q<this.e){const X=$[q]||this.e,B=+X>+this.e?this.e:X;K.push(F.fromDateTimes(Q,B)),Q=B,q+=1}return K}splitBy(_){const $=R.fromDurationLike(_);if(!this.isValid||!$.isValid||$.as("milliseconds")===0)return[];let{s:K}=this,Q=1,q;const X=[];while(K<this.e){const B=this.start.plus($.mapUnits((G)=>G*Q));q=+B>+this.e?this.e:B,X.push(F.fromDateTimes(K,q)),K=q,Q+=1}return X}divideEqually(_){if(!this.isValid)return[];return this.splitBy(this.length()/_).slice(0,_)}overlaps(_){return this.e>_.s&&this.s<_.e}abutsStart(_){if(!this.isValid)return!1;return+this.e===+_.s}abutsEnd(_){if(!this.isValid)return!1;return+_.e===+this.s}engulfs(_){if(!this.isValid)return!1;return this.s<=_.s&&this.e>=_.e}equals(_){if(!this.isValid||!_.isValid)return!1;return this.s.equals(_.s)&&this.e.equals(_.e)}intersection(_){if(!this.isValid)return this;const $=this.s>_.s?this.s:_.s,K=this.e<_.e?this.e:_.e;if($>=K)return null;else return F.fromDateTimes($,K)}union(_){if(!this.isValid)return this;const $=this.s<_.s?this.s:_.s,K=this.e>_.e?this.e:_.e;return F.fromDateTimes($,K)}static merge(_){const[$,K]=_.sort((Q,q)=>Q.s-q.s).reduce(([Q,q],X)=>{if(!q)return[Q,X];else if(q.overlaps(X)||q.abutsStart(X))return[Q,q.union(X)];else return[Q.concat([q]),X]},[[],null]);if(K)$.push(K);return $}static xor(_){let $=null,K=0;const Q=[],q=_.map((G)=>[{time:G.s,type:"s"},{time:G.e,type:"e"}]),X=Array.prototype.concat(...q),B=X.sort((G,J)=>G.time-J.time);for(let G of B)if(K+=G.type==="s"?1:-1,K===1)$=G.time;else{if($&&+$!==+G.time)Q.push(F.fromDateTimes($,G.time));$=null}return F.merge(Q)}difference(..._){return F.xor([this].concat(_)).map(($)=>this.intersection($)).filter(($)=>$&&!$.isEmpty())}toString(){if(!this.isValid)return M_;return`[${this.s.toISO()} \u2013 ${this.e.toISO()})`}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`;else return`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(_=o,$={}){return this.isValid?L.create(this.s.loc.clone($),_).formatInterval(this):M_}toISO(_){if(!this.isValid)return M_;return`${this.s.toISO(_)}/${this.e.toISO(_)}`}toISODate(){if(!this.isValid)return M_;return`${this.s.toISODate()}/${this.e.toISODate()}`}toISOTime(_){if(!this.isValid)return M_;return`${this.s.toISOTime(_)}/${this.e.toISOTime(_)}`}toFormat(_,{separator:$=" \u2013 "}={}){if(!this.isValid)return M_;return`${this.s.toFormat(_)}${$}${this.e.toFormat(_)}`}toDuration(_,$){if(!this.isValid)return R.invalid(this.invalidReason);return this.e.diff(this.s,_,$)}mapEndpoints(_){return F.fromDateTimes(_(this.s),_(this.e))}}class Q_{static hasDST(_=W.defaultZone){const $=H.now().setZone(_).set({month:12});return!_.isUniversal&&$.offset!==$.set({month:6}).offset}static isValidIANAZone(_){return D.isValidZone(_)}static normalizeZone(_){return k(_,W.defaultZone)}static getStartOfWeek({locale:_=null,locObj:$=null}={}){return($||N.create(_)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:_=null,locObj:$=null}={}){return($||N.create(_)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:_=null,locObj:$=null}={}){return($||N.create(_)).getWeekendDays().slice()}static months(_="long",{locale:$=null,numberingSystem:K=null,locObj:Q=null,outputCalendar:q="gregory"}={}){return(Q||N.create($,K,q)).months(_)}static monthsFormat(_="long",{locale:$=null,numberingSystem:K=null,locObj:Q=null,outputCalendar:q="gregory"}={}){return(Q||N.create($,K,q)).months(_,!0)}static weekdays(_="long",{locale:$=null,numberingSystem:K=null,locObj:Q=null}={}){return(Q||N.create($,K,null)).weekdays(_)}static weekdaysFormat(_="long",{locale:$=null,numberingSystem:K=null,locObj:Q=null}={}){return(Q||N.create($,K,null)).weekdays(_,!0)}static meridiems({locale:_=null}={}){return N.create(_).meridiems()}static eras(_="short",{locale:$=null}={}){return N.create($,null,"gregory").eras(_)}static features(){return{relative:q$(),localeWeek:X$()}}}function G4(_,$){const K=(q)=>q.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),Q=K($)-K(_);return Math.floor(R.fromMillis(Q).as("days"))}function cQ(_,$,K){const Q=[["years",(J,V)=>V.year-J.year],["quarters",(J,V)=>V.quarter-J.quarter+(V.year-J.year)*4],["months",(J,V)=>V.month-J.month+(V.year-J.year)*12],["weeks",(J,V)=>{const E=G4(J,V);return(E-E%7)/7}],["days",G4]],q={},X=_;let B,G;for(let[J,V]of Q)if(K.indexOf(J)>=0)if(B=J,q[J]=V(_,$),G=X.plus(q),G>$){if(q[J]--,_=X.plus(q),_>$)G=_,q[J]--,_=X.plus(q)}else _=G;return[_,q,G,B]}function r$(_,$,K,Q){let[q,X,B,G]=cQ(_,$,K);const J=$-q,V=K.filter((C)=>["hours","minutes","seconds","milliseconds"].indexOf(C)>=0);if(V.length===0){if(B<$)B=q.plus({[G]:1});if(B!==q)X[G]=(X[G]||0)+J/(B-q)}const E=R.fromObject(X,Q);if(V.length>0)return R.fromMillis(J,Q).shiftTo(...V).plus(E);else return E}function M(_,$=(K)=>K){return{regex:_,deser:([K])=>$(FK(K))}}function lQ(_){return _.replace(/\./g,"\\.?").replace(E4,H4)}function J4(_){return _.replace(/\./g,"").replace(E4," ").toLowerCase()}function g(_,$){if(_===null)return null;else return{regex:RegExp(_.map(lQ).join("|")),deser:([K])=>_.findIndex((Q)=>J4(K)===J4(Q))+$}}function V4(_,$){return{regex:_,deser:([,K,Q])=>e(K,Q),groups:$}}function V$(_){return{regex:_,deser:([$])=>$}}function dQ(_){return _.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function sQ(_,$){const K=T($),Q=T($,"{2}"),q=T($,"{3}"),X=T($,"{4}"),B=T($,"{6}"),G=T($,"{1,2}"),J=T($,"{1,3}"),V=T($,"{1,6}"),E=T($,"{1,9}"),C=T($,"{2,4}"),P=T($,"{4,6}"),A=(v)=>({regex:RegExp(dQ(v.val)),deser:([f])=>f,literal:!0}),w=((v)=>{if(_.literal)return A(v);switch(v.val){case"G":return g($.eras("short"),0);case"GG":return g($.eras("long"),0);case"y":return M(V);case"yy":return M(C,O_);case"yyyy":return M(X);case"yyyyy":return M(P);case"yyyyyy":return M(B);case"M":return M(G);case"MM":return M(Q);case"MMM":return g($.months("short",!0),1);case"MMMM":return g($.months("long",!0),1);case"L":return M(G);case"LL":return M(Q);case"LLL":return g($.months("short",!1),1);case"LLLL":return g($.months("long",!1),1);case"d":return M(G);case"dd":return M(Q);case"o":return M(J);case"ooo":return M(q);case"HH":return M(Q);case"H":return M(G);case"hh":return M(Q);case"h":return M(G);case"mm":return M(Q);case"m":return M(G);case"q":return M(G);case"qq":return M(Q);case"s":return M(G);case"ss":return M(Q);case"S":return M(J);case"SSS":return M(q);case"u":return V$(E);case"uu":return V$(G);case"uuu":return M(K);case"a":return g($.meridiems(),0);case"kkkk":return M(X);case"kk":return M(C,O_);case"W":return M(G);case"WW":return M(Q);case"E":case"c":return M(K);case"EEE":return g($.weekdays("short",!1),1);case"EEEE":return g($.weekdays("long",!1),1);case"ccc":return g($.weekdays("short",!0),1);case"cccc":return g($.weekdays("long",!0),1);case"Z":case"ZZ":return V4(new RegExp(`([+-]${G.source})(?::(${Q.source}))?`),2);case"ZZZ":return V4(new RegExp(`([+-]${G.source})(${Q.source})?`),2);case"z":return V$(/[a-z_+-/]{1,256}?/i);case" ":return V$(/[^\S\n\r]/);default:return A(v)}})(_)||{invalidReason:mQ};return w.token=_,w}function rQ(_,$,K){const{type:Q,value:q}=_;if(Q==="literal"){const J=/^\s+$/.test(q);return{literal:!J,val:J?" ":q}}const X=$[Q];let B=Q;if(Q==="hour")if($.hour12!=null)B=$.hour12?"hour12":"hour24";else if($.hourCycle!=null)if($.hourCycle==="h11"||$.hourCycle==="h12")B="hour12";else B="hour24";else B=K.hour12?"hour12":"hour24";let G=iQ[B];if(typeof G==="object")G=G[X];if(G)return{literal:!1,val:G};return}function nQ(_){return[`^${_.map((K)=>K.regex).reduce((K,Q)=>`${K}(${Q.source})`,"")}\$`,_]}function aQ(_,$,K){const Q=_.match($);if(Q){const q={};let X=1;for(let B in K)if(s(K,B)){const G=K[B],J=G.groups?G.groups+1:1;if(!G.literal&&G.token)q[G.token.val[0]]=G.deser(Q.slice(X,X+J));X+=J}return[Q,q]}else return[Q,{}]}function oQ(_){const $=(X)=>{switch(X){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let K=null,Q;if(!Y(_.z))K=D.create(_.z);if(!Y(_.Z)){if(!K)K=new x(_.Z);Q=_.Z}if(!Y(_.q))_.M=(_.q-1)*3+1;if(!Y(_.h)){if(_.h<12&&_.a===1)_.h+=12;else if(_.h===12&&_.a===0)_.h=0}if(_.G===0&&_.y)_.y=-_.y;if(!Y(_.u))_.S=j_(_.u);return[Object.keys(_).reduce((X,B)=>{const G=$(B);if(G)X[G]=_[B];return X},{}),K,Q]}function tQ(){if(!n$)n$=H.fromMillis(1555555555555);return n$}function eQ(_,$){if(_.literal)return _;const K=L.macroTokenToFormatOpts(_.val),Q=t$(K,$);if(Q==null||Q.includes(void 0))return _;return Q}function a$(_,$){return Array.prototype.concat(..._.map((K)=>eQ(K,$)))}function o$(_,$,K){return new H$(_,K).explainFromTokens($)}function Y4(_,$,K){const{result:Q,zone:q,specificOffset:X,invalidReason:B}=o$(_,$,K);return[Q,q,X,B]}function t$(_,$){if(!_)return null;const Q=L.create($,_).dtFormatter(tQ()),q=Q.formatToParts(),X=Q.resolvedOptions();return q.map((B)=>rQ(B,_,X))}var mQ="missing Intl.DateTimeFormat.formatToParts support",uQ=String.fromCharCode(160),H4=`[ ${uQ}]`,E4=new RegExp(H4,"g"),iQ={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}},n$=null;class H${constructor(_,$){if(this.locale=_,this.format=$,this.tokens=a$(L.parseFormat($),_),this.units=this.tokens.map((K)=>sQ(K,_)),this.disqualifyingUnit=this.units.find((K)=>K.invalidReason),!this.disqualifyingUnit){const[K,Q]=nQ(this.units);this.regex=RegExp(K,"i"),this.handlers=Q}}explainFromTokens(_){if(!this.isValid)return{input:_,tokens:this.tokens,invalidReason:this.invalidReason};else{const[$,K]=aQ(_,this.regex,this.handlers),[Q,q,X]=K?oQ(K):[null,null,void 0];if(s(K,"a")&&s(K,"H"))throw new p("Can't include meridiem when specifying 24-hour format");return{input:_,tokens:this.tokens,regex:this.regex,rawMatches:$,matches:K,result:Q,zone:q,specificOffset:X}}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function T_(_){return new I("unsupported zone",`the zone "${_.name}" is not supported`)}function _K(_){if(_.weekData===null)_.weekData=w_(_.c);return _.weekData}function $K(_){if(_.localWeekData===null)_.localWeekData=w_(_.c,_.loc.getMinDaysInFirstWeek(),_.loc.getStartOfWeek());return _.localWeekData}function q_(_,$){const K={ts:_.ts,zone:_.zone,c:_.c,o:_.o,loc:_.loc,invalid:_.invalid};return new H({...K,...$,old:K})}function F4(_,$,K){let Q=_-$*60*1000;const q=K.offset(Q);if($===q)return[Q,$];Q-=(q-$)*60*1000;const X=K.offset(Q);if(q===X)return[Q,q];return[_-Math.min(q,X)*60*1000,Math.max(q,X)]}function E$(_,$){_+=$*60*1000;const K=new Date(_);return{year:K.getUTCFullYear(),month:K.getUTCMonth()+1,day:K.getUTCDate(),hour:K.getUTCHours(),minute:K.getUTCMinutes(),second:K.getUTCSeconds(),millisecond:K.getUTCMilliseconds()}}function P$(_,$,K){return F4(B_(_),$,K)}function R4(_,$){const K=_.o,Q=_.c.year+Math.trunc($.years),q=_.c.month+Math.trunc($.months)+Math.trunc($.quarters)*3,X={..._.c,year:Q,month:q,day:Math.min(_.c.day,V_(Q,q))+Math.trunc($.days)+Math.trunc($.weeks)*7},B=R.fromObject({years:$.years-Math.trunc($.years),quarters:$.quarters-Math.trunc($.quarters),months:$.months-Math.trunc($.months),weeks:$.weeks-Math.trunc($.weeks),days:$.days-Math.trunc($.days),hours:$.hours,minutes:$.minutes,seconds:$.seconds,milliseconds:$.milliseconds}).as("milliseconds"),G=B_(X);let[J,V]=F4(G,K,_.zone);if(B!==0)J+=B,V=_.zone.offset(J);return{ts:J,o:V}}function C_(_,$,K,Q,q,X){const{setZone:B,zone:G}=K;if(_&&Object.keys(_).length!==0||$){const J=$||G,V=H.fromObject(_,{...K,zone:J,specificOffset:X});return B?V:V.setZone(G)}else return H.invalid(new I("unparsable",`the input "${q}" can't be parsed as ${Q}`))}function Y$(_,$,K=!0){return _.isValid?L.create(N.create("en-US"),{allowZ:K,forceSimple:!0}).formatDateTimeFromString(_,$):null}function KK(_,$){const K=_.c.year>9999||_.c.year<0;let Q="";if(K&&_.c.year>=0)Q+="+";if(Q+=Z(_.c.year,K?6:4),$)Q+="-",Q+=Z(_.c.month),Q+="-",Q+=Z(_.c.day);else Q+=Z(_.c.month),Q+=Z(_.c.day);return Q}function N4(_,$,K,Q,q,X){let B=Z(_.c.hour);if($){if(B+=":",B+=Z(_.c.minute),_.c.millisecond!==0||_.c.second!==0||!K)B+=":"}else B+=Z(_.c.minute);if(_.c.millisecond!==0||_.c.second!==0||!K){if(B+=Z(_.c.second),_.c.millisecond!==0||!Q)B+=".",B+=Z(_.c.millisecond,3)}if(q)if(_.isOffsetFixed&&_.offset===0&&!X)B+="Z";else if(_.o<0)B+="-",B+=Z(Math.trunc(-_.o/60)),B+=":",B+=Z(Math.trunc(-_.o%60));else B+="+",B+=Z(Math.trunc(_.o/60)),B+=":",B+=Z(Math.trunc(_.o%60));if(X)B+="["+_.zone.ianaName+"]";return B}function q5(_){const $={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[_.toLowerCase()];if(!$)throw new U_(_);return $}function A4(_){switch(_.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return q5(_)}}function X5(_){if(!N$[_]){if(R$===void 0)R$=W.now();N$[_]=_.offset(R$)}return N$[_]}function M4(_,$){const K=k($.zone,W.defaultZone);if(!K.isValid)return H.invalid(T_(K));const Q=N.fromObject($);let q,X;if(!Y(_.year)){for(let J of U4)if(Y(_[J]))_[J]=Z4[J];const B=g$(_)||f$(_);if(B)return H.invalid(B);const G=X5(K);[q,X]=P$(_,G,K)}else q=W.now();return new H({ts:q,zone:K,loc:Q,o:X})}function W4(_,$,K){const Q=Y(K.round)?!0:K.round,q=(B,G)=>{return B=G_(B,Q||K.calendary?0:2,!0),$.loc.clone(K).relFormatter(K).format(B,G)},X=(B)=>{if(K.calendary)if(!$.hasSame(_,B))return $.startOf(B).diff(_.startOf(B),B).get(B);else return 0;else return $.diff(_,B).get(B)};if(K.unit)return q(X(K.unit),K.unit);for(let B of K.units){const G=X(B);if(Math.abs(G)>=1)return q(G,B)}return q(_>$?-0:0,K.units[K.units.length-1])}function C4(_){let $={},K;if(_.length>0&&typeof _[_.length-1]==="object")$=_[_.length-1],K=Array.from(_).slice(0,_.length-1);else K=Array.from(_);return[$,K]}function W_(_){if(H.isDateTime(_))return _;else if(_&&_.valueOf&&h(_.valueOf()))return H.fromJSDate(_);else if(_&&typeof _==="object")return H.fromObject(_);else throw new U(`Unknown datetime argument: ${_}, of type ${typeof _}`)}var e$="Invalid DateTime",P4=8640000000000000,Z4={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},_5={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},$5={ordinal:1,hour:0,minute:0,second:0,millisecond:0},U4=["year","month","day","hour","minute","second","millisecond"],K5=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Q5=["year","ordinal","hour","minute","second","millisecond"],R$,N$={};class H{constructor(_){const $=_.zone||W.defaultZone;let K=_.invalid||(Number.isNaN(_.ts)?new I("invalid input"):null)||(!$.isValid?T_($):null);this.ts=Y(_.ts)?W.now():_.ts;let Q=null,q=null;if(!K)if(_.old&&_.old.ts===this.ts&&_.old.zone.equals($))[Q,q]=[_.old.c,_.old.o];else{const B=h(_.o)&&!_.old?_.o:$.offset(this.ts);Q=E$(this.ts,B),K=Number.isNaN(Q.year)?new I("invalid input"):null,Q=K?null:Q,q=K?null:B}this._zone=$,this.loc=_.loc||N.create(),this.invalid=K,this.weekData=null,this.localWeekData=null,this.c=Q,this.o=q,this.isLuxonDateTime=!0}static now(){return new H({})}static local(){const[_,$]=C4(arguments),[K,Q,q,X,B,G,J]=$;return M4({year:K,month:Q,day:q,hour:X,minute:B,second:G,millisecond:J},_)}static utc(){const[_,$]=C4(arguments),[K,Q,q,X,B,G,J]=$;return _.zone=x.utcInstance,M4({year:K,month:Q,day:q,hour:X,minute:B,second:G,millisecond:J},_)}static fromJSDate(_,$={}){const K=hK(_)?_.valueOf():NaN;if(Number.isNaN(K))return H.invalid("invalid input");const Q=k($.zone,W.defaultZone);if(!Q.isValid)return H.invalid(T_(Q));return new H({ts:K,zone:Q,loc:N.fromObject($)})}static fromMillis(_,$={}){if(!h(_))throw new U(`fromMillis requires a numerical input, but received a ${typeof _} with value ${_}`);else if(_<-P4||_>P4)return H.invalid("Timestamp out of range");else return new H({ts:_,zone:k($.zone,W.defaultZone),loc:N.fromObject($)})}static fromSeconds(_,$={}){if(!h(_))throw new U("fromSeconds requires a numerical input");else return new H({ts:_*1000,zone:k($.zone,W.defaultZone),loc:N.fromObject($)})}static fromObject(_,$={}){_=_||{};const K=k($.zone,W.defaultZone);if(!K.isValid)return H.invalid(T_(K));const Q=N.fromObject($),q=H_(_,A4),{minDaysInFirstWeek:X,startOfWeek:B}=h$(q,Q),G=W.now(),J=!Y($.specificOffset)?$.specificOffset:K.offset(G),V=!Y(q.ordinal),E=!Y(q.year),C=!Y(q.month)||!Y(q.day),P=E||C,A=q.weekYear||q.weekNumber;if((P||V)&&A)throw new p("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(C&&V)throw new p("Can't mix ordinal dates with month/day");const j=A||q.weekday&&!P;let w,v,f=E$(G,J);if(j)w=K5,v=_5,f=w_(f,X,B);else if(V)w=Q5,v=$5,f=J$(f);else w=U4,v=Z4;let W$=!1;for(let Z_ of w){const T4=q[Z_];if(!Y(T4))W$=!0;else if(W$)q[Z_]=v[Z_];else q[Z_]=f[Z_]}const j4=j?yK(q,X,B):V?bK(q):g$(q),VK=j4||f$(q);if(VK)return H.invalid(VK);const O4=j?b$(q,X,B):V?k$(q):q,[v4,S4]=P$(O4,J,K),F_=new H({ts:v4,zone:K,o:S4,loc:Q});if(q.weekday&&P&&_.weekday!==F_.weekday)return H.invalid("mismatched weekday",`you can't specify both a weekday of ${q.weekday} and a date of ${F_.toISO()}`);if(!F_.isValid)return H.invalid(F_.invalid);return F_}static fromISO(_,$={}){const[K,Q]=oK(_);return C_(K,Q,$,"ISO 8601",_)}static fromRFC2822(_,$={}){const[K,Q]=tK(_);return C_(K,Q,$,"RFC 2822",_)}static fromHTTP(_,$={}){const[K,Q]=eK(_);return C_(K,Q,$,"HTTP",$)}static fromFormat(_,$,K={}){if(Y(_)||Y($))throw new U("fromFormat requires an input string and a format");const{locale:Q=null,numberingSystem:q=null}=K,X=N.fromOpts({locale:Q,numberingSystem:q,defaultToEN:!0}),[B,G,J,V]=Y4(X,_,$);if(V)return H.invalid(V);else return C_(B,G,K,`format ${$}`,_,J)}static fromString(_,$,K={}){return H.fromFormat(_,$,K)}static fromSQL(_,$={}){const[K,Q]=K4(_);return C_(K,Q,$,"SQL",_)}static invalid(_,$=null){if(!_)throw new U("need to specify a reason the DateTime is invalid");const K=_ instanceof I?_:new I(_,$);if(W.throwOnInvalid)throw new C$(K);else return new H({invalid:K})}static isDateTime(_){return _&&_.isLuxonDateTime||!1}static parseFormatForOpts(_,$={}){const K=t$(_,N.fromObject($));return!K?null:K.map((Q)=>Q?Q.val:null).join("")}static expandFormat(_,$={}){return a$(L.parseFormat(_),N.fromObject($)).map((Q)=>Q.val).join("")}static resetCache(){R$=void 0,N$={}}get(_){return this[_]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?_K(this).weekYear:NaN}get weekNumber(){return this.isValid?_K(this).weekNumber:NaN}get weekday(){return this.isValid?_K(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?$K(this).weekday:NaN}get localWeekNumber(){return this.isValid?$K(this).weekNumber:NaN}get localWeekYear(){return this.isValid?$K(this).weekYear:NaN}get ordinal(){return this.isValid?J$(this.c).ordinal:NaN}get monthShort(){return this.isValid?Q_.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Q_.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Q_.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Q_.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){if(this.isValid)return this.zone.offsetName(this.ts,{format:"short",locale:this.locale});else return null}get offsetNameLong(){if(this.isValid)return this.zone.offsetName(this.ts,{format:"long",locale:this.locale});else return null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){if(this.isOffsetFixed)return!1;else return this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const _=86400000,$=60000,K=B_(this.c),Q=this.zone.offset(K-_),q=this.zone.offset(K+_),X=this.zone.offset(K-Q*$),B=this.zone.offset(K-q*$);if(X===B)return[this];const G=K-X*$,J=K-B*$,V=E$(G,X),E=E$(J,B);if(V.hour===E.hour&&V.minute===E.minute&&V.second===E.second&&V.millisecond===E.millisecond)return[q_(this,{ts:G}),q_(this,{ts:J})];return[this]}get isInLeapYear(){return $_(this.year)}get daysInMonth(){return V_(this.year,this.month)}get daysInYear(){return this.isValid?d(this.year):NaN}get weeksInWeekYear(){return this.isValid?__(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?__(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(_={}){const{locale:$,numberingSystem:K,calendar:Q}=L.create(this.loc.clone(_),_).resolvedOptions(this);return{locale:$,numberingSystem:K,outputCalendar:Q}}toUTC(_=0,$={}){return this.setZone(x.instance(_),$)}toLocal(){return this.setZone(W.defaultZone)}setZone(_,{keepLocalTime:$=!1,keepCalendarTime:K=!1}={}){if(_=k(_,W.defaultZone),_.equals(this.zone))return this;else if(!_.isValid)return H.invalid(T_(_));else{let Q=this.ts;if($||K){const q=_.offset(this.ts),X=this.toObject();[Q]=P$(X,q,_)}return q_(this,{ts:Q,zone:_})}}reconfigure({locale:_,numberingSystem:$,outputCalendar:K}={}){const Q=this.loc.clone({locale:_,numberingSystem:$,outputCalendar:K});return q_(this,{loc:Q})}setLocale(_){return this.reconfigure({locale:_})}set(_){if(!this.isValid)return this;const $=H_(_,A4),{minDaysInFirstWeek:K,startOfWeek:Q}=h$($,this.loc),q=!Y($.weekYear)||!Y($.weekNumber)||!Y($.weekday),X=!Y($.ordinal),B=!Y($.year),G=!Y($.month)||!Y($.day),J=B||G,V=$.weekYear||$.weekNumber;if((J||X)&&V)throw new p("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(G&&X)throw new p("Can't mix ordinal dates with month/day");let E;if(q)E=b$({...w_(this.c,K,Q),...$},K,Q);else if(!Y($.ordinal))E=k$({...J$(this.c),...$});else if(E={...this.toObject(),...$},Y($.day))E.day=Math.min(V_(E.year,E.month),E.day);const[C,P]=P$(E,this.o,this.zone);return q_(this,{ts:C,o:P})}plus(_){if(!this.isValid)return this;const $=R.fromDurationLike(_);return q_(this,R4(this,$))}minus(_){if(!this.isValid)return this;const $=R.fromDurationLike(_).negate();return q_(this,R4(this,$))}startOf(_,{useLocaleWeeks:$=!1}={}){if(!this.isValid)return this;const K={},Q=R.normalizeUnit(_);switch(Q){case"years":K.month=1;case"quarters":case"months":K.day=1;case"weeks":case"days":K.hour=0;case"hours":K.minute=0;case"minutes":K.second=0;case"seconds":K.millisecond=0;break;case"milliseconds":break}if(Q==="weeks")if($){const q=this.loc.getStartOfWeek(),{weekday:X}=this;if(X<q)K.weekNumber=this.weekNumber-1;K.weekday=q}else K.weekday=1;if(Q==="quarters"){const q=Math.ceil(this.month/3);K.month=(q-1)*3+1}return this.set(K)}endOf(_,$){return this.isValid?this.plus({[_]:1}).startOf(_,$).minus(1):this}toFormat(_,$={}){return this.isValid?L.create(this.loc.redefaultToEN($)).formatDateTimeFromString(this,_):e$}toLocaleString(_=o,$={}){return this.isValid?L.create(this.loc.clone($),_).formatDateTime(this):e$}toLocaleParts(_={}){return this.isValid?L.create(this.loc.clone(_),_).formatDateTimeParts(this):[]}toISO({format:_="extended",suppressSeconds:$=!1,suppressMilliseconds:K=!1,includeOffset:Q=!0,extendedZone:q=!1}={}){if(!this.isValid)return null;const X=_==="extended";let B=KK(this,X);return B+="T",B+=N4(this,X,$,K,Q,q),B}toISODate({format:_="extended"}={}){if(!this.isValid)return null;return KK(this,_==="extended")}toISOWeekDate(){return Y$(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:_=!1,suppressSeconds:$=!1,includeOffset:K=!0,includePrefix:Q=!1,extendedZone:q=!1,format:X="extended"}={}){if(!this.isValid)return null;return(Q?"T":"")+N4(this,X==="extended",$,_,K,q)}toRFC2822(){return Y$(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Y$(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){if(!this.isValid)return null;return KK(this,!0)}toSQLTime({includeOffset:_=!0,includeZone:$=!1,includeOffsetSpace:K=!0}={}){let Q="HH:mm:ss.SSS";if($||_){if(K)Q+=" ";if($)Q+="z";else if(_)Q+="ZZ"}return Y$(this,Q,!0)}toSQL(_={}){if(!this.isValid)return null;return`${this.toSQLDate()} ${this.toSQLTime(_)}`}toString(){return this.isValid?this.toISO():e$}[Symbol.for("nodejs.util.inspect.custom")](){if(this.isValid)return`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`;else return`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1000:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1000):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(_={}){if(!this.isValid)return{};const $={...this.c};if(_.includeConfig)$.outputCalendar=this.outputCalendar,$.numberingSystem=this.loc.numberingSystem,$.locale=this.loc.locale;return $}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(_,$="milliseconds",K={}){if(!this.isValid||!_.isValid)return R.invalid("created by diffing an invalid DateTime");const Q={locale:this.locale,numberingSystem:this.numberingSystem,...K},q=gK($).map(R.normalizeUnit),X=_.valueOf()>this.valueOf(),B=X?this:_,G=X?_:this,J=r$(B,G,q,Q);return X?J.negate():J}diffNow(_="milliseconds",$={}){return this.diff(H.now(),_,$)}until(_){return this.isValid?F.fromDateTimes(this,_):this}hasSame(_,$,K){if(!this.isValid)return!1;const Q=_.valueOf(),q=this.setZone(_.zone,{keepLocalTime:!0});return q.startOf($,K)<=Q&&Q<=q.endOf($,K)}equals(_){return this.isValid&&_.isValid&&this.valueOf()===_.valueOf()&&this.zone.equals(_.zone)&&this.loc.equals(_.loc)}toRelative(_={}){if(!this.isValid)return null;const $=_.base||H.fromObject({},{zone:this.zone}),K=_.padding?this<$?-_.padding:_.padding:0;let Q=["years","months","days","hours","minutes","seconds"],q=_.unit;if(Array.isArray(_.unit))Q=_.unit,q=void 0;return W4($,this.plus(K),{..._,numeric:"always",units:Q,unit:q})}toRelativeCalendar(_={}){if(!this.isValid)return null;return W4(_.base||H.fromObject({},{zone:this.zone}),this,{..._,numeric:"auto",units:["years","months","days"],calendary:!0})}static min(..._){if(!_.every(H.isDateTime))throw new U("min requires all arguments be DateTimes");return p$(_,($)=>$.valueOf(),Math.min)}static max(..._){if(!_.every(H.isDateTime))throw new U("max requires all arguments be DateTimes");return p$(_,($)=>$.valueOf(),Math.max)}static fromFormatExplain(_,$,K={}){const{locale:Q=null,numberingSystem:q=null}=K,X=N.fromOpts({locale:Q,numberingSystem:q,defaultToEN:!0});return o$(X,_,$)}static fromStringExplain(_,$,K={}){return H.fromFormatExplain(_,$,K)}static buildFormatParser(_,$={}){const{locale:K=null,numberingSystem:Q=null}=$,q=N.fromOpts({locale:K,numberingSystem:Q,defaultToEN:!0});return new H$(q,_)}static fromFormatParser(_,$,K={}){if(Y(_)||Y($))throw new U("fromFormatParser requires an input string and a format parser");const{locale:Q=null,numberingSystem:q=null}=K,X=N.fromOpts({locale:Q,numberingSystem:q,defaultToEN:!0});if(!X.equals($.locale))throw new U(`fromFormatParser called with a locale of ${X}, but the format parser was created for ${$.locale}`);const{result:B,zone:G,specificOffset:J,invalidReason:V}=$.explainFromTokens(_);if(V)return H.invalid(V);else return C_(B,G,K,`format ${$.format}`,_,J)}static get DATE_SHORT(){return o}static get DATE_MED(){return b_}static get DATE_MED_WITH_WEEKDAY(){return HK}static get DATE_FULL(){return k_}static get DATE_HUGE(){return h_}static get TIME_SIMPLE(){return g_}static get TIME_WITH_SECONDS(){return f_}static get TIME_WITH_SHORT_OFFSET(){return p_}static get TIME_WITH_LONG_OFFSET(){return c_}static get TIME_24_SIMPLE(){return m_}static get TIME_24_WITH_SECONDS(){return u_}static get TIME_24_WITH_SHORT_OFFSET(){return l_}static get TIME_24_WITH_LONG_OFFSET(){return d_}static get DATETIME_SHORT(){return s_}static get DATETIME_SHORT_WITH_SECONDS(){return i_}static get DATETIME_MED(){return r_}static get DATETIME_MED_WITH_SECONDS(){return n_}static get DATETIME_MED_WITH_WEEKDAY(){return EK}static get DATETIME_FULL(){return a_}static get DATETIME_FULL_WITH_SECONDS(){return o_}static get DATETIME_HUGE(){return t_}static get DATETIME_HUGE_WITH_SECONDS(){return e_}}var QK=Object.freeze({second:[0,59],minute:[0,59],hour:[0,23],dayOfMonth:[1,31],month:[1,12],dayOfWeek:[0,7]}),qK=Object.freeze({1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}),L4=Object.freeze({second:"0",minute:"*",hour:"*",dayOfMonth:"*",month:"*",dayOfWeek:"*"}),XK=Object.freeze({jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12,sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}),BK=Object.freeze({SECOND:"second",MINUTE:"minute",HOUR:"hour",DAY_OF_MONTH:"dayOfMonth",MONTH:"month",DAY_OF_WEEK:"dayOfWeek"}),y_=Object.freeze(Object.values(BK)),A$=y_.length,GK=Object.freeze({"@yearly":"0 0 0 1 1 *","@monthly":"0 0 0 1 * *","@weekly":"0 0 0 * * 0","@daily":"0 0 0 * * *","@hourly":"0 0 * * * *","@minutely":"0 * * * * *","@secondly":"* * * * * *","@weekdays":"0 0 0 * * 1-5","@weekends":"0 0 0 * * 0,6"}),z4=/\*/g,x4=/^(\d+)(?:-(\d+))?(?:\/(\d+))?$/g;function JK(_){return Object.keys(_)}function w4(_,$){if(_!=null&&$!=null)throw new a("timeZone","utcOffset");if(_!=null)return{timeZone:_,utcOffset:null};if($!=null)return{timeZone:null,utcOffset:$};return{timeZone:null,utcOffset:null}}class n{source;timeZone;utcOffset;realDate=!1;second={};minute={};hour={};dayOfMonth={};month={};dayOfWeek={};constructor(_,$,K){if($!=null&&K!=null)throw new a("timeZone","utcOffset");if($){if(!H.fromObject({},{zone:$}).isValid)throw new z("Invalid timezone.");this.timeZone=$}if(K!=null)this.utcOffset=K;if(_ instanceof Date||_ instanceof H)this.source=_ instanceof Date?H.fromJSDate(_):_,this.realDate=!0;else this.source=_,this._parse(this.source),this._verifyParse()}_getWeekDay(_){return _.weekday===7?0:_.weekday}_verifyParse(){const _=JK(this.month),$=JK(this.dayOfMonth);let K=!1,Q=null;for(let q of _){const X=qK[q];for(let B of $)if(B<=X)K=!0;if(!K)Q=q,console.warn(`Month '${q}' is limited to '${X}' days.`)}if(!K&&Q!==null){const q=qK[Q];for(let X of $)if(X>q){delete this.dayOfMonth[X];const B=X%q;this.dayOfMonth[B]=!0}}}sendAt(_){let $=this.realDate&&this.source instanceof H?this.source:H.local();if(this.timeZone)$=$.setZone(this.timeZone);if(this.utcOffset!==void 0){const Q=this.utcOffset<0?"-":"+",q=Math.trunc(this.utcOffset/60),X=String(Math.abs(q)).padStart(2,"0"),B=Math.abs(this.utcOffset-q*60),G=String(B).padStart(2,"0"),J=`UTC${Q}${X}:${G}`;if($=$.setZone(J),!$.isValid)throw new z("ERROR: You specified an invalid UTC offset.")}if(this.realDate){if(H.local()>$)throw new z("WARNING: Date in past. Will never be fired.");return $}if(_===void 0||Number.isNaN(_)||_<0)return this.getNextDateFrom($);const K=[];for(;_>0;_--)$=this.getNextDateFrom($),K.push($);return K}getTimeout(){return Math.max(-1,this.sendAt().toMillis()-H.local().toMillis())}toString(){return this.toJSON().join(" ")}toJSON(){return y_.map((_)=>{return this._wcOrAll(_)})}getNextDateFrom(_,$){if(_ instanceof Date)_=H.fromJSDate(_);let K=_;const Q=_.toMillis();if($)K=K.setZone($);if(!this.realDate){if(K.millisecond>0)K=K.set({millisecond:0,second:K.second+1})}if(!K.isValid)throw new z("ERROR: You specified an invalid date.");const q=H.now().plus({years:8});while(!0){const X=K.toMillis()-_.toMillis();if(K>q)throw new z(`Something went wrong. No execution date was found in the next 8 years.
|
|
232
3
|
Please provide the following string if you would like to help debug:
|
|
233
|
-
Time Zone: ${
|
|
234
|
-
}
|
|
235
|
-
if (!(date.month in this.month) && Object.keys(this.month).length !== 12) {
|
|
236
|
-
date = date.plus({ months: 1 });
|
|
237
|
-
date = date.set({ day: 1, hour: 0, minute: 0, second: 0 });
|
|
238
|
-
if (this._forwardDSTJump(0, 0, date)) {
|
|
239
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
240
|
-
date = newDate;
|
|
241
|
-
if (isDone)
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (!(date.day in this.dayOfMonth) && Object.keys(this.dayOfMonth).length !== 31 && !((this._getWeekDay(date) in this.dayOfWeek) && Object.keys(this.dayOfWeek).length !== 7)) {
|
|
247
|
-
date = date.plus({ days: 1 });
|
|
248
|
-
date = date.set({ hour: 0, minute: 0, second: 0 });
|
|
249
|
-
if (this._forwardDSTJump(0, 0, date)) {
|
|
250
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
251
|
-
date = newDate;
|
|
252
|
-
if (isDone)
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
if (!(this._getWeekDay(date) in this.dayOfWeek) && Object.keys(this.dayOfWeek).length !== 7 && !((date.day in this.dayOfMonth) && Object.keys(this.dayOfMonth).length !== 31)) {
|
|
258
|
-
date = date.plus({ days: 1 });
|
|
259
|
-
date = date.set({ hour: 0, minute: 0, second: 0 });
|
|
260
|
-
if (this._forwardDSTJump(0, 0, date)) {
|
|
261
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
262
|
-
date = newDate;
|
|
263
|
-
if (isDone)
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
if (!(date.hour in this.hour) && Object.keys(this.hour).length !== 24) {
|
|
269
|
-
const expectedHour = date.hour === 23 && diff > 86400000 ? 0 : date.hour + 1;
|
|
270
|
-
const expectedMinute = date.minute;
|
|
271
|
-
date = date.set({ hour: expectedHour });
|
|
272
|
-
date = date.set({ minute: 0, second: 0 });
|
|
273
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
274
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
275
|
-
date = newDate;
|
|
276
|
-
if (isDone)
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (!(date.minute in this.minute) && Object.keys(this.minute).length !== 60) {
|
|
282
|
-
const expectedMinute = date.minute === 59 && diff > 3600000 ? 0 : date.minute + 1;
|
|
283
|
-
const expectedHour = date.hour + (expectedMinute === 60 ? 1 : 0);
|
|
284
|
-
date = date.set({ minute: expectedMinute });
|
|
285
|
-
date = date.set({ second: 0 });
|
|
286
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
287
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
288
|
-
date = newDate;
|
|
289
|
-
if (isDone)
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
if (!(date.second in this.second) && Object.keys(this.second).length !== 60) {
|
|
295
|
-
const expectedSecond = date.second === 59 && diff > 60000 ? 0 : date.second + 1;
|
|
296
|
-
const expectedMinute = date.minute + (expectedSecond === 60 ? 1 : 0);
|
|
297
|
-
const expectedHour = date.hour + (expectedMinute === 60 ? 1 : 0);
|
|
298
|
-
date = date.set({ second: expectedSecond });
|
|
299
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
300
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
301
|
-
date = newDate;
|
|
302
|
-
if (isDone)
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
if (date.toMillis() === firstDate) {
|
|
308
|
-
const expectedSecond = date.second + 1;
|
|
309
|
-
const expectedMinute = date.minute + (expectedSecond === 60 ? 1 : 0);
|
|
310
|
-
const expectedHour = date.hour + (expectedMinute === 60 ? 1 : 0);
|
|
311
|
-
date = date.set({ second: expectedSecond });
|
|
312
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
313
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
314
|
-
date = newDate;
|
|
315
|
-
if (isDone)
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
return date;
|
|
323
|
-
}
|
|
324
|
-
_findPreviousDSTJump(date) {
|
|
325
|
-
let expectedMinute;
|
|
326
|
-
let expectedHour;
|
|
327
|
-
let actualMinute;
|
|
328
|
-
let actualHour;
|
|
329
|
-
let maybeJumpingPoint = date;
|
|
330
|
-
const iterationLimit = 60 * 24;
|
|
331
|
-
let iteration = 0;
|
|
332
|
-
do {
|
|
333
|
-
if (++iteration > iterationLimit) {
|
|
334
|
-
throw new CronError(`ERROR: This DST checking related function assumes the input DateTime (${date.toISO() ?? date.toMillis()}) is within 24 hours of a DST jump.`);
|
|
335
|
-
}
|
|
336
|
-
expectedMinute = maybeJumpingPoint.minute - 1;
|
|
337
|
-
expectedHour = maybeJumpingPoint.hour;
|
|
338
|
-
if (expectedMinute < 0) {
|
|
339
|
-
expectedMinute += 60;
|
|
340
|
-
expectedHour = (expectedHour + 24 - 1) % 24;
|
|
341
|
-
}
|
|
342
|
-
maybeJumpingPoint = maybeJumpingPoint.minus({ minute: 1 });
|
|
343
|
-
actualMinute = maybeJumpingPoint.minute;
|
|
344
|
-
actualHour = maybeJumpingPoint.hour;
|
|
345
|
-
} while (expectedMinute === actualMinute && expectedHour === actualHour);
|
|
346
|
-
const afterJumpingPoint = maybeJumpingPoint.plus({ minute: 1 }).set({ second: 0, millisecond: 0 });
|
|
347
|
-
const beforeJumpingPoint = afterJumpingPoint.minus({ second: 1 });
|
|
348
|
-
if (date.month + 1 in this.month && date.day in this.dayOfMonth && this._getWeekDay(date) in this.dayOfWeek) {
|
|
349
|
-
return [this._checkTimeInSkippedRange(beforeJumpingPoint, afterJumpingPoint), afterJumpingPoint];
|
|
350
|
-
}
|
|
351
|
-
return [false, afterJumpingPoint];
|
|
352
|
-
}
|
|
353
|
-
_checkTimeInSkippedRange(beforeJumpingPoint, afterJumpingPoint) {
|
|
354
|
-
const startingMinute = (beforeJumpingPoint.minute + 1) % 60;
|
|
355
|
-
const startingHour = (beforeJumpingPoint.hour + (startingMinute === 0 ? 1 : 0)) % 24;
|
|
356
|
-
const hourRangeSize = afterJumpingPoint.hour - startingHour + 1;
|
|
357
|
-
const isHourJump = startingMinute === 0 && afterJumpingPoint.minute === 0;
|
|
358
|
-
if (hourRangeSize === 2 && isHourJump) {
|
|
359
|
-
return startingHour in this.hour;
|
|
360
|
-
}
|
|
361
|
-
if (hourRangeSize === 1) {
|
|
362
|
-
return startingHour in this.hour && this._checkTimeInSkippedRangeSingleHour(startingMinute, afterJumpingPoint.minute);
|
|
363
|
-
}
|
|
364
|
-
return this._checkTimeInSkippedRangeMultiHour(startingHour, startingMinute, afterJumpingPoint.hour, afterJumpingPoint.minute);
|
|
365
|
-
}
|
|
366
|
-
_checkTimeInSkippedRangeSingleHour(startMinute, endMinute) {
|
|
367
|
-
for (let minute = startMinute;minute < endMinute; ++minute) {
|
|
368
|
-
if (minute in this.minute)
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
return endMinute in this.minute && 0 in this.second;
|
|
372
|
-
}
|
|
373
|
-
_checkTimeInSkippedRangeMultiHour(startHour, startMinute, endHour, endMinute) {
|
|
374
|
-
if (startHour >= endHour) {
|
|
375
|
-
throw new CronError(`ERROR: This DST checking related function assumes the forward jump starting hour (${startHour}) is less than the end hour (${endHour})`);
|
|
376
|
-
}
|
|
377
|
-
const firstHourMinuteRange = Array.from({ length: 60 - startMinute }, (_, k) => startMinute + k);
|
|
378
|
-
const lastHourMinuteRange = Array.from({ length: endMinute }, (_, k) => k);
|
|
379
|
-
const middleHourMinuteRange = Array.from({ length: 60 }, (_, k) => k);
|
|
380
|
-
const selectRange = (forHour) => {
|
|
381
|
-
if (forHour === startHour)
|
|
382
|
-
return firstHourMinuteRange;
|
|
383
|
-
if (forHour === endHour)
|
|
384
|
-
return lastHourMinuteRange;
|
|
385
|
-
return middleHourMinuteRange;
|
|
386
|
-
};
|
|
387
|
-
for (let hour = startHour;hour <= endHour; ++hour) {
|
|
388
|
-
if (!(hour in this.hour))
|
|
389
|
-
continue;
|
|
390
|
-
const usingRange = selectRange(hour);
|
|
391
|
-
for (const minute of usingRange) {
|
|
392
|
-
if (minute in this.minute)
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return endHour in this.hour && endMinute in this.minute && 0 in this.second;
|
|
397
|
-
}
|
|
398
|
-
_forwardDSTJump(expectedHour, expectedMinute, actualDate) {
|
|
399
|
-
const actualHour = actualDate.hour;
|
|
400
|
-
const actualMinute = actualDate.minute;
|
|
401
|
-
const didHoursJumped = expectedHour % 24 < actualHour;
|
|
402
|
-
const didMinutesJumped = expectedMinute % 60 < actualMinute;
|
|
403
|
-
return didHoursJumped || didMinutesJumped;
|
|
404
|
-
}
|
|
405
|
-
_wcOrAll(unit) {
|
|
406
|
-
if (this._hasAll(unit))
|
|
407
|
-
return "*";
|
|
408
|
-
const all = [];
|
|
409
|
-
for (const time in this[unit])
|
|
410
|
-
all.push(time);
|
|
411
|
-
return all.join(",");
|
|
412
|
-
}
|
|
413
|
-
_hasAll(unit) {
|
|
414
|
-
const constraints = CONSTRAINTS[unit];
|
|
415
|
-
const low = constraints[0];
|
|
416
|
-
const high = unit === TIME_UNITS_MAP.DAY_OF_WEEK ? constraints[1] - 1 : constraints[1];
|
|
417
|
-
for (let i = low, n = high;i < n; i++) {
|
|
418
|
-
if (!(i in this[unit]))
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
return true;
|
|
422
|
-
}
|
|
423
|
-
_parse(source) {
|
|
424
|
-
source = source.toLowerCase();
|
|
425
|
-
if (Object.keys(PRESETS).includes(source))
|
|
426
|
-
source = PRESETS[source];
|
|
427
|
-
source = source.replace(/[a-z]{1,3}/gi, (alias) => {
|
|
428
|
-
if (Object.keys(ALIASES).includes(alias))
|
|
429
|
-
return ALIASES[alias].toString();
|
|
430
|
-
throw new CronError(`Unknown alias: ${alias}`);
|
|
431
|
-
});
|
|
432
|
-
const units = source.trim().split(/\s+/);
|
|
433
|
-
if (units.length < TIME_UNITS_LEN - 1)
|
|
434
|
-
throw new CronError("Too few fields");
|
|
435
|
-
if (units.length > TIME_UNITS_LEN)
|
|
436
|
-
throw new CronError("Too many fields");
|
|
437
|
-
const unitsLen = units.length;
|
|
438
|
-
for (const unit of TIME_UNITS) {
|
|
439
|
-
const i = TIME_UNITS.indexOf(unit);
|
|
440
|
-
const cur = units[i - (TIME_UNITS_LEN - unitsLen)] ?? PARSE_DEFAULTS[unit];
|
|
441
|
-
this._parseField(cur, unit);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
_parseField(value, unit) {
|
|
445
|
-
const typeObj = this[unit];
|
|
446
|
-
let pointer;
|
|
447
|
-
const constraints = CONSTRAINTS[unit];
|
|
448
|
-
const low = constraints[0];
|
|
449
|
-
const high = constraints[1];
|
|
450
|
-
const fields = value.split(",");
|
|
451
|
-
fields.forEach((field) => {
|
|
452
|
-
const wildcardIndex = field.indexOf("*");
|
|
453
|
-
if (wildcardIndex !== -1 && wildcardIndex !== 0) {
|
|
454
|
-
throw new CronError(`Field (${field}) has an invalid wildcard expression`);
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
value = value.replace(RE_WILDCARDS, `${low}-${high}`);
|
|
458
|
-
const allRanges = value.split(",");
|
|
459
|
-
for (const range of allRanges) {
|
|
460
|
-
const match = [...range.matchAll(RE_RANGE)][0];
|
|
461
|
-
if (match?.[1] !== undefined) {
|
|
462
|
-
const [, mLower, mUpper, mStep] = match;
|
|
463
|
-
let lower = Number.parseInt(mLower, 10);
|
|
464
|
-
let upper = mUpper !== undefined ? Number.parseInt(mUpper, 10) : undefined;
|
|
465
|
-
const wasStepDefined = mStep !== undefined;
|
|
466
|
-
const step = Number.parseInt(mStep ?? "1", 10);
|
|
467
|
-
if (step === 0)
|
|
468
|
-
throw new CronError(`Field (${unit}) has a step of zero`);
|
|
469
|
-
if (upper !== undefined && lower > upper)
|
|
470
|
-
throw new CronError(`Field (${unit}) has an invalid range`);
|
|
471
|
-
const isOutOfRange = lower < low || upper !== undefined && upper > high || upper === undefined && lower > high;
|
|
472
|
-
if (isOutOfRange)
|
|
473
|
-
throw new CronError(`Field value (${value}) is out of range`);
|
|
474
|
-
lower = Math.min(Math.max(low, ~~Math.abs(lower)), high);
|
|
475
|
-
if (upper !== undefined) {
|
|
476
|
-
upper = Math.min(high, ~~Math.abs(upper));
|
|
477
|
-
} else {
|
|
478
|
-
upper = wasStepDefined ? high : lower;
|
|
479
|
-
}
|
|
480
|
-
pointer = lower;
|
|
481
|
-
do {
|
|
482
|
-
typeObj[pointer] = true;
|
|
483
|
-
pointer += step;
|
|
484
|
-
} while (pointer <= upper);
|
|
485
|
-
if (unit === "dayOfWeek") {
|
|
486
|
-
if (!typeObj[0] && !!typeObj[7])
|
|
487
|
-
typeObj[0] = typeObj[7];
|
|
488
|
-
typeObj[7] = undefined;
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
throw new CronError(`Field (${unit}) cannot be parsed`);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// src/job.ts
|
|
498
|
-
class CronJob {
|
|
499
|
-
cronTime;
|
|
500
|
-
running = false;
|
|
501
|
-
unrefTimeout = false;
|
|
502
|
-
lastExecution = null;
|
|
503
|
-
runOnce = false;
|
|
504
|
-
context;
|
|
505
|
-
onComplete;
|
|
506
|
-
_timeout;
|
|
507
|
-
_callbacks = [];
|
|
508
|
-
_errorHandler;
|
|
509
|
-
constructor(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, unrefTimeout, errorHandler) {
|
|
510
|
-
this._errorHandler = errorHandler;
|
|
511
|
-
this.context = context ?? this;
|
|
512
|
-
const { timeZone: tz, utcOffset: uo } = getTimeZoneAndOffset(timeZone, utcOffset);
|
|
513
|
-
this.cronTime = new CronTime(cronTime, tz, uo);
|
|
514
|
-
if (unrefTimeout != null)
|
|
515
|
-
this.unrefTimeout = unrefTimeout;
|
|
516
|
-
if (onComplete != null) {
|
|
517
|
-
this.onComplete = this._fnWrap(onComplete);
|
|
518
|
-
}
|
|
519
|
-
if (this.cronTime.realDate)
|
|
520
|
-
this.runOnce = true;
|
|
521
|
-
this.addCallback(this._fnWrap(onTick));
|
|
522
|
-
if (runOnInit) {
|
|
523
|
-
this.lastExecution = new Date;
|
|
524
|
-
this.fireOnTick();
|
|
525
|
-
}
|
|
526
|
-
if (start)
|
|
527
|
-
this.start();
|
|
528
|
-
}
|
|
529
|
-
static from(params) {
|
|
530
|
-
if (params.timeZone != null && params.utcOffset != null)
|
|
531
|
-
throw new ExclusiveParametersError("timeZone", "utcOffset");
|
|
532
|
-
if (params.timeZone != null) {
|
|
533
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout);
|
|
534
|
-
}
|
|
535
|
-
if (params.utcOffset != null) {
|
|
536
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, null, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout);
|
|
537
|
-
}
|
|
538
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout);
|
|
539
|
-
}
|
|
540
|
-
_fnWrap(cmd) {
|
|
541
|
-
switch (typeof cmd) {
|
|
542
|
-
case "function": {
|
|
543
|
-
return cmd;
|
|
544
|
-
}
|
|
545
|
-
case "string": {
|
|
546
|
-
const [command, ...args] = cmd.split(" ");
|
|
547
|
-
return spawn.bind(undefined, command ?? cmd, args, {});
|
|
548
|
-
}
|
|
549
|
-
case "object": {
|
|
550
|
-
return spawn.bind(undefined, cmd.command, cmd.args ?? [], cmd.options ?? {});
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
addCallback(callback) {
|
|
555
|
-
if (typeof callback === "function")
|
|
556
|
-
this._callbacks.push(callback);
|
|
557
|
-
}
|
|
558
|
-
setTime(time2) {
|
|
559
|
-
if (!(time2 instanceof CronTime))
|
|
560
|
-
throw new CronError("time must be an instance of CronTime.");
|
|
561
|
-
const wasRunning = this.running;
|
|
562
|
-
this.stop();
|
|
563
|
-
this.cronTime = time2;
|
|
564
|
-
if (time2.realDate)
|
|
565
|
-
this.runOnce = true;
|
|
566
|
-
if (wasRunning)
|
|
567
|
-
this.start();
|
|
568
|
-
}
|
|
569
|
-
nextDate() {
|
|
570
|
-
return this.cronTime.sendAt();
|
|
571
|
-
}
|
|
572
|
-
fireOnTick() {
|
|
573
|
-
try {
|
|
574
|
-
for (const callback of this._callbacks) {
|
|
575
|
-
callback.call(this.context, this.onComplete);
|
|
576
|
-
}
|
|
577
|
-
} catch (error) {
|
|
578
|
-
if (this._errorHandler && error instanceof Error) {
|
|
579
|
-
this._errorHandler(error);
|
|
580
|
-
} else {
|
|
581
|
-
console.error("An error occurred in the cron job callback:", error);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
nextDates(i) {
|
|
586
|
-
return this.cronTime.sendAt(i ?? 0);
|
|
587
|
-
}
|
|
588
|
-
start() {
|
|
589
|
-
if (this.running)
|
|
590
|
-
return;
|
|
591
|
-
const MAXDELAY = 2147483647;
|
|
592
|
-
let timeout = this.cronTime.getTimeout();
|
|
593
|
-
let remaining = 0;
|
|
594
|
-
let startTime;
|
|
595
|
-
const setCronTimeout = (t) => {
|
|
596
|
-
this._timeout = setTimeout(callbackWrapper, t);
|
|
597
|
-
if (this.unrefTimeout && typeof this._timeout.unref === "function")
|
|
598
|
-
this._timeout.unref();
|
|
599
|
-
};
|
|
600
|
-
const callbackWrapper = () => {
|
|
601
|
-
const diff = startTime + timeout - Date.now();
|
|
602
|
-
if (diff > 0) {
|
|
603
|
-
let newTimeout = this.cronTime.getTimeout();
|
|
604
|
-
if (newTimeout > diff)
|
|
605
|
-
newTimeout = diff;
|
|
606
|
-
remaining += newTimeout;
|
|
607
|
-
}
|
|
608
|
-
if (remaining) {
|
|
609
|
-
if (remaining > MAXDELAY) {
|
|
610
|
-
remaining -= MAXDELAY;
|
|
611
|
-
timeout = MAXDELAY;
|
|
612
|
-
} else {
|
|
613
|
-
timeout = remaining;
|
|
614
|
-
remaining = 0;
|
|
615
|
-
}
|
|
616
|
-
setCronTimeout(timeout);
|
|
617
|
-
} else {
|
|
618
|
-
this.lastExecution = new Date;
|
|
619
|
-
this.running = false;
|
|
620
|
-
if (!this.runOnce)
|
|
621
|
-
this.start();
|
|
622
|
-
this.fireOnTick();
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
if (timeout >= 0) {
|
|
626
|
-
this.running = true;
|
|
627
|
-
if (timeout > MAXDELAY) {
|
|
628
|
-
remaining = timeout - MAXDELAY;
|
|
629
|
-
timeout = MAXDELAY;
|
|
630
|
-
}
|
|
631
|
-
setCronTimeout(timeout);
|
|
632
|
-
} else {
|
|
633
|
-
this.stop();
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
lastDate() {
|
|
637
|
-
return this.lastExecution;
|
|
638
|
-
}
|
|
639
|
-
stop() {
|
|
640
|
-
if (this._timeout)
|
|
641
|
-
clearTimeout(this._timeout);
|
|
642
|
-
this.running = false;
|
|
643
|
-
if (typeof this.onComplete === "function")
|
|
644
|
-
this.onComplete.call(this.context);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// src/schedule.ts
|
|
649
|
-
function sendAt(cronTime) {
|
|
650
|
-
return new CronTime(cronTime).sendAt();
|
|
651
|
-
}
|
|
652
|
-
function timeout(cronTime) {
|
|
653
|
-
return new CronTime(cronTime).getTimeout();
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
class Schedule {
|
|
657
|
-
cronPattern = "";
|
|
658
|
-
timezone = "America/Los_Angeles";
|
|
659
|
-
task;
|
|
660
|
-
constructor(task) {
|
|
661
|
-
this.task = task;
|
|
662
|
-
}
|
|
663
|
-
everySecond() {
|
|
664
|
-
this.cronPattern = "* * * * * *";
|
|
665
|
-
return this;
|
|
666
|
-
}
|
|
667
|
-
everyMinute() {
|
|
668
|
-
this.cronPattern = "0 * * * * *";
|
|
669
|
-
return this;
|
|
670
|
-
}
|
|
671
|
-
everyTwoMinutes() {
|
|
672
|
-
this.cronPattern = "*/2 * * * * *";
|
|
673
|
-
return this;
|
|
674
|
-
}
|
|
675
|
-
everyFiveMinutes() {
|
|
676
|
-
this.cronPattern = "*/5 * * * *";
|
|
677
|
-
return this;
|
|
678
|
-
}
|
|
679
|
-
everyTenMinutes() {
|
|
680
|
-
this.cronPattern = "*/10 * * * *";
|
|
681
|
-
return this;
|
|
682
|
-
}
|
|
683
|
-
everyThirtyMinutes() {
|
|
684
|
-
this.cronPattern = "*/30 * * * *";
|
|
685
|
-
return this;
|
|
686
|
-
}
|
|
687
|
-
hourly() {
|
|
688
|
-
this.cronPattern = "0 0 * * * *";
|
|
689
|
-
return this;
|
|
690
|
-
}
|
|
691
|
-
daily() {
|
|
692
|
-
this.cronPattern = "0 0 0 * * *";
|
|
693
|
-
return this;
|
|
694
|
-
}
|
|
695
|
-
weekly() {
|
|
696
|
-
this.cronPattern = "0 0 0 * * 0";
|
|
697
|
-
return this;
|
|
698
|
-
}
|
|
699
|
-
monthly() {
|
|
700
|
-
this.cronPattern = "0 0 0 1 * *";
|
|
701
|
-
return this;
|
|
702
|
-
}
|
|
703
|
-
yearly() {
|
|
704
|
-
this.cronPattern = "0 0 0 1 1 *";
|
|
705
|
-
return this;
|
|
706
|
-
}
|
|
707
|
-
onDays(days) {
|
|
708
|
-
const dayPattern = days.join(",");
|
|
709
|
-
this.cronPattern = `0 0 0 * * ${dayPattern}`;
|
|
710
|
-
return this;
|
|
711
|
-
}
|
|
712
|
-
at(time3) {
|
|
713
|
-
const [hour, minute] = time3.split(":").map(Number);
|
|
714
|
-
this.cronPattern = `${minute} ${hour} * * *`;
|
|
715
|
-
return this;
|
|
716
|
-
}
|
|
717
|
-
setTimeZone(timezone) {
|
|
718
|
-
this.timezone = timezone;
|
|
719
|
-
return this;
|
|
720
|
-
}
|
|
721
|
-
start() {
|
|
722
|
-
new CronJob(this.cronPattern, this.task, null, true, this.timezone);
|
|
723
|
-
log.info(`Scheduled task with pattern: ${this.cronPattern} in timezone: ${this.timezone}`);
|
|
724
|
-
}
|
|
725
|
-
job(path) {
|
|
726
|
-
log.info(`Scheduling job: ${path}`);
|
|
727
|
-
return this;
|
|
728
|
-
}
|
|
729
|
-
action(path) {
|
|
730
|
-
log.info(`Scheduling action: ${path}`);
|
|
731
|
-
return this;
|
|
732
|
-
}
|
|
733
|
-
static command(cmd) {
|
|
734
|
-
log.info(`Executing command: ${cmd}`);
|
|
735
|
-
return this;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
4
|
+
Time Zone: ${$?.toString()??'""'} - Cron String: ${this.source.toString()} - UTC offset: ${K.offset} - current Date: ${H.local().toString()}`);if(!(K.month in this.month)&&Object.keys(this.month).length!==12){if(K=K.plus({months:1}),K=K.set({day:1,hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,K)){const[B,G]=this._findPreviousDSTJump(K);if(K=G,B)break}continue}if(!(K.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31&&!((this._getWeekDay(K)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7)){if(K=K.plus({days:1}),K=K.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,K)){const[B,G]=this._findPreviousDSTJump(K);if(K=G,B)break}continue}if(!(this._getWeekDay(K)in this.dayOfWeek)&&Object.keys(this.dayOfWeek).length!==7&&!((K.day in this.dayOfMonth)&&Object.keys(this.dayOfMonth).length!==31)){if(K=K.plus({days:1}),K=K.set({hour:0,minute:0,second:0}),this._forwardDSTJump(0,0,K)){const[B,G]=this._findPreviousDSTJump(K);if(K=G,B)break}continue}if(!(K.hour in this.hour)&&Object.keys(this.hour).length!==24){const B=K.hour===23&&X>86400000?0:K.hour+1,G=K.minute;if(K=K.set({hour:B}),K=K.set({minute:0,second:0}),this._forwardDSTJump(B,G,K)){const[J,V]=this._findPreviousDSTJump(K);if(K=V,J)break}continue}if(!(K.minute in this.minute)&&Object.keys(this.minute).length!==60){const B=K.minute===59&&X>3600000?0:K.minute+1,G=K.hour+(B===60?1:0);if(K=K.set({minute:B}),K=K.set({second:0}),this._forwardDSTJump(G,B,K)){const[J,V]=this._findPreviousDSTJump(K);if(K=V,J)break}continue}if(!(K.second in this.second)&&Object.keys(this.second).length!==60){const B=K.second===59&&X>60000?0:K.second+1,G=K.minute+(B===60?1:0),J=K.hour+(G===60?1:0);if(K=K.set({second:B}),this._forwardDSTJump(J,G,K)){const[V,E]=this._findPreviousDSTJump(K);if(K=E,V)break}continue}if(K.toMillis()===Q){const B=K.second+1,G=K.minute+(B===60?1:0),J=K.hour+(G===60?1:0);if(K=K.set({second:B}),this._forwardDSTJump(J,G,K)){const[V,E]=this._findPreviousDSTJump(K);if(K=E,V)break}continue}break}return K}_findPreviousDSTJump(_){let $,K,Q,q,X=_;const B=1440;let G=0;do{if(++G>B)throw new z(`ERROR: This DST checking related function assumes the input DateTime (${_.toISO()??_.toMillis()}) is within 24 hours of a DST jump.`);if($=X.minute-1,K=X.hour,$<0)$+=60,K=(K+24-1)%24;X=X.minus({minute:1}),Q=X.minute,q=X.hour}while($===Q&&K===q);const J=X.plus({minute:1}).set({second:0,millisecond:0}),V=J.minus({second:1});if(_.month+1 in this.month&&_.day in this.dayOfMonth&&this._getWeekDay(_)in this.dayOfWeek)return[this._checkTimeInSkippedRange(V,J),J];return[!1,J]}_checkTimeInSkippedRange(_,$){const K=(_.minute+1)%60,Q=(_.hour+(K===0?1:0))%24,q=$.hour-Q+1,X=K===0&&$.minute===0;if(q===2&&X)return Q in this.hour;if(q===1)return Q in this.hour&&this._checkTimeInSkippedRangeSingleHour(K,$.minute);return this._checkTimeInSkippedRangeMultiHour(Q,K,$.hour,$.minute)}_checkTimeInSkippedRangeSingleHour(_,$){for(let K=_;K<$;++K)if(K in this.minute)return!0;return $ in this.minute&&0 in this.second}_checkTimeInSkippedRangeMultiHour(_,$,K,Q){if(_>=K)throw new z(`ERROR: This DST checking related function assumes the forward jump starting hour (${_}) is less than the end hour (${K})`);const q=Array.from({length:60-$},(J,V)=>$+V),X=Array.from({length:Q},(J,V)=>V),B=Array.from({length:60},(J,V)=>V),G=(J)=>{if(J===_)return q;if(J===K)return X;return B};for(let J=_;J<=K;++J){if(!(J in this.hour))continue;const V=G(J);for(let E of V)if(E in this.minute)return!0}return K in this.hour&&Q in this.minute&&0 in this.second}_forwardDSTJump(_,$,K){const{hour:Q,minute:q}=K,X=_%24<Q,B=$%60<q;return X||B}_wcOrAll(_){if(this._hasAll(_))return"*";const $=[];for(let K in this[_])$.push(K);return $.join(",")}_hasAll(_){const $=QK[_],K=$[0],Q=_===BK.DAY_OF_WEEK?$[1]-1:$[1];for(let q=K,X=Q;q<X;q++)if(!(q in this[_]))return!1;return!0}_parse(_){if(_=_.toLowerCase(),Object.keys(GK).includes(_))_=GK[_];_=_.replace(/[a-z]{1,3}/gi,(Q)=>{if(Object.keys(XK).includes(Q))return XK[Q].toString();throw new z(`Unknown alias: ${Q}`)});const $=_.trim().split(/\s+/);if($.length<A$-1)throw new z("Too few fields");if($.length>A$)throw new z("Too many fields");const K=$.length;for(let Q of y_){const q=y_.indexOf(Q),X=$[q-(A$-K)]??L4[Q];this._parseField(X,Q)}}_parseField(_,$){const K=this[$];let Q;const q=QK[$],X=q[0],B=q[1];_.split(",").forEach((V)=>{const E=V.indexOf("*");if(E!==-1&&E!==0)throw new z(`Field (${V}) has an invalid wildcard expression`)}),_=_.replace(z4,`${X}-${B}`);const J=_.split(",");for(let V of J){const E=[...V.matchAll(x4)][0];if(E?.[1]!==void 0){const[,C,P,A]=E;let j=Number.parseInt(C,10),w=P!==void 0?Number.parseInt(P,10):void 0;const v=A!==void 0,f=Number.parseInt(A??"1",10);if(f===0)throw new z(`Field (${$}) has a step of zero`);if(w!==void 0&&j>w)throw new z(`Field (${$}) has an invalid range`);if(j<X||w!==void 0&&w>B||w===void 0&&j>B)throw new z(`Field value (${_}) is out of range`);if(j=Math.min(Math.max(X,~~Math.abs(j)),B),w!==void 0)w=Math.min(B,~~Math.abs(w));else w=v?B:j;Q=j;do K[Q]=!0,Q+=f;while(Q<=w);if($==="dayOfWeek"){if(!K[0]&&!!K[7])K[0]=K[7];K[7]=void 0}}else throw new z(`Field (${$}) cannot be parsed`)}}}class X_{cronTime;running=!1;unrefTimeout=!1;lastExecution=null;runOnce=!1;context;onComplete;_timeout;_callbacks=[];_errorHandler;constructor(_,$,K,Q,q,X,B,G,J,V){this._errorHandler=V,this.context=X??this;const{timeZone:E,utcOffset:C}=w4(q,G);if(this.cronTime=new n(_,E,C),J!=null)this.unrefTimeout=J;if(K!=null)this.onComplete=this._fnWrap(K);if(this.cronTime.realDate)this.runOnce=!0;if(this.addCallback(this._fnWrap($)),B)this.lastExecution=new Date,this.fireOnTick();if(Q)this.start()}static from(_){if(_.timeZone!=null&&_.utcOffset!=null)throw new a("timeZone","utcOffset");if(_.timeZone!=null)return new X_(_.cronTime,_.onTick,_.onComplete,_.start,_.timeZone,_.context,_.runOnInit,_.utcOffset,_.unrefTimeout);if(_.utcOffset!=null)return new X_(_.cronTime,_.onTick,_.onComplete,_.start,null,_.context,_.runOnInit,_.utcOffset,_.unrefTimeout);return new X_(_.cronTime,_.onTick,_.onComplete,_.start,_.timeZone,_.context,_.runOnInit,_.utcOffset,_.unrefTimeout)}_fnWrap(_){switch(typeof _){case"function":return _;case"string":{const[$,...K]=_.split(" ");return I4.bind(void 0,$??_,K,{})}case"object":return I4.bind(void 0,_.command,_.args??[],_.options??{})}}addCallback(_){if(typeof _==="function")this._callbacks.push(_)}setTime(_){if(!(_ instanceof n))throw new z("time must be an instance of CronTime.");const $=this.running;if(this.stop(),this.cronTime=_,_.realDate)this.runOnce=!0;if($)this.start()}nextDate(){return this.cronTime.sendAt()}fireOnTick(){try{for(let _ of this._callbacks)_.call(this.context,this.onComplete)}catch(_){if(this._errorHandler&&_ instanceof Error)this._errorHandler(_);else console.error("An error occurred in the cron job callback:",_)}}nextDates(_){return this.cronTime.sendAt(_??0)}start(){if(this.running)return;const _=2147483647;let $=this.cronTime.getTimeout(),K=0,Q;const q=(B)=>{if(this._timeout=setTimeout(X,B),this.unrefTimeout&&typeof this._timeout.unref==="function")this._timeout.unref()},X=()=>{const B=Q+$-Date.now();if(B>0){let G=this.cronTime.getTimeout();if(G>B)G=B;K+=G}if(K){if(K>_)K-=_,$=_;else $=K,K=0;q($)}else{if(this.lastExecution=new Date,this.running=!1,!this.runOnce)this.start();this.fireOnTick()}};if($>=0){if(this.running=!0,$>_)K=$-_,$=_;q($)}else this.stop()}lastDate(){return this.lastExecution}stop(){if(this._timeout)clearTimeout(this._timeout);if(this.running=!1,typeof this.onComplete==="function")this.onComplete.call(this.context)}}function A8(_){return new n(_).sendAt()}function M8(_){return new n(_).getTimeout()}class D4{cronPattern="";timezone="America/Los_Angeles";task;constructor(_){this.task=_}everySecond(){return this.cronPattern="* * * * * *",this}everyMinute(){return this.cronPattern="0 * * * * *",this}everyTwoMinutes(){return this.cronPattern="*/2 * * * * *",this}everyFiveMinutes(){return this.cronPattern="*/5 * * * *",this}everyTenMinutes(){return this.cronPattern="*/10 * * * *",this}everyThirtyMinutes(){return this.cronPattern="*/30 * * * *",this}hourly(){return this.cronPattern="0 0 * * * *",this}daily(){return this.cronPattern="0 0 0 * * *",this}weekly(){return this.cronPattern="0 0 0 * * 0",this}monthly(){return this.cronPattern="0 0 0 1 * *",this}yearly(){return this.cronPattern="0 0 0 1 1 *",this}onDays(_){const $=_.join(",");return this.cronPattern=`0 0 0 * * ${$}`,this}at(_){const[$,K]=_.split(":").map(Number);return this.cronPattern=`${K} ${$} * * *`,this}setTimeZone(_){return this.timezone=_,this}start(){new X_(this.cronPattern,this.task,null,!0,this.timezone),M$.info(`Scheduled task with pattern: ${this.cronPattern} in timezone: ${this.timezone}`)}job(_){return M$.info(`Scheduling job: ${_}`),this}action(_){return M$.info(`Scheduling action: ${_}`),this}static command(_){return M$.info(`Executing command: ${_}`),this}}export{M8 as timeout,A8 as sendAt,D4 as Schedule,n as CronTime,X_ as BunCronJob};
|
|
738
5
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
export {
|
|
742
|
-
timeout,
|
|
743
|
-
sendAt,
|
|
744
|
-
src_default as default,
|
|
745
|
-
Schedule,
|
|
746
|
-
CronTime,
|
|
747
|
-
CronJob as BunCronJob
|
|
748
|
-
};
|
|
6
|
+
//# debugId=82B6CFE506E0EA7C64756E2164756E21
|
|
7
|
+
//# sourceMappingURL=index.js.map
|