Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

temporal-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporal-polyfill - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

src/argParse/totalOptions.ts

2

dist/global.js

@@ -1,2 +0,2 @@

function n(n,e,t){const r=function(n,e,t){return(o,r)=>{if(void 0===o){const e=r??t;if(void 0===e)throw new RangeError(`Must specify a ${n}`);return e}if(void 0===e[o])throw new RangeError(`Invalid ${n}: ${o}`);return e[o]}}(n,e,t);return(e,t)=>{const i=o(e);return r(i[n],t)}}function e(n,e,t,o){if(void 0===n)return e;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,e),t);if(r!==n&&o===c)throw new RangeError("Invalid overflowed value "+n);return r}function t(n,e){const t={};let o=0;for(const r in e)void 0!==n[r]&&(t[r]=e[r](n[r]),o++);if(!o)throw new TypeError("Invalid object, no keys");return t}function o(n){if(void 0===n)return{};if(!i(n))throw TypeError("options must be an object or undefined");return n}var r=/object|function/;function i(n){return null!==n&&r.test(typeof n)}var s=["calendar","timeZone"];function a(n,e){for(const e of s)if(void 0!==n[e])throw new TypeError(`Disallowed field ${e}`);return t(n,e)}var c=1,u=n("overflow",{constrain:0,reject:1},0);function d(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function h(n,e){Object.defineProperties(n.prototype,l(e,(n=>({get:n}))))}function l(n,e){const t={};for(const o in n)t[o]=e(n[o],o);return t}function f(n,e){const t={};return n.forEach(((n,o)=>{t[n]=e(n,o)})),t}var m=Symbol();function g(n,e,...t){return e instanceof n?e:n.from(e,...t)}var y=class{toJSON(){return this.toString()}},p=class extends y{valueOf(){throw new Error("Cannot convert object using valueOf")}},[w,v]=d(),M=class extends p{constructor(n){super(),v(this,Object.freeze(n))}getISOFields(){return w(this)}},I=1000n,S=1000000n,b=1000000000n,F=60000000000n,D=3600000000000n,T=86400000000000n,O=[1,1e3,1e6,1e9,6e10,36e11,864e11],N=[9,6,3];function Y(n){return n<=6}function E(n){return n>=6}var Z=n("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor}),C=["nanosecond","microsecond","millisecond","second","minute","hour"],P=[...C,"day","week","month","year"],U=P.map((n=>n+"s")),B=f(P,((n,e)=>e)),R=f(U,((n,e)=>e));function k(n,e,t,o){let r;if(void 0===n){if(void 0===e)throw new RangeError("Unit is required");r=e}else if(r=B[n]??R[n],void 0===r||r<t||r>o)throw new RangeError("Invalid unit "+n);return r}function x(n,e,t,r,s,a){if(void 0===e&&!i(n))throw new TypeError("Need rounding options");const c=o(n),u=c.roundingIncrement??1,d=k(c.smallestUnit,e,t,r);if(!s&&a){if(d<6&&864e11%u*O[d])throw new RangeError("Increment must evenly divide into 24 hours")}else{if(d<6?O[d+1]%u:!s&&1!==u)throw new RangeError("roundingIncrement does not divide evenly into next highest unit");if(d<6&&u*O[d]>=O[d+1])throw new RangeError("roundingIncrement must be less than next highest unit")}return{smallestUnit:d,roundingMode:Z(n,s?Math.trunc:Math.round),roundingIncrement:u}}function j(n,e,t,r,i,s,a){const c=x(n,t,r,i,!a,s);e=Math.max(e,c.smallestUnit);let u=o(n).largestUnit;"auto"===u&&(u=void 0);const d=k(u,e,r,i);if(c.smallestUnit>d)throw new RangeError("Bad smallestUnit/largestUnit");return{largestUnit:d,...c}}function q(n,e){return n<e?-1:n>e?1:0}function L(n){return q(n,0)}function H(n,e,t){const o=BigInt(e),r=n/o*o,i=Number(n-r);return r+BigInt(t(i/e))*o}function $(n,e){return(n%e+e)%e}function z(n){return K(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function A(n){return Math.floor(W(n)/1e3)}function W(n){return G(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond)}function K(n,e,t,o,r,i,s,a,c){return BigInt(G(n,e,t,o,r,i,s))*S+BigInt(a??0)*I+BigInt(c??0)}function G(n,e,t,o,r,i,s){const a=n??1970,c=e??1,u=t??1,d=L(a);let h,l,f=0;const m=a>=0&&a<1e3,g=m?a+1200:a;for(;f<31;f++){h=u-d*f;const n=Date.UTC(g,c-1,h,o??0,r??0,i??0,s??0);if(!on(n)){l=n+d*f*864e5;break}}return(void 0===l||h<1||h>fn.daysInMonth(a,c))&&rn(),m&&(l=new Date(l).setUTCFullYear(a)),l}function J(n){let e=n/S,t=Number(n-e*S);t<0&&(t+=1e6,e-=1n);const o=Math.floor(t/1e3);return t-=1e3*o,{...Q(Number(e)),isoMicrosecond:o,isoNanosecond:t}}function Q(n){const[e,t]=tn(n);return{isoYear:e.getUTCFullYear(),isoMonth:e.getUTCMonth()+1,isoDay:e.getUTCDate()+t,isoHour:e.getUTCHours(),isoMinute:e.getUTCMinutes(),isoSecond:e.getUTCSeconds(),isoMillisecond:e.getUTCMilliseconds()}}function V(n){return tn(1e3*n)[0].getUTCFullYear()}function X(n){return Math.floor(G(n)/1e3)}function _(n,e){return Math.round((e-n)/864e5)}function nn(n,e){return n+864e5*e}function en(n,e,t){const[o,r]=tn(G(n,e,t));return $(o.getUTCDay()+r,7)||7}function tn(n){const e=L(n);let t,o=0;for(;o<31;o++){const r=new Date(n-e*o*864e5);if(!on(r)){t=r;break}}return void 0===t&&rn(),[t,e*o]}function on(n){return isNaN(n.valueOf())}function rn(){throw new RangeError("Date outside of supported range")}function sn(n,e){return String(n).padStart(e,"0")}function an(n){return n<0?"-":"+"}var cn={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}},un=class{constructor(n){this.id=n}monthCode(n,e){return"M"+sn(n,2)}convertMonthCode(n,e){const t=/L$/.test(n),o=parseInt(n.substr(1));if(t)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}};function dn(n,e,t,o){let r=cn[hn(n)]?.[t];if(void 0===r){if(!o)throw new Error("Unkown era "+t);r=0}return(r+e)*(L(r)||1)}function hn(n){return n.split("-")[0]}var ln=class extends un{computeFields(n){const e=Q(n);return{era:void 0,eraYear:void 0,year:e.isoYear,month:e.isoMonth,day:e.isoDay}}epochMilliseconds(n,e,t){return G(n,e,t)}daysInMonth(n,e){return 2===e?this.inLeapYear(n)?29:28:4===e||6===e||9===e||11===e?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return 1972}normalizeISOYearForMonthDay(){return 1972}},fn=new ln("iso8601"),mn=class extends ln{computeFields(n){const e=super.computeFields(n),{year:t}=e;return{...e,era:t<1?"bce":"ce",eraYear:t<1?-(t-1):t}}},gn=n("calendarName",{auto:0,never:1,always:2},0),yn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},pn={...yn,day:Number},wn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},vn={...pn,...wn},Mn={...vn,offset:String},In=f(U,(()=>Number)),Sn=n("offset",{prefer:0,use:1,ignore:2,reject:3});function bn(n,t=4){const r=o(n),i=r.smallestUnit,s=r.fractionalSecondDigits;let a,u=0,d=1;return void 0!==i?(u=k(i,void 0,0,t),d=O[u],a=N[u]||0):void 0!==s&&"auto"!==s&&(a=e(s,0,9,c),d=Math.pow(10,9-a)),{smallestUnit:u,fractionalSecondDigits:a,roundingMode:Z(n,Math.trunc),roundingIncrement:d}}var Fn=n("timeZoneName",{auto:0,never:1},0);function Dn(n){h(n,{epochMicroseconds(){return this.epochNanoseconds/I},epochMilliseconds(){return Number(this.epochNanoseconds/S)},epochSeconds(){return Number(this.epochNanoseconds/b)}})}var Tn,On={calendar:"calendar"};for(const n of P)On[n]="iso"+((Tn=n).charAt(0).toUpperCase()+Tn.slice(1));function Nn(n,e=[]){h(n,f(e.concat("calendar"),(n=>function(){return this.getISOFields()[On[n]]})))}var Yn=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],En=[...Yn,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function Zn(n,e){h(n,f(e,(n=>function(){const e=this.calendar[n](this);return Object.defineProperty(this,n,{value:e}),e})))}var Cn="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Pn="([+-])"+Cn,Un="(Z|"+Pn+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Bn=Hn("([+-]\\d{6}|\\d{4})-?(\\d{2})"+Un),Rn=Hn("(--)?(\\d{2})-?(\\d{2})"+Un),kn=Hn("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Un),xn=Hn(Cn+Un),jn=Hn(Pn),qn=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,Ln=/\u2212/g;function Hn(n){return new RegExp(`^${n}$`,"i")}function $n(n){const e=Jn(n);if(!e)throw se("dateTime",n);return e}function zn(n){const e=Qn(n);if(!e)throw se("dateTime",n);return e}function An(n){const e=function(n){const e=Bn.exec(ie(n));if(e)return{calendar:(t=e.slice(1))[14],isoYear:oe(t[0]),isoMonth:oe(t[1]),isoDay:1};var t}(n)||Qn(n);if(!e)throw se("yearMonth",n);return e}function Wn(n){const e=function(n){const e=Rn.exec(ie(n));if(e)return{calendar:(t=e.slice(1))[15],isoYear:1972,isoMonth:oe(t[1]),isoDay:oe(t[2])};var t}(n)||Qn(n);if(!e)throw se("monthDay",n);return e}function Kn(n){const e=Vn(n);if(void 0===e)throw se("timeZone",n);return e}function Gn(n){const e=function(n){const e=xn.exec(ie(n));if(e)return _n(e.slice(1))}(n)||Qn(n);if(void 0===e)throw se("time",n);return e}function Jn(n){const e=kn.exec(ie(n));if(e)return function(n){const e=n[11];let t,o=!1;e&&(o="Z"===e.toUpperCase(),t=o?0:ne(n.slice(12)));return{...Xn(n),timeZone:n[21],offset:t,Z:o}}(e.slice(1))}function Qn(n){const e=kn.exec(ie(n));if(e)return Xn(e.slice(1))}function Vn(n){const e=jn.exec(ie(n));if(e)return ne(e.slice(1))}function Xn(n){return{calendar:n[23],isoYear:oe(n[0]),isoMonth:oe(n[1]),isoDay:oe(n[2]),..._n(n.slice(4))}}function _n(n){const e=te(n[4]);return{...pt(vt(BigInt(ee(n[6]||"")),2)),isoHour:te(n[0]),isoMinute:te(n[2]),isoSecond:60===e?59:e}}function ne(n){return("+"===n[0]?1:-1)*function(n){return 36e11*te(n[0])+6e10*te(n[2])+1e9*te(n[4])+ee(n[6]||"")}(n.slice(1))}function ee(n){return parseInt(n.padEnd(9,"0"))}function te(n){return parseInt(n||"0")}function oe(n){return parseInt(n||"1")}function re(n){return void 0===n?void 0:parseInt(n)}function ie(n){return n.replace(Ln,"-")}function se(n,e){throw new RangeError(`Cannot parse ${n} '${e}'`)}function ae(n,e,t,o){const r=U[e],{sign:i}=n,s={};for(let t=9;t>=e;t--){const e=U[t];s[e]=n[e]}const a={[r]:i},c=t.add(s),u=c.add(a),d=ce(c),h=ce(u),l=ce(o),f=Number(l-d)/Number(h-d)*i;return s[r]+=f,s}function ce(n){const{epochNanoseconds:e}=n;return void 0!==e?e:z(n.getISOFields())}var ue=n("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0),de=n("offset",{auto:0,never:1},0);function he(n){return{...n,calendar:void 0===n.calendar?Zo():new Calendar(n.calendar)}}function le(n){return{...he(n),timeZone:new TimeZone(n.timeZone)}}var fe=class{constructor(n){this.id=n}},me=class extends fe{constructor(n,e){super(n),this.offsetSecs=e}getPossibleOffsets(){return[this.offsetSecs]}getOffset(){return this.offsetSecs}getTransition(){}};function ge(n,e){const t={},o=n.formatToParts(e);for(const n of o)t[n.type]=n.value;return t}var ye={bc:"bce",ad:"ce"};function pe(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),ye[n]||n}var we=Intl.DateTimeFormat;function ve(n){return[].concat(n||[])}var Me={"Pacific/Apia":{2011:[[1301752800,-36e3,-39600],[1316872800,-39600,-36e3],[1325239200,-36e3,50400]]}},Ie=[182,91,273],Se=class extends fe{constructor(n){const e=new we("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(e.resolvedOptions().timeZone),this.format=e,this.yearEndOffsets={},this.transitionsInYear=Me[n]||{}}getPossibleOffsets(n){const e=[this.getTransition(n,-1),this.getTransition(n-1,1)].filter(Boolean);let t;for(const o of e){const[e,r,i]=o,s=n-r,a=n-i;if(e>s&&e>a)return[r];if(!(e<=s&&e<=a))return[r,i];t=i}return void 0!==t?[t]:[this.getYearEndOffset(V(n))]}getOffset(n){const e=ge(this.format,1e3*n);let t=parseInt(e.year);"bce"===pe(e.era)&&(t=-(t-1));const o=G(t,parseInt(e.month),parseInt(e.day),parseInt(e.hour),parseInt(e.minute),parseInt(e.second));return Math.floor(o/1e3)-n}getTransition(n,e){const t=V(n);for(let o=0;o<100;o++){const r=t+o*e,i=this.getTransitionsInYear(r),s=i.length,a=e<0?s-1:0;for(let t=0;t<s;t++){const o=i[a+t*e];if(q(o[0],n)===e)return o}}}getYearEndOffset(n){const{yearEndOffsets:e}=this;return e[n]||(e[n]=this.getOffset(X(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:e}=this;return e[n]||(e[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const e=this.getYearEndOffset(n-1),t=this.getYearEndOffset(n),o=X(n)-1,r=X(n+1)-1;if(e!==t)return[this.searchTransition(o,r,e,t)];const i=this.searchIsland(e,o);return void 0!==i?[this.searchTransition(o,i[0],e,i[1]),this.searchTransition(i[0],r,i[1],t)]:[]}searchTransition(n,e,t,o){for(;e-n>1;){const o=Math.floor(n+(e-n)/2);this.getOffset(o)===t?n=o:e=o}return[e,t,o]}searchIsland(n,e){for(const t of Ie){const o=e+86400*t,r=this.getOffset(o);if(r!==n)return[o,r]}}},be={UTC:new me("UTC",0)};var[Fe,De]=d(),TimeZone=class extends y{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),De(this,function(n){const e=(n=String(n)).toLocaleUpperCase();if(be[e])return be[e];const t=Vn(n);if(void 0!==t){if(Math.abs(t)>864e11)throw new RangeError("Offset out of bounds");return new me(Dt(t),Math.trunc(t/1e9))}return be[e]=new Se(n)}(n))}static from(n){if("object"==typeof n)return function(n){return n.timeZone}(n)?function(n){if("object"==typeof n){if("string"==typeof n.id)return n;throw new RangeError("Invalid timeZone")}return new TimeZone(String(n))}(n.timeZone):n;const e=Jn(String(n));if(e){if(e.timeZone){const n=le(e);return We(n,3),n.timeZone}if(e.Z)return new TimeZone("UTC");if(void 0!==e.offset)return new TimeZone(Dt(e.offset))}return new TimeZone(n)}get id(){return Fe(this).id}getOffsetStringFor(n){return Dt(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const e=g(Instant,n);return 1e9*Fe(this).getOffset(e.epochSeconds)}getPlainDateTimeFor(n,e=Zo()){const t=g(Instant,n);return ko({...J(t.epochNanoseconds+BigInt(this.getOffsetNanosecondsFor(t))),calendar:g(Calendar,e)})}getInstantFor(n,e){const t=ue(e),o=g(PlainDateTime,n).getISOFields(),r=A(o),i=Fe(this).getPossibleOffsets(r);let s;if(1===i.length||0===t)s=i[0];else{if(3===t)throw new RangeError("Ambiguous offset");s=Math[1===t?"max":"min"](...i)}return Te(r-s,o)}getPossibleInstantsFor(n){const e=g(PlainDateTime,n).getISOFields(),t=A(e);let o=Fe(this).getPossibleOffsets(t);return 2===o.length&&o[0]<o[1]&&(o=[]),o.map((n=>Te(t-n,e)))}getPreviousTransition(n){const e=g(Instant,n),t=Fe(this).getTransition(e.epochSeconds,-1);return t?Te(t[0]):null}getNextTransition(n){const e=g(Instant,n),t=Fe(this).getTransition(e.epochSeconds,1);return t?Te(t[0]):null}toString(){return this.id}};function Te(n,e){return new Instant(BigInt(n)*b+(e?BigInt(e.isoMillisecond)*S+BigInt(e.isoMicrosecond)*I+BigInt(e.isoNanosecond):0n))}function Oe(n,e){const t=z(n);Ne(t),Fo(t,e)}function Ne(n){(n<-8640000086399999999999n||n>8640000086399999999999n)&&rn()}function Ye(n,e,t){return(o,r)=>{const i=Be(n,r)?{}:{...n,...e};return{buildKey:Ue(o,r,!1),buildFormat:function(n,e){return new we(o,{calendar:n,timeZone:e||void 0,...i,...r,...t})},buildEpochMilli:Ee}}}function Ee(n){return n.epochMilliseconds}function Ze(n,e,t){return(o,r)=>{const i=Be(n,r)?{}:n;return{buildKey:Ue(o,r,t),buildFormat:function(n,t){return new we(o,{calendar:n,...i,...r,...e,timeZone:t,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?Ce.bind(null,new TimeZone(r.timeZone)):Pe}}}function Ce(n,e){const t=ko({..._e,...e.getISOFields()});return n.getInstantFor(t).epochMilliseconds}function Pe(n){return W(n.getISOFields())}function Ue(n,e,t){const o=e.calendar??function(n){for(const e of n){const n=e.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),r=e.timeZone;return function(n,e){const i=n.calendar?.id,s=n.timeZone?.id;if(e){if(e.calendar?.id!==i)throw new RangeError("Mismatching calendar");if(e.timeZone?.id!==s)throw new RangeError("Mismatching timeZone")}if((t||"iso8601"!==i)&&void 0!==i&&void 0!==o&&o!==i)throw new RangeError("Non-iso calendar mismatch");if(void 0!==s&&void 0!==r&&r!==s)throw new RangeError("Given timeZone must agree");return[o||i||"iso8601",r||s||"UTC"]}}function Be(n,e){for(const t in n)if(void 0!==e[t])return!0;return!1}function Re(n,e){n.prototype.toLocaleString=function(n,t){const o=e(ve(n),t||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[m]=e}function ke(n){return n?.[m]}var xe={day:1},PlainYearMonth=class extends M{constructor(n,e,t=Zo(),o=1){const r=to({isoYear:n,isoMonth:e,isoDay:o},c),i=g(Calendar,t);var s,a;s=r,a=i.id,Fo(z(s),a),super({...r,calendar:i})}static from(n,e){if(u(e),n instanceof PlainYearMonth)return qe(n.getISOFields());if("object"==typeof n){const o=t(n,yn);return Po(n).yearMonthFromFields(o,e)}const o=An(String(n));return void 0===o.calendar&&(o.isoDay=1),qe(he(o))}static compare(n,e){return He(g(PlainYearMonth,n),g(PlainYearMonth,e))}with(n,e){const t=a(n,yn);return this.calendar.yearMonthFromFields(Le(t,this),e)}add(n,e){return je(this,g(Duration,n),e)}subtract(n,e){return je(this,g(Duration,n).negated(),e)}until(n,e){return io(this.toPlainDate(xe),g(PlainYearMonth,n).toPlainDate(xe),j(e,9,8,8,9))}since(n,e){return io(this.toPlainDate(xe),g(PlainYearMonth,n).toPlainDate(xe),j(e,9,8,8,9),!0)}equals(n){return 0===He(this,g(PlainYearMonth,n))}toString(n){const e=this.getISOFields(),t=e.calendar.id,o=gn(n);return("iso8601"===t?bt(e):St(e))+Tt(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}};function je(n,e,t){return n.toPlainDate({day:e.sign<0?n.daysInMonth:1}).add(e,t).toPlainYearMonth()}function qe(n){return new PlainYearMonth(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function Le(n,e){const t={};let o=!1,r=!1;return void 0===n.era&&void 0===n.eraYear||(t.era=n.era,t.eraYear=n.eraYear,o=!0),void 0!==n.year&&(t.year=n.year,o=!0),o||(t.year=e.year),void 0!==n.month&&(t.month=n.month,r=!0),void 0!==n.monthCode&&(t.monthCode=n.monthCode,r=!0),r||(t.month=e.month),t}function He(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}Nn(PlainYearMonth),Zn(PlainYearMonth,Yn),Re(PlainYearMonth,Ze({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));var[$e,ze]=d(),ZonedDateTime=class extends M{constructor(n,e,t=Zo()){const o=g(TimeZone,e),r=g(Calendar,t),i=new Instant(n),s=o.getOffsetNanosecondsFor(i),a=J(n+BigInt(s));Oe(a,r.id),super({...a,calendar:r,timeZone:o,offset:o.getOffsetStringFor(i)}),ze(this,{epochNanoseconds:n,offsetNanoseconds:s})}static from(n,e){const o=Sn(e,3),r=u(e);return Ae(n instanceof ZonedDateTime?{...n.getISOFields(),offset:n.offsetNanoseconds}:"object"==typeof n?Ke(t(n,Mn),e,r,Po(n),function(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return g(TimeZone,n.timeZone)}(n)):le($n(String(n))),e,o)}static compare(n,e){return q(g(ZonedDateTime,n).epochNanoseconds,g(ZonedDateTime,e).epochNanoseconds)}get timeZone(){return this.getISOFields().timeZone}get epochNanoseconds(){return $e(this).epochNanoseconds}get offsetNanoseconds(){return $e(this).offsetNanoseconds}get offset(){return this.getISOFields().offset}with(n,e){const t=a(n,Mn),o={...jo(r=t,i=this),offset:r.offset??i.offset};var r,i;const s=Sn(e,0),c=u(e);return ue(e),Ae(Ke(o,e,c,this.calendar,this.timeZone),e,s)}withPlainDate(n){const e=g(PlainDate,n),t=e.toPlainDateTime(this),{timeZone:o}=this,r=o.getInstantFor(t);return new ZonedDateTime(r.epochNanoseconds,o,Bo(this,e))}withPlainTime(n){return this.toPlainDate().toZonedDateTime({plainTime:n,timeZone:this.timeZone})}withCalendar(n){return new ZonedDateTime(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new ZonedDateTime(this.epochNanoseconds,n,this.calendar)}add(n,e){return Ge(this,g(Duration,n),e)}subtract(n,e){return Ge(this,g(Duration,n).negated(),e)}until(n,e){return Je(this,g(ZonedDateTime,n),e)}since(n,e){return Je(this,g(ZonedDateTime,n),e,!0)}round(n){return function(n,e){const t=x(e,void 0,0,6);if(6===t.smallestUnit){const e=function(n,e,t){const o=gt(n);return{day:t(Number(o)/e),hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}}(n,nt(n),t.roundingMode);return ko(st(n.getISOFields(),e)).toZonedDateTime(n.timeZone)}return et(n,it(t),t.roundingMode)}(this,n)}equals(n){const e=g(ZonedDateTime,n);return this.epochNanoseconds===e.epochNanoseconds&&this.calendar.id===e.calendar.id&&this.timeZone.id===e.timeZone.id}startOfDay(){return Ae({...this.getISOFields(),..._e,offset:void 0},void 0,3)}get hoursInDay(){return nt(this)/36e11}toString(n){const e=bn(n),t=de(n),o=Fn(n),r=gn(n),i=et(this,e.roundingIncrement,e.roundingMode).getISOFields();return It(i,e)+(0===t?i.offset:"")+function(n,e){if(1!==e)return`[${n}]`;return""}(i.timeZone.id,o)+Tt(i.calendar.id,r)}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return ko(this.getISOFields())}toPlainDate(){return _t(this.getISOFields())}toPlainTime(){return at(this.getISOFields())}toInstant(){return new Instant(this.epochNanoseconds)}};function Ae(n,e,t){const{calendar:o,timeZone:r}=n,i=We(n,t)??r.getInstantFor(ko(n),e).epochNanoseconds;return new ZonedDateTime(i,r,o)}function We(n,e){const{timeZone:t,offset:o,Z:r}=n;let i;if(void 0!==o&&2!==e&&(i=z(n)-BigInt(o),1!==e&&!r)){if(!function(n,e){for(const t of e)if(t.epochNanoseconds===n)return!0;return!1}(i,t.getPossibleInstantsFor(ko(n)))){if(3===e)throw new RangeError("Mismatching offset/timezone");i=void 0}}return i}function Ke(n,e,t,o,r){return{...xo(n,e,t,o),timeZone:r,offset:n.offset?Kn(n.offset):void 0}}function Ge(n,e,t){const{calendar:o,timeZone:r}=n,i=Ht(e),s=$t(e),a=o.dateAdd(n.toPlainDate(),i,t).toZonedDateTime({plainTime:n,timeZone:r}),c=gt(s),u=a.epochNanoseconds+c;return new ZonedDateTime(u,r,o)}function Je(n,e,t,o){const r=j(t,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==e.timeZone.id)throw new Error("Must be same timeZone");return tt(Qe(n,e,i),r,n,e,o)}function Qe(n,e,t){const o=Uo(n,e);if(!E(t))return Ve(n,e,t);const r=_t(n.getISOFields());let i,s,a,c,u,d=_t(e.getISOFields());do{s=o.dateUntil(r,d,{largestUnit:P[t]}),i=n.add(s),a=Ve(i,e,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(d=d.add({days:u})));return Bt(s,a)}function Ve(n,e,t){return jt(Xe(e)-Xe(n),t)}function Xe(n){return n instanceof PlainDateTime?z(n.getISOFields()):n.epochNanoseconds}Nn(ZonedDateTime,C),Zn(ZonedDateTime,En),Dn(ZonedDateTime),Re(ZonedDateTime,Ye({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));var _e={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0};function nt(n){const e={...n.getISOFields(),..._e,offset:void 0},t=Ae(e,void 0,3),o=Ae({...e,...Qt(e,1)},void 0,3);return Number(o.epochNanoseconds-t.epochNanoseconds)}function et(n,e,t){return Ae({...zo(n.toPlainDateTime(),e,t).getISOFields(),timeZone:n.timeZone,offset:n.offsetNanoseconds},void 0,0)}function tt(n,e,t,o,r){const{largestUnit:i,smallestUnit:s,roundingIncrement:a,roundingMode:c}=e;if(!E(i))return jt(rt((Xe(o)-Xe(t))*(r?-1n:1n),e),i);let u=ae(n,s,t,o);const d=U[s];function h(){const n=u[d];var e;u[d]=c(n/(e=a))*e}c===Math.round&&h(),r&&(u=Wt(u)),c!==Math.round&&h();let l=Pt(u);return s>0&&(l=r?Rt(l.negated(),i,t).negated():Rt(l,i,t)),l}function ot(n,e,t){return yt(H(gt(n),e,t))}function rt(n,e){return H(n,it(e),e.roundingMode)}function it(n){return O[n.smallestUnit]*n.roundingIncrement}function st(n,e){return{...Qt(n,e.day),...pt(e)}}var PlainTime=class extends M{constructor(n=0,e=0,t=0,o=0,r=0,i=0){super({...ct({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},c),calendar:Zo()})}static from(n,e){const o=u(e);return at(n instanceof PlainTime?n.getISOFields():"object"==typeof n?lt(t(n,wn),o):Gn(String(n)))}static compare(n,e){return mt(g(PlainTime,n),g(PlainTime,e))}with(n,e){return at(lt(ut(a(n,wn),this),u(e)))}add(n){return dt(this,g(Duration,n))}subtract(n){return dt(this,g(Duration,n).negated())}until(n,e){return ht(this,g(PlainTime,n),e)}since(n,e){return ht(g(PlainTime,n),this,e)}round(n){return function(n,e){const t=x(e,void 0,0,5);return at(pt(ot(n,it(t),t.roundingMode)))}(this,n)}equals(n){return 0===mt(this,g(PlainTime,n))}toString(n){const e=bn(n);return Ft(pt(ot(this,e.roundingIncrement,e.roundingMode)),e)}toZonedDateTime(n){return this.toPlainDateTime(n.plainDate).toZonedDateTime(n.timeZone)}toPlainDateTime(n){return g(PlainDate,n).toPlainDateTime(this)}};function at(n){return new PlainTime(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function ct({isoHour:n,isoMinute:t,isoSecond:o,isoMillisecond:r,isoMicrosecond:i,isoNanosecond:s},a){return{isoHour:n=e(n,0,23,a),isoMinute:t=e(t,0,59,a),isoSecond:o=e(o,0,59,a),isoMillisecond:r=e(r,0,999,a),isoMicrosecond:i=e(i,0,999,a),isoNanosecond:s=e(s,0,999,a)}}function ut(n,e){return l(wn,((t,o)=>n[o]??e[o]))}function dt(n,e){var t,o;return at(pt((t=n,o=$t(e),yt(gt(t)+gt(o)))))}function ht(n,e,t){const o=j(t,5,0,0,5);return jt(rt(gt(e)-gt(n),o),o.largestUnit)}function lt(n,e){return ct(pt(n),e)}function ft(n){return g(PlainTime,n??{hour:0})}function mt(n,e){return q(gt(n),gt(e))}function gt(n){return BigInt(n.hour)*D+BigInt(n.minute)*F+BigInt(n.second)*b+BigInt(n.millisecond)*S+BigInt(n.microsecond)*I+BigInt(n.nanosecond)}function yt(n){const[e,t]=Mt(n);return{...vt(t,5),day:Number(e/T)}}function pt(n){return{isoNanosecond:n.nanosecond??0,isoMicrosecond:n.microsecond??0,isoMillisecond:n.millisecond??0,isoSecond:n.second??0,isoMinute:n.minute??0,isoHour:n.hour??0}}function wt(n){return BigInt(n.day)*T+gt(n)}function vt(n,e){const t={};for(let o=e;o>=0;o--){const e=BigInt(O[o]),r=n/e;n-=r*e,t[P[o]]=Number(r)}return t}function Mt(n){const e=J(n);return[K(e.isoYear,e.isoMonth,e.isoDay),(t=e,BigInt(t.isoHour)*D+BigInt(t.isoMinute)*F+BigInt(t.isoSecond)*b+BigInt(t.isoMillisecond)*S+BigInt(t.isoMicrosecond)*I+BigInt(t.isoNanosecond))];var t}function It(n,e){return St(n)+"T"+Ft(n,e)}function St(n){return bt(n)+"-"+sn(n.isoDay,2)}function bt(n){const{isoYear:e}=n;return(e<1e3||e>9999?an(e)+sn(Math.abs(e),6):sn(e,4))+"-"+sn(n.isoMonth,2)}function Ft(n,e){const t=[sn(n.isoHour,2)];return e.smallestUnit<=4&&(t.push(sn(n.isoMinute,2)),e.smallestUnit<=3&&t.push(sn(n.isoSecond,2)+Nt(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,e.fractionalSecondDigits)[0])),t.join(":")}function Dt(n){const e=vt(BigInt(Math.abs(n)),5),t=Nt(e.millisecond,e.microsecond,e.nanosecond,void 0)[0];return an(n)+sn(e.hour,2)+":"+sn(e.minute,2)+(e.second||t?":"+sn(e.second,2)+t:"")}function Tt(n,e){return n&&(2===e||1!==e&&"iso8601"!==n)?`[u-ca=${n}]`:""}function Ot(n){return n.map((([n,e,t])=>t||n?(n<BigInt(0)?-n:n)+e:"")).join("")}function Nt(n,e,t,o,r,i){let s=BigInt(t)+BigInt(e)*I+BigInt(n)*S;r&&(s=H(s,void 0===o?O[i]:Math.pow(10,9-o),r));const a=s<0?-s:s,c=a/b;let u=sn(Number(a-c*b),9);return u=void 0===o?u.replace(/0+$/,""):u.substr(0,o),[u?"."+u:"",Number(c)*(s<0?-1:1)]}function Yt(n){const e=function(n){const e=qn.exec(ie(n));if(e){let n,t,o,r;[n,r]=Et(e[8],e[10],5,void 0),[t,r]=Et(e[12],e[14],4,r),[o,r]=Et(e[16],e[18],3,r);let i=function(n){const e={};for(const t in n)void 0!==n[t]&&(e[t]=n[t]);return e}({years:re(e[2]),months:re(e[3]),weeks:re(e[4]),days:re(e[5]),hours:n,minutes:t,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=vt(BigInt(r||0),2);return i.milliseconds=s.millisecond,i.microseconds=s.microsecond,i.nanoseconds=s.nanosecond,"-"===e[1]&&(i=Wt(i)),i}}(n);if(void 0===e)throw se("duration",n);return e}function Et(n,e,t,o){if(void 0!==n){if(void 0!==o)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==e?ee(e)*(O[t]/1e9):void 0]}if(void 0!==o){const n=Math.trunc(o/O[t]);return[n,o-n*O[t]]}return[void 0,void 0]}Nn(PlainTime,C),Re(PlainTime,(function(n,e){return{buildKey:()=>["",""],buildFormat:()=>new we(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...e,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Number(gt(n)/S)}}));var[Zt,Ct]=d(),Duration=class extends p{constructor(n=0,e=0,t=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super(),Ct(this,function(n){const e={};let t=0;for(const o of U){const r=Number(n[o]||0),i=L(n[o]);if(i){if(t&&t!==i)throw new RangeError("All fields must be same sign");t=i}if(!Number.isInteger(r))throw new RangeError("Duration fields must be integers");e[o]=r}return e.sign=t,e}({years:n,months:e,weeks:t,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u}))}static from(n){return Pt("object"==typeof n?t(n,In):Yt(n))}static compare(n,e,t){return function(n,e,t){const o=g(Duration,n),r=g(Duration,e),i=Lt(o),s=Lt(r);if(void 0===t&&i&&s)return q(wt(i),wt(s));const a=zt(t),c=a.add(o),u=a.add(r);if(a instanceof ZonedDateTime)return ZonedDateTime.compare(c,u);return PlainDateTime.compare(c,u)}(n,e,o(t).relativeTo)}get years(){return Zt(this).years}get months(){return Zt(this).months}get weeks(){return Zt(this).weeks}get days(){return Zt(this).days}get hours(){return Zt(this).hours}get minutes(){return Zt(this).minutes}get seconds(){return Zt(this).seconds}get milliseconds(){return Zt(this).milliseconds}get microseconds(){return Zt(this).microseconds}get nanoseconds(){return Zt(this).nanoseconds}get sign(){return Zt(this).sign}get blank(){return!this.sign}with(n){return Pt({...Zt(this),...a(n,In)})}negated(){return Pt(Wt(Zt(this)))}abs(){return Pt(l(Zt(this),(n=>Math.abs(n))))}add(n,e){return Ut(this,g(Duration,n),o(e).relativeTo)}subtract(n,e){return Ut(this,g(Duration,n).negated(),o(e).relativeTo)}round(n){return function(n,e){if(!i(e))throw new TypeError("Must specify options");if(void 0===e.largestUnit&&void 0===e.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const t=xt(n),o=j(e,t,0,0,9,!1,!0),{largestUnit:r,smallestUnit:s}=o,a=Lt(n);if(void 0===e.relativeTo&&a&&Y(r)&&Y(s)){return qt(vt(rt(wt(a),o),r))}const c=At(e.relativeTo),u=kt(n,r,c);return tt(u,o,c,c.add(u))}(this,n)}total(n){return function(n,e,t){const o=Lt(n);if(void 0===t&&o&&Y(e))return Number(wt(o))/O[e];const r=At(t),i=kt(n,e,r,!0);return ae(i,e,r,r.add(i))[U[e]]}(this,k(o(n).unit,void 0,0,9),n.relativeTo)}toString(n){const e=bn(n,3);return function(n,e){const{smallestUnit:t,fractionalSecondDigits:o,roundingMode:r}=e,{sign:i}=n,s=BigInt(n.hours),a=BigInt(n.minutes);let c=BigInt(n.seconds),u="";if(t<=3){const e=Nt(n.milliseconds,n.microseconds,n.nanoseconds,o,r,t);u=e[0],c+=BigInt(e[1])}return(i<0?"-":"")+"P"+Ot([[BigInt(n.years),"Y"],[BigInt(n.months),"M"],[BigInt(n.weeks),"W"],[BigInt(n.days),"D"]])+(s||a||c||u||!i?"T"+Ot([[s,"H"],[a,"M"],[t<=3?c:BigInt(0),u+"S",u||!i]]):"")}(Zt(this),e)}toLocaleString(n,e){return this.toString()}};function Pt(n){return new Duration(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function Ut(n,e,t){const o=Lt(n),r=Lt(e),i=Math.max(xt(n),xt(e));if(void 0===t&&o&&r)return jt(wt(o)+wt(r),i);const s=zt(t),a=s.add(n).add(e);return Qe(s,a,i)}function Bt(n,e){return new Duration(n.years+e.years,n.months+e.months,n.weeks+e.weeks,n.days+e.days,n.hours+e.hours,n.minutes+e.minutes,n.seconds+e.seconds,n.milliseconds+e.milliseconds,n.microseconds+e.microseconds,n.nanoseconds+e.nanoseconds)}function Rt(n,e,t){return t instanceof PlainDate?function(n,e,t){const o=t.add(n);return t.calendar.dateUntil(t,o,{largestUnit:P[e]})}(n,Math.max(6,e),t):kt(n,e,t)}function kt(n,e,t,o){const r=!0!==o&&e>7&&n.weeks;r&&(n=n.with({weeks:0}));const i=t.add(n);let s=Qe(t,i,e);return r&&(s=Bt(s,new Duration(0,0,r))),s}function xt(n){return n.years?9:n.months?8:n.weeks?7:n.days?6:n.hours?5:n.minutes?4:n.seconds?3:n.milliseconds?2:n.microseconds?1:0}function jt(n,e){return qt(vt(n,e))}function qt(n){return new Duration(0,0,0,n.day,n.hour,n.minute,n.second,n.millisecond,n.microsecond,n.nanosecond)}function Lt(n){if(!n.years&&!n.months&&!n.weeks)return{day:n.days,...$t(n)}}function Ht(n){return new Duration(n.years,n.months,n.weeks,n.days)}function $t(n){return{hour:n.hours,minute:n.minutes,second:n.seconds,millisecond:n.milliseconds,microsecond:n.microseconds,nanosecond:n.nanoseconds}}function zt(n){if(void 0===n)throw new RangeError("Need relativeTo");if("object"==typeof n)return void 0!==n.timeZone?ZonedDateTime.from(n):PlainDateTime.from(n);{const e=$n(String(n));return void 0!==e.timeZone?Ae(le(e),void 0,0):ko(he(e))}}function At(n){if(void 0===n)throw new RangeError("Must specify relativeTo");if(i(n))return n instanceof ZonedDateTime||n instanceof PlainDateTime?n:g(void 0!==n.timeZone?ZonedDateTime:PlainDateTime,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const e=Jn(String(n));if(e)return void 0!==e.timeZone?Ae(le(e),void 0,3):ko(he(e));throw new RangeError("Invalid value of relativeTo")}function Wt(n){return l(n,(n=>-n||0))}function Kt(n,e,t,o){n=Jt(n=Gt(n,e.years,t,o),e.months,t,o);let r=t.epochMilliseconds(n.year,n.month,n.day);const[,i]=function(n){const e=gt($t(n)),t=e/T;return[vt(e-t*T,5),new Duration(n.years,n.months,n.weeks,n.days+Number(t))]}(e);return r=nn(r,7*i.weeks+i.days),Q(r)}function Gt({year:n,month:t,day:o},r,i,s){n+=r;const a=e(t,1,i.monthsInYear(n),s);let c=t===a?o:1;return c=e(c,1,i.daysInMonth(n,a),s),{year:n,month:a,day:c}}function Jt({year:n,month:t,day:o},r,i,s){if(r){if(t+=r,r<0)for(;t<1;)t+=i.monthsInYear(--n);else{let e;for(;t>(e=i.monthsInYear(n));)t-=e,n++}o=e(o,1,i.daysInMonth(n,t),s)}return{year:n,month:t,day:o}}function Qt(n,e){return e?{...Q(nn(W(n),e)),calendar:n.calendar}:n}var PlainMonthDay=class extends M{constructor(n,e,t=Zo(),o){super({...to({isoYear:o??("iso8601"===t.id?1972:function(n,e){throw new n(e)}(Error,"Must specify referenceYear")),isoMonth:n,isoDay:e},c),calendar:t})}static from(n,e){if(u(e),n instanceof PlainMonthDay)return Xt(n.getISOFields());if("object"==typeof n){const o=Po(n);let r=t(n,Vt);return void 0===r.year&&void 0===n.calendar&&(r={...r,year:1972}),o.monthDayFromFields(r,e)}const o=Wn(String(n));return void 0===o.calendar&&(o.isoYear=1972),Xt(he(o))}with(n,e){const t=function(n,e){const t={day:n.day??e.day};void 0!==n.monthCode?(t.monthCode=n.monthCode,void 0!==n.month&&(t.month=n.month)):void 0!==n.month?(t.month=n.month,t.year=n.year):t.monthCode=e.monthCode;return t}(a(n,Vt),this);return this.calendar.monthDayFromFields(t,e)}equals(n){return e=this,t=g(PlainMonthDay,n),e.calendar.id===t.calendar.id&&z(e.getISOFields())===z(t.getISOFields());var e,t}toString(n){const e=this.getISOFields(),t=e.calendar.id,o=gn(n);return("iso8601"===t?function(n){return sn(n.isoMonth,2)+"-"+sn(n.isoDay,2)}(e):St(e))+Tt(t,o)}toPlainDate(n,e){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},e)}};Nn(PlainMonthDay),Zn(PlainMonthDay,["monthCode","day"]),Re(PlainMonthDay,Ze({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));var Vt={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number};function Xt(n){return new PlainMonthDay(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function _t(n){return new PlainDate(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function no(n,e){return{...Le(n,e),day:n.day??e.day}}function eo(n,t,o,r,i){return[n=Number(n),t=e(t,1,r.monthsInYear(n),i),o=e(o,1,r.daysInMonth(n,t),i)]}function to(n,e){const[t,o,r]=eo(n.isoYear,n.isoMonth,n.isoDay,fn,e);return{isoYear:t,isoMonth:o,isoDay:r}}function oo(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}function ro(n,e){return q(n.year,e.year)||function(n,e){return q(n.month,e.month)||q(n.day,e.day)}(n,e)}function io(n,e,t,o){return tt(Uo(n,e).dateUntil(n,e,{largestUnit:P[t.largestUnit]}),t,n,e,o)}var PlainDate=class extends M{constructor(n,e,t,o=Zo()){const r=to({isoYear:n,isoMonth:e,isoDay:t},c),i=g(Calendar,o);!function(n,e){const t=z(n);Ne(t+(t<0n?86399999999999n:0n)),Fo(t,e)}(r,i.id),super({...r,calendar:i})}static from(n,e){if(u(e),n instanceof PlainDate)return _t(n.getISOFields());if("object"==typeof n){const o=t(n,pn);return Po(n).dateFromFields(o,e)}return _t(he(zn(String(n))))}static compare(n,e){return oo(g(PlainDate,n),g(PlainDate,e))}with(n,e){const t=no(a(n,pn),this);return this.calendar.dateFromFields(t,e)}withCalendar(n){const e=this.getISOFields();return new PlainDate(e.isoYear,e.isoMonth,e.isoDay,n)}add(n,e){return this.calendar.dateAdd(this,n,e)}subtract(n,e){return this.calendar.dateAdd(this,g(Duration,n).negated(),e)}until(n,e){return io(this,g(PlainDate,n),j(e,6,6,6,9))}since(n,e){return io(this,g(PlainDate,n),j(e,6,6,6,9),!0)}equals(n){return 0===oo(this,g(PlainDate,n))}toString(n){const e=gn(n),t=this.getISOFields();return St(t)+Tt(t.calendar.id,e)}toZonedDateTime(n){return this.toPlainDateTime(n.plainTime).toZonedDateTime(n.timeZone)}toPlainDateTime(n){return ko({...this.getISOFields(),...ft(n).getISOFields()})}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}};function so(n){return n instanceof PlainDate||n instanceof PlainDateTime||n instanceof ZonedDateTime||n instanceof PlainYearMonth||n instanceof PlainMonthDay}function ao(n,e,t){let o;if(n instanceof PlainDate)o=n;else if(so(n)){if(t&&n instanceof PlainMonthDay)throw new TypeError("PlainMonthDay not allowed");o=_t(n.getISOFields())}else o=PlainDate.from(n);return Ro(o.calendar,e),o}function co(n,e,t){if(so(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:d}=n;const h=void 0!==r&&void 0!==o?dn(e.id,r,o):void 0;if(void 0===i){if(void 0===h)throw new TypeError("Must specify either a year or an era & eraYear");i=h}else if(void 0!==h&&h!==i)throw new RangeError("year and era/eraYear must match");if(void 0===d)throw new TypeError("Must specify day");const l=u(t);if(void 0!==a){const[n,t]=e.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,t){if(l===c)throw new RangeError("Month code out of range");d=e.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,d]=eo(i,s,d,e,l),Q(e.epochMilliseconds(i,s,d))}function uo(n,e){if(so(n)){if(e&&n instanceof PlainMonthDay)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return PlainDate.from(n).getISOFields()}function ho(n,e){return _(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e+1,1,1))}function lo(n,e,t,o){return _(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e,t,o))+1}Nn(PlainDate),Zn(PlainDate,En),Re(PlainDate,Ze({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));var fo={hebrew:6,chinese:0,dangi:0},mo=class extends un{constructor(n){const e=go(n);if(t=n,o=e.resolvedOptions().calendar,hn(t)!==hn(o))throw new RangeError("Invalid calendar: "+n);var t,o;super(n),this.format=e,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,e,t){return nn(this.queryMonthCache(n)[0][e-1],t-1)}daysInMonth(n,e){const t=this.queryMonthCache(n)[0],o=t[e-1];e>=t.length&&(n++,e=0);return _(o,this.queryMonthCache(n)[0][e])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,e){const t=this.queryLeapMonthByYear(e);return!t||n<t?super.monthCode(n,e):super.monthCode(n-1,e)+(n===t?"L":"")}convertMonthCode(n,e){const t=this.queryLeapMonthByYear(e);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=fo[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||t&&r===t-1||(i=!0,o=!1),(o||t&&r>=t)&&r++,[r,i]}inLeapYear(n){const e=ho(this,n);return e>ho(this,n-1)&&e>ho(this,n+1)}guessYearForMonthDay(n,e){let t=1970+this.yearCorrection;const o=t+100;for(;t<o;t++){const[o,r]=this.convertMonthCode(n,t);if(!r&&o<=this.monthsInYear(t)&&e<=this.daysInMonth(t,o))return t}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const e=this.computeFieldsDumb(n),t=this.queryMonthCache(e.year)[2];return{...e,month:t[e.month]}}computeFieldsDumb(n){const e=ge(this.format,n);let t,o,r=parseInt(e.relatedYear||e.year);var i;return e.era&&(i=this.id,void 0!==cn[hn(i)])&&(t=pe(e.era),o=r,r=dn(this.id,o,t,!0)),{era:t,eraYear:o,year:r,month:e.month,day:parseInt(e.day)}}queryLeapMonthByYear(n){const e=this.queryMonthCache(n),t=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(e[0].length>t[0].length&&e[0].length>o[0].length){const n=e[1],o=t[1];for(let e=0;e<o.length;e++)if(o[e]!==n[e])return e+1}}queryMonthCache(n){const{monthCacheByYear:e}=this;return e[n]||(e[n]=this.buildMonthCache(n))}buildMonthCache(n){const e=[],t=[],o={};let r=G(this.guessISOYear(n));for(r=nn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=nn(r,1-o.day),o.year===n&&(e.unshift(r),t.unshift(o.month)),r=nn(r,-1)}for(let n=0;n<t.length;n++)o[t[n]]=n+1;return[e,t,o]}guessISOYear(n){return n-this.yearCorrection}};function go(n){return new we("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}var yo=G(1868,9,8),po={gregory:mn,japanese:class extends mn{constructor(){super(...arguments),this.format=go("japanese")}computeFields(n){const e=super.computeFields(n);if(n>=yo){const t=ge(this.format,n);e.era=pe(t.era),e.eraYear=parseInt(t.relatedYear||t.year)}return e}},islamic:class extends mo{guessISOYear(n){return Math.ceil(32*n/33+622)}}},wo={iso8601:fn};function vo(n){const e=(n=String(n)).toLocaleLowerCase();return wo[e]||(wo[e]=new(po[hn(e)]||mo)(n))}var Mo=G(1582,10,15),Io=G(622,7,18),So={buddhist:Mo,japanese:Mo,roc:Mo,islamic:Io,"islamic-rgsa":Io,indian:0},bo={};function Fo(n,e){return Do(Number(n/S),e)}function Do(n,e){if(function(n,e){return function(n){let e=bo[n];if(void 0===e){const t=So[n];if(void 0===t)e=!1;else{let o=vo(n);o instanceof mo||(o=new mo(n));const r=t-864e5,i=o.computeFields(r);e=r!==o.epochMilliseconds(i.year,i.month,i.day)}bo[n]=e}return e}(e)&&n<So[e]}(n,e))throw new RangeError("Invalid timestamp for calendar")}function To(n,e,t,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,e,t){const[,o,r]=eo(e.year,n.month,n.day,t,0),i=ro(e,n),s=q(e.month,o)||q(e.day,r);return e.year-n.year-(s&&i&&s!==i?i:0)}(n,e,t),n=Gt(n,r,t,0);case 8:i=function(n,e,t){let o=0;const r=ro(e,n);if(r){let{year:i}=n;for(;i!==e.year;)o+=t.monthsInYear(i)*r,i+=r;const[,s,a]=eo(e.year,n.month,n.day,t,0);o+=e.month-s;const c=q(e.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,e,t),n=Jt(n,i,t,0)}return a=_(t.epochMilliseconds(n.year,n.month,n.day),t.epochMilliseconds(e.year,e.month,e.day)),7===o&&(s=Math.trunc(a/7),a%=7),new Duration(r,i,s,a)}function Oo(n,e,t){const o=7+e-t;return-$(en(n,1,o)-e,7)+o-1}function No(n,e,t){const o=Oo(n,e,t),r=Oo(n+1,e,t);return(ho(fn,n)-o+r)/7}var[Yo,Eo]=d(),Calendar=class extends y{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),Eo(this,vo(n))}static from(n){if("object"==typeof n&&n)return function(n){return n.calendar}(n)?function(n){if("object"==typeof n&&n){if("string"==typeof n.id)return n;throw new RangeError("Invalid calendar")}return new Calendar(String(n))}(n.calendar):n;const e=Qn(String(n));return new Calendar(e?e.calendar||"iso8601":n)}get id(){return Yo(this).id}era(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).era}eraYear(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).eraYear}year(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).year}month(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).month}monthCode(n){const e=ao(n,this);return Yo(this).monthCode(e.month,e.year)}day(n){const e=uo(n);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).day}dayOfWeek(n){const e=uo(n,!0);return en(e.isoYear,e.isoMonth,e.isoDay)}dayOfYear(n){const e=ao(n,this,!0);return lo(Yo(this),e.year,e.month,e.day)}weekOfYear(n){const e=uo(n,!0);return function(n,e,t,o,r){const i=Oo(n,o,r),s=Math.floor((lo(fn,n,e,t)-i-1)/7)+1;if(s<1)return s+No(n-1,o,r);const a=No(n,o,r);return s>a?s-a:s}(e.isoYear,e.isoMonth,e.isoDay,1,4)}daysInWeek(n){return uo(n,!0),7}daysInMonth(n){const e=ao(n,this,!0);return Yo(this).daysInMonth(e.year,e.month)}daysInYear(n){const e=ao(n,this,!0);return ho(Yo(this),e.year)}monthsInYear(n){const e=ao(n,this,!0);return Yo(this).monthsInYear(e.year)}inLeapYear(n){return Yo(this).inLeapYear(this.year(n))}dateFromFields(n,e){const t=co(n,Yo(this),e);return new PlainDate(t.isoYear,t.isoMonth,t.isoDay,this)}yearMonthFromFields(n,e){const t=co({...n,day:1},Yo(this),e);return new PlainYearMonth(t.isoYear,t.isoMonth,this,t.isoDay)}monthDayFromFields(n,e){const t=Yo(this);let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;if(void 0===c)throw new TypeError("required property 'day' missing or undefined");if(void 0!==a?i=1972:void 0!==o&&void 0!==r&&(i=dn(t.id,r,o)),void 0===i){if(void 0===a)throw new TypeError("either year or monthCode required with month");i=t.guessYearForMonthDay(a,c)}const u=co({year:i,month:s,monthCode:a,day:c},t,e);return new PlainMonthDay(u.isoMonth,u.isoDay,this,t.normalizeISOYearForMonthDay(u.isoYear))}dateAdd(n,e,t){const o=Yo(this),r=Kt(g(PlainDate,n,t),g(Duration,e),o,u(t));return new PlainDate(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,e,t){const r=Yo(this),i=g(PlainDate,n),s=g(PlainDate,e),a=k(o(t).largestUnit,6,6,9);return Ro(Uo(i,s),this),To(i,s,r,a)}toString(){return this.id}};function Zo(){return new Calendar("iso8601")}function Co(n,e,t,o){const r=G(e,t,o);return Do(r,n.id),n.computeFields(r)}function Po(n){return void 0===n.calendar?Zo():g(Calendar,n.calendar)}function Uo(n,e){const{calendar:t}=n;return Ro(t,e.calendar),t}function Bo(n,e){const t=n.calendar,o=e.calendar;if("iso8601"===t.id)return o;if("iso8601"===o.id)return t;if(t.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return t}function Ro(n,e){if(n.id!==e.id)throw new RangeError("Calendars must match")}var PlainDateTime=class extends M{constructor(n,e,t,o=0,r=0,i=0,s=0,a=0,u=0,d=Zo()){const h=qo({isoYear:n,isoMonth:e,isoDay:t,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:u},c),l=g(Calendar,d);Oe(h,l.id),super({...h,calendar:l})}static from(n,e){const o=u(e);return ko(n instanceof PlainDateTime?n.getISOFields():"object"==typeof n?xo(t(n,vn),e,o,Po(n)):he(zn(String(n))))}static compare(n,e){return Lo(g(PlainDateTime,n),g(PlainDateTime,e))}with(n,e){return ko(xo(jo(a(n,vn),this),e,u(e),this.calendar))}withPlainDate(n){const e=g(PlainDate,n);return ko({...this.getISOFields(),...e.getISOFields(),calendar:Bo(this,e)})}withPlainTime(n){return ko({...this.getISOFields(),...ft(n).getISOFields()})}withCalendar(n){return ko({...this.getISOFields(),calendar:g(Calendar,n)})}add(n,e){return Ho(this,g(Duration,n),e)}subtract(n,e){return Ho(this,g(Duration,n).negated(),e)}until(n,e){return $o(this,g(PlainDateTime,n),e)}since(n,e){return $o(this,g(PlainDateTime,n),e,!0)}round(n){return function(n,e){const t=x(e,void 0,0,6);return zo(n,it(t),t.roundingMode)}(this,n)}equals(n){return 0===Lo(this,g(PlainDateTime,n))}toString(n){const e=bn(n),t=gn(n),o=zo(this,e.roundingIncrement,e.roundingMode).getISOFields();return It(o,e)+Tt(o.calendar.id,t)}toZonedDateTime(n,e){const t=g(TimeZone,n),o=t.getInstantFor(this,e);return new ZonedDateTime(o.epochNanoseconds,t,this.calendar)}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return _t(this.getISOFields())}toPlainTime(){return at(this.getISOFields())}};function ko(n){return new PlainDateTime(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function xo(n,e,t,o){return{...o.dateFromFields(n,e).getISOFields(),...lt(n,t)}}function jo(n,e){return{...no(n,e),...ut(n,e)}}function qo(n,e){return{...to(n,e),...ct(n,e)}}function Lo(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}function Ho(n,e,t){const{calendar:o}=n,r=Ht(e),i=$t(e);return ko({...J(z(o.dateAdd(_t(n.getISOFields()),r,t).getISOFields())+gt(n)+gt(i)),calendar:o})}function $o(n,e,t,o){const r=j(t,6,0,0,9);return tt(Qe(n,e,r.largestUnit),r,n,e,o)}function zo(n,e,t){const o=ot(n,e,t);return ko(st(n.getISOFields(),o))}function Ao(n,e){return q(n.epochNanoseconds,e.epochNanoseconds)}function Wo(n,e){if(xt(e)>=6)throw new RangeError("Duration cant have units larger than days");return new Instant(n.epochNanoseconds+gt($t(e)))}function Ko(n,e,t){const o=j(t,3,0,0,5,!0);return jt(rt(e.epochNanoseconds-n.epochNanoseconds,o),o.largestUnit)}Nn(PlainDateTime,C),Zn(PlainDateTime,En),Re(PlainDateTime,Ze({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));var[Go,Jo]=d(),Instant=class extends p{constructor(n){var e;super(),n=BigInt(n),((e=n)<-8640000000000000000000n||e>8640000000000000000000n)&&rn(),Jo(this,n)}static from(n){if(n instanceof Instant)return new Instant(n.epochNanoseconds);const e=$n(String(n)),t=e.offset;if(void 0===t)throw new RangeError("Must specify an offset");return new Instant(z(qo(e,c))-BigInt(t))}static fromEpochSeconds(n){return new Instant(BigInt(n)*b)}static fromEpochMilliseconds(n){return new Instant(BigInt(n)*S)}static fromEpochMicroseconds(n){return new Instant(n*I)}static fromEpochNanoseconds(n){return new Instant(n)}static compare(n,e){return Ao(g(Instant,n),g(Instant,e))}get epochNanoseconds(){return Go(this)}add(n){return Wo(this,g(Duration,n))}subtract(n){return Wo(this,g(Duration,n).negated())}until(n,e){return Ko(this,g(Instant,n),e)}since(n,e){return Ko(g(Instant,n),this,e)}round(n){return function(n,e){const t=x(e,void 0,0,5,!1,!0),[o,r]=Mt(n.epochNanoseconds);return new Instant(o+rt(r,t))}(this,n)}equals(n){return 0===Ao(this,g(Instant,n))}toString(n){const e=o(n).timeZone;return this.toZonedDateTimeISO(e??"UTC").toString({...n,offset:void 0===e?"never":"auto",timeZoneName:"never"})+(void 0===e?"Z":"")}toZonedDateTimeISO(n){return new ZonedDateTime(this.epochNanoseconds,n)}toZonedDateTime(n){if(!i(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new ZonedDateTime(this.epochNanoseconds,n.timeZone,n.calendar)}};Dn(Instant),Re(Instant,Ye({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));var Qo=Symbol(),Vo=Symbol(),Xo=Symbol(),_o=class extends we{constructor(n,e){const t=ve(n),o=function(n){const e={};for(const t in n){let o=n[t];i(o)&&(o=o.toString()),e[t]=o}return e}(e||{});super(t,o),this[Qo]=t,this[Vo]=o,this[Xo]=new Map}format(n){const e=nr(this,n);return e[0]===this?super.format(n):e[0].format(e[1])}formatToParts(n){return super.formatToParts.call(...nr(this,n))}formatRange(n,e){return super.formatRange.call(...er(this,n,e))}formatRangeToParts(n,e){return super.formatRangeToParts.call(...er(this,n,e))}};function nr(n,e){const t=ke(e);if(t){const o=tr(n,t);return[o.buildFormat(e),o.buildEpochMilli(e)]}return[n,e]}function er(n,e,t){const o=ke(e);if(o!==ke(t))throw new TypeError("Mismatch of types");if(o){const r=tr(n,o);return[r.buildFormat(e,t),r.buildEpochMilli(e),r.buildEpochMilli(t)]}return[n,e,t]}function tr(n,e){const t=n[Xo];let o=t.get(e);return o||(o=function(n){const e={};return{buildFormat:function(t,o){const r=n.buildKey(t,o),i=r.join("|");return e[i]||(e[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(e(n[Qo],n[Vo])),t.set(e,o)),o}function or(n=cr()){return ar().toZonedDateTimeISO(n)}function rr(n,e){if(void 0===n)throw new RangeError("Must specify calendar");return ar().toZonedDateTime({calendar:n,timeZone:e??cr()})}function ir(n=cr()){return or(n).toPlainDateTime()}function sr(n,e){return rr(n,e).toPlainDateTime()}function ar(){return new Instant(BigInt(Date.now())*S)}function cr(){return new TimeZone((new we).resolvedOptions().timeZone)}var ur={zonedDateTimeISO:or,zonedDateTime:rr,plainDateTimeISO:ir,plainDateTime:sr,plainDateISO:function(n=cr()){return ir(n).toPlainDate()},plainDate:function(n,e){return sr(n,e).toPlainDate()},plainTimeISO:function(n=cr()){return ar().toZonedDateTimeISO(n).toPlainTime()},instant:ar,timeZone:cr};globalThis.Temporal||(globalThis.Temporal={PlainYearMonth:PlainYearMonth,PlainMonthDay:PlainMonthDay,PlainDate:PlainDate,PlainTime:PlainTime,PlainDateTime:PlainDateTime,ZonedDateTime:ZonedDateTime,Instant:Instant,Calendar:Calendar,TimeZone:TimeZone,Duration:Duration,Now:ur},globalThis.Date.prototype.toTemporalInstant=function(){return n=this,Instant.fromEpochMilliseconds(n.valueOf());var n},globalThis.Intl.DateTimeFormat=_o);
var n=1000n,e=1000000n,t=1000000000n,o=60000000000n,r=3600000000000n,i=86400000000000n,s=864e11,a=[1,1e3,1e6,1e9,6e10,36e11,s],c=[9,6,3];function u(n){return n<=6}function d(n){return n>=6}var h=l("overflow",{constrain:0,reject:1},0);function l(n,e,t){const o=function(n,e,t){return(o,r)=>{if(void 0===o){const e=r??t;if(void 0===e)throw new RangeError(`Must specify a ${n}`);return e}if(void 0===e[o])throw new RangeError(`Invalid ${n}: ${o}`);return e[o]}}(n,e,t);return(e,t)=>{const r=g(e);return o(r[n],t)}}function f(n,e,t,o){if(void 0===n)return e;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,e),t);if(r!==n&&1===o)throw new RangeError("Invalid overflowed value "+n);return r}function m(n,e){const t={};for(const o in e)void 0!==n[o]&&(t[o]=e[o](n[o]));return t}function g(n){if(void 0===n)return{};if(!w(n))throw TypeError("options must be an object or undefined");return n}var y=/object|function/;function w(n){return null!==n&&y.test(typeof n)}var p=l("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor});function v(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function M(n,e){Object.defineProperties(n.prototype,I(e,(n=>({get:n}))))}function I(n,e){const t={};for(const o in n)t[o]=e(n[o],o);return t}function S(n,e,t){const o={};for(const r of e)o[r]=t(n[r]);return o}function F(n,e){const t={};return n.forEach(((n,o)=>{t[n]=e(n,o)})),t}var b=["nanosecond","microsecond","millisecond","second","minute","hour"],N=[...b,"day","week","month","year"],T=N.map((n=>n+"s")),O=F(N,((n,e)=>e)),D=F(T,((n,e)=>e));function Y(n,e,t,o){let r;if(void 0===n){if(void 0===e)throw new RangeError("Unit is required");r=e}else if(r=O[n]??D[n],void 0===r||r<t||r>o)throw new RangeError("Invalid unit "+n);return r}function E(n,e,t,o,r,i){const s=g(n),c=s.roundingIncrement??1,u=Y(s.smallestUnit,t,o,r),d=p(s,i?Math.round:Math.trunc);let h=s.largestUnit;"auto"===h&&(h=void 0);const l=Y(h,e=Math.max(e,u),o,r);if(u>l)throw new RangeError("Bad smallestUnit/largestUnit");if(u<6){const n=a[u+1],e=a[u]*c;if(n===e)throw new RangeError("Must not equal larger unit");if(n%e)throw new RangeError("Must divide into larger unit")}return{smallestUnit:u,largestUnit:l,roundingFunc:d,roundingIncrement:c}}function Z(n,e,t,o,r){const i="string"==typeof n?{smallestUnit:n}:n;if(void 0===e&&!w(i))throw new TypeError("Need rounding options");const c=g(i),u=c.roundingIncrement??1,d=Y(c.smallestUnit,e,t,o),h=p(c,Math.round),l=a[d]*u;if(6===d){if(1!==u)throw new RangeError("When smallestUnit is days, roundingIncrement must be 1")}else{const n=r?s:a[d+1];if(!r&&n===l)throw new RangeError("Must not equal larger unit");if(n%l)throw new RangeError("Must divide into larger unit")}return{smallestUnit:d,roundingFunc:h,incNano:l}}var C=Symbol();function U(n,e,...t){return e instanceof n?e:n.from(e,...t)}var P=class{toJSON(){return this.toString()}},R=class extends P{valueOf(){throw new Error("Cannot convert object using valueOf")}},[B,k]=v(),x=class extends R{constructor(n){super(),k(this,Object.freeze(n))}getISOFields(){return B(this)}};function j(n,e){return n<e?-1:n>e?1:0}function q(n){return j(n,0)}function H(n,e,t){return t(n/e)*e}function L(n){return H(n,6e10,$)}function $(n){return Math.round(Math.abs(n))*q(n)}function z(n,e,t){const o=BigInt(e),r=n/o*o,i=Number(n-r);return r+BigInt(t(i/e))*o}function A(n,e){return(n%e+e)%e}var W=T.concat("sign");function K(n){return S(n,W,(n=>-n||0))}function G(n,e){return J({years:e.years??n.years,months:e.months??n.months,weeks:e.weeks??n.weeks,days:e.days??n.days,hours:e.hours??n.hours,minutes:e.minutes??n.minutes,seconds:e.seconds??n.seconds,milliseconds:e.milliseconds??n.milliseconds,microseconds:e.microseconds??n.microseconds,nanoseconds:e.nanoseconds??n.nanoseconds})}function J(n){return{...n,sign:Q(n)}}function Q(n){let e=0;for(const t of T){if(n[t]){e=q(n[t]);break}}return e}function V(n){let e=9;for(;e>0&&!n[T[e]];)e--;return e}var X={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0},_={hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};function nn(n){return{isoHour:n.hour||0,isoMinute:n.minute||0,isoSecond:n.second||0,isoMillisecond:n.millisecond||0,isoMicrosecond:n.microsecond||0,isoNanosecond:n.nanosecond||0}}function en(n){return BigInt(n.days)*i+tn(n)}function tn(i){return BigInt(i.hours)*r+BigInt(i.minutes)*o+BigInt(i.seconds)*t+BigInt(i.milliseconds)*e+BigInt(i.microseconds)*n+BigInt(i.nanoseconds)}function on(n){return 36e11*n.isoHour+6e10*n.isoMinute+1e9*n.isoSecond+1e6*n.isoMillisecond+1e3*n.isoMicrosecond+n.isoNanosecond}function rn(s,a){let c,u=0,d=0,h=0,l=0,f=0,m=0;switch(a){case 6:c=s/i,u=Number(c),s-=c*i;case 5:c=s/r,d=Number(c),s-=c*r;case 4:c=s/o,h=Number(c),s-=c*o;case 3:c=s/t,l=Number(c),s-=c*t;case 2:c=s/e,f=Number(c),s-=c*e;case 1:c=s/n,m=Number(c),s-=c*n}return J({years:0,months:0,weeks:0,days:u,hours:d,minutes:h,seconds:l,milliseconds:f,microseconds:m,nanoseconds:Number(s)})}function sn(n){const e=Math.floor(n/s);n-=e*s;const t=Math.floor(n/36e11);n-=36e11*t;const o=Math.floor(n/6e10);n-=6e10*o;const r=Math.floor(n/1e9);n-=1e9*r;const i=Math.floor(n/1e6);n-=1e6*i;const a=Math.floor(n/1e3);return[{isoHour:t,isoMinute:o,isoSecond:r,isoMillisecond:i,isoMicrosecond:a,isoNanosecond:n-=1e3*a},e]}function an(n,e){return String(n).padStart(e,"0")}function cn(n){return n<0?"-":"+"}var un={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}},dn=class{constructor(n){this.id=n}monthCode(n,e){return"M"+an(n,2)}convertMonthCode(n,e){const t=/L$/.test(n),o=parseInt(n.substr(1));if(t)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}};function hn(n,e,t,o){let r=un[ln(n)]?.[t];if(void 0===r){if(!o)throw new Error("Unkown era "+t);r=0}return(r+e)*(q(r)||1)}function ln(n){return n.split("-")[0]}var fn=class extends dn{computeFields(n){const e=Mn(n);return{era:void 0,eraYear:void 0,year:e.isoYear,month:e.isoMonth,day:e.isoDay}}epochMilliseconds(n,e,t){return pn(n,e,t)}daysInMonth(n,e){return 2===e?this.inLeapYear(n)?29:28:4===e||6===e||9===e||11===e?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return gn}normalizeISOYearForMonthDay(){return gn}},mn=new fn("iso8601"),gn=1972;function yn(n){return wn(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function wn(t,o,r,i,s,a,c,u,d){return BigInt(pn(t,o,r,i,s,a,c))*e+BigInt(u??0)*n+BigInt(d??0)}function pn(n,e,t,o,r,i,s){const a=q(n);let c,u,d=0;const h=n>=0&&n<1e3,l=h?n+1200:n;for(;d<31;d++){c=t-a*d;const n=Date.UTC(l,e-1,c,o??0,r??0,i??0,s??0);if(!Tn(n)){u=n+a*d*864e5;break}}return(void 0===u||c<1||c>mn.daysInMonth(n,e))&&On(),h&&(u=new Date(u).setUTCFullYear(n)),u}function vn(n){let t=n/e,o=Number(n-t*e);o<0&&(o+=1e6,t-=1n);const r=Math.floor(o/1e3);return o-=1e3*r,{...Mn(Number(t)),isoMicrosecond:r,isoNanosecond:o}}function Mn(n){const[e,t]=Nn(n);return{isoYear:e.getUTCFullYear(),isoMonth:e.getUTCMonth()+1,isoDay:e.getUTCDate()+t,isoHour:e.getUTCHours(),isoMinute:e.getUTCMinutes(),isoSecond:e.getUTCSeconds(),isoMillisecond:e.getUTCMilliseconds()}}function In(n){return n.epochNanoseconds??yn(n.getISOFields())}function Sn(n){return Math.floor(pn(n,1,1)/1e3)}function Fn(n){return Nn(Number(n/e))[0].getUTCFullYear()}function bn(n,e,t){const[o,r]=Nn(pn(n,e,t));return A(o.getUTCDay()+r,7)||7}function Nn(n){const e=q(n);let t,o=0;for(;o<31;o++){const r=new Date(n-e*o*864e5);if(!Tn(r)){t=r;break}}return void 0===t&&On(),[t,e*o]}function Tn(n){return isNaN(n.valueOf())}function On(){throw new RangeError("Date outside of supported range")}function Dn(n,e){return Math.round((e-n)/864e5)}function Yn(n,e){return n+864e5*e}function En(n,e){return function(n,e){return!Zn(n,e)&&n.calendar.id===e.calendar.id}(n,e)&&n.timeZone.id===e.timeZone.id}function Zn(n,e){return j(yn(n.getISOFields()),yn(e.getISOFields()))}function Cn(n,e){return j(on(n.getISOFields()),on(e.getISOFields()))}function Un(n,e){return j(n.year,e.year)||j(n.month,e.month)||j(n.day,e.day)}function Pn(n,e){return j(n.epochNanoseconds,e.epochNanoseconds)}function Rn(n,e,t,o,r){return[n=Number(n),e=f(e,1,o.monthsInYear(n),r),t=f(t,1,o.daysInMonth(n,e),r)]}function Bn(n,e){const[t,o,r]=Rn(n.isoYear,n.isoMonth,n.isoDay,mn,e);return{isoYear:t,isoMonth:o,isoDay:r}}function kn(n,e){return{...Bn(n,e),...xn(n,e)}}function xn({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},s){return{isoHour:n=f(n,0,23,s),isoMinute:e=f(e,0,59,s),isoSecond:t=f(t,0,59,s),isoMillisecond:o=f(o,0,999,s),isoMicrosecond:r=f(r,0,999,s),isoNanosecond:i=f(i,0,999,s)}}var jn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},qn={...jn,day:Number},Hn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},Ln={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number},$n=F(T,(()=>Number)),zn=class extends fn{computeFields(n){const e=super.computeFields(n),{year:t}=e;return{...e,era:t<1?"bce":"ce",eraYear:t<1?-(t-1):t}}},An=l("calendarName",{auto:0,never:1,always:2},0);function Wn(n,e=4){const t=g(n),o=t.smallestUnit,r=t.fractionalSecondDigits;let i,s=0,u=1;return void 0!==o?(s=Y(o,void 0,0,e),u=a[s],i=c[s]||0):void 0!==r&&"auto"!==r&&(i=f(r,0,9,1),u=Math.pow(10,9-i)),{smallestUnit:s,fractionalSecondDigits:i,roundingFunc:p(n,Math.trunc),incNano:u}}var Kn=l("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0),Gn=l("timeZoneName",{auto:0,never:1},0);function Jn(n,e){return Qn(n)+"T"+Xn(n,e)}function Qn(n){return Vn(n)+"-"+an(n.isoDay,2)}function Vn(n){const{isoYear:e}=n;return(e<1e3||e>9999?cn(e)+an(Math.abs(e),6):an(e,4))+"-"+an(n.isoMonth,2)}function Xn(n,e){const t=[an(n.isoHour,2)];return e.smallestUnit<=4&&(t.push(an(n.isoMinute,2)),e.smallestUnit<=3&&t.push(an(n.isoSecond,2)+te(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,e.fractionalSecondDigits)[0])),t.join(":")}function _n(n){const[e,t]=sn(Math.abs(n)),o=te(e.isoMillisecond,e.isoMicrosecond,e.isoNanosecond,void 0)[0];return cn(n)+an(e.isoHour+24*t,2)+":"+an(e.isoMinute,2)+(e.isoSecond||o?":"+an(e.isoSecond,2)+o:"")}function ne(n,e){return n&&(2===e||1!==e&&"iso8601"!==n)?`[u-ca=${n}]`:""}function ee(n){return n.map((([n,e,t])=>t||n?(n<BigInt(0)?-n:n)+e:"")).join("")}function te(o,r,i,s,c,u){let d=BigInt(i)+BigInt(r)*n+BigInt(o)*e;c&&(d=z(d,void 0===s?a[u]:Math.pow(10,9-s),c));const h=d<0?-d:d,l=h/t;let f=an(Number(h-l*t),9);return f=void 0===s?f.replace(/0+$/,""):f.substr(0,s),[f?"."+f:"",Number(l)*(d<0?-1:1)]}function oe(o){M(o,{epochMicroseconds(){return this.epochNanoseconds/n},epochMilliseconds(){return Number(this.epochNanoseconds/e)},epochSeconds(){return Number(this.epochNanoseconds/t)}})}var re,ie={calendar:"calendar"};for(const n of N)ie[n]="iso"+((re=n).charAt(0).toUpperCase()+re.slice(1));function se(n,e=[]){M(n,F(e.concat("calendar"),(n=>function(){return this.getISOFields()[ie[n]]})))}var ae=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],ce=[...ae,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function ue(n,e){M(n,F(e,(n=>function(){const e=this.calendar[n](this);return Object.defineProperty(this,n,{value:e}),e})))}function de(n,e){(n.prototype||n)[Symbol.toStringTag]="Temporal."+e}var he=l("offset",{prefer:0,use:1,ignore:2,reject:3});function le({year:n,month:e,day:t},o,r,i){n+=o;const s=f(e,1,r.monthsInYear(n),i);let a=e===s?t:1;return a=f(a,1,r.daysInMonth(n,s),i),{year:n,month:s,day:a}}function fe({year:n,month:e,day:t},o,r,i){if(o){if(e+=o,o<0)for(;e<1;)e+=r.monthsInYear(--n);else{let t;for(;e>(t=r.monthsInYear(n));)e-=t,n++}t=f(t,1,r.daysInMonth(n,e),i)}return{year:n,month:e,day:t}}function me({isoYear:n,isoMonth:e,isoDay:t},o){if(o){let r=pn(n,e,t);r=Yn(r,o),({isoYear:n,isoMonth:e,isoDay:t}=Mn(r))}return{isoYear:n,isoMonth:e,isoDay:t}}function ge(n,e){if(V(e)>=6)throw new RangeError("Duration cant have units >= days");return n+tn(e)}function ye(n,e,t=3,o){const{offsetNanoseconds:r,timeZone:i,Z:s}=n;if(void 0!==r&&2!==t){if(1===t||s)return yn(n)-BigInt(r);{const o=we(n,r,i,e);if(void 0!==o)return o;if(3===t)throw new RangeError("Mismatching offset/timezone")}}return i.getInstantFor(Zo(n),o).epochNanoseconds}function we(n,e,t,o){const r=t.getPossibleInstantsFor(Zo(n)),i=yn(n),s=o?L(e):e;for(const n of r){const e=n.epochNanoseconds,t=Number(i-e);if((o?L(t):t)===s)return e}}function pe(n){const{timeZone:e}=n,t={...n,...X,calendar:new ir("iso8601")},o={...me(t,1),...X,calendar:new ir("iso8601")},r=e.getInstantFor(Zo(t)).epochNanoseconds,i=e.getInstantFor(Zo(o)).epochNanoseconds;return Number(i-r)}var ve="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Me="([+-])"+ve,Ie="(Z|"+Me+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Se=Ye("([+-]\\d{6}|\\d{4})-?(\\d{2})"+Ie),Fe=Ye("(--)?(\\d{2})-?(\\d{2})"+Ie),be=Ye("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Ie),Ne=Ye("T?"+ve+Ie),Te=Ye(Me),Oe=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,De=/\u2212/g;function Ye(n){return new RegExp(`^${n}$`,"i")}function Ee(n){return n.replace(De,"-")}function Ze(n){const e=Be(n);if(!e)throw Ge("dateTime",n);return e}function Ce(n){const e=ke(n);if(!e)throw Ge("dateTime",n);return e}function Ue(n){const e=qe(n);if(void 0===e)throw Ge("timeZone",n);return e}function Pe(n){let e=function(n){const e=Ne.exec(Ee(n));if(e)return Le(e.slice(1))}(n);if(void 0!==e){if("T"!==n.charAt(0)){const t=xe(n)||je(n);t&&function(n){try{return Bn(n,1),!0}catch(n){return!1}}(t)&&(e=void 0)}}else e=ke(n,!0);if(void 0===e)throw Ge("time",n);return e}var Re=/^Z$/i;function Be(n){const e=be.exec(Ee(n));if(e)return function(n){const e=n[11];let t,o=!1;e&&(o=Re.test(e),t=o?0:$e(n.slice(12)));return{...He(n),timeZone:n[21],offsetNanoseconds:t,Z:o}}(e.slice(1))}function ke(n,e,t){const o=be.exec(Ee(n));if(o&&(t||!Re.test(o[12]))&&(!e||o[4]))return He(o.slice(1))}function xe(n){const e=Se.exec(Ee(n));if(e)return{calendar:(t=e.slice(1))[14],isoYear:We(t[0]),isoMonth:We(t[1]),isoDay:1};var t}function je(n){const e=Fe.exec(Ee(n));if(e)return{calendar:(t=e.slice(1))[15],isoYear:gn,isoMonth:We(t[1]),isoDay:We(t[2])};var t}function qe(n){const e=Te.exec(Ee(n));if(e)return $e(e.slice(1))}function He(n){return{calendar:n[23],isoYear:We(n[0]),isoMonth:We(n[1]),isoDay:We(n[2]),...Le(n.slice(4))}}function Le(n){const e=Ae(n[4]);return{...sn(ze(n[6]||""))[0],isoHour:Ae(n[0]),isoMinute:Ae(n[2]),isoSecond:60===e?59:e}}function $e(n){return("+"===n[0]?1:-1)*function(n){return 36e11*Ae(n[0])+6e10*Ae(n[2])+1e9*Ae(n[4])+ze(n[6]||"")}(n.slice(1))}function ze(n){return parseInt(n.padEnd(9,"0"))}function Ae(n){return parseInt(n||"0")}function We(n){return parseInt(n||"1")}function Ke(n){return void 0===n?void 0:parseInt(n)}function Ge(n,e){throw new RangeError(`Cannot parse ${n} '${e}'`)}function Je(n){return{...n,calendar:void 0===n.calendar?sr():new ir(n.calendar)}}function Qe(n){return{...Je(n),timeZone:new ht(n.timeZone)}}var Ve=class{constructor(n){this.id=n}},Xe=class extends Ve{constructor(n,e){super(n),this.offsetNano=e}getPossibleOffsets(){return[this.offsetNano]}getOffset(){return this.offsetNano}getTransition(){}};function _e(n,e){const t={},o=n.formatToParts(e);for(const n of o)t[n.type]=n.value;return t}var nt={bc:"bce",ad:"ce"};function et(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),nt[n]||n}var tt=Intl.DateTimeFormat;function ot(n){return[].concat(n||[])}var rt={"Pacific/Apia":{2011:[[1301752800000000000n,-36e12,-396e11],[1316872800000000000n,-396e11,-36e12],[1325239200000000000n,-36e12,504e11]]}},it=(new Date).getUTCFullYear()+10,st=[182,91,273],at=class extends Ve{constructor(n){const e=new tt("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(e.resolvedOptions().timeZone),this.format=e,this.yearEndOffsets={},this.transitionsInYear=rt[n]||{}}getPossibleOffsets(n){let e;const t=[this.getTransition(n,-1),this.getTransition(n-1n,1)].filter(Boolean);for(const o of t){const[t,r,i]=o,s=n-BigInt(r),a=n-BigInt(i);if(t>s&&t>a)return[r];if(!(t<=s&&t<=a))return[r,i];e=i}return void 0!==e?[e]:[1e9*this.getYearEndOffsetSec(Fn(n))]}getOffset(n){return 1e9*this.getOffsetForEpochSecs(Number(n/t))}getOffsetForEpochSecs(n){const e=_e(this.format,1e3*n);let t=parseInt(e.year);"bce"===et(e.era)&&(t=-(t-1));const o=pn(t,parseInt(e.month),parseInt(e.day),parseInt(e.hour),parseInt(e.minute),parseInt(e.second));return Math.floor(o/1e3)-n}getTransition(n,e){let t=Fn(n);if(t>it){const o=this.getTransitionFrom(t,t+e,e,n);if(o||e>0)return o;t=it}return this.getTransitionFrom(Math.max(t,1847),e<0?1846:it,e,n)}getTransitionFrom(n,e,t,o){for(;n!==e;n+=t){let e=this.getTransitionsInYear(n);t<0&&(e=e.slice().reverse());for(const n of e)if(j(n[0],o)===t)return n}}getYearEndOffsetSec(n){const{yearEndOffsets:e}=this;return e[n]||(e[n]=this.getOffsetForEpochSecs(Sn(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:e}=this;return e[n]||(e[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const e=this.getYearEndOffsetSec(n-1),t=this.getYearEndOffsetSec(n),o=Sn(n)-1,r=Sn(n+1)-1;if(e!==t)return[this.searchTransition(o,r,e,t)];const i=this.searchIsland(e,o);return void 0!==i?[this.searchTransition(o,i[0],e,i[1]),this.searchTransition(i[0],r,i[1],t)]:[]}searchTransition(n,e,o,r){for(;e-n>1;){const t=Math.floor(n+(e-n)/2);this.getOffsetForEpochSecs(t)===o?n=t:e=t}return[BigInt(e)*t,1e9*o,1e9*r]}searchIsland(n,e){for(const t of st){const o=e+86400*t,r=this.getOffsetForEpochSecs(o);if(r!==n)return[o,r]}}},ct={UTC:new Xe("UTC",0)};var[ut,dt]=v(),ht=class extends P{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),dt(this,function(n){const e=(n=String(n)).toLocaleUpperCase();if(ct[e])return ct[e];const t=qe(n);if(void 0!==t){if(Math.abs(t)>s)throw new RangeError("Offset out of bounds");return new Xe(_n(t),t)}return ct[e]=new at(n)}(n))}static from(n){if("object"==typeof n)return function(n){return n.timeZone}(n)?function(n){if("object"==typeof n){if("string"==typeof n.id)return n;throw new RangeError("Invalid timeZone")}return new ht(String(n))}(n.timeZone):n;const e=Be(String(n));if(e){if(e.timeZone){const n=Qe(e);return function(n){const{offsetNanoseconds:e,timeZone:t,Z:o}=n;if(void 0!==e&&!o&&void 0===we(n,e,t,!0))throw new RangeError("Mismatching offset/timezone")}(n),n.timeZone}if(e.Z)return new ht("UTC");if(void 0!==e.offsetNanoseconds)return new ht(_n(e.offsetNanoseconds))}return new ht(n)}get id(){return this.toString()}getOffsetStringFor(n){return _n(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const e=U(Sr,n);return ut(this).getOffset(e.epochNanoseconds)}getPlainDateTimeFor(n,e=sr()){const t=U(Sr,n);return Zo({...vn(t.epochNanoseconds+BigInt(this.getOffsetNanosecondsFor(t))),calendar:U(ir,e)})}getInstantFor(n,e){const t=Kn(e),o=yn(U(Eo,n).getISOFields()),r=ut(this).getPossibleOffsets(o);let i;if(1===r.length||0===t)i=r[0];else{if(3===t)throw new RangeError("Ambiguous offset");i=Math[1===t?"max":"min"](...r)}return new Sr(o-BigInt(i))}getPossibleInstantsFor(n){const e=yn(U(Eo,n).getISOFields());let t=ut(this).getPossibleOffsets(e);return 2===t.length&&t[0]<t[1]&&(t=[]),t.map((n=>new Sr(e-BigInt(n))))}getPreviousTransition(n){const e=U(Sr,n),t=ut(this).getTransition(e.epochNanoseconds,-1);return t?new Sr(t[0]):null}getNextTransition(n){const e=U(Sr,n),t=ut(this).getTransition(e.epochNanoseconds,1);return t?new Sr(t[0]):null}toString(){return ut(this).id}};function lt(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return U(ht,n.timeZone)}de(ht,"TimeZone");var ft=Rt((function(n,e,t){const o=Tt(n,e,t);if(o)return{...o,timeZone:lt(n),offsetNanoseconds:void 0!==n.offset?Ue(String(n.offset)):void 0}})),mt=Rt(Tt),gt=Rt(Ot),yt=Rt((function(n,e){const t=ur(n),o=Ct(n,jn,t);if(Bt(o))return t.yearMonthFromFields(o,e)})),wt=Rt((function(n,e){const t=ur(n),o=Ct(n,Ln,t);if(Bt(o))return void 0===n.year&&void 0===n.calendar&&(o.year=gn),t.monthDayFromFields(o,e)})),pt=Rt(Dt),vt=Rt((function(n,e,t,o){const r=Yt(n,e,t,o),i=void 0!==e.offset;if(r||i)return{...r||n.getISOFields(),timeZone:n.timeZone,offsetNanoseconds:i?Ue(String(e.offset)):n.offsetNanoseconds}}),!0),Mt=Rt(Yt,!0),It=Rt(Et,!0),St=Rt((function(n,e,t){const o=n.calendar;if(Bt(Ct(e,jn,o))){const r=Pt(n,e,jn,o);return o.yearMonthFromFields(r,t)}}),!0),Ft=Rt((function(n,e,t){const o=n.calendar;if(Bt(Ct(e,Ln,o))){const r=Pt(n,e,Ln,o);return o.monthDayFromFields(r,t)}}),!0),bt=Rt(Zt,!0),Nt=Rt((function(n){const e=m(n,$n);if(Bt(e))return e}));function Tt(n,e,t){const o=Ot(n,t),r=Dt(n,e);if(o)return{...o.getISOFields(),...r||X}}function Ot(n,e){const t=ur(n),o=Ct(n,qn,t);if(Bt(o))return t.dateFromFields(o,e)}function Dt(n,e){const t=m(n,Hn);if(Bt(t))return xn(nn(t),e)}function Yt(n,e,t,o){const r=Et(n,e,o),i=Zt(n,e,t);if(r||i)return{...n.getISOFields(),...r?r.getISOFields():{},...i}}function Et(n,e,t){const o=n.calendar,r=Ct(e,qn,o);if(Bt(r)){const e=Pt(n,r,qn,o);return o.dateFromFields(e,t)}}function Zt(n,e,t){const o=m(e,Hn);if(Bt(o)){return xn(nn((r=n,i=o,I(Hn,((n,e)=>i[e]??r[e])))),t)}var r,i}function Ct(n,e,t){let o=Object.keys(e);return o=t.fields?t.fields(o):Object.keys(Ut(t,o)),Ut(n,o)}function Ut(n,e){const t={};for(const o of e)void 0!==n[o]&&(t[o]=n[o]);return t}function Pt(n,e,t,o){const r=Ct(n,t,o);return o.mergeFields?o.mergeFields(r,e):ar(r,e)}function Rt(n,e){return(...t)=>{if(e){const n=t[1];if(!w(n))throw new TypeError("must be object-like");if(void 0!==n.calendar)throw new TypeError("calendar not allowed");if(void 0!==n.timeZone)throw new TypeError("timeZone not allowed")}const o=n(...t);if(!o)throw new TypeError("No valid fields");return o}}function Bt(n){return Object.keys(n).length>0}function kt(n,e){const t=yn(n);xt(t),_o(t,e)}function xt(n){(n<-8640000086399999999999n||n>8640000086399999999999n)&&On()}function jt(n,e){const t=Lt(on(n),e),[o,r]=sn(t);return{...me(n,r),...o}}function qt(n,e){const t=Lt(on(n),e),[o]=sn(t);return o}function Ht(n,e){const[t,o]=function(n){const e=vn(n);return[wn(e.isoYear,e.isoMonth,e.isoDay),on(e)]}(n),r=Lt(o,e);return t+BigInt(r)}function Lt(n,e){return H(n,e.incNano,e.roundingFunc)}function $t(n,e,t){return(o,r)=>{const i=Jt(n,r)?{}:{...n,...e};return{buildKey:Gt(o,r,!1),buildFormat:function(n,e){return new tt(o,{calendar:n,timeZone:e||void 0,...i,...r,...t})},buildEpochMilli:zt}}}function zt(n){return n.epochMilliseconds}function At(n,e,t){return(o,r)=>{const i=Jt(n,r)?{}:n;return{buildKey:Gt(o,r,t),buildFormat:function(n,t){return new tt(o,{calendar:n,...i,...r,...e,timeZone:t,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?Wt.bind(null,new ht(r.timeZone)):Kt}}}function Wt(n,e){const t=Zo({...X,...e.getISOFields()});return n.getInstantFor(t).epochMilliseconds}function Kt(n){return pn((e=n.getISOFields()).isoYear,e.isoMonth,e.isoDay,e.isoHour,e.isoMinute,e.isoSecond,e.isoMillisecond);var e}function Gt(n,e,t){const o=e.calendar??function(n){for(const e of n){const n=e.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),r=e.timeZone;return function(n,e){const i=n.calendar?.id,s=n.timeZone?.id;if(e){if(e.calendar?.id!==i)throw new RangeError("Mismatching calendar");if(e.timeZone?.id!==s)throw new RangeError("Mismatching timeZone")}if((t||"iso8601"!==i)&&void 0!==i&&void 0!==o&&o!==i)throw new RangeError("Non-iso calendar mismatch");if(void 0!==s&&void 0!==r&&r!==s)throw new RangeError("Given timeZone must agree");return[o||i||"iso8601",r||s||"UTC"]}}function Jt(n,e){for(const t in n)if(void 0!==e[t])return!0;return!1}function Qt(n,e){n.prototype.toLocaleString=function(n,t){const o=e(ot(n),t||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[C]=e}function Vt(n){return n?.[C]}function Xt(n){const e=function(n){const e=Oe.exec(Ee(n));if(e){let n,t,o,r;[n,r]=_t(e[8],e[10],5,void 0),[t,r]=_t(e[12],e[14],4,r),[o,r]=_t(e[16],e[18],3,r);const i=function(n){const e={};for(const t in n)void 0!==n[t]&&(e[t]=n[t]);return e}({years:Ke(e[2]),months:Ke(e[3]),weeks:Ke(e[4]),days:Ke(e[5]),hours:n,minutes:t,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=rn(BigInt(r||0),2);i.milliseconds=s.milliseconds,i.microseconds=s.microseconds,i.nanoseconds=s.nanoseconds;let a=J(i);return"-"===e[1]&&(a=K(a)),a}}(n);if(void 0===e)throw Ge("duration",n);return e}function _t(n,e,t,o){if(void 0!==n){if(void 0!==o)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==e?ze(e)*(a[t]/1e9):void 0]}if(void 0!==o){const n=Math.trunc(o/a[t]);return[n,o-n*a[t]]}return[void 0,void 0]}var no=l("offset",{auto:0,never:1},0),eo=class extends x{constructor(n=0,e=0,t=0,o=0,r=0,i=0){super({...xn({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},1),calendar:sr()})}static from(n,e){const t=h(e);return to(n instanceof eo?n.getISOFields():"object"==typeof n?pt(n,t):Pe(String(n)))}static compare(n,e){return Cn(U(eo,n),U(eo,e))}with(n,e){return to(bt(this,n,h(e)))}add(n){return ro(this,U(Oo,n))}subtract(n){return ro(this,K(U(Oo,n)))}until(n,e){return io(this,U(eo,n),e)}since(n,e){return io(U(eo,n),this,e)}round(n){const e=Z(n,void 0,0,5);return to(qt(this.getISOFields(),e))}equals(n){return!Cn(this,U(eo,n))}toString(n){const e=Wn(n);return Xn(qt(this.getISOFields(),e),e)}toZonedDateTime(n){const e=U(fr,n.plainDate),t=U(ht,n.timeZone);return go({...e.getISOFields(),...this.getISOFields(),timeZone:t})}toPlainDateTime(n){return U(fr,n).toPlainDateTime(this)}};function to(n){return new eo(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function oo(n){return U(eo,n??{hour:0})}function ro(n,e){return to(function(n,e){const t=on(n)+Number(tn(e)),[o]=sn(t);return o}(n.getISOFields(),e))}function io(n,e,t){const o=E(t,5,0,0,5);return Do(function(n,e,t){const o=H(on(e)-on(n),a[t.smallestUnit]*t.roundingIncrement,t.roundingFunc);return rn(BigInt(o),t.largestUnit)}(n.getISOFields(),e.getISOFields(),o))}de(eo,"PlainTime"),se(eo,b),Qt(eo,(function(n,e){return{buildKey:()=>["",""],buildFormat:()=>new tt(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...e,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Math.trunc(on(n.getISOFields())/1e6)}}));var so={day:1},ao=class extends x{constructor(n,e,t=sr(),o=1){const r=Bn({isoYear:n,isoMonth:e,isoDay:o},1),i=U(ir,t);var s,a;s=r,a=i.id,_o(yn(s),a),super({...r,calendar:i})}static from(n,e){if(h(e),n instanceof ao)return co(n.getISOFields());if("object"==typeof n)return yt(n,e);const t=function(n){const e=xe(n)||ke(n);if(!e)throw Ge("yearMonth",n);return e}(String(n));return void 0===t.calendar&&(t.isoDay=1),co(Je(t))}static compare(n,e){return Zn(U(ao,n),U(ao,e))}with(n,e){return St(this,n,e)}add(n,e){return uo(this,U(Oo,n),e)}subtract(n,e){return uo(this,K(U(Oo,n)),e)}until(n,e){return ho(this,U(ao,n),!1,e)}since(n,e){return ho(this,U(ao,n),!0,e)}equals(n){return!Zn(this,U(ao,n))}toString(n){const e=this.getISOFields(),t=e.calendar.toString(),o=An(n);return("iso8601"===t?Vn(e):Qn(e))+ne(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}};function co(n){return new ao(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function uo(n,e,t){return n.toPlainDate({day:e.sign<0?n.daysInMonth:1}).add(e,t).toPlainYearMonth()}function ho(n,e,t,o){return Do(wr(n.toPlainDate(so),e.toPlainDate(so),dr(n,e),t,E(o,9,8,8,9)))}de(ao,"PlainYearMonth"),se(ao),ue(ao,ae),Qt(ao,At({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));var[lo,fo]=v(),mo=class extends x{constructor(n,e,t=sr()){const o=U(ht,e),r=U(ir,t),[i,s]=yo(n,o);kt(i,r.id),super({...i,calendar:r,timeZone:o,offset:_n(s)}),fo(this,{epochNanoseconds:n,offsetNanoseconds:s})}static from(n,e){const t=he(e,3),o=h(e);if(n instanceof mo)return new mo(n.epochNanoseconds,n.timeZone,n.calendar);const r="object"==typeof n;return go(r?ft(n,o,e):Qe(Ze(String(n))),!r,t,e)}static compare(n,e){return Pn(U(mo,n),U(mo,e))}get timeZone(){return this.getISOFields().timeZone}get epochNanoseconds(){return lo(this).epochNanoseconds}get offsetNanoseconds(){return lo(this).offsetNanoseconds}get offset(){return this.getISOFields().offset}with(n,e){Kn(e);const t=h(e),o=he(e,0);return go(vt(this,n,t,e),!1,o,e)}withPlainDate(n){const e=U(fr,n),t=e.toPlainDateTime(this),{timeZone:o}=this,r=o.getInstantFor(t);return new mo(r.epochNanoseconds,o,hr(this,e))}withPlainTime(n){return go({...this.getISOFields(),...void 0===n?X:U(eo,n).getISOFields()})}withCalendar(n){return new mo(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new mo(this.epochNanoseconds,n,this.calendar)}add(n,e){return wo(this,U(Oo,n),e)}subtract(n,e){return wo(this,K(U(Oo,n)),e)}until(n,e){return vo(this,U(mo,n),!1,e)}since(n,e){return vo(this,U(mo,n),!0,e)}round(n){return po(this,Z(n,void 0,0,6))}equals(n){return En(this,U(mo,n))}startOfDay(){return go({...this.getISOFields(),...X,offsetNanoseconds:this.offsetNanoseconds},!1,0)}get hoursInDay(){return pe(this.getISOFields())/36e11}toString(n){const e=Wn(n),t=no(n),o=Gn(n),r=An(n),i=po(this,e);return Jn(i.getISOFields(),e)+(0===t?_n(L(i.offsetNanoseconds)):"")+(s=this.timeZone.toString(),1!==o?`[${s}]`:"")+ne(this.calendar.toString(),r);var s}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return Zo(this.getISOFields())}toPlainDate(){return mr(this.getISOFields())}toPlainTime(){return to(this.getISOFields())}toInstant(){return new Sr(this.epochNanoseconds)}};function go(n,e,t,o){const r=ye(n,e,t,o);return new mo(r,n.timeZone,n.calendar)}function yo(n,e){const t=new Sr(n),o=e.getOffsetNanosecondsFor(t);return[vn(n+BigInt(o)),o]}function wo(n,e,t){const o=n.getISOFields(),r=function(n,e,t){const{calendar:o,timeZone:r}=n,i=o.dateAdd(mr(n),G(e,_),t),s=Zo({...n,...i.getISOFields()});return r.getInstantFor(s).epochNanoseconds+tn(e)}(o,e,t);return new mo(r,o.timeZone,o.calendar)}function po(n,e){const t=n.getISOFields(),o=function(n,e,t){const{calendar:o,timeZone:r}=n;let i,s,a=on(n);return 6===t.smallestUnit?(i=X,s=t.roundingFunc(a/pe(n))):(a=Lt(a,t),[i,s]=sn(a)),ye({...me(n,s),...i,offsetNanoseconds:e,calendar:o,timeZone:r},!1,0)}(t,n.offsetNanoseconds,e);return new mo(o,t.timeZone,t.calendar)}function vo(n,e,t,o){const r=E(o,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==e.timeZone.id)throw new Error("Must be same timeZone");return Do(yr(n,e,dr(n,e),t,r))}function Mo(n){if(void 0===n)return;if(w(n))return n instanceof mo||n instanceof Eo?n:U(void 0!==n.timeZone?mo:Eo,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const e=Be(String(n));if(e)return void 0!==e.timeZone?go(Qe(e),!0):Zo(Je(e));throw new RangeError("Invalid value of relativeTo")}function Io(n,e,t,o){return(t instanceof fr?function(n,e,t,o){const r=t.add(n);return[o.dateUntil(t,r,{largestUnit:N[e]}),r]}(n,Math.max(6,e),t,o):So(n,e,t,o))[0]}function So(n,e,t,o,r){const i=!0!==r&&e>7&&n.weeks;i&&(n=G(n,{weeks:0}));let s=t.add(n),a=pr(t,s,o,e);return i&&(a=G(a,{weeks:i}),s=s.add({weeks:i})),[a,s]}function Fo(n,e,t,o){const r=T[e],{sign:i}=n;if(!i)return n;const s={};for(let t=9;t>=e;t--){const e=T[t];s[e]=n[e]}const a={[r]:i},c=t.add(s),u=c.add(a),d=In(c),h=In(u),l=In(o),f=Number(l-d)/Number(h-d)*i;return s[r]+=f,s}function bo(n,e,t,o,r,i){const{largestUnit:s,smallestUnit:c,roundingIncrement:u,roundingFunc:h}=i;if(!d(s)){return rn(z((In(t)-In(e))*(r?-1n:1n),a[c]*u,h),s)}let l=Fo(n,c,e,t);const f=T[c];function m(){const n=l[f];l[f]=H(n,u,h)}return h===Math.round&&m(),r&&(l=K(l)),h!==Math.round&&m(),c>0&&(l=r?K(Io(K(l),s,e,o)):Io(l,s,e,o)),l}de(mo,"ZonedDateTime"),se(mo,b),ue(mo,ce),oe(mo),Qt(mo,$t({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));var[No,To]=v(),Oo=class extends R{constructor(n=0,e=0,t=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super();const d=Nt({years:n,months:e,weeks:t,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u});To(this,function(n){const e=J(n),{sign:t}=e;for(const n of T){const o=e[n],r=q(e[n]);if(r&&r!==t)throw new RangeError("All fields must be same sign");if(!Number.isInteger(o))throw new RangeError("Duration fields must be integers")}return e}(d))}static from(n){return Do("object"==typeof n?Nt(n):Xt(n))}static compare(n,e,t){return function(n,e,t){if(void 0===t&&V(n)<=6&&V(e)<=6)return j(en(n),en(e));if(!t)throw new RangeError("Need relativeTo");const o=t.add(n),r=t.add(e);return void 0!==t.epochNanoseconds?Pn(o,r):Zn(o,r)}(U(Oo,n),U(Oo,e),Mo(g(t).relativeTo))}get years(){return No(this).years}get months(){return No(this).months}get weeks(){return No(this).weeks}get days(){return No(this).days}get hours(){return No(this).hours}get minutes(){return No(this).minutes}get seconds(){return No(this).seconds}get milliseconds(){return No(this).milliseconds}get microseconds(){return No(this).microseconds}get nanoseconds(){return No(this).nanoseconds}get sign(){return No(this).sign}get blank(){return!this.sign}with(n){return Do({...No(this),...Nt(n)})}negated(){return Do(K(No(this)))}abs(){return Do(S(No(this),W,(n=>Math.abs(n))))}add(n,e){return Yo(this,U(Oo,n),e)}subtract(n,e){return Yo(this,K(U(Oo,n)),e)}round(n){const e="string"==typeof n?{smallestUnit:n}:n;if(!w(e))throw new TypeError("Must specify options");if(void 0===e.largestUnit&&void 0===e.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const t=E(e,V(this),0,0,9,!0),o=Mo(e.relativeTo);return Do(function(n,e,t,o){const{largestUnit:r,smallestUnit:i,roundingIncrement:s,roundingFunc:c}=e;if(void 0===t&&V(n)<=6&&u(r)&&u(i))return rn(z(en(n),a[i]*s,c),r);if(!t)throw new RangeError("Need relativeTo");const[d,h]=So(n,r,t,o);return bo(d,t,h,o,!1,e)}(this,t,o,o?o.calendar:void 0))}total(n){const e=function(n){let e,t;return"string"==typeof n?t=n:(t=g(n).unit,e=n.relativeTo),{unit:Y(t,void 0,0,9),relativeTo:e}}(n),t=Mo(e.relativeTo);return function(n,e,t,o){if(void 0===t&&V(n)<=6&&u(e))return Number(en(n))/a[e];if(!t)throw new RangeError("Need relativeTo");const[r,i]=So(n,e,t,o,!0);return Fo(r,e,t,i)[T[e]]}(this,e.unit,t,t?t.calendar:void 0)}toString(n){const e=Wn(n,3);return function(n,e){const{smallestUnit:t,fractionalSecondDigits:o,roundingFunc:r}=e,{sign:i}=n,s=BigInt(n.hours),a=BigInt(n.minutes);let c=BigInt(n.seconds),u="";if(t<=3){const e=te(n.milliseconds,n.microseconds,n.nanoseconds,o,r,t);u=e[0],c+=BigInt(e[1])}const d=void 0!==o||u||!i;return(i<0?"-":"")+"P"+ee([[BigInt(n.years),"Y"],[BigInt(n.months),"M"],[BigInt(n.weeks),"W"],[BigInt(n.days),"D"]])+(s||a||c||d?"T"+ee([[s,"H"],[a,"M"],[t<=3?c:BigInt(0),u+"S",d]]):"")}(No(this),e)}toLocaleString(n,e){return this.toString()}};function Do(n){return new Oo(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function Yo(n,e,t){const o=Mo(g(t).relativeTo);return Do(function(n,e,t,o){const r=Math.max(V(n),V(e));if(void 0===t&&r<=6)return rn(en(n)+en(e),r);if(!t)throw new RangeError("Need relativeTo");const i=t.add(n).add(e);return pr(t,i,o,r)}(n,e,o,o?o.calendar:void 0))}de(Oo,"Duration");var Eo=class extends x{constructor(n,e,t,o=0,r=0,i=0,s=0,a=0,c=0,u=sr()){const d=kn({isoYear:n,isoMonth:e,isoDay:t,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:c},1),h=U(ir,u);kt(d,h.id),super({...d,calendar:h})}static from(n,e){const t=h(e);return Zo(n instanceof Eo?n.getISOFields():"object"==typeof n?mt(n,t,e):Je(Ce(String(n))))}static compare(n,e){return Zn(U(Eo,n),U(Eo,e))}with(n,e){const t=h(e);return Zo(Mt(this,n,t,e))}withPlainDate(n){const e=U(fr,n);return Zo({...this.getISOFields(),...e.getISOFields(),calendar:hr(this,e)})}withPlainTime(n){return Zo({...this.getISOFields(),...oo(n).getISOFields()})}withCalendar(n){return Zo({...this.getISOFields(),calendar:U(ir,n)})}add(n,e){return Co(this,U(Oo,n),e)}subtract(n,e){return Co(this,K(U(Oo,n)),e)}until(n,e){return Uo(this,U(Eo,n),!1,e)}since(n,e){return Uo(this,U(Eo,n),!0,e)}round(n){const e=Z(n,void 0,0,6);return Zo({...jt(this.getISOFields(),e),calendar:this.calendar})}equals(n){return!Zn(this,U(Eo,n))}toString(n){const e=Wn(n),t=An(n);return Jn(jt(this.getISOFields(),e),e)+ne(this.calendar.toString(),t)}toZonedDateTime(n,e){const t=U(ht,n),o=t.getInstantFor(this,e);return new mo(o.epochNanoseconds,t,this.calendar)}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return mr(this.getISOFields())}toPlainTime(){return to(this.getISOFields())}};function Zo(n){return new Eo(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function Co(n,e,t){const o=function(n,e,t){const{calendar:o}=n;return vn(yn(o.dateAdd(mr(n),G(e,_),t).getISOFields())+BigInt(on(n))+tn(e))}(n.getISOFields(),e,t);return Zo({...o,calendar:n.calendar})}function Uo(n,e,t,o){const r=E(o,6,0,0,9);return Do(yr(n,e,dr(n,e),t,r))}de(Eo,"PlainDateTime"),se(Eo,b),ue(Eo,ce),Qt(Eo,At({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));var Po=class extends x{constructor(n,e,t=sr(),o=gn){super({...Bn({isoYear:o,isoMonth:n,isoDay:e},1),calendar:t})}static from(n,e){if(h(e),n instanceof Po)return Ro(n.getISOFields());if("object"==typeof n)return wt(n,e);const t=function(n){const e=je(n)||ke(n);if(!e)throw Ge("monthDay",n);return e}(String(n));return void 0===t.calendar&&(t.isoYear=gn),Ro(Je(t))}with(n,e){return Ft(this,n,e)}equals(n){return!Zn(this,U(Po,n))}toString(n){const e=this.getISOFields(),t=e.calendar.toString(),o=An(n);return("iso8601"===t?function(n){return an(n.isoMonth,2)+"-"+an(n.isoDay,2)}(e):Qn(e))+ne(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},{overflow:"reject"})}};function Ro(n){return new Po(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function Bo(n){return n instanceof fr||n instanceof Eo||n instanceof mo||n instanceof ao||n instanceof Po}function ko(n,e,t){let o;if(n instanceof fr)o=n;else if(Bo(n)){if(t&&n instanceof Po)throw new TypeError("PlainMonthDay not allowed");o=mr(n.getISOFields())}else o=fr.from(n);return lr(o.calendar,e),o}function xo(n,e,t){if(Bo(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;const u=void 0!==r&&void 0!==o?hn(e.id,r,o):void 0;if(void 0===i){if(void 0===u)throw new TypeError("Must specify either a year or an era & eraYear");i=u}else if(void 0!==u&&u!==i)throw new RangeError("year and era/eraYear must match");if(void 0===c)throw new TypeError("Must specify day");const d=h(t);if(void 0!==a){const[n,t]=e.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,t){if(1===d)throw new RangeError("Month code out of range");c=e.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,c]=Rn(i,s,c,e,d),Mn(e.epochMilliseconds(i,s,c))}function jo(n,e){if(Bo(n)){if(e&&n instanceof Po)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return fr.from(n).getISOFields()}function qo(n,e){return Dn(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e+1,1,1))}function Ho(n,e,t,o){return Dn(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e,t,o))+1}de(Po,"PlainMonthDay"),se(Po),ue(Po,["monthCode","day"]),Qt(Po,At({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));var Lo={hebrew:6,chinese:0,dangi:0},$o=class extends dn{constructor(n){const e=zo(n);if(t=n,o=e.resolvedOptions().calendar,ln(t)!==ln(o))throw new RangeError("Invalid calendar: "+n);var t,o;super(n),this.format=e,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,e,t){return Yn(this.queryMonthCache(n)[0][e-1],t-1)}daysInMonth(n,e){const t=this.queryMonthCache(n)[0],o=t[e-1];e>=t.length&&(n++,e=0);return Dn(o,this.queryMonthCache(n)[0][e])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,e){const t=this.queryLeapMonthByYear(e);return!t||n<t?super.monthCode(n,e):super.monthCode(n-1,e)+(n===t?"L":"")}convertMonthCode(n,e){const t=this.queryLeapMonthByYear(e);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=Lo[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||t&&r===t-1||(i=!0,o=!1),(o||t&&r>=t)&&r++,[r,i]}inLeapYear(n){const e=qo(this,n);return e>qo(this,n-1)&&e>qo(this,n+1)}guessYearForMonthDay(n,e){let t=1970+this.yearCorrection;const o=t+100;for(;t<o;t++){const[o,r]=this.convertMonthCode(n,t);if(!r&&o<=this.monthsInYear(t)&&e<=this.daysInMonth(t,o))return t}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const e=this.computeFieldsDumb(n),t=this.queryMonthCache(e.year)[2];return{...e,month:t[e.month]}}computeFieldsDumb(n){const e=_e(this.format,n);let t,o,r=parseInt(e.relatedYear||e.year);var i;return e.era&&(i=this.id,void 0!==un[ln(i)])&&(t=et(e.era),o=r,r=hn(this.id,o,t,!0)),{era:t,eraYear:o,year:r,month:e.month,day:parseInt(e.day)}}queryLeapMonthByYear(n){const e=this.queryMonthCache(n),t=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(e[0].length>t[0].length&&e[0].length>o[0].length){const n=e[1],o=t[1];for(let e=0;e<o.length;e++)if(o[e]!==n[e])return e+1}}queryMonthCache(n){const{monthCacheByYear:e}=this;return e[n]||(e[n]=this.buildMonthCache(n))}buildMonthCache(n){const e=[],t=[],o={};let r=pn(this.guessISOYear(n),1,1);for(r=Yn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=Yn(r,1-o.day),o.year===n&&(e.unshift(r),t.unshift(o.month)),r=Yn(r,-1)}for(let n=0;n<t.length;n++)o[t[n]]=n+1;return[e,t,o]}guessISOYear(n){return n-this.yearCorrection}};function zo(n){return new tt("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}var Ao=pn(1868,9,8),Wo={gregory:zn,japanese:class extends zn{constructor(){super(...arguments),this.format=zo("japanese")}computeFields(n){const e=super.computeFields(n);if(n>=Ao){const t=_e(this.format,n);e.era=et(t.era),e.eraYear=parseInt(t.relatedYear||t.year)}return e}},islamic:class extends $o{guessISOYear(n){return Math.ceil(32*n/33+622)}}},Ko={iso8601:mn};function Go(n){const e=(n=String(n)).toLocaleLowerCase();return Ko[e]||(Ko[e]=new(Wo[ln(e)]||$o)(n))}var Jo=pn(1582,10,15),Qo=pn(622,7,18),Vo={buddhist:Jo,japanese:Jo,roc:Jo,islamic:Qo,"islamic-rgsa":Qo,indian:0},Xo={};function _o(n,t){return nr(Number(n/e),t)}function nr(n,e){if(function(n,e){return function(n){let e=Xo[n];if(void 0===e){const t=Vo[n];if(void 0===t)e=!1;else{let o=Go(n);o instanceof $o||(o=new $o(n));const r=t-864e5,i=o.computeFields(r);e=r!==o.epochMilliseconds(i.year,i.month,i.day)}Xo[n]=e}return e}(e)&&n<Vo[e]}(n,e))throw new RangeError("Invalid timestamp for calendar")}function er(n,e,t){const o=7+e-t;return-A(bn(n,1,o)-e,7)+o-1}function tr(n,e,t){const o=er(n,e,t),r=er(n+1,e,t);return(qo(mn,n)-o+r)/7}var[or,rr]=v(),ir=class extends P{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),rr(this,Go(n))}static from(n){if("object"==typeof n&&n)return function(n){return n.calendar}(n)?function(n){if("object"==typeof n&&n){if("string"==typeof n.id)return n;throw new RangeError("Invalid calendar")}return new ir(String(n))}(n.calendar):n;const e=ke(String(n),!1,!0);return new ir(e?e.calendar||"iso8601":n)}get id(){return this.toString()}era(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).era}eraYear(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).eraYear}year(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).year}month(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).month}monthCode(n){const e=ko(n,this);return or(this).monthCode(e.month,e.year)}day(n){const e=jo(n);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).day}dayOfWeek(n){const e=jo(n,!0);return bn(e.isoYear,e.isoMonth,e.isoDay)}dayOfYear(n){const e=ko(n,this,!0);return Ho(or(this),e.year,e.month,e.day)}weekOfYear(n){const e=jo(n,!0);return function(n,e,t,o,r){const i=er(n,o,r),s=Math.floor((Ho(mn,n,e,t)-i-1)/7)+1;if(s<1)return s+tr(n-1,o,r);const a=tr(n,o,r);return s>a?s-a:s}(e.isoYear,e.isoMonth,e.isoDay,1,4)}daysInWeek(n){return jo(n,!0),7}daysInMonth(n){const e=ko(n,this,!0);return or(this).daysInMonth(e.year,e.month)}daysInYear(n){const e=ko(n,this,!0);return qo(or(this),e.year)}monthsInYear(n){const e=ko(n,this,!0);return or(this).monthsInYear(e.year)}inLeapYear(n){return or(this).inLeapYear(this.year(n))}dateFromFields(n,e){const t=xo(m(n,qn),or(this),e);return new fr(t.isoYear,t.isoMonth,t.isoDay,this)}yearMonthFromFields(n,e){const t=xo({...m(n,jn),day:1},or(this),e);return new ao(t.isoYear,t.isoMonth,this,t.isoDay)}monthDayFromFields(n,e){const t=or(this),o=m(n,Ln);let{era:r,eraYear:i,year:s,month:a,monthCode:c,day:u}=o;if(void 0===u)throw new TypeError("required property 'day' missing or undefined");if(void 0!==c?s=gn:void 0!==r&&void 0!==i&&(s=hn(t.id,i,r)),void 0===s){if(void 0===c)throw new TypeError("either year or monthCode required with month");s=t.guessYearForMonthDay(c,u)}const d=xo({year:s,month:a,monthCode:c,day:u},t,e);return new Po(d.isoMonth,d.isoDay,this,t.normalizeISOYearForMonthDay(d.isoYear))}dateAdd(n,e,t){const o=or(this),r=function(n,e,t,o){n=fe(n=le(n,e.years,t,o),e.months,t,o);let r=t.epochMilliseconds(n.year,n.month,n.day);const i=Math.trunc(Number(tn(e))/s);return r=Yn(r,7*e.weeks+e.days+i),Mn(r)}(U(fr,n,t),U(Oo,e),o,h(t));return new fr(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,e,t){const o=or(this),r=U(fr,n),i=U(fr,e),s=Y(g(t).largestUnit,6,6,9);return lr(this,dr(r,i)),Do(function(n,e,t,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,e,t){const[,o,r]=Rn(e.year,n.month,n.day,t,0),i=Un(e,n),s=j(e.month,o)||j(e.day,r);return e.year-n.year-(s&&i&&s!==i?i:0)}(n,e,t),n=le(n,r,t,0);case 8:i=function(n,e,t){let o=0;const r=Un(e,n);if(r){let{year:i}=n;for(;i!==e.year;)o+=t.monthsInYear(i)*r,i+=r;const[,s,a]=Rn(e.year,n.month,n.day,t,0);o+=e.month-s;const c=j(e.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,e,t),n=fe(n,i,t,0)}a=Dn(t.epochMilliseconds(n.year,n.month,n.day),t.epochMilliseconds(e.year,e.month,e.day)),7===o&&(s=Math.trunc(a/7),a%=7);return J({years:r,months:i,weeks:s,days:a,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0})}(r,i,o,s))}fields(n){return n.slice()}mergeFields(n,e){return ar(n,e)}toString(){return or(this).id}};function sr(){return new ir("iso8601")}function ar(n,e){const t={...n,...e};if(void 0!==n.year){delete t.era,delete t.eraYear,delete t.year;let o=!1;void 0===e.era&&void 0===e.eraYear||(t.era=e.era,t.eraYear=e.eraYear,o=!0),void 0!==e.year&&(t.year=e.year,o=!0),o||(t.year=n.year)}if(void 0!==n.monthCode){delete t.monthCode,delete t.month;let o=!1;void 0!==e.month&&(t.month=e.month,o=!0),void 0!==e.monthCode&&(t.monthCode=e.monthCode,o=!0),o||(t.monthCode=n.monthCode)}return void 0!==n.day&&(t.day=e.day??n.day),t}function cr(n,e,t,o){const r=pn(e,t,o);return nr(r,n.id),n.computeFields(r)}function ur(n){return void 0===n.calendar?sr():U(ir,n.calendar)}function dr(n,e){const{calendar:t}=n;return lr(t,e.calendar),t}function hr(n,e){const t=n.calendar,o=e.calendar;if("iso8601"===t.id)return o;if("iso8601"===o.id)return t;if(t.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return t}function lr(n,e){if(n.id!==e.id)throw new RangeError("Calendars must match")}de(ir,"Calendar");var fr=class extends x{constructor(n,e,t,o=sr()){const r=Bn({isoYear:n,isoMonth:e,isoDay:t},1),i=U(ir,o);!function(n,e){const t=yn(n);xt(t+(t<0n?86399999999999n:0n)),_o(t,e)}(r,i.id),super({...r,calendar:i})}static from(n,e){return h(e),n instanceof fr?mr(n.getISOFields()):"object"==typeof n?gt(n,e):mr(Je(Ce(String(n))))}static compare(n,e){return Zn(U(fr,n),U(fr,e))}with(n,e){return It(this,n,e)}withCalendar(n){const e=this.getISOFields();return new fr(e.isoYear,e.isoMonth,e.isoDay,n)}add(n,e){return this.calendar.dateAdd(this,n,e)}subtract(n,e){return this.calendar.dateAdd(this,U(Oo,n).negated(),e)}until(n,e){return gr(this,U(fr,n),!1,e)}since(n,e){return gr(this,U(fr,n),!0,e)}equals(n){return!Zn(this,U(fr,n))}toString(n){const e=An(n),t=this.getISOFields();return Qn(t)+ne(t.calendar.toString(),e)}toZonedDateTime(n){const e=function(n){let e,t;if("string"==typeof n)t=n;else{if("object"!=typeof n)throw new TypeError("Invalid options/timeZone argument");if(void 0!==n.id?t=n:(t=n.timeZone,e=n.plainTime),void 0===t)throw new TypeError("Invalid timeZone argument")}return{plainTime:e,timeZone:t}}(n),t=U(ht,e.timeZone),o=void 0===e.plainTime?void 0:U(eo,e.plainTime);return go({...this.getISOFields(),...o?o.getISOFields():X,timeZone:t})}toPlainDateTime(n){return Zo({...this.getISOFields(),...oo(n).getISOFields()})}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}};function mr(n){return new fr(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function gr(n,e,t,o){return Do(wr(n,e,dr(n,e),t,E(o,6,6,6,9)))}function yr(n,e,t,o,r){return bo(pr(n,e,t,r.largestUnit),n,e,t,o,r)}function wr(n,e,t,o,r){return bo(t.dateUntil(n,e,{largestUnit:N[r.largestUnit]}),n,e,t,o,r)}function pr(n,e,t,o){if(!d(o))return vr(n,e,o);const r=mr({...n.getISOFields(),calendar:t});let i,s,a,c,u,h=mr({...e.getISOFields(),calendar:t});do{s=t.dateUntil(r,h,{largestUnit:N[o]}),i=n.add(s),a=vr(i,e,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(h=h.add({days:u})));return f=a,{sign:(l=s).sign||f.sign,years:l.years+f.years,months:l.months+f.months,weeks:l.weeks+f.weeks,days:l.days+f.days,hours:l.hours+f.hours,minutes:l.minutes+f.minutes,seconds:l.seconds+f.seconds,milliseconds:l.milliseconds+f.milliseconds,microseconds:l.microseconds+f.microseconds,nanoseconds:l.nanoseconds+f.nanoseconds};var l,f}function vr(n,e,t){return rn(In(e)-In(n),t)}de(fr,"PlainDate"),se(fr),ue(fr,ce),Qt(fr,At({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));var[Mr,Ir]=v(),Sr=class extends R{constructor(n){if(super(),"number"==typeof n)throw new TypeError("Must supply bigint, not number");var e;n=BigInt(n),((e=n)<-8640000000000000000000n||e>8640000000000000000000n)&&On(),Ir(this,n)}static from(n){if(n instanceof Sr)return new Sr(n.epochNanoseconds);const e=Ze(String(n)),t=e.offsetNanoseconds;if(void 0===t)throw new RangeError("Must specify an offset");return new Sr(yn(kn(e,1))-BigInt(t))}static fromEpochSeconds(n){return new Sr(BigInt(n)*t)}static fromEpochMilliseconds(n){return new Sr(BigInt(n)*e)}static fromEpochMicroseconds(e){return new Sr(e*n)}static fromEpochNanoseconds(n){return new Sr(n)}static compare(n,e){return Pn(U(Sr,n),U(Sr,e))}get epochNanoseconds(){return Mr(this)}add(n){return new Sr(ge(this.epochNanoseconds,U(Oo,n)))}subtract(n){return new Sr(ge(this.epochNanoseconds,K(U(Oo,n))))}until(n,e){return Fr(this,U(Sr,n),e)}since(n,e){return Fr(U(Sr,n),this,e)}round(n){const e=Z(n,void 0,0,5,!0);return new Sr(Ht(this.epochNanoseconds,e))}equals(n){return!Pn(this,U(Sr,n))}toString(n){const e=g(n).timeZone;return this.toZonedDateTimeISO(e??"UTC").toString({...n,offset:void 0===e?"never":"auto",timeZoneName:"never"})+(void 0===e?"Z":"")}toZonedDateTimeISO(n){return new mo(this.epochNanoseconds,n)}toZonedDateTime(n){if(!w(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new mo(this.epochNanoseconds,n.timeZone,n.calendar)}};function Fr(n,e,t){const o=E(t,3,0,0,5);return Do(function(n,e,t){return rn(z(e-n,a[t.smallestUnit]*t.roundingIncrement,t.roundingFunc),t.largestUnit)}(n.epochNanoseconds,e.epochNanoseconds,o))}de(Sr,"Instant"),oe(Sr),Qt(Sr,$t({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));var br=Symbol(),Nr=Symbol(),Tr=Symbol(),Or=class extends tt{constructor(n,e){const t=ot(n),o=function(n){const e={};for(const t in n){let o=n[t];w(o)&&(o=o.toString()),e[t]=o}return e}(e||{});super(t,o),this[br]=t,this[Nr]=o,this[Tr]=new Map}format(n){const e=Dr(this,n);return e[0]===this?super.format(n):e[0].format(e[1])}formatToParts(n){return super.formatToParts.call(...Dr(this,n))}formatRange(n,e){return super.formatRange.call(...Yr(this,n,e))}formatRangeToParts(n,e){return super.formatRangeToParts.call(...Yr(this,n,e))}};function Dr(n,e){const t=Vt(e);if(t){const o=Er(n,t);return[o.buildFormat(e),o.buildEpochMilli(e)]}return[n,e]}function Yr(n,e,t){const o=Vt(e);if(o!==Vt(t))throw new TypeError("Mismatch of types");if(o){const r=Er(n,o);return[r.buildFormat(e,t),r.buildEpochMilli(e),r.buildEpochMilli(t)]}return[n,e,t]}function Er(n,e){const t=n[Tr];let o=t.get(e);return o||(o=function(n){const e={};return{buildFormat:function(t,o){const r=n.buildKey(t,o),i=r.join("|");return e[i]||(e[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(e(n[br],n[Nr])),t.set(e,o)),o}var Zr={zonedDateTimeISO:function(n){return go(Ur("iso8601",n))},zonedDateTime:function(n,e){return go(Ur(n,e))},plainDateTimeISO:function(n){return Zo(Ur("iso8601",n))},plainDateTime:function(n,e){return Zo(Ur(n,e))},plainDateISO:function(n){return mr(Ur("iso8601",n))},plainDate:function(n,e){return mr(Ur(n,e))},plainTimeISO:function(n){return to(Ur("iso8601",n))},instant:function(){return new Sr(Pr())},timeZone:Cr};function Cr(){return new ht((new tt).resolvedOptions().timeZone)}function Ur(n,e=Cr()){const t=U(ht,e);return{...yo(Pr(),t)[0],timeZone:t,calendar:U(ir,n)}}function Pr(){return BigInt(Date.now())*e}de(Zr,"Now"),globalThis.Temporal||(globalThis.Temporal={PlainYearMonth:ao,PlainMonthDay:Po,PlainDate:fr,PlainTime:eo,PlainDateTime:Eo,ZonedDateTime:mo,Instant:Sr,Calendar:ir,TimeZone:ht,Duration:Oo,Now:Zr},globalThis.Date.prototype.toTemporalInstant=function(){return n=this,Sr.fromEpochMilliseconds(n.valueOf());var n},globalThis.Intl.DateTimeFormat=Or);
//# sourceMappingURL=global.js.map

@@ -13,2 +13,56 @@ declare abstract class AbstractObj {

interface LocalYearFields {
year: number;
}
interface LocalYearMonthFields extends LocalYearFields {
month: number;
}
interface LocalDateFields extends LocalYearMonthFields {
day: number;
}
interface LocalTimeFields {
hour: number;
minute: number;
second: number;
millisecond: number;
microsecond: number;
nanosecond: number;
}
interface ISOYearFields {
isoYear: number;
}
interface ISOYearMonthFields extends ISOYearFields {
isoMonth: number;
}
interface ISODateFields extends ISOYearMonthFields {
isoDay: number;
}
interface ISOTimeFieldsMilli {
isoHour: number;
isoMinute: number;
isoSecond: number;
isoMillisecond: number;
}
interface ISOTimeFields extends ISOTimeFieldsMilli {
isoMicrosecond: number;
isoNanosecond: number;
}
interface DurationTimeFields {
hours: number;
minutes: number;
seconds: number;
milliseconds: number;
microseconds: number;
nanoseconds: number;
}
interface UnsignedDurationFields extends DurationTimeFields {
years: number;
months: number;
weeks: number;
days: number;
}
interface DurationFields extends UnsignedDurationFields {
sign: CompareResult;
}
declare class Duration extends AbstractNoValueObj {

@@ -41,4 +95,4 @@ constructor(years?: number, months?: number, weeks?: number, days?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number, microseconds?: number, nanoseconds?: number);

}): Duration;
round(options: DurationRoundingOptions): Duration;
total(options: DurationTotalOptions): number;
round(options: DurationRoundingOptions | Unit): Duration;
total(options: DurationTotalOptions | Unit): number;
toString(options?: DurationToStringOptions): string;

@@ -48,9 +102,12 @@ toLocaleString(_locales?: LocalesArg, _options?: unknown): string;

interface OverflowHandlingMap {
constrain: 0;
reject: 1;
interface OffsetHandlingMap {
prefer: 0;
use: 1;
ignore: 2;
reject: 3;
}
declare class PlainMonthDay extends AbstractISOObj<DateISOFields> {
constructor(isoMonth: number, isoDay: number, calendar?: CalendarProtocol, referenceISOYear?: number);
constructor(isoMonth: number, isoDay: number, calendar?: Calendar, // TODO: change back to CalendarProtocol
referenceISOYear?: number);
static from(arg: MonthDayArg, options?: OverflowOptions): PlainMonthDay;

@@ -62,3 +119,3 @@ with(fields: MonthDayOverrides, options?: OverflowOptions): PlainMonthDay;

year: number;
}, options?: OverflowOptions): PlainDate;
}): PlainDate;
}

@@ -71,2 +128,26 @@ interface PlainMonthDay extends MonthDayCalendarFields {

declare class PlainTime extends AbstractISOObj<TimeISOFields> {
constructor(isoHour?: number, isoMinute?: number, isoSecond?: number, isoMillisecond?: number, isoMicrosecond?: number, isoNanosecond?: number);
static from(arg: TimeArg, options?: OverflowOptions): PlainTime;
static compare(a: TimeArg, b: TimeArg): CompareResult;
with(fields: TimeLike, options?: OverflowOptions): PlainTime;
add(durationArg: DurationArg): PlainTime;
subtract(durationArg: DurationArg): PlainTime;
until(other: TimeArg, options?: TimeDiffOptions): Duration;
since(other: TimeArg, options?: TimeDiffOptions): Duration;
round(options: TimeRoundingOptions | TimeUnit): PlainTime;
equals(other: TimeArg): boolean;
toString(options?: TimeToStringOptions): string;
toZonedDateTime(options: {
plainDate: DateArg;
timeZone: TimeZoneArg;
}): ZonedDateTime;
toPlainDateTime(dateArg: DateArg): PlainDateTime;
}
interface PlainTime extends LocalTimeFields {
calendar: Calendar;
}
interface PlainTime extends ToLocaleStringMethods {
}
declare class PlainYearMonth extends AbstractISOObj<DateISOFields> {

@@ -110,3 +191,3 @@ constructor(isoYear: number, isoMonth: number, calendarArg?: CalendarArg, referenceISODay?: number);

since(other: ZonedDateTimeArg, options?: DiffOptions): Duration;
round(options?: DateTimeRoundingOptions): ZonedDateTime;
round(options?: DateTimeRoundingOptions | DayTimeUnit): ZonedDateTime;
equals(other: ZonedDateTimeArg): boolean;

@@ -126,3 +207,3 @@ startOfDay(): ZonedDateTime;

}
interface ZonedDateTime extends TimeFields {
interface ZonedDateTime extends LocalTimeFields {
}

@@ -197,45 +278,2 @@ interface ZonedDateTime extends ComputedEpochFields {

declare class PlainTime extends AbstractISOObj<TimeISOFields> {
constructor(isoHour?: number, isoMinute?: number, isoSecond?: number, isoMillisecond?: number, isoMicrosecond?: number, isoNanosecond?: number);
static from(arg: TimeArg, options?: OverflowOptions): PlainTime;
static compare(a: TimeArg, b: TimeArg): CompareResult;
with(fields: TimeLike, options?: OverflowOptions): PlainTime;
add(durationArg: DurationArg): PlainTime;
subtract(durationArg: DurationArg): PlainTime;
until(other: TimeArg, options?: TimeDiffOptions): Duration;
since(other: TimeArg, options?: TimeDiffOptions): Duration;
round(options: TimeRoundingOptions): PlainTime;
equals(other: TimeArg): boolean;
toString(options?: TimeToStringOptions): string;
toZonedDateTime(options: {
plainDate: DateArg;
timeZone: TimeZoneArg;
}): ZonedDateTime;
toPlainDateTime(dateArg: DateArg): PlainDateTime;
}
interface PlainTime extends TimeFields {
calendar: Calendar;
}
interface PlainTime extends ToLocaleStringMethods {
}
interface TimeISOMilli {
isoHour: number;
isoMinute: number;
isoSecond: number;
isoMillisecond: number;
}
interface TimeISOEssentials extends TimeISOMilli {
isoMicrosecond: number;
isoNanosecond: number;
}
interface TimeFields {
hour: number;
minute: number;
second: number;
millisecond: number;
microsecond: number;
nanosecond: number;
}
declare class PlainDateTime extends AbstractISOObj<DateTimeISOFields> {

@@ -253,3 +291,3 @@ constructor(isoYear: number, isoMonth: number, isoDay: number, isoHour?: number, isoMinute?: number, isoSecond?: number, isoMillisecond?: number, isoMicrosecond?: number, isoNanosecond?: number, calendarArg?: CalendarArg);

since(other: DateTimeArg, options?: DiffOptions): Duration;
round(options: DateTimeRoundingOptions): PlainDateTime;
round(options: DateTimeRoundingOptions | DayTimeUnit): PlainDateTime;
equals(other: DateTimeArg): boolean;

@@ -268,3 +306,3 @@ toString(options?: DateTimeToStringOptions): string;

}
interface PlainDateTime extends TimeFields {
interface PlainDateTime extends LocalTimeFields {
}

@@ -274,21 +312,2 @@ interface PlainDateTime extends ToLocaleStringMethods {

declare type RoundingFunc = (n: number) => number;
interface YearMonthFields {
era: string | undefined;
eraYear: number | undefined;
year: number;
month: number;
monthCode: string;
}
declare type DateISOEssentials = {
isoYear: number;
isoMonth: number;
isoDay: number;
};
declare type DateFields = YearMonthFields & {
day: number;
};
interface ComputedEpochFields {

@@ -337,3 +356,3 @@ epochMicroseconds: bigint;

timeZone: TimeZoneArg;
}): ZonedDateTime;
} | TimeZoneArg): ZonedDateTime;
toPlainDateTime(timeArg?: TimeArg): PlainDateTime;

@@ -367,4 +386,4 @@ toPlainYearMonth(): PlainYearMonth;

inLeapYear(arg: PlainYearMonth | DateArg | PlainDateTime | ZonedDateTime): boolean;
dateFromFields(arg: DateLikeFields, options?: OverflowOptions): PlainDate;
yearMonthFromFields(arg: YearMonthLikeFields, options?: OverflowOptions): PlainYearMonth;
dateFromFields(fields: DateLikeFields, options?: OverflowOptions): PlainDate;
yearMonthFromFields(fields: YearMonthLikeFields, options?: OverflowOptions): PlainYearMonth;
monthDayFromFields(fields: MonthDayLikeFields, options?: OverflowOptions): PlainMonthDay;

@@ -375,2 +394,4 @@ dateAdd(dateArg: DateArg, durationArg: DurationArg, options?: OverflowOptions): PlainDate;

}): Duration;
fields(inFields: string[]): string[];
mergeFields(baseFields: any, additionalFields: any): any;
toString(): string;

@@ -402,9 +423,9 @@ }

interface OffsetHandlingMap {
prefer: 0;
use: 1;
ignore: 2;
reject: 3;
interface OverflowHandlingMap {
constrain: 0;
reject: 1;
}
declare type RoundingFunc = (n: number) => number;
interface RoundingModeMap {

@@ -427,21 +448,6 @@ halfExpand: RoundingFunc;

interface DurationTimeFields {
hours: number;
minutes: number;
seconds: number;
milliseconds: number;
microseconds: number;
nanoseconds: number;
}
interface DurationFields extends DurationTimeFields {
years: number;
months: number;
weeks: number;
days: number;
}
declare type YearMonthUnitProper = keyof LocalYearMonthFields;
declare type DateUnitProper = keyof LocalDateFields | 'week';
declare type TimeUnitProper = keyof LocalTimeFields;
declare type YearMonthUnitProper = keyof YearMonthFields;
declare type DateUnitProper = keyof DateFields | 'week';
declare type TimeUnitProper = keyof TimeFields;
declare type CompareResult = -1 | 0 | 1;

@@ -454,3 +460,3 @@ declare type TimeUnit = TimeUnitProper | /** @deprecated */ 'hours' | /** @deprecated */ 'minutes' | /** @deprecated */ 'seconds' | /** @deprecated */ 'milliseconds' | /** @deprecated */ 'microseconds' | /** @deprecated */ 'nanoseconds';

declare type RoundingMode = keyof RoundingModeMap;
declare type RoundingOptions<UnitType extends Unit = Unit> = {
declare type RoundingOptions<UnitType extends DayTimeUnit = DayTimeUnit> = {
smallestUnit: UnitType;

@@ -460,4 +466,4 @@ roundingMode?: RoundingMode;

};
declare type DateTimeRoundingOptions = RoundingOptions;
declare type TimeRoundingOptions = RoundingOptions<TimeUnit>;
declare type DateTimeRoundingOptions = RoundingOptions<DayTimeUnit>;
declare type DurationRoundingOptions = DiffOptions & {

@@ -502,9 +508,9 @@ relativeTo?: ZonedDateTimeArg | DateTimeArg;

};
declare type DateISOFields = DateISOEssentials & {
calendar: CalendarProtocol;
declare type DateISOFields = ISODateFields & {
calendar: Calendar;
};
declare type TimeISOFields = TimeISOEssentials & {
calendar: CalendarProtocol;
declare type TimeISOFields = ISOTimeFields & {
calendar: Calendar;
};
declare type DateTimeISOFields = DateISOFields & TimeISOEssentials;
declare type DateTimeISOFields = DateISOFields & ISOTimeFields;
declare type ZonedDateTimeISOFields = DateTimeISOFields & {

@@ -539,3 +545,3 @@ timeZone: TimeZone;

};
declare type DateTimeLikeFields = DateLikeFields & Partial<TimeFields>;
declare type DateTimeLikeFields = DateLikeFields & Partial<LocalTimeFields>;
declare type ZonedDateTimeLikeFields = DateTimeLikeFields & {

@@ -567,3 +573,3 @@ offset?: string;

};
declare type TimeLike = Partial<TimeFields>;
declare type TimeLike = Partial<LocalTimeFields>;
declare type DateTimeLike = DateLike & TimeLike;

@@ -676,11 +682,2 @@ declare type ZonedDateTimeLike = DateTimeLike & {

declare function getZonedDateTimeISO(timeZoneArg?: TimeZoneArg): ZonedDateTime;
declare function getZonedDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): ZonedDateTime;
declare function getPlainDateTimeISO(timeZoneArg?: TimeZoneArg): PlainDateTime;
declare function getPlainDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDateTime;
declare function getPlainDateISO(timeZoneArg?: TimeZoneArg): PlainDate;
declare function getPlainDate(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDate;
declare function getPlainTimeISO(timeZoneArg?: TimeZoneArg): PlainTime;
declare function getInstant(): Instant;
declare function getTimeZone(): TimeZone;
declare const Now: {

@@ -698,2 +695,13 @@ zonedDateTimeISO: typeof getZonedDateTimeISO;

declare function getZonedDateTimeISO(timeZoneArg?: TimeZoneArg): ZonedDateTime;
declare function getZonedDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): ZonedDateTime;
declare function getPlainDateTimeISO(timeZoneArg?: TimeZoneArg): PlainDateTime;
declare function getPlainDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDateTime;
declare function getPlainDateISO(timeZoneArg: TimeZoneArg): PlainDate;
declare function getPlainDate(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDate;
declare function getPlainTimeISO(timeZoneArg: TimeZoneArg): PlainTime;
declare function getInstant(): Instant;
declare function getTimeZone(): TimeZone;
export { Calendar, CalendarArg, CalendarDisplay, CalendarProtocol, CompareResult, DateArg, DateDiffOptions, DateISOFields, DateLike, DateLikeFields, DateOverrides, DateTemporalMethods, DateTimeArg, DateTimeFormatArg, DateTimeFormatRangePart, DateTimeISOFields, DateTimeLike, DateTimeLikeFields, DateTimeOverrides, DateTimeRoundingOptions, DateTimeToStringOptions, DateToStringOptions, DateUnit, DateWithTemporal, DayTimeUnit, DiffOptions, Disambiguation, Duration, DurationArg, DurationLike, DurationRoundingOptions, DurationToStringOptions, DurationToStringUnit, DurationTotalOptions, ExtendedDateTimeFormat, FractionalSecondDigits, Instant, InstantArg, InstantToStringOptions, LocalesArg, MonthDayArg, MonthDayLike, MonthDayLikeFields, MonthDayOverrides, Now, OffsetDisplay, OffsetHandling, OverflowHandling, OverflowOptions, PlainDate, PlainDateTime, PlainMonthDay, PlainTime, PlainYearMonth, RoundingMode, RoundingOptions, TimeArg, TimeDiffOptions, TimeISOFields, TimeLike, TimeRoundingOptions, TimeToStringOptions, TimeToStringUnit, TimeUnit, TimeZone, TimeZoneArg, TimeZoneDisplay, TimeZoneProtocol, Unit, YearMonthArg, YearMonthDiffOptions, YearMonthLike, YearMonthLikeFields, YearMonthOverrides, YearMonthUnit, ZonedDateTime, ZonedDateTimeArg, ZonedDateTimeISOFields, ZonedDateTimeLike, ZonedDateTimeLikeFields, ZonedDateTimeOptions, ZonedDateTimeOverrides, ZonedDateTimeToStringOptions, dateToTemporalInstant };

@@ -1,2 +0,2 @@

function n(n,e,t){const r=function(n,e,t){return(o,r)=>{if(void 0===o){const e=r??t;if(void 0===e)throw new RangeError(`Must specify a ${n}`);return e}if(void 0===e[o])throw new RangeError(`Invalid ${n}: ${o}`);return e[o]}}(n,e,t);return(e,t)=>{const i=o(e);return r(i[n],t)}}function e(n,e,t,o){if(void 0===n)return e;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,e),t);if(r!==n&&o===c)throw new RangeError("Invalid overflowed value "+n);return r}function t(n,e){const t={};let o=0;for(const r in e)void 0!==n[r]&&(t[r]=e[r](n[r]),o++);if(!o)throw new TypeError("Invalid object, no keys");return t}function o(n){if(void 0===n)return{};if(!i(n))throw TypeError("options must be an object or undefined");return n}var r=/object|function/;function i(n){return null!==n&&r.test(typeof n)}var s=["calendar","timeZone"];function a(n,e){for(const e of s)if(void 0!==n[e])throw new TypeError(`Disallowed field ${e}`);return t(n,e)}var c=1,u=n("overflow",{constrain:0,reject:1},0);function d(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function h(n,e){Object.defineProperties(n.prototype,f(e,(n=>({get:n}))))}function f(n,e){const t={};for(const o in n)t[o]=e(n[o],o);return t}function l(n,e){const t={};return n.forEach(((n,o)=>{t[n]=e(n,o)})),t}var m=Symbol();function g(n,e,...t){return e instanceof n?e:n.from(e,...t)}var y=class{toJSON(){return this.toString()}},w=class extends y{valueOf(){throw new Error("Cannot convert object using valueOf")}},[p,v]=d(),M=class extends w{constructor(n){super(),v(this,Object.freeze(n))}getISOFields(){return p(this)}},I=1000n,S=1000000n,b=1000000000n,F=60000000000n,D=3600000000000n,O=86400000000000n,T=[1,1e3,1e6,1e9,6e10,36e11,864e11],N=[9,6,3];function Y(n){return n<=6}function E(n){return n>=6}var Z=n("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor}),C=["nanosecond","microsecond","millisecond","second","minute","hour"],U=[...C,"day","week","month","year"],P=U.map((n=>n+"s")),B=l(U,((n,e)=>e)),R=l(P,((n,e)=>e));function k(n,e,t,o){let r;if(void 0===n){if(void 0===e)throw new RangeError("Unit is required");r=e}else if(r=B[n]??R[n],void 0===r||r<t||r>o)throw new RangeError("Invalid unit "+n);return r}function x(n,e,t,r,s,a){if(void 0===e&&!i(n))throw new TypeError("Need rounding options");const c=o(n),u=c.roundingIncrement??1,d=k(c.smallestUnit,e,t,r);if(!s&&a){if(d<6&&864e11%u*T[d])throw new RangeError("Increment must evenly divide into 24 hours")}else{if(d<6?T[d+1]%u:!s&&1!==u)throw new RangeError("roundingIncrement does not divide evenly into next highest unit");if(d<6&&u*T[d]>=T[d+1])throw new RangeError("roundingIncrement must be less than next highest unit")}return{smallestUnit:d,roundingMode:Z(n,s?Math.trunc:Math.round),roundingIncrement:u}}function j(n,e,t,r,i,s,a){const c=x(n,t,r,i,!a,s);e=Math.max(e,c.smallestUnit);let u=o(n).largestUnit;"auto"===u&&(u=void 0);const d=k(u,e,r,i);if(c.smallestUnit>d)throw new RangeError("Bad smallestUnit/largestUnit");return{largestUnit:d,...c}}function q(n,e){return n<e?-1:n>e?1:0}function L(n){return q(n,0)}function H(n,e,t){const o=BigInt(e),r=n/o*o,i=Number(n-r);return r+BigInt(t(i/e))*o}function $(n,e){return(n%e+e)%e}function z(n){return K(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function A(n){return Math.floor(W(n)/1e3)}function W(n){return G(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond)}function K(n,e,t,o,r,i,s,a,c){return BigInt(G(n,e,t,o,r,i,s))*S+BigInt(a??0)*I+BigInt(c??0)}function G(n,e,t,o,r,i,s){const a=n??1970,c=e??1,u=t??1,d=L(a);let h,f,l=0;const m=a>=0&&a<1e3,g=m?a+1200:a;for(;l<31;l++){h=u-d*l;const n=Date.UTC(g,c-1,h,o??0,r??0,i??0,s??0);if(!on(n)){f=n+d*l*864e5;break}}return(void 0===f||h<1||h>ln.daysInMonth(a,c))&&rn(),m&&(f=new Date(f).setUTCFullYear(a)),f}function J(n){let e=n/S,t=Number(n-e*S);t<0&&(t+=1e6,e-=1n);const o=Math.floor(t/1e3);return t-=1e3*o,{...Q(Number(e)),isoMicrosecond:o,isoNanosecond:t}}function Q(n){const[e,t]=tn(n);return{isoYear:e.getUTCFullYear(),isoMonth:e.getUTCMonth()+1,isoDay:e.getUTCDate()+t,isoHour:e.getUTCHours(),isoMinute:e.getUTCMinutes(),isoSecond:e.getUTCSeconds(),isoMillisecond:e.getUTCMilliseconds()}}function V(n){return tn(1e3*n)[0].getUTCFullYear()}function X(n){return Math.floor(G(n)/1e3)}function _(n,e){return Math.round((e-n)/864e5)}function nn(n,e){return n+864e5*e}function en(n,e,t){const[o,r]=tn(G(n,e,t));return $(o.getUTCDay()+r,7)||7}function tn(n){const e=L(n);let t,o=0;for(;o<31;o++){const r=new Date(n-e*o*864e5);if(!on(r)){t=r;break}}return void 0===t&&rn(),[t,e*o]}function on(n){return isNaN(n.valueOf())}function rn(){throw new RangeError("Date outside of supported range")}function sn(n,e){return String(n).padStart(e,"0")}function an(n){return n<0?"-":"+"}var cn={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}},un=class{constructor(n){this.id=n}monthCode(n,e){return"M"+sn(n,2)}convertMonthCode(n,e){const t=/L$/.test(n),o=parseInt(n.substr(1));if(t)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}};function dn(n,e,t,o){let r=cn[hn(n)]?.[t];if(void 0===r){if(!o)throw new Error("Unkown era "+t);r=0}return(r+e)*(L(r)||1)}function hn(n){return n.split("-")[0]}var fn=class extends un{computeFields(n){const e=Q(n);return{era:void 0,eraYear:void 0,year:e.isoYear,month:e.isoMonth,day:e.isoDay}}epochMilliseconds(n,e,t){return G(n,e,t)}daysInMonth(n,e){return 2===e?this.inLeapYear(n)?29:28:4===e||6===e||9===e||11===e?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return 1972}normalizeISOYearForMonthDay(){return 1972}},ln=new fn("iso8601"),mn=class extends fn{computeFields(n){const e=super.computeFields(n),{year:t}=e;return{...e,era:t<1?"bce":"ce",eraYear:t<1?-(t-1):t}}},gn=n("calendarName",{auto:0,never:1,always:2},0),yn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},wn={...yn,day:Number},pn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},vn={...wn,...pn},Mn={...vn,offset:String},In=l(P,(()=>Number)),Sn=n("offset",{prefer:0,use:1,ignore:2,reject:3});function bn(n,t=4){const r=o(n),i=r.smallestUnit,s=r.fractionalSecondDigits;let a,u=0,d=1;return void 0!==i?(u=k(i,void 0,0,t),d=T[u],a=N[u]||0):void 0!==s&&"auto"!==s&&(a=e(s,0,9,c),d=Math.pow(10,9-a)),{smallestUnit:u,fractionalSecondDigits:a,roundingMode:Z(n,Math.trunc),roundingIncrement:d}}var Fn=n("timeZoneName",{auto:0,never:1},0);function Dn(n){h(n,{epochMicroseconds(){return this.epochNanoseconds/I},epochMilliseconds(){return Number(this.epochNanoseconds/S)},epochSeconds(){return Number(this.epochNanoseconds/b)}})}var On,Tn={calendar:"calendar"};for(const n of U)Tn[n]="iso"+((On=n).charAt(0).toUpperCase()+On.slice(1));function Nn(n,e=[]){h(n,l(e.concat("calendar"),(n=>function(){return this.getISOFields()[Tn[n]]})))}var Yn=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],En=[...Yn,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function Zn(n,e){h(n,l(e,(n=>function(){const e=this.calendar[n](this);return Object.defineProperty(this,n,{value:e}),e})))}var Cn="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Un="([+-])"+Cn,Pn="(Z|"+Un+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Bn=Hn("([+-]\\d{6}|\\d{4})-?(\\d{2})"+Pn),Rn=Hn("(--)?(\\d{2})-?(\\d{2})"+Pn),kn=Hn("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Pn),xn=Hn(Cn+Pn),jn=Hn(Un),qn=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,Ln=/\u2212/g;function Hn(n){return new RegExp(`^${n}$`,"i")}function $n(n){const e=Jn(n);if(!e)throw se("dateTime",n);return e}function zn(n){const e=Qn(n);if(!e)throw se("dateTime",n);return e}function An(n){const e=function(n){const e=Bn.exec(ie(n));if(e)return{calendar:(t=e.slice(1))[14],isoYear:oe(t[0]),isoMonth:oe(t[1]),isoDay:1};var t}(n)||Qn(n);if(!e)throw se("yearMonth",n);return e}function Wn(n){const e=function(n){const e=Rn.exec(ie(n));if(e)return{calendar:(t=e.slice(1))[15],isoYear:1972,isoMonth:oe(t[1]),isoDay:oe(t[2])};var t}(n)||Qn(n);if(!e)throw se("monthDay",n);return e}function Kn(n){const e=Vn(n);if(void 0===e)throw se("timeZone",n);return e}function Gn(n){const e=function(n){const e=xn.exec(ie(n));if(e)return _n(e.slice(1))}(n)||Qn(n);if(void 0===e)throw se("time",n);return e}function Jn(n){const e=kn.exec(ie(n));if(e)return function(n){const e=n[11];let t,o=!1;e&&(o="Z"===e.toUpperCase(),t=o?0:ne(n.slice(12)));return{...Xn(n),timeZone:n[21],offset:t,Z:o}}(e.slice(1))}function Qn(n){const e=kn.exec(ie(n));if(e)return Xn(e.slice(1))}function Vn(n){const e=jn.exec(ie(n));if(e)return ne(e.slice(1))}function Xn(n){return{calendar:n[23],isoYear:oe(n[0]),isoMonth:oe(n[1]),isoDay:oe(n[2]),..._n(n.slice(4))}}function _n(n){const e=te(n[4]);return{...wt(vt(BigInt(ee(n[6]||"")),2)),isoHour:te(n[0]),isoMinute:te(n[2]),isoSecond:60===e?59:e}}function ne(n){return("+"===n[0]?1:-1)*function(n){return 36e11*te(n[0])+6e10*te(n[2])+1e9*te(n[4])+ee(n[6]||"")}(n.slice(1))}function ee(n){return parseInt(n.padEnd(9,"0"))}function te(n){return parseInt(n||"0")}function oe(n){return parseInt(n||"1")}function re(n){return void 0===n?void 0:parseInt(n)}function ie(n){return n.replace(Ln,"-")}function se(n,e){throw new RangeError(`Cannot parse ${n} '${e}'`)}function ae(n,e,t,o){const r=P[e],{sign:i}=n,s={};for(let t=9;t>=e;t--){const e=P[t];s[e]=n[e]}const a={[r]:i},c=t.add(s),u=c.add(a),d=ce(c),h=ce(u),f=ce(o),l=Number(f-d)/Number(h-d)*i;return s[r]+=l,s}function ce(n){const{epochNanoseconds:e}=n;return void 0!==e?e:z(n.getISOFields())}var ue=n("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0),de=n("offset",{auto:0,never:1},0);function he(n){return{...n,calendar:void 0===n.calendar?Zo():new Calendar(n.calendar)}}function fe(n){return{...he(n),timeZone:new TimeZone(n.timeZone)}}var le=class{constructor(n){this.id=n}},me=class extends le{constructor(n,e){super(n),this.offsetSecs=e}getPossibleOffsets(){return[this.offsetSecs]}getOffset(){return this.offsetSecs}getTransition(){}};function ge(n,e){const t={},o=n.formatToParts(e);for(const n of o)t[n.type]=n.value;return t}var ye={bc:"bce",ad:"ce"};function we(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),ye[n]||n}var pe=Intl.DateTimeFormat;function ve(n){return[].concat(n||[])}var Me={"Pacific/Apia":{2011:[[1301752800,-36e3,-39600],[1316872800,-39600,-36e3],[1325239200,-36e3,50400]]}},Ie=[182,91,273],Se=class extends le{constructor(n){const e=new pe("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(e.resolvedOptions().timeZone),this.format=e,this.yearEndOffsets={},this.transitionsInYear=Me[n]||{}}getPossibleOffsets(n){const e=[this.getTransition(n,-1),this.getTransition(n-1,1)].filter(Boolean);let t;for(const o of e){const[e,r,i]=o,s=n-r,a=n-i;if(e>s&&e>a)return[r];if(!(e<=s&&e<=a))return[r,i];t=i}return void 0!==t?[t]:[this.getYearEndOffset(V(n))]}getOffset(n){const e=ge(this.format,1e3*n);let t=parseInt(e.year);"bce"===we(e.era)&&(t=-(t-1));const o=G(t,parseInt(e.month),parseInt(e.day),parseInt(e.hour),parseInt(e.minute),parseInt(e.second));return Math.floor(o/1e3)-n}getTransition(n,e){const t=V(n);for(let o=0;o<100;o++){const r=t+o*e,i=this.getTransitionsInYear(r),s=i.length,a=e<0?s-1:0;for(let t=0;t<s;t++){const o=i[a+t*e];if(q(o[0],n)===e)return o}}}getYearEndOffset(n){const{yearEndOffsets:e}=this;return e[n]||(e[n]=this.getOffset(X(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:e}=this;return e[n]||(e[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const e=this.getYearEndOffset(n-1),t=this.getYearEndOffset(n),o=X(n)-1,r=X(n+1)-1;if(e!==t)return[this.searchTransition(o,r,e,t)];const i=this.searchIsland(e,o);return void 0!==i?[this.searchTransition(o,i[0],e,i[1]),this.searchTransition(i[0],r,i[1],t)]:[]}searchTransition(n,e,t,o){for(;e-n>1;){const o=Math.floor(n+(e-n)/2);this.getOffset(o)===t?n=o:e=o}return[e,t,o]}searchIsland(n,e){for(const t of Ie){const o=e+86400*t,r=this.getOffset(o);if(r!==n)return[o,r]}}},be={UTC:new me("UTC",0)};var[Fe,De]=d(),TimeZone=class extends y{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),De(this,function(n){const e=(n=String(n)).toLocaleUpperCase();if(be[e])return be[e];const t=Vn(n);if(void 0!==t){if(Math.abs(t)>864e11)throw new RangeError("Offset out of bounds");return new me(Dt(t),Math.trunc(t/1e9))}return be[e]=new Se(n)}(n))}static from(n){if("object"==typeof n)return function(n){return n.timeZone}(n)?function(n){if("object"==typeof n){if("string"==typeof n.id)return n;throw new RangeError("Invalid timeZone")}return new TimeZone(String(n))}(n.timeZone):n;const e=Jn(String(n));if(e){if(e.timeZone){const n=fe(e);return We(n,3),n.timeZone}if(e.Z)return new TimeZone("UTC");if(void 0!==e.offset)return new TimeZone(Dt(e.offset))}return new TimeZone(n)}get id(){return Fe(this).id}getOffsetStringFor(n){return Dt(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const e=g(Instant,n);return 1e9*Fe(this).getOffset(e.epochSeconds)}getPlainDateTimeFor(n,e=Zo()){const t=g(Instant,n);return ko({...J(t.epochNanoseconds+BigInt(this.getOffsetNanosecondsFor(t))),calendar:g(Calendar,e)})}getInstantFor(n,e){const t=ue(e),o=g(PlainDateTime,n).getISOFields(),r=A(o),i=Fe(this).getPossibleOffsets(r);let s;if(1===i.length||0===t)s=i[0];else{if(3===t)throw new RangeError("Ambiguous offset");s=Math[1===t?"max":"min"](...i)}return Oe(r-s,o)}getPossibleInstantsFor(n){const e=g(PlainDateTime,n).getISOFields(),t=A(e);let o=Fe(this).getPossibleOffsets(t);return 2===o.length&&o[0]<o[1]&&(o=[]),o.map((n=>Oe(t-n,e)))}getPreviousTransition(n){const e=g(Instant,n),t=Fe(this).getTransition(e.epochSeconds,-1);return t?Oe(t[0]):null}getNextTransition(n){const e=g(Instant,n),t=Fe(this).getTransition(e.epochSeconds,1);return t?Oe(t[0]):null}toString(){return this.id}};function Oe(n,e){return new Instant(BigInt(n)*b+(e?BigInt(e.isoMillisecond)*S+BigInt(e.isoMicrosecond)*I+BigInt(e.isoNanosecond):0n))}function Te(n,e){const t=z(n);Ne(t),Fo(t,e)}function Ne(n){(n<-8640000086399999999999n||n>8640000086399999999999n)&&rn()}function Ye(n,e,t){return(o,r)=>{const i=Be(n,r)?{}:{...n,...e};return{buildKey:Pe(o,r,!1),buildFormat:function(n,e){return new pe(o,{calendar:n,timeZone:e||void 0,...i,...r,...t})},buildEpochMilli:Ee}}}function Ee(n){return n.epochMilliseconds}function Ze(n,e,t){return(o,r)=>{const i=Be(n,r)?{}:n;return{buildKey:Pe(o,r,t),buildFormat:function(n,t){return new pe(o,{calendar:n,...i,...r,...e,timeZone:t,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?Ce.bind(null,new TimeZone(r.timeZone)):Ue}}}function Ce(n,e){const t=ko({..._e,...e.getISOFields()});return n.getInstantFor(t).epochMilliseconds}function Ue(n){return W(n.getISOFields())}function Pe(n,e,t){const o=e.calendar??function(n){for(const e of n){const n=e.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),r=e.timeZone;return function(n,e){const i=n.calendar?.id,s=n.timeZone?.id;if(e){if(e.calendar?.id!==i)throw new RangeError("Mismatching calendar");if(e.timeZone?.id!==s)throw new RangeError("Mismatching timeZone")}if((t||"iso8601"!==i)&&void 0!==i&&void 0!==o&&o!==i)throw new RangeError("Non-iso calendar mismatch");if(void 0!==s&&void 0!==r&&r!==s)throw new RangeError("Given timeZone must agree");return[o||i||"iso8601",r||s||"UTC"]}}function Be(n,e){for(const t in n)if(void 0!==e[t])return!0;return!1}function Re(n,e){n.prototype.toLocaleString=function(n,t){const o=e(ve(n),t||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[m]=e}function ke(n){return n?.[m]}var xe={day:1},PlainYearMonth=class extends M{constructor(n,e,t=Zo(),o=1){const r=to({isoYear:n,isoMonth:e,isoDay:o},c),i=g(Calendar,t);var s,a;s=r,a=i.id,Fo(z(s),a),super({...r,calendar:i})}static from(n,e){if(u(e),n instanceof PlainYearMonth)return qe(n.getISOFields());if("object"==typeof n){const o=t(n,yn);return Uo(n).yearMonthFromFields(o,e)}const o=An(String(n));return void 0===o.calendar&&(o.isoDay=1),qe(he(o))}static compare(n,e){return He(g(PlainYearMonth,n),g(PlainYearMonth,e))}with(n,e){const t=a(n,yn);return this.calendar.yearMonthFromFields(Le(t,this),e)}add(n,e){return je(this,g(Duration,n),e)}subtract(n,e){return je(this,g(Duration,n).negated(),e)}until(n,e){return io(this.toPlainDate(xe),g(PlainYearMonth,n).toPlainDate(xe),j(e,9,8,8,9))}since(n,e){return io(this.toPlainDate(xe),g(PlainYearMonth,n).toPlainDate(xe),j(e,9,8,8,9),!0)}equals(n){return 0===He(this,g(PlainYearMonth,n))}toString(n){const e=this.getISOFields(),t=e.calendar.id,o=gn(n);return("iso8601"===t?bt(e):St(e))+Ot(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}};function je(n,e,t){return n.toPlainDate({day:e.sign<0?n.daysInMonth:1}).add(e,t).toPlainYearMonth()}function qe(n){return new PlainYearMonth(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function Le(n,e){const t={};let o=!1,r=!1;return void 0===n.era&&void 0===n.eraYear||(t.era=n.era,t.eraYear=n.eraYear,o=!0),void 0!==n.year&&(t.year=n.year,o=!0),o||(t.year=e.year),void 0!==n.month&&(t.month=n.month,r=!0),void 0!==n.monthCode&&(t.monthCode=n.monthCode,r=!0),r||(t.month=e.month),t}function He(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}Nn(PlainYearMonth),Zn(PlainYearMonth,Yn),Re(PlainYearMonth,Ze({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));var[$e,ze]=d(),ZonedDateTime=class extends M{constructor(n,e,t=Zo()){const o=g(TimeZone,e),r=g(Calendar,t),i=new Instant(n),s=o.getOffsetNanosecondsFor(i),a=J(n+BigInt(s));Te(a,r.id),super({...a,calendar:r,timeZone:o,offset:o.getOffsetStringFor(i)}),ze(this,{epochNanoseconds:n,offsetNanoseconds:s})}static from(n,e){const o=Sn(e,3),r=u(e);return Ae(n instanceof ZonedDateTime?{...n.getISOFields(),offset:n.offsetNanoseconds}:"object"==typeof n?Ke(t(n,Mn),e,r,Uo(n),function(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return g(TimeZone,n.timeZone)}(n)):fe($n(String(n))),e,o)}static compare(n,e){return q(g(ZonedDateTime,n).epochNanoseconds,g(ZonedDateTime,e).epochNanoseconds)}get timeZone(){return this.getISOFields().timeZone}get epochNanoseconds(){return $e(this).epochNanoseconds}get offsetNanoseconds(){return $e(this).offsetNanoseconds}get offset(){return this.getISOFields().offset}with(n,e){const t=a(n,Mn),o={...jo(r=t,i=this),offset:r.offset??i.offset};var r,i;const s=Sn(e,0),c=u(e);return ue(e),Ae(Ke(o,e,c,this.calendar,this.timeZone),e,s)}withPlainDate(n){const e=g(PlainDate,n),t=e.toPlainDateTime(this),{timeZone:o}=this,r=o.getInstantFor(t);return new ZonedDateTime(r.epochNanoseconds,o,Bo(this,e))}withPlainTime(n){return this.toPlainDate().toZonedDateTime({plainTime:n,timeZone:this.timeZone})}withCalendar(n){return new ZonedDateTime(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new ZonedDateTime(this.epochNanoseconds,n,this.calendar)}add(n,e){return Ge(this,g(Duration,n),e)}subtract(n,e){return Ge(this,g(Duration,n).negated(),e)}until(n,e){return Je(this,g(ZonedDateTime,n),e)}since(n,e){return Je(this,g(ZonedDateTime,n),e,!0)}round(n){return function(n,e){const t=x(e,void 0,0,6);if(6===t.smallestUnit){const e=function(n,e,t){const o=gt(n);return{day:t(Number(o)/e),hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}}(n,nt(n),t.roundingMode);return ko(st(n.getISOFields(),e)).toZonedDateTime(n.timeZone)}return et(n,it(t),t.roundingMode)}(this,n)}equals(n){const e=g(ZonedDateTime,n);return this.epochNanoseconds===e.epochNanoseconds&&this.calendar.id===e.calendar.id&&this.timeZone.id===e.timeZone.id}startOfDay(){return Ae({...this.getISOFields(),..._e,offset:void 0},void 0,3)}get hoursInDay(){return nt(this)/36e11}toString(n){const e=bn(n),t=de(n),o=Fn(n),r=gn(n),i=et(this,e.roundingIncrement,e.roundingMode).getISOFields();return It(i,e)+(0===t?i.offset:"")+function(n,e){if(1!==e)return`[${n}]`;return""}(i.timeZone.id,o)+Ot(i.calendar.id,r)}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return ko(this.getISOFields())}toPlainDate(){return _t(this.getISOFields())}toPlainTime(){return at(this.getISOFields())}toInstant(){return new Instant(this.epochNanoseconds)}};function Ae(n,e,t){const{calendar:o,timeZone:r}=n,i=We(n,t)??r.getInstantFor(ko(n),e).epochNanoseconds;return new ZonedDateTime(i,r,o)}function We(n,e){const{timeZone:t,offset:o,Z:r}=n;let i;if(void 0!==o&&2!==e&&(i=z(n)-BigInt(o),1!==e&&!r)){if(!function(n,e){for(const t of e)if(t.epochNanoseconds===n)return!0;return!1}(i,t.getPossibleInstantsFor(ko(n)))){if(3===e)throw new RangeError("Mismatching offset/timezone");i=void 0}}return i}function Ke(n,e,t,o,r){return{...xo(n,e,t,o),timeZone:r,offset:n.offset?Kn(n.offset):void 0}}function Ge(n,e,t){const{calendar:o,timeZone:r}=n,i=Ht(e),s=$t(e),a=o.dateAdd(n.toPlainDate(),i,t).toZonedDateTime({plainTime:n,timeZone:r}),c=gt(s),u=a.epochNanoseconds+c;return new ZonedDateTime(u,r,o)}function Je(n,e,t,o){const r=j(t,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==e.timeZone.id)throw new Error("Must be same timeZone");return tt(Qe(n,e,i),r,n,e,o)}function Qe(n,e,t){const o=Po(n,e);if(!E(t))return Ve(n,e,t);const r=_t(n.getISOFields());let i,s,a,c,u,d=_t(e.getISOFields());do{s=o.dateUntil(r,d,{largestUnit:U[t]}),i=n.add(s),a=Ve(i,e,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(d=d.add({days:u})));return Bt(s,a)}function Ve(n,e,t){return jt(Xe(e)-Xe(n),t)}function Xe(n){return n instanceof PlainDateTime?z(n.getISOFields()):n.epochNanoseconds}Nn(ZonedDateTime,C),Zn(ZonedDateTime,En),Dn(ZonedDateTime),Re(ZonedDateTime,Ye({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));var _e={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0};function nt(n){const e={...n.getISOFields(),..._e,offset:void 0},t=Ae(e,void 0,3),o=Ae({...e,...Qt(e,1)},void 0,3);return Number(o.epochNanoseconds-t.epochNanoseconds)}function et(n,e,t){return Ae({...zo(n.toPlainDateTime(),e,t).getISOFields(),timeZone:n.timeZone,offset:n.offsetNanoseconds},void 0,0)}function tt(n,e,t,o,r){const{largestUnit:i,smallestUnit:s,roundingIncrement:a,roundingMode:c}=e;if(!E(i))return jt(rt((Xe(o)-Xe(t))*(r?-1n:1n),e),i);let u=ae(n,s,t,o);const d=P[s];function h(){const n=u[d];var e;u[d]=c(n/(e=a))*e}c===Math.round&&h(),r&&(u=Wt(u)),c!==Math.round&&h();let f=Ut(u);return s>0&&(f=r?Rt(f.negated(),i,t).negated():Rt(f,i,t)),f}function ot(n,e,t){return yt(H(gt(n),e,t))}function rt(n,e){return H(n,it(e),e.roundingMode)}function it(n){return T[n.smallestUnit]*n.roundingIncrement}function st(n,e){return{...Qt(n,e.day),...wt(e)}}var PlainTime=class extends M{constructor(n=0,e=0,t=0,o=0,r=0,i=0){super({...ct({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},c),calendar:Zo()})}static from(n,e){const o=u(e);return at(n instanceof PlainTime?n.getISOFields():"object"==typeof n?ft(t(n,pn),o):Gn(String(n)))}static compare(n,e){return mt(g(PlainTime,n),g(PlainTime,e))}with(n,e){return at(ft(ut(a(n,pn),this),u(e)))}add(n){return dt(this,g(Duration,n))}subtract(n){return dt(this,g(Duration,n).negated())}until(n,e){return ht(this,g(PlainTime,n),e)}since(n,e){return ht(g(PlainTime,n),this,e)}round(n){return function(n,e){const t=x(e,void 0,0,5);return at(wt(ot(n,it(t),t.roundingMode)))}(this,n)}equals(n){return 0===mt(this,g(PlainTime,n))}toString(n){const e=bn(n);return Ft(wt(ot(this,e.roundingIncrement,e.roundingMode)),e)}toZonedDateTime(n){return this.toPlainDateTime(n.plainDate).toZonedDateTime(n.timeZone)}toPlainDateTime(n){return g(PlainDate,n).toPlainDateTime(this)}};function at(n){return new PlainTime(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function ct({isoHour:n,isoMinute:t,isoSecond:o,isoMillisecond:r,isoMicrosecond:i,isoNanosecond:s},a){return{isoHour:n=e(n,0,23,a),isoMinute:t=e(t,0,59,a),isoSecond:o=e(o,0,59,a),isoMillisecond:r=e(r,0,999,a),isoMicrosecond:i=e(i,0,999,a),isoNanosecond:s=e(s,0,999,a)}}function ut(n,e){return f(pn,((t,o)=>n[o]??e[o]))}function dt(n,e){var t,o;return at(wt((t=n,o=$t(e),yt(gt(t)+gt(o)))))}function ht(n,e,t){const o=j(t,5,0,0,5);return jt(rt(gt(e)-gt(n),o),o.largestUnit)}function ft(n,e){return ct(wt(n),e)}function lt(n){return g(PlainTime,n??{hour:0})}function mt(n,e){return q(gt(n),gt(e))}function gt(n){return BigInt(n.hour)*D+BigInt(n.minute)*F+BigInt(n.second)*b+BigInt(n.millisecond)*S+BigInt(n.microsecond)*I+BigInt(n.nanosecond)}function yt(n){const[e,t]=Mt(n);return{...vt(t,5),day:Number(e/O)}}function wt(n){return{isoNanosecond:n.nanosecond??0,isoMicrosecond:n.microsecond??0,isoMillisecond:n.millisecond??0,isoSecond:n.second??0,isoMinute:n.minute??0,isoHour:n.hour??0}}function pt(n){return BigInt(n.day)*O+gt(n)}function vt(n,e){const t={};for(let o=e;o>=0;o--){const e=BigInt(T[o]),r=n/e;n-=r*e,t[U[o]]=Number(r)}return t}function Mt(n){const e=J(n);return[K(e.isoYear,e.isoMonth,e.isoDay),(t=e,BigInt(t.isoHour)*D+BigInt(t.isoMinute)*F+BigInt(t.isoSecond)*b+BigInt(t.isoMillisecond)*S+BigInt(t.isoMicrosecond)*I+BigInt(t.isoNanosecond))];var t}function It(n,e){return St(n)+"T"+Ft(n,e)}function St(n){return bt(n)+"-"+sn(n.isoDay,2)}function bt(n){const{isoYear:e}=n;return(e<1e3||e>9999?an(e)+sn(Math.abs(e),6):sn(e,4))+"-"+sn(n.isoMonth,2)}function Ft(n,e){const t=[sn(n.isoHour,2)];return e.smallestUnit<=4&&(t.push(sn(n.isoMinute,2)),e.smallestUnit<=3&&t.push(sn(n.isoSecond,2)+Nt(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,e.fractionalSecondDigits)[0])),t.join(":")}function Dt(n){const e=vt(BigInt(Math.abs(n)),5),t=Nt(e.millisecond,e.microsecond,e.nanosecond,void 0)[0];return an(n)+sn(e.hour,2)+":"+sn(e.minute,2)+(e.second||t?":"+sn(e.second,2)+t:"")}function Ot(n,e){return n&&(2===e||1!==e&&"iso8601"!==n)?`[u-ca=${n}]`:""}function Tt(n){return n.map((([n,e,t])=>t||n?(n<BigInt(0)?-n:n)+e:"")).join("")}function Nt(n,e,t,o,r,i){let s=BigInt(t)+BigInt(e)*I+BigInt(n)*S;r&&(s=H(s,void 0===o?T[i]:Math.pow(10,9-o),r));const a=s<0?-s:s,c=a/b;let u=sn(Number(a-c*b),9);return u=void 0===o?u.replace(/0+$/,""):u.substr(0,o),[u?"."+u:"",Number(c)*(s<0?-1:1)]}function Yt(n){const e=function(n){const e=qn.exec(ie(n));if(e){let n,t,o,r;[n,r]=Et(e[8],e[10],5,void 0),[t,r]=Et(e[12],e[14],4,r),[o,r]=Et(e[16],e[18],3,r);let i=function(n){const e={};for(const t in n)void 0!==n[t]&&(e[t]=n[t]);return e}({years:re(e[2]),months:re(e[3]),weeks:re(e[4]),days:re(e[5]),hours:n,minutes:t,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=vt(BigInt(r||0),2);return i.milliseconds=s.millisecond,i.microseconds=s.microsecond,i.nanoseconds=s.nanosecond,"-"===e[1]&&(i=Wt(i)),i}}(n);if(void 0===e)throw se("duration",n);return e}function Et(n,e,t,o){if(void 0!==n){if(void 0!==o)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==e?ee(e)*(T[t]/1e9):void 0]}if(void 0!==o){const n=Math.trunc(o/T[t]);return[n,o-n*T[t]]}return[void 0,void 0]}Nn(PlainTime,C),Re(PlainTime,(function(n,e){return{buildKey:()=>["",""],buildFormat:()=>new pe(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...e,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Number(gt(n)/S)}}));var[Zt,Ct]=d(),Duration=class extends w{constructor(n=0,e=0,t=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super(),Ct(this,function(n){const e={};let t=0;for(const o of P){const r=Number(n[o]||0),i=L(n[o]);if(i){if(t&&t!==i)throw new RangeError("All fields must be same sign");t=i}if(!Number.isInteger(r))throw new RangeError("Duration fields must be integers");e[o]=r}return e.sign=t,e}({years:n,months:e,weeks:t,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u}))}static from(n){return Ut("object"==typeof n?t(n,In):Yt(n))}static compare(n,e,t){return function(n,e,t){const o=g(Duration,n),r=g(Duration,e),i=Lt(o),s=Lt(r);if(void 0===t&&i&&s)return q(pt(i),pt(s));const a=zt(t),c=a.add(o),u=a.add(r);if(a instanceof ZonedDateTime)return ZonedDateTime.compare(c,u);return PlainDateTime.compare(c,u)}(n,e,o(t).relativeTo)}get years(){return Zt(this).years}get months(){return Zt(this).months}get weeks(){return Zt(this).weeks}get days(){return Zt(this).days}get hours(){return Zt(this).hours}get minutes(){return Zt(this).minutes}get seconds(){return Zt(this).seconds}get milliseconds(){return Zt(this).milliseconds}get microseconds(){return Zt(this).microseconds}get nanoseconds(){return Zt(this).nanoseconds}get sign(){return Zt(this).sign}get blank(){return!this.sign}with(n){return Ut({...Zt(this),...a(n,In)})}negated(){return Ut(Wt(Zt(this)))}abs(){return Ut(f(Zt(this),(n=>Math.abs(n))))}add(n,e){return Pt(this,g(Duration,n),o(e).relativeTo)}subtract(n,e){return Pt(this,g(Duration,n).negated(),o(e).relativeTo)}round(n){return function(n,e){if(!i(e))throw new TypeError("Must specify options");if(void 0===e.largestUnit&&void 0===e.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const t=xt(n),o=j(e,t,0,0,9,!1,!0),{largestUnit:r,smallestUnit:s}=o,a=Lt(n);if(void 0===e.relativeTo&&a&&Y(r)&&Y(s)){return qt(vt(rt(pt(a),o),r))}const c=At(e.relativeTo),u=kt(n,r,c);return tt(u,o,c,c.add(u))}(this,n)}total(n){return function(n,e,t){const o=Lt(n);if(void 0===t&&o&&Y(e))return Number(pt(o))/T[e];const r=At(t),i=kt(n,e,r,!0);return ae(i,e,r,r.add(i))[P[e]]}(this,k(o(n).unit,void 0,0,9),n.relativeTo)}toString(n){const e=bn(n,3);return function(n,e){const{smallestUnit:t,fractionalSecondDigits:o,roundingMode:r}=e,{sign:i}=n,s=BigInt(n.hours),a=BigInt(n.minutes);let c=BigInt(n.seconds),u="";if(t<=3){const e=Nt(n.milliseconds,n.microseconds,n.nanoseconds,o,r,t);u=e[0],c+=BigInt(e[1])}return(i<0?"-":"")+"P"+Tt([[BigInt(n.years),"Y"],[BigInt(n.months),"M"],[BigInt(n.weeks),"W"],[BigInt(n.days),"D"]])+(s||a||c||u||!i?"T"+Tt([[s,"H"],[a,"M"],[t<=3?c:BigInt(0),u+"S",u||!i]]):"")}(Zt(this),e)}toLocaleString(n,e){return this.toString()}};function Ut(n){return new Duration(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function Pt(n,e,t){const o=Lt(n),r=Lt(e),i=Math.max(xt(n),xt(e));if(void 0===t&&o&&r)return jt(pt(o)+pt(r),i);const s=zt(t),a=s.add(n).add(e);return Qe(s,a,i)}function Bt(n,e){return new Duration(n.years+e.years,n.months+e.months,n.weeks+e.weeks,n.days+e.days,n.hours+e.hours,n.minutes+e.minutes,n.seconds+e.seconds,n.milliseconds+e.milliseconds,n.microseconds+e.microseconds,n.nanoseconds+e.nanoseconds)}function Rt(n,e,t){return t instanceof PlainDate?function(n,e,t){const o=t.add(n);return t.calendar.dateUntil(t,o,{largestUnit:U[e]})}(n,Math.max(6,e),t):kt(n,e,t)}function kt(n,e,t,o){const r=!0!==o&&e>7&&n.weeks;r&&(n=n.with({weeks:0}));const i=t.add(n);let s=Qe(t,i,e);return r&&(s=Bt(s,new Duration(0,0,r))),s}function xt(n){return n.years?9:n.months?8:n.weeks?7:n.days?6:n.hours?5:n.minutes?4:n.seconds?3:n.milliseconds?2:n.microseconds?1:0}function jt(n,e){return qt(vt(n,e))}function qt(n){return new Duration(0,0,0,n.day,n.hour,n.minute,n.second,n.millisecond,n.microsecond,n.nanosecond)}function Lt(n){if(!n.years&&!n.months&&!n.weeks)return{day:n.days,...$t(n)}}function Ht(n){return new Duration(n.years,n.months,n.weeks,n.days)}function $t(n){return{hour:n.hours,minute:n.minutes,second:n.seconds,millisecond:n.milliseconds,microsecond:n.microseconds,nanosecond:n.nanoseconds}}function zt(n){if(void 0===n)throw new RangeError("Need relativeTo");if("object"==typeof n)return void 0!==n.timeZone?ZonedDateTime.from(n):PlainDateTime.from(n);{const e=$n(String(n));return void 0!==e.timeZone?Ae(fe(e),void 0,0):ko(he(e))}}function At(n){if(void 0===n)throw new RangeError("Must specify relativeTo");if(i(n))return n instanceof ZonedDateTime||n instanceof PlainDateTime?n:g(void 0!==n.timeZone?ZonedDateTime:PlainDateTime,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const e=Jn(String(n));if(e)return void 0!==e.timeZone?Ae(fe(e),void 0,3):ko(he(e));throw new RangeError("Invalid value of relativeTo")}function Wt(n){return f(n,(n=>-n||0))}function Kt(n,e,t,o){n=Jt(n=Gt(n,e.years,t,o),e.months,t,o);let r=t.epochMilliseconds(n.year,n.month,n.day);const[,i]=function(n){const e=gt($t(n)),t=e/O;return[vt(e-t*O,5),new Duration(n.years,n.months,n.weeks,n.days+Number(t))]}(e);return r=nn(r,7*i.weeks+i.days),Q(r)}function Gt({year:n,month:t,day:o},r,i,s){n+=r;const a=e(t,1,i.monthsInYear(n),s);let c=t===a?o:1;return c=e(c,1,i.daysInMonth(n,a),s),{year:n,month:a,day:c}}function Jt({year:n,month:t,day:o},r,i,s){if(r){if(t+=r,r<0)for(;t<1;)t+=i.monthsInYear(--n);else{let e;for(;t>(e=i.monthsInYear(n));)t-=e,n++}o=e(o,1,i.daysInMonth(n,t),s)}return{year:n,month:t,day:o}}function Qt(n,e){return e?{...Q(nn(W(n),e)),calendar:n.calendar}:n}var PlainMonthDay=class extends M{constructor(n,e,t=Zo(),o){super({...to({isoYear:o??("iso8601"===t.id?1972:function(n,e){throw new n(e)}(Error,"Must specify referenceYear")),isoMonth:n,isoDay:e},c),calendar:t})}static from(n,e){if(u(e),n instanceof PlainMonthDay)return Xt(n.getISOFields());if("object"==typeof n){const o=Uo(n);let r=t(n,Vt);return void 0===r.year&&void 0===n.calendar&&(r={...r,year:1972}),o.monthDayFromFields(r,e)}const o=Wn(String(n));return void 0===o.calendar&&(o.isoYear=1972),Xt(he(o))}with(n,e){const t=function(n,e){const t={day:n.day??e.day};void 0!==n.monthCode?(t.monthCode=n.monthCode,void 0!==n.month&&(t.month=n.month)):void 0!==n.month?(t.month=n.month,t.year=n.year):t.monthCode=e.monthCode;return t}(a(n,Vt),this);return this.calendar.monthDayFromFields(t,e)}equals(n){return e=this,t=g(PlainMonthDay,n),e.calendar.id===t.calendar.id&&z(e.getISOFields())===z(t.getISOFields());var e,t}toString(n){const e=this.getISOFields(),t=e.calendar.id,o=gn(n);return("iso8601"===t?function(n){return sn(n.isoMonth,2)+"-"+sn(n.isoDay,2)}(e):St(e))+Ot(t,o)}toPlainDate(n,e){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},e)}};Nn(PlainMonthDay),Zn(PlainMonthDay,["monthCode","day"]),Re(PlainMonthDay,Ze({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));var Vt={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number};function Xt(n){return new PlainMonthDay(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function _t(n){return new PlainDate(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function no(n,e){return{...Le(n,e),day:n.day??e.day}}function eo(n,t,o,r,i){return[n=Number(n),t=e(t,1,r.monthsInYear(n),i),o=e(o,1,r.daysInMonth(n,t),i)]}function to(n,e){const[t,o,r]=eo(n.isoYear,n.isoMonth,n.isoDay,ln,e);return{isoYear:t,isoMonth:o,isoDay:r}}function oo(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}function ro(n,e){return q(n.year,e.year)||function(n,e){return q(n.month,e.month)||q(n.day,e.day)}(n,e)}function io(n,e,t,o){return tt(Po(n,e).dateUntil(n,e,{largestUnit:U[t.largestUnit]}),t,n,e,o)}var PlainDate=class extends M{constructor(n,e,t,o=Zo()){const r=to({isoYear:n,isoMonth:e,isoDay:t},c),i=g(Calendar,o);!function(n,e){const t=z(n);Ne(t+(t<0n?86399999999999n:0n)),Fo(t,e)}(r,i.id),super({...r,calendar:i})}static from(n,e){if(u(e),n instanceof PlainDate)return _t(n.getISOFields());if("object"==typeof n){const o=t(n,wn);return Uo(n).dateFromFields(o,e)}return _t(he(zn(String(n))))}static compare(n,e){return oo(g(PlainDate,n),g(PlainDate,e))}with(n,e){const t=no(a(n,wn),this);return this.calendar.dateFromFields(t,e)}withCalendar(n){const e=this.getISOFields();return new PlainDate(e.isoYear,e.isoMonth,e.isoDay,n)}add(n,e){return this.calendar.dateAdd(this,n,e)}subtract(n,e){return this.calendar.dateAdd(this,g(Duration,n).negated(),e)}until(n,e){return io(this,g(PlainDate,n),j(e,6,6,6,9))}since(n,e){return io(this,g(PlainDate,n),j(e,6,6,6,9),!0)}equals(n){return 0===oo(this,g(PlainDate,n))}toString(n){const e=gn(n),t=this.getISOFields();return St(t)+Ot(t.calendar.id,e)}toZonedDateTime(n){return this.toPlainDateTime(n.plainTime).toZonedDateTime(n.timeZone)}toPlainDateTime(n){return ko({...this.getISOFields(),...lt(n).getISOFields()})}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}};function so(n){return n instanceof PlainDate||n instanceof PlainDateTime||n instanceof ZonedDateTime||n instanceof PlainYearMonth||n instanceof PlainMonthDay}function ao(n,e,t){let o;if(n instanceof PlainDate)o=n;else if(so(n)){if(t&&n instanceof PlainMonthDay)throw new TypeError("PlainMonthDay not allowed");o=_t(n.getISOFields())}else o=PlainDate.from(n);return Ro(o.calendar,e),o}function co(n,e,t){if(so(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:d}=n;const h=void 0!==r&&void 0!==o?dn(e.id,r,o):void 0;if(void 0===i){if(void 0===h)throw new TypeError("Must specify either a year or an era & eraYear");i=h}else if(void 0!==h&&h!==i)throw new RangeError("year and era/eraYear must match");if(void 0===d)throw new TypeError("Must specify day");const f=u(t);if(void 0!==a){const[n,t]=e.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,t){if(f===c)throw new RangeError("Month code out of range");d=e.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,d]=eo(i,s,d,e,f),Q(e.epochMilliseconds(i,s,d))}function uo(n,e){if(so(n)){if(e&&n instanceof PlainMonthDay)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return PlainDate.from(n).getISOFields()}function ho(n,e){return _(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e+1,1,1))}function fo(n,e,t,o){return _(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e,t,o))+1}Nn(PlainDate),Zn(PlainDate,En),Re(PlainDate,Ze({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));var lo={hebrew:6,chinese:0,dangi:0},mo=class extends un{constructor(n){const e=go(n);if(t=n,o=e.resolvedOptions().calendar,hn(t)!==hn(o))throw new RangeError("Invalid calendar: "+n);var t,o;super(n),this.format=e,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,e,t){return nn(this.queryMonthCache(n)[0][e-1],t-1)}daysInMonth(n,e){const t=this.queryMonthCache(n)[0],o=t[e-1];e>=t.length&&(n++,e=0);return _(o,this.queryMonthCache(n)[0][e])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,e){const t=this.queryLeapMonthByYear(e);return!t||n<t?super.monthCode(n,e):super.monthCode(n-1,e)+(n===t?"L":"")}convertMonthCode(n,e){const t=this.queryLeapMonthByYear(e);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=lo[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||t&&r===t-1||(i=!0,o=!1),(o||t&&r>=t)&&r++,[r,i]}inLeapYear(n){const e=ho(this,n);return e>ho(this,n-1)&&e>ho(this,n+1)}guessYearForMonthDay(n,e){let t=1970+this.yearCorrection;const o=t+100;for(;t<o;t++){const[o,r]=this.convertMonthCode(n,t);if(!r&&o<=this.monthsInYear(t)&&e<=this.daysInMonth(t,o))return t}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const e=this.computeFieldsDumb(n),t=this.queryMonthCache(e.year)[2];return{...e,month:t[e.month]}}computeFieldsDumb(n){const e=ge(this.format,n);let t,o,r=parseInt(e.relatedYear||e.year);var i;return e.era&&(i=this.id,void 0!==cn[hn(i)])&&(t=we(e.era),o=r,r=dn(this.id,o,t,!0)),{era:t,eraYear:o,year:r,month:e.month,day:parseInt(e.day)}}queryLeapMonthByYear(n){const e=this.queryMonthCache(n),t=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(e[0].length>t[0].length&&e[0].length>o[0].length){const n=e[1],o=t[1];for(let e=0;e<o.length;e++)if(o[e]!==n[e])return e+1}}queryMonthCache(n){const{monthCacheByYear:e}=this;return e[n]||(e[n]=this.buildMonthCache(n))}buildMonthCache(n){const e=[],t=[],o={};let r=G(this.guessISOYear(n));for(r=nn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=nn(r,1-o.day),o.year===n&&(e.unshift(r),t.unshift(o.month)),r=nn(r,-1)}for(let n=0;n<t.length;n++)o[t[n]]=n+1;return[e,t,o]}guessISOYear(n){return n-this.yearCorrection}};function go(n){return new pe("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}var yo=G(1868,9,8),wo={gregory:mn,japanese:class extends mn{constructor(){super(...arguments),this.format=go("japanese")}computeFields(n){const e=super.computeFields(n);if(n>=yo){const t=ge(this.format,n);e.era=we(t.era),e.eraYear=parseInt(t.relatedYear||t.year)}return e}},islamic:class extends mo{guessISOYear(n){return Math.ceil(32*n/33+622)}}},po={iso8601:ln};function vo(n){const e=(n=String(n)).toLocaleLowerCase();return po[e]||(po[e]=new(wo[hn(e)]||mo)(n))}var Mo=G(1582,10,15),Io=G(622,7,18),So={buddhist:Mo,japanese:Mo,roc:Mo,islamic:Io,"islamic-rgsa":Io,indian:0},bo={};function Fo(n,e){return Do(Number(n/S),e)}function Do(n,e){if(function(n,e){return function(n){let e=bo[n];if(void 0===e){const t=So[n];if(void 0===t)e=!1;else{let o=vo(n);o instanceof mo||(o=new mo(n));const r=t-864e5,i=o.computeFields(r);e=r!==o.epochMilliseconds(i.year,i.month,i.day)}bo[n]=e}return e}(e)&&n<So[e]}(n,e))throw new RangeError("Invalid timestamp for calendar")}function Oo(n,e,t,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,e,t){const[,o,r]=eo(e.year,n.month,n.day,t,0),i=ro(e,n),s=q(e.month,o)||q(e.day,r);return e.year-n.year-(s&&i&&s!==i?i:0)}(n,e,t),n=Gt(n,r,t,0);case 8:i=function(n,e,t){let o=0;const r=ro(e,n);if(r){let{year:i}=n;for(;i!==e.year;)o+=t.monthsInYear(i)*r,i+=r;const[,s,a]=eo(e.year,n.month,n.day,t,0);o+=e.month-s;const c=q(e.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,e,t),n=Jt(n,i,t,0)}return a=_(t.epochMilliseconds(n.year,n.month,n.day),t.epochMilliseconds(e.year,e.month,e.day)),7===o&&(s=Math.trunc(a/7),a%=7),new Duration(r,i,s,a)}function To(n,e,t){const o=7+e-t;return-$(en(n,1,o)-e,7)+o-1}function No(n,e,t){const o=To(n,e,t),r=To(n+1,e,t);return(ho(ln,n)-o+r)/7}var[Yo,Eo]=d(),Calendar=class extends y{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),Eo(this,vo(n))}static from(n){if("object"==typeof n&&n)return function(n){return n.calendar}(n)?function(n){if("object"==typeof n&&n){if("string"==typeof n.id)return n;throw new RangeError("Invalid calendar")}return new Calendar(String(n))}(n.calendar):n;const e=Qn(String(n));return new Calendar(e?e.calendar||"iso8601":n)}get id(){return Yo(this).id}era(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).era}eraYear(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).eraYear}year(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).year}month(n){const e=uo(n,!0);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).month}monthCode(n){const e=ao(n,this);return Yo(this).monthCode(e.month,e.year)}day(n){const e=uo(n);return Co(Yo(this),e.isoYear,e.isoMonth,e.isoDay).day}dayOfWeek(n){const e=uo(n,!0);return en(e.isoYear,e.isoMonth,e.isoDay)}dayOfYear(n){const e=ao(n,this,!0);return fo(Yo(this),e.year,e.month,e.day)}weekOfYear(n){const e=uo(n,!0);return function(n,e,t,o,r){const i=To(n,o,r),s=Math.floor((fo(ln,n,e,t)-i-1)/7)+1;if(s<1)return s+No(n-1,o,r);const a=No(n,o,r);return s>a?s-a:s}(e.isoYear,e.isoMonth,e.isoDay,1,4)}daysInWeek(n){return uo(n,!0),7}daysInMonth(n){const e=ao(n,this,!0);return Yo(this).daysInMonth(e.year,e.month)}daysInYear(n){const e=ao(n,this,!0);return ho(Yo(this),e.year)}monthsInYear(n){const e=ao(n,this,!0);return Yo(this).monthsInYear(e.year)}inLeapYear(n){return Yo(this).inLeapYear(this.year(n))}dateFromFields(n,e){const t=co(n,Yo(this),e);return new PlainDate(t.isoYear,t.isoMonth,t.isoDay,this)}yearMonthFromFields(n,e){const t=co({...n,day:1},Yo(this),e);return new PlainYearMonth(t.isoYear,t.isoMonth,this,t.isoDay)}monthDayFromFields(n,e){const t=Yo(this);let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;if(void 0===c)throw new TypeError("required property 'day' missing or undefined");if(void 0!==a?i=1972:void 0!==o&&void 0!==r&&(i=dn(t.id,r,o)),void 0===i){if(void 0===a)throw new TypeError("either year or monthCode required with month");i=t.guessYearForMonthDay(a,c)}const u=co({year:i,month:s,monthCode:a,day:c},t,e);return new PlainMonthDay(u.isoMonth,u.isoDay,this,t.normalizeISOYearForMonthDay(u.isoYear))}dateAdd(n,e,t){const o=Yo(this),r=Kt(g(PlainDate,n,t),g(Duration,e),o,u(t));return new PlainDate(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,e,t){const r=Yo(this),i=g(PlainDate,n),s=g(PlainDate,e),a=k(o(t).largestUnit,6,6,9);return Ro(Po(i,s),this),Oo(i,s,r,a)}toString(){return this.id}};function Zo(){return new Calendar("iso8601")}function Co(n,e,t,o){const r=G(e,t,o);return Do(r,n.id),n.computeFields(r)}function Uo(n){return void 0===n.calendar?Zo():g(Calendar,n.calendar)}function Po(n,e){const{calendar:t}=n;return Ro(t,e.calendar),t}function Bo(n,e){const t=n.calendar,o=e.calendar;if("iso8601"===t.id)return o;if("iso8601"===o.id)return t;if(t.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return t}function Ro(n,e){if(n.id!==e.id)throw new RangeError("Calendars must match")}var PlainDateTime=class extends M{constructor(n,e,t,o=0,r=0,i=0,s=0,a=0,u=0,d=Zo()){const h=qo({isoYear:n,isoMonth:e,isoDay:t,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:u},c),f=g(Calendar,d);Te(h,f.id),super({...h,calendar:f})}static from(n,e){const o=u(e);return ko(n instanceof PlainDateTime?n.getISOFields():"object"==typeof n?xo(t(n,vn),e,o,Uo(n)):he(zn(String(n))))}static compare(n,e){return Lo(g(PlainDateTime,n),g(PlainDateTime,e))}with(n,e){return ko(xo(jo(a(n,vn),this),e,u(e),this.calendar))}withPlainDate(n){const e=g(PlainDate,n);return ko({...this.getISOFields(),...e.getISOFields(),calendar:Bo(this,e)})}withPlainTime(n){return ko({...this.getISOFields(),...lt(n).getISOFields()})}withCalendar(n){return ko({...this.getISOFields(),calendar:g(Calendar,n)})}add(n,e){return Ho(this,g(Duration,n),e)}subtract(n,e){return Ho(this,g(Duration,n).negated(),e)}until(n,e){return $o(this,g(PlainDateTime,n),e)}since(n,e){return $o(this,g(PlainDateTime,n),e,!0)}round(n){return function(n,e){const t=x(e,void 0,0,6);return zo(n,it(t),t.roundingMode)}(this,n)}equals(n){return 0===Lo(this,g(PlainDateTime,n))}toString(n){const e=bn(n),t=gn(n),o=zo(this,e.roundingIncrement,e.roundingMode).getISOFields();return It(o,e)+Ot(o.calendar.id,t)}toZonedDateTime(n,e){const t=g(TimeZone,n),o=t.getInstantFor(this,e);return new ZonedDateTime(o.epochNanoseconds,t,this.calendar)}toPlainYearMonth(){return qe(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return _t(this.getISOFields())}toPlainTime(){return at(this.getISOFields())}};function ko(n){return new PlainDateTime(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function xo(n,e,t,o){return{...o.dateFromFields(n,e).getISOFields(),...ft(n,t)}}function jo(n,e){return{...no(n,e),...ut(n,e)}}function qo(n,e){return{...to(n,e),...ct(n,e)}}function Lo(n,e){return q(z(n.getISOFields()),z(e.getISOFields()))||q(n.calendar.id,e.calendar.id)}function Ho(n,e,t){const{calendar:o}=n,r=Ht(e),i=$t(e);return ko({...J(z(o.dateAdd(_t(n.getISOFields()),r,t).getISOFields())+gt(n)+gt(i)),calendar:o})}function $o(n,e,t,o){const r=j(t,6,0,0,9);return tt(Qe(n,e,r.largestUnit),r,n,e,o)}function zo(n,e,t){const o=ot(n,e,t);return ko(st(n.getISOFields(),o))}function Ao(n,e){return q(n.epochNanoseconds,e.epochNanoseconds)}function Wo(n,e){if(xt(e)>=6)throw new RangeError("Duration cant have units larger than days");return new Instant(n.epochNanoseconds+gt($t(e)))}function Ko(n,e,t){const o=j(t,3,0,0,5,!0);return jt(rt(e.epochNanoseconds-n.epochNanoseconds,o),o.largestUnit)}Nn(PlainDateTime,C),Zn(PlainDateTime,En),Re(PlainDateTime,Ze({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));var[Go,Jo]=d(),Instant=class extends w{constructor(n){var e;super(),n=BigInt(n),((e=n)<-8640000000000000000000n||e>8640000000000000000000n)&&rn(),Jo(this,n)}static from(n){if(n instanceof Instant)return new Instant(n.epochNanoseconds);const e=$n(String(n)),t=e.offset;if(void 0===t)throw new RangeError("Must specify an offset");return new Instant(z(qo(e,c))-BigInt(t))}static fromEpochSeconds(n){return new Instant(BigInt(n)*b)}static fromEpochMilliseconds(n){return new Instant(BigInt(n)*S)}static fromEpochMicroseconds(n){return new Instant(n*I)}static fromEpochNanoseconds(n){return new Instant(n)}static compare(n,e){return Ao(g(Instant,n),g(Instant,e))}get epochNanoseconds(){return Go(this)}add(n){return Wo(this,g(Duration,n))}subtract(n){return Wo(this,g(Duration,n).negated())}until(n,e){return Ko(this,g(Instant,n),e)}since(n,e){return Ko(g(Instant,n),this,e)}round(n){return function(n,e){const t=x(e,void 0,0,5,!1,!0),[o,r]=Mt(n.epochNanoseconds);return new Instant(o+rt(r,t))}(this,n)}equals(n){return 0===Ao(this,g(Instant,n))}toString(n){const e=o(n).timeZone;return this.toZonedDateTimeISO(e??"UTC").toString({...n,offset:void 0===e?"never":"auto",timeZoneName:"never"})+(void 0===e?"Z":"")}toZonedDateTimeISO(n){return new ZonedDateTime(this.epochNanoseconds,n)}toZonedDateTime(n){if(!i(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new ZonedDateTime(this.epochNanoseconds,n.timeZone,n.calendar)}};function Qo(n){return Instant.fromEpochMilliseconds(n.valueOf())}Dn(Instant),Re(Instant,Ye({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));var Vo=Symbol(),Xo=Symbol(),_o=Symbol(),nr=class extends pe{constructor(n,e){const t=ve(n),o=function(n){const e={};for(const t in n){let o=n[t];i(o)&&(o=o.toString()),e[t]=o}return e}(e||{});super(t,o),this[Vo]=t,this[Xo]=o,this[_o]=new Map}format(n){const e=er(this,n);return e[0]===this?super.format(n):e[0].format(e[1])}formatToParts(n){return super.formatToParts.call(...er(this,n))}formatRange(n,e){return super.formatRange.call(...tr(this,n,e))}formatRangeToParts(n,e){return super.formatRangeToParts.call(...tr(this,n,e))}};function er(n,e){const t=ke(e);if(t){const o=or(n,t);return[o.buildFormat(e),o.buildEpochMilli(e)]}return[n,e]}function tr(n,e,t){const o=ke(e);if(o!==ke(t))throw new TypeError("Mismatch of types");if(o){const r=or(n,o);return[r.buildFormat(e,t),r.buildEpochMilli(e),r.buildEpochMilli(t)]}return[n,e,t]}function or(n,e){const t=n[_o];let o=t.get(e);return o||(o=function(n){const e={};return{buildFormat:function(t,o){const r=n.buildKey(t,o),i=r.join("|");return e[i]||(e[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(e(n[Vo],n[Xo])),t.set(e,o)),o}function rr(n=ur()){return cr().toZonedDateTimeISO(n)}function ir(n,e){if(void 0===n)throw new RangeError("Must specify calendar");return cr().toZonedDateTime({calendar:n,timeZone:e??ur()})}function sr(n=ur()){return rr(n).toPlainDateTime()}function ar(n,e){return ir(n,e).toPlainDateTime()}function cr(){return new Instant(BigInt(Date.now())*S)}function ur(){return new TimeZone((new pe).resolvedOptions().timeZone)}var dr={zonedDateTimeISO:rr,zonedDateTime:ir,plainDateTimeISO:sr,plainDateTime:ar,plainDateISO:function(n=ur()){return sr(n).toPlainDate()},plainDate:function(n,e){return ar(n,e).toPlainDate()},plainTimeISO:function(n=ur()){return cr().toZonedDateTimeISO(n).toPlainTime()},instant:cr,timeZone:ur};export{Calendar,Duration,nr as ExtendedDateTimeFormat,Instant,dr as Now,PlainDate,PlainDateTime,PlainMonthDay,PlainTime,PlainYearMonth,TimeZone,ZonedDateTime,Qo as dateToTemporalInstant};
var n=1000n,e=1000000n,t=1000000000n,o=60000000000n,r=3600000000000n,i=86400000000000n,s=864e11,a=[1,1e3,1e6,1e9,6e10,36e11,s],c=[9,6,3];function u(n){return n<=6}function d(n){return n>=6}var h=f("overflow",{constrain:0,reject:1},0);function f(n,e,t){const o=function(n,e,t){return(o,r)=>{if(void 0===o){const e=r??t;if(void 0===e)throw new RangeError(`Must specify a ${n}`);return e}if(void 0===e[o])throw new RangeError(`Invalid ${n}: ${o}`);return e[o]}}(n,e,t);return(e,t)=>{const r=g(e);return o(r[n],t)}}function l(n,e,t,o){if(void 0===n)return e;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,e),t);if(r!==n&&1===o)throw new RangeError("Invalid overflowed value "+n);return r}function m(n,e){const t={};for(const o in e)void 0!==n[o]&&(t[o]=e[o](n[o]));return t}function g(n){if(void 0===n)return{};if(!w(n))throw TypeError("options must be an object or undefined");return n}var y=/object|function/;function w(n){return null!==n&&y.test(typeof n)}var p=f("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor});function v(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function M(n,e){Object.defineProperties(n.prototype,I(e,(n=>({get:n}))))}function I(n,e){const t={};for(const o in n)t[o]=e(n[o],o);return t}function S(n,e,t){const o={};for(const r of e)o[r]=t(n[r]);return o}function F(n,e){const t={};return n.forEach(((n,o)=>{t[n]=e(n,o)})),t}var b=["nanosecond","microsecond","millisecond","second","minute","hour"],N=[...b,"day","week","month","year"],O=N.map((n=>n+"s")),T=F(N,((n,e)=>e)),D=F(O,((n,e)=>e));function Y(n,e,t,o){let r;if(void 0===n){if(void 0===e)throw new RangeError("Unit is required");r=e}else if(r=T[n]??D[n],void 0===r||r<t||r>o)throw new RangeError("Invalid unit "+n);return r}function E(n,e,t,o,r,i){const s=g(n),c=s.roundingIncrement??1,u=Y(s.smallestUnit,t,o,r),d=p(s,i?Math.round:Math.trunc);let h=s.largestUnit;"auto"===h&&(h=void 0);const f=Y(h,e=Math.max(e,u),o,r);if(u>f)throw new RangeError("Bad smallestUnit/largestUnit");if(u<6){const n=a[u+1],e=a[u]*c;if(n===e)throw new RangeError("Must not equal larger unit");if(n%e)throw new RangeError("Must divide into larger unit")}return{smallestUnit:u,largestUnit:f,roundingFunc:d,roundingIncrement:c}}function Z(n,e,t,o,r){const i="string"==typeof n?{smallestUnit:n}:n;if(void 0===e&&!w(i))throw new TypeError("Need rounding options");const c=g(i),u=c.roundingIncrement??1,d=Y(c.smallestUnit,e,t,o),h=p(c,Math.round),f=a[d]*u;if(6===d){if(1!==u)throw new RangeError("When smallestUnit is days, roundingIncrement must be 1")}else{const n=r?s:a[d+1];if(!r&&n===f)throw new RangeError("Must not equal larger unit");if(n%f)throw new RangeError("Must divide into larger unit")}return{smallestUnit:d,roundingFunc:h,incNano:f}}var C=Symbol();function U(n,e,...t){return e instanceof n?e:n.from(e,...t)}var R=class{toJSON(){return this.toString()}},P=class extends R{valueOf(){throw new Error("Cannot convert object using valueOf")}},[B,k]=v(),x=class extends P{constructor(n){super(),k(this,Object.freeze(n))}getISOFields(){return B(this)}};function j(n,e){return n<e?-1:n>e?1:0}function q(n){return j(n,0)}function H(n,e,t){return t(n/e)*e}function L(n){return H(n,6e10,$)}function $(n){return Math.round(Math.abs(n))*q(n)}function z(n,e,t){const o=BigInt(e),r=n/o*o,i=Number(n-r);return r+BigInt(t(i/e))*o}function A(n,e){return(n%e+e)%e}var W=O.concat("sign");function K(n){return S(n,W,(n=>-n||0))}function G(n,e){return J({years:e.years??n.years,months:e.months??n.months,weeks:e.weeks??n.weeks,days:e.days??n.days,hours:e.hours??n.hours,minutes:e.minutes??n.minutes,seconds:e.seconds??n.seconds,milliseconds:e.milliseconds??n.milliseconds,microseconds:e.microseconds??n.microseconds,nanoseconds:e.nanoseconds??n.nanoseconds})}function J(n){return{...n,sign:Q(n)}}function Q(n){let e=0;for(const t of O){if(n[t]){e=q(n[t]);break}}return e}function V(n){let e=9;for(;e>0&&!n[O[e]];)e--;return e}var X={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0},_={hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};function nn(n){return{isoHour:n.hour||0,isoMinute:n.minute||0,isoSecond:n.second||0,isoMillisecond:n.millisecond||0,isoMicrosecond:n.microsecond||0,isoNanosecond:n.nanosecond||0}}function en(n){return BigInt(n.days)*i+tn(n)}function tn(i){return BigInt(i.hours)*r+BigInt(i.minutes)*o+BigInt(i.seconds)*t+BigInt(i.milliseconds)*e+BigInt(i.microseconds)*n+BigInt(i.nanoseconds)}function on(n){return 36e11*n.isoHour+6e10*n.isoMinute+1e9*n.isoSecond+1e6*n.isoMillisecond+1e3*n.isoMicrosecond+n.isoNanosecond}function rn(s,a){let c,u=0,d=0,h=0,f=0,l=0,m=0;switch(a){case 6:c=s/i,u=Number(c),s-=c*i;case 5:c=s/r,d=Number(c),s-=c*r;case 4:c=s/o,h=Number(c),s-=c*o;case 3:c=s/t,f=Number(c),s-=c*t;case 2:c=s/e,l=Number(c),s-=c*e;case 1:c=s/n,m=Number(c),s-=c*n}return J({years:0,months:0,weeks:0,days:u,hours:d,minutes:h,seconds:f,milliseconds:l,microseconds:m,nanoseconds:Number(s)})}function sn(n){const e=Math.floor(n/s);n-=e*s;const t=Math.floor(n/36e11);n-=36e11*t;const o=Math.floor(n/6e10);n-=6e10*o;const r=Math.floor(n/1e9);n-=1e9*r;const i=Math.floor(n/1e6);n-=1e6*i;const a=Math.floor(n/1e3);return[{isoHour:t,isoMinute:o,isoSecond:r,isoMillisecond:i,isoMicrosecond:a,isoNanosecond:n-=1e3*a},e]}function an(n,e){return String(n).padStart(e,"0")}function cn(n){return n<0?"-":"+"}var un={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}},dn=class{constructor(n){this.id=n}monthCode(n,e){return"M"+an(n,2)}convertMonthCode(n,e){const t=/L$/.test(n),o=parseInt(n.substr(1));if(t)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}};function hn(n,e,t,o){let r=un[fn(n)]?.[t];if(void 0===r){if(!o)throw new Error("Unkown era "+t);r=0}return(r+e)*(q(r)||1)}function fn(n){return n.split("-")[0]}var ln=class extends dn{computeFields(n){const e=Mn(n);return{era:void 0,eraYear:void 0,year:e.isoYear,month:e.isoMonth,day:e.isoDay}}epochMilliseconds(n,e,t){return pn(n,e,t)}daysInMonth(n,e){return 2===e?this.inLeapYear(n)?29:28:4===e||6===e||9===e||11===e?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return gn}normalizeISOYearForMonthDay(){return gn}},mn=new ln("iso8601"),gn=1972;function yn(n){return wn(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function wn(t,o,r,i,s,a,c,u,d){return BigInt(pn(t,o,r,i,s,a,c))*e+BigInt(u??0)*n+BigInt(d??0)}function pn(n,e,t,o,r,i,s){const a=q(n);let c,u,d=0;const h=n>=0&&n<1e3,f=h?n+1200:n;for(;d<31;d++){c=t-a*d;const n=Date.UTC(f,e-1,c,o??0,r??0,i??0,s??0);if(!On(n)){u=n+a*d*864e5;break}}return(void 0===u||c<1||c>mn.daysInMonth(n,e))&&Tn(),h&&(u=new Date(u).setUTCFullYear(n)),u}function vn(n){let t=n/e,o=Number(n-t*e);o<0&&(o+=1e6,t-=1n);const r=Math.floor(o/1e3);return o-=1e3*r,{...Mn(Number(t)),isoMicrosecond:r,isoNanosecond:o}}function Mn(n){const[e,t]=Nn(n);return{isoYear:e.getUTCFullYear(),isoMonth:e.getUTCMonth()+1,isoDay:e.getUTCDate()+t,isoHour:e.getUTCHours(),isoMinute:e.getUTCMinutes(),isoSecond:e.getUTCSeconds(),isoMillisecond:e.getUTCMilliseconds()}}function In(n){return n.epochNanoseconds??yn(n.getISOFields())}function Sn(n){return Math.floor(pn(n,1,1)/1e3)}function Fn(n){return Nn(Number(n/e))[0].getUTCFullYear()}function bn(n,e,t){const[o,r]=Nn(pn(n,e,t));return A(o.getUTCDay()+r,7)||7}function Nn(n){const e=q(n);let t,o=0;for(;o<31;o++){const r=new Date(n-e*o*864e5);if(!On(r)){t=r;break}}return void 0===t&&Tn(),[t,e*o]}function On(n){return isNaN(n.valueOf())}function Tn(){throw new RangeError("Date outside of supported range")}function Dn(n,e){return Math.round((e-n)/864e5)}function Yn(n,e){return n+864e5*e}function En(n,e){return function(n,e){return!Zn(n,e)&&n.calendar.id===e.calendar.id}(n,e)&&n.timeZone.id===e.timeZone.id}function Zn(n,e){return j(yn(n.getISOFields()),yn(e.getISOFields()))}function Cn(n,e){return j(on(n.getISOFields()),on(e.getISOFields()))}function Un(n,e){return j(n.year,e.year)||j(n.month,e.month)||j(n.day,e.day)}function Rn(n,e){return j(n.epochNanoseconds,e.epochNanoseconds)}function Pn(n,e,t,o,r){return[n=Number(n),e=l(e,1,o.monthsInYear(n),r),t=l(t,1,o.daysInMonth(n,e),r)]}function Bn(n,e){const[t,o,r]=Pn(n.isoYear,n.isoMonth,n.isoDay,mn,e);return{isoYear:t,isoMonth:o,isoDay:r}}function kn(n,e){return{...Bn(n,e),...xn(n,e)}}function xn({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},s){return{isoHour:n=l(n,0,23,s),isoMinute:e=l(e,0,59,s),isoSecond:t=l(t,0,59,s),isoMillisecond:o=l(o,0,999,s),isoMicrosecond:r=l(r,0,999,s),isoNanosecond:i=l(i,0,999,s)}}var jn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},qn={...jn,day:Number},Hn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},Ln={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number},$n=F(O,(()=>Number)),zn=class extends ln{computeFields(n){const e=super.computeFields(n),{year:t}=e;return{...e,era:t<1?"bce":"ce",eraYear:t<1?-(t-1):t}}},An=f("calendarName",{auto:0,never:1,always:2},0);function Wn(n,e=4){const t=g(n),o=t.smallestUnit,r=t.fractionalSecondDigits;let i,s=0,u=1;return void 0!==o?(s=Y(o,void 0,0,e),u=a[s],i=c[s]||0):void 0!==r&&"auto"!==r&&(i=l(r,0,9,1),u=Math.pow(10,9-i)),{smallestUnit:s,fractionalSecondDigits:i,roundingFunc:p(n,Math.trunc),incNano:u}}var Kn=f("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0),Gn=f("timeZoneName",{auto:0,never:1},0);function Jn(n,e){return Qn(n)+"T"+Xn(n,e)}function Qn(n){return Vn(n)+"-"+an(n.isoDay,2)}function Vn(n){const{isoYear:e}=n;return(e<1e3||e>9999?cn(e)+an(Math.abs(e),6):an(e,4))+"-"+an(n.isoMonth,2)}function Xn(n,e){const t=[an(n.isoHour,2)];return e.smallestUnit<=4&&(t.push(an(n.isoMinute,2)),e.smallestUnit<=3&&t.push(an(n.isoSecond,2)+te(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,e.fractionalSecondDigits)[0])),t.join(":")}function _n(n){const[e,t]=sn(Math.abs(n)),o=te(e.isoMillisecond,e.isoMicrosecond,e.isoNanosecond,void 0)[0];return cn(n)+an(e.isoHour+24*t,2)+":"+an(e.isoMinute,2)+(e.isoSecond||o?":"+an(e.isoSecond,2)+o:"")}function ne(n,e){return n&&(2===e||1!==e&&"iso8601"!==n)?`[u-ca=${n}]`:""}function ee(n){return n.map((([n,e,t])=>t||n?(n<BigInt(0)?-n:n)+e:"")).join("")}function te(o,r,i,s,c,u){let d=BigInt(i)+BigInt(r)*n+BigInt(o)*e;c&&(d=z(d,void 0===s?a[u]:Math.pow(10,9-s),c));const h=d<0?-d:d,f=h/t;let l=an(Number(h-f*t),9);return l=void 0===s?l.replace(/0+$/,""):l.substr(0,s),[l?"."+l:"",Number(f)*(d<0?-1:1)]}function oe(o){M(o,{epochMicroseconds(){return this.epochNanoseconds/n},epochMilliseconds(){return Number(this.epochNanoseconds/e)},epochSeconds(){return Number(this.epochNanoseconds/t)}})}var re,ie={calendar:"calendar"};for(const n of N)ie[n]="iso"+((re=n).charAt(0).toUpperCase()+re.slice(1));function se(n,e=[]){M(n,F(e.concat("calendar"),(n=>function(){return this.getISOFields()[ie[n]]})))}var ae=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],ce=[...ae,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function ue(n,e){M(n,F(e,(n=>function(){const e=this.calendar[n](this);return Object.defineProperty(this,n,{value:e}),e})))}function de(n,e){(n.prototype||n)[Symbol.toStringTag]="Temporal."+e}var he=f("offset",{prefer:0,use:1,ignore:2,reject:3});function fe({year:n,month:e,day:t},o,r,i){n+=o;const s=l(e,1,r.monthsInYear(n),i);let a=e===s?t:1;return a=l(a,1,r.daysInMonth(n,s),i),{year:n,month:s,day:a}}function le({year:n,month:e,day:t},o,r,i){if(o){if(e+=o,o<0)for(;e<1;)e+=r.monthsInYear(--n);else{let t;for(;e>(t=r.monthsInYear(n));)e-=t,n++}t=l(t,1,r.daysInMonth(n,e),i)}return{year:n,month:e,day:t}}function me({isoYear:n,isoMonth:e,isoDay:t},o){if(o){let r=pn(n,e,t);r=Yn(r,o),({isoYear:n,isoMonth:e,isoDay:t}=Mn(r))}return{isoYear:n,isoMonth:e,isoDay:t}}function ge(n,e){if(V(e)>=6)throw new RangeError("Duration cant have units >= days");return n+tn(e)}function ye(n,e,t=3,o){const{offsetNanoseconds:r,timeZone:i,Z:s}=n;if(void 0!==r&&2!==t){if(1===t||s)return yn(n)-BigInt(r);{const o=we(n,r,i,e);if(void 0!==o)return o;if(3===t)throw new RangeError("Mismatching offset/timezone")}}return i.getInstantFor(Zo(n),o).epochNanoseconds}function we(n,e,t,o){const r=t.getPossibleInstantsFor(Zo(n)),i=yn(n),s=o?L(e):e;for(const n of r){const e=n.epochNanoseconds,t=Number(i-e);if((o?L(t):t)===s)return e}}function pe(n){const{timeZone:e}=n,t={...n,...X,calendar:new ir("iso8601")},o={...me(t,1),...X,calendar:new ir("iso8601")},r=e.getInstantFor(Zo(t)).epochNanoseconds,i=e.getInstantFor(Zo(o)).epochNanoseconds;return Number(i-r)}var ve="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Me="([+-])"+ve,Ie="(Z|"+Me+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Se=Ye("([+-]\\d{6}|\\d{4})-?(\\d{2})"+Ie),Fe=Ye("(--)?(\\d{2})-?(\\d{2})"+Ie),be=Ye("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Ie),Ne=Ye("T?"+ve+Ie),Oe=Ye(Me),Te=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,De=/\u2212/g;function Ye(n){return new RegExp(`^${n}$`,"i")}function Ee(n){return n.replace(De,"-")}function Ze(n){const e=Be(n);if(!e)throw Ge("dateTime",n);return e}function Ce(n){const e=ke(n);if(!e)throw Ge("dateTime",n);return e}function Ue(n){const e=qe(n);if(void 0===e)throw Ge("timeZone",n);return e}function Re(n){let e=function(n){const e=Ne.exec(Ee(n));if(e)return Le(e.slice(1))}(n);if(void 0!==e){if("T"!==n.charAt(0)){const t=xe(n)||je(n);t&&function(n){try{return Bn(n,1),!0}catch(n){return!1}}(t)&&(e=void 0)}}else e=ke(n,!0);if(void 0===e)throw Ge("time",n);return e}var Pe=/^Z$/i;function Be(n){const e=be.exec(Ee(n));if(e)return function(n){const e=n[11];let t,o=!1;e&&(o=Pe.test(e),t=o?0:$e(n.slice(12)));return{...He(n),timeZone:n[21],offsetNanoseconds:t,Z:o}}(e.slice(1))}function ke(n,e,t){const o=be.exec(Ee(n));if(o&&(t||!Pe.test(o[12]))&&(!e||o[4]))return He(o.slice(1))}function xe(n){const e=Se.exec(Ee(n));if(e)return{calendar:(t=e.slice(1))[14],isoYear:We(t[0]),isoMonth:We(t[1]),isoDay:1};var t}function je(n){const e=Fe.exec(Ee(n));if(e)return{calendar:(t=e.slice(1))[15],isoYear:gn,isoMonth:We(t[1]),isoDay:We(t[2])};var t}function qe(n){const e=Oe.exec(Ee(n));if(e)return $e(e.slice(1))}function He(n){return{calendar:n[23],isoYear:We(n[0]),isoMonth:We(n[1]),isoDay:We(n[2]),...Le(n.slice(4))}}function Le(n){const e=Ae(n[4]);return{...sn(ze(n[6]||""))[0],isoHour:Ae(n[0]),isoMinute:Ae(n[2]),isoSecond:60===e?59:e}}function $e(n){return("+"===n[0]?1:-1)*function(n){return 36e11*Ae(n[0])+6e10*Ae(n[2])+1e9*Ae(n[4])+ze(n[6]||"")}(n.slice(1))}function ze(n){return parseInt(n.padEnd(9,"0"))}function Ae(n){return parseInt(n||"0")}function We(n){return parseInt(n||"1")}function Ke(n){return void 0===n?void 0:parseInt(n)}function Ge(n,e){throw new RangeError(`Cannot parse ${n} '${e}'`)}function Je(n){return{...n,calendar:void 0===n.calendar?sr():new ir(n.calendar)}}function Qe(n){return{...Je(n),timeZone:new ht(n.timeZone)}}var Ve=class{constructor(n){this.id=n}},Xe=class extends Ve{constructor(n,e){super(n),this.offsetNano=e}getPossibleOffsets(){return[this.offsetNano]}getOffset(){return this.offsetNano}getTransition(){}};function _e(n,e){const t={},o=n.formatToParts(e);for(const n of o)t[n.type]=n.value;return t}var nt={bc:"bce",ad:"ce"};function et(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),nt[n]||n}var tt=Intl.DateTimeFormat;function ot(n){return[].concat(n||[])}var rt={"Pacific/Apia":{2011:[[1301752800000000000n,-36e12,-396e11],[1316872800000000000n,-396e11,-36e12],[1325239200000000000n,-36e12,504e11]]}},it=(new Date).getUTCFullYear()+10,st=[182,91,273],at=class extends Ve{constructor(n){const e=new tt("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(e.resolvedOptions().timeZone),this.format=e,this.yearEndOffsets={},this.transitionsInYear=rt[n]||{}}getPossibleOffsets(n){let e;const t=[this.getTransition(n,-1),this.getTransition(n-1n,1)].filter(Boolean);for(const o of t){const[t,r,i]=o,s=n-BigInt(r),a=n-BigInt(i);if(t>s&&t>a)return[r];if(!(t<=s&&t<=a))return[r,i];e=i}return void 0!==e?[e]:[1e9*this.getYearEndOffsetSec(Fn(n))]}getOffset(n){return 1e9*this.getOffsetForEpochSecs(Number(n/t))}getOffsetForEpochSecs(n){const e=_e(this.format,1e3*n);let t=parseInt(e.year);"bce"===et(e.era)&&(t=-(t-1));const o=pn(t,parseInt(e.month),parseInt(e.day),parseInt(e.hour),parseInt(e.minute),parseInt(e.second));return Math.floor(o/1e3)-n}getTransition(n,e){let t=Fn(n);if(t>it){const o=this.getTransitionFrom(t,t+e,e,n);if(o||e>0)return o;t=it}return this.getTransitionFrom(Math.max(t,1847),e<0?1846:it,e,n)}getTransitionFrom(n,e,t,o){for(;n!==e;n+=t){let e=this.getTransitionsInYear(n);t<0&&(e=e.slice().reverse());for(const n of e)if(j(n[0],o)===t)return n}}getYearEndOffsetSec(n){const{yearEndOffsets:e}=this;return e[n]||(e[n]=this.getOffsetForEpochSecs(Sn(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:e}=this;return e[n]||(e[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const e=this.getYearEndOffsetSec(n-1),t=this.getYearEndOffsetSec(n),o=Sn(n)-1,r=Sn(n+1)-1;if(e!==t)return[this.searchTransition(o,r,e,t)];const i=this.searchIsland(e,o);return void 0!==i?[this.searchTransition(o,i[0],e,i[1]),this.searchTransition(i[0],r,i[1],t)]:[]}searchTransition(n,e,o,r){for(;e-n>1;){const t=Math.floor(n+(e-n)/2);this.getOffsetForEpochSecs(t)===o?n=t:e=t}return[BigInt(e)*t,1e9*o,1e9*r]}searchIsland(n,e){for(const t of st){const o=e+86400*t,r=this.getOffsetForEpochSecs(o);if(r!==n)return[o,r]}}},ct={UTC:new Xe("UTC",0)};var[ut,dt]=v(),ht=class extends R{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),dt(this,function(n){const e=(n=String(n)).toLocaleUpperCase();if(ct[e])return ct[e];const t=qe(n);if(void 0!==t){if(Math.abs(t)>s)throw new RangeError("Offset out of bounds");return new Xe(_n(t),t)}return ct[e]=new at(n)}(n))}static from(n){if("object"==typeof n)return function(n){return n.timeZone}(n)?function(n){if("object"==typeof n){if("string"==typeof n.id)return n;throw new RangeError("Invalid timeZone")}return new ht(String(n))}(n.timeZone):n;const e=Be(String(n));if(e){if(e.timeZone){const n=Qe(e);return function(n){const{offsetNanoseconds:e,timeZone:t,Z:o}=n;if(void 0!==e&&!o&&void 0===we(n,e,t,!0))throw new RangeError("Mismatching offset/timezone")}(n),n.timeZone}if(e.Z)return new ht("UTC");if(void 0!==e.offsetNanoseconds)return new ht(_n(e.offsetNanoseconds))}return new ht(n)}get id(){return this.toString()}getOffsetStringFor(n){return _n(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const e=U(Sr,n);return ut(this).getOffset(e.epochNanoseconds)}getPlainDateTimeFor(n,e=sr()){const t=U(Sr,n);return Zo({...vn(t.epochNanoseconds+BigInt(this.getOffsetNanosecondsFor(t))),calendar:U(ir,e)})}getInstantFor(n,e){const t=Kn(e),o=yn(U(Eo,n).getISOFields()),r=ut(this).getPossibleOffsets(o);let i;if(1===r.length||0===t)i=r[0];else{if(3===t)throw new RangeError("Ambiguous offset");i=Math[1===t?"max":"min"](...r)}return new Sr(o-BigInt(i))}getPossibleInstantsFor(n){const e=yn(U(Eo,n).getISOFields());let t=ut(this).getPossibleOffsets(e);return 2===t.length&&t[0]<t[1]&&(t=[]),t.map((n=>new Sr(e-BigInt(n))))}getPreviousTransition(n){const e=U(Sr,n),t=ut(this).getTransition(e.epochNanoseconds,-1);return t?new Sr(t[0]):null}getNextTransition(n){const e=U(Sr,n),t=ut(this).getTransition(e.epochNanoseconds,1);return t?new Sr(t[0]):null}toString(){return ut(this).id}};function ft(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return U(ht,n.timeZone)}de(ht,"TimeZone");var lt=Pt((function(n,e,t){const o=Ot(n,e,t);if(o)return{...o,timeZone:ft(n),offsetNanoseconds:void 0!==n.offset?Ue(String(n.offset)):void 0}})),mt=Pt(Ot),gt=Pt(Tt),yt=Pt((function(n,e){const t=ur(n),o=Ct(n,jn,t);if(Bt(o))return t.yearMonthFromFields(o,e)})),wt=Pt((function(n,e){const t=ur(n),o=Ct(n,Ln,t);if(Bt(o))return void 0===n.year&&void 0===n.calendar&&(o.year=gn),t.monthDayFromFields(o,e)})),pt=Pt(Dt),vt=Pt((function(n,e,t,o){const r=Yt(n,e,t,o),i=void 0!==e.offset;if(r||i)return{...r||n.getISOFields(),timeZone:n.timeZone,offsetNanoseconds:i?Ue(String(e.offset)):n.offsetNanoseconds}}),!0),Mt=Pt(Yt,!0),It=Pt(Et,!0),St=Pt((function(n,e,t){const o=n.calendar;if(Bt(Ct(e,jn,o))){const r=Rt(n,e,jn,o);return o.yearMonthFromFields(r,t)}}),!0),Ft=Pt((function(n,e,t){const o=n.calendar;if(Bt(Ct(e,Ln,o))){const r=Rt(n,e,Ln,o);return o.monthDayFromFields(r,t)}}),!0),bt=Pt(Zt,!0),Nt=Pt((function(n){const e=m(n,$n);if(Bt(e))return e}));function Ot(n,e,t){const o=Tt(n,t),r=Dt(n,e);if(o)return{...o.getISOFields(),...r||X}}function Tt(n,e){const t=ur(n),o=Ct(n,qn,t);if(Bt(o))return t.dateFromFields(o,e)}function Dt(n,e){const t=m(n,Hn);if(Bt(t))return xn(nn(t),e)}function Yt(n,e,t,o){const r=Et(n,e,o),i=Zt(n,e,t);if(r||i)return{...n.getISOFields(),...r?r.getISOFields():{},...i}}function Et(n,e,t){const o=n.calendar,r=Ct(e,qn,o);if(Bt(r)){const e=Rt(n,r,qn,o);return o.dateFromFields(e,t)}}function Zt(n,e,t){const o=m(e,Hn);if(Bt(o)){return xn(nn((r=n,i=o,I(Hn,((n,e)=>i[e]??r[e])))),t)}var r,i}function Ct(n,e,t){let o=Object.keys(e);return o=t.fields?t.fields(o):Object.keys(Ut(t,o)),Ut(n,o)}function Ut(n,e){const t={};for(const o of e)void 0!==n[o]&&(t[o]=n[o]);return t}function Rt(n,e,t,o){const r=Ct(n,t,o);return o.mergeFields?o.mergeFields(r,e):ar(r,e)}function Pt(n,e){return(...t)=>{if(e){const n=t[1];if(!w(n))throw new TypeError("must be object-like");if(void 0!==n.calendar)throw new TypeError("calendar not allowed");if(void 0!==n.timeZone)throw new TypeError("timeZone not allowed")}const o=n(...t);if(!o)throw new TypeError("No valid fields");return o}}function Bt(n){return Object.keys(n).length>0}function kt(n,e){const t=yn(n);xt(t),_o(t,e)}function xt(n){(n<-8640000086399999999999n||n>8640000086399999999999n)&&Tn()}function jt(n,e){const t=Lt(on(n),e),[o,r]=sn(t);return{...me(n,r),...o}}function qt(n,e){const t=Lt(on(n),e),[o]=sn(t);return o}function Ht(n,e){const[t,o]=function(n){const e=vn(n);return[wn(e.isoYear,e.isoMonth,e.isoDay),on(e)]}(n),r=Lt(o,e);return t+BigInt(r)}function Lt(n,e){return H(n,e.incNano,e.roundingFunc)}function $t(n,e,t){return(o,r)=>{const i=Jt(n,r)?{}:{...n,...e};return{buildKey:Gt(o,r,!1),buildFormat:function(n,e){return new tt(o,{calendar:n,timeZone:e||void 0,...i,...r,...t})},buildEpochMilli:zt}}}function zt(n){return n.epochMilliseconds}function At(n,e,t){return(o,r)=>{const i=Jt(n,r)?{}:n;return{buildKey:Gt(o,r,t),buildFormat:function(n,t){return new tt(o,{calendar:n,...i,...r,...e,timeZone:t,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?Wt.bind(null,new ht(r.timeZone)):Kt}}}function Wt(n,e){const t=Zo({...X,...e.getISOFields()});return n.getInstantFor(t).epochMilliseconds}function Kt(n){return pn((e=n.getISOFields()).isoYear,e.isoMonth,e.isoDay,e.isoHour,e.isoMinute,e.isoSecond,e.isoMillisecond);var e}function Gt(n,e,t){const o=e.calendar??function(n){for(const e of n){const n=e.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),r=e.timeZone;return function(n,e){const i=n.calendar?.id,s=n.timeZone?.id;if(e){if(e.calendar?.id!==i)throw new RangeError("Mismatching calendar");if(e.timeZone?.id!==s)throw new RangeError("Mismatching timeZone")}if((t||"iso8601"!==i)&&void 0!==i&&void 0!==o&&o!==i)throw new RangeError("Non-iso calendar mismatch");if(void 0!==s&&void 0!==r&&r!==s)throw new RangeError("Given timeZone must agree");return[o||i||"iso8601",r||s||"UTC"]}}function Jt(n,e){for(const t in n)if(void 0!==e[t])return!0;return!1}function Qt(n,e){n.prototype.toLocaleString=function(n,t){const o=e(ot(n),t||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[C]=e}function Vt(n){return n?.[C]}function Xt(n){const e=function(n){const e=Te.exec(Ee(n));if(e){let n,t,o,r;[n,r]=_t(e[8],e[10],5,void 0),[t,r]=_t(e[12],e[14],4,r),[o,r]=_t(e[16],e[18],3,r);const i=function(n){const e={};for(const t in n)void 0!==n[t]&&(e[t]=n[t]);return e}({years:Ke(e[2]),months:Ke(e[3]),weeks:Ke(e[4]),days:Ke(e[5]),hours:n,minutes:t,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=rn(BigInt(r||0),2);i.milliseconds=s.milliseconds,i.microseconds=s.microseconds,i.nanoseconds=s.nanoseconds;let a=J(i);return"-"===e[1]&&(a=K(a)),a}}(n);if(void 0===e)throw Ge("duration",n);return e}function _t(n,e,t,o){if(void 0!==n){if(void 0!==o)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==e?ze(e)*(a[t]/1e9):void 0]}if(void 0!==o){const n=Math.trunc(o/a[t]);return[n,o-n*a[t]]}return[void 0,void 0]}var no=f("offset",{auto:0,never:1},0),eo=class extends x{constructor(n=0,e=0,t=0,o=0,r=0,i=0){super({...xn({isoHour:n,isoMinute:e,isoSecond:t,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},1),calendar:sr()})}static from(n,e){const t=h(e);return to(n instanceof eo?n.getISOFields():"object"==typeof n?pt(n,t):Re(String(n)))}static compare(n,e){return Cn(U(eo,n),U(eo,e))}with(n,e){return to(bt(this,n,h(e)))}add(n){return ro(this,U(To,n))}subtract(n){return ro(this,K(U(To,n)))}until(n,e){return io(this,U(eo,n),e)}since(n,e){return io(U(eo,n),this,e)}round(n){const e=Z(n,void 0,0,5);return to(qt(this.getISOFields(),e))}equals(n){return!Cn(this,U(eo,n))}toString(n){const e=Wn(n);return Xn(qt(this.getISOFields(),e),e)}toZonedDateTime(n){const e=U(lr,n.plainDate),t=U(ht,n.timeZone);return go({...e.getISOFields(),...this.getISOFields(),timeZone:t})}toPlainDateTime(n){return U(lr,n).toPlainDateTime(this)}};function to(n){return new eo(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function oo(n){return U(eo,n??{hour:0})}function ro(n,e){return to(function(n,e){const t=on(n)+Number(tn(e)),[o]=sn(t);return o}(n.getISOFields(),e))}function io(n,e,t){const o=E(t,5,0,0,5);return Do(function(n,e,t){const o=H(on(e)-on(n),a[t.smallestUnit]*t.roundingIncrement,t.roundingFunc);return rn(BigInt(o),t.largestUnit)}(n.getISOFields(),e.getISOFields(),o))}de(eo,"PlainTime"),se(eo,b),Qt(eo,(function(n,e){return{buildKey:()=>["",""],buildFormat:()=>new tt(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...e,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Math.trunc(on(n.getISOFields())/1e6)}}));var so={day:1},ao=class extends x{constructor(n,e,t=sr(),o=1){const r=Bn({isoYear:n,isoMonth:e,isoDay:o},1),i=U(ir,t);var s,a;s=r,a=i.id,_o(yn(s),a),super({...r,calendar:i})}static from(n,e){if(h(e),n instanceof ao)return co(n.getISOFields());if("object"==typeof n)return yt(n,e);const t=function(n){const e=xe(n)||ke(n);if(!e)throw Ge("yearMonth",n);return e}(String(n));return void 0===t.calendar&&(t.isoDay=1),co(Je(t))}static compare(n,e){return Zn(U(ao,n),U(ao,e))}with(n,e){return St(this,n,e)}add(n,e){return uo(this,U(To,n),e)}subtract(n,e){return uo(this,K(U(To,n)),e)}until(n,e){return ho(this,U(ao,n),!1,e)}since(n,e){return ho(this,U(ao,n),!0,e)}equals(n){return!Zn(this,U(ao,n))}toString(n){const e=this.getISOFields(),t=e.calendar.toString(),o=An(n);return("iso8601"===t?Vn(e):Qn(e))+ne(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}};function co(n){return new ao(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function uo(n,e,t){return n.toPlainDate({day:e.sign<0?n.daysInMonth:1}).add(e,t).toPlainYearMonth()}function ho(n,e,t,o){return Do(wr(n.toPlainDate(so),e.toPlainDate(so),dr(n,e),t,E(o,9,8,8,9)))}de(ao,"PlainYearMonth"),se(ao),ue(ao,ae),Qt(ao,At({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));var[fo,lo]=v(),mo=class extends x{constructor(n,e,t=sr()){const o=U(ht,e),r=U(ir,t),[i,s]=yo(n,o);kt(i,r.id),super({...i,calendar:r,timeZone:o,offset:_n(s)}),lo(this,{epochNanoseconds:n,offsetNanoseconds:s})}static from(n,e){const t=he(e,3),o=h(e);if(n instanceof mo)return new mo(n.epochNanoseconds,n.timeZone,n.calendar);const r="object"==typeof n;return go(r?lt(n,o,e):Qe(Ze(String(n))),!r,t,e)}static compare(n,e){return Rn(U(mo,n),U(mo,e))}get timeZone(){return this.getISOFields().timeZone}get epochNanoseconds(){return fo(this).epochNanoseconds}get offsetNanoseconds(){return fo(this).offsetNanoseconds}get offset(){return this.getISOFields().offset}with(n,e){Kn(e);const t=h(e),o=he(e,0);return go(vt(this,n,t,e),!1,o,e)}withPlainDate(n){const e=U(lr,n),t=e.toPlainDateTime(this),{timeZone:o}=this,r=o.getInstantFor(t);return new mo(r.epochNanoseconds,o,hr(this,e))}withPlainTime(n){return go({...this.getISOFields(),...void 0===n?X:U(eo,n).getISOFields()})}withCalendar(n){return new mo(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new mo(this.epochNanoseconds,n,this.calendar)}add(n,e){return wo(this,U(To,n),e)}subtract(n,e){return wo(this,K(U(To,n)),e)}until(n,e){return vo(this,U(mo,n),!1,e)}since(n,e){return vo(this,U(mo,n),!0,e)}round(n){return po(this,Z(n,void 0,0,6))}equals(n){return En(this,U(mo,n))}startOfDay(){return go({...this.getISOFields(),...X,offsetNanoseconds:this.offsetNanoseconds},!1,0)}get hoursInDay(){return pe(this.getISOFields())/36e11}toString(n){const e=Wn(n),t=no(n),o=Gn(n),r=An(n),i=po(this,e);return Jn(i.getISOFields(),e)+(0===t?_n(L(i.offsetNanoseconds)):"")+(s=this.timeZone.toString(),1!==o?`[${s}]`:"")+ne(this.calendar.toString(),r);var s}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return Zo(this.getISOFields())}toPlainDate(){return mr(this.getISOFields())}toPlainTime(){return to(this.getISOFields())}toInstant(){return new Sr(this.epochNanoseconds)}};function go(n,e,t,o){const r=ye(n,e,t,o);return new mo(r,n.timeZone,n.calendar)}function yo(n,e){const t=new Sr(n),o=e.getOffsetNanosecondsFor(t);return[vn(n+BigInt(o)),o]}function wo(n,e,t){const o=n.getISOFields(),r=function(n,e,t){const{calendar:o,timeZone:r}=n,i=o.dateAdd(mr(n),G(e,_),t),s=Zo({...n,...i.getISOFields()});return r.getInstantFor(s).epochNanoseconds+tn(e)}(o,e,t);return new mo(r,o.timeZone,o.calendar)}function po(n,e){const t=n.getISOFields(),o=function(n,e,t){const{calendar:o,timeZone:r}=n;let i,s,a=on(n);return 6===t.smallestUnit?(i=X,s=t.roundingFunc(a/pe(n))):(a=Lt(a,t),[i,s]=sn(a)),ye({...me(n,s),...i,offsetNanoseconds:e,calendar:o,timeZone:r},!1,0)}(t,n.offsetNanoseconds,e);return new mo(o,t.timeZone,t.calendar)}function vo(n,e,t,o){const r=E(o,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==e.timeZone.id)throw new Error("Must be same timeZone");return Do(yr(n,e,dr(n,e),t,r))}function Mo(n){if(void 0===n)return;if(w(n))return n instanceof mo||n instanceof Eo?n:U(void 0!==n.timeZone?mo:Eo,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const e=Be(String(n));if(e)return void 0!==e.timeZone?go(Qe(e),!0):Zo(Je(e));throw new RangeError("Invalid value of relativeTo")}function Io(n,e,t,o){return(t instanceof lr?function(n,e,t,o){const r=t.add(n);return[o.dateUntil(t,r,{largestUnit:N[e]}),r]}(n,Math.max(6,e),t,o):So(n,e,t,o))[0]}function So(n,e,t,o,r){const i=!0!==r&&e>7&&n.weeks;i&&(n=G(n,{weeks:0}));let s=t.add(n),a=pr(t,s,o,e);return i&&(a=G(a,{weeks:i}),s=s.add({weeks:i})),[a,s]}function Fo(n,e,t,o){const r=O[e],{sign:i}=n;if(!i)return n;const s={};for(let t=9;t>=e;t--){const e=O[t];s[e]=n[e]}const a={[r]:i},c=t.add(s),u=c.add(a),d=In(c),h=In(u),f=In(o),l=Number(f-d)/Number(h-d)*i;return s[r]+=l,s}function bo(n,e,t,o,r,i){const{largestUnit:s,smallestUnit:c,roundingIncrement:u,roundingFunc:h}=i;if(!d(s)){return rn(z((In(t)-In(e))*(r?-1n:1n),a[c]*u,h),s)}let f=Fo(n,c,e,t);const l=O[c];function m(){const n=f[l];f[l]=H(n,u,h)}return h===Math.round&&m(),r&&(f=K(f)),h!==Math.round&&m(),c>0&&(f=r?K(Io(K(f),s,e,o)):Io(f,s,e,o)),f}de(mo,"ZonedDateTime"),se(mo,b),ue(mo,ce),oe(mo),Qt(mo,$t({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));var[No,Oo]=v(),To=class extends P{constructor(n=0,e=0,t=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super();const d=Nt({years:n,months:e,weeks:t,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u});Oo(this,function(n){const e=J(n),{sign:t}=e;for(const n of O){const o=e[n],r=q(e[n]);if(r&&r!==t)throw new RangeError("All fields must be same sign");if(!Number.isInteger(o))throw new RangeError("Duration fields must be integers")}return e}(d))}static from(n){return Do("object"==typeof n?Nt(n):Xt(n))}static compare(n,e,t){return function(n,e,t){if(void 0===t&&V(n)<=6&&V(e)<=6)return j(en(n),en(e));if(!t)throw new RangeError("Need relativeTo");const o=t.add(n),r=t.add(e);return void 0!==t.epochNanoseconds?Rn(o,r):Zn(o,r)}(U(To,n),U(To,e),Mo(g(t).relativeTo))}get years(){return No(this).years}get months(){return No(this).months}get weeks(){return No(this).weeks}get days(){return No(this).days}get hours(){return No(this).hours}get minutes(){return No(this).minutes}get seconds(){return No(this).seconds}get milliseconds(){return No(this).milliseconds}get microseconds(){return No(this).microseconds}get nanoseconds(){return No(this).nanoseconds}get sign(){return No(this).sign}get blank(){return!this.sign}with(n){return Do({...No(this),...Nt(n)})}negated(){return Do(K(No(this)))}abs(){return Do(S(No(this),W,(n=>Math.abs(n))))}add(n,e){return Yo(this,U(To,n),e)}subtract(n,e){return Yo(this,K(U(To,n)),e)}round(n){const e="string"==typeof n?{smallestUnit:n}:n;if(!w(e))throw new TypeError("Must specify options");if(void 0===e.largestUnit&&void 0===e.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const t=E(e,V(this),0,0,9,!0),o=Mo(e.relativeTo);return Do(function(n,e,t,o){const{largestUnit:r,smallestUnit:i,roundingIncrement:s,roundingFunc:c}=e;if(void 0===t&&V(n)<=6&&u(r)&&u(i))return rn(z(en(n),a[i]*s,c),r);if(!t)throw new RangeError("Need relativeTo");const[d,h]=So(n,r,t,o);return bo(d,t,h,o,!1,e)}(this,t,o,o?o.calendar:void 0))}total(n){const e=function(n){let e,t;return"string"==typeof n?t=n:(t=g(n).unit,e=n.relativeTo),{unit:Y(t,void 0,0,9),relativeTo:e}}(n),t=Mo(e.relativeTo);return function(n,e,t,o){if(void 0===t&&V(n)<=6&&u(e))return Number(en(n))/a[e];if(!t)throw new RangeError("Need relativeTo");const[r,i]=So(n,e,t,o,!0);return Fo(r,e,t,i)[O[e]]}(this,e.unit,t,t?t.calendar:void 0)}toString(n){const e=Wn(n,3);return function(n,e){const{smallestUnit:t,fractionalSecondDigits:o,roundingFunc:r}=e,{sign:i}=n,s=BigInt(n.hours),a=BigInt(n.minutes);let c=BigInt(n.seconds),u="";if(t<=3){const e=te(n.milliseconds,n.microseconds,n.nanoseconds,o,r,t);u=e[0],c+=BigInt(e[1])}const d=void 0!==o||u||!i;return(i<0?"-":"")+"P"+ee([[BigInt(n.years),"Y"],[BigInt(n.months),"M"],[BigInt(n.weeks),"W"],[BigInt(n.days),"D"]])+(s||a||c||d?"T"+ee([[s,"H"],[a,"M"],[t<=3?c:BigInt(0),u+"S",d]]):"")}(No(this),e)}toLocaleString(n,e){return this.toString()}};function Do(n){return new To(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function Yo(n,e,t){const o=Mo(g(t).relativeTo);return Do(function(n,e,t,o){const r=Math.max(V(n),V(e));if(void 0===t&&r<=6)return rn(en(n)+en(e),r);if(!t)throw new RangeError("Need relativeTo");const i=t.add(n).add(e);return pr(t,i,o,r)}(n,e,o,o?o.calendar:void 0))}de(To,"Duration");var Eo=class extends x{constructor(n,e,t,o=0,r=0,i=0,s=0,a=0,c=0,u=sr()){const d=kn({isoYear:n,isoMonth:e,isoDay:t,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:c},1),h=U(ir,u);kt(d,h.id),super({...d,calendar:h})}static from(n,e){const t=h(e);return Zo(n instanceof Eo?n.getISOFields():"object"==typeof n?mt(n,t,e):Je(Ce(String(n))))}static compare(n,e){return Zn(U(Eo,n),U(Eo,e))}with(n,e){const t=h(e);return Zo(Mt(this,n,t,e))}withPlainDate(n){const e=U(lr,n);return Zo({...this.getISOFields(),...e.getISOFields(),calendar:hr(this,e)})}withPlainTime(n){return Zo({...this.getISOFields(),...oo(n).getISOFields()})}withCalendar(n){return Zo({...this.getISOFields(),calendar:U(ir,n)})}add(n,e){return Co(this,U(To,n),e)}subtract(n,e){return Co(this,K(U(To,n)),e)}until(n,e){return Uo(this,U(Eo,n),!1,e)}since(n,e){return Uo(this,U(Eo,n),!0,e)}round(n){const e=Z(n,void 0,0,6);return Zo({...jt(this.getISOFields(),e),calendar:this.calendar})}equals(n){return!Zn(this,U(Eo,n))}toString(n){const e=Wn(n),t=An(n);return Jn(jt(this.getISOFields(),e),e)+ne(this.calendar.toString(),t)}toZonedDateTime(n,e){const t=U(ht,n),o=t.getInstantFor(this,e);return new mo(o.epochNanoseconds,t,this.calendar)}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return mr(this.getISOFields())}toPlainTime(){return to(this.getISOFields())}};function Zo(n){return new Eo(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function Co(n,e,t){const o=function(n,e,t){const{calendar:o}=n;return vn(yn(o.dateAdd(mr(n),G(e,_),t).getISOFields())+BigInt(on(n))+tn(e))}(n.getISOFields(),e,t);return Zo({...o,calendar:n.calendar})}function Uo(n,e,t,o){const r=E(o,6,0,0,9);return Do(yr(n,e,dr(n,e),t,r))}de(Eo,"PlainDateTime"),se(Eo,b),ue(Eo,ce),Qt(Eo,At({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));var Ro=class extends x{constructor(n,e,t=sr(),o=gn){super({...Bn({isoYear:o,isoMonth:n,isoDay:e},1),calendar:t})}static from(n,e){if(h(e),n instanceof Ro)return Po(n.getISOFields());if("object"==typeof n)return wt(n,e);const t=function(n){const e=je(n)||ke(n);if(!e)throw Ge("monthDay",n);return e}(String(n));return void 0===t.calendar&&(t.isoYear=gn),Po(Je(t))}with(n,e){return Ft(this,n,e)}equals(n){return!Zn(this,U(Ro,n))}toString(n){const e=this.getISOFields(),t=e.calendar.toString(),o=An(n);return("iso8601"===t?function(n){return an(n.isoMonth,2)+"-"+an(n.isoDay,2)}(e):Qn(e))+ne(t,o)}toPlainDate(n){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},{overflow:"reject"})}};function Po(n){return new Ro(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function Bo(n){return n instanceof lr||n instanceof Eo||n instanceof mo||n instanceof ao||n instanceof Ro}function ko(n,e,t){let o;if(n instanceof lr)o=n;else if(Bo(n)){if(t&&n instanceof Ro)throw new TypeError("PlainMonthDay not allowed");o=mr(n.getISOFields())}else o=lr.from(n);return fr(o.calendar,e),o}function xo(n,e,t){if(Bo(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;const u=void 0!==r&&void 0!==o?hn(e.id,r,o):void 0;if(void 0===i){if(void 0===u)throw new TypeError("Must specify either a year or an era & eraYear");i=u}else if(void 0!==u&&u!==i)throw new RangeError("year and era/eraYear must match");if(void 0===c)throw new TypeError("Must specify day");const d=h(t);if(void 0!==a){const[n,t]=e.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,t){if(1===d)throw new RangeError("Month code out of range");c=e.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,c]=Pn(i,s,c,e,d),Mn(e.epochMilliseconds(i,s,c))}function jo(n,e){if(Bo(n)){if(e&&n instanceof Ro)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return lr.from(n).getISOFields()}function qo(n,e){return Dn(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e+1,1,1))}function Ho(n,e,t,o){return Dn(n.epochMilliseconds(e,1,1),n.epochMilliseconds(e,t,o))+1}de(Ro,"PlainMonthDay"),se(Ro),ue(Ro,["monthCode","day"]),Qt(Ro,At({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));var Lo={hebrew:6,chinese:0,dangi:0},$o=class extends dn{constructor(n){const e=zo(n);if(t=n,o=e.resolvedOptions().calendar,fn(t)!==fn(o))throw new RangeError("Invalid calendar: "+n);var t,o;super(n),this.format=e,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,e,t){return Yn(this.queryMonthCache(n)[0][e-1],t-1)}daysInMonth(n,e){const t=this.queryMonthCache(n)[0],o=t[e-1];e>=t.length&&(n++,e=0);return Dn(o,this.queryMonthCache(n)[0][e])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,e){const t=this.queryLeapMonthByYear(e);return!t||n<t?super.monthCode(n,e):super.monthCode(n-1,e)+(n===t?"L":"")}convertMonthCode(n,e){const t=this.queryLeapMonthByYear(e);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=Lo[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||t&&r===t-1||(i=!0,o=!1),(o||t&&r>=t)&&r++,[r,i]}inLeapYear(n){const e=qo(this,n);return e>qo(this,n-1)&&e>qo(this,n+1)}guessYearForMonthDay(n,e){let t=1970+this.yearCorrection;const o=t+100;for(;t<o;t++){const[o,r]=this.convertMonthCode(n,t);if(!r&&o<=this.monthsInYear(t)&&e<=this.daysInMonth(t,o))return t}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const e=this.computeFieldsDumb(n),t=this.queryMonthCache(e.year)[2];return{...e,month:t[e.month]}}computeFieldsDumb(n){const e=_e(this.format,n);let t,o,r=parseInt(e.relatedYear||e.year);var i;return e.era&&(i=this.id,void 0!==un[fn(i)])&&(t=et(e.era),o=r,r=hn(this.id,o,t,!0)),{era:t,eraYear:o,year:r,month:e.month,day:parseInt(e.day)}}queryLeapMonthByYear(n){const e=this.queryMonthCache(n),t=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(e[0].length>t[0].length&&e[0].length>o[0].length){const n=e[1],o=t[1];for(let e=0;e<o.length;e++)if(o[e]!==n[e])return e+1}}queryMonthCache(n){const{monthCacheByYear:e}=this;return e[n]||(e[n]=this.buildMonthCache(n))}buildMonthCache(n){const e=[],t=[],o={};let r=pn(this.guessISOYear(n),1,1);for(r=Yn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=Yn(r,1-o.day),o.year===n&&(e.unshift(r),t.unshift(o.month)),r=Yn(r,-1)}for(let n=0;n<t.length;n++)o[t[n]]=n+1;return[e,t,o]}guessISOYear(n){return n-this.yearCorrection}};function zo(n){return new tt("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}var Ao=pn(1868,9,8),Wo={gregory:zn,japanese:class extends zn{constructor(){super(...arguments),this.format=zo("japanese")}computeFields(n){const e=super.computeFields(n);if(n>=Ao){const t=_e(this.format,n);e.era=et(t.era),e.eraYear=parseInt(t.relatedYear||t.year)}return e}},islamic:class extends $o{guessISOYear(n){return Math.ceil(32*n/33+622)}}},Ko={iso8601:mn};function Go(n){const e=(n=String(n)).toLocaleLowerCase();return Ko[e]||(Ko[e]=new(Wo[fn(e)]||$o)(n))}var Jo=pn(1582,10,15),Qo=pn(622,7,18),Vo={buddhist:Jo,japanese:Jo,roc:Jo,islamic:Qo,"islamic-rgsa":Qo,indian:0},Xo={};function _o(n,t){return nr(Number(n/e),t)}function nr(n,e){if(function(n,e){return function(n){let e=Xo[n];if(void 0===e){const t=Vo[n];if(void 0===t)e=!1;else{let o=Go(n);o instanceof $o||(o=new $o(n));const r=t-864e5,i=o.computeFields(r);e=r!==o.epochMilliseconds(i.year,i.month,i.day)}Xo[n]=e}return e}(e)&&n<Vo[e]}(n,e))throw new RangeError("Invalid timestamp for calendar")}function er(n,e,t){const o=7+e-t;return-A(bn(n,1,o)-e,7)+o-1}function tr(n,e,t){const o=er(n,e,t),r=er(n+1,e,t);return(qo(mn,n)-o+r)/7}var[or,rr]=v(),ir=class extends R{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),rr(this,Go(n))}static from(n){if("object"==typeof n&&n)return function(n){return n.calendar}(n)?function(n){if("object"==typeof n&&n){if("string"==typeof n.id)return n;throw new RangeError("Invalid calendar")}return new ir(String(n))}(n.calendar):n;const e=ke(String(n),!1,!0);return new ir(e?e.calendar||"iso8601":n)}get id(){return this.toString()}era(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).era}eraYear(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).eraYear}year(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).year}month(n){const e=jo(n,!0);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).month}monthCode(n){const e=ko(n,this);return or(this).monthCode(e.month,e.year)}day(n){const e=jo(n);return cr(or(this),e.isoYear,e.isoMonth,e.isoDay).day}dayOfWeek(n){const e=jo(n,!0);return bn(e.isoYear,e.isoMonth,e.isoDay)}dayOfYear(n){const e=ko(n,this,!0);return Ho(or(this),e.year,e.month,e.day)}weekOfYear(n){const e=jo(n,!0);return function(n,e,t,o,r){const i=er(n,o,r),s=Math.floor((Ho(mn,n,e,t)-i-1)/7)+1;if(s<1)return s+tr(n-1,o,r);const a=tr(n,o,r);return s>a?s-a:s}(e.isoYear,e.isoMonth,e.isoDay,1,4)}daysInWeek(n){return jo(n,!0),7}daysInMonth(n){const e=ko(n,this,!0);return or(this).daysInMonth(e.year,e.month)}daysInYear(n){const e=ko(n,this,!0);return qo(or(this),e.year)}monthsInYear(n){const e=ko(n,this,!0);return or(this).monthsInYear(e.year)}inLeapYear(n){return or(this).inLeapYear(this.year(n))}dateFromFields(n,e){const t=xo(m(n,qn),or(this),e);return new lr(t.isoYear,t.isoMonth,t.isoDay,this)}yearMonthFromFields(n,e){const t=xo({...m(n,jn),day:1},or(this),e);return new ao(t.isoYear,t.isoMonth,this,t.isoDay)}monthDayFromFields(n,e){const t=or(this),o=m(n,Ln);let{era:r,eraYear:i,year:s,month:a,monthCode:c,day:u}=o;if(void 0===u)throw new TypeError("required property 'day' missing or undefined");if(void 0!==c?s=gn:void 0!==r&&void 0!==i&&(s=hn(t.id,i,r)),void 0===s){if(void 0===c)throw new TypeError("either year or monthCode required with month");s=t.guessYearForMonthDay(c,u)}const d=xo({year:s,month:a,monthCode:c,day:u},t,e);return new Ro(d.isoMonth,d.isoDay,this,t.normalizeISOYearForMonthDay(d.isoYear))}dateAdd(n,e,t){const o=or(this),r=function(n,e,t,o){n=le(n=fe(n,e.years,t,o),e.months,t,o);let r=t.epochMilliseconds(n.year,n.month,n.day);const i=Math.trunc(Number(tn(e))/s);return r=Yn(r,7*e.weeks+e.days+i),Mn(r)}(U(lr,n,t),U(To,e),o,h(t));return new lr(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,e,t){const o=or(this),r=U(lr,n),i=U(lr,e),s=Y(g(t).largestUnit,6,6,9);return fr(this,dr(r,i)),Do(function(n,e,t,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,e,t){const[,o,r]=Pn(e.year,n.month,n.day,t,0),i=Un(e,n),s=j(e.month,o)||j(e.day,r);return e.year-n.year-(s&&i&&s!==i?i:0)}(n,e,t),n=fe(n,r,t,0);case 8:i=function(n,e,t){let o=0;const r=Un(e,n);if(r){let{year:i}=n;for(;i!==e.year;)o+=t.monthsInYear(i)*r,i+=r;const[,s,a]=Pn(e.year,n.month,n.day,t,0);o+=e.month-s;const c=j(e.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,e,t),n=le(n,i,t,0)}a=Dn(t.epochMilliseconds(n.year,n.month,n.day),t.epochMilliseconds(e.year,e.month,e.day)),7===o&&(s=Math.trunc(a/7),a%=7);return J({years:r,months:i,weeks:s,days:a,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0})}(r,i,o,s))}fields(n){return n.slice()}mergeFields(n,e){return ar(n,e)}toString(){return or(this).id}};function sr(){return new ir("iso8601")}function ar(n,e){const t={...n,...e};if(void 0!==n.year){delete t.era,delete t.eraYear,delete t.year;let o=!1;void 0===e.era&&void 0===e.eraYear||(t.era=e.era,t.eraYear=e.eraYear,o=!0),void 0!==e.year&&(t.year=e.year,o=!0),o||(t.year=n.year)}if(void 0!==n.monthCode){delete t.monthCode,delete t.month;let o=!1;void 0!==e.month&&(t.month=e.month,o=!0),void 0!==e.monthCode&&(t.monthCode=e.monthCode,o=!0),o||(t.monthCode=n.monthCode)}return void 0!==n.day&&(t.day=e.day??n.day),t}function cr(n,e,t,o){const r=pn(e,t,o);return nr(r,n.id),n.computeFields(r)}function ur(n){return void 0===n.calendar?sr():U(ir,n.calendar)}function dr(n,e){const{calendar:t}=n;return fr(t,e.calendar),t}function hr(n,e){const t=n.calendar,o=e.calendar;if("iso8601"===t.id)return o;if("iso8601"===o.id)return t;if(t.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return t}function fr(n,e){if(n.id!==e.id)throw new RangeError("Calendars must match")}de(ir,"Calendar");var lr=class extends x{constructor(n,e,t,o=sr()){const r=Bn({isoYear:n,isoMonth:e,isoDay:t},1),i=U(ir,o);!function(n,e){const t=yn(n);xt(t+(t<0n?86399999999999n:0n)),_o(t,e)}(r,i.id),super({...r,calendar:i})}static from(n,e){return h(e),n instanceof lr?mr(n.getISOFields()):"object"==typeof n?gt(n,e):mr(Je(Ce(String(n))))}static compare(n,e){return Zn(U(lr,n),U(lr,e))}with(n,e){return It(this,n,e)}withCalendar(n){const e=this.getISOFields();return new lr(e.isoYear,e.isoMonth,e.isoDay,n)}add(n,e){return this.calendar.dateAdd(this,n,e)}subtract(n,e){return this.calendar.dateAdd(this,U(To,n).negated(),e)}until(n,e){return gr(this,U(lr,n),!1,e)}since(n,e){return gr(this,U(lr,n),!0,e)}equals(n){return!Zn(this,U(lr,n))}toString(n){const e=An(n),t=this.getISOFields();return Qn(t)+ne(t.calendar.toString(),e)}toZonedDateTime(n){const e=function(n){let e,t;if("string"==typeof n)t=n;else{if("object"!=typeof n)throw new TypeError("Invalid options/timeZone argument");if(void 0!==n.id?t=n:(t=n.timeZone,e=n.plainTime),void 0===t)throw new TypeError("Invalid timeZone argument")}return{plainTime:e,timeZone:t}}(n),t=U(ht,e.timeZone),o=void 0===e.plainTime?void 0:U(eo,e.plainTime);return go({...this.getISOFields(),...o?o.getISOFields():X,timeZone:t})}toPlainDateTime(n){return Zo({...this.getISOFields(),...oo(n).getISOFields()})}toPlainYearMonth(){return co(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}};function mr(n){return new lr(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function gr(n,e,t,o){return Do(wr(n,e,dr(n,e),t,E(o,6,6,6,9)))}function yr(n,e,t,o,r){return bo(pr(n,e,t,r.largestUnit),n,e,t,o,r)}function wr(n,e,t,o,r){return bo(t.dateUntil(n,e,{largestUnit:N[r.largestUnit]}),n,e,t,o,r)}function pr(n,e,t,o){if(!d(o))return vr(n,e,o);const r=mr({...n.getISOFields(),calendar:t});let i,s,a,c,u,h=mr({...e.getISOFields(),calendar:t});do{s=t.dateUntil(r,h,{largestUnit:N[o]}),i=n.add(s),a=vr(i,e,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(h=h.add({days:u})));return l=a,{sign:(f=s).sign||l.sign,years:f.years+l.years,months:f.months+l.months,weeks:f.weeks+l.weeks,days:f.days+l.days,hours:f.hours+l.hours,minutes:f.minutes+l.minutes,seconds:f.seconds+l.seconds,milliseconds:f.milliseconds+l.milliseconds,microseconds:f.microseconds+l.microseconds,nanoseconds:f.nanoseconds+l.nanoseconds};var f,l}function vr(n,e,t){return rn(In(e)-In(n),t)}de(lr,"PlainDate"),se(lr),ue(lr,ce),Qt(lr,At({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));var[Mr,Ir]=v(),Sr=class extends P{constructor(n){if(super(),"number"==typeof n)throw new TypeError("Must supply bigint, not number");var e;n=BigInt(n),((e=n)<-8640000000000000000000n||e>8640000000000000000000n)&&Tn(),Ir(this,n)}static from(n){if(n instanceof Sr)return new Sr(n.epochNanoseconds);const e=Ze(String(n)),t=e.offsetNanoseconds;if(void 0===t)throw new RangeError("Must specify an offset");return new Sr(yn(kn(e,1))-BigInt(t))}static fromEpochSeconds(n){return new Sr(BigInt(n)*t)}static fromEpochMilliseconds(n){return new Sr(BigInt(n)*e)}static fromEpochMicroseconds(e){return new Sr(e*n)}static fromEpochNanoseconds(n){return new Sr(n)}static compare(n,e){return Rn(U(Sr,n),U(Sr,e))}get epochNanoseconds(){return Mr(this)}add(n){return new Sr(ge(this.epochNanoseconds,U(To,n)))}subtract(n){return new Sr(ge(this.epochNanoseconds,K(U(To,n))))}until(n,e){return Fr(this,U(Sr,n),e)}since(n,e){return Fr(U(Sr,n),this,e)}round(n){const e=Z(n,void 0,0,5,!0);return new Sr(Ht(this.epochNanoseconds,e))}equals(n){return!Rn(this,U(Sr,n))}toString(n){const e=g(n).timeZone;return this.toZonedDateTimeISO(e??"UTC").toString({...n,offset:void 0===e?"never":"auto",timeZoneName:"never"})+(void 0===e?"Z":"")}toZonedDateTimeISO(n){return new mo(this.epochNanoseconds,n)}toZonedDateTime(n){if(!w(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new mo(this.epochNanoseconds,n.timeZone,n.calendar)}};function Fr(n,e,t){const o=E(t,3,0,0,5);return Do(function(n,e,t){return rn(z(e-n,a[t.smallestUnit]*t.roundingIncrement,t.roundingFunc),t.largestUnit)}(n.epochNanoseconds,e.epochNanoseconds,o))}function br(n){return Sr.fromEpochMilliseconds(n.valueOf())}de(Sr,"Instant"),oe(Sr),Qt(Sr,$t({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));var Nr=Symbol(),Or=Symbol(),Tr=Symbol(),Dr=class extends tt{constructor(n,e){const t=ot(n),o=function(n){const e={};for(const t in n){let o=n[t];w(o)&&(o=o.toString()),e[t]=o}return e}(e||{});super(t,o),this[Nr]=t,this[Or]=o,this[Tr]=new Map}format(n){const e=Yr(this,n);return e[0]===this?super.format(n):e[0].format(e[1])}formatToParts(n){return super.formatToParts.call(...Yr(this,n))}formatRange(n,e){return super.formatRange.call(...Er(this,n,e))}formatRangeToParts(n,e){return super.formatRangeToParts.call(...Er(this,n,e))}};function Yr(n,e){const t=Vt(e);if(t){const o=Zr(n,t);return[o.buildFormat(e),o.buildEpochMilli(e)]}return[n,e]}function Er(n,e,t){const o=Vt(e);if(o!==Vt(t))throw new TypeError("Mismatch of types");if(o){const r=Zr(n,o);return[r.buildFormat(e,t),r.buildEpochMilli(e),r.buildEpochMilli(t)]}return[n,e,t]}function Zr(n,e){const t=n[Tr];let o=t.get(e);return o||(o=function(n){const e={};return{buildFormat:function(t,o){const r=n.buildKey(t,o),i=r.join("|");return e[i]||(e[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(e(n[Nr],n[Or])),t.set(e,o)),o}var Cr={zonedDateTimeISO:function(n){return go(Rr("iso8601",n))},zonedDateTime:function(n,e){return go(Rr(n,e))},plainDateTimeISO:function(n){return Zo(Rr("iso8601",n))},plainDateTime:function(n,e){return Zo(Rr(n,e))},plainDateISO:function(n){return mr(Rr("iso8601",n))},plainDate:function(n,e){return mr(Rr(n,e))},plainTimeISO:function(n){return to(Rr("iso8601",n))},instant:function(){return new Sr(Pr())},timeZone:Ur};function Ur(){return new ht((new tt).resolvedOptions().timeZone)}function Rr(n,e=Ur()){const t=U(ht,e);return{...yo(Pr(),t)[0],timeZone:t,calendar:U(ir,n)}}function Pr(){return BigInt(Date.now())*e}de(Cr,"Now");export{ir as Calendar,To as Duration,Dr as ExtendedDateTimeFormat,Sr as Instant,Cr as Now,lr as PlainDate,Eo as PlainDateTime,Ro as PlainMonthDay,eo as PlainTime,ao as PlainYearMonth,ht as TimeZone,mo as ZonedDateTime,br as dateToTemporalInstant};
//# sourceMappingURL=impl.js.map

@@ -1,2 +0,2 @@

import*as a from"./impl.js";var n=globalThis.Temporal,t=n||a,PlainYearMonth=t.PlainYearMonth,PlainMonthDay=t.PlainMonthDay,PlainDate=t.PlainDate,PlainTime=t.PlainTime,PlainDateTime=t.PlainDateTime,ZonedDateTime=t.ZonedDateTime,Instant=t.Instant,Calendar=t.Calendar,TimeZone=t.TimeZone,Duration=t.Duration,e=t.Now,o=n?a=>a.toTemporalInstant():a.dateToTemporalInstant;export{Calendar,Duration,Instant,e as Now,PlainDate,PlainDateTime,PlainMonthDay,PlainTime,PlainYearMonth,TimeZone,ZonedDateTime,o as dateToTemporalInstant};
import*as a from"./impl.js";var n=globalThis.Temporal,t=n||a,e=t.PlainYearMonth,o=t.PlainMonthDay,i=t.PlainDate,l=t.PlainTime,m=t.PlainDateTime,r=t.ZonedDateTime,T=t.Instant,s=t.Calendar,p=t.TimeZone,D=t.Duration,P=t.Now,d=n?a=>a.toTemporalInstant():a.dateToTemporalInstant;export{s as Calendar,D as Duration,T as Instant,P as Now,i as PlainDate,m as PlainDateTime,o as PlainMonthDay,l as PlainTime,e as PlainYearMonth,p as TimeZone,r as ZonedDateTime,d as dateToTemporalInstant};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Calendar,Duration,ExtendedDateTimeFormat as a,Instant,Now as t,PlainDate,PlainDateTime,PlainMonthDay,PlainTime,PlainYearMonth,TimeZone,ZonedDateTime,dateToTemporalInstant as o}from"./impl.js";function n(){globalThis.Temporal||(globalThis.Temporal={PlainYearMonth:PlainYearMonth,PlainMonthDay:PlainMonthDay,PlainDate:PlainDate,PlainTime:PlainTime,PlainDateTime:PlainDateTime,ZonedDateTime:ZonedDateTime,Instant:Instant,Calendar:Calendar,TimeZone:TimeZone,Duration:Duration,Now:t},globalThis.Date.prototype.toTemporalInstant=function(){return o(this)},globalThis.Intl.DateTimeFormat=a)}export{n as shimTemporal};
import{Calendar as a,Duration as t,ExtendedDateTimeFormat as o,Instant as n,Now as e,PlainDate as i,PlainDateTime as l,PlainMonthDay as r,PlainTime as m,PlainYearMonth as T,TimeZone as p,ZonedDateTime as s,dateToTemporalInstant as h}from"./impl.js";function D(){globalThis.Temporal||(globalThis.Temporal={PlainYearMonth:T,PlainMonthDay:r,PlainDate:i,PlainTime:m,PlainDateTime:l,ZonedDateTime:s,Instant:n,Calendar:a,TimeZone:p,Duration:t,Now:e},globalThis.Date.prototype.toTemporalInstant=function(){return h(this)},globalThis.Intl.DateTimeFormat=o)}export{D as shimTemporal};
//# sourceMappingURL=shim.js.map
{
"name": "temporal-polyfill",
"version": "0.0.5",
"version": "0.0.6",
"title": "Temporal Polyfill",
"description": "A spec-compliant Temporal JavaScript polyfill in 15kb",
"description": "A spec-compliant Temporal JavaScript polyfill in 16kb",
"author": {

@@ -48,3 +48,2 @@ "name": "Adam Shaw",

"/src",
"!/src/specs",
"/dist",

@@ -51,0 +50,0 @@ "/*.d.ts"

# temporal-polyfill
A spec-compliant<super>*</super> [Temporal] JavaScript polyfill in 15kb<super>**</super>.
A spec-compliant [Temporal] JavaScript polyfill in 16kb<super>*</super>.
Works in modern browsers<super>***</super>, not Internet Explorer.
Works in modern browsers<super>**</super>, not Internet Explorer.

@@ -48,10 +48,5 @@ [Codepen](https://codepen.io/arshaw/pen/VwrMQPJ?editors=1111)

<super>*</super> = the size will shrink as the codebase is cleaned up
<super>*</super> = *almost* spec-compliant.
[a few more tests must pass](jest.config.cjs)
([see results](https://github.com/fullcalendar/temporal/actions))
<super>**</super> = the size will shrink as the codebase is cleaned up
<super>***</super> = targets browsers that support [BigInt], however, more browser-compatibility
<super>**</super> = targets browsers that support [BigInt], however, more browser-compatibility
work is needed

@@ -58,0 +53,0 @@

@@ -1,11 +0,13 @@

import { UnitInt } from '../dateUtils/units'
import { DAY, UnitInt, nanoIn } from '../dateUtils/units'
import { DiffOptions, Unit } from '../public/types'
import { RoundingFunc } from '../utils/math'
import { ensureOptionsObj } from './refine'
import { RoundingConfig, parseRoundingOptions } from './roundingOptions'
import { parseRoundingModeOption } from './roundingMode'
import { parseUnit } from './unitStr'
export interface DiffConfig<
UnitType extends UnitInt = UnitInt
> extends RoundingConfig<UnitType> {
export interface DiffConfig<UnitType extends UnitInt = UnitInt> {
smallestUnit: UnitType
largestUnit: UnitType
roundingFunc: RoundingFunc
roundingIncrement: number
}

@@ -22,17 +24,13 @@

maxUnit: UnitIntType,
forInstant?: boolean, // weird
forRounding?: boolean, // weird
forDurationRounding?: boolean, // TODO: change to 'defaultRoundingFunc'
): DiffConfig<UnitIntType> {
const roundingConfig = parseRoundingOptions<UnitArg, UnitIntType>(
options,
smallestUnitDefault,
minUnit,
maxUnit,
!forRounding,
forInstant,
const ensuredOptions = ensureOptionsObj(options)
const roundingIncrement = ensuredOptions.roundingIncrement ?? 1
const smallestUnit = parseUnit(ensuredOptions.smallestUnit, smallestUnitDefault, minUnit, maxUnit)
const roundingFunc = parseRoundingModeOption(
ensuredOptions,
forDurationRounding ? Math.round : Math.trunc,
)
largestUnitDefault = Math.max(largestUnitDefault, roundingConfig.smallestUnit) as UnitIntType
let largestUnitArg = ensureOptionsObj(options).largestUnit
let largestUnitArg = ensuredOptions.largestUnit
if (largestUnitArg === 'auto') {

@@ -42,12 +40,28 @@ largestUnitArg = undefined

largestUnitDefault = Math.max(largestUnitDefault, smallestUnit) as UnitIntType
const largestUnit = parseUnit(largestUnitArg, largestUnitDefault, minUnit, maxUnit)
if (roundingConfig.smallestUnit > largestUnit) {
if (smallestUnit > largestUnit) {
throw new RangeError('Bad smallestUnit/largestUnit')
}
if (smallestUnit < DAY) {
const largerNano = nanoIn[smallestUnit + 1]
const incNano = nanoIn[smallestUnit] * roundingIncrement
if (largerNano === incNano) {
throw new RangeError('Must not equal larger unit')
}
if (largerNano % incNano) {
throw new RangeError('Must divide into larger unit')
}
}
return {
smallestUnit,
largestUnit,
...roundingConfig,
roundingFunc,
roundingIncrement,
}
}

@@ -26,12 +26,11 @@ import { strArrayToHash } from '../utils/obj'

export const dateTimeFieldMap = {
...dateFieldMap,
...timeFieldMap,
export const monthDayFieldMap = {
era: String,
eraYear: Number,
year: Number,
month: Number,
monthCode: String,
day: Number,
}
export const zonedDateTimeFieldMap = {
...dateTimeFieldMap,
offset: String,
}
export const durationFieldMap = strArrayToHash(durationUnitNames, () => Number)

@@ -11,9 +11,9 @@ import {

import { TimeToStringOptions, TimeToStringUnit } from '../public/types'
import { RoundingFunc } from '../utils/math'
import { OVERFLOW_REJECT } from './overflowHandling'
import { constrainInt, ensureOptionsObj } from './refine'
import { parseRoundingModeOption } from './roundingMode'
import { RoundingConfig } from './roundingOptions'
import { parseUnit } from './unitStr'
export type DurationToStringUnitInt =
export type DurationToStringUnitInt = // TODO: move this??? weird name/location for this
typeof SECOND |

@@ -26,7 +26,6 @@ typeof MILLISECOND |

export interface TimeToStringConfig<UnitType extends TimeToStringUnitInt = TimeToStringUnitInt> {
export interface TimeToStringConfig<
UnitType extends TimeToStringUnitInt = TimeToStringUnitInt
> extends RoundingConfig<UnitType> {
fractionalSecondDigits: number | undefined
smallestUnit: UnitType
roundingMode: RoundingFunc
roundingIncrement: number // number of nanoseconds (rename? but good for gzip)
}

@@ -47,3 +46,3 @@

let smallestUnit = NANOSECOND as UnitType
let roundingIncrement = 1
let incNano = 1
let digits: number | undefined

@@ -58,7 +57,7 @@

)
roundingIncrement = nanoIn[smallestUnit]
incNano = nanoIn[smallestUnit]
digits = unitDigitMap[smallestUnit] || 0
} else if (digitsArg !== undefined && digitsArg !== 'auto') {
digits = constrainInt(digitsArg, 0, 9, OVERFLOW_REJECT)
roundingIncrement = Math.pow(10, 9 - digits)
incNano = Math.pow(10, 9 - digits)
}

@@ -69,5 +68,5 @@

fractionalSecondDigits: digits,
roundingMode: parseRoundingModeOption(options, Math.trunc),
roundingIncrement,
roundingFunc: parseRoundingModeOption(options, Math.trunc),
incNano,
}
}

@@ -71,3 +71,2 @@ import { ValueOf } from '../utils/obj'

const res: { [FieldName in keyof Map]?: ReturnType<Map[FieldName]> } = {}
let cnt = 0

@@ -77,10 +76,5 @@ for (const fieldName in refinerMap) {

res[fieldName] = refinerMap[fieldName](input[fieldName])
cnt++
}
}
if (!cnt) {
throw new TypeError('Invalid object, no keys')
}
return res

@@ -106,16 +100,1 @@ }

}
const invalidOverrideFields = ['calendar', 'timeZone']
export function refineOverrideFields<Map extends { [fieldName: string]: (input: unknown) => any }>(
input: { [FieldName in keyof Map]?: unknown },
refinerMap: Map,
): { [FieldName in keyof Map]?: ReturnType<Map[FieldName]> } {
for (const fieldName of invalidOverrideFields) {
if (input[fieldName] !== undefined) {
throw new TypeError(`Disallowed field ${fieldName}`)
}
}
return refineFields(input, refinerMap)
}

@@ -1,3 +0,3 @@

import { DAY, UnitInt, nanoIn, nanoInDay } from '../dateUtils/units'
import { RoundingOptions, Unit } from '../public/types'
import { DAY, DayTimeUnitInt, nanoIn, nanoInDay } from '../dateUtils/units'
import { DayTimeUnit, RoundingOptions } from '../public/types'
import { RoundingFunc } from '../utils/math'

@@ -8,49 +8,46 @@ import { ensureOptionsObj, isObjectLike } from './refine'

export interface RoundingConfig<UnitType extends UnitInt = UnitInt> {
export interface RoundingConfig<UnitType extends DayTimeUnitInt = DayTimeUnitInt> {
smallestUnit: UnitType
roundingMode: RoundingFunc
roundingIncrement: number
roundingFunc: RoundingFunc
incNano: number
}
export function parseRoundingOptions<
UnitArgType extends Unit,
UnitType extends UnitInt
UnitArgType extends DayTimeUnit,
UnitType extends DayTimeUnitInt
>(
options: Partial<RoundingOptions<UnitArgType>> | undefined,
options: Partial<RoundingOptions<UnitArgType>> | UnitArgType | undefined,
smallestUnitDefault: UnitType | undefined,
minUnit: UnitType,
maxUnit: UnitType,
forDiffing?: boolean,
forInstant?: boolean,
relaxedDivisibility?: boolean,
): RoundingConfig<UnitType> {
if (smallestUnitDefault === undefined && !isObjectLike(options)) {
const optionsObj: Partial<RoundingOptions<UnitArgType>> | undefined =
typeof options === 'string'
? { smallestUnit: options }
: options
if (smallestUnitDefault === undefined && !isObjectLike(optionsObj)) {
throw new TypeError('Need rounding options')
}
const ensuredOptions = ensureOptionsObj(options)
const ensuredOptions = ensureOptionsObj(optionsObj)
const roundingIncrement = ensuredOptions.roundingIncrement ?? 1
const smallestUnit = parseUnit(ensuredOptions.smallestUnit, smallestUnitDefault, minUnit, maxUnit)
const roundingFunc = parseRoundingModeOption(ensuredOptions, Math.round)
const incNano = nanoIn[smallestUnit] * roundingIncrement
// Instant rounding only cares about solar alignment
if (!forDiffing && forInstant) {
if (
smallestUnit < DAY &&
nanoInDay % roundingIncrement * nanoIn[smallestUnit]
) {
throw new RangeError('Increment must evenly divide into 24 hours')
if (smallestUnit === DAY) {
if (roundingIncrement !== 1) {
throw new RangeError('When smallestUnit is days, roundingIncrement must be 1')
}
} else {
if (
(smallestUnit < DAY)
? nanoIn[smallestUnit + 1] % roundingIncrement
: !forDiffing && roundingIncrement !== 1 // rounding can't have non-1 large units
) {
throw new RangeError('roundingIncrement does not divide evenly into next highest unit')
const largerNano = relaxedDivisibility ? nanoInDay : nanoIn[smallestUnit + 1]
if (!relaxedDivisibility && largerNano === incNano) {
throw new RangeError('Must not equal larger unit')
}
if (
smallestUnit < DAY &&
roundingIncrement * nanoIn[smallestUnit] >= nanoIn[smallestUnit + 1]
) {
throw new RangeError('roundingIncrement must be less than next highest unit')
if (largerNano % incNano) {
throw new RangeError('Must divide into larger unit')
}

@@ -61,5 +58,5 @@ }

smallestUnit,
roundingMode: parseRoundingModeOption(options, forDiffing ? Math.trunc : Math.round),
roundingIncrement,
roundingFunc,
incNano,
}
}

@@ -1,12 +0,14 @@

import { DateFields } from '../dateUtils/date'
import { DurationFields } from '../dateUtils/duration'
import { TimeFields } from '../dateUtils/time'
import {
LocalDateFields,
LocalTimeFields,
LocalYearMonthFields,
UnsignedDurationFields,
} from '../dateUtils/typesPrivate'
import { UnitInt } from '../dateUtils/units'
import { YearMonthFields } from '../dateUtils/yearMonth'
import { DateUnit, TimeUnit, Unit } from '../public/types'
import { strArrayToHash } from '../utils/obj'
export type YearMonthUnitProper = keyof YearMonthFields
export type DateUnitProper = keyof DateFields | 'week'
export type TimeUnitProper = keyof TimeFields
export type YearMonthUnitProper = keyof LocalYearMonthFields
export type DateUnitProper = keyof LocalDateFields | 'week'
export type TimeUnitProper = keyof LocalTimeFields

@@ -36,4 +38,4 @@ // These names must match the indexes of the Unit integers

export const durationUnitNames: (keyof DurationFields)[] = unitNames.map(
(unit) => (unit + 's') as keyof DurationFields,
export const durationUnitNames: (keyof UnsignedDurationFields)[] = unitNames.map(
(unit) => (unit + 's') as keyof UnsignedDurationFields,
)

@@ -40,0 +42,0 @@

@@ -1,2 +0,2 @@

import { isoToEpochMilli } from '../dateUtils/isoMath'
import { isoToEpochMilli } from '../dateUtils/epoch'
import { milliInDay, nanoInMilliBI } from '../dateUtils/units'

@@ -3,0 +3,0 @@ import { queryCalendarImpl } from './calendarImplQuery'

import { computeDaysInYear } from '../dateUtils/calendar'
import { hashIntlFormatParts, normalizeShortEra } from '../dateUtils/intlFormat'
import {

@@ -8,3 +7,4 @@ addDaysMilli,

isoToEpochMilli,
} from '../dateUtils/isoMath'
} from '../dateUtils/epoch'
import { hashIntlFormatParts, normalizeShortEra } from '../dateUtils/intlFormat'
import { OrigDateTimeFormat } from '../native/intlUtils'

@@ -236,3 +236,3 @@ import {

// either part-way through the desired year or very slightly before
let epochMilli = isoToEpochMilli(this.guessISOYear(year))
let epochMilli = isoToEpochMilli(this.guessISOYear(year), 1, 1)

@@ -239,0 +239,0 @@ // ensure marker is in year+1

@@ -1,2 +0,2 @@

import { epochMilliToISOFields, isoEpochLeapYear, isoToEpochMilli } from '../dateUtils/isoMath'
import { epochMilliToISOFields, isoEpochLeapYear, isoToEpochMilli } from '../dateUtils/epoch'
import { CalendarImpl, CalendarImplFields } from './calendarImpl'

@@ -3,0 +3,0 @@

@@ -0,3 +1,3 @@

import { isoToEpochMilli } from '../dateUtils/epoch'
import { hashIntlFormatParts, normalizeShortEra } from '../dateUtils/intlFormat'
import { isoToEpochMilli } from '../dateUtils/isoMath'
import { CalendarImplFields } from './calendarImpl'

@@ -4,0 +4,0 @@ import { GregoryCalendarImpl } from './gregoryCalendarImpl'

@@ -5,3 +5,3 @@ import { ensureCalendarsEqual } from '../argParse/calendar'

import { Calendar } from '../public/calendar'
import { PlainDate } from '../public/plainDate'
import { PlainDate, createDate } from '../public/plainDate'
import { PlainDateTime } from '../public/plainDateTime'

@@ -12,4 +12,5 @@ import { PlainMonthDay } from '../public/plainMonthDay'

import { ZonedDateTime } from '../public/zonedDateTime'
import { DateFields, DateISOEssentials, constrainDateFields, createDate } from './date'
import { diffDaysMilli, epochMilliToISOFields } from './isoMath'
import { constrainDateFields } from './constrain'
import { diffDaysMilli, epochMilliToISOFields } from './epoch'
import { ISODateFields, InputDateFields, LocalDateFields } from './typesPrivate'

@@ -44,3 +45,3 @@ // Date-type Testing (TODO: move this?)

disallowMonthDay?: boolean,
): DateFields {
): LocalDateFields {
let date: PlainDate

@@ -69,3 +70,3 @@

options: OverflowOptions | undefined,
): DateISOEssentials {
): ISODateFields {
if (isDateISOInstance(dateLike)) {

@@ -75,3 +76,3 @@ return dateLike.getISOFields() // hard work has already been done

let { era, eraYear, year, month, monthCode, day } = dateLike as Partial<DateFields>
let { era, eraYear, year, month, monthCode, day } = dateLike as Partial<InputDateFields>
const yearFromEra = (eraYear !== undefined && era !== undefined)

@@ -133,3 +134,3 @@ ? convertEraYear(calendarImpl.id, eraYear, era)

disallowMonthDay?: boolean,
): DateISOEssentials {
): ISODateFields {
if (isDateISOInstance(dateArg)) {

@@ -136,0 +137,0 @@ if (disallowMonthDay && dateArg instanceof PlainMonthDay) {

@@ -0,16 +1,102 @@

import { DiffConfig } from '../argParse/diffOptions'
import { OVERFLOW_CONSTRAIN } from '../argParse/overflowHandling'
import { unitNames } from '../argParse/unitStr'
import { CalendarImpl } from '../calendarImpl/calendarImpl'
import { Duration } from '../public/duration'
import { compareValues } from '../utils/math'
import { addWholeMonths, addWholeYears } from './add'
import { DateEssentials, compareDateFields, constrainDateFields } from './date'
import { diffDaysMilli } from './isoMath'
import { MONTH, UnitInt, WEEK, YEAR } from './units'
import { Calendar } from '../public/calendar'
import { createDate } from '../public/plainDate'
import { CompareResult, DateUnit } from '../public/types'
import { compareValues, roundToIncrement, roundToIncrementBI } from '../utils/math'
import { compareLocalDateFields } from './compare'
import { constrainDateFields } from './constrain'
import { isoTimeToNano, nanoToDuration } from './dayAndTime'
import { mergeDurations, signDuration } from './durationFields'
import { EpochableObj, diffDaysMilli, toEpochNano } from './epoch'
import { roundDurationSpan } from './roundingDuration'
import { addMonths, addYears } from './translate'
import {
DurationFields,
ISOTimeFields,
LocalDateFields,
} from './typesPrivate'
import {
HOUR,
MONTH,
TimeUnitInt,
UnitInt,
WEEK,
YEAR,
isDateUnit,
nanoIn,
} from './units'
export type DiffableObj = LocalDateFields & EpochableObj & {
add(durationFields: Partial<DurationFields>): DiffableObj
}
// used for zoned date times as well
export function diffDateTimes(
dt0: DiffableObj,
dt1: DiffableObj,
calendar: Calendar,
flip: boolean,
diffConfig: DiffConfig,
): DurationFields {
return roundDurationSpan(
diffAccurate(dt0, dt1, calendar, diffConfig.largestUnit),
dt0,
dt1,
calendar,
flip,
diffConfig,
)
}
export function diffDates(
d0: DiffableObj,
d1: DiffableObj,
calendar: Calendar,
flip: boolean,
diffConfig: DiffConfig,
): DurationFields {
const balancedDuration = calendar.dateUntil(d0, d1, {
largestUnit: unitNames[diffConfig.largestUnit] as DateUnit,
})
return roundDurationSpan(balancedDuration, d0, d1, calendar, flip, diffConfig)
}
export function diffTimes(
t0: ISOTimeFields,
t1: ISOTimeFields,
diffConfig: DiffConfig<TimeUnitInt>,
): DurationFields {
const roundedDiff = roundToIncrement(
isoTimeToNano(t1) - isoTimeToNano(t0),
nanoIn[diffConfig.smallestUnit] * diffConfig.roundingIncrement,
diffConfig.roundingFunc,
)
return nanoToDuration(BigInt(roundedDiff), diffConfig.largestUnit)
}
export function diffEpochNanos(
epochNano0: bigint,
epochNano1: bigint,
diffConfig: DiffConfig<TimeUnitInt>,
): DurationFields {
const roundedDiff = roundToIncrementBI(
epochNano1 - epochNano0,
nanoIn[diffConfig.smallestUnit] * diffConfig.roundingIncrement,
diffConfig.roundingFunc,
)
return nanoToDuration(roundedDiff, diffConfig.largestUnit)
}
// Utils
// -------------------------------------------------------------------------------------------------
export function diffDateFields(
d0: DateEssentials,
d1: DateEssentials,
d0: LocalDateFields,
d1: LocalDateFields,
calendarImpl: CalendarImpl,
largestUnit: UnitInt,
): Duration {
): DurationFields {
let years = 0; let months = 0; let weeks = 0; let days = 0

@@ -21,7 +107,7 @@

years = wholeYearsUntil(d0, d1, calendarImpl)
d0 = addWholeYears(d0, years, calendarImpl, OVERFLOW_CONSTRAIN)
d0 = addYears(d0, years, calendarImpl, OVERFLOW_CONSTRAIN)
// fallthrough
case MONTH:
months = wholeMonthsUntil(d0, d1, calendarImpl)
d0 = addWholeMonths(d0, months, calendarImpl, OVERFLOW_CONSTRAIN)
d0 = addMonths(d0, months, calendarImpl, OVERFLOW_CONSTRAIN)
}

@@ -39,8 +125,19 @@

return new Duration(years, months, weeks, days)
return signDuration({
years,
months,
weeks,
days,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0,
microseconds: 0,
nanoseconds: 0,
})
}
function wholeYearsUntil(
d0: DateEssentials,
d1: DateEssentials,
d0: LocalDateFields,
d1: LocalDateFields,
calendarImpl: CalendarImpl,

@@ -57,3 +154,3 @@ ): number {

const generalSign = compareDateFields(d1, d0)
const generalSign = compareLocalDateFields(d1, d0)
const monthSign = compareValues(d1.month, newMonth) || compareValues(d1.day, newDay)

@@ -69,8 +166,8 @@

function wholeMonthsUntil(
d0: DateEssentials,
d1: DateEssentials,
d0: LocalDateFields,
d1: LocalDateFields,
calendarImpl: CalendarImpl,
): number {
let monthsToAdd = 0
const generalSign = compareDateFields(d1, d0)
const generalSign = compareLocalDateFields(d1, d0)

@@ -106,1 +203,48 @@ if (generalSign) {

}
export function diffAccurate(
dt0: DiffableObj,
dt1: DiffableObj,
calendar: Calendar,
largestUnit: UnitInt,
): DurationFields {
// a time unit
if (!isDateUnit(largestUnit)) {
return diffTimeScale(dt0, dt1, largestUnit)
}
const dateStart = createDate({ ...dt0.getISOFields(), calendar })
let dateMiddle = createDate({ ...dt1.getISOFields(), calendar })
let dateTimeMiddle: DiffableObj
let bigDuration: DurationFields
let timeDuration: DurationFields
let bigSign: CompareResult
let timeSign: CompareResult
do {
bigDuration = calendar.dateUntil(
dateStart,
dateMiddle,
{ largestUnit: unitNames[largestUnit] as DateUnit },
)
dateTimeMiddle = dt0.add(bigDuration)
timeDuration = diffTimeScale(dateTimeMiddle, dt1, HOUR)
bigSign = bigDuration.sign
timeSign = timeDuration.sign
} while (
// did we overshoot? keep backing up a day
bigSign && timeSign &&
bigSign !== timeSign &&
(dateMiddle = dateMiddle.add({ days: timeSign })) // move dateMiddle closer to dt0
)
return mergeDurations(bigDuration, timeDuration)
}
function diffTimeScale(
dt0: EpochableObj,
dt1: EpochableObj,
largestUnit: TimeUnitInt,
): DurationFields {
return nanoToDuration(toEpochNano(dt1) - toEpochNano(dt0), largestUnit)
}
import { checkEpochNanoBuggy } from '../calendarImpl/bugs'
import { DateTimeISOEssentials } from '../dateUtils/dateTime'
import { DateISOEssentials } from './date'
import { isoFieldsToEpochNano, throwOutOfRange } from './isoMath'
import { isoFieldsToEpochNano, throwOutOfRange } from './epoch'
import { ISODateFields, ISODateTimeFields } from './typesPrivate'

@@ -25,3 +24,3 @@ /*

export function validateYearMonth(isoFields: DateISOEssentials, calendarID: string): void {
export function validateYearMonth(isoFields: ISODateFields, calendarID: string): void {
// might throw an error

@@ -34,3 +33,3 @@ // moves between days in month

export function validateDate(isoFields: DateISOEssentials, calendarID: string): void {
export function validateDate(isoFields: ISODateFields, calendarID: string): void {
const epochNano = isoFieldsToEpochNano(isoFields)

@@ -46,3 +45,3 @@

export function validateDateTime(isoFields: DateTimeISOEssentials, calendarID: string): void {
export function validateDateTime(isoFields: ISODateTimeFields, calendarID: string): void {
const epochNano = isoFieldsToEpochNano(isoFields)

@@ -49,0 +48,0 @@

@@ -9,12 +9,13 @@ import {

import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { TimeISOEssentials } from '../dateUtils/time'
import { DateISOFields } from '../public/types'
import { RoundingFunc, roundToIncrementBI } from '../utils/math'
import { getSignStr, padZeros } from '../utils/string'
import { DateISOEssentials } from './date'
import { DateTimeISOEssentials } from './dateTime'
import { nanoToDayTimeFields } from './dayTime'
import { SignedDurationFields } from './duration'
import { nanoToISOTime } from './dayAndTime'
import {
HOUR,
DurationFields,
ISODateFields,
ISODateTimeFields,
ISOTimeFields,
} from './typesPrivate'
import {
MINUTE,

@@ -31,3 +32,3 @@ SECOND,

export function formatDateTimeISO(
fields: DateTimeISOEssentials,
fields: ISODateTimeFields,
formatConfig: TimeToStringConfig,

@@ -38,7 +39,7 @@ ): string {

export function formatDateISO(fields: DateISOEssentials): string {
export function formatDateISO(fields: ISODateFields): string {
return formatYearMonthISO(fields) + '-' + padZeros(fields.isoDay, 2)
}
export function formatYearMonthISO(fields: DateISOEssentials): string {
export function formatYearMonthISO(fields: ISODateFields): string {
const { isoYear } = fields

@@ -59,3 +60,3 @@ return (

export function formatTimeISO(
fields: TimeISOEssentials,
fields: ISOTimeFields,
formatConfig: TimeToStringConfig, // tighten type? remove roundingMode?

@@ -86,7 +87,7 @@ ): string {

export function formatOffsetISO(offsetNano: number): string {
const fields = nanoToDayTimeFields(BigInt(Math.abs(offsetNano)), HOUR) // TODO: cleaner util
const [fields, dayDelta] = nanoToISOTime(Math.abs(offsetNano))
const partialSecondsStr = formatPartialSeconds(
fields.millisecond!,
fields.microsecond!,
fields.nanosecond!,
fields.isoMillisecond,
fields.isoMicrosecond,
fields.isoNanosecond,
undefined,

@@ -96,9 +97,12 @@ )[0]

return getSignStr(offsetNano) +
padZeros(fields.hour!, 2) + ':' +
padZeros(fields.minute!, 2) +
((fields.second || partialSecondsStr)
? ':' + padZeros(fields.second!, 2) + partialSecondsStr
// format beyond 24:00 (TODO: somehow convince nanoToISOTime to have topheavy hours?)
padZeros(fields.isoHour + dayDelta * 24, 2) + ':' +
padZeros(fields.isoMinute, 2) +
((fields.isoSecond || partialSecondsStr)
? ':' + padZeros(fields.isoSecond, 2) + partialSecondsStr
: '')
}
// you MUST pass in Calendar::toString()
// this is WEIRD. proper solution: have a proper CalendarProtocol object
export function formatCalendarID(

@@ -127,6 +131,6 @@ calendarID: string | undefined,

export function formatDurationISO(
fields: SignedDurationFields,
fields: DurationFields,
formatConfig: DurationToStringConfig,
): string {
const { smallestUnit, fractionalSecondDigits, roundingMode } = formatConfig
const { smallestUnit, fractionalSecondDigits, roundingFunc } = formatConfig
const { sign } = fields

@@ -144,3 +148,3 @@ const hours = BigInt(fields.hours)

fractionalSecondDigits,
roundingMode,
roundingFunc,
smallestUnit,

@@ -152,2 +156,8 @@ )

// guarantee display of seconds if...
const forceSeconds =
fractionalSecondDigits !== undefined || // fractionalSecondDigits explicitly specified
partialSecondsStr || // partial seconds, either via fractionalSecondDigits or default
!sign // duration is completely empty, display 'PT0S'
return (sign < 0 ? '-' : '') + 'P' +

@@ -160,3 +170,3 @@ collapseDurationTuples([

]) +
(hours || minutes || seconds || partialSecondsStr || !sign // see below for last 2 conditions
(hours || minutes || seconds || forceSeconds
? 'T' +

@@ -169,5 +179,3 @@ collapseDurationTuples([

partialSecondsStr + 'S',
partialSecondsStr || !sign,
// ^^^ ensures seconds if partialSecondsStr OR
// OR ensures 'PT0S' if completely empty
forceSeconds,
],

@@ -174,0 +182,0 @@ ])

@@ -124,1 +124,7 @@ import { unitNames } from '../argParse/unitStr'

}
// affects how objects are displayed in console
export function attachStringTag(objOrClass: any, name: string): void {
(objOrClass.prototype || objOrClass)[Symbol.toStringTag] = 'Temporal.' + name
}

@@ -1,16 +0,14 @@

import { DateISOEssentials } from './date'
import { DateTimeISOEssentials } from './dateTime'
import { nanoToDayTimeFields } from './dayTime'
import { isoEpochLeapYear } from './isoMath'
import { isValidDateISO } from './constrain'
import { nanoToISOTime } from './dayAndTime'
import { isoEpochLeapYear } from './epoch'
import {
dateTimeRegExp,
monthDayRegExp,
normalizeDashes,
offsetRegExp,
timeRegExp,
unicodeDashRegExp,
yearMonthRegExp,
} from './parseRegExp'
import { TimeISOEssentials, timeLikeToISO } from './time'
import { ISODateFields, ISODateTimeFields, ISOTimeFields } from './typesPrivate'
import {
MILLISECOND,
nanoInHour,

@@ -21,7 +19,7 @@ nanoInMinute,

export interface DateParseResults extends DateISOEssentials {
export interface DateParseResults extends ISODateFields {
calendar: string | undefined
}
export interface DateTimeParseResult extends DateTimeISOEssentials {
export interface DateTimeParseResult extends ISODateTimeFields {
calendar: string | undefined

@@ -32,4 +30,4 @@ }

timeZone: string | undefined
offset: number | undefined
Z?: boolean // whether ISO8601 specified with 'Z' as offset indicator
offsetNanoseconds: number | undefined
Z: boolean | undefined // whether ISO8601 specified with 'Z' as offset indicator
}

@@ -79,4 +77,17 @@

export function parseTime(str: string): TimeISOEssentials {
const res = tryParseTime(str) || tryParseDateTime(str)
export function parseTime(str: string): ISOTimeFields {
let res = tryParseTime(str)
if (res !== undefined) {
// detect ambiguity in format
if (str.charAt(0) !== 'T') {
const tryOther = tryParseYearMonth(str) || tryParseMonthDay(str)
if (tryOther && isValidDateISO(tryOther)) {
res = undefined // invalid
}
}
} else {
res = tryParseDateTime(str, true)
}
if (res === undefined) {

@@ -90,2 +101,4 @@ throw createParseError('time', str)

const zRE = /^Z$/i
export function tryParseZonedDateTime(str: string): ZonedDateTimeParseResult | undefined {

@@ -98,5 +111,13 @@ const m = dateTimeRegExp.exec(normalizeDashes(str))

export function tryParseDateTime(str: string): DateTimeParseResult | undefined {
export function tryParseDateTime(
str: string,
requireTime?: boolean,
allowZ?: boolean,
): DateTimeParseResult | undefined {
const m = dateTimeRegExp.exec(normalizeDashes(str))
if (m) {
if (
m &&
(allowZ || !zRE.test(m[12])) && // don't allow Z (12 means index 11 when unsliced)
(!requireTime || m[4]) // timeEverything (4 means index 3 when unsliced)
) {
return parseDateTimeParts(m.slice(1))

@@ -140,8 +161,8 @@ }

const zOrOffset = parts[11]
let offset: number | undefined
let offsetNanoseconds: number | undefined
let Z = false
if (zOrOffset) {
Z = zOrOffset.toUpperCase() === 'Z'
offset = Z ? 0 : parseOffsetParts(parts.slice(12))
Z = zRE.test(zOrOffset)
offsetNanoseconds = Z ? 0 : parseOffsetParts(parts.slice(12))
}

@@ -152,3 +173,3 @@

timeZone: parts[21],
offset,
offsetNanoseconds,
Z,

@@ -186,11 +207,7 @@ }

function parseTimeParts(parts: string[]): TimeISOEssentials {
function parseTimeParts(parts: string[]): ISOTimeFields {
const isoSecond = toInt0(parts[4])
return {
...timeLikeToISO( // properties like isoMillisecond/isoMicrosecond
nanoToDayTimeFields( // properties like millisecond/microsecond
BigInt(parseNanoAfterDecimal(parts[6] || '')),
MILLISECOND,
),
),
...nanoToISOTime(parseNanoAfterDecimal(parts[6] || ''))[0],
isoHour: toInt0(parts[0]),

@@ -233,8 +250,4 @@ isoMinute: toInt0(parts[2]),

export function normalizeDashes(str: string): string {
return str.replace(unicodeDashRegExp, '-')
}
export function createParseError(type: string, str: string): any {
throw new RangeError(`Cannot parse ${type} '${str}'`)
}
import { excludeUndefined } from '../utils/obj'
import { nanoToDayTimeFields } from './dayTime'
import { DurationFields, negateFields } from './duration'
import { createParseError, normalizeDashes, parseNanoAfterDecimal, toIntMaybe } from './parse'
import { durationRegExp } from './parseRegExp'
import { nanoToDuration } from './dayAndTime'
import { negateDuration, signDuration } from './durationFields'
import { createParseError, parseNanoAfterDecimal, toIntMaybe } from './parse'
import { durationRegExp, normalizeDashes } from './parseRegExp'
import { DurationFields, UnsignedDurationFields } from './typesPrivate'
import {

@@ -36,3 +37,3 @@ HOUR,

let fields: Partial<DurationFields> = excludeUndefined({
const fields: Partial<UnsignedDurationFields> = excludeUndefined({
years: toIntMaybe(match[2]),

@@ -51,12 +52,15 @@ months: toIntMaybe(match[3]),

const small = nanoToDayTimeFields(BigInt(leftoverNano || 0), MILLISECOND)
fields.milliseconds = small.millisecond
fields.microseconds = small.microsecond
fields.nanoseconds = small.nanosecond
const small = nanoToDuration(BigInt(leftoverNano || 0), MILLISECOND)
// TODO: use mergeDurations somehow?
fields.milliseconds = small.milliseconds
fields.microseconds = small.microseconds
fields.nanoseconds = small.nanoseconds
let signedDuration = signDuration(fields as UnsignedDurationFields)
if (match[1] === '-') {
fields = negateFields(fields)
signedDuration = negateDuration(signedDuration)
}
return fields as DurationFields
return signedDuration
}

@@ -63,0 +67,0 @@ }

@@ -26,3 +26,3 @@

dateRegExpStr + // 0-2: date
'([T ]' +
'([T ]' + // 3: timeEverything
timeRegExpStr + // 4-10: time

@@ -46,3 +46,3 @@ ')?'

export const dateTimeRegExp = createRegExp(dateTimeRegExpStr + endingRegExpStr)
export const timeRegExp = createRegExp(timeRegExpStr + endingRegExpStr)
export const timeRegExp = createRegExp('T?' + timeRegExpStr + endingRegExpStr)
export const offsetRegExp = createRegExp(offsetRegExpStr)

@@ -54,3 +54,3 @@

// TODO: inject this into regexes above?
export const unicodeDashRegExp = /\u2212/g
const unicodeDashRegExp = /\u2212/g

@@ -60,1 +60,5 @@ function createRegExp(meat: string): RegExp {

}
export function normalizeDashes(str: string): string {
return str.replace(unicodeDashRegExp, '-')
}

@@ -1,139 +0,93 @@

import { DiffConfig } from '../argParse/diffOptions'
import { OFFSET_PREFER } from '../argParse/offsetHandling'
import { RoundingConfig } from '../argParse/roundingOptions'
import { durationUnitNames } from '../argParse/unitStr'
import { Duration } from '../public/duration'
import { PlainDateTime } from '../public/plainDateTime'
import { DateISOFields, DateTimeISOFields } from '../public/types'
import { ZonedDateTime } from '../public/zonedDateTime'
import { RoundingFunc, roundToIncrement, roundToIncrementBI } from '../utils/math'
import { addWholeDays } from './add'
import { DateLikeInstance } from './calendar'
import { DayTimeFields } from './dayTime'
import { balanceDuration, createDuration, nanoToDuration, negateFields } from './duration'
import { TimeFields, timeFieldsToNano, timeLikeToISO, wrapTimeOfDayNano } from './time'
import { computeExactDuration } from './totalUnits'
import { DayTimeUnitInt, NANOSECOND, isDateUnit, nanoIn } from './units'
import { toNano } from './zonedDateTime'
import { Calendar } from '../public/calendar'
import { TimeZone } from '../public/timeZone'
import { roundToIncrement, roundToIncrementBI } from '../utils/math'
import { isoTimeToNano, nanoToISOTime, zeroISOTimeFields } from './dayAndTime'
import { splitEpochNano } from './epoch'
import { computeNanoInDay, computeZonedDateTimeEpochNano } from './offset'
import { addDays } from './translate'
import { ISODateTimeFields, ISOTimeFields } from './typesPrivate'
import { DAY, DayTimeUnitInt, TimeUnitInt } from './units'
export function roundBalancedDuration(
balancedDuration: Duration,
diffConfig: DiffConfig,
d0: DateLikeInstance,
d1: DateLikeInstance,
flip?: boolean,
): Duration {
const { largestUnit, smallestUnit, roundingIncrement, roundingMode } = diffConfig
export function roundDateTime(
fields: ISODateTimeFields,
roundingConfig: RoundingConfig<DayTimeUnitInt>,
): ISODateTimeFields {
const timeNano = isoTimeToNano(fields)
const roundedTimeNano = roundNano(timeNano, roundingConfig)
const [isoTimeFields, dayDelta] = nanoToISOTime(roundedTimeNano)
// optimize for time units
if (!isDateUnit(largestUnit)) {
return nanoToDuration( // TODO: make util like diffTimeScale
roundNano(
(
toNano(d1 as (ZonedDateTime | PlainDateTime)) -
toNano(d0 as (ZonedDateTime | PlainDateTime))
) * (flip ? -1n : 1n),
diffConfig as RoundingConfig<DayTimeUnitInt>,
),
largestUnit,
)
}
const dayStartTranslated = addDays(fields, dayDelta)
return { ...dayStartTranslated, ...isoTimeFields }
}
let durationLike = computeExactDuration(balancedDuration, smallestUnit, d0, d1)
const unitName = durationUnitNames[smallestUnit]
export function roundTime(
fields: ISOTimeFields,
roundingConfig: RoundingConfig<TimeUnitInt>,
): ISOTimeFields {
const timeNano = isoTimeToNano(fields)
const roundedTimeNano = roundNano(timeNano, roundingConfig)
const [isoTimeFields] = nanoToISOTime(roundedTimeNano)
return isoTimeFields
}
function doRound() {
const orig = durationLike[unitName]! // computeExactDuration guarantees value
durationLike[unitName] = roundToIncrement(
orig,
roundingIncrement,
roundingMode,
)
}
export function roundEpochNano(
epochNano: bigint,
roundingConfig: RoundingConfig<TimeUnitInt>,
): bigint {
const [dayEpochNano, timeNano] = splitEpochNano(epochNano)
const roundedTimeNano = roundNano(timeNano, roundingConfig)
return dayEpochNano + BigInt(roundedTimeNano)
}
if (roundingMode === Math.round) {
// 'halfExpand' cares about point-to-point translation
doRound()
}
if (flip) {
durationLike = negateFields(durationLike)
}
if (roundingMode !== Math.round) {
// other rounding techniques operate on final number
doRound()
}
// TODO: instead of this mess, have a halfExpandDirection arg
// returns epochNano!
export function roundZonedDateTimeFields(
fields: ISODateTimeFields & { calendar: Calendar, timeZone: TimeZone },
offsetNanoseconds: number,
roundingConfig: RoundingConfig<DayTimeUnitInt>,
): bigint {
const { calendar, timeZone } = fields
let timeNano = isoTimeToNano(fields)
let isoTimeFields: ISOTimeFields
let dayDelta: number
let resDuration = createDuration(durationLike)
// rebalance
if (smallestUnit > NANOSECOND) {
if (flip) {
// yuck
resDuration = balanceDuration(resDuration.negated(), largestUnit, d0).negated()
} else {
resDuration = balanceDuration(resDuration, largestUnit, d0)
}
if (roundingConfig.smallestUnit === DAY) {
isoTimeFields = zeroISOTimeFields
dayDelta = roundingConfig.roundingFunc(timeNano / computeNanoInDay(fields))
} else {
timeNano = roundNano(timeNano, roundingConfig)
;([isoTimeFields, dayDelta] = nanoToISOTime(timeNano))
}
return resDuration
const dayStartTranslated = addDays(fields, dayDelta)
return computeZonedDateTimeEpochNano(
{
...dayStartTranslated,
...isoTimeFields,
offsetNanoseconds,
calendar, // !!!
timeZone, // !!!
},
false,
OFFSET_PREFER, // for offsetNanoseconds conflicts
)
}
export function roundTimeToSpecialDay(
timeFields: TimeFields,
ourNanoInDay: number,
roundingFunc: RoundingFunc,
): DayTimeFields {
const nano = timeFieldsToNano(timeFields)
return {
day: roundingFunc(Number(nano) / ourNanoInDay),
hour: 0,
minute: 0,
second: 0,
millisecond: 0,
microsecond: 0,
nanosecond: 0,
}
}
// low-level utils (just for day-and-time)
export function roundTime(
timeFields: TimeFields,
nanoIncrement: number,
roundingFunc: RoundingFunc,
): DayTimeFields {
return wrapTimeOfDayNano(
roundToIncrementBI(
timeFieldsToNano(timeFields),
nanoIncrement,
roundingFunc,
),
export function roundNano(nano: number, roundingConfig: RoundingConfig<DayTimeUnitInt>): number {
return roundToIncrement(
nano,
roundingConfig.incNano,
roundingConfig.roundingFunc,
)
}
// convenience func
export function roundNano(
nano: bigint,
roundingConfig: RoundingConfig,
): bigint {
export function roundNanoBI(nano: bigint, roundingConfig: RoundingConfig<DayTimeUnitInt>): bigint {
return roundToIncrementBI(
nano,
computeRoundingNanoIncrement(roundingConfig),
roundingConfig.roundingMode,
roundingConfig.incNano,
roundingConfig.roundingFunc,
)
}
// util
export function computeRoundingNanoIncrement(roundingConfig: RoundingConfig): number {
return nanoIn[roundingConfig.smallestUnit] * roundingConfig.roundingIncrement
}
// util
export function combineISOWithDayTimeFields(
isoFields: DateISOFields,
dayTimeFields: DayTimeFields,
): DateTimeISOFields {
const dateISOFields = addWholeDays(isoFields, dayTimeFields.day) // preserves `calendar`
return {
...dateISOFields,
...timeLikeToISO(dayTimeFields),
}
}
import { durationUnitNames } from '../argParse/unitStr'
import { Duration } from '../public/duration'
import { PlainDate } from '../public/plainDate'
import { PlainDateTime } from '../public/plainDateTime'
import { DateTimeArg, DurationLike } from '../public/types'
import { ZonedDateTime } from '../public/zonedDateTime'
import { DateLikeInstance } from './calendar'
import { dayTimeFieldsToNano } from './dayTime'
import {
balanceComplexDuration,
durationToDayTimeFields,
extractRelativeTo,
} from './duration'
import { isoFieldsToEpochNano } from './isoMath'
import { UnitInt, YEAR, isDayTimeUnit, nanoIn } from './units'
import { Calendar } from '../public/calendar'
import { durationDayTimeToNano } from './dayAndTime'
import { DiffableObj } from './diff'
import { computeLargestDurationUnit } from './durationFields'
import { spanDurationFromDateTime } from './durationSpan'
import { toEpochNano } from './epoch'
import { DurationFields, UnsignedDurationFields } from './typesPrivate'
import { DAY, UnitInt, YEAR, isDayTimeUnit, nanoIn } from './units'
export function computeTotalUnits(
duration: Duration,
duration: DurationFields,
unit: UnitInt,
relativeToArg: DateTimeArg | undefined,
relativeTo: DiffableObj | undefined,
calendar: Calendar | undefined,
): number {
const fields = durationToDayTimeFields(duration)
if (
relativeToArg === undefined &&
fields &&
relativeTo === undefined &&
computeLargestDurationUnit(duration) <= DAY &&
isDayTimeUnit(unit)
) {
return Number(dayTimeFieldsToNano(fields)) / nanoIn[unit]
// TODO: accidentaly loss of precision?
return Number(durationDayTimeToNano(duration)) / nanoIn[unit]
}
const relativeTo = extractRelativeTo(relativeToArg) // throws an exception if undefined
const balancedDuration = balanceComplexDuration(
if (!relativeTo) {
throw new RangeError('Need relativeTo')
}
const [balancedDuration, relativeToTranslated] = spanDurationFromDateTime(
duration,
unit,
relativeTo,
calendar!,
true, // dissolveWeeks
)
const durationLike = computeExactDuration(

@@ -41,5 +42,7 @@ balancedDuration,

relativeTo,
relativeTo.add(balancedDuration),
relativeToTranslated,
)
return durationLike[durationUnitNames[unit]]! // computeExactDuration guarantees this
const unitName = durationUnitNames[unit] as keyof UnsignedDurationFields
return durationLike[unitName]
}

@@ -52,14 +55,18 @@

export function computeExactDuration(
balancedDuration: Duration,
balancedDuration: DurationFields,
smallestUnit: UnitInt,
d0: DateLikeInstance,
d1: DateLikeInstance,
): DurationLike {
const smallestUnitName = durationUnitNames[smallestUnit]
dt0: DiffableObj,
dt1: DiffableObj,
): DurationFields {
const smallestUnitName = durationUnitNames[smallestUnit] as keyof UnsignedDurationFields
const { sign } = balancedDuration
if (!sign) { // prevents division by zero
return balancedDuration
}
// make a new duration object that excludes units smaller than smallestUnit
const dur: DurationLike = {}
const dur: Partial<DurationFields> = {}
for (let unit = YEAR; unit >= smallestUnit; unit--) {
const durationUnit = durationUnitNames[unit]
const durationUnit = durationUnitNames[unit] as keyof UnsignedDurationFields
dur[durationUnit] = balancedDuration[durationUnit]

@@ -69,22 +76,13 @@ }

// a single additional unit of `unit`
const incDur: DurationLike = { [smallestUnitName]: sign }
const startDateTime = d0.add(dur)
const incDur: Partial<DurationFields> = { [smallestUnitName]: sign }
const startDateTime = dt0.add(dur)
const endDateTime = startDateTime.add(incDur)
const startNano = realisticEpochNano(startDateTime)
const endNano = realisticEpochNano(endDateTime)
const middleNano = realisticEpochNano(d1)
const startNano = toEpochNano(startDateTime)
const endNano = toEpochNano(endDateTime)
const middleNano = toEpochNano(dt1)
const unitFrac = Number(middleNano - startNano) / Number(endNano - startNano) * sign
dur[smallestUnitName]! += unitFrac // above loop populated this
return dur
return dur as DurationFields
}
// TODO: use this everywhere instead of isoFieldsToEpochNano?
// Make a separate sub-util JUST for PlainDatetime/PlainDate?
function realisticEpochNano(dt: ZonedDateTime | PlainDateTime | PlainDate): bigint {
const { epochNanoseconds } = dt as ZonedDateTime
return epochNanoseconds !== undefined
? epochNanoseconds
: isoFieldsToEpochNano(dt.getISOFields())
}
import { isoCalendarImpl } from '../calendarImpl/isoCalendarImpl'
import { positiveModulo } from '../utils/math'
import { computeDayOfYear, computeDaysInYear } from './calendar'
import { computeISODayOfWeek } from './isoMath'
import { computeISODayOfWeek } from './epoch'

@@ -6,0 +6,0 @@ // TODO: fix lots of 1-index problems!!!

@@ -12,2 +12,3 @@ /*

export { ExtendedDateTimeFormat } from './native/intlExtend'
// TODO: fix problem noted in tests/exports.js

@@ -14,0 +15,0 @@ export { PlainYearMonth } from './public/plainYearMonth'

import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { createDateTime } from '../dateUtils/dateTime'
import { isoFieldsToEpochMilli } from '../dateUtils/isoMath'
import { zeroTimeISOFields } from '../dateUtils/zonedDateTime'
import { zeroISOTimeFields } from '../dateUtils/dayAndTime'
import { isoFieldsToEpochMilli } from '../dateUtils/epoch'
import { Calendar } from '../public/calendar'
import { createDateTime } from '../public/plainDateTime'
import { TimeZone } from '../public/timeZone'

@@ -103,3 +103,3 @@ import { DateISOFields } from '../public/types'

const plainDateTime = createDateTime({ // necessary? pass directly into getInstantFor?
...zeroTimeISOFields,
...zeroISOTimeFields,
...entity.getISOFields(),

@@ -106,0 +106,0 @@ })

@@ -7,4 +7,5 @@ import {

} from '../argParse/calendar'
import { dateFieldMap, monthDayFieldMap, yearMonthFieldMap } from '../argParse/fieldStr'
import { parseOverflowOption } from '../argParse/overflowHandling'
import { ensureOptionsObj } from '../argParse/refine'
import { ensureOptionsObj, refineFields } from '../argParse/refine'
import { parseUnit } from '../argParse/unitStr'

@@ -16,3 +17,2 @@ import { checkEpochMilliBuggy } from '../calendarImpl/bugs'

import { AbstractObj, ensureObj } from '../dateUtils/abstract'
import { addToDateFields } from '../dateUtils/add'
import {

@@ -26,9 +26,11 @@ computeDayOfYear,

import { diffDateFields } from '../dateUtils/diff'
import { computeISODayOfWeek, isoEpochLeapYear, isoToEpochMilli } from '../dateUtils/isoMath'
import { MonthDayFields } from '../dateUtils/monthDay'
import { computeISODayOfWeek, isoEpochLeapYear, isoToEpochMilli } from '../dateUtils/epoch'
import { attachStringTag } from '../dateUtils/mixins'
import { tryParseDateTime } from '../dateUtils/parse'
import { translateDate } from '../dateUtils/translate'
import { InputDateFields } from '../dateUtils/typesPrivate'
import { DAY, DateUnitInt, YEAR } from '../dateUtils/units'
import { computeWeekOfISOYear } from '../dateUtils/week'
import { createWeakMap } from '../utils/obj'
import { Duration } from './duration'
import { Duration, createDuration } from './duration'
import { PlainDate } from './plainDate'

@@ -72,3 +74,3 @@ import { PlainDateTime } from './plainDateTime'

}
const parsed = tryParseDateTime(String(arg))
const parsed = tryParseDateTime(String(arg), false, true) // allowZ=true
return new Calendar(

@@ -81,3 +83,5 @@ parsed // a date-time string?

get id(): string { return getImpl(this).id }
get id(): string {
return this.toString()
}

@@ -187,4 +191,6 @@ era(arg: PlainYearMonth | DateArg | PlainDateTime | ZonedDateTime): string | undefined {

dateFromFields(arg: DateLikeFields, options?: OverflowOptions): PlainDate {
const isoFields = queryDateISOFields(arg, getImpl(this), options)
dateFromFields(fields: DateLikeFields, options?: OverflowOptions): PlainDate {
const refinedFields = refineFields(fields, dateFieldMap) as DateLikeFields
const isoFields = queryDateISOFields(refinedFields, getImpl(this), options)
return new PlainDate(

@@ -198,4 +204,6 @@ isoFields.isoYear,

yearMonthFromFields(arg: YearMonthLikeFields, options?: OverflowOptions): PlainYearMonth {
const isoFields = queryDateISOFields({ ...arg, day: 1 }, getImpl(this), options)
yearMonthFromFields(fields: YearMonthLikeFields, options?: OverflowOptions): PlainYearMonth {
const refinedFields = refineFields(fields, yearMonthFieldMap) as YearMonthLikeFields
const isoFields = queryDateISOFields({ ...refinedFields, day: 1 }, getImpl(this), options)
return new PlainYearMonth(

@@ -211,4 +219,6 @@ isoFields.isoYear,

const impl = getImpl(this)
let { era, eraYear, year, month, monthCode, day } = fields as Partial<MonthDayFields>
const refinedFields = refineFields(fields, monthDayFieldMap) as MonthDayLikeFields
let { era, eraYear, year, month, monthCode, day } = refinedFields as Partial<InputDateFields>
if (day === undefined) {

@@ -251,3 +261,3 @@ throw new TypeError('required property \'day\' missing or undefined')

const overflowHandling = parseOverflowOption(options)
const isoFields = addToDateFields(date, duration, impl, overflowHandling)
const isoFields = translateDate(date, duration, impl, overflowHandling)

@@ -270,9 +280,32 @@ return new PlainDate(

ensureCalendarsEqual(getCommonCalendar(d0, d1), this)
return diffDateFields(d0, d1, impl, largestUnit)
ensureCalendarsEqual(this, getCommonCalendar(d0, d1))
return createDuration(
diffDateFields(d0, d1, impl, largestUnit),
)
}
toString(): string { return this.id }
/*
Given a date-type's core field names, returns the field names that should be
given to Calendar::yearMonthFromFields/monthDayFromFields/dateFromFields
*/
fields(inFields: string[]): string[] {
return inFields.slice() // copy
}
/*
Given a date-instance, and fields to override, returns the fields that should be
given to Calendar::yearMonthFromFields/monthDayFromFields/dateFromFields
*/
mergeFields(baseFields: any, additionalFields: any): any {
return mergeCalFields(baseFields, additionalFields)
}
toString(): string {
return getImpl(this).id
}
}
attachStringTag(Calendar, 'Calendar')
export function createDefaultCalendar(): Calendar {

@@ -282,2 +315,53 @@ return new Calendar(isoCalendarID)

// TODO: better types?
export function mergeCalFields(baseFields: any, additionalFields: any): any {
const merged = { ...baseFields, ...additionalFields } as any
if (baseFields.year !== undefined) {
delete merged.era
delete merged.eraYear
delete merged.year
let anyAdditionalYear = false
if (additionalFields.era !== undefined || additionalFields.eraYear !== undefined) {
merged.era = additionalFields.era
merged.eraYear = additionalFields.eraYear
anyAdditionalYear = true
}
if (additionalFields.year !== undefined) {
merged.year = additionalFields.year
anyAdditionalYear = true
}
if (!anyAdditionalYear) {
merged.year = baseFields.year
}
}
if (baseFields.monthCode !== undefined) {
delete merged.monthCode
delete merged.month
let anyAdditionalMonth = false
if (additionalFields.month !== undefined) {
merged.month = additionalFields.month
anyAdditionalMonth = true
}
if (additionalFields.monthCode !== undefined) {
merged.monthCode = additionalFields.monthCode
anyAdditionalMonth = true
}
if (!anyAdditionalMonth) {
merged.monthCode = baseFields.monthCode
}
}
if (baseFields.day !== undefined) {
merged.day = additionalFields.day ?? baseFields.day
}
return merged
}
// utils

@@ -284,0 +368,0 @@

@@ -1,20 +0,23 @@

import { durationFieldMap } from '../argParse/fieldStr'
import { parseDiffOptions } from '../argParse/diffOptions'
import { DurationToStringUnitInt, parseTimeToStringOptions } from '../argParse/isoFormatOptions'
import { ensureOptionsObj, refineFields, refineOverrideFields } from '../argParse/refine'
import { parseUnit } from '../argParse/unitStr'
import { ensureOptionsObj, isObjectLike } from '../argParse/refine'
import { parseTotalConfig } from '../argParse/totalOptions'
import { AbstractNoValueObj, ensureObj } from '../dateUtils/abstract'
import { compareDurations } from '../dateUtils/compare'
import {
SignedDurationFields,
addAndBalanceDurations,
compareDurations,
createDuration,
negateFields,
refineDurationFields,
roundAndBalanceDuration,
} from '../dateUtils/duration'
absDuration,
computeLargestDurationUnit,
negateDuration,
refineDurationNumbers,
} from '../dateUtils/durationFields'
import { processDurationFields } from '../dateUtils/fromAndWith'
import { formatDurationISO } from '../dateUtils/isoFormat'
import { attachStringTag } from '../dateUtils/mixins'
import { parseDuration } from '../dateUtils/parseDuration'
import { extractRelativeTo } from '../dateUtils/relativeTo'
import { roundDuration } from '../dateUtils/roundingDuration'
import { computeTotalUnits } from '../dateUtils/totalUnits'
import { addDurationFields } from '../dateUtils/translate'
import { DurationFields, UnsignedDurationFields } from '../dateUtils/typesPrivate'
import { NANOSECOND, SECOND, UnitInt, YEAR } from '../dateUtils/units'
import { createWeakMap, mapHash } from '../utils/obj'
import {

@@ -30,6 +33,8 @@ CompareResult,

LocalesArg,
Unit,
ZonedDateTimeArg,
} from './types'
} from '../public/types'
import { createWeakMap } from '../utils/obj'
const [getFields, setFields] = createWeakMap<Duration, SignedDurationFields>()
const [getFields, setFields] = createWeakMap<Duration, DurationFields>()

@@ -50,3 +55,3 @@ export class Duration extends AbstractNoValueObj {

super()
setFields(this, refineDurationFields({
const numberFields = processDurationFields({ // TODO: overkill. does hasAnyProps
years,

@@ -62,3 +67,4 @@ months,

nanoseconds,
}))
})
setFields(this, refineDurationNumbers(numberFields))
}

@@ -69,3 +75,3 @@

typeof arg === 'object'
? refineFields(arg, durationFieldMap)
? processDurationFields(arg)
: parseDuration(arg),

@@ -80,3 +86,7 @@ )

): CompareResult {
return compareDurations(a, b, ensureOptionsObj(options).relativeTo)
return compareDurations(
ensureObj(Duration, a),
ensureObj(Duration, b),
extractRelativeTo(ensureOptionsObj(options).relativeTo),
)
}

@@ -100,3 +110,3 @@

...getFields(this),
...refineOverrideFields(fields, durationFieldMap),
...processDurationFields(fields),
})

@@ -106,41 +116,54 @@ }

negated(): Duration {
return createDuration(
negateFields(getFields(this) as Partial<SignedDurationFields>), // TODO: fix types
)
return createDuration(negateDuration(getFields(this)))
}
abs(): Duration {
return createDuration(
mapHash(
getFields(this),
(num: number) => Math.abs(num),
),
)
return createDuration(absDuration(getFields(this)))
}
add(other: DurationArg, options?: { relativeTo?: ZonedDateTimeArg | DateTimeArg}): Duration {
return addAndBalanceDurations(
this,
ensureObj(Duration, other),
ensureOptionsObj(options).relativeTo,
)
return addDurations(this, ensureObj(Duration, other), options)
}
subtract(other: DurationArg, options?: { relativeTo?: ZonedDateTimeArg | DateTimeArg}): Duration {
return addAndBalanceDurations(
this,
ensureObj(Duration, other).negated(),
ensureOptionsObj(options).relativeTo,
)
return addDurations(this, negateDuration(ensureObj(Duration, other)), options)
}
round(options: DurationRoundingOptions): Duration {
return roundAndBalanceDuration(this, options)
round(options: DurationRoundingOptions | Unit): Duration {
const optionsObj: DurationRoundingOptions = typeof options === 'string'
? { smallestUnit: options }
: options
if (!isObjectLike(optionsObj)) {
throw new TypeError('Must specify options') // best place for this?
} else if (optionsObj.largestUnit === undefined && optionsObj.smallestUnit === undefined) {
throw new RangeError('Must specify either largestUnit or smallestUnit')
}
const defaultLargestUnit = computeLargestDurationUnit(this)
const diffConfig = parseDiffOptions<Unit, UnitInt>(
optionsObj,
defaultLargestUnit, // largestUnitDefault
NANOSECOND, // smallestUnitDefault
NANOSECOND, // minUnit
YEAR, // maxUnit
true, // forDurationRounding
)
const relativeTo = extractRelativeTo(optionsObj.relativeTo)
return createDuration(
roundDuration(this, diffConfig, relativeTo, relativeTo ? relativeTo.calendar : undefined),
)
}
total(options: DurationTotalOptions): number {
total(options: DurationTotalOptions | Unit): number {
const totalConfig = parseTotalConfig(options)
const relativeTo = extractRelativeTo(totalConfig.relativeTo)
return computeTotalUnits(
this,
parseUnit<UnitInt>(ensureOptionsObj(options).unit, undefined, NANOSECOND, YEAR),
options.relativeTo,
totalConfig.unit,
relativeTo,
relativeTo ? relativeTo.calendar : undefined,
)

@@ -161,1 +184,30 @@ }

}
attachStringTag(Duration, 'Duration')
export function createDuration(fields: UnsignedDurationFields): Duration {
return new Duration(
fields.years,
fields.months,
fields.weeks,
fields.days,
fields.hours,
fields.minutes,
fields.seconds,
fields.milliseconds,
fields.microseconds,
fields.nanoseconds,
)
}
function addDurations(
d0: DurationFields,
d1: DurationFields,
options?: { relativeTo?: ZonedDateTimeArg | DateTimeArg },
): Duration {
const relativeTo = extractRelativeTo(ensureOptionsObj(options).relativeTo)
return createDuration(
addDurationFields(d0, d1, relativeTo, relativeTo ? relativeTo.calendar : undefined),
)
}

@@ -0,15 +1,28 @@

import { parseDiffOptions } from '../argParse/diffOptions'
import { OVERFLOW_REJECT } from '../argParse/overflowHandling'
import { ensureOptionsObj, isObjectLike } from '../argParse/refine'
import { parseRoundingOptions } from '../argParse/roundingOptions'
import { AbstractNoValueObj, ensureObj } from '../dateUtils/abstract'
import { constrainDateTimeISO } from '../dateUtils/dateTime'
import { addToInstant, compareInstants, diffInstants, roundInstant } from '../dateUtils/instant'
import { compareEpochObjs } from '../dateUtils/compare'
import { constrainDateTimeISO } from '../dateUtils/constrain'
import { diffEpochNanos } from '../dateUtils/diff'
import { negateDuration } from '../dateUtils/durationFields'
import { isoFieldsToEpochNano } from '../dateUtils/epoch'
import { validateInstant } from '../dateUtils/isoFieldValidation'
import { isoFieldsToEpochNano } from '../dateUtils/isoMath'
import { ComputedEpochFields, mixinEpochFields } from '../dateUtils/mixins'
import { ComputedEpochFields, attachStringTag, mixinEpochFields } from '../dateUtils/mixins'
import { parseZonedDateTime } from '../dateUtils/parse'
import { nanoInMicroBI, nanoInMilliBI, nanoInSecondBI } from '../dateUtils/units'
import { roundEpochNano } from '../dateUtils/rounding'
import { translateEpochNano } from '../dateUtils/translate'
import {
HOUR,
NANOSECOND,
SECOND,
nanoInMicroBI,
nanoInMilliBI,
nanoInSecondBI,
} from '../dateUtils/units'
import { createZonedFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { createWeakMap } from '../utils/obj'
import { Duration } from './duration'
import { Duration, createDuration } from './duration'
import {

@@ -32,2 +45,5 @@ CalendarArg,

super()
if (typeof epochNanoseconds === 'number') {
throw new TypeError('Must supply bigint, not number')
}
epochNanoseconds = BigInt(epochNanoseconds) // cast

@@ -44,3 +60,3 @@ validateInstant(epochNanoseconds)

const fields = parseZonedDateTime(String(arg))
const offsetNano = fields.offset
const offsetNano = fields.offsetNanoseconds
if (offsetNano === undefined) {

@@ -73,3 +89,3 @@ throw new RangeError('Must specify an offset')

static compare(a: InstantArg, b: InstantArg): CompareResult {
return compareInstants(
return compareEpochObjs(
ensureObj(Instant, a),

@@ -83,7 +99,11 @@ ensureObj(Instant, b),

add(durationArg: DurationArg): Instant {
return addToInstant(this, ensureObj(Duration, durationArg))
return new Instant(
translateEpochNano(this.epochNanoseconds, ensureObj(Duration, durationArg)),
)
}
subtract(durationArg: DurationArg): Instant {
return addToInstant(this, ensureObj(Duration, durationArg).negated())
return new Instant(
translateEpochNano(this.epochNanoseconds, negateDuration(ensureObj(Duration, durationArg))),
)
}

@@ -100,7 +120,11 @@

round(options: TimeRoundingOptions): Instant {
return roundInstant(this, options)
const roundingConfig = parseRoundingOptions(options, undefined, NANOSECOND, HOUR, true)
return new Instant(
roundEpochNano(this.epochNanoseconds, roundingConfig),
)
}
equals(other: InstantArg): boolean {
return compareInstants(this, ensureObj(Instant, other)) === 0
return !compareEpochObjs(this, ensureObj(Instant, other))
}

@@ -110,3 +134,3 @@

const timeZoneArg = ensureOptionsObj(options).timeZone
const zonedDateTime = this.toZonedDateTimeISO(timeZoneArg ?? 'UTC')
const zonedDateTime = this.toZonedDateTimeISO(timeZoneArg ?? 'UTC') // TODO: don't use util!!!
return zonedDateTime.toString({

@@ -144,2 +168,3 @@ ...options,

export interface Instant extends ToLocaleStringMethods {}
attachStringTag(Instant, 'Instant')
mixinEpochFields(Instant)

@@ -157,1 +182,19 @@ mixinLocaleStringMethods(Instant, createZonedFormatFactoryFactory({

}, {}))
function diffInstants(
inst0: Instant,
inst1: Instant,
options: TimeDiffOptions | undefined,
): Duration {
const diffConfig = parseDiffOptions(
options,
SECOND,
NANOSECOND,
NANOSECOND,
HOUR,
)
return createDuration(
diffEpochNanos(inst0.epochNanoseconds, inst1.epochNanoseconds, diffConfig),
)
}

@@ -0,47 +1,65 @@

import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { ensureObj } from '../dateUtils/abstract'
import { attachStringTag } from '../dateUtils/mixins'
import { ISODateTimeFields } from '../dateUtils/typesPrivate'
import { nanoInMilliBI } from '../dateUtils/units'
import { OrigDateTimeFormat } from '../native/intlUtils'
import { Calendar } from './calendar'
import { Instant } from './instant'
import { PlainDate } from './plainDate'
import { PlainDateTime } from './plainDateTime'
import { PlainTime } from './plainTime'
import { PlainDate, createDate } from './plainDate'
import { PlainDateTime, createDateTime } from './plainDateTime'
import { PlainTime, createTime } from './plainTime'
import { TimeZone } from './timeZone'
import { CalendarArg, TimeZoneArg } from './types'
import { ZonedDateTime } from './zonedDateTime'
import {
ZonedDateTime,
buildZonedDateTimeISOFields,
createZonedDateTimeFromFields,
} from './zonedDateTime'
function getZonedDateTimeISO(timeZoneArg: TimeZoneArg = getTimeZone()): ZonedDateTime {
return getInstant().toZonedDateTimeISO(timeZoneArg)
const Now = {
zonedDateTimeISO: getZonedDateTimeISO,
zonedDateTime: getZonedDateTime,
plainDateTimeISO: getPlainDateTimeISO,
plainDateTime: getPlainDateTime,
plainDateISO: getPlainDateISO,
plainDate: getPlainDate,
plainTimeISO: getPlainTimeISO,
instant: getInstant,
timeZone: getTimeZone,
}
attachStringTag(Now, 'Now')
export { Now }
function getZonedDateTimeISO(timeZoneArg?: TimeZoneArg): ZonedDateTime {
return createZonedDateTimeFromFields(buidZonedFields(isoCalendarID, timeZoneArg))
}
function getZonedDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): ZonedDateTime {
if (calendarArg === undefined) {
throw new RangeError('Must specify calendar') // bad
}
return getInstant().toZonedDateTime({
calendar: calendarArg,
timeZone: timeZoneArg ?? getTimeZone(),
})
return createZonedDateTimeFromFields(buidZonedFields(calendarArg, timeZoneArg))
}
function getPlainDateTimeISO(timeZoneArg: TimeZoneArg = getTimeZone()): PlainDateTime {
return getZonedDateTimeISO(timeZoneArg).toPlainDateTime()
function getPlainDateTimeISO(timeZoneArg?: TimeZoneArg): PlainDateTime {
return createDateTime(buidZonedFields(isoCalendarID, timeZoneArg))
}
function getPlainDateTime(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDateTime {
return getZonedDateTime(calendarArg, timeZoneArg).toPlainDateTime()
return createDateTime(buidZonedFields(calendarArg, timeZoneArg))
}
function getPlainDateISO(timeZoneArg: TimeZoneArg = getTimeZone()): PlainDate {
return getPlainDateTimeISO(timeZoneArg).toPlainDate()
function getPlainDateISO(timeZoneArg: TimeZoneArg): PlainDate {
return createDate(buidZonedFields(isoCalendarID, timeZoneArg))
}
function getPlainDate(calendarArg: CalendarArg, timeZoneArg?: TimeZoneArg): PlainDate {
return getPlainDateTime(calendarArg, timeZoneArg).toPlainDate()
return createDate(buidZonedFields(calendarArg, timeZoneArg))
}
function getPlainTimeISO(timeZoneArg: TimeZoneArg = getTimeZone()): PlainTime {
return getInstant().toZonedDateTimeISO(timeZoneArg).toPlainTime()
function getPlainTimeISO(timeZoneArg: TimeZoneArg): PlainTime {
return createTime(buidZonedFields(isoCalendarID, timeZoneArg))
}
function getInstant(): Instant {
return new Instant(BigInt(Date.now()) * nanoInMilliBI)
return new Instant(getEpochNano())
}

@@ -53,12 +71,19 @@

export const Now = {
zonedDateTimeISO: getZonedDateTimeISO,
zonedDateTime: getZonedDateTime,
plainDateTimeISO: getPlainDateTimeISO,
plainDateTime: getPlainDateTime,
plainDateISO: getPlainDateISO,
plainDate: getPlainDate,
plainTimeISO: getPlainTimeISO,
instant: getInstant,
timeZone: getTimeZone,
// utils
function buidZonedFields(
calendarArg: CalendarArg,
timeZoneArg: TimeZoneArg = getTimeZone(),
): ISODateTimeFields & { timeZone: TimeZone, calendar: Calendar } {
const timeZone = ensureObj(TimeZone, timeZoneArg)
return {
...buildZonedDateTimeISOFields(getEpochNano(), timeZone)[0],
// build these in to buildZonedDateTimeISOFields?
timeZone,
calendar: ensureObj(Calendar, calendarArg),
}
}
function getEpochNano(): bigint {
return BigInt(Date.now()) * nanoInMilliBI
}

@@ -1,16 +0,11 @@

import { extractCalendar } from '../argParse/calendar'
import { getCommonCalendar } from '../argParse/calendar'
import { parseCalendarDisplayOption } from '../argParse/calendarDisplay'
import { parseDiffOptions } from '../argParse/diffOptions'
import { dateFieldMap } from '../argParse/fieldStr'
import { OVERFLOW_REJECT, parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import {
compareDates,
constrainDateISO,
createDate,
diffDates,
overrideDateFields,
} from '../dateUtils/date'
import { createDateTime } from '../dateUtils/dateTime'
import { compareDateTimes } from '../dateUtils/compare'
import { constrainDateISO } from '../dateUtils/constrain'
import { zeroISOTimeFields } from '../dateUtils/dayAndTime'
import { diffDates } from '../dateUtils/diff'
import { processDateFromFields, processDateWithFields } from '../dateUtils/fromAndWith'
import { validateDate } from '../dateUtils/isoFieldValidation'

@@ -20,2 +15,3 @@ import { formatCalendarID, formatDateISO } from '../dateUtils/isoFormat'

DateCalendarFields,
attachStringTag,
dateCalendarFields,

@@ -27,12 +23,12 @@ mixinCalendarFields,

import { refineBaseObj } from '../dateUtils/parseRefine'
import { ensureLooseTime } from '../dateUtils/time'
import { DAY, DateUnitInt, YEAR } from '../dateUtils/units'
import { createYearMonth } from '../dateUtils/yearMonth'
import { createPlainFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { Calendar, createDefaultCalendar } from './calendar'
import { Duration } from './duration'
import { PlainDateTime } from './plainDateTime'
import { Duration, createDuration } from './duration'
import { PlainDateTime, createDateTime } from './plainDateTime'
import { PlainMonthDay } from './plainMonthDay'
import { PlainYearMonth } from './plainYearMonth'
import { PlainTime, ensureLooseTime } from './plainTime'
import { PlainYearMonth, createYearMonth } from './plainYearMonth'
import { TimeZone } from './timeZone'
import {

@@ -44,3 +40,2 @@ CalendarArg,

DateISOFields,
DateLikeFields,
DateOverrides,

@@ -53,4 +48,5 @@ DateToStringOptions,

TimeZoneArg,
TimeZoneProtocol,
} from './types'
import { ZonedDateTime } from './zonedDateTime'
import { ZonedDateTime, createZonedDateTimeFromFields } from './zonedDateTime'

@@ -83,4 +79,3 @@ export class PlainDate extends AbstractISOObj<DateISOFields> {

if (typeof arg === 'object') {
const refinedFields = refineFields(arg, dateFieldMap) as DateLikeFields
return extractCalendar(arg).dateFromFields(refinedFields, options)
return processDateFromFields(arg, options)
}

@@ -92,3 +87,3 @@

static compare(a: DateArg, b: DateArg): CompareResult {
return compareDates(
return compareDateTimes(
ensureObj(PlainDate, a),

@@ -100,5 +95,3 @@ ensureObj(PlainDate, b),

with(fields: DateOverrides, options?: OverflowOptions): PlainDate {
const refinedFields = refineOverrideFields(fields, dateFieldMap)
const mergedFields = overrideDateFields(refinedFields, this)
return this.calendar.dateFromFields(mergedFields, options)
return processDateWithFields(this, fields, options)
}

@@ -125,6 +118,7 @@

until(other: DateArg, options?: DateDiffOptions): Duration {
return diffDates(
return diffPlainDates(
this,
ensureObj(PlainDate, other),
parseDiffOptions<DateUnit, DateUnitInt>(options, DAY, DAY, DAY, YEAR),
false,
options,
)

@@ -134,7 +128,7 @@ }

since(other: DateArg, options?: DateDiffOptions): Duration {
return diffDates(
return diffPlainDates(
this,
ensureObj(PlainDate, other),
parseDiffOptions<DateUnit, DateUnitInt>(options, DAY, DAY, DAY, YEAR),
true,
options,
)

@@ -144,3 +138,3 @@ }

equals(other: DateArg): boolean {
return compareDates(this, ensureObj(PlainDate, other)) === 0
return !compareDateTimes(this, ensureObj(PlainDate, other))
}

@@ -153,7 +147,19 @@

return formatDateISO(fields) +
formatCalendarID(fields.calendar.id, calendarDisplay)
formatCalendarID(fields.calendar.toString(), calendarDisplay)
}
toZonedDateTime(options: { plainTime?: TimeArg, timeZone: TimeZoneArg }): ZonedDateTime {
return this.toPlainDateTime(options.plainTime).toZonedDateTime(options.timeZone)
toZonedDateTime(
options: { plainTime?: TimeArg, timeZone: TimeZoneArg } | TimeZoneArg,
): ZonedDateTime {
const refinedOptions = processToZonedDateTimeOptions(options)
const timeZone = ensureObj(TimeZone, refinedOptions.timeZone)
const plainTime = refinedOptions.plainTime === undefined
? undefined
: ensureObj(PlainTime, refinedOptions.plainTime)
return createZonedDateTimeFromFields({
...this.getISOFields(),
...(plainTime ? plainTime.getISOFields() : zeroISOTimeFields),
timeZone,
})
}

@@ -175,2 +181,3 @@

export interface PlainDate extends ToLocaleStringMethods {}
attachStringTag(PlainDate, 'PlainDate')
mixinISOFields(PlainDate)

@@ -188,1 +195,57 @@ mixinCalendarFields(PlainDate, dateCalendarFields)

}))
// creation
export function createDate(isoFields: DateISOFields): PlainDate {
return new PlainDate(
isoFields.isoYear,
isoFields.isoMonth,
isoFields.isoDay,
isoFields.calendar,
)
}
// argument processing
function processToZonedDateTimeOptions(
options?: { plainTime?: TimeArg, timeZone: TimeZoneArg } | TimeZoneArg,
): {
plainTime?: TimeArg,
timeZone: TimeZoneArg,
} {
let plainTime: TimeArg | undefined
let timeZone: TimeZoneArg | undefined
if (typeof options === 'string') {
timeZone = options
} else if (typeof options === 'object') {
if ((options as TimeZoneProtocol).id !== undefined) {
timeZone = options as TimeZoneProtocol
} else {
timeZone = options.timeZone
plainTime = (options as { plainTime?: TimeArg }).plainTime
}
if (timeZone === undefined) {
throw new TypeError('Invalid timeZone argument')
}
} else {
throw new TypeError('Invalid options/timeZone argument')
}
return { plainTime, timeZone }
}
function diffPlainDates(
pd0: PlainDate,
pd1: PlainDate,
flip: boolean,
options: DateDiffOptions | undefined,
): Duration {
return createDuration(
diffDates(
pd0,
pd1,
getCommonCalendar(pd0, pd1),
flip,
parseDiffOptions<DateUnit, DateUnitInt>(options, DAY, DAY, DAY, YEAR),
),
)
}

@@ -1,21 +0,14 @@

import { extractCalendar, getStrangerCalendar } from '../argParse/calendar'
import { getCommonCalendar, getStrangerCalendar } from '../argParse/calendar'
import { parseCalendarDisplayOption } from '../argParse/calendarDisplay'
import { dateTimeFieldMap } from '../argParse/fieldStr'
import { parseDiffOptions } from '../argParse/diffOptions'
import { parseTimeToStringOptions } from '../argParse/isoFormatOptions'
import { OVERFLOW_REJECT, parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { parseRoundingOptions } from '../argParse/roundingOptions'
import { timeUnitNames } from '../argParse/unitStr'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import { createDate } from '../dateUtils/date'
import {
addToDateTime,
compareDateTimes,
constrainDateTimeISO,
createDateTime,
dateTimeFieldsToISO,
diffDateTimes,
overrideDateTimeFields,
roundDateTime,
roundDateTimeWithOptions,
} from '../dateUtils/dateTime'
import { compareDateTimes } from '../dateUtils/compare'
import { constrainDateTimeISO } from '../dateUtils/constrain'
import { diffDateTimes } from '../dateUtils/diff'
import { negateDuration } from '../dateUtils/durationFields'
import { processDateTimeFromFields, processDateTimeWithFields } from '../dateUtils/fromAndWith'
import { validateDateTime } from '../dateUtils/isoFieldValidation'

@@ -25,2 +18,3 @@ import { formatCalendarID, formatDateTimeISO } from '../dateUtils/isoFormat'

DateCalendarFields,
attachStringTag,
dateCalendarFields,

@@ -32,12 +26,14 @@ mixinCalendarFields,

import { refineBaseObj } from '../dateUtils/parseRefine'
import { TimeFields, createTime, ensureLooseTime } from '../dateUtils/time'
import { createYearMonth } from '../dateUtils/yearMonth'
import { roundDateTime } from '../dateUtils/rounding'
import { translateDateTime } from '../dateUtils/translate'
import { DurationFields, LocalTimeFields } from '../dateUtils/typesPrivate'
import { DAY, DayTimeUnitInt, NANOSECOND, UnitInt, YEAR } from '../dateUtils/units'
import { createPlainFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { Calendar, createDefaultCalendar } from './calendar'
import { Duration } from './duration'
import { PlainDate } from './plainDate'
import { Duration, createDuration } from './duration'
import { PlainDate, createDate } from './plainDate'
import { PlainMonthDay } from './plainMonthDay'
import { PlainTime } from './plainTime'
import { PlainYearMonth } from './plainYearMonth'
import { PlainTime, createTime, ensureLooseTime } from './plainTime'
import { PlainYearMonth, createYearMonth } from './plainYearMonth'
import { TimeZone } from './timeZone'

@@ -50,6 +46,6 @@ import {

DateTimeISOFields,
DateTimeLikeFields,
DateTimeOverrides,
DateTimeRoundingOptions,
DateTimeToStringOptions,
DayTimeUnit,
DiffOptions,

@@ -61,2 +57,3 @@ Disambiguation,

TimeZoneArg,
Unit,
} from './types'

@@ -106,8 +103,3 @@ import { ZonedDateTime } from './zonedDateTime'

: typeof arg === 'object'
? dateTimeFieldsToISO(
refineFields(arg, dateTimeFieldMap) as DateTimeLikeFields,
options,
overflowHandling,
extractCalendar(arg),
)
? processDateTimeFromFields(arg, overflowHandling, options)
: refineBaseObj(parseDateTime(String(arg))),

@@ -125,11 +117,5 @@ )

with(fields: DateTimeOverrides, options?: OverflowOptions): PlainDateTime {
const refinedFields = refineOverrideFields(fields, dateTimeFieldMap)
const mergedFields = overrideDateTimeFields(refinedFields, this)
const overflowHandling = parseOverflowOption(options)
return createDateTime(
dateTimeFieldsToISO(
mergedFields,
options,
parseOverflowOption(options),
this.calendar,
),
processDateTimeWithFields(this, fields, overflowHandling, options),
)

@@ -162,23 +148,43 @@ }

add(durationArg: DurationArg, options?: OverflowOptions): PlainDateTime {
return addToDateTime(this, ensureObj(Duration, durationArg), options)
return translatePlainDateTime(this, ensureObj(Duration, durationArg), options)
}
subtract(durationArg: DurationArg, options?: OverflowOptions): PlainDateTime {
return addToDateTime(this, ensureObj(Duration, durationArg).negated(), options)
return translatePlainDateTime(this, negateDuration(ensureObj(Duration, durationArg)), options)
}
until(other: DateTimeArg, options?: DiffOptions): Duration {
return diffDateTimes(this, ensureObj(PlainDateTime, other), options)
return diffPlainDateTimes(
this,
ensureObj(PlainDateTime, other),
false,
options,
)
}
since(other: DateTimeArg, options?: DiffOptions): Duration {
return diffDateTimes(this, ensureObj(PlainDateTime, other), options, true)
return diffPlainDateTimes(
this,
ensureObj(PlainDateTime, other),
true,
options,
)
}
round(options: DateTimeRoundingOptions): PlainDateTime {
return roundDateTimeWithOptions(this, options)
round(options: DateTimeRoundingOptions | DayTimeUnit): PlainDateTime {
const roundingConfig = parseRoundingOptions<DayTimeUnit, DayTimeUnitInt>(
options,
undefined, // no default. required
NANOSECOND, // minUnit
DAY, // maxUnit
)
return createDateTime({
...roundDateTime(this.getISOFields(), roundingConfig),
calendar: this.calendar,
})
}
equals(other: DateTimeArg): boolean {
return compareDateTimes(this, ensureObj(PlainDateTime, other)) === 0
return !compareDateTimes(this, ensureObj(PlainDateTime, other))
}

@@ -189,13 +195,8 @@

const calendarDisplay = parseCalendarDisplayOption(options)
const isoFields = roundDateTime(
this,
formatConfig.roundingIncrement,
formatConfig.roundingMode,
).getISOFields() // TODO: somehow have ISO fields returned directly
const isoFields = roundDateTime(this.getISOFields(), formatConfig)
return formatDateTimeISO(isoFields, formatConfig) +
formatCalendarID(isoFields.calendar.id, calendarDisplay)
formatCalendarID(this.calendar.toString(), calendarDisplay)
}
// workhorse for converting to ZonedDateTime for other objects
toZonedDateTime(

@@ -208,7 +209,4 @@ timeZoneArg: TimeZoneArg,

return new ZonedDateTime(
instant.epochNanoseconds,
timeZone,
this.calendar,
)
// more succinct than createZonedDateTimeFromFields
return new ZonedDateTime(instant.epochNanoseconds, timeZone, this.calendar)
}

@@ -224,4 +222,5 @@

export interface PlainDateTime extends DateCalendarFields { calendar: Calendar }
export interface PlainDateTime extends TimeFields {}
export interface PlainDateTime extends LocalTimeFields {}
export interface PlainDateTime extends ToLocaleStringMethods {}
attachStringTag(PlainDateTime, 'PlainDateTime')
mixinISOFields(PlainDateTime, timeUnitNames)

@@ -238,1 +237,48 @@ mixinCalendarFields(PlainDateTime, dateCalendarFields)

}, {}))
// creation
export function createDateTime(isoFields: DateTimeISOFields): PlainDateTime {
return new PlainDateTime(
isoFields.isoYear,
isoFields.isoMonth,
isoFields.isoDay,
isoFields.isoHour,
isoFields.isoMinute,
isoFields.isoSecond,
isoFields.isoMillisecond,
isoFields.isoMicrosecond,
isoFields.isoNanosecond,
isoFields.calendar,
)
}
function translatePlainDateTime(
pdt0: PlainDateTime,
dur: DurationFields,
options: OverflowOptions | undefined,
): PlainDateTime {
const isoFields = translateDateTime(pdt0.getISOFields(), dur, options)
return createDateTime({
...isoFields,
calendar: pdt0.calendar,
})
}
function diffPlainDateTimes(
pdt0: PlainDateTime,
pdt1: PlainDateTime,
flip: boolean,
options: DiffOptions | undefined,
): Duration {
const diffConfig = parseDiffOptions<Unit, UnitInt>(
options,
DAY, // largestUnitDefault
NANOSECOND, // smallestUnitDefault
NANOSECOND, // minUnit
YEAR, // maxUnit
)
return createDuration(
diffDateTimes(pdt0, pdt1, getCommonCalendar(pdt0, pdt1), flip, diffConfig),
)
}

@@ -1,12 +0,13 @@

import { extractCalendar } from '../argParse/calendar'
import { parseCalendarDisplayOption } from '../argParse/calendarDisplay'
import { OVERFLOW_REJECT, parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import { constrainDateISO } from '../dateUtils/date'
import { compareDateTimes } from '../dateUtils/compare'
import { constrainDateISO } from '../dateUtils/constrain'
import { isoEpochLeapYear } from '../dateUtils/epoch'
import { processMonthDayFromFields, processMonthDayWithFields } from '../dateUtils/fromAndWith'
import { formatCalendarID, formatDateISO, formatMonthDayISO } from '../dateUtils/isoFormat'
import { isoEpochLeapYear } from '../dateUtils/isoMath'
import {
MonthDayCalendarFields,
attachStringTag,
mixinCalendarFields,

@@ -16,9 +17,2 @@ mixinISOFields,

} from '../dateUtils/mixins'
import {
MonthDayFields,
createMonthDay,
monthDayFieldMap,
monthDaysEqual,
overrideMonthDayFields,
} from '../dateUtils/monthDay'
import { parseMonthDay } from '../dateUtils/parse'

@@ -30,11 +24,8 @@ import { refineBaseObj } from '../dateUtils/parseRefine'

} from '../native/intlUtils'
import { throwNew } from '../utils/obj'
import { Calendar, createDefaultCalendar } from './calendar'
import { PlainDate } from './plainDate'
import {
CalendarProtocol,
DateISOFields,
DateToStringOptions,
MonthDayArg,
MonthDayLikeFields,
MonthDayOverrides,

@@ -48,13 +39,7 @@ OverflowOptions,

isoDay: number,
calendar: CalendarProtocol = createDefaultCalendar(),
referenceISOYear?: number,
calendar: Calendar = createDefaultCalendar(), // TODO: change back to CalendarProtocol
referenceISOYear: number = isoEpochLeapYear,
) {
const isoYear: number = referenceISOYear ??
(calendar.id === isoCalendarID
? isoEpochLeapYear
: throwNew(Error, 'Must specify referenceYear')
)
super({
...constrainDateISO({ isoYear, isoMonth, isoDay }, OVERFLOW_REJECT),
...constrainDateISO({ isoYear: referenceISOYear, isoMonth, isoDay }, OVERFLOW_REJECT),
calendar,

@@ -72,11 +57,3 @@ })

if (typeof arg === 'object') {
const calendar = extractCalendar(arg)
let refinedFields = refineFields(arg, monthDayFieldMap) as Partial<MonthDayFields>
// be nice and guess year if no calendar specified
if (refinedFields.year === undefined && arg.calendar === undefined) {
refinedFields = { ...refinedFields, year: isoEpochLeapYear }
}
return calendar.monthDayFromFields(refinedFields as MonthDayLikeFields, options)
return processMonthDayFromFields(arg, options)
}

@@ -88,2 +65,3 @@

// for strings, force ISO year if no calendar specified
// TODO: more DRY with processMonthDayLike?
if (parsed.calendar === undefined) {

@@ -97,9 +75,7 @@ parsed.isoYear = isoEpochLeapYear

with(fields: MonthDayOverrides, options?: OverflowOptions): PlainMonthDay {
const refinedFields = refineOverrideFields(fields, monthDayFieldMap)
const mergedFields = overrideMonthDayFields(refinedFields, this)
return this.calendar.monthDayFromFields(mergedFields, options)
return processMonthDayWithFields(this, fields, options)
}
equals(other: MonthDayArg): boolean {
return monthDaysEqual(this, ensureObj(PlainMonthDay, other))
return !compareDateTimes(this, ensureObj(PlainMonthDay, other))
}

@@ -109,3 +85,3 @@

const fields = this.getISOFields()
const calendarID = fields.calendar.id
const calendarID = fields.calendar.toString() // see note in formatCalendarID
const calendarDisplay = parseCalendarDisplayOption(options)

@@ -120,3 +96,3 @@

toPlainDate(fields: { year: number }, options?: OverflowOptions): PlainDate {
toPlainDate(fields: { year: number }): PlainDate {
return this.calendar.dateFromFields({

@@ -126,3 +102,5 @@ year: fields.year,

day: this.day,
}, options)
}, {
overflow: 'reject', // always reject
})
}

@@ -134,2 +112,3 @@ }

export interface PlainMonthDay extends ToLocaleStringMethods {}
attachStringTag(PlainMonthDay, 'PlainMonthDay')
mixinISOFields(PlainMonthDay)

@@ -147,1 +126,11 @@ mixinCalendarFields(PlainMonthDay, monthDayCalendarFields)

}, true)) // strictCalendar
// create
export function createMonthDay(isoFields: DateISOFields): PlainMonthDay {
return new PlainMonthDay(
isoFields.isoMonth,
isoFields.isoDay,
isoFields.calendar,
isoFields.isoYear,
)
}

@@ -1,25 +0,20 @@

import { timeFieldMap } from '../argParse/fieldStr'
import { parseDiffOptions } from '../argParse/diffOptions'
import { parseTimeToStringOptions } from '../argParse/isoFormatOptions'
import { OVERFLOW_REJECT, parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { parseRoundingOptions } from '../argParse/roundingOptions'
import { timeUnitNames } from '../argParse/unitStr'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import { compareTimes } from '../dateUtils/compare'
import { constrainTimeISO } from '../dateUtils/constrain'
import { isoTimeToNano } from '../dateUtils/dayAndTime'
import { diffTimes } from '../dateUtils/diff'
import { negateDuration } from '../dateUtils/durationFields'
import { processTimeFromFields, processTimeWithFields } from '../dateUtils/fromAndWith'
import { formatTimeISO } from '../dateUtils/isoFormat'
import { mixinISOFields } from '../dateUtils/mixins'
import { attachStringTag, mixinISOFields } from '../dateUtils/mixins'
import { parseTime } from '../dateUtils/parse'
import { roundTime } from '../dateUtils/rounding'
import {
TimeFields,
addToPlainTime,
compareTimes,
constrainTimeISO,
createTime,
diffPlainTimes,
overrideTimeFields,
roundPlainTime,
timeFieldsToConstrainedISO,
timeFieldsToNano,
timeLikeToISO,
} from '../dateUtils/time'
import { nanoInMilliBI } from '../dateUtils/units'
import { translateTime } from '../dateUtils/translate'
import { DurationFields, ISOTimeFields, LocalTimeFields } from '../dateUtils/typesPrivate'
import { HOUR, NANOSECOND, TimeUnitInt, nanoInMilli } from '../dateUtils/units'
import { FormatFactory } from '../native/intlFactory'

@@ -29,5 +24,6 @@ import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'

import { Calendar, createDefaultCalendar } from './calendar'
import { Duration } from './duration'
import { Duration, createDuration } from './duration'
import { PlainDate } from './plainDate'
import { PlainDateTime } from './plainDateTime'
import { TimeZone } from './timeZone'
import {

@@ -44,5 +40,6 @@ CompareResult,

TimeToStringOptions,
TimeUnit,
TimeZoneArg,
} from './types'
import { ZonedDateTime } from './zonedDateTime'
import { ZonedDateTime, createZonedDateTimeFromFields } from './zonedDateTime'

@@ -80,3 +77,3 @@ export class PlainTime extends AbstractISOObj<TimeISOFields> {

: typeof arg === 'object'
? timeFieldsToConstrainedISO(refineFields(arg, timeFieldMap), overflowHandling)
? processTimeFromFields(arg, overflowHandling)
: parseTime(String(arg)),

@@ -91,6 +88,4 @@ )

with(fields: TimeLike, options?: OverflowOptions): PlainTime {
const refinedFields = refineOverrideFields(fields, timeFieldMap)
const mergedFields = overrideTimeFields(refinedFields, this)
return createTime(
timeFieldsToConstrainedISO(mergedFields, parseOverflowOption(options)),
processTimeWithFields(this, fields, parseOverflowOption(options)),
)

@@ -100,7 +95,7 @@ }

add(durationArg: DurationArg): PlainTime {
return addToPlainTime(this, ensureObj(Duration, durationArg))
return translatePlainTime(this, ensureObj(Duration, durationArg))
}
subtract(durationArg: DurationArg): PlainTime {
return addToPlainTime(this, ensureObj(Duration, durationArg).negated())
return translatePlainTime(this, negateDuration(ensureObj(Duration, durationArg)))
}

@@ -116,8 +111,15 @@

round(options: TimeRoundingOptions): PlainTime {
return roundPlainTime(this, options)
round(options: TimeRoundingOptions | TimeUnit): PlainTime {
const roundingConfig = parseRoundingOptions<TimeUnit, TimeUnitInt>(
options,
undefined, // no default. required
NANOSECOND, // minUnit
HOUR, // maxUnit
)
return createTime(roundTime(this.getISOFields(), roundingConfig))
}
equals(other: TimeArg): boolean {
return compareTimes(this, ensureObj(PlainTime, other)) === 0
return !compareTimes(this, ensureObj(PlainTime, other))
}

@@ -127,12 +129,16 @@

const formatConfig = parseTimeToStringOptions(options)
const roundedISOFields = roundTime(
this,
formatConfig.roundingIncrement,
formatConfig.roundingMode,
)
return formatTimeISO(timeLikeToISO(roundedISOFields), formatConfig)
const roundedISOFields: ISOTimeFields = roundTime(this.getISOFields(), formatConfig)
return formatTimeISO(roundedISOFields, formatConfig)
}
toZonedDateTime(options: { plainDate: DateArg, timeZone: TimeZoneArg }): ZonedDateTime {
return this.toPlainDateTime(options.plainDate).toZonedDateTime(options.timeZone)
// TODO: ensure options object first?
const plainDate = ensureObj(PlainDate, options.plainDate)
const timeZone = ensureObj(TimeZone, options.timeZone)
return createZonedDateTimeFromFields({
...plainDate.getISOFields(),
...this.getISOFields(),
timeZone,
})
}

@@ -146,4 +152,5 @@

// mixin
export interface PlainTime extends TimeFields { calendar: Calendar }
export interface PlainTime extends LocalTimeFields { calendar: Calendar }
export interface PlainTime extends ToLocaleStringMethods {}
attachStringTag(PlainTime, 'PlainTime')
mixinISOFields(PlainTime, timeUnitNames)

@@ -171,5 +178,45 @@ mixinLocaleStringMethods(PlainTime, createPlainTimeFormatFactory)

buildEpochMilli: (plainTime: PlainTime) => (
Number(timeFieldsToNano(plainTime) / nanoInMilliBI)
Math.trunc(isoTimeToNano(plainTime.getISOFields()) / nanoInMilli)
),
}
}
export function createTime(isoFields: ISOTimeFields): PlainTime {
return new PlainTime(
isoFields.isoHour,
isoFields.isoMinute,
isoFields.isoSecond,
isoFields.isoMillisecond,
isoFields.isoMicrosecond,
isoFields.isoNanosecond,
)
}
// Normally ensureObj and ::from would fail when undefined is specified
// Fallback to 00:00 time
export function ensureLooseTime(arg: TimeArg | undefined): PlainTime {
return ensureObj(PlainTime, arg ?? { hour: 0 })
}
function translatePlainTime(pt: PlainTime, dur: DurationFields): PlainTime {
return createTime(translateTime(pt.getISOFields(), dur))
}
function diffPlainTimes(
pt0: PlainTime,
pt1: PlainTime,
options: TimeDiffOptions | undefined,
): Duration {
const diffConfig = parseDiffOptions<TimeUnit, TimeUnitInt>(
options,
HOUR, // largestUnitDefault
NANOSECOND, // smallestUnitDefault
NANOSECOND, // minUnit
HOUR, // maxUnit
)
return createDuration(
// TODO: use local-time-fields as-is somehow???
diffTimes(pt0.getISOFields(), pt1.getISOFields(), diffConfig),
)
}

@@ -1,10 +0,12 @@

import { extractCalendar } from '../argParse/calendar'
import { getCommonCalendar } from '../argParse/calendar'
import { parseCalendarDisplayOption } from '../argParse/calendarDisplay'
import { parseDiffOptions } from '../argParse/diffOptions'
import { yearMonthFieldMap } from '../argParse/fieldStr'
import { OVERFLOW_REJECT, parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import { constrainDateISO, diffDates } from '../dateUtils/date'
import { compareDateTimes } from '../dateUtils/compare'
import { constrainDateISO } from '../dateUtils/constrain'
import { diffDates } from '../dateUtils/diff'
import { negateDuration } from '../dateUtils/durationFields'
import { processYearMonthFromFields, processYearMonthWithFields } from '../dateUtils/fromAndWith'
import { validateYearMonth } from '../dateUtils/isoFieldValidation'

@@ -14,2 +16,3 @@ import { formatCalendarID, formatDateISO, formatYearMonthISO } from '../dateUtils/isoFormat'

YearMonthCalendarFields,
attachStringTag,
mixinCalendarFields,

@@ -21,12 +24,8 @@ mixinISOFields,

import { refineBaseObj } from '../dateUtils/parseRefine'
import { DurationFields } from '../dateUtils/typesPrivate'
import { MONTH, YEAR, YearMonthUnitInt } from '../dateUtils/units'
import {
comparePlainYearMonths,
createYearMonth,
overrideYearMonthFields,
} from '../dateUtils/yearMonth'
import { createPlainFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { Calendar, createDefaultCalendar } from './calendar'
import { Duration } from './duration'
import { Duration, createDuration } from './duration'
import { PlainDate } from './plainDate'

@@ -42,3 +41,2 @@ import {

YearMonthDiffOptions,
YearMonthLikeFields,
YearMonthOverrides,

@@ -80,4 +78,3 @@ YearMonthUnit,

if (typeof arg === 'object') {
const refinedFields = refineFields(arg, yearMonthFieldMap) as YearMonthLikeFields
return extractCalendar(arg).yearMonthFromFields(refinedFields, options)
return processYearMonthFromFields(arg, options)
}

@@ -97,3 +94,3 @@

static compare(a: YearMonthArg, b: YearMonthArg): CompareResult {
return comparePlainYearMonths(
return compareDateTimes(
ensureObj(PlainYearMonth, a),

@@ -105,36 +102,23 @@ ensureObj(PlainYearMonth, b),

with(fields: YearMonthOverrides, options?: OverflowOptions): PlainYearMonth {
const refinedFields = refineOverrideFields(fields, yearMonthFieldMap)
return this.calendar.yearMonthFromFields(
overrideYearMonthFields(refinedFields, this),
options,
)
return processYearMonthWithFields(this, fields, options)
}
add(durationArg: DurationArg, options?: OverflowOptions): PlainYearMonth {
return addDuration(this, ensureObj(Duration, durationArg), options)
return translatePlainYearMonth(this, ensureObj(Duration, durationArg), options)
}
subtract(durationArg: DurationArg, options?: OverflowOptions): PlainYearMonth {
return addDuration(this, ensureObj(Duration, durationArg).negated(), options)
return translatePlainYearMonth(this, negateDuration(ensureObj(Duration, durationArg)), options)
}
until(other: YearMonthArg, options?: YearMonthDiffOptions): Duration {
return diffDates(
this.toPlainDate(day1),
ensureObj(PlainYearMonth, other).toPlainDate(day1),
parseDiffOptions<YearMonthUnit, YearMonthUnitInt>(options, YEAR, MONTH, MONTH, YEAR),
)
return diffPlainYearMonths(this, ensureObj(PlainYearMonth, other), false, options)
}
since(other: YearMonthArg, options?: YearMonthDiffOptions): Duration {
return diffDates(
this.toPlainDate(day1),
ensureObj(PlainYearMonth, other).toPlainDate(day1),
parseDiffOptions<YearMonthUnit, YearMonthUnitInt>(options, YEAR, MONTH, MONTH, YEAR),
true,
)
return diffPlainYearMonths(this, ensureObj(PlainYearMonth, other), true, options)
}
equals(other: YearMonthArg): boolean {
return comparePlainYearMonths(this, ensureObj(PlainYearMonth, other)) === 0
return !compareDateTimes(this, ensureObj(PlainYearMonth, other))
}

@@ -144,3 +128,3 @@

const fields = this.getISOFields()
const calendarID = fields.calendar.id
const calendarID = fields.calendar.toString() // see note in formatCalendarID
const calendarDisplay = parseCalendarDisplayOption(options)

@@ -167,2 +151,3 @@

export interface PlainYearMonth extends ToLocaleStringMethods {}
attachStringTag(PlainYearMonth, 'PlainYearMonth')
mixinISOFields(PlainYearMonth)

@@ -181,7 +166,14 @@ mixinCalendarFields(PlainYearMonth, yearMonthCalendarFields)

// utils
export function createYearMonth(isoFields: DateISOFields): PlainYearMonth {
return new PlainYearMonth(
isoFields.isoYear,
isoFields.isoMonth,
isoFields.calendar,
isoFields.isoDay,
)
}
function addDuration(
function translatePlainYearMonth(
yearMonth: PlainYearMonth,
duration: Duration,
duration: DurationFields,
options?: OverflowOptions,

@@ -197,1 +189,18 @@ ): PlainYearMonth {

}
function diffPlainYearMonths(
pym0: PlainYearMonth,
pym1: PlainYearMonth,
flip: boolean,
options: YearMonthDiffOptions | undefined,
): Duration {
return createDuration(
diffDates(
pym0.toPlainDate(day1),
pym1.toPlainDate(day1),
getCommonCalendar(pym0, pym1),
flip,
parseDiffOptions<YearMonthUnit, YearMonthUnitInt>(options, YEAR, MONTH, MONTH, YEAR),
),
)
}

@@ -7,17 +7,10 @@ import {

} from '../argParse/disambig'
import { OFFSET_REJECT } from '../argParse/offsetHandling'
import { isTimeZoneArgBag, parseTimeZoneFromBag } from '../argParse/timeZone'
import { AbstractObj, ensureObj } from '../dateUtils/abstract'
import { createDateTime } from '../dateUtils/dateTime'
import { epochNanoToISOFields, isoFieldsToEpochNano } from '../dateUtils/epoch'
import { formatOffsetISO } from '../dateUtils/isoFormat'
import { epochNanoToISOFields, isoFieldsToEpochSecs } from '../dateUtils/isoMath'
import { attachStringTag } from '../dateUtils/mixins'
import { checkInvalidOffset } from '../dateUtils/offset'
import { tryParseZonedDateTime } from '../dateUtils/parse'
import { refineZonedObj } from '../dateUtils/parseRefine'
import {
nanoInMicroBI,
nanoInMilliBI,
nanoInSecond,
nanoInSecondBI,
} from '../dateUtils/units'
import { computeEpochNanoViaOffset } from '../dateUtils/zonedDateTime'
import { TimeZoneImpl } from '../timeZoneImpl/timeZoneImpl'

@@ -28,3 +21,3 @@ import { queryTimeZoneImpl } from '../timeZoneImpl/timeZoneImplQuery'

import { Instant } from './instant'
import { PlainDateTime } from './plainDateTime'
import { PlainDateTime, createDateTime } from './plainDateTime'
import {

@@ -64,8 +57,8 @@ CalendarArg,

const refined = refineZonedObj(parsed) // TODO: we don't need the calendar
computeEpochNanoViaOffset(refined, OFFSET_REJECT) // throws error if offset/tz inconsistent
checkInvalidOffset(refined)
return refined.timeZone
} else if (parsed.Z) {
return new TimeZone('UTC')
} else if (parsed.offset !== undefined) {
return new TimeZone(formatOffsetISO(parsed.offset))
} else if (parsed.offsetNanoseconds !== undefined) {
return new TimeZone(formatOffsetISO(parsed.offsetNanoseconds))
}

@@ -77,3 +70,5 @@ }

get id(): string { return getImpl(this).id }
get id(): string {
return this.toString()
}

@@ -86,3 +81,3 @@ getOffsetStringFor(instantArg: InstantArg): string {

const instant = ensureObj(Instant, instantArg)
return getImpl(this).getOffset(instant.epochSeconds) * nanoInSecond
return getImpl(this).getOffset(instant.epochNanoseconds)
}

@@ -107,19 +102,19 @@

const isoFields = ensureObj(PlainDateTime, dateTimeArg).getISOFields()
const zoneSecs = isoFieldsToEpochSecs(isoFields)
const possibleOffsetSecs = getImpl(this).getPossibleOffsets(zoneSecs)
let offsetSecs: number
const zoneNano = isoFieldsToEpochNano(isoFields)
const possibleOffsetNanos = getImpl(this).getPossibleOffsets(zoneNano)
let offsetNano: number
if (possibleOffsetSecs.length === 1 || disambig === DISAMBIG_COMPATIBLE) {
offsetSecs = possibleOffsetSecs[0]
if (possibleOffsetNanos.length === 1 || disambig === DISAMBIG_COMPATIBLE) {
offsetNano = possibleOffsetNanos[0]
} else if (disambig === DISAMBIG_REJECT) {
throw new RangeError('Ambiguous offset')
} else {
offsetSecs = Math[
offsetNano = Math[
disambig === DISAMBIG_EARLIER
? 'max' // (results in an earlier epochNano, because offsetSecs is subtracted)
? 'max' // (results in an earlier epochNano, because offsetNano is subtracted)
: 'min' // DISAMBIG_LATER
](...(possibleOffsetSecs as [number, number]))
](...(possibleOffsetNanos as [number, number]))
}
return epochSecsToInstant(zoneSecs - offsetSecs, isoFields)
return new Instant(zoneNano - BigInt(offsetNano))
}

@@ -129,4 +124,4 @@

const isoFields = ensureObj(PlainDateTime, dateTimeArg).getISOFields()
const zoneSecs = isoFieldsToEpochSecs(isoFields)
let possibleOffsetSecs = getImpl(this).getPossibleOffsets(zoneSecs)
const zoneNano = isoFieldsToEpochNano(isoFields)
let possibleOffsetNanos = getImpl(this).getPossibleOffsets(zoneNano)

@@ -136,10 +131,10 @@ // A forward transition looses an hour.

if (
possibleOffsetSecs.length === 2 &&
possibleOffsetSecs[0] < possibleOffsetSecs[1]
possibleOffsetNanos.length === 2 &&
possibleOffsetNanos[0] < possibleOffsetNanos[1]
) {
possibleOffsetSecs = []
possibleOffsetNanos = []
}
return possibleOffsetSecs.map((offsetSecs) => (
epochSecsToInstant(zoneSecs - offsetSecs, isoFields)
return possibleOffsetNanos.map((offsetNano) => (
new Instant(zoneNano - BigInt(offsetNano))
))

@@ -150,5 +145,5 @@ }

const instant = ensureObj(Instant, instantArg)
const rawTransition = getImpl(this).getTransition(instant.epochSeconds, -1)
const rawTransition = getImpl(this).getTransition(instant.epochNanoseconds, -1)
if (rawTransition) {
return epochSecsToInstant(rawTransition[0])
return new Instant(rawTransition[0])
}

@@ -160,5 +155,5 @@ return null

const instant = ensureObj(Instant, instantArg)
const rawTransition = getImpl(this).getTransition(instant.epochSeconds, 1)
const rawTransition = getImpl(this).getTransition(instant.epochNanoseconds, 1)
if (rawTransition) {
return epochSecsToInstant(rawTransition[0])
return new Instant(rawTransition[0])
}

@@ -168,19 +163,7 @@ return null

toString(): string { return this.id }
toString(): string {
return getImpl(this).id
}
}
function epochSecsToInstant(
epochSecs: number,
otherISOFields?: { isoMillisecond: number, isoMicrosecond: number, isoNanosecond: number },
): Instant {
return new Instant(
BigInt(epochSecs) * nanoInSecondBI + (
otherISOFields
// TODO: use a common util for this?
? BigInt(otherISOFields.isoMillisecond) * nanoInMilliBI +
BigInt(otherISOFields.isoMicrosecond) * nanoInMicroBI +
BigInt(otherISOFields.isoNanosecond)
: 0n
),
)
}
attachStringTag(TimeZone, 'TimeZone')

@@ -11,5 +11,9 @@ import { CalendarArgBag, CalendarArgSimple } from '../argParse/calendar'

import { DateUnitProper, TimeUnitProper, YearMonthUnitProper } from '../argParse/unitStr'
import { DateISOEssentials } from '../dateUtils/date'
import { DurationFields } from '../dateUtils/duration'
import { TimeFields, TimeISOEssentials } from '../dateUtils/time'
import {
DurationFields,
ISODateFields,
ISOTimeFields,
LocalTimeFields,
} from '../dateUtils/typesPrivate'
import { Calendar } from './calendar'
import { Duration } from './duration'

@@ -55,3 +59,3 @@ import { Instant } from './instant'

export type RoundingMode = keyof RoundingModeMap
export type RoundingOptions<UnitType extends Unit = Unit> = {
export type RoundingOptions<UnitType extends DayTimeUnit = DayTimeUnit> = {
smallestUnit: UnitType // required

@@ -61,4 +65,4 @@ roundingMode?: RoundingMode

}
export type DateTimeRoundingOptions = RoundingOptions // uuhhh
export type TimeRoundingOptions = RoundingOptions<TimeUnit>
export type DateTimeRoundingOptions = RoundingOptions<DayTimeUnit>
// similar to diffing

@@ -107,6 +111,6 @@ export type DurationRoundingOptions = DiffOptions & { relativeTo?: ZonedDateTimeArg | DateTimeArg }

// iso-fields
export type DateISOFields = DateISOEssentials & { calendar: CalendarProtocol }
export type TimeISOFields = TimeISOEssentials & { calendar: CalendarProtocol }
export type DateTimeISOFields = DateISOFields & TimeISOEssentials
// iso-fields (TODO: change back to CalendarProtocol!!!)
export type DateISOFields = ISODateFields & { calendar: Calendar }
export type TimeISOFields = ISOTimeFields & { calendar: Calendar }
export type DateTimeISOFields = DateISOFields & ISOTimeFields
export type ZonedDateTimeISOFields = DateTimeISOFields & { timeZone: TimeZone, offset: string }

@@ -123,3 +127,3 @@

export type DateLikeFields = YearMonthLikeFields & { day: number }
export type DateTimeLikeFields = DateLikeFields & Partial<TimeFields>
export type DateTimeLikeFields = DateLikeFields & Partial<LocalTimeFields>
export type ZonedDateTimeLikeFields = DateTimeLikeFields & { offset?: string }

@@ -135,3 +139,3 @@

export type DateLike = YearMonthLike & { day: number }
export type TimeLike = Partial<TimeFields>
export type TimeLike = Partial<LocalTimeFields>
export type DateTimeLike = DateLike & TimeLike

@@ -138,0 +142,0 @@ export type ZonedDateTimeLike = DateTimeLike & { timeZone: TimeZoneArgSimple, offset?: string }

@@ -1,22 +0,38 @@

import { extractCalendar, getStrangerCalendar } from '../argParse/calendar'
import { getCommonCalendar, getStrangerCalendar } from '../argParse/calendar'
import { parseCalendarDisplayOption } from '../argParse/calendarDisplay'
import { parseDiffOptions } from '../argParse/diffOptions'
import { parseDisambigOption } from '../argParse/disambig'
import { zonedDateTimeFieldMap } from '../argParse/fieldStr'
import { parseTimeToStringOptions } from '../argParse/isoFormatOptions'
import { OFFSET_DISPLAY_AUTO, parseOffsetDisplayOption } from '../argParse/offsetDisplay'
import { OFFSET_PREFER, OFFSET_REJECT, parseOffsetHandlingOption } from '../argParse/offsetHandling'
import {
OFFSET_PREFER,
OFFSET_REJECT,
OffsetHandlingInt,
parseOffsetHandlingOption,
} from '../argParse/offsetHandling'
import { parseOverflowOption } from '../argParse/overflowHandling'
import { refineFields, refineOverrideFields } from '../argParse/refine'
import { extractTimeZone } from '../argParse/timeZone'
import { RoundingConfig, parseRoundingOptions } from '../argParse/roundingOptions'
import { parseTimeZoneDisplayOption } from '../argParse/timeZoneDisplay'
import { timeUnitNames } from '../argParse/unitStr'
import { AbstractISOObj, ensureObj } from '../dateUtils/abstract'
import { createDate } from '../dateUtils/date'
import { createDateTime } from '../dateUtils/dateTime'
import { compareEpochObjs, zonedDateTimesEqual } from '../dateUtils/compare'
import { zeroISOTimeFields } from '../dateUtils/dayAndTime'
import { diffDateTimes } from '../dateUtils/diff'
import { negateDuration } from '../dateUtils/durationFields'
import { epochNanoToISOFields } from '../dateUtils/epoch'
import {
processZonedDateTimeFromFields,
processZonedDateTimeWithFields,
} from '../dateUtils/fromAndWith'
import { validateDateTime } from '../dateUtils/isoFieldValidation'
import { formatCalendarID, formatDateTimeISO, formatTimeZoneID } from '../dateUtils/isoFormat'
import { epochNanoToISOFields } from '../dateUtils/isoMath'
import {
formatCalendarID,
formatDateTimeISO,
formatOffsetISO,
formatTimeZoneID,
} from '../dateUtils/isoFormat'
import {
ComputedEpochFields,
DateCalendarFields,
attachStringTag,
dateCalendarFields,

@@ -27,30 +43,33 @@ mixinCalendarFields,

} from '../dateUtils/mixins'
import {
OffsetComputableFields,
computeNanoInDay,
computeZonedDateTimeEpochNano,
} from '../dateUtils/offset'
import { parseZonedDateTime } from '../dateUtils/parse'
import { refineZonedObj } from '../dateUtils/parseRefine'
import { TimeFields, createTime } from '../dateUtils/time'
import { nanoInHour } from '../dateUtils/units'
import { createYearMonth } from '../dateUtils/yearMonth'
import { roundZonedDateTimeFields } from '../dateUtils/rounding'
import { translateZonedDateTimeFields } from '../dateUtils/translate'
import { DurationFields, ISODateTimeFields, LocalTimeFields } from '../dateUtils/typesPrivate'
import {
addToZonedDateTime,
computeNanoInDay,
createZonedDateTime,
diffZonedDateTimes,
overrideZonedDateTimeFields,
roundZonedDateTime,
roundZonedDateTimeWithOptions,
zeroTimeISOFields,
zonedDateTimeFieldsToISO,
} from '../dateUtils/zonedDateTime'
DAY,
DayTimeUnitInt,
HOUR,
NANOSECOND,
UnitInt,
YEAR,
nanoInHour,
} from '../dateUtils/units'
import { createZonedFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { compareValues } from '../utils/math'
import { roundToMinute } from '../utils/math'
import { createWeakMap } from '../utils/obj'
import { Calendar, createDefaultCalendar } from './calendar'
import { Duration } from './duration'
import { Duration, createDuration } from './duration'
import { Instant } from './instant'
import { PlainDate } from './plainDate'
import { PlainDateTime } from './plainDateTime'
import { PlainDate, createDate } from './plainDate'
import { PlainDateTime, createDateTime } from './plainDateTime'
import { PlainMonthDay } from './plainMonthDay'
import { PlainTime } from './plainTime'
import { PlainYearMonth } from './plainYearMonth'
import { PlainTime, createTime } from './plainTime'
import { PlainYearMonth, createYearMonth } from './plainYearMonth'
import { TimeZone } from './timeZone'

@@ -62,2 +81,3 @@ import {

DateTimeRoundingOptions,
DayTimeUnit,
DiffOptions,

@@ -68,5 +88,5 @@ DurationArg,

TimeZoneArg,
Unit,
ZonedDateTimeArg,
ZonedDateTimeISOFields,
ZonedDateTimeLikeFields,
ZonedDateTimeOptions,

@@ -93,6 +113,4 @@ ZonedDateTimeOverrides,

const calendar = ensureObj(Calendar, calendarArg)
const instant = new Instant(epochNanoseconds) // will do validation
const offsetNanoseconds = timeZone.getOffsetNanosecondsFor(instant)
const isoFields = epochNanoToISOFields(epochNanoseconds + BigInt(offsetNanoseconds))
const [isoFields, offsetNano] = buildZonedDateTimeISOFields(epochNanoseconds, timeZone)
validateDateTime(isoFields, calendar.id)

@@ -104,3 +122,5 @@

timeZone,
offset: timeZone.getOffsetStringFor(instant),
// NOTE: must support TimeZone protocols that don't implement getOffsetStringFor
// TODO: more DRY with getOffsetStringFor
offset: formatOffsetISO(offsetNano),
})

@@ -110,3 +130,3 @@

epochNanoseconds,
offsetNanoseconds,
offsetNanoseconds: offsetNano,
})

@@ -119,19 +139,16 @@ }

return createZonedDateTime(
arg instanceof ZonedDateTime
? { // optimization
...arg.getISOFields(),
offset: arg.offsetNanoseconds,
}
: typeof arg === 'object'
? zonedDateTimeFieldsToISO(
refineFields(arg, zonedDateTimeFieldMap) as ZonedDateTimeLikeFields,
options,
overflowHandling,
extractCalendar(arg),
extractTimeZone(arg),
)
: refineZonedObj(parseZonedDateTime(String(arg))),
if (arg instanceof ZonedDateTime) {
return new ZonedDateTime(arg.epochNanoseconds, arg.timeZone, arg.calendar)
}
const isObject = typeof arg === 'object'
const fields = isObject
? processZonedDateTimeFromFields(arg, overflowHandling, options)
: refineZonedObj(parseZonedDateTime(String(arg)))
return createZonedDateTimeFromFields(
fields,
!isObject, // fuzzyMatching (if string)
offsetHandling,
options,
offsetHandling,
)

@@ -141,5 +158,5 @@ }

static compare(a: ZonedDateTimeArg, b: ZonedDateTimeArg): CompareResult {
return compareValues(
ensureObj(ZonedDateTime, a).epochNanoseconds,
ensureObj(ZonedDateTime, b).epochNanoseconds,
return compareEpochObjs(
ensureObj(ZonedDateTime, a),
ensureObj(ZonedDateTime, b),
)

@@ -154,19 +171,8 @@ }

with(fields: ZonedDateTimeOverrides, options?: ZonedDateTimeOptions): ZonedDateTime {
const refinedFields = refineOverrideFields(fields, zonedDateTimeFieldMap)
const mergedFields = overrideZonedDateTimeFields(refinedFields, this)
parseDisambigOption(options) // for validation
const overflowHandling = parseOverflowOption(options) // for validation (?)
const offsetHandling = parseOffsetHandlingOption(options, OFFSET_PREFER)
const overflowHandling = parseOverflowOption(options)
parseDisambigOption(options) // for validation
const refined = processZonedDateTimeWithFields(this, fields, overflowHandling, options)
return createZonedDateTime(
zonedDateTimeFieldsToISO(
mergedFields,
options,
overflowHandling,
this.calendar,
this.timeZone,
),
options,
offsetHandling,
)
return createZonedDateTimeFromFields(refined, false, offsetHandling, options)
}

@@ -188,5 +194,9 @@

withPlainTime(timeArg?: TimeArg): ZonedDateTime {
return this.toPlainDate().toZonedDateTime({
plainTime: timeArg,
timeZone: this.timeZone,
return createZonedDateTimeFromFields({
...this.getISOFields(),
...(
timeArg === undefined
? zeroISOTimeFields
: ensureObj(PlainTime, timeArg).getISOFields()
),
})

@@ -212,39 +222,38 @@ }

add(durationArg: DurationArg, options?: OverflowOptions): ZonedDateTime {
return addToZonedDateTime(this, ensureObj(Duration, durationArg), options)
return translateZonedDateTime(this, ensureObj(Duration, durationArg), options)
}
subtract(durationArg: DurationArg, options?: OverflowOptions): ZonedDateTime {
return addToZonedDateTime(this, ensureObj(Duration, durationArg).negated(), options)
return translateZonedDateTime(this, negateDuration(ensureObj(Duration, durationArg)), options)
}
until(other: ZonedDateTimeArg, options?: DiffOptions): Duration {
return diffZonedDateTimes(this, ensureObj(ZonedDateTime, other), options)
return diffZonedDateTimes(this, ensureObj(ZonedDateTime, other), false, options)
}
since(other: ZonedDateTimeArg, options?: DiffOptions): Duration {
return diffZonedDateTimes(this, ensureObj(ZonedDateTime, other), options, true)
return diffZonedDateTimes(this, ensureObj(ZonedDateTime, other), true, options)
}
round(options?: DateTimeRoundingOptions): ZonedDateTime {
return roundZonedDateTimeWithOptions(this, options)
round(options?: DateTimeRoundingOptions | DayTimeUnit): ZonedDateTime {
const roundingConfig = parseRoundingOptions<DayTimeUnit, DayTimeUnitInt>(
options,
undefined, // no default. will error-out if unset
NANOSECOND, // minUnit
DAY, // maxUnit
)
return roundZonedDateTime(this, roundingConfig)
}
equals(other: ZonedDateTimeArg): boolean {
const otherZdt = ensureObj(ZonedDateTime, other)
return this.epochNanoseconds === otherZdt.epochNanoseconds &&
this.calendar.id === otherZdt.calendar.id &&
this.timeZone.id === otherZdt.timeZone.id
return zonedDateTimesEqual(this, ensureObj(ZonedDateTime, other))
}
startOfDay(): ZonedDateTime {
return createZonedDateTime( // TODO: more DRY with computeNanoInDay
{
...this.getISOFields(),
...zeroTimeISOFields,
offset: undefined,
},
undefined, // options
OFFSET_REJECT, // doesn't matter b/c no explicit offset given
)
return createZonedDateTimeFromFields({
...this.getISOFields(),
...zeroISOTimeFields,
offsetNanoseconds: this.offsetNanoseconds,
}, false, OFFSET_PREFER)
}

@@ -254,3 +263,3 @@

get hoursInDay(): number {
return computeNanoInDay(this) / nanoInHour
return computeNanoInDay(this.getISOFields()) / nanoInHour
}

@@ -263,12 +272,11 @@

const calendarDisplay = parseCalendarDisplayOption(options)
const isoFields = roundZonedDateTime(
this,
formatConfig.roundingIncrement,
formatConfig.roundingMode,
).getISOFields()
const roundedZdt = roundZonedDateTime(this, formatConfig)
return formatDateTimeISO(isoFields, formatConfig) +
(offsetDisplay === OFFSET_DISPLAY_AUTO ? isoFields.offset : '') + // already formatted
formatTimeZoneID(isoFields.timeZone.id, timeZoneDisplay) +
formatCalendarID(isoFields.calendar.id, calendarDisplay)
return formatDateTimeISO(roundedZdt.getISOFields(), formatConfig) +
(offsetDisplay === OFFSET_DISPLAY_AUTO
? formatOffsetISO(roundToMinute(roundedZdt.offsetNanoseconds))
: ''
) +
formatTimeZoneID(this.timeZone.toString(), timeZoneDisplay) +
formatCalendarID(this.calendar.toString(), calendarDisplay)
}

@@ -286,5 +294,6 @@

export interface ZonedDateTime extends DateCalendarFields { calendar: Calendar }
export interface ZonedDateTime extends TimeFields {}
export interface ZonedDateTime extends LocalTimeFields {}
export interface ZonedDateTime extends ComputedEpochFields {}
export interface ZonedDateTime extends ToLocaleStringMethods {}
attachStringTag(ZonedDateTime, 'ZonedDateTime')
mixinISOFields(ZonedDateTime, timeUnitNames)

@@ -304,1 +313,70 @@ mixinCalendarFields(ZonedDateTime, dateCalendarFields)

}, {}))
export function createZonedDateTimeFromFields(
fields: OffsetComputableFields,
fuzzyMatching?: boolean,
offsetHandling?: OffsetHandlingInt,
disambigOptions?: ZonedDateTimeOptions, // TODO: more specific type
): ZonedDateTime {
const epochNano = computeZonedDateTimeEpochNano(
fields,
fuzzyMatching,
offsetHandling,
disambigOptions,
)
return new ZonedDateTime(epochNano, fields.timeZone, fields.calendar)
}
export function buildZonedDateTimeISOFields(
epochNano: bigint,
timeZone: TimeZone,
): [ISODateTimeFields, number] {
const instant = new Instant(epochNano) // will do validation
const offsetNano = timeZone.getOffsetNanosecondsFor(instant)
const isoFields = epochNanoToISOFields(epochNano + BigInt(offsetNano))
return [isoFields, offsetNano]
}
function translateZonedDateTime(
zdt: ZonedDateTime,
dur: DurationFields,
options: OverflowOptions | undefined,
): ZonedDateTime {
const isoFields = zdt.getISOFields()
const epochNano = translateZonedDateTimeFields(isoFields, dur, options)
return new ZonedDateTime(epochNano, isoFields.timeZone, isoFields.calendar)
}
function roundZonedDateTime(
zdt: ZonedDateTime,
roundingConfig: RoundingConfig<DayTimeUnitInt>,
): ZonedDateTime {
const isoFields = zdt.getISOFields()
const epochNano = roundZonedDateTimeFields(isoFields, zdt.offsetNanoseconds, roundingConfig)
return new ZonedDateTime(epochNano, isoFields.timeZone, isoFields.calendar)
}
// TODO: make common util with PlainDateTime, because leverages same diffDateTimes?
function diffZonedDateTimes(
dt0: ZonedDateTime,
dt1: ZonedDateTime,
flip: boolean,
options: DiffOptions | undefined,
): Duration {
const diffConfig = parseDiffOptions<Unit, UnitInt>(
options,
HOUR, // largestUnitDefault
NANOSECOND, // smallestUnitDefault
NANOSECOND, // minUnit
YEAR, // maxUnit
)
const { largestUnit } = diffConfig
if (largestUnit >= DAY && dt0.timeZone.id !== dt1.timeZone.id) {
throw new Error('Must be same timeZone')
}
return createDuration(
diffDateTimes(dt0, dt1, getCommonCalendar(dt0, dt1), flip, diffConfig),
)
}

@@ -6,3 +6,3 @@ import { RawTransition, TimeZoneImpl } from './timeZoneImpl'

id: string,
private offsetSecs: number,
private offsetNano: number,
) {

@@ -13,7 +13,7 @@ super(id)

getPossibleOffsets(): number[] {
return [this.offsetSecs]
return [this.offsetNano]
}
getOffset(): number {
return this.offsetSecs
return this.offsetNano
}

@@ -20,0 +20,0 @@

@@ -0,4 +1,4 @@

import { epochNanoToISOYear, isoToEpochMilli, isoYearToEpochSeconds } from '../dateUtils/epoch'
import { hashIntlFormatParts, normalizeShortEra } from '../dateUtils/intlFormat'
import { epochSecondsToISOYear, isoToEpochMilli, isoYearToEpochSeconds } from '../dateUtils/isoMath'
import { milliInSecond, secondsInDay } from '../dateUtils/units'
import { milliInSecond, nanoInSecond, nanoInSecondBI, secondsInDay } from '../dateUtils/units'
import { OrigDateTimeFormat } from '../native/intlUtils'

@@ -9,6 +9,4 @@ import { compareValues } from '../utils/math'

// Europe/Amsterdam and America/New_York have long gaps
// see timezone.spec.ts
// TODO: this is probably very expensive for timezones WITHOUT transitions
const MAX_YEAR_TRAVEL = 100
const DST_EARLIEST_YEAR = 1847 // year with the first DST transitions
const DST_PERSIST_YEAR = new Date().getUTCFullYear() + 10 // DST won't change on or after this

@@ -21,2 +19,6 @@ const ISLAND_SEARCH_DAYS = [

// TODO: general question: why not use minutes internally instead of seconds?
// No... Temporal.ZonedDateTime.from({ year: 1971, month: 1, day: 1, timeZone: 'Africa/Monrovia' })
// .offset => '-00:44:30' // seconds
export class IntlTimeZoneImpl extends TimeZoneImpl {

@@ -47,26 +49,27 @@ private format: Intl.DateTimeFormat

// `zoneSecs` is like epochSecs, but from zone's pseudo-epoch
getPossibleOffsets(zoneSecs: number): number[] {
// `zoneNano` is like epochNano, but from zone's pseudo-epoch
getPossibleOffsets(zoneNano: bigint): number[] {
let lastOffsetNano: number | undefined
const transitions = [
this.getTransition(zoneSecs, -1),
this.getTransition(zoneSecs - 1, 1), // subtract 1 b/c getTransition is always exclusive
this.getTransition(zoneNano, -1),
this.getTransition(zoneNano - 1n, 1), // subtract 1 b/c getTransition is always exclusive
].filter(Boolean) as RawTransition[]
let lastOffsetSecs: number | undefined
// loop transitions from past to future
for (const transition of transitions) {
const [transitionEpochSecs, offsetSecsBefore, offsetSecsAfter] = transition
// FYI, a transition's switchover to offsetSecsAfter happens
// *inclusively* as transitionEpochSecs
const [transitionEpochNano, offsetNanoBefore, offsetNanoAfter] = transition
// FYI, a transition's switchover to offsetNanoAfter happens
// *inclusively* as transitionEpochNano
// two possibilities (no guarantee of chronology)
const epochSecsA = zoneSecs - offsetSecsBefore
const epochSecsB = zoneSecs - offsetSecsAfter
const epochNanoA = zoneNano - BigInt(offsetNanoBefore)
const epochNanoB = zoneNano - BigInt(offsetNanoAfter)
// is the transition after both possibilities?
if (transitionEpochSecs > epochSecsA && transitionEpochSecs > epochSecsB) {
return [offsetSecsBefore]
if (transitionEpochNano > epochNanoA && transitionEpochNano > epochNanoB) {
return [offsetNanoBefore]
// is the transition before both possibilities?
} else if (transitionEpochSecs <= epochSecsA && transitionEpochSecs <= epochSecsB) {
} else if (transitionEpochNano <= epochNanoA && transitionEpochNano <= epochNanoB) {
// keep looping...

@@ -76,25 +79,29 @@

} else {
return [offsetSecsBefore, offsetSecsAfter]
return [offsetNanoBefore, offsetNanoAfter]
}
lastOffsetSecs = offsetSecsAfter
lastOffsetNano = offsetNanoAfter
}
// only found transitions before zoneSecs
if (lastOffsetSecs !== undefined) {
return [lastOffsetSecs]
if (lastOffsetNano !== undefined) {
return [lastOffsetNano]
}
// found no transitions?
return [this.getYearEndOffset(epochSecondsToISOYear(zoneSecs))]
return [
this.getYearEndOffsetSec(epochNanoToISOYear(zoneNano)) * nanoInSecond,
]
}
/*
NOTE: if Intl.DateTimeFormat's timeZoneName:'shortOffset' option were available,
we could parse that.
*/
getOffset(epochSecs: number): number {
const map = hashIntlFormatParts(this.format, epochSecs * milliInSecond)
getOffset(epochNano: bigint): number {
return this.getOffsetForEpochSecs(Number(epochNano / nanoInSecondBI)) * nanoInSecond
}
private getOffsetForEpochSecs(epochSec: number): number {
// NOTE: if Intl.DateTimeFormat's timeZoneName:'shortOffset' option were available,
// we could parse that.
const map = hashIntlFormatParts(this.format, epochSec * milliInSecond)
let year = parseInt(map.year)
if (normalizeShortEra(map.era) === 'bce') {

@@ -114,22 +121,47 @@ year = -(year - 1)

return zoneSecs - epochSecs
return zoneSecs - epochSec
}
/*
Always exclusive. Will never return a transition that starts exactly on epochSecs
Always exclusive. Will never return a transition that starts exactly on epochNano
*/
getTransition(epochSecs: number, direction: -1 | 1): RawTransition | undefined {
const startYear = epochSecondsToISOYear(epochSecs)
getTransition(epochNano: bigint, direction: -1 | 1): RawTransition | undefined {
let year = epochNanoToISOYear(epochNano)
for (let yearTravel = 0; yearTravel < MAX_YEAR_TRAVEL; yearTravel++) {
const year = startYear + yearTravel * direction
const transitions = this.getTransitionsInYear(year)
const len = transitions.length
const startIndex = direction < 0 ? len - 1 : 0
if (year > DST_PERSIST_YEAR) {
// look ahead or behine ONE year
const res = this.getTransitionFrom(year, year + direction, direction, epochNano)
if (res || direction > 0) {
return res
}
// fast-backwards in-bounds
year = DST_PERSIST_YEAR
}
for (let travel = 0; travel < len; travel++) {
const transition = transitions[startIndex + travel * direction]
return this.getTransitionFrom(
Math.max(year, DST_EARLIEST_YEAR),
direction < 0
? DST_EARLIEST_YEAR - 1 // inclusive -> exclusive
: DST_PERSIST_YEAR,
direction,
epochNano,
)
}
// does the current transition overtake epochSecs in the direction of travel?
if (compareValues(transition[0], epochSecs) === direction) {
getTransitionFrom(
year: number,
endYear: number, // exclusive
direction: -1 | 1,
epochNano: bigint,
): RawTransition | undefined {
for (; year !== endYear; year += direction) {
let transitions = this.getTransitionsInYear(year)
if (direction < 0) {
transitions = transitions.slice().reverse()
}
for (const transition of transitions) {
// does the current transition overtake epochNano in the direction of travel?
if (compareValues(transition[0], epochNano) === direction) {
return transition

@@ -141,6 +173,6 @@ }

private getYearEndOffset(utcYear: number): number {
private getYearEndOffsetSec(utcYear: number): number {
const { yearEndOffsets } = this
return yearEndOffsets[utcYear] ||
(yearEndOffsets[utcYear] = this.getOffset(
(yearEndOffsets[utcYear] = this.getOffsetForEpochSecs(
isoYearToEpochSeconds(utcYear + 1) - 1,

@@ -157,19 +189,19 @@ ))

private computeTransitionsInYear(utcYear: number): RawTransition[] {
const startOffsetSecs = this.getYearEndOffset(utcYear - 1) // right before start of year
const endOffsetSecs = this.getYearEndOffset(utcYear) // at end of year
const startOffsetSec = this.getYearEndOffsetSec(utcYear - 1) // right before start of year
const endOffsetSec = this.getYearEndOffsetSec(utcYear) // at end of year
// FYI, a transition could be in the first second of the year, thus the exclusiveness
// TODO: make a isoYearEndEpochSeconds util? use in getYearEndOffset?
const startEpochSecs = isoYearToEpochSeconds(utcYear) - 1
const endEpochSecs = isoYearToEpochSeconds(utcYear + 1) - 1
// TODO: make a isoYearEndEpochSeconds util? use in getYearEndOffsetSec?
const startEpochSec = isoYearToEpochSeconds(utcYear) - 1
const endEpochSec = isoYearToEpochSeconds(utcYear + 1) - 1
if (startOffsetSecs !== endOffsetSecs) {
return [this.searchTransition(startEpochSecs, endEpochSecs, startOffsetSecs, endOffsetSecs)]
if (startOffsetSec !== endOffsetSec) {
return [this.searchTransition(startEpochSec, endEpochSec, startOffsetSec, endOffsetSec)]
}
const island = this.searchIsland(startOffsetSecs, startEpochSecs)
const island = this.searchIsland(startOffsetSec, startEpochSec)
if (island !== undefined) {
return [
this.searchTransition(startEpochSecs, island[0], startOffsetSecs, island[1]),
this.searchTransition(island[0], endEpochSecs, island[1], endOffsetSecs),
this.searchTransition(startEpochSec, island[0], startOffsetSec, island[1]),
this.searchTransition(island[0], endEpochSec, island[1], endOffsetSec),
]

@@ -184,24 +216,24 @@ }

private searchTransition(
startEpochSecs: number,
endEpochSecs: number,
startOffsetSecs: number,
endOffsetSecs: number,
startEpochSec: number,
endEpochSec: number,
startOffsetSec: number,
endOffsetSec: number,
): RawTransition {
// keep doing binary search until start/end are 1 second apart
while (endEpochSecs - startEpochSecs > 1) {
const middleEpochSecs = Math.floor(startEpochSecs + (endEpochSecs - startEpochSecs) / 2)
const middleOffsetSecs = this.getOffset(middleEpochSecs)
while (endEpochSec - startEpochSec > 1) {
const middleEpochSecs = Math.floor(startEpochSec + (endEpochSec - startEpochSec) / 2)
const middleOffsetSecs = this.getOffsetForEpochSecs(middleEpochSecs)
if (middleOffsetSecs === startOffsetSecs) {
if (middleOffsetSecs === startOffsetSec) {
// middle is same as start. move start to the middle
startEpochSecs = middleEpochSecs
startEpochSec = middleEpochSecs
} else {
// middle is same as end. move end to the middle
endEpochSecs = middleEpochSecs
endEpochSec = middleEpochSecs
}
}
return [
endEpochSecs,
startOffsetSecs, // caller could have computed this
endOffsetSecs, // same
BigInt(endEpochSec) * nanoInSecondBI,
startOffsetSec * nanoInSecond,
endOffsetSec * nanoInSecond,
]

@@ -213,10 +245,10 @@ }

private searchIsland(
outerOffsetSecs: number,
startEpochSecs: number,
): [number, number] | undefined { // [epochSecs, offsetSecs]
outerOffsetSec: number,
startEpochSec: number,
): [number, number] | undefined { // [epochSec, offsetSec]
for (const days of ISLAND_SEARCH_DAYS) {
const epochSecs = startEpochSecs + days * secondsInDay
const offsetSecs = this.getOffset(epochSecs)
if (offsetSecs !== outerOffsetSecs) {
return [epochSecs, offsetSecs]
const epochSec = startEpochSec + days * secondsInDay
const offsetSec = this.getOffsetForEpochSecs(epochSec)
if (offsetSec !== outerOffsetSec) {
return [epochSec, offsetSec]
}

@@ -223,0 +255,0 @@ }

@@ -8,7 +8,9 @@ import { RawTransition } from './timeZoneImpl'

2011: [
[1301752800, -36000, -39600], // start DST
[1316872800, -39600, -36000], // end DST
[1325239200, -36000, 50400], // change of time zone
// TODO: this was much nicer when specified in seconds
// TODO: have RawTransitions be seconds again?
[1301752800000000000n, -36000000000000, -39600000000000], // start DST
[1316872800000000000n, -39600000000000, -36000000000000], // end DST
[1325239200000000000n, -36000000000000, 50400000000000], // change of time zone
],
},
}
// [epochSecs, offsetSecsBefore, offsetSecsAfter]
export type RawTransition = [number, number, number]
export type RawTransition = [
bigint, // epochNano
number, // offsetNanoBefore
number, // offsetNanoAfter
]

@@ -8,5 +11,5 @@ export abstract class TimeZoneImpl {

abstract getPossibleOffsets(zoneSecs: number): number[]
abstract getOffset(epochSecs: number): number
abstract getTransition(epochSecs: number, direction: -1 | 1): RawTransition | undefined
abstract getPossibleOffsets(zoneNano: bigint): number[] // offsetNanos
abstract getOffset(epochNano: bigint): number // offsetNano
abstract getTransition(epochNano: bigint, direction: -1 | 1): RawTransition | undefined
}
import { formatOffsetISO } from '../dateUtils/isoFormat'
import { tryParseOffsetNano } from '../dateUtils/parse'
import { nanoInDay, nanoInSecond } from '../dateUtils/units'
import { nanoInDay } from '../dateUtils/units'
import { FixedTimeZoneImpl } from './fixedTimeZoneImpl'

@@ -29,3 +29,3 @@ import { IntlTimeZoneImpl } from './intlTimeZoneImpl'

formatOffsetISO(offsetNano),
Math.trunc(offsetNano / nanoInSecond), // convert to seconds
offsetNano,
)

@@ -32,0 +32,0 @@ }

@@ -0,1 +1,2 @@

import { nanoInMinute } from '../dateUtils/units'
import { CompareResult } from '../public/types'

@@ -31,2 +32,12 @@

export function roundToMinute(nano: number): number {
return roundToIncrement(nano, nanoInMinute, halfExpand)
}
// like round, but does rounds negatives "down" (closer to -0.9)
// use elsewhere?
function halfExpand(n: number) {
return Math.round(Math.abs(n)) * numSign(n)
}
export function roundToIncrementBI(

@@ -33,0 +44,0 @@ num: bigint,

@@ -43,2 +43,16 @@ export type ValueOf<T> = T[keyof T]

export function mapHashByKeys<PropInputType, PropOutputType>(
input: { [prop: string]: PropInputType },
keys: string[],
func: (inputProp: PropInputType) => PropOutputType,
): { [prop: string]: PropOutputType } {
const output = {} as { [prop: string]: PropOutputType }
for (const key of keys) {
output[key] = func(input[key])
}
return output
}
export function excludeUndefined(obj: GenericHash): GenericHash {

@@ -64,5 +78,1 @@ const res: GenericHash = {}

}
export function throwNew(ErrorClass: { new(message: string): Error }, message: string): any {
throw new ErrorClass(message)
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc