import e from"../_lib/toInteger/index.js";import t from"../_lib/requiredArgs/index.js";var r={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},n=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,i=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,a=/^([+-])(\d{2})(?::?(\d{2}))?$/;function u(r,n){t(1,arguments);var i=n||{},a=null==i.additionalDigits?2:e(i.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof r&&"[object String]"!==Object.prototype.toString.call(r))return new Date(NaN);var u,s=l(r);if(s.date){var m=o(s.date,a);u=d(m.restDateString,m.year)}if(isNaN(u)||!u)return new Date(NaN);var g,D=u.getTime(),N=0;if(s.time&&(N=f(s.time),isNaN(N)||null===N))return new Date(NaN);if(!s.timezone){var v=new Date(D+N),p=new Date(0);return p.setFullYear(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),p.setHours(v.getUTCHours(),v.getUTCMinutes(),v.getUTCSeconds(),v.getUTCMilliseconds()),p}return g=c(s.timezone),isNaN(g)?new Date(NaN):new Date(D+N+g)}function l(e){var t,n={},i=e.split(r.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?(n.date=null,t=i[0]):(n.date=i[0],t=i[1],r.timeZoneDelimiter.test(n.date)&&(n.date=e.split(r.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var a=r.timezone.exec(t);a?(n.time=t.replace(a[1],""),n.timezone=a[1]):n.time=t}return n}function o(e,t){var r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),n=e.match(r);if(!n)return{year:null};var i=n[1]&&parseInt(n[1]),a=n[2]&&parseInt(n[2]);return{year:null==a?i:100*a,restDateString:e.slice((n[1]||n[2]).length)}}function d(e,t){if(null===t)return null;var r=e.match(n);if(!r)return null;var i=!!r[4],a=s(r[1]),u=s(r[2])-1,l=s(r[3]),o=s(r[4]),d=s(r[5])-1;if(i)return function(e,t,r){return t>=1&&t<=53&&r>=0&&r<=6}(0,o,d)?function(e,t,r){var n=new Date(0);n.setUTCFullYear(e,0,4);var i=n.getUTCDay()||7,a=7*(t-1)+r+1-i;return n.setUTCDate(n.getUTCDate()+a),n}(t,o,d):new Date(NaN);var f=new Date(0);return function(e,t,r){return t>=0&&t<=11&&r>=1&&r<=(g[t]||(D(e)?29:28))}(t,u,l)&&function(e,t){return t>=1&&t<=(D(e)?366:365)}(t,a)?(f.setUTCFullYear(t,u,Math.max(a,l)),f):new Date(NaN)}function s(e){return e?parseInt(e):1}function f(e){var t=e.match(i);if(!t)return null;var r=m(t[1]),n=m(t[2]),a=m(t[3]);return function(e,t,r){if(24===e)return 0===t&&0===r;return r>=0&&r<60&&t>=0&&t<60&&e>=0&&e<25}(r,n,a)?36e5*r+6e4*n+1e3*a:NaN}function m(e){return e&&parseFloat(e.replace(",","."))||0}function c(e){if("Z"===e)return 0;var t=e.match(a);if(!t)return 0;var r="+"===t[1]?-1:1,n=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,i)?r*(36e5*n+6e4*i):NaN}var g=[31,null,31,30,31,30,31,31,30,31,30,31];function D(e){return e%400==0||e%4==0&&e%100}export default u;
//# sourceMappingURL=index.js.map
