import{b as e,v as t,x as n,y as r}from"./format-cICbIpsk.js";function i(e,n){let i=()=>r(n?.in,NaN),a=n?.additionalDigits??2,o=l(e),s;if(o.date){let e=u(o.date,a);s=d(e.restDateString,e.year)}if(!s||isNaN(+s))return i();let c=+s,f=0,m;if(o.time&&(f=p(o.time),isNaN(f)))return i();if(o.timezone){if(m=h(o.timezone),isNaN(m))return i()}else{let e=new Date(c+f),r=t(0,n?.in);return r.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),r.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),r}return t(c+f+m,n?.in)}var a={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},o=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,s=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,c=/^([+-])(\d{2})(?::?(\d{2}))?$/;function l(e){let t={},n=e.split(a.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],a.timeZoneDelimiter.test(t.date)&&(t.date=e.split(a.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=a.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function u(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function d(e,t){if(t===null)return new Date(NaN);let n=e.match(o);if(!n)return new Date(NaN);let r=!!n[4],i=f(n[1]),a=f(n[2])-1,s=f(n[3]),c=f(n[4]),l=f(n[5])-1;if(r)return x(t,c,l)?g(t,c,l):new Date(NaN);{let e=new Date(0);return!y(t,a,s)||!b(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,s)),e)}}function f(e){return e?parseInt(e):1}function p(t){let r=t.match(s);if(!r)return NaN;let i=m(r[1]),a=m(r[2]),o=m(r[3]);return S(i,a,o)?i*e+a*n+o*1e3:NaN}function m(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function h(t){if(t===`Z`)return 0;let r=t.match(c);if(!r)return 0;let i=r[1]===`+`?-1:1,a=parseInt(r[2]),o=r[3]&&parseInt(r[3])||0;return C(a,o)?i*(a*e+o*n):NaN}function g(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var _=[31,null,31,30,31,30,31,31,30,31,30,31];function v(e){return e%400==0||e%4==0&&e%100!=0}function y(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(_[t]||(v(e)?29:28))}function b(e,t){return t>=1&&t<=(v(e)?366:365)}function x(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function S(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function C(e,t){return t>=0&&t<=59}export{i as t};