croner 10.0.0-dev.1 → 10.0.0-dev.2

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/README.md CHANGED
@@ -149,7 +149,8 @@ job.name // Optional job name, populated if a name were passed to options
149
149
  | interval | 0 | Number | Minimum number of seconds between triggers. |
150
150
  | paused | false | Boolean | If the job should be paused from start. |
151
151
  | context | undefined | Any | Passed as the second parameter to triggered function |
152
- | legacyMode | true | boolean | Combine day-of-month and day-of-week using true = OR, false = AND |
152
+ | domAndDow | false | boolean | Combine day-of-month and day-of-week using true = AND, false = OR (default) |
153
+ | legacyMode | (deprecated) | boolean | **Deprecated:** Use `domAndDow` instead. Inverse of `domAndDow` (legacyMode: true = domAndDow: false). |
153
154
  | unref | false | boolean | Setting this to true unrefs the internal timer, which allows the process to exit even if a cron job is running. |
154
155
  | utcOffset | undefined | number | Schedule using a specific utc offset in minutes. This does not take care of daylight savings time, you probably want to use option `timezone` instead. |
155
156
  | protect | undefined | boolean\|Function | Enabled over-run protection. Will block new triggers as long as an old trigger is in progress. Pass either `true` or a callback function to enable |
@@ -191,7 +192,7 @@ Croner is fully compliant with the [Open Cron Pattern Specification (OCPS)](http
191
192
 
192
193
  * Croner allows you to pass a JavaScript Date object or an ISO 8601 formatted string as a pattern. The scheduled function will trigger at the specified date/time and only once. If you use a timezone different from the local timezone, you should pass the ISO 8601 local time in the target location and specify the timezone using the options (2nd parameter).
193
194
 
194
- * By default, Croner uses OR logic for day-of-month and day-of-week (OCPS 1.0 compliant). Example: `0 20 1 * MON` triggers on the 1st of the month OR on Mondays. Use the `+` modifier (`0 20 1 * +MON`) or `{ legacyMode: false }` option for AND logic. For more information, see issue [#53](https://github.com/Hexagon/croner/issues/53).
195
+ * By default, Croner uses OR logic for day-of-month and day-of-week (OCPS 1.0 compliant). Example: `0 20 1 * MON` triggers on the 1st of the month OR on Mondays. Use the `+` modifier (`0 20 1 * +MON`) or `{ domAndDow: true }` for AND logic (OCPS 1.4 compliant). For more information, see issue [#53](https://github.com/Hexagon/croner/issues/53).
195
196
 
196
197
  | Field | Required | Allowed values | Allowed special characters | Remarks |
197
198
  |--------------|----------|----------------|----------------------------|---------------------------------------|
package/dist/croner.cjs CHANGED
@@ -1 +1 @@
1
- var D=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!I.call(n,i)&&i!==t&&D(n,i,{get:()=>e[i],enumerable:!(r=S(e,i))||r.enumerable});return n};var F=n=>z(D({},"__esModule",{value:!0}),n);var j={};W(j,{Cron:()=>P,CronDate:()=>f,CronPattern:()=>g,scheduledJobs:()=>T});module.exports=F(j);function C(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function v(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function L(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?b(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):b(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function k(n,e,t){return O(L(n,e),t)}function O(n,e){let t=new Date(C(n)),r=p(t,n.tz),i=C(n),s=C(r),a=i-s,h=new Date(t.getTime()+a),o=p(h,n.tz);if(v(o,n)){let m=new Date(h.getTime()-36e5),d=p(m,n.tz);return v(d,n)?m:h}let l=new Date(h.getTime()+C(n)-C(o)),u=p(l,n.tz);if(v(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function p(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(s){let a=s instanceof Error?s.message:String(s);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let s of r)(s.type==="year"||s.type==="month"||s.type==="day"||s.type==="hour"||s.type==="minute"||s.type==="second")&&(i[s.type]=parseInt(s.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function b(n,e,t,r,i,s,a){return{y:n,m:e,d:t,h:r,i,s,tz:a}}var N=[1,2,4,8,16],g=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let s=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${s} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,i){let s=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return s.fill(i);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,i);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,i):t.indexOf("-")!==-1?this.handleRange(t,e,r,i):t.indexOf("/")!==-1?this.handleStepping(t,e,r,i):t!==""&&this.handleNumber(t,e,r,i)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,i){let s=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(s[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,s[1]||i)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(e,t),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let w=u;w<=m;w+=d)this.setPart(t,w,s[1]||i)}extractNth(e,t){let r=e,i;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(e,t),a=s[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,s[1]||i)}handleStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(e,t),a=s[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,s[1]||i)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|N[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}};var R=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let s=new Date(Date.UTC(e,t,r)).getUTCDay();if(s===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return s===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,i){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(i&63&&N[h-1]&i)return!0;if(i&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=p(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>R[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=k(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(k(e,this.tz))}findNext(e,t,r,i){let s=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=R[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+i;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-i)===o-i){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-i==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-i-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-i,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:e.legacyMode&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-i,s!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let s=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){s=a;break}if(s===-1)return null;this.year=s,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(t,c[r][0],e,c[r][2]);if(i>1){let s=r+1;for(;s<c.length;)this[c[s][0]]=-c[s][2],s++;if(i===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):O(b(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function _(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode=n.legacyMode===void 0?!0:n.legacyMode,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");return n}function y(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function x(n){return y(n)}function U(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var M=30*1e3,T=[],P=class{name;options;_states;fn;constructor(e,t,r){let i,s;if(y(t))s=t;else if(typeof t=="object")i=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if(typeof r=="object")i=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=_(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:i?i.paused:!1,pattern:new g("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new g(e,this.options.timezone,{mode:this.options.mode}),this.name){if(T.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");T.push(this)}return s!==void 0&&x(s)&&(this.fn=s,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],i=t||this._states.currentRun||void 0;for(;e--&&(i=this.nextRun(i));)r.push(i);return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,i=!this._states.kill;return t&&r&&i&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=T.indexOf(this);e>=0&&T.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>M&&(t=M),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&U(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){y(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let i=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&i!==this._states.once&&(i=i.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||i===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),i=e;if(this.options.startAt.getTime()<=r.getTime()){i=this.options.startAt;let s=i.getTime()+this.options.interval*1e3;for(;s<=r.getTime();)i=new f(i,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),s=i.getTime()+this.options.interval*1e3;t=!0}return i===null&&(i=void 0),[i,t]}};0&&(module.exports={Cron,CronDate,CronPattern,scheduledJobs});
1
+ var D=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var W=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!I.call(n,s)&&s!==t&&D(n,s,{get:()=>e[s],enumerable:!(r=M(e,s))||r.enumerable});return n};var F=n=>z(D({},"__esModule",{value:!0}),n);var j={};W(j,{Cron:()=>P,CronDate:()=>f,CronPattern:()=>g,scheduledJobs:()=>T});module.exports=F(j);function C(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function v(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function L(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?b(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):b(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function O(n,e,t){return k(L(n,e),t)}function k(n,e){let t=new Date(C(n)),r=p(t,n.tz),s=C(n),i=C(r),a=s-i,h=new Date(t.getTime()+a),o=p(h,n.tz);if(v(o,n)){let m=new Date(h.getTime()-36e5),d=p(m,n.tz);return v(d,n)?m:h}let l=new Date(h.getTime()+C(n)-C(o)),u=p(l,n.tz);if(v(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function p(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let s={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let i of r)(i.type==="year"||i.type==="month"||i.type==="day"||i.type==="hour"||i.type==="minute"||i.type==="second")&&(s[i.type]=parseInt(i.value,10));if(isNaN(s.year)||isNaN(s.month)||isNaN(s.day)||isNaN(s.hour)||isNaN(s.minute)||isNaN(s.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(s)}`);return s.hour===24&&(s.hour=0),{y:s.year,m:s.month,d:s.day,h:s.hour,i:s.minute,s:s.second,tz:e}}function b(n,e,t,r,s,i,a){return{y:n,m:e,d:t,h:r,i:s,s:i,tz:a}}var N=[1,2,4,8,16],g=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let i=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${i} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,s){let i=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return i.fill(s);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,s);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,s):t.indexOf("-")!==-1?this.handleRange(t,e,r,s):t.indexOf("/")!==-1?this.handleStepping(t,e,r,s):t!==""&&this.handleNumber(t,e,r,s)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,s){let i=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(i[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,i[1]||s)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let w=u;w<=m;w+=d)this.setPart(t,w,i[1]||s)}extractNth(e,t){let r=e,s;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");s=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");s="L",r=r.slice(0,-1)}return[r,s]}handleRange(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let i=this.extractNth(e,t),a=i[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,i[1]||s)}handleStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let i=this.extractNth(e,t),a=i[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,i[1]||s)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|N[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}};var R=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let i=new Date(Date.UTC(e,t,r)).getUTCDay();if(i===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return i===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,s){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(s&63&&N[h-1]&s)return!0;if(s&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=p(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>R[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=O(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(O(e,this.tz))}findNext(e,t,r,s){let i=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=R[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+s;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-s)===o-s){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-s==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-s-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-s,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:!e.domAndDow&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-s,i!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let i=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){i=a;break}if(i===-1)return null;this.year=i,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let s=this.findNext(t,c[r][0],e,c[r][2]);if(s>1){let i=r+1;for(;i<c.length;)this[c[i][0]]=-c[i][2],i++;if(s===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):k(b(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function _(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode!==void 0&&n.domAndDow===void 0?n.domAndDow=!n.legacyMode:n.domAndDow===void 0&&(n.domAndDow=!1),n.legacyMode=!n.domAndDow,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.dayOffset=n.dayOffset===void 0?0:parseInt(n.dayOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");if(n.dayOffset!==void 0&&n.dayOffset!==0&&isNaN(n.dayOffset))throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return n}function y(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function A(n){return y(n)}function x(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var U=30*1e3,T=[],P=class{name;options;_states;fn;constructor(e,t,r){let s,i;if(y(t))i=t;else if(typeof t=="object")s=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))i=r;else if(typeof r=="object")s=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=s?.name,this.options=_(s),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:s?s.maxRuns:void 0,paused:s?s.paused:!1,pattern:new g("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new g(e,this.options.timezone,{mode:this.options.mode}),this.name){if(T.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");T.push(this)}return i!==void 0&&A(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);if(!t)return null;if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let r=t.getDate(!1),s=this.options.dayOffset*24*60*60*1e3;return new Date(r.getTime()+s)}return t.getDate(!1)}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],s=t||this._states.currentRun||void 0;for(;e--&&(s=this._next(s));)if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let i=s.getDate(!1),a=this.options.dayOffset*24*60*60*1e3;r.push(new Date(i.getTime()+a))}else r.push(s.getDate(!1));return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,s=!this._states.kill;return t&&r&&s&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=T.indexOf(this);e>=0&&T.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>U&&(t=U),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&x(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){y(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),s=this._states.blocking&&this.options.protect;r&&!s?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&s&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let s=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&s!==this._states.once&&(s=s.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||s===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&s.getTime()>=this.options.stopAt.getTime()?null:s}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),s=e;if(this.options.startAt.getTime()<=r.getTime()){s=this.options.startAt;let i=s.getTime()+this.options.interval*1e3;for(;i<=r.getTime();)s=new f(s,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),i=s.getTime()+this.options.interval*1e3;t=!0}return s===null&&(s=void 0),[s,t]}};0&&(module.exports={Cron,CronDate,CronPattern,scheduledJobs});
package/dist/croner.js CHANGED
@@ -1 +1 @@
1
- function y(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function D(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function M(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?T(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):T(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function v(n,e,t){return k(M(n,e),t)}function k(n,e){let t=new Date(y(n)),r=p(t,n.tz),i=y(n),s=y(r),a=i-s,h=new Date(t.getTime()+a),o=p(h,n.tz);if(D(o,n)){let m=new Date(h.getTime()-36e5),d=p(m,n.tz);return D(d,n)?m:h}let l=new Date(h.getTime()+y(n)-y(o)),u=p(l,n.tz);if(D(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function p(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(s){let a=s instanceof Error?s.message:String(s);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let s of r)(s.type==="year"||s.type==="month"||s.type==="day"||s.type==="hour"||s.type==="minute"||s.type==="second")&&(i[s.type]=parseInt(s.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function T(n,e,t,r,i,s,a){return{y:n,m:e,d:t,h:r,i,s,tz:a}}var O=[1,2,4,8,16],C=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let s=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${s} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,i){let s=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return s.fill(i);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,i);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,i):t.indexOf("-")!==-1?this.handleRange(t,e,r,i):t.indexOf("/")!==-1?this.handleStepping(t,e,r,i):t!==""&&this.handleNumber(t,e,r,i)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,i){let s=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(s[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,s[1]||i)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(e,t),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let w=u;w<=m;w+=d)this.setPart(t,w,s[1]||i)}extractNth(e,t){let r=e,i;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(e,t),a=s[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,s[1]||i)}handleStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(e,t),a=s[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,s[1]||i)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|O[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}};var P=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let s=new Date(Date.UTC(e,t,r)).getUTCDay();if(s===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return s===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,i){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(i&63&&O[h-1]&i)return!0;if(i&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=p(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>P[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=v(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(v(e,this.tz))}findNext(e,t,r,i){let s=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=P[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+i;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-i)===o-i){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-i==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-i-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-i,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:e.legacyMode&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-i,s!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let s=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){s=a;break}if(s===-1)return null;this.year=s,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(t,c[r][0],e,c[r][2]);if(i>1){let s=r+1;for(;s<c.length;)this[c[s][0]]=-c[s][2],s++;if(i===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):k(T(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function E(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode=n.legacyMode===void 0?!0:n.legacyMode,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");return n}function g(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function R(n){return g(n)}function _(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var x=30*1e3,b=[],U=class{name;options;_states;fn;constructor(e,t,r){let i,s;if(g(t))s=t;else if(typeof t=="object")i=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(g(r))s=r;else if(typeof r=="object")i=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=E(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:i?i.paused:!1,pattern:new C("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new C(e,this.options.timezone,{mode:this.options.mode}),this.name){if(b.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");b.push(this)}return s!==void 0&&R(s)&&(this.fn=s,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],i=t||this._states.currentRun||void 0;for(;e--&&(i=this.nextRun(i));)r.push(i);return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,i=!this._states.kill;return t&&r&&i&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=b.indexOf(this);e>=0&&b.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>x&&(t=x),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&_(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){g(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&i&&g(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let i=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&i!==this._states.once&&(i=i.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||i===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),i=e;if(this.options.startAt.getTime()<=r.getTime()){i=this.options.startAt;let s=i.getTime()+this.options.interval*1e3;for(;s<=r.getTime();)i=new f(i,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),s=i.getTime()+this.options.interval*1e3;t=!0}return i===null&&(i=void 0),[i,t]}};export{U as Cron,f as CronDate,C as CronPattern,b as scheduledJobs};
1
+ function y(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function D(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function U(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?T(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):T(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function v(n,e,t){return O(U(n,e),t)}function O(n,e){let t=new Date(y(n)),r=p(t,n.tz),s=y(n),i=y(r),a=s-i,h=new Date(t.getTime()+a),o=p(h,n.tz);if(D(o,n)){let m=new Date(h.getTime()-36e5),d=p(m,n.tz);return D(d,n)?m:h}let l=new Date(h.getTime()+y(n)-y(o)),u=p(l,n.tz);if(D(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function p(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let s={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let i of r)(i.type==="year"||i.type==="month"||i.type==="day"||i.type==="hour"||i.type==="minute"||i.type==="second")&&(s[i.type]=parseInt(i.value,10));if(isNaN(s.year)||isNaN(s.month)||isNaN(s.day)||isNaN(s.hour)||isNaN(s.minute)||isNaN(s.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(s)}`);return s.hour===24&&(s.hour=0),{y:s.year,m:s.month,d:s.day,h:s.hour,i:s.minute,s:s.second,tz:e}}function T(n,e,t,r,s,i,a){return{y:n,m:e,d:t,h:r,i:s,s:i,tz:a}}var k=[1,2,4,8,16],C=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let i=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${i} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,s){let i=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return i.fill(s);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,s);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,s):t.indexOf("-")!==-1?this.handleRange(t,e,r,s):t.indexOf("/")!==-1?this.handleStepping(t,e,r,s):t!==""&&this.handleNumber(t,e,r,s)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,s){let i=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(i[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,i[1]||s)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let w=u;w<=m;w+=d)this.setPart(t,w,i[1]||s)}extractNth(e,t){let r=e,s;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");s=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");s="L",r=r.slice(0,-1)}return[r,s]}handleRange(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let i=this.extractNth(e,t),a=i[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,i[1]||s)}handleStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let i=this.extractNth(e,t),a=i[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,i[1]||s)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|k[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}};var P=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let i=new Date(Date.UTC(e,t,r)).getUTCDay();if(i===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return i===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,s){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(s&63&&k[h-1]&s)return!0;if(s&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=p(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>P[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=v(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(v(e,this.tz))}findNext(e,t,r,s){let i=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=P[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+s;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-s)===o-s){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-s==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-s-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-s,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:!e.domAndDow&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-s,i!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let i=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){i=a;break}if(i===-1)return null;this.year=i,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let s=this.findNext(t,c[r][0],e,c[r][2]);if(s>1){let i=r+1;for(;i<c.length;)this[c[i][0]]=-c[i][2],i++;if(s===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):O(T(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function E(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode!==void 0&&n.domAndDow===void 0?n.domAndDow=!n.legacyMode:n.domAndDow===void 0&&(n.domAndDow=!1),n.legacyMode=!n.domAndDow,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.dayOffset=n.dayOffset===void 0?0:parseInt(n.dayOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");if(n.dayOffset!==void 0&&n.dayOffset!==0&&isNaN(n.dayOffset))throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return n}function g(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function R(n){return g(n)}function _(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var A=30*1e3,b=[],x=class{name;options;_states;fn;constructor(e,t,r){let s,i;if(g(t))i=t;else if(typeof t=="object")s=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(g(r))i=r;else if(typeof r=="object")s=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=s?.name,this.options=E(s),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:s?s.maxRuns:void 0,paused:s?s.paused:!1,pattern:new C("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new C(e,this.options.timezone,{mode:this.options.mode}),this.name){if(b.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");b.push(this)}return i!==void 0&&R(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);if(!t)return null;if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let r=t.getDate(!1),s=this.options.dayOffset*24*60*60*1e3;return new Date(r.getTime()+s)}return t.getDate(!1)}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],s=t||this._states.currentRun||void 0;for(;e--&&(s=this._next(s));)if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let i=s.getDate(!1),a=this.options.dayOffset*24*60*60*1e3;r.push(new Date(i.getTime()+a))}else r.push(s.getDate(!1));return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,s=!this._states.kill;return t&&r&&s&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=b.indexOf(this);e>=0&&b.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>A&&(t=A),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&_(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){g(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),s=this._states.blocking&&this.options.protect;r&&!s?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&s&&g(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let s=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&s!==this._states.once&&(s=s.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||s===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&s.getTime()>=this.options.stopAt.getTime()?null:s}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),s=e;if(this.options.startAt.getTime()<=r.getTime()){s=this.options.startAt;let i=s.getTime()+this.options.interval*1e3;for(;i<=r.getTime();)s=new f(s,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),i=s.getTime()+this.options.interval*1e3;t=!0}return s===null&&(s=void 0),[s,t]}};export{x as Cron,f as CronDate,C as CronPattern,b as scheduledJobs};
@@ -1 +1 @@
1
- var Cron=(()=>{var p=(n,e)=>()=>(n&&(e=n(n=0)),e);var Y=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);function C(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function k(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function j(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?b(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):b(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function O(n,e,t){return N(j(n,e),t)}function N(n,e){let t=new Date(C(n)),r=g(t,n.tz),i=C(n),s=C(r),a=i-s,h=new Date(t.getTime()+a),o=g(h,n.tz);if(k(o,n)){let m=new Date(h.getTime()-36e5),d=g(m,n.tz);return k(d,n)?m:h}let l=new Date(h.getTime()+C(n)-C(o)),u=g(l,n.tz);if(k(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function g(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(s){let a=s instanceof Error?s.message:String(s);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let s of r)(s.type==="year"||s.type==="month"||s.type==="day"||s.type==="hour"||s.type==="minute"||s.type==="second")&&(i[s.type]=parseInt(s.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function b(n,e,t,r,i,s,a){return{y:n,m:e,d:t,h:r,i,s,tz:a}}var _=p(()=>{});var P,T,E=p(()=>{P=[1,2,4,8,16],T=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let s=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${s} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,i){let s=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return s.fill(i);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,i);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,i):t.indexOf("-")!==-1?this.handleRange(t,e,r,i):t.indexOf("/")!==-1?this.handleStepping(t,e,r,i):t!==""&&this.handleNumber(t,e,r,i)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,i){let s=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(s[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,s[1]||i)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(e,t),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let v=u;v<=m;v+=d)this.setPart(t,v,s[1]||i)}extractNth(e,t){let r=e,i;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(e,t),a=s[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,s[1]||i)}handleStepping(e,t,r,i){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(e,t),a=s[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,s[1]||i)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|P[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}}});var U,c,f,R=p(()=>{_();E();U=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let s=new Date(Date.UTC(e,t,r)).getUTCDay();if(s===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return s===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,i){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(i&63&&P[h-1]&i)return!0;if(i&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=g(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>U[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=O(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(O(e,this.tz))}findNext(e,t,r,i){let s=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=U[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+i;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-i)===o-i){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-i==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-i-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-i,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:e.legacyMode&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-i,s!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let s=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){s=a;break}if(s===-1)return null;this.year=s,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(t,c[r][0],e,c[r][2]);if(i>1){let s=r+1;for(;s<c.length;)this[c[s][0]]=-c[s][2],s++;if(i===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):N(b(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}}});function M(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode=n.legacyMode===void 0?!0:n.legacyMode,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");return n}var S=p(()=>{R()});function y(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function A(n){return y(n)}function I(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var W=p(()=>{});var z,w,D,F=p(()=>{R();E();S();W();z=30*1e3,w=[],D=class{name;options;_states;fn;constructor(e,t,r){let i,s;if(y(t))s=t;else if(typeof t=="object")i=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if(typeof r=="object")i=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=M(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:i?i.paused:!1,pattern:new T("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new T(e,this.options.timezone,{mode:this.options.mode}),this.name){if(w.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");w.push(this)}return s!==void 0&&A(s)&&(this.fn=s,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],i=t||this._states.currentRun||void 0;for(;e--&&(i=this.nextRun(i));)r.push(i);return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,i=!this._states.kill;return t&&r&&i&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=w.indexOf(this);e>=0&&w.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>z&&(t=z),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&I(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){y(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let i=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&i!==this._states.once&&(i=i.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||i===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),i=e;if(this.options.startAt.getTime()<=r.getTime()){i=this.options.startAt;let s=i.getTime()+this.options.interval*1e3;for(;s<=r.getTime();)i=new f(i,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),s=i.getTime()+this.options.interval*1e3;t=!0}return i===null&&(i=void 0),[i,t]}}});var Z=Y((ae,L)=>{F();L.exports=D});return Z();})();
1
+ var Cron=(()=>{var p=(n,e)=>()=>(n&&(e=n(n=0)),e);var Y=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);function C(n){return Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)}function O(n,e){return n.y===e.y&&n.m===e.m&&n.d===e.d&&n.h===e.h&&n.i===e.i&&n.s===e.s}function j(n,e){let t=new Date(Date.parse(n));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=n.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?b(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):b(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function k(n,e,t){return N(j(n,e),t)}function N(n,e){let t=new Date(C(n)),r=g(t,n.tz),s=C(n),i=C(r),a=s-i,h=new Date(t.getTime()+a),o=g(h,n.tz);if(O(o,n)){let m=new Date(h.getTime()-36e5),d=g(m,n.tz);return O(d,n)?m:h}let l=new Date(h.getTime()+C(n)-C(o)),u=g(l,n.tz);if(O(u,n))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return h.getTime()>l.getTime()?h:l}function g(n,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let s={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let i of r)(i.type==="year"||i.type==="month"||i.type==="day"||i.type==="hour"||i.type==="minute"||i.type==="second")&&(s[i.type]=parseInt(i.value,10));if(isNaN(s.year)||isNaN(s.month)||isNaN(s.day)||isNaN(s.hour)||isNaN(s.minute)||isNaN(s.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(s)}`);return s.hour===24&&(s.hour=0),{y:s.year,m:s.month,d:s.day,h:s.hour,i:s.minute,s:s.second,tz:e}}function b(n,e,t,r,s,i,a){return{y:n,m:e,d:t,h:r,i:s,s:i,tz:a}}var _=p(()=>{});var P,T,E=p(()=>{P=[1,2,4,8,16],T=class{pattern;timezone;mode;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let r;switch(this.mode){case"5-part":r=5;break;case"6-part":r=6;break;case"7-part":r=7;break;case"5-or-6-parts":r=[5,6];break;case"6-or-7-parts":r=[6,7];break;default:r=0}if(!(Array.isArray(r)?r.includes(t):t===r)){let i=Array.isArray(r)?r.join(" or "):r.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${i} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].indexOf("L")>=0&&(e[3]=e[3].replace("L",""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1),this.partToArray("dayOfWeek",e[5],0,63),this.partToArray("year",e[6],0,1),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,s){let i=this[e],a=e==="day"&&this.lastDayOfMonth;if(t===""&&!a)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return i.fill(s);let h=t.split(",");if(h.length>1)for(let o=0;o<h.length;o++)this.partToArray(e,h[o],r,s);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,s):t.indexOf("-")!==-1?this.handleRange(t,e,r,s):t.indexOf("/")!==-1?this.handleStepping(t,e,r,s):t!==""&&this.handleNumber(t,e,r,s)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,-WL]+/:t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,s){let i=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let h=parseInt(i[0],10)+r;if(isNaN(h))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,h,i[1]||s)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}handleRangeWithStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,h,o,l]=a,u=parseInt(h,10)+r,m=parseInt(o,10)+r,d=parseInt(l,10);if(isNaN(u))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(m))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(d))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(d===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(d>this[t].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[t].length+")");if(u>m)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let v=u;v<=m;v+=d)this.setPart(t,v,i[1]||s)}extractNth(e,t){let r=e,s;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");s=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");s="L",r=r.slice(0,-1)}return[r,s]}handleRange(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let i=this.extractNth(e,t),a=i[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let h=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(h))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(h>o)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(let l=h;l<=o;l++)this.setPart(t,l,i[1]||s)}handleStepping(e,t,r,s){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let i=this.extractNth(e,t),a=i[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");a[0]===""&&(a[0]="*");let h=0;a[0]!=="*"&&(h=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[t].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[t].length+")");for(let l=h;l<this[t].length;l+=o)this.setPart(t,l,i[1]||s)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|P[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}}});var x,c,f,R=p(()=>{_();E();x=[31,28,31,30,31,30,31,31,30,31,30,31],c=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e===void 0)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof n)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getNearestWeekday(e,t,r){let i=new Date(Date.UTC(e,t,r)).getUTCDay();if(i===0){let a=new Date(Date.UTC(e,t+1,0)).getUTCDate();return r===a?r-2:r+1}return i===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,s){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),h=0;for(let o=1;o<=r;o++)new Date(Date.UTC(e,t,o)).getUTCDay()===a&&h++;if(s&63&&P[h-1]&s)return!0;if(s&32){let o=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let l=r+1;l<=o;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=g(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>x[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=k(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(k(e,this.tz))}findNext(e,t,r,s){let i=this[t],a;r.lastDayOfMonth&&(this.month!==1?a=x[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[t]+s;o<r[t].length;o++){let l=r[t][o];if(t==="day"&&!l){for(let u=0;u<r.nearestWeekdays.length;u++)if(r.nearestWeekdays[u]&&this.getNearestWeekday(this.year,this.month,u-s)===o-s){l=1;break}}if(t==="day"&&r.lastDayOfMonth&&o-s==a&&(l=1),t==="day"&&!r.starDOW){let u=r.dayOfWeek[(h+(o-s-1))%7];if(u&&u&63)u=this.isNthWeekdayOfMonth(this.year,this.month,o-s,u)?1:0;else if(u)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${u}`);r.useAndLogic?l=l&&u:!e.domAndDow&&!r.starDOM?l=l||u:l=l&&u}if(l)return this[t]=o-s,i!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let i=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){i=a;break}if(i===-1)return null;this.year=i,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let s=this.findNext(t,c[r][0],e,c[r][2]);if(s>1){let i=r+1;for(;i<c.length;)this[c[i][0]]=-c[i][2],i++;if(s===3){if(this[c[r][1]]++,this[c[r][0]]=-c[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=c.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):N(b(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}}});function U(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode!==void 0&&n.domAndDow===void 0?n.domAndDow=!n.legacyMode:n.domAndDow===void 0&&(n.domAndDow=!1),n.legacyMode=!n.domAndDow,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.dayOffset=n.dayOffset===void 0?0:parseInt(n.dayOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.mode=n.mode===void 0?"auto":n.mode,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(n.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");if(n.dayOffset!==void 0&&n.dayOffset!==0&&isNaN(n.dayOffset))throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return n}var M=p(()=>{R()});function y(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function S(n){return y(n)}function I(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var W=p(()=>{});var z,w,D,F=p(()=>{R();E();M();W();z=30*1e3,w=[],D=class{name;options;_states;fn;constructor(e,t,r){let s,i;if(y(t))i=t;else if(typeof t=="object")s=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))i=r;else if(typeof r=="object")s=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=s?.name,this.options=U(s),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:s?s.maxRuns:void 0,paused:s?s.paused:!1,pattern:new T("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new f(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new T(e,this.options.timezone,{mode:this.options.mode}),this.name){if(w.find(h=>h.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");w.push(this)}return i!==void 0&&S(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);if(!t)return null;if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let r=t.getDate(!1),s=this.options.dayOffset*24*60*60*1e3;return new Date(r.getTime()+s)}return t.getDate(!1)}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=[],s=t||this._states.currentRun||void 0;for(;e--&&(s=this._next(s));)if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let i=s.getDate(!1),a=this.options.dayOffset*24*60*60*1e3;r.push(new Date(i.getTime()+a))}else r.push(s.getDate(!1));return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,s=!this._states.kill;return t&&r&&s&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof f||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new f(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=w.indexOf(this);e>=0&&w.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>z&&(t=z),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&I(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){y(this.options.catch)&&this.options.catch(t,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),s=this._states.blocking&&this.options.protect;r&&!s?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&s&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new f(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let s=this._states.once||new f(e,this.options.timezone||this.options.utcOffset);return!r&&s!==this._states.once&&(s=s.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||s===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&s.getTime()>=this.options.stopAt.getTime()?null:s}_calculatePreviousRun(e,t){let r=new f(void 0,this.options.timezone||this.options.utcOffset),s=e;if(this.options.startAt.getTime()<=r.getTime()){s=this.options.startAt;let i=s.getTime()+this.options.interval*1e3;for(;i<=r.getTime();)s=new f(s,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),i=s.getTime()+this.options.interval*1e3;t=!0}return s===null&&(s=void 0),[s,t]}}});var Z=Y((ae,L)=>{F();L.exports=D});return Z();})();
package/dist/options.d.ts CHANGED
@@ -68,6 +68,21 @@ interface CronOptions<T = undefined> {
68
68
  * The UTC offset for the cron job, in minutes.
69
69
  */
70
70
  utcOffset?: number;
71
+ /**
72
+ * If true, uses AND logic when combining day-of-month and day-of-week.
73
+ * If false, uses OR logic for combining day-of-month and day-of-week (legacy behavior).
74
+ * @default false
75
+ */
76
+ domAndDow?: boolean;
77
+ /**
78
+ * @deprecated Use domAndDow instead. This option will be removed in a future version.
79
+ * If true, enables legacy mode (OR logic) for compatibility with older cron implementations.
80
+ * Offset the scheduled date by a number of days.
81
+ * Positive values shift the date forward, negative values shift it backward.
82
+ * For example, dayOffset: -1 schedules the job one day before the pattern match.
83
+ * @default 0
84
+ */
85
+ dayOffset?: number;
71
86
  /**
72
87
  * If true, enables legacy mode for compatibility with older cron implementations.
73
88
  * @default true
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  }
60
60
  },
61
61
  "license": "MIT",
62
- "version": "10.0.0-dev.1"
62
+ "version": "10.0.0-dev.2"
63
63
  }