!function(f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tc=f()}(function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);throw(f=new Error("Cannot find module '"+i+"'")).code="MODULE_NOT_FOUND",f}c=n[i]={exports:{}},e[i][0].call(c.exports,function(r){return o(e[i][1][r]||r)},c,c.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=TimeUnit.MAX?(0,error_1.throwError)("Argument.Unit","invalid time unit ".concat(unit)):(unit=TimeUnit[unit].toLowerCase(),1===amount||-1===amount?unit:unit+"s")}function isLeapYear(year){return(0,assert_1.default)(Number.isInteger(year),"Argument.Year","Invalid year ".concat(year)),year%4==0&&(year%100!=0||year%400==0)}function daysInYear(year){return isLeapYear(year)?366:365}function daysInMonth(year,month){switch(month){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31;case 2:return isLeapYear(year)?29:28;case 4:case 6:case 9:case 11:return 30;default:return(0,error_1.throwError)("Argument.Month","Invalid month: ".concat(month))}}function dayOfYear(year,month,day){(0,assert_1.default)(Number.isInteger(year),"Argument.Year","Year out of range: ".concat(year)),(0,assert_1.default)(Number.isInteger(month)&&1<=month&&month<=12,"Argument.Month","Month out of range: ".concat(month)),(0,assert_1.default)(Number.isInteger(day)&&1<=day&&day<=daysInMonth(year,month),"Argument.Day","day out of range");for(var yearDay=0,i=1;i=daysInYear(year);)temp-=daysInYear(year),year++;for(result.year=year,month=1;temp>=daysInMonth(year,month);)temp-=daysInMonth(year,month),month++;result.month=month,result.day=temp+1}else{for(result.milli=math.positiveModulo(temp,1e3),temp=Math.floor(temp/1e3),result.second=math.positiveModulo(temp,60),temp=Math.floor(temp/60),result.minute=math.positiveModulo(temp,60),temp=Math.floor(temp/60),result.hour=math.positiveModulo(temp,24),temp=Math.floor(temp/24),year=1969;temp<-daysInYear(year);)temp+=daysInYear(year),year--;for(result.year=year,month=12;temp<-daysInMonth(year,month);)temp+=daysInMonth(year,month),month--;result.month=month,result.day=temp+1+daysInMonth(year,month)}return result}function normalizeTimeComponents(components){components={year:"number"==typeof components.year?components.year:1970,month:"number"==typeof components.month?components.month:1,day:"number"==typeof components.day?components.day:1,hour:"number"==typeof components.hour?components.hour:0,minute:"number"==typeof components.minute?components.minute:0,second:"number"==typeof components.second?components.second:0,milli:"number"==typeof components.milli?components.milli:0};return(0,assert_1.default)(Number.isInteger(components.year),"Argument.Year","invalid year ".concat(components.year)),(0,assert_1.default)(Number.isInteger(components.month)&&1<=components.month&&components.month<=12,"Argument.Month","invalid month ".concat(components.month)),(0,assert_1.default)(Number.isInteger(components.day)&&1<=components.day&&components.day<=daysInMonth(components.year,components.month),"Argument.Day","invalid day ".concat(components.day)),(0,assert_1.default)(Number.isInteger(components.hour)&&0<=components.hour&&components.hour<=23,"Argument.Hour","invalid hour ".concat(components.hour)),(0,assert_1.default)(Number.isInteger(components.minute)&&0<=components.minute&&components.minute<=59,"Argument.Minute","invalid minute ".concat(components.minute)),(0,assert_1.default)(Number.isInteger(components.second)&&0<=components.second&&components.second<=59,"Argument.Second","invalid second ".concat(components.second)),(0,assert_1.default)(Number.isInteger(components.milli)&&0<=components.milli&&components.milli<=999,"Argument.Milli","invalid milli ".concat(components.milli)),components}function timeToUnixNoLeapSecs(a,month,day,hour,minute,second,milli){month=normalizeTimeComponents("number"==typeof a?{year:a,month:month,day:day,hour:hour,minute:minute,second:second,milli:milli}:a);return month.milli+1e3*(month.second+60*month.minute+3600*month.hour+86400*dayOfYear(month.year,month.month,month.day)+31536e3*(month.year-1970)+86400*Math.floor((month.year-1969)/4)-86400*Math.floor((month.year-1901)/100)+86400*Math.floor((month.year-1900+299)/400))}function weekDayNoLeapSecs(unixMillis){(0,assert_1.default)(Number.isInteger(unixMillis),"Argument.UnixMillis","unixMillis should be an integer number");var epochDay=WeekDay.Thursday,unixMillis=Math.floor(unixMillis/1e3/86400);return math.positiveModulo(epochDay+unixMillis,7)}(WeekDay=>{WeekDay[WeekDay.Sunday=0]="Sunday",WeekDay[WeekDay.Monday=1]="Monday",WeekDay[WeekDay.Tuesday=2]="Tuesday",WeekDay[WeekDay.Wednesday=3]="Wednesday",WeekDay[WeekDay.Thursday=4]="Thursday",WeekDay[WeekDay.Friday=5]="Friday",WeekDay[WeekDay.Saturday=6]="Saturday"})(WeekDay||(exports.WeekDay=WeekDay={})),(TimeUnit=>{TimeUnit[TimeUnit.Millisecond=0]="Millisecond",TimeUnit[TimeUnit.Second=1]="Second",TimeUnit[TimeUnit.Minute=2]="Minute",TimeUnit[TimeUnit.Hour=3]="Hour",TimeUnit[TimeUnit.Day=4]="Day",TimeUnit[TimeUnit.Week=5]="Week",TimeUnit[TimeUnit.Month=6]="Month",TimeUnit[TimeUnit.Year=7]="Year",TimeUnit[TimeUnit.MAX=8]="MAX"})(TimeUnit||(exports.TimeUnit=TimeUnit={})),exports.timeUnitToMilliseconds=function(unit){switch(unit){case TimeUnit.Millisecond:return 1;case TimeUnit.Second:return 1e3;case TimeUnit.Minute:return 6e4;case TimeUnit.Hour:return 36e5;case TimeUnit.Day:return 864e5;case TimeUnit.Week:return 6048e5;case TimeUnit.Month:return 2592e6;case TimeUnit.Year:return 31104e6;default:return(0,error_1.throwError)("Argument.Unit","unknown time unit ".concat(unit))}},exports.timeUnitToString=timeUnitToString,exports.stringToTimeUnit=function(s){for(var trimmed=s.trim().toLowerCase(),i=0;i=dayOfYear(year,12,29)&&4<(day=getWeekOneDayOfYear(year+1))&&day<=month)return 1;var weekTwo,day=getWeekOneDayOfYear(year);return 4{function TimeStruct(a){"number"==typeof a?((0,assert_1.default)(Number.isInteger(a),"Argument.UnixMillis","invalid unix millis ".concat(a)),this._unixMillis=a):((0,assert_1.default)("object"==typeof a&&null!==a,"Argument.Components","invalid components object"),this._components=normalizeTimeComponents(a))}return TimeStruct.fromComponents=function(year,month,day,hour,minute,second,milli){return new TimeStruct({year:year,month:month,day:day,hour:hour,minute:minute,second:second,milli:milli})},TimeStruct.fromUnix=function(unixMillis){return new TimeStruct(unixMillis)},TimeStruct.fromDate=function(d,df){return df===javascript_1.DateFunctions.Get?new TimeStruct({year:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),milli:d.getMilliseconds()}):new TimeStruct({year:d.getUTCFullYear(),month:d.getUTCMonth()+1,day:d.getUTCDate(),hour:d.getUTCHours(),minute:d.getUTCMinutes(),second:d.getUTCSeconds(),milli:d.getUTCMilliseconds()})},TimeStruct.fromString=function(s){try{var dateAndTime,year=1970,month=1,day=1,hour=0,minute=0,second=0,fractionMillis=0,lastUnit=TimeUnit.Year,split=s.trim().split(".");if((0,assert_1.default)(1<=split.length&&split.length<=2,"Argument.S","Empty string or multiple dots."),-1===s.indexOf("-")?((0,assert_1.default)(split[0].match(/^((\d)+)|(\d\d\d\d\d\d\d\dT(\d)+)$/),"Argument.S","ISO string in basic notation may only contain numbers before the fractional part"),split[0]=split[0].replace("T",""),(0,assert_1.default)(-1!==[4,8,10,12,14].indexOf(split[0].length),"Argument.S","Padding or required components are missing. Note that YYYYMM is not valid per ISO 8601"),4<=split[0].length&&(year=parseInt(split[0].substr(0,4),10),lastUnit=TimeUnit.Year),8<=split[0].length&&(month=parseInt(split[0].substr(4,2),10),day=parseInt(split[0].substr(6,2),10),lastUnit=TimeUnit.Day),10<=split[0].length&&(hour=parseInt(split[0].substr(8,2),10),lastUnit=TimeUnit.Hour),12<=split[0].length&&(minute=parseInt(split[0].substr(10,2),10),lastUnit=TimeUnit.Minute),14<=split[0].length&&(second=parseInt(split[0].substr(12,2),10),lastUnit=TimeUnit.Second)):((0,assert_1.default)(split[0].match(/^\d\d\d\d(-\d\d-\d\d((T)?\d\d(\:\d\d(:\d\d)?)?)?)?$/),"Argument.S","Invalid ISO string"),dateAndTime=[],dateAndTime=-1!==s.indexOf("T")?split[0].split("T"):10{function DateTime(a1,a2,a3,h,m,s,ms,timeZone){switch(this.kind="DateTime",typeof a1){case"number":var year_1,month_1,day_1,hour_1,minute_1,second_1,milli_1;"number"!=typeof a2?((0,assert_1.default)(void 0===a3&&void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A3","for unix timestamp datetime constructor, third through 8th argument must be undefined"),(0,assert_1.default)(null==a2||isTimeZone(a2),"Argument.TimeZone","DateTime.DateTime(): second arg should be a TimeZone object."),this._zone="object"==typeof a2&&isTimeZone(a2)?a2:void 0,unixMillis=(0,error_1.convertError)("Argument.UnixMillis",function(){return math.roundSym(a1)}),this._zone?this._zoneDate=this._zone.normalizeZoneTime(new basics_1.TimeStruct(unixMillis)):this._zoneDate=new basics_1.TimeStruct(unixMillis)):((0,assert_1.default)("number"==typeof a2,"Argument.Year","DateTime.DateTime(): Expect month to be a number."),(0,assert_1.default)("number"==typeof a3,"Argument.Month","DateTime.DateTime(): Expect day to be a number."),(0,assert_1.default)(null==timeZone||isTimeZone(timeZone),"Argument.TimeZone","DateTime.DateTime(): eighth arg should be a TimeZone object."),year_1=a1,month_1=a2,day_1=a3,hour_1="number"==typeof h?h:0,minute_1="number"==typeof m?m:0,second_1="number"==typeof s?s:0,milli_1="number"==typeof ms?ms:0,year_1=(0,error_1.convertError)("Argument.Year",function(){return math.roundSym(year_1)}),month_1=(0,error_1.convertError)("Argument.Month",function(){return math.roundSym(month_1)}),day_1=(0,error_1.convertError)("Argument.Day",function(){return math.roundSym(day_1)}),hour_1=(0,error_1.convertError)("Argument.Hour",function(){return math.roundSym(hour_1)}),minute_1=(0,error_1.convertError)("Argument.Minute",function(){return math.roundSym(minute_1)}),second_1=(0,error_1.convertError)("Argument.Second",function(){return math.roundSym(second_1)}),milli_1=(0,error_1.convertError)("Argument.Milli",function(){return math.roundSym(milli_1)}),unixMillis=new basics_1.TimeStruct({year:year_1,month:month_1,day:day_1,hour:hour_1,minute:minute_1,second:second_1,milli:milli_1}),this._zone="object"==typeof timeZone&&isTimeZone(timeZone)?timeZone:void 0,this._zone?this._zoneDate=this._zone.normalizeZoneTime(unixMillis):this._zoneDate=unixMillis);break;case"string":"string"==typeof a2?((0,assert_1.default)(void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A4","first two arguments are a string, therefore the fourth through 8th argument must be undefined"),(0,assert_1.default)(null==a3||isTimeZone(a3),"Argument.TimeZone","DateTime.DateTime(): third arg should be a TimeZone object."),unixMillis=void 0,"object"==typeof a3&&isTimeZone(a3)&&(unixMillis=a3),unixMillis=parseFuncs.parse(a1,a2,unixMillis),this._zoneDate=unixMillis.time,this._zone=unixMillis.zone):((0,assert_1.default)(void 0===a3&&void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A3","first arguments is a string and the second is not, therefore the third through 8th argument must be undefined"),(0,assert_1.default)(null==a2||isTimeZone(a2),"Argument.TimeZone","DateTime.DateTime(): second arg should be a TimeZone object."),unixMillis=a1.trim(),unixMillis=DateTime._splitDateFromTimeZone(unixMillis),(0,assert_1.default)(2===unixMillis.length,"Argument.S",'Invalid date string given: "'+a1+'"'),isTimeZone(a2)?this._zone=a2:this._zone=unixMillis[1].trim()?timezone_1.TimeZone.zone(unixMillis[1]):void 0,this._zoneDate=basics_1.TimeStruct.fromString(unixMillis[0]),this._zone&&(this._zoneDate=this._zone.normalizeZoneTime(this._zoneDate)));break;case"object":var unixMillis,dk;a1 instanceof Date?((0,assert_1.default)(void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A4","first argument is a Date, therefore the fourth through 8th argument must be undefined"),(0,assert_1.default)("number"==typeof a2&&(a2===javascript_1.DateFunctions.Get||a2===javascript_1.DateFunctions.GetUTC),"Argument.GetFuncs","DateTime.DateTime(): for a Date object a DateFunctions must be passed as second argument"),(0,assert_1.default)(null==a3||isTimeZone(a3),"Argument.TimeZone","DateTime.DateTime(): third arg should be a TimeZone object."),unixMillis=a1,dk=a2,this._zone=a3||void 0,this._zoneDate=basics_1.TimeStruct.fromDate(unixMillis,dk),this._zone&&(this._zoneDate=this._zone.normalizeZoneTime(this._zoneDate))):((0,assert_1.default)(void 0===a3&&void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A3","first argument is a TimeStruct, therefore the third through 8th argument must be undefined"),(0,assert_1.default)(null==a2||isTimeZone(a2),"Argument.TimeZone","expect a TimeZone as second argument"),this._zoneDate=a1.clone(),this._zone=a2||void 0);break;case"undefined":(0,assert_1.default)(void 0===a2&&void 0===a3&&void 0===h&&void 0===m&&void 0===s&&void 0===ms&&void 0===timeZone,"Argument.A2","first argument is undefined, therefore the rest must also be undefined"),this._zone=timezone_1.TimeZone.local(),this._utcDate=basics_1.TimeStruct.fromDate(DateTime.timeSource.now(),javascript_1.DateFunctions.GetUTC);break;default:throw(0,error_1.error)("Argument.A1","DateTime.DateTime(): unexpected first argument type.")}}return Object.defineProperty(DateTime.prototype,"utcDate",{get:function(){return this._utcDate||(this._utcDate=convertToUtc(this._zoneDate,this._zone)),this._utcDate},set:function(value){this._utcDate=value,this._zoneDate=void 0},enumerable:!1,configurable:!0}),Object.defineProperty(DateTime.prototype,"zoneDate",{get:function(){return this._zoneDate||(this._zoneDate=convertFromUtc(this._utcDate,this._zone)),this._zoneDate},set:function(value){this._zoneDate=value,this._utcDate=void 0},enumerable:!1,configurable:!0}),DateTime.nowLocal=function(){var n=DateTime.timeSource.now();return new DateTime(n,javascript_1.DateFunctions.Get,timezone_1.TimeZone.local())},DateTime.nowUtc=function(){return new DateTime(DateTime.timeSource.now(),javascript_1.DateFunctions.GetUTC,timezone_1.TimeZone.utc())},DateTime.now=function(timeZone){return void 0===timeZone&&(timeZone=timezone_1.TimeZone.utc()),new DateTime(DateTime.timeSource.now(),javascript_1.DateFunctions.GetUTC,timezone_1.TimeZone.utc()).toZone(timeZone)},DateTime.fromExcel=function(n,timeZone){return(0,assert_1.default)(Number.isFinite(n),"Argument.N","invalid number"),new DateTime(Math.round(24*(n-25569)*60*60*1e3),timeZone)},DateTime.exists=function(year,month,day,hour,minute,second,millisecond,zone,allowPre1970){if(void 0===month&&(month=1),void 0===day&&(day=1),void 0===hour&&(hour=0),void 0===minute&&(minute=0),void 0===second&&(second=0),void 0===millisecond&&(millisecond=0),void 0===allowPre1970&&(allowPre1970=!1),!(isFinite(year)&&isFinite(month)&&isFinite(day)&&isFinite(hour)&&isFinite(minute)&&isFinite(second)&&isFinite(millisecond)))return!1;if(!allowPre1970&&year<1970)return!1;try{var dt=new DateTime(year,month,day,hour,minute,second,millisecond,zone);return year===dt.year()&&month===dt.month()&&day===dt.day()&&hour===dt.hour()&&minute===dt.minute()&&second===dt.second()&&millisecond===dt.millisecond()}catch(e){return!1}},DateTime.prototype.clone=function(){return new DateTime(this.zoneDate,this._zone)},DateTime.prototype.zone=function(){return this._zone},DateTime.prototype.zoneAbbreviation=function(dstDependent){return void 0===dstDependent&&(dstDependent=!0),this._zone?this._zone.abbreviationForUtc(this.utcDate,dstDependent):""},DateTime.prototype.offset=function(){return Math.round((this.zoneDate.unixMillis-this.utcDate.unixMillis)/6e4)},DateTime.prototype.offsetDuration=function(){return duration_1.Duration.milliseconds(Math.round(this.zoneDate.unixMillis-this.utcDate.unixMillis))},DateTime.prototype.standardOffsetDuration=function(){return this._zone?duration_1.Duration.minutes(this._zone.standardOffsetForUtc(this.utcDate)):duration_1.Duration.minutes(0)},DateTime.prototype.year=function(){return this.zoneDate.components.year},DateTime.prototype.month=function(){return this.zoneDate.components.month},DateTime.prototype.day=function(){return this.zoneDate.components.day},DateTime.prototype.hour=function(){return this.zoneDate.components.hour},DateTime.prototype.minute=function(){return this.zoneDate.components.minute},DateTime.prototype.second=function(){return this.zoneDate.components.second},DateTime.prototype.millisecond=function(){return this.zoneDate.components.milli},DateTime.prototype.weekDay=function(){return basics.weekDayNoLeapSecs(this.zoneDate.unixMillis)},DateTime.prototype.dayOfYear=function(){return this.zoneDate.yearDay()},DateTime.prototype.weekNumber=function(){return basics.weekNumber(this.year(),this.month(),this.day())},DateTime.prototype.weekOfMonth=function(){return basics.weekOfMonth(this.year(),this.month(),this.day())},DateTime.prototype.secondOfDay=function(){return basics.secondOfDay(this.hour(),this.minute(),this.second())},DateTime.prototype.unixUtcMillis=function(){return this.utcDate.unixMillis},DateTime.prototype.utcYear=function(){return this.utcDate.components.year},DateTime.prototype.utcMonth=function(){return this.utcDate.components.month},DateTime.prototype.utcDay=function(){return this.utcDate.components.day},DateTime.prototype.utcHour=function(){return this.utcDate.components.hour},DateTime.prototype.utcMinute=function(){return this.utcDate.components.minute},DateTime.prototype.utcSecond=function(){return this.utcDate.components.second},DateTime.prototype.utcDayOfYear=function(){return basics.dayOfYear(this.utcYear(),this.utcMonth(),this.utcDay())},DateTime.prototype.utcMillisecond=function(){return this.utcDate.components.milli},DateTime.prototype.utcWeekDay=function(){return basics.weekDayNoLeapSecs(this.utcDate.unixMillis)},DateTime.prototype.utcWeekNumber=function(){return basics.weekNumber(this.utcYear(),this.utcMonth(),this.utcDay())},DateTime.prototype.utcWeekOfMonth=function(){return basics.weekOfMonth(this.utcYear(),this.utcMonth(),this.utcDay())},DateTime.prototype.utcSecondOfDay=function(){return basics.secondOfDay(this.utcHour(),this.utcMinute(),this.utcSecond())},DateTime.prototype.withZone=function(zone){return new DateTime(this.year(),this.month(),this.day(),this.hour(),this.minute(),this.second(),this.millisecond(),zone)},DateTime.prototype.convert=function(zone){if(zone){if(!this._zone)return(0,error_1.throwError)("UnawareToAwareConversion","DateTime.toZone(): Cannot convert unaware date to an aware date");this._zone.equals(zone)?this._zone=zone:(this._utcDate||(this._utcDate=convertToUtc(this._zoneDate,this._zone)),this._zone=zone,this._zoneDate=void 0)}else{if(!this._zone)return this;this._zoneDate||(this._zoneDate=convertFromUtc(this._utcDate,this._zone)),this._zone=void 0,this._utcDate=void 0}return this},DateTime.prototype.toZone=function(zone){var result;return zone?((0,assert_1.default)(this._zone,"UnawareToAwareConversion","DateTime.toZone(): Cannot convert unaware date to an aware date"),(result=new DateTime).utcDate=this.utcDate,result._zone=zone,result):new DateTime(this.zoneDate,void 0)},DateTime.prototype.toDate=function(){return new Date(this.year(),this.month()-1,this.day(),this.hour(),this.minute(),this.second(),this.millisecond())},DateTime.prototype.toExcel=function(timeZone){var dt=this,timeZone=60*(dt=!timeZone||this._zone&&timeZone.equals(this._zone)?dt:this.toZone(timeZone)).offset()*1e3,dt=dt.unixUtcMillis();return this._unixTimeStampToExcel(dt+timeZone)},DateTime.prototype.toUtcExcel=function(){var unixTimestamp=this.unixUtcMillis();return this._unixTimeStampToExcel(unixTimestamp)},DateTime.prototype._unixTimeStampToExcel=function(n){return Math.round((n/864e5+25569)/(1/864e5))*(1/864e5)},DateTime.prototype.add=function(a1,unit){var amount,duration;return duration="object"==typeof a1?(amount=(duration=a1).amount(),duration.unit()):(amount=a1,unit),new DateTime(this._addToTimeStruct(this.utcDate,amount,duration),timezone_1.TimeZone.utc()).toZone(this._zone)},DateTime.prototype.addLocal=function(a1,unit){duration="object"==typeof a1?(amount=(duration=a1).amount(),duration.unit()):(amount=a1,unit);var amount,duration,a1=this._addToTimeStruct(this.zoneDate,amount,duration);return this._zone?(unit=0<=amount?tz_database_1.NormalizeOption.Up:tz_database_1.NormalizeOption.Down,new DateTime(this._zone.normalizeZoneTime(a1,unit),this._zone)):new DateTime(a1,void 0)},DateTime.prototype._addToTimeStruct=function(tm,amount,unit){var year,month,day,hour,minute,second,milli;switch((0,assert_1.default)(Number.isFinite(amount),"Argument.Amount","amount must be a finite number"),unit){case basics_1.TimeUnit.Millisecond:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+amount));case basics_1.TimeUnit.Second:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+1e3*amount));case basics_1.TimeUnit.Minute:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+6e4*amount));case basics_1.TimeUnit.Hour:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+36e5*amount));case basics_1.TimeUnit.Day:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+864e5*amount));case basics_1.TimeUnit.Week:return new basics_1.TimeStruct(math.roundSym(tm.unixMillis+7*amount*864e5));case basics_1.TimeUnit.Month:return(0,assert_1.default)(math.isInt(amount),"Argument.Amount","Cannot add/sub a non-integer amount of months"),month=0<=amount?(year=tm.components.year+Math.ceil((amount-(12-tm.components.month))/12),1+math.positiveModulo(tm.components.month-1+Math.floor(amount),12)):(year=tm.components.year+Math.floor((amount+(tm.components.month-1))/12),1+math.positiveModulo(tm.components.month-1+Math.ceil(amount),12)),day=Math.min(tm.components.day,basics.daysInMonth(year,month)),hour=tm.components.hour,minute=tm.components.minute,second=tm.components.second,milli=tm.components.milli,new basics_1.TimeStruct({year:year,month:month,day:day,hour:hour,minute:minute,second:second,milli:milli});case basics_1.TimeUnit.Year:return(0,assert_1.default)(math.isInt(amount),"Argument.Amount","Cannot add/sub a non-integer amount of years"),year=tm.components.year+amount,month=tm.components.month,day=Math.min(tm.components.day,basics.daysInMonth(year,month)),hour=tm.components.hour,minute=tm.components.minute,second=tm.components.second,milli=tm.components.milli,new basics_1.TimeStruct({year:year,month:month,day:day,hour:hour,minute:minute,second:second,milli:milli});default:return(0,error_1.throwError)("Argument.Unit","invalid time unit")}},DateTime.prototype.sub=function(a1,unit){return"number"==typeof a1?this.add(-1*a1,unit):this.add(a1.multiply(-1))},DateTime.prototype.subLocal=function(a1,unit){return"number"==typeof a1?this.addLocal(-1*a1,unit):this.addLocal(a1.multiply(-1))},DateTime.prototype.diff=function(other){return new duration_1.Duration(this.utcDate.unixMillis-other.utcDate.unixMillis)},DateTime.prototype.startOfDay=function(){return new DateTime(this.year(),this.month(),this.day(),0,0,0,0,this.zone())},DateTime.prototype.startOfMonth=function(){return new DateTime(this.year(),this.month(),1,0,0,0,0,this.zone())},DateTime.prototype.startOfYear=function(){return new DateTime(this.year(),1,1,0,0,0,0,this.zone())},DateTime.prototype.lessThan=function(other){return this.utcDate.unixMillisother.utcDate.unixMillis},DateTime.prototype.greaterEqual=function(other){return this.utcDate.unixMillis>=other.utcDate.unixMillis},DateTime.prototype.min=function(other){return(this.lessThan(other)?this:other).clone()},DateTime.prototype.max=function(other){return(this.greaterThan(other)?this:other).clone()},DateTime.prototype.toIsoString=function(){var s=this.zoneDate.toString();return this._zone?s+timezone_1.TimeZone.offsetToString(this.offset()):s},DateTime.prototype.toUtcIsoString=function(){return(this._zone?this.toZone(timezone_1.TimeZone.utc()):this.withZone(timezone_1.TimeZone.utc())).format("yyyy-MM-ddTHH:mm:ss.SSSZZZZZ")},DateTime.prototype.format=function(formatString,locale){return format.format(this.zoneDate,this.utcDate,this._zone,formatString,locale)},DateTime.parse=function(s,format,zone,locale,allowTrailing){s=parseFuncs.parse(s,format,zone,allowTrailing||!1,locale);try{return new DateTime(s.time,s.zone)}catch(e){throw e=(0,error_1.errorIs)(e,"InvalidTimeZoneData")?e:(0,error_1.error)("ParseError",e.message)}},DateTime.prototype.toString=function(){var s=this.zoneDate.toString();return this._zone?this._zone.kind()!==timezone_1.TimeZoneKind.Offset?s+" "+this._zone.toString():s+this._zone.toString():s},DateTime.prototype.valueOf=function(){return this.unixUtcMillis()},DateTime.prototype.toUtcString=function(){return this.utcDate.toString()},DateTime._splitDateFromTimeZone=function(s){var trimmed=s.trim(),result=["",""],index=trimmed.lastIndexOf("without DST");return-1{function Duration(i1,unit){var s,trimmed,hours_1,minutes_1,milliseconds_1,seconds_1,parts,sign,amount;this.kind="Duration","number"==typeof i1?(amount=i1,(0,assert_1.default)(Number.isFinite(amount),"Argument.Amount","amount should be finite: ".concat(amount)),this._amount=amount,this._unit="number"==typeof unit?unit:basics_1.TimeUnit.Millisecond,(0,assert_1.default)(Number.isInteger(this._unit)&&0<=this._unit&&this._unit=basics_1.TimeUnit.Month&&unit>=basics_1.TimeUnit.Month?(thisMonths=this._unit===basics_1.TimeUnit.Year?12:1,reqMonths=unit===basics_1.TimeUnit.Year?12:1,this._amount*thisMonths/reqMonths):(thisMonths=basics.timeUnitToMilliseconds(this._unit),reqMonths=basics.timeUnitToMilliseconds(unit),this._amount*thisMonths/reqMonths)},Duration.prototype.convert=function(unit){return new Duration(this.as(unit),unit)},Duration.prototype.milliseconds=function(){return this.as(basics_1.TimeUnit.Millisecond)},Duration.prototype.millisecond=function(){return this._part(basics_1.TimeUnit.Millisecond)},Duration.prototype.seconds=function(){return this.as(basics_1.TimeUnit.Second)},Duration.prototype.second=function(){return this._part(basics_1.TimeUnit.Second)},Duration.prototype.minutes=function(){return this.as(basics_1.TimeUnit.Minute)},Duration.prototype.minute=function(){return this._part(basics_1.TimeUnit.Minute)},Duration.prototype.hours=function(){return this.as(basics_1.TimeUnit.Hour)},Duration.prototype.hour=function(){return this._part(basics_1.TimeUnit.Hour)},Duration.prototype.wholeHours=function(){return Math.floor(basics.timeUnitToMilliseconds(this._unit)*Math.abs(this._amount)/36e5)},Duration.prototype.days=function(){return this.as(basics_1.TimeUnit.Day)},Duration.prototype.day=function(){return this._part(basics_1.TimeUnit.Day)},Duration.prototype.months=function(){return this.as(basics_1.TimeUnit.Month)},Duration.prototype.month=function(){return this._part(basics_1.TimeUnit.Month)},Duration.prototype.years=function(){return this.as(basics_1.TimeUnit.Year)},Duration.prototype.wholeYears=function(){return this._unit===basics_1.TimeUnit.Year?Math.floor(Math.abs(this._amount)):this._unit===basics_1.TimeUnit.Month?Math.floor(Math.abs(this._amount)/12):Math.floor(basics.timeUnitToMilliseconds(this._unit)*Math.abs(this._amount)/basics.timeUnitToMilliseconds(basics_1.TimeUnit.Year))},Duration.prototype.amount=function(){return this._amount},Duration.prototype.unit=function(){return this._unit},Duration.prototype.sign=function(){return this._amount<0?"-":""},Duration.prototype.lessThan=function(other){return this.milliseconds()=basics_1.TimeUnit.Month&&other.unit()>=basics_1.TimeUnit.Month||this._unitother.milliseconds()},Duration.prototype.greaterEqual=function(other){return this.milliseconds()>=other.milliseconds()},Duration.prototype.min=function(other){return(this.lessThan(other)?this:other).clone()},Duration.prototype.max=function(other){return(this.greaterThan(other)?this:other).clone()},Duration.prototype.multiply=function(value){return new Duration(this._amount*value,this._unit)},Duration.prototype.divide=function(value){return"number"==typeof value?((0,assert_1.default)(Number.isFinite(value)&&0!==value,"Argument.Value","cannot divide by ".concat(value)),new Duration(this._amount/value,this._unit)):((0,assert_1.default)(0!==value.amount(),"Argument.Value","cannot divide by 0"),this.milliseconds()/value.milliseconds())},Duration.prototype.add=function(value){return new Duration(this._amount+value.as(this._unit),this._unit)},Duration.prototype.sub=function(value){return new Duration(this._amount-value.as(this._unit),this._unit)},Duration.prototype.abs=function(){return 0<=this._amount?this.clone():this.multiply(-1)},Duration.prototype.toFullString=function(){return this.toHmsString(!0)},Duration.prototype.toHmsString=function(full){var result="";return((full=void 0===full?!1:full)||0{var AD=0{switch(token.symbol){case"y":case"Y":case"r":var yearValue=strings.padLeft(dateTime.year.toString(),token.length,"0");return yearValue=2===token.length?yearValue.slice(-2):yearValue;default:return token.raw}})(dateTime,token);break;case token_1.TokenType.QUARTER:tokenResult=((dateTime,token,locale)=>{var quarter=Math.ceil(dateTime.month/3);switch(token.symbol){case"Q":switch(token.length){case 1:case 2:return strings.padLeft(quarter.toString(),2,"0");case 3:return locale.quarterLetter+quarter;case 4:return locale.quarterAbbreviations[quarter-1]+" "+locale.quarterWord;case 5:return quarter.toString();default:return token.raw}case"q":switch(token.length){case 1:case 2:return strings.padLeft(quarter.toString(),2,"0");case 3:return locale.standAloneQuarterLetter+quarter;case 4:return locale.standAloneQuarterAbbreviations[quarter-1]+" "+locale.standAloneQuarterWord;case 5:return quarter.toString();default:return token.raw}default:return(0,error_1.throwError)("Argument.FormatString","invalid quarter pattern")}})(dateTime,token,mergedLocale);break;case token_1.TokenType.MONTH:tokenResult=((dateTime,token,locale)=>{switch(token.symbol){case"M":switch(token.length){case 1:case 2:return strings.padLeft(dateTime.month.toString(),token.length,"0");case 3:return locale.shortMonthNames[dateTime.month-1];case 4:return locale.longMonthNames[dateTime.month-1];case 5:return locale.monthLetters[dateTime.month-1];default:return token.raw}case"L":switch(token.length){case 1:case 2:return strings.padLeft(dateTime.month.toString(),token.length,"0");case 3:return locale.standAloneShortMonthNames[dateTime.month-1];case 4:return locale.standAloneLongMonthNames[dateTime.month-1];case 5:return locale.standAloneMonthLetters[dateTime.month-1];default:return token.raw}default:return(0,error_1.throwError)("Argument.FormatString","invalid month pattern")}})(dateTime,token,mergedLocale);break;case token_1.TokenType.DAY:tokenResult=((dateTime,token)=>{switch(token.symbol){case"d":return strings.padLeft(dateTime.day.toString(),token.length,"0");case"D":var dayOfYear=basics.dayOfYear(dateTime.year,dateTime.month,dateTime.day)+1;return strings.padLeft(dayOfYear.toString(),token.length,"0");default:return token.raw}})(dateTime,token);break;case token_1.TokenType.WEEKDAY:tokenResult=((dateTime,token,locale)=>{var weekDayNumber=basics.weekDayNoLeapSecs(dateTime.unixMillis);switch(token.length){case 1:case 2:return"e"===token.symbol?strings.padLeft(basics.weekDayNoLeapSecs(dateTime.unixMillis).toString(),token.length,"0"):locale.shortWeekdayNames[weekDayNumber];case 3:return locale.shortWeekdayNames[weekDayNumber];case 4:return locale.longWeekdayNames[weekDayNumber];case 5:return locale.weekdayLetters[weekDayNumber];case 6:return locale.weekdayTwoLetters[weekDayNumber];default:return token.raw}})(dateTime,token,mergedLocale);break;case token_1.TokenType.DAYPERIOD:tokenResult=((dateTime,token,locale)=>{switch(token.symbol){case"a":return token.length<=3?dateTime.hour<12?locale.dayPeriodAbbreviated.am:locale.dayPeriodAbbreviated.pm:4===token.length?dateTime.hour<12?locale.dayPeriodWide.am:locale.dayPeriodWide.pm:dateTime.hour<12?locale.dayPeriodNarrow.am:locale.dayPeriodNarrow.pm;case"b":case"B":return token.length<=3?0===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodAbbreviated.midnight:12===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodAbbreviated.noon:dateTime.hour<12?locale.dayPeriodAbbreviated.am:locale.dayPeriodAbbreviated.pm:4===token.length?0===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodWide.midnight:12===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodWide.noon:dateTime.hour<12?locale.dayPeriodWide.am:locale.dayPeriodWide.pm:0===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodNarrow.midnight:12===dateTime.hour&&0===dateTime.minute&&0===dateTime.second&&0===dateTime.milli?locale.dayPeriodNarrow.noon:dateTime.hour<12?locale.dayPeriodNarrow.am:locale.dayPeriodNarrow.pm;default:return token.raw}})(dateTime,token,mergedLocale);break;case token_1.TokenType.HOUR:tokenResult=((dateTime,token)=>{var hour=dateTime.hour;switch(token.symbol){case"h":return 0===(hour%=12)&&(hour=12),strings.padLeft(hour.toString(),token.length,"0");case"H":return strings.padLeft(hour.toString(),token.length,"0");case"K":return hour%=12,strings.padLeft(hour.toString(),token.length,"0");case"k":return 0===hour&&(hour=24),strings.padLeft(hour.toString(),token.length,"0");default:return token.raw}})(dateTime,token);break;case token_1.TokenType.MINUTE:tokenResult=((dateTime,token)=>strings.padLeft(dateTime.minute.toString(),token.length,"0"))(dateTime,token);break;case token_1.TokenType.SECOND:tokenResult=((dateTime,token)=>{switch(token.symbol){case"s":return strings.padLeft(dateTime.second.toString(),token.length,"0");case"S":var fraction=dateTime.milli,fraction=strings.padLeft(fraction.toString(),3,"0");return(fraction=strings.padRight(fraction,token.length,"0")).slice(0,token.length);case"A":return strings.padLeft(basics.secondOfDay(dateTime.hour,dateTime.minute,dateTime.second).toString(),token.length,"0");default:return token.raw}})(dateTime,token);break;case token_1.TokenType.ZONE:tokenResult=function _formatZone(currentTime,utcTime,zone,token){if(!zone)return"";var offset=Math.round((currentTime.unixMillis-utcTime.unixMillis)/6e4);var offsetHours=Math.floor(Math.abs(offset)/60);var offsetHoursString=strings.padLeft(offsetHours.toString(),2,"0");offsetHoursString=0<=offset?"+"+offsetHoursString:"-"+offsetHoursString;var offsetMinutes=Math.abs(offset%60);var offsetMinutesString=strings.padLeft(offsetMinutes.toString(),2,"0");var result;switch(token.symbol){case"O":return result="GMT",result=(result+=0<=offset?"+":"-")+offsetHours.toString(),(4<=token.length||0!==offsetMinutes)&&(result+=":"+offsetMinutesString),4"w"===token.symbol?strings.padLeft(basics.weekNumber(dateTime.year,dateTime.month,dateTime.day).toString(),token.length,"0"):strings.padLeft(basics.weekOfMonth(dateTime.year,dateTime.month,dateTime.day).toString(),token.length,"0"))(dateTime,token);break;default:token_1.TokenType.IDENTITY;tokenResult=token.raw}result+=tokenResult}return result.trim()}},{"./basics":2,"./error":5,"./locale":9,"./strings":13,"./token":16}],7:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.abs=exports.max=exports.min=void 0;var assert_1=require("./assert");exports.min=function(d1,d2){return(0,assert_1.default)(d1,"Argument.D1","first argument is falsy"),(0,assert_1.default)(d2,"Argument.D2","second argument is falsy"),(0,assert_1.default)(d1.kind===d2.kind,"Argument.D2","expected either two datetimes or two durations"),d1.min(d2)},exports.max=function(d1,d2){return(0,assert_1.default)(d1,"Argument.D1","first argument is falsy"),(0,assert_1.default)(d2,"Argument.D2","second argument is falsy"),(0,assert_1.default)(d1.kind===d2.kind,"Argument.D2","expected either two datetimes or two durations"),d1.max(d2)},exports.abs=function(d){return(0,assert_1.default)(d,"Argument.D","first argument is falsy"),d.abs()}},{"./assert":1}],8:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateFunctions=void 0,(DateFunctions=>{DateFunctions[DateFunctions.Get=0]="Get",DateFunctions[DateFunctions.GetUTC=1]="GetUTC"})(exports.DateFunctions={})},{}],9:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_LOCALE=exports.DAY_PERIODS_NARROW=exports.DAY_PERIODS_WIDE=exports.DAY_PERIODS_ABBREVIATED=exports.WEEKDAY_LETTERS=exports.WEEKDAY_TWO_LETTERS=exports.SHORT_WEEKDAY_NAMES=exports.LONG_WEEKDAY_NAMES=exports.STAND_ALONE_MONTH_LETTERS=exports.STAND_ALONE_SHORT_MONTH_NAMES=exports.STAND_ALONE_LONG_MONTH_NAMES=exports.MONTH_LETTERS=exports.SHORT_MONTH_NAMES=exports.LONG_MONTH_NAMES=exports.STAND_ALONE_QUARTER_ABBREVIATIONS=exports.STAND_ALONE_QUARTER_WORD=exports.STAND_ALONE_QUARTER_LETTER=exports.QUARTER_ABBREVIATIONS=exports.QUARTER_WORD=exports.QUARTER_LETTER=exports.ERA_NAMES_ABBREVIATED=exports.ERA_NAMES_WIDE=exports.ERA_NAMES_NARROW=void 0,exports.ERA_NAMES_NARROW=["A","B"],exports.ERA_NAMES_WIDE=["Anno Domini","Before Christ"],exports.ERA_NAMES_ABBREVIATED=["AD","BC"],exports.QUARTER_LETTER="Q",exports.QUARTER_WORD="quarter",exports.QUARTER_ABBREVIATIONS=["1st","2nd","3rd","4th"],exports.STAND_ALONE_QUARTER_LETTER=exports.QUARTER_LETTER,exports.STAND_ALONE_QUARTER_WORD=exports.QUARTER_WORD,exports.STAND_ALONE_QUARTER_ABBREVIATIONS=exports.QUARTER_ABBREVIATIONS.slice(),exports.LONG_MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],exports.SHORT_MONTH_NAMES=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],exports.MONTH_LETTERS=["J","F","M","A","M","J","J","A","S","O","N","D"],exports.STAND_ALONE_LONG_MONTH_NAMES=exports.LONG_MONTH_NAMES.slice(),exports.STAND_ALONE_SHORT_MONTH_NAMES=exports.SHORT_MONTH_NAMES.slice(),exports.STAND_ALONE_MONTH_LETTERS=exports.MONTH_LETTERS.slice(),exports.LONG_WEEKDAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],exports.SHORT_WEEKDAY_NAMES=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],exports.WEEKDAY_TWO_LETTERS=["Su","Mo","Tu","We","Th","Fr","Sa"],exports.WEEKDAY_LETTERS=["S","M","T","W","T","F","S"],exports.DAY_PERIODS_ABBREVIATED={am:"AM",pm:"PM",noon:"noon",midnight:"mid."},exports.DAY_PERIODS_WIDE={am:"AM",pm:"PM",noon:"noon",midnight:"midnight"},exports.DAY_PERIODS_NARROW={am:"A",pm:"P",noon:"noon",midnight:"md"},exports.DEFAULT_LOCALE={eraNarrow:exports.ERA_NAMES_NARROW,eraWide:exports.ERA_NAMES_WIDE,eraAbbreviated:exports.ERA_NAMES_ABBREVIATED,quarterLetter:exports.QUARTER_LETTER,quarterWord:exports.QUARTER_WORD,quarterAbbreviations:exports.QUARTER_ABBREVIATIONS,standAloneQuarterLetter:exports.STAND_ALONE_QUARTER_LETTER,standAloneQuarterWord:exports.STAND_ALONE_QUARTER_WORD,standAloneQuarterAbbreviations:exports.STAND_ALONE_QUARTER_ABBREVIATIONS,longMonthNames:exports.LONG_MONTH_NAMES,shortMonthNames:exports.SHORT_MONTH_NAMES,monthLetters:exports.MONTH_LETTERS,standAloneLongMonthNames:exports.STAND_ALONE_LONG_MONTH_NAMES,standAloneShortMonthNames:exports.STAND_ALONE_SHORT_MONTH_NAMES,standAloneMonthLetters:exports.STAND_ALONE_MONTH_LETTERS,longWeekdayNames:exports.LONG_WEEKDAY_NAMES,shortWeekdayNames:exports.SHORT_WEEKDAY_NAMES,weekdayTwoLetters:exports.WEEKDAY_TWO_LETTERS,weekdayLetters:exports.WEEKDAY_LETTERS,dayPeriodAbbreviated:exports.DAY_PERIODS_ABBREVIATED,dayPeriodWide:exports.DAY_PERIODS_WIDE,dayPeriodNarrow:exports.DAY_PERIODS_NARROW}},{}],10:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.positiveModulo=exports.filterFloat=exports.roundSym=exports.isInt=void 0;var assert_1=require("./assert");exports.isInt=function(n){return!(null===n||!isFinite(n))&&Math.floor(n)===n},exports.roundSym=function(n){return(0,assert_1.default)(Number.isFinite(n),"Argument.N","n must be a finite number but is: ".concat(n)),n<0?-1*Math.round(-1*n):Math.round(n)},exports.filterFloat=function(value){return/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(value)?Number(value):NaN},exports.positiveModulo=function(value,modulo){return(0,assert_1.default)(Number.isFinite(value),"Argument.Value","value should be finite"),(0,assert_1.default)(Number.isFinite(modulo)&&1<=modulo,"Argument.Modulo","modulo should be >= 1"),value<0?(value%modulo+modulo)%modulo:value%modulo}},{"./assert":1}],11:[function(require,module,exports){var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i{var allowed;switch(token.length){case 4:allowed=locale.eraWide;break;case 5:allowed=locale.eraNarrow;break;default:allowed=locale.eraAbbreviated}return token=stripStrings(token,remaining,allowed),[0===allowed.indexOf(token.chosen)?1:-1,token.remaining]})(token,remaining,mergedLocale))[0],remaining=_a[1];break;case token_1.TokenType.QUARTER:var r=((token,remaining,locale)=>{var quarterLetter,quarterWord,quarterAbbreviations,allowed;switch(token.symbol){case"Q":quarterLetter=locale.quarterLetter,quarterWord=locale.quarterWord,quarterAbbreviations=locale.quarterAbbreviations;break;case"q":quarterLetter=locale.standAloneQuarterLetter,quarterWord=locale.standAloneQuarterWord,quarterAbbreviations=locale.standAloneQuarterAbbreviations;break;default:return(0,error_1.throwError)("Argument.FormatString","invalid quarter pattern")}switch(token.length){case 1:case 5:return stripNumber(remaining,1);case 2:return stripNumber(remaining,2);case 3:allowed=[1,2,3,4].map(function(n){return quarterLetter+n.toString(10)});break;case 4:allowed=quarterAbbreviations.map(function(a){return a+" "+quarterWord});break;default:return(0,error_1.throwError)("Argument.FormatString","invalid quarter pattern")}return token=stripStrings(token,remaining,allowed),{n:allowed.indexOf(token.chosen)+1,remaining:token.remaining}})(token,remaining,mergedLocale),quarter=r.n,remaining=r.remaining;break;case token_1.TokenType.WEEKDAY:remaining=((token,remaining,locale)=>{var allowed;switch(token.length){case 1:if("e"===token.symbol)return stripNumber(remaining,1).remaining;allowed=locale.shortWeekdayNames;break;case 2:if("e"===token.symbol)return stripNumber(remaining,2).remaining;allowed=locale.shortWeekdayNames;break;case 3:allowed=locale.shortWeekdayNames;break;case 4:allowed=locale.longWeekdayNames;break;case 5:allowed=locale.weekdayLetters;break;case 6:allowed=locale.weekdayTwoLetters;break;default:return(0,error_1.throwError)("Argument.FormatString","invalid quarter pattern")}return stripStrings(token,remaining,allowed).remaining})(token,remaining,mergedLocale);break;case token_1.TokenType.WEEK:remaining=stripNumber(remaining,2).remaining;break;case token_1.TokenType.DAYPERIOD:remaining=(dpr=((token,remaining,locale)=>{var _a,_d,offsets;if("a"===token.symbol)switch(token.length){case 4:(_a={})[locale.dayPeriodWide.am]="am",_a[locale.dayPeriodWide.pm]="pm",offsets=_a;break;case 5:(_a={})[locale.dayPeriodNarrow.am]="am",_a[locale.dayPeriodNarrow.pm]="pm",offsets=_a;break;default:(_a={})[locale.dayPeriodAbbreviated.am]="am",_a[locale.dayPeriodAbbreviated.pm]="pm",offsets=_a}else switch(token.length){case 4:(_d={})[locale.dayPeriodWide.am]="am",_d[locale.dayPeriodWide.midnight]="midnight",_d[locale.dayPeriodWide.pm]="pm",_d[locale.dayPeriodWide.noon]="noon",offsets=_d;break;case 5:(_d={})[locale.dayPeriodNarrow.am]="am",_d[locale.dayPeriodNarrow.midnight]="midnight",_d[locale.dayPeriodNarrow.pm]="pm",_d[locale.dayPeriodNarrow.noon]="noon",offsets=_d;break;default:(_d={})[locale.dayPeriodAbbreviated.am]="am",_d[locale.dayPeriodAbbreviated.midnight]="midnight",_d[locale.dayPeriodAbbreviated.pm]="pm",_d[locale.dayPeriodAbbreviated.noon]="noon",offsets=_d}for(var token=Object.keys(offsets).sort(function(a,b){return a.lengthb.length?-1:0}),upper=remaining.toUpperCase(),_i=0,sortedKeys_1=token;_iyearCutoff?time.year=1900+pnr.n:time.year=2e3+pnr.n:time.year=pnr.n;break;case token_1.TokenType.MONTH:remaining=(pnr=((token,remaining,locale)=>{var shortMonthNames,longMonthNames,monthLetters,allowed;switch(token.symbol){case"M":shortMonthNames=locale.shortMonthNames,longMonthNames=locale.longMonthNames,monthLetters=locale.monthLetters;break;case"L":shortMonthNames=locale.standAloneShortMonthNames,longMonthNames=locale.standAloneLongMonthNames,monthLetters=locale.standAloneMonthLetters;break;default:return(0,error_1.throwError)("Argument.FormatString","invalid month pattern")}switch(token.length){case 1:case 2:return stripNumber(remaining,2);case 3:allowed=shortMonthNames;break;case 4:allowed=longMonthNames;break;case 5:allowed=monthLetters;break;default:return(0,error_1.throwError)("Argument.FormatString","invalid month pattern")}return token=stripStrings(token,remaining,allowed),{n:allowed.indexOf(token.chosen)+1,remaining:token.remaining}})(token,remaining,mergedLocale)).remaining,time.month=pnr.n;break;case token_1.TokenType.DAY:remaining=(pnr=stripNumber(remaining,2)).remaining,time.day=pnr.n;break;case token_1.TokenType.HOUR:remaining=(pnr=((token,remaining)=>{var result=stripNumber(remaining,2);switch(token.symbol){case"h":12===result.n&&(result.n=0);break;case"H":case"K":break;case"k":--result.n}return result})(token,remaining)).remaining,time.hour=pnr.n;break;case token_1.TokenType.MINUTE:remaining=(pnr=stripNumber(remaining,2)).remaining,time.minute=pnr.n;break;case token_1.TokenType.SECOND:switch(remaining=(pnr=((token,remaining)=>{switch(token.symbol){case"s":return stripNumber(remaining,2);case"S":return stripNumber(remaining,token.length);case"A":return stripNumber(remaining,8);default:return(0,error_1.throwError)("Argument.FormatString","invalid seconds pattern")}})(token,remaining)).remaining,token.symbol){case"s":time.second=pnr.n;break;case"S":time.milli=1e3*parseFloat("0."+Math.floor(pnr.n).toString(10).slice(0,3));break;case"A":time.hour=Math.floor(pnr.n/36e5),time.minute=Math.floor((0,math_1.positiveModulo)(pnr.n/6e4,60)),time.second=Math.floor((0,math_1.positiveModulo)(pnr.n/1e3,60)),time.milli=(0,math_1.positiveModulo)(pnr.n,1e3);break;default:return(0,error_1.throwError)("ParseError","unsupported second format '".concat(token.raw,"'"))}break;case token_1.TokenType.ZONE:remaining=(pzr=((token,s)=>{if("z"===token.symbol||"Z"===token.symbol&&5===token.length||"v"===token.symbol||"V"===token.symbol&&2!==token.length||"x"===token.symbol&&4<=token.length||"X"===token.symbol&&4<=token.length)return(0,error_1.throwError)("NotImplemented","time zone pattern '"+token.raw+"' is not implemented");for(var result={remaining:s},s=!1,zoneString=(("Z"===token.symbol&&4===token.length||"O"===token.symbol)&&result.remaining.toUpperCase().startsWith("GMT")&&(result.remaining=result.remaining.slice(3),s=!0),"");0{for(var remaining=s,eremaining=expected;0b.length?-1:0}),upper=remaining.toUpperCase(),_i=0,sortedKeys_2=sortedKeys;_i{PeriodDst[PeriodDst.RegularIntervals=0]="RegularIntervals",PeriodDst[PeriodDst.RegularLocalTime=1]="RegularLocalTime",PeriodDst[PeriodDst.MAX=2]="MAX"})(PeriodDst||(exports.PeriodDst=PeriodDst={})),exports.periodDstToString=periodDstToString;var Period=(()=>{function Period(a,amountOrInterval,unitOrDst,givenDst){this.kind="Period";var reference,interval,dst=PeriodDst.RegularLocalTime;if((0,datetime_1.isDateTime)(a))reference=a,"number"!=typeof(dst="object"==typeof amountOrInterval?(interval=amountOrInterval,unitOrDst):((0,assert_1.default)("number"==typeof unitOrDst&&0<=unitOrDst&&unitOrDst=opts.reference?_a.subLocal((0,duration_1.days)(7)):_a}},{"./assert":1,"./basics":2,"./datetime":3,"./duration":4,"./error":5,"./timezone":15}],13:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.padRight=exports.padLeft=void 0;var assert_1=require("./assert");exports.padLeft=function(s,width,char){(0,assert_1.default)(Number.isInteger(width)&&0<=width,"Argument.Width","width should be an integer number >= 0 but is: ".concat(width));for(var padding="",i=0;i= 0 but is: ".concat(width));for(var padding="",i=0;i{function RealTimeSource(){}return RealTimeSource.prototype.now=function(){return new Date},RealTimeSource})();exports.RealTimeSource=RealTimeSource},{}],15:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.isTimeZone=exports.TimeZone=exports.TimeZoneKind=exports.zone=exports.utc=exports.local=void 0;var TimeZoneKind,assert_1=require("./assert"),basics_1=require("./basics"),error_1=require("./error"),strings=require("./strings"),tz_database_1=require("./tz-database");exports.local=function(){return TimeZone.local()},exports.utc=function(){return TimeZone.utc()},exports.zone=function(a,dst){return TimeZone.zone(a,dst)},(TimeZoneKind=>{TimeZoneKind[TimeZoneKind.Local=0]="Local",TimeZoneKind[TimeZoneKind.Offset=1]="Offset",TimeZoneKind[TimeZoneKind.Proper=2]="Proper"})(TimeZoneKind||(exports.TimeZoneKind=TimeZoneKind={}));var TimeZone=(()=>{function TimeZone(name,dst){void 0===dst&&(dst=!0),this.classKind="TimeZone",this._name=name,this._dst=dst,"localtime"===name?this._kind=TimeZoneKind.Local:"+"===name.charAt(0)||"-"===name.charAt(0)||name.charAt(0).match(/\d/)||"Z"===name?(this._kind=TimeZoneKind.Offset,this._offset=TimeZone.stringToOffset(name)):(this._kind=TimeZoneKind.Proper,(0,assert_1.default)(tz_database_1.TzDatabase.instance().exists(name),"NotFound.Zone","non-existing time zone name '".concat(name,"'")))}return TimeZone.local=function(){return TimeZone._findOrCreate("localtime",!0)},TimeZone.utc=function(){return TimeZone._findOrCreate("UTC",!0)},TimeZone.zone=function(a,dst){void 0===dst&&(dst=!0);var name="";switch(typeof a){case"string":var s=a;0<=s.indexOf("without DST")&&(dst=!1,s=s.slice(0,s.indexOf("without DST")-1)),name=TimeZone._normalizeString(s);break;case"number":s=a;(0,assert_1.default)(-1440{TokenType[TokenType.IDENTITY=0]="IDENTITY",TokenType[TokenType.ERA=1]="ERA",TokenType[TokenType.YEAR=2]="YEAR",TokenType[TokenType.QUARTER=3]="QUARTER",TokenType[TokenType.MONTH=4]="MONTH",TokenType[TokenType.WEEK=5]="WEEK",TokenType[TokenType.DAY=6]="DAY",TokenType[TokenType.WEEKDAY=7]="WEEKDAY",TokenType[TokenType.DAYPERIOD=8]="DAYPERIOD",TokenType[TokenType.HOUR=9]="HOUR",TokenType[TokenType.MINUTE=10]="MINUTE",TokenType[TokenType.SECOND=11]="SECOND",TokenType[TokenType.ZONE=12]="ZONE"})(TokenType||(exports.TokenType=TokenType={})),exports.tokenize=function(formatString){if(!formatString)return[];for(var result=[],appendToken=function(tokenString,raw){for(;""!==tokenString;)if(raw||!SYMBOL_MAPPING.hasOwnProperty(tokenString[0])){var token={length:tokenString.length,raw:tokenString,symbol:tokenString[0],type:TokenType.IDENTITY};result.push(token),tokenString=""}else{var info=SYMBOL_MAPPING[tokenString[0]],length_1=void 0;if(void 0!==info.maxLength||Array.isArray(info.lengths)&&0!==info.lengths.length){if(void 0!==info.maxLength)length_1=Math.min(tokenString.length,info.maxLength);else if(Array.isArray(info.lengths)&&0{ToType[ToType.Year=0]="Year",ToType[ToType.Max=1]="Max"})(ToType||(exports.ToType=ToType={})),(OnType=>{OnType[OnType.DayNum=0]="DayNum",OnType[OnType.LastX=1]="LastX",OnType[OnType.GreqX=2]="GreqX",OnType[OnType.LeqX=3]="LeqX"})(OnType||(exports.OnType=OnType={})),(AtType=>{AtType[AtType.Standard=0]="Standard",AtType[AtType.Wall=1]="Wall",AtType[AtType.Utc=2]="Utc"})(AtType||(exports.AtType=AtType={})),(()=>{function RuleInfo(from,toType,toYear,type,inMonth,onType,onDay,onWeekDay,atHour,atMinute,atSecond,atType,save,letter){this.from=from,this.toType=toType,this.toYear=toYear,this.type=type,this.inMonth=inMonth,this.onType=onType,this.onDay=onDay,this.onWeekDay=onWeekDay,this.atHour=atHour,this.atMinute=atMinute,this.atSecond=atSecond,this.atType=atType,this.save=save,this.letter=letter,this.save&&(this.save=this.save.convert(basics_1.TimeUnit.Hour))}return RuleInfo.prototype.applicable=function(year){if(yearother.from)&&(this.inMonthother.inMonth)&&this.effectiveDate(this.from){RuleType[RuleType.None=0]="None",RuleType[RuleType.Offset=1]="Offset",RuleType[RuleType.RuleName=2]="RuleName"})(RuleType||(exports.RuleType=RuleType={})),function(gmtoff,ruleType,ruleOffset,ruleName,format,until){this.gmtoff=gmtoff,this.ruleType=ruleType,this.ruleOffset=ruleOffset,this.ruleName=ruleName,this.format=format,this.until=until,this.ruleOffset&&(this.ruleOffset=this.ruleOffset.convert(basics.TimeUnit.Hour))});function isValidOffsetString(s){return/^(\-|\+)?([0-9]+((\:[0-9]+)?(\:[0-9]+(\.[0-9]+)?)?))$/.test(s)}exports.ZoneInfo=ZoneInfo,(TzMonthNames=>{TzMonthNames[TzMonthNames.Jan=1]="Jan",TzMonthNames[TzMonthNames.Feb=2]="Feb",TzMonthNames[TzMonthNames.Mar=3]="Mar",TzMonthNames[TzMonthNames.Apr=4]="Apr",TzMonthNames[TzMonthNames.May=5]="May",TzMonthNames[TzMonthNames.Jun=6]="Jun",TzMonthNames[TzMonthNames.Jul=7]="Jul",TzMonthNames[TzMonthNames.Aug=8]="Aug",TzMonthNames[TzMonthNames.Sep=9]="Sep",TzMonthNames[TzMonthNames.Oct=10]="Oct",TzMonthNames[TzMonthNames.Nov=11]="Nov",TzMonthNames[TzMonthNames.Dec=12]="Dec"})(TzMonthNames=TzMonthNames||{}),(TzDayNames=>{TzDayNames[TzDayNames.Sun=0]="Sun",TzDayNames[TzDayNames.Mon=1]="Mon",TzDayNames[TzDayNames.Tue=2]="Tue",TzDayNames[TzDayNames.Wed=3]="Wed",TzDayNames[TzDayNames.Thu=4]="Thu",TzDayNames[TzDayNames.Fri=5]="Fri",TzDayNames[TzDayNames.Sat=6]="Sat"})(TzDayNames=TzDayNames||{}),exports.isValidOffsetString=isValidOffsetString;exports.Transition=function(at,offset,letter){this.at=at,this.offset=offset,this.letter=letter,this.offset&&(this.offset=this.offset.convert(basics.TimeUnit.Hour))},(NormalizeOption=>{NormalizeOption[NormalizeOption.Up=0]="Up",NormalizeOption[NormalizeOption.Down=1]="Down"})(NormalizeOption||(exports.NormalizeOption=NormalizeOption={}));var NormalizeOption,TzDatabase=(()=>{function TzDatabase(data){var _this=this;this._zoneInfoCache={},this._ruleInfoCache={},this._zoneTransitionsCache=new Map,this._ruleTransitionsCache=new Map,(0,assert_1.default)(!TzDatabase._instance,"AlreadyCreated","You should not create an instance of the TzDatabase class yourself. Use TzDatabase.instance()"),(0,assert_1.default)(0{var zoneName,ruleName,result={};for(zoneName in(0,assert_1.default)("object"==typeof data,"InvalidTimeZoneData","time zone data should be an object"),(0,assert_1.default)(data.hasOwnProperty("rules"),"InvalidTimeZoneData","time zone data should be an object with a 'rules' property"),(0,assert_1.default)(data.hasOwnProperty("zones"),"InvalidTimeZoneData","time zone data should be an object with a 'zones' property"),data.zones)if(data.zones.hasOwnProperty(zoneName)){var zoneArr=data.zones[zoneName];if("string"==typeof zoneArr)(0,assert_1.default)(data.zones.hasOwnProperty(zoneArr),"InvalidTimeZoneData",'Entry for zone "'.concat(zoneName,'" links to "').concat(zoneArr,"\" but that doesn't exist"));else{if(!Array.isArray(zoneArr))return(0,error_1.throwError)("InvalidTimeZoneData",'Entry for zone "'.concat(zoneName,'" is neither a string nor an array'));for(var i=0;i=")&&-1===rule[4].indexOf("<=")&&isNaN(parseInt(rule[4],10)))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][4] is not a known type of expression");if(!Array.isArray(rule[5]))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5] is not an array");if(4!==rule[5].length)return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5] is not of length 4");if(isNaN(parseInt(rule[5][0],10)))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5][0] is not a number");if(isNaN(parseInt(rule[5][1],10)))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5][1] is not a number");if(isNaN(parseInt(rule[5][2],10)))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5][2] is not a number");if(""!==rule[5][3]&&"s"!==rule[5][3]&&"w"!==rule[5][3]&&"g"!==rule[5][3]&&"u"!==rule[5][3]&&"z"!==rule[5][3]&&null!==rule[5][3])return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][5][3] is not empty, g, z, s, w, u or null");var save=parseInt(rule[6],10);if(isNaN(save))return(0,error_1.throwError)("InvalidTimeZoneData","Rule "+ruleName+"["+i.toString(10)+"][6] does not contain a valid number");0!==save&&((void 0===result.maxDstSave||result.maxDstSave{try{var d=require("tzdata");data_1.push(d)}catch(e){["tzdata-africa","tzdata-antarctica","tzdata-asia","tzdata-australasia","tzdata-backward","tzdata-backward-utc","tzdata-etcetera","tzdata-europe","tzdata-northamerica","tzdata-pacificnew","tzdata-southamerica","tzdata-systemv"].forEach(function(moduleName){try{var d=require(moduleName);data_1.push(d)}catch(e){}})}})(require),TzDatabase._instance=new TzDatabase(data_1)}},TzDatabase.instance=function(){return TzDatabase._instance||TzDatabase.init(),TzDatabase._instance},TzDatabase.prototype.zoneNames=function(){return this._zoneNames||(this._zoneNames=Object.keys(this._data.zones),this._zoneNames.sort()),this._zoneNames},TzDatabase.prototype.exists=function(zoneName){return this._data.zones.hasOwnProperty(zoneName)},TzDatabase.prototype.minDstSave=function(zoneName){try{if(zoneName){for(var zoneInfos=this.getZoneInfos(zoneName),result=void 0,ruleNames=[],_i=0,zoneInfos_1=zoneInfos;_iutcTime)return iterator.transition.atUtc.unixMillis;for(;iterator;)if((iterator=zone.findNext(iterator))&&iterator.transition.atUtc>utcTime)return iterator.transition.atUtc.unixMillis},TzDatabase.prototype.zoneIsUtc=function(zoneName){for(var actualZoneName=zoneName,zoneEntries=this._data.zones[zoneName];"string"==typeof zoneEntries;){if(!this._data.zones.hasOwnProperty(zoneEntries))throw new Error('Zone "'+zoneEntries+'" not found (referred to in link from "'+zoneName+'" via "'+actualZoneName+'"');actualZoneName=zoneEntries,zoneEntries=this._data.zones[actualZoneName]}return"Etc/UTC"===actualZoneName||"Etc/GMT"===actualZoneName||"Etc/UCT"===actualZoneName},TzDatabase.prototype.normalizeLocal=function(zoneName,a,opt){if(void 0===opt&&(opt=NormalizeOption.Up),this.hasDst(zoneName))for(var localTime="number"==typeof a?new basics_1.TimeStruct(a):a,zoneName=this._getZoneTransitions(zoneName).transitionsInYears(localTime.components.year-1,localTime.components.year+1),prev=duration_1.Duration.hours(0),_i=0,transitions_1=zoneName;_i=localBefore&&localTime.unixMillisunixMillis)return zoneInfo.gmtoff.clone()}return(0,error_1.throwError)("InvalidTimeZoneData","No zone info found")},TzDatabase.prototype.totalOffsetLocal=function(zoneName,localTime){for(var prev,prevPrev,prevPrevOffset,diff,localTime="number"==typeof localTime?new basics_1.TimeStruct(localTime):localTime,normalizedTm=this.normalizeLocal(zoneName,localTime),localTime=this._getZoneTransitions(zoneName),_i=0,transitions_2=localTime.transitionsInYears(normalizedTm.components.year-1,normalizedTm.components.year+2);_inormalizedTm.unixMillis)break;prevPrev=prev,prev=transition}return prev?(zoneName=prev.newState.dstOffset.add(prev.newState.standardOffset),prevPrevOffset=prevPrev?prevPrev.newState.dstOffset.add(prevPrev.newState.standardOffset):void 0,(prevPrev&&void 0!==prevPrevOffset&&prevPrevOffset.greaterThan(zoneName)&&(diff=prevPrevOffset.sub(zoneName),normalizedTm.unixMillis>=prev.atUtc.unixMillis+zoneName.milliseconds())&&normalizedTm.unixMillis=fromYear&&iterator.transition.at.year<=toYear&&result.push({at:ruleTransitionUtc(iterator.transition,standardOffset,prevDst).unixMillis,letter:iterator.transition.newState.letter||"",offset:iterator.transition.newState.dstOffset}),prevDst=iterator.transition.newState.dstOffset,iterator=rules.findNext(iterator);return result.sort(function(a,b){return a.at-b.at}),result},TzDatabase.prototype.getTransitionsTotalOffsets=function(zoneName,fromYear,toYear){(0,assert_1.default)(fromYear<=toYear,"Argument.FromYear","fromYear must be <= toYear");for(var zone=this._getZoneTransitions(zoneName),result=[],zoneName=zone.stateAt(new basics_1.TimeStruct({year:fromYear,month:1,day:1})),iterator=(result.push({at:new basics_1.TimeStruct({year:fromYear}).unixMillis,letter:zoneName.letter,offset:zoneName.dstOffset.add(zoneName.standardOffset)}),zone.findFirst());iterator&&iterator.transition.atUtc.year<=toYear;)iterator.transition.atUtc.year>=fromYear&&result.push({at:iterator.transition.atUtc.unixMillis,letter:iterator.transition.newState.letter||"",offset:iterator.transition.newState.dstOffset.add(iterator.transition.newState.standardOffset)}),iterator=zone.findNext(iterator);return result.sort(function(a,b){return a.at-b.at}),result},TzDatabase.prototype.getZoneInfo=function(zoneName,utcTime){for(var unixMillis="number"==typeof utcTime?utcTime:utcTime.unixMillis,_i=0,zoneInfos_4=this.getZoneInfos(zoneName);_iunixMillis)return zoneInfo}return(0,error_1.throwError)("NotFound.Zone","\"no zone info found for zone '".concat(zoneName,"'"))},TzDatabase.prototype.getZoneInfos=function(zoneName){if((0,assert_1.default)(this._data.zones.hasOwnProperty(zoneName),"NotFound.Zone","zone not found: '".concat(zoneName,"'")),this._zoneInfoCache.hasOwnProperty(zoneName))return this._zoneInfoCache[zoneName];for(var result=[],actualZoneName=zoneName,zoneEntries=this._data.zones[zoneName];"string"==typeof zoneEntries;){if(!this._data.zones.hasOwnProperty(zoneEntries))return(0,error_1.throwError)("NotFound.Zone",'Zone "'+zoneEntries+'" not found (referred to in link from "'+zoneName+'" via "'+actualZoneName+'"');actualZoneName=zoneEntries,zoneEntries=this._data.zones[actualZoneName]}for(var _i=0,zoneEntries_1=zoneEntries;_i{for(var i=1;i<=12;++i)if(TzMonthNames[i]===name)return i;return(0,error_1.throwError)("InvalidTimeZoneData","Invalid month name '".concat(name,"'"))})(rule[3]);result.push(new RuleInfo(fromYear,toType,toYear,rule[2],monthNumber,onType,onDay,onWeekDay,math.positiveModulo(parseInt(rule[5][0],10),24),math.positiveModulo(parseInt(rule[5][1],10),60),math.positiveModulo(parseInt(rule[5][2],10),60),this.parseAtType(rule[5][3]),duration_1.Duration.minutes(parseInt(rule[6],10)),"-"===rule[7]?"":rule[7]))}return result.sort(function(a,b){return a.effectiveEqual(b)?0:a.effectiveLess(b)?-1:1}),this._ruleInfoCache[ruleName]=result}catch(e){throw e=(0,error_1.errorIs)(e,["Argument.To","Argument.N","Argument.Value","Argument.Amount"])?(0,error_1.error)("InvalidTimeZoneData",e.message):e}},TzDatabase.prototype.parseRuleType=function(rule){return"-"===rule?RuleType.None:isValidOffsetString(rule)?RuleType.Offset:RuleType.RuleName},TzDatabase.prototype.parseToType=function(to){return"max"===to?ToType.Max:"only"!==to&&isNaN(parseInt(to,10))?(0,error_1.throwError)("Argument.To","TO column incorrect: ".concat(to)):ToType.Year},TzDatabase.prototype.parseOnType=function(on){return 4=")?OnType.GreqX:OnType.DayNum},TzDatabase.prototype.parseOnDay=function(on,onType){switch(onType){case OnType.DayNum:return parseInt(on,10);case OnType.LeqX:return parseInt(on.substr(on.indexOf("<=")+2),10);case OnType.GreqX:return parseInt(on.substr(on.indexOf(">=")+2),10);default:return 0}},TzDatabase.prototype.parseOnWeekDay=function(on){for(var i=0;i<7;i++)if(-1!==on.indexOf(TzDayNames[i]))return i;return basics_1.WeekDay.Sunday},TzDatabase.prototype.parseAtType=function(at){switch(at){case"s":return AtType.Standard;case"u":case"g":case"z":return AtType.Utc;default:return AtType.Wall}},TzDatabase.prototype._getZoneTransitions=function(zoneName){var result=this._zoneTransitionsCache.get(zoneName);return result||(result=new CachedZoneTransitions(zoneName,this.getZoneInfos(zoneName),this._getRuleTransitionsForZone(zoneName)),this._zoneTransitionsCache.set(zoneName,result)),result},TzDatabase.prototype._getRuleTransitions=function(ruleName){var result=this._ruleTransitionsCache.get(ruleName);return result||(result=new CachedRuleTransitions(this.getRuleInfos(ruleName)),this._ruleTransitionsCache.set(ruleName,result)),result},TzDatabase.prototype._getRuleTransitionsForZone=function(zoneName){for(var result=new Map,_i=0,zoneInfos_5=this.getZoneInfos(zoneName);_i{function CachedRuleTransitions(ruleInfos){for(var maxYear,_i=0,ruleInfos_1=ruleInfos;_imaxYear?ruleInfo.toYear:maxYear)||ruleInfo.from>maxYear)&&(maxYear=ruleInfo.from);this._transitions=[];for(var _a=0,ruleInfos_2=ruleInfos;_ab.at?1:0}),this._finalRulesByFromEffective=ruleInfos.filter(function(info){return info.toType===ToType.Max}),this._finalRulesByEffective=__spreadArray([],this._finalRulesByFromEffective,!0),this._finalRulesByFromEffective=this._finalRulesByFromEffective.sort(function(a,b){return a.fromprev.transition.at&&(!foundEffective||effective{function CachedZoneTransitions(zoneName,zoneInfos,rules){(0,assert_1.default)(0iterator.transition.atUtc&&(!found||found.atUtc>ruleInfo.atUtc)&&(found=ruleInfo)}return found?{transition:found,index:0,final:!0}:void 0},CachedZoneTransitions.prototype.stateAt=function(utc){for(var prevState=this._initialState,iterator=this.findFirst();iterator&&iterator.transition.atUtc<=utc;)prevState=iterator.transition.newState,iterator=this.findNext(iterator);return prevState},CachedZoneTransitions.prototype.transitionsInYears=function(start,end){var result=[];if(0===this._transitions.length||this._transitions[this._transitions.length-1].atUtc.year=start&&result.push(tr.transition)}}else for(var iterator=this.findFirst();iterator&&iterator.transition.atUtc.year=start&&result.push(iterator.transition),iterator=this.findNext(iterator);return result},CachedZoneTransitions.prototype._calcInitialState=function(zoneName,infos,rules){if(0===infos.length)return{abbreviation:"",letter:"",dstOffset:(0,duration_1.hours)(0),standardOffset:(0,duration_1.hours)(0)};var info=infos[0];switch(info.ruleType){case RuleType.None:return{abbreviation:zoneAbbreviation(info.format,!1,void 0),letter:"",dstOffset:(0,duration_1.hours)(0),standardOffset:info.gmtoff};case RuleType.Offset:return{abbreviation:zoneAbbreviation(info.format,info.ruleOffset.nonZero(),void 0),letter:"",dstOffset:info.ruleOffset,standardOffset:info.gmtoff};case RuleType.RuleName:for(var rule=rules.get(info.ruleName),iterator=(rule||(0,error_1.throwError)("InvalidTimeZoneData","zone '".concat(zoneName,"' refers to non-existing rule '").concat(info.ruleName,"'")),rule.findFirst());iterator&&iterator.transition.newState.dstOffset.nonZero();)iterator=rule.findNext(iterator);var _a=null!=(_a=null==iterator?void 0:iterator.transition.newState.letter)?_a:"";return{abbreviation:zoneAbbreviation(info.format,!1,_a),dstOffset:(0,duration_1.hours)(0),letter:_a,standardOffset:info.gmtoff};default:(0,assert_1.default)(!1,"timezonecomplete.Assertion","Unknown RuleType")}},CachedZoneTransitions.prototype._calcTransitions=function(zoneName,initialState,zoneInfos,rules){if(0===zoneInfos.length)return[[],[]];for(var prevUntil,transitions=[],prevState=initialState,_i=0,zoneInfos_6=zoneInfos;_i