"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("dayjs"),D=require("dayjs/plugin/advancedFormat"),k=require("dayjs/plugin/customParseFormat"),p=require("dayjs/plugin/localeData"),Y=require("dayjs/plugin/quarterOfYear"),b=require("dayjs/plugin/weekOfYear"),W=require("dayjs/plugin/weekYear"),_=require("dayjs/plugin/weekday"),S=require("../../vc-util/warning.js");o.extend(k);o.extend(D);o.extend(_);o.extend(p);o.extend(b);o.extend(W);o.extend(Y);o.extend((e,t)=>{const r=t.prototype,a=r.format;r.format=function(s){const n=(s||"").replace("Wo","wo");return a.bind(this)(n)}});const M={bn_BD:"bn-bd",by_BY:"be",en_GB:"en-gb",en_US:"en",fr_BE:"fr",fr_CA:"fr-ca",hy_AM:"hy-am",kmr_IQ:"ku",nl_BE:"nl-be",pt_BR:"pt-br",zh_CN:"zh-cn",zh_HK:"zh-hk",zh_TW:"zh-tw"},i=e=>M[e]||e.split("_")[0],h=()=>{S.noteOnce(!1,"Not match any format. Please help to fire a issue about this.")},x=/\[([^\]]+)\]|Q|wo|ww|w|WW|W|zzz|[zS]|gggg|GGGG|k{1,2}/g;function m(e,t,r){const a=[...new Set(e.split(r))];let c=0;for(let s=0;s<a.length;s++){const n=a[s];if(c+=n.length,c>t)return n;c+=r.length}}const g=(e,t)=>{if(!e)return null;if(o.isDayjs(e))return e;const r=t.matchAll(x);let a=o(e,t);if(r===null)return a;for(const c of r){const s=c[0],n=c.index;if(s==="Q"){const l=e.slice(n-1,n),d=m(e,n,l).match(/\d+/)[0];a=a.quarter(Number.parseInt(d))}if(s.toLowerCase()==="wo"){const l=e.slice(n-1,n),d=m(e,n,l).match(/\d+/)[0];a=a.week(Number.parseInt(d))}s.toLowerCase()==="ww"&&(a=a.week(Number.parseInt(e.slice(n,n+s.length)))),s.toLowerCase()==="w"&&(a=a.week(Number.parseInt(e.slice(n,n+s.length+1))))}return a},q={getNow:()=>o(),getFixedDate:e=>o(e,["YYYY-M-DD","YYYY-MM-DD"]),getEndDate:e=>e.endOf("month"),getWeekDay:e=>{const t=e.locale("en");return t.weekday()+t.localeData().firstDayOfWeek()},getYear:e=>e.year(),getMonth:e=>e.month(),getDate:e=>e.date(),getHour:e=>e.hour(),getMinute:e=>e.minute(),getSecond:e=>e.second(),addYear:(e,t)=>e.add(t,"year"),addMonth:(e,t)=>e.add(t,"month"),addDate:(e,t)=>e.add(t,"day"),setYear:(e,t)=>e.year(t),setMonth:(e,t)=>e.month(t),setDate:(e,t)=>e.date(t),setHour:(e,t)=>e.hour(t),setMinute:(e,t)=>e.minute(t),setSecond:(e,t)=>e.second(t),isAfter:(e,t)=>e.isAfter(t),isValidate:e=>e.isValid(),locale:{getWeekFirstDay:e=>o().locale(i(e)).localeData().firstDayOfWeek(),getWeekFirstDate:(e,t)=>t.locale(i(e)).weekday(0),getWeek:(e,t)=>t.locale(i(e)).week(),getShortWeekDays:e=>o().locale(i(e)).localeData().weekdaysMin(),getShortMonths:e=>o().locale(i(e)).localeData().monthsShort(),format:(e,t,r)=>t.locale(i(e)).format(r),parse:(e,t,r)=>{const a=i(e);for(let c=0;c<r.length;c+=1){const s=r[c],n=t;if(s.includes("wo")||s.includes("Wo")){const d=n.split("-")[0],w=n.split("-")[1],y=o(d,"YYYY").startOf("year").locale(a);for(let f=0;f<=52;f+=1){const u=y.add(f,"week");if(u.format("Wo")===w)return u}return h(),null}const l=o(n,s,!0).locale(a);if(l.isValid())return l}return t||h(),null}},toDate:(e,t)=>Array.isArray(e)?e.map(r=>g(r,t)):g(e,t),toString:(e,t)=>Array.isArray(e)?e.map(r=>o.isDayjs(r)?r.format(t):r):o.isDayjs(e)?e.format(t):e};exports.default=q;
