const e=require("../../_virtual/_rolldown/runtime.js"),t=require("../../vc-util/warning.js");let n=require("dayjs");n=e.__toESM(n,1);let r=require("dayjs/plugin/advancedFormat");r=e.__toESM(r,1);let i=require("dayjs/plugin/customParseFormat");i=e.__toESM(i,1);let a=require("dayjs/plugin/localeData");a=e.__toESM(a,1);let o=require("dayjs/plugin/quarterOfYear");o=e.__toESM(o,1);let s=require("dayjs/plugin/weekOfYear");s=e.__toESM(s,1);let c=require("dayjs/plugin/weekYear");c=e.__toESM(c,1);let l=require("dayjs/plugin/weekday");l=e.__toESM(l,1),n.default.extend(i.default),n.default.extend(r.default),n.default.extend(l.default),n.default.extend(a.default),n.default.extend(s.default),n.default.extend(c.default),n.default.extend(o.default),n.default.extend((e,t)=>{let n=t.prototype,r=n.format;n.format=function(e){let t=(e||``).replace(`Wo`,`wo`);return r.bind(this)(t)}});var u={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`},d=e=>u[e]||e.split(`_`)[0],f=()=>{t.noteOnce(!1,`Not match any format. Please help to fire a issue about this.`)},p=/\[([^\]]+)\]|Q|wo|ww|w|WW|W|zzz|[zS]|gggg|GGGG|k{1,2}/g;function m(e,t,n){let r=[...new Set(e.split(n))],i=0;for(let e=0;e<r.length;e++){let a=r[e];if(i+=a.length,i>t)return a;i+=n.length}}var h=(e,t)=>{if(!e)return null;if(n.default.isDayjs(e))return e;let r=t.matchAll(p),i=(0,n.default)(e,t);if(r===null)return i;for(let t of r){let n=t[0],r=t.index;if(n===`Q`){let t=m(e,r,e.slice(r-1,r)).match(/\d+/)[0];i=i.quarter(Number.parseInt(t))}if(n.toLowerCase()===`wo`){let t=m(e,r,e.slice(r-1,r)).match(/\d+/)[0];i=i.week(Number.parseInt(t))}n.toLowerCase()===`ww`&&(i=i.week(Number.parseInt(e.slice(r,r+n.length)))),n.toLowerCase()===`w`&&(i=i.week(Number.parseInt(e.slice(r,r+n.length+1))))}return i},g={getNow:()=>(0,n.default)(),getFixedDate:e=>(0,n.default)(e,[`YYYY-M-DD`,`YYYY-MM-DD`]),getEndDate:e=>e.endOf(`month`),getWeekDay:e=>{let 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=>(0,n.default)().locale(d(e)).localeData().firstDayOfWeek(),getWeekFirstDate:(e,t)=>t.locale(d(e)).weekday(0),getWeek:(e,t)=>t.locale(d(e)).week(),getShortWeekDays:e=>(0,n.default)().locale(d(e)).localeData().weekdaysMin(),getShortMonths:e=>(0,n.default)().locale(d(e)).localeData().monthsShort(),format:(e,t,n)=>t.locale(d(e)).format(n),parse:(e,t,r)=>{let i=d(e);for(let e=0;e<r.length;e+=1){let a=r[e],o=t;if(a.includes(`wo`)||a.includes(`Wo`)){let e=o.split(`-`)[0],t=o.split(`-`)[1],r=(0,n.default)(e,`YYYY`).startOf(`year`).locale(i);for(let e=0;e<=52;e+=1){let n=r.add(e,`week`);if(n.format(`Wo`)===t)return n}return f(),null}let s=(0,n.default)(o,a,!0).locale(i);if(s.isValid())return s}return t||f(),null}},toDate:(e,t)=>Array.isArray(e)?e.map(e=>h(e,t)):h(e,t),toString:(e,t)=>Array.isArray(e)?e.map(e=>n.default.isDayjs(e)?e.format(t):e):n.default.isDayjs(e)?e.format(t):e};exports.default=g;