const e=require("../utils/dateUtil.js"),t=require("../utils/miscUtil.js");let n=require("vue");function r(t,n,r,i){let a=e.getClosingViewDate(t,r,i,1);function o(e){return e(t,n)?`same`:e(a,n)?`closing`:`far`}switch(r){case`year`:return o((t,n)=>e.isSameDecade(i,t,n));case`quarter`:case`month`:return o((t,n)=>e.isSameYear(i,t,n));default:return o((t,n)=>e.isSameMonth(i,t,n))}}function i(n,i,a,o){let s=t.getValue(n,0),c=t.getValue(n,1);if(i===0)return s;if(s&&c)switch(r(s,c,a,o)){case`same`:return s;case`closing`:return s;default:return e.getClosingViewDate(c,a,o,-1)}return s}function a({values:e,picker:r,defaultDates:a,generateConfig:o}){let s=(0,n.ref)([t.getValue(a,0),t.getValue(a,1)]),c=(0,n.ref)(null),l=(0,n.computed)(()=>t.getValue(e.value,0)),u=(0,n.computed)(()=>t.getValue(e.value,1)),d=n=>s.value[n]?s.value[n]:t.getValue(c.value,n)||i(e.value,n,r.value,o.value)||l.value||u.value||o.value.getNow(),f=(0,n.ref)(null),p=(0,n.ref)(null);(0,n.watchEffect)(()=>{f.value=d(0),p.value=d(1)});function m(n,r){if(n){let i=t.updateValues(c.value,n,r);s.value=t.updateValues(s.value,null,r)||[null,null];let a=(r+1)%2;t.getValue(e.value,a)||(i=t.updateValues(i,n,a)),c.value=i}else(l.value||u.value)&&(c.value=null)}return[f,p,m]}exports.default=a;