1import{s as e}from"./appType-H4Lk86HF.js";import{Bi as t,Gi as n,Hi as r,Ho as i,Ji as a,Ki as o,Lg as s,Li as c,Og as l,Qi as u,Ri as d,So as f,Ui as p,Vi as m,Wi as h,Xi as g,Yi as _,Zi as v,a as y,bo as b,o as x,qi as S,qn as C,yo as w,zi as T}from"./common-C5mtuLG2.js";import{E,O as D,Ri as O,ai as k,at as A,k as j,ot as ee,zi as te}from"./vendor-BYBdXKh1.js";import{Y as M,d as N,dt as P,gt as F,pt as I,q as L}from"./ErrorBoxContainer-DHmIt_-p.js";import{t as R}from"./useUserDateTime-D4CeEi-p.js";import{t as z}from"./Icon-41ddX0F1.js";import{n as B}from"./FormDateRange-DNRbaGre.js";var V=e(te(),1),H=()=>{let e=L(),t=M();return(0,V.useCallback)((n,r)=>{let i=k.fromISO(n),a=k.fromISO(r),o=!1;i>a&&(i=k.fromISO(r),a=k.fromISO(n),o=!0);let s=i.plus({years:1}).minus({days:1});return a>s&&(a=s,o=!0,I(e.formatAsString({id:`DateRangeSelect/ErrorOutOfRange`},{until:C({since:a,language:t.language})}))),{correctedSince:i,correctedUntil:a,isCorrected:o}},[e,t])},U={grid:`_grid_1a2fw_1`},W=O(),G=({since:e,until:t,onChange:n})=>{let r=L(),a=M(),o=H(),s=ee({criteriaMode:`all`,mode:`onSubmit`,shouldUnregister:!0,defaultValues:{since:i(e),until:i(t)}}),{handleSubmit:c,formState:{errors:l}}=s,u=e=>{let{correctedSince:t,correctedUntil:r}=o(e.since,e.until);n(t,r)},d=()=>{F({message:r.formatAsString({id:`Format/Date/Required`}),type:`error`,containerId:P.App})};return(0,W.jsx)(A,{...s,children:(0,W.jsx)(`form`,{onSubmit:c(u,d),children:(0,W.jsxs)(`div`,{className:U.grid,children:[(0,W.jsx)(B,{prepend:{content:r.formatAsString({id:`DateRangeSelect/Since`})+`:`},name:`since`,errors:l.since,rules:{required:!0},weekstartMonday:a.weekstartMonday,locale:a.language}),(0,W.jsx)(B,{prepend:{content:r.formatAsString({id:`DateRangeSelect/Until`})+`:`},name:`until`,errors:l.until,rules:{required:!0},weekstartMonday:a.weekstartMonday,locale:a.language}),(0,W.jsx)(N,{theme:`primary`,"aria-label":r.formatAsString({id:`DateRangeSelect/Apply`}),children:(0,W.jsx)(z,{name:x.ArrowCircleRight,mods:[y.Regular]})})]})})})},K=(e,t,n)=>g(e,t,n)?l.ThisMonth:_(e,t,n)?l.ThisAndNextMonth:v(e,t,n)?l.ThisQuarter:a(e,t,n)?l.ThisAndNextTwoMonths:u(e,t,n)?l.ThisYear:S(e,t,n)?l.RestOfTheYear:null,q=(e,t)=>{switch(e){case l.ThisMonth:return{since:t.startOf(`month`),until:t.endOf(`month`)};case l.ThisAndNextMonth:return{since:t.startOf(`month`),until:t.plus({months:1}).endOf(`month`)};case l.ThisAndNextTwoMonths:return{since:t.startOf(`month`),until:t.plus({months:2}).endOf(`month`)};case l.ThisQuarter:return{since:t.startOf(`quarter`),until:t.endOf(`quarter`)};case l.ThisYear:return{since:t.startOf(`year`),until:t.endOf(`year`)};case l.RestOfTheYear:return{since:t,until:t.endOf(`year`)};default:return null}},J={root:`_root_r20x4_1`,list:`_list_r20x4_16`,preset:`_preset_r20x4_24`},Y=e=>{let t=L(),n=R(),{since:r,until:i,onChange:a}=e,o=e=>{let t=q(e,n);t&&a(t.since,t.until)},s=K(r,i,n);return(0,W.jsxs)(E,{className:J.root,align:`start`,sideOffset:5,children:[e.mode===`advanced`&&(0,W.jsxs)(`ul`,{className:J.list,children:[(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.ThisMonth,onClick:()=>o(l.ThisMonth),children:t.formatAsString({id:`DateRangeSelect/ThisMonth`})})}),(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.ThisAndNextMonth,onClick:()=>o(l.ThisAndNextMonth),children:t.formatAsString({id:`DateRangeSelect/ThisAndNextMonth`})})}),(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.ThisAndNextTwoMonths,onClick:()=>o(l.ThisAndNextTwoMonths),children:t.formatAsString({id:`DateRangeSelect/ThisAndNextTwoMonths`})})}),(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.ThisQuarter,onClick:()=>o(l.ThisQuarter),children:t.formatAsString({id:`DateRangeSelect/ThisQuarter`})})}),(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.ThisYear,onClick:()=>o(l.ThisYear),children:t.formatAsString({id:`DateRangeSelect/ThisYear`})})}),(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{className:J.preset,type:`button`,"data-is-active":s===l.RestOfTheYear,onClick:()=>o(l.RestOfTheYear),children:t.formatAsString({id:`DateRangeSelect/RestOfYear`})})})]}),(0,W.jsx)(`div`,{children:t.formatAsString({id:e.mode===`advanced`?`DateRangeSelect/SelectCustomPeriod`:`DateRangeSelect/SelectPeriod`})}),(0,W.jsx)(G,{since:r,until:i,onChange:a})]})},X={button:`_button_1bt1s_1`},Z=(e,t)=>t.plus({day:1}).diff(e,[`years`,`months`,`days`]),ne=e=>{let t=L(),n=R(),{since:r,until:i,onChange:o}=e,s=()=>
1{let e=Z(r,i);e.days===0?o(r.plus(e),i.plus(e).endOf(`month`)):o(r.plus(e),i.plus(e))},c=()=>{let e=Z(r,i);e.days===0?o(r.minus(e),i.minus(e).endOf(`month`)):o(r.minus(e),i.minus(e))},l=S(r,i,n)&&!g(r,i,n)&&!_(r,i,n)&&!a(r,i,n)&&!v(r,i,n)&&!u(r,i,n);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:X.button,type:`button`,"aria-label":t.formatAsString({id:`DateRangeSelect/Back`}),onClick:c,disabled:l,children:(0,W.jsx)(`i`,{className:`icon-chevron-left`})}),(0,W.jsx)(`button`,{className:X.button,type:`button`,"aria-label":t.formatAsString({id:`DateRangeSelect/Forward`}),onClick:s,disabled:l,children:(0,W.jsx)(`i`,{className:`icon-chevron-right`})})]})},re=e=>e.clientWidth<e.scrollWidth,ie={endWithDot:!0,maxChar:4},Q=(e=``,t)=>{let{maxChar:n,endWithDot:r}={...ie,...t};return e.length<=n?e:e.substring(0,n-1)+(r?`.`:``)},ae=({since:e})=>{let{language:t}=M();switch(t){case s.German:return(0,W.jsx)(W.Fragment,{children:e.toFormat(`cccc, d. LLLL yyyy`)});case s.English:return(0,W.jsx)(W.Fragment,{children:e.toFormat(`cccc, d LLLL yyyy`)});case s.French:return(0,W.jsx)(W.Fragment,{children:e.toFormat(`cccc d LLLL yyyy`)});default:return(0,W.jsx)(W.Fragment,{children:e.toFormat(`cccc d LLLL yyyy`)})}},oe=({since:e,until:t})=>{let{language:n}=M(),r=b(e,t);switch(n){case s.French:case s.German:return(0,W.jsx)(W.Fragment,{children:[Q(e.toFormat(`cccc`),{maxChar:3}),e.toFormat(`d.`),r?null:Q(e.toFormat(`LLLL`)),`â`,Q(t.toFormat(`cccc`),{maxChar:3}),t.toFormat(`d.`),Q(t.toFormat(`LLLL`)),t.toFormat(`yyyy`)].filter(Boolean).join(` `)});case s.English:return(0,W.jsx)(W.Fragment,{children:[r?e.toFormat(`ccc d`):e.toFormat(`ccc d LLL`),`â`,t.toFormat(`ccc d LLL yyyy`)].join(` `)});default:return null}},$=({since:e,until:i})=>{let s=L(),l=R(),{language:y}=M();return!e.isValid||!i.isValid?(0,W.jsx)(W.Fragment,{children:`â`}):p(e,i)?w(e,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/Today`})}):w(e,l.minus({days:1}))?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/Yesterday`})}):(0,W.jsx)(ae,{since:e}):h(e,i)?g(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/ThisMonth`})}):t(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/LastMonth`})}):(0,W.jsx)(W.Fragment,{children:e.toFormat(`MMMM yyyy`)}):n(e,i)?m(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/LastQuarter`})}):v(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/ThisQuarter`})}):(0,W.jsxs)(W.Fragment,{children:[s.formatAsString({id:`DateRangeSelect/Quarter`}),` `,e.toFormat(`q / yyyy`)]}):d(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/Last2Months`})}):T(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/Last3Months`})}):_(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/ThisAndNextMonth`})}):a(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/ThisAndNextTwoMonths`})}):c(e,i)?r(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/LastYear`})}):u(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/ThisYear`})}):o(e,i)?(0,W.jsx)(W.Fragment,{children:e.toFormat(`yyyy`)}):(0,W.jsx)(W.Fragment,{children:[e.toFormat(`yyyy`),`â`,i.toFormat(`yyyy`)].join(` `)}):S(e,i,l)?(0,W.jsx)(W.Fragment,{children:s.formatAsString({id:`DateRangeSelect/RestOfYear`})}):f(e,i)?(0,W.jsx)(oe,{since:e,until:i}):(0,W.jsx)(W.Fragment,{children:C({since:e,until:i,language:y})})},se={root:`_root_1r67d_1`},ce=({showPeriodLabel:e,...t})=>{let n=L();return(0,W.jsxs)(j,{className:se.root,children:[e&&(0,W.jsxs)(W.Fragment,{children:[n.formatAsString({id:`DateRangeSelect/Period`}),` `]}),(0,W.jsx)($,{...t}),` `,(0,W.jsx)(`i`,{className:`icon-chevron-down`})]})},le={root:`_root_1z0hs_1`},ue=({mode:e=`advanced`,showPeriodLabel:t=!1,...n})=>{let{language:r}=M(),[i,a]=V.useState(!1),o=k.fromISO(n.since,{locale:r}),s=k.fromISO(n.until,{locale:r}),c=(e,t)=>{n.onChange(e,t),a(!1)};return(0,W.jsxs)(`div`,{className:le.root,"data-testid":`date-range-select`,children:[(0,W.jsxs)(D,{open:i,onOpenChange:a,children:[(0,W.jsx)(ce,{since:o,until:s,showPeriodLabel:t}),(0,W.jsx)(Y,{since:o,until:s,onChange:c,mode:e})]}),e===`advanced`&&(0,W.jsx)(ne,{since:o,until:s,onChange:c})]})};export{K as a,q as i,re as n,H as o,Q as r,ue as t}; 2//# sourceMappingURL=DateRangeSelect-CLbnPBXr.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.