@stenajs-webui/calendar 22.6.2 → 22.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._calendar_hknk7_1{--swui-calendar-day-width: 48px;--swui-calendar-day-height: 48px;--swui-calendar-day-border-radius: var(--swui-max-border-radius);--swui-calendar-week-number-bg-color: transparent;--swui-calendar-week-number-text-color: var(--lhds-color-ui-500);--swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-wrapper-selected-border: var(--modern-blue);--swui-calendar-wrapper-selected-background: var(--modern-blue);--swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);--swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);--swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);--swui-calendar-wrapper-today-background: var(--lhds-color-ui-50);--swui-calendar-text-selected-color: #fff;--swui-calendar-text-disabled-color: var(--swui-text-disabled-color);--swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color)}._calendar_hknk7_1 table{border-spacing:0 4px}._calendar_hknk7_1 tr td:last-child{border-top-right-radius:var(--swui-calendar-day-border-radius);border-bottom-right-radius:var(--swui-calendar-day-border-radius)}._calendar_hknk7_1._weekNumberVisible_hknk7_41 tr td:nth-child(2),._calendar_hknk7_1:not(._weekNumberVisible_hknk7_41) tr td:first-child{border-top-left-radius:var(--swui-calendar-day-border-radius);border-bottom-left-radius:var(--swui-calendar-day-border-radius)}._calendar_hknk7_1 td{padding:0;width:var(--swui-calendar-day-width);height:var(--swui-calendar-day-height)}._timePicker_1w05d_1{overflow:hidden;width:180px}._timePickerColumn_1w05d_6{overflow-y:hidden;flex:1}._timePickerColumn_1w05d_6:hover{overflow-y:scroll}._travelDateCell_1t2af_1{position:relative}._travelDateCell_1t2af_1._smaller_1t2af_4{width:40px;height:40px}._travelDateCell_1t2af_1._small_1t2af_4{width:44px;height:44px}._travelDateCell_1t2af_1._medium_1t2af_14{width:48px;height:48px}._travelDateCell_1t2af_1._large_1t2af_19{width:56px;height:28px}._travelDateCell_1t2af_1{border-radius:var(--swui-max-border-radius)}._travelDateCell_1t2af_1:focus{outline:none}._travelDateCell_1t2af_1:focus-visible ._outline_1t2af_31{outline:var(--swui-focus-outline);outline-width:var(--swui-focus-outline-width);background:transparent;position:absolute;border-radius:var(--swui-max-border-radius);top:0;bottom:0;left:0;right:0;z-index:10}._travelDateCell_1t2af_1:focus-visible ._contentWrapper_1t2af_44._contentWrapper_1t2af_44._contentWrapper_1t2af_44{border-color:transparent}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44{cursor:pointer;border-radius:var(--swui-max-border-radius);border-width:2px;border-style:solid;border-color:transparent;background:transparent;position:absolute;display:flex;align-items:center;justify-content:center;left:0;right:0;top:0;bottom:0}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._disabled_1t2af_65{cursor:not-allowed}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isToday_1t2af_68{border-color:var(--lhds-color-ui-400)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72,._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionEnd_1t2af_73{border-color:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72{background:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72 span{color:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionEnd_1t2af_73:not(._isSelectionStart_1t2af_72){background:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88{border-color:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88._startSelected_1t2af_91:not(._endSelected_1t2af_91):not(._isSelectionStart_1t2af_72){background:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88._startSelected_1t2af_91:not(._endSelected_1t2af_91):not(._isSelectionStart_1t2af_72) span{color:var(--swui-text-primary-color)}._travelDateCellBackground_45q5d_1._smaller_45q5d_2{width:20px;height:40px}._travelDateCellBackground_45q5d_1._small_45q5d_2{width:22px;height:44px}._travelDateCellBackground_45q5d_1._medium_45q5d_12{width:24px;height:48px}._travelDateCellBackground_45q5d_1._large_45q5d_17{width:28px;height:56px}._travelCalendar_ib2y4_1{border-spacing:0 4px;width:-webkit-fit-content;width:fit-content;--selection-background-color: var( --travel-calendar-selection-background-color, var(--modern-blue) );--selection-range-background-color: var( --travel-calendar-selection-range-background-color, var(--himmel) )}._travelCalendar_ib2y4_1 td{padding:0}._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2{transition:opacity var(--swui-animation-time-fast) ease-in-out;opacity:1}._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2:not(._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2._calendarVisible_1j7rp_6){opacity:0}._travelDateInput_hmfbf_1 ._overlay_hmfbf_2{transition:opacity var(--swui-animation-time-fast) ease-in-out;opacity:1}._travelDateInput_hmfbf_1 ._overlay_hmfbf_2:not(._travelDateInput_hmfbf_1 ._overlay_hmfbf_2._calendarVisible_hmfbf_6){opacity:0}")),document.head.appendChild(e)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("@stenajs-webui/core"),M=require("@stenajs-webui/elements"),d=require("date-fns"),A=require("date-fns/locale"),ae=require("lodash-es"),c=require("react"),ce=require("classnames"),Ne=require("@emotion/styled"),X=require("@stenajs-webui/forms"),ye=require("@stenajs-webui/tooltip"),qe=require("@stenajs-webui/theme"),_t=require("@stenajs-webui/input-mask");function Nt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ke=Nt(c),te={yearAndMonth:"yyyy-MM",fullDate:"yyyy-MM-dd",fullMonthName:"LLLL",fullDateAndTime:"yyyy-MM-dd HH:mm",fullDateAndTimeSystem:"yyyy-MM-ddTHH:MM",weekDayName:"EEEE",weekDayNameShort:"EEE",dateAndMonth:"d MMM",monthAndDate:"MMM do"},fe=(e={},t,n)=>{if(t&&n&&d.isAfter(n,t))return d.eachDayOfInterval({start:t,end:n}).reduce((s,a)=>{const l=d.isSameDay(a,t),i=d.isSameDay(a,n);return ee(s,a,l?["selected","selectedStart","range"]:i?["selected","selectedEnd","range"]:["range"])},e);let r=e;return t&&(r=ee(r,t,["selected","singleSelected"])),n&&(r=ee(r,n,["selected","singleSelected"])),r},rt=(e={},t,n,r)=>st(e,t,n,d.startOfMonth(r),d.endOfMonth(r)),st=(e={},t,n,r,s)=>t&&n?fe(e,d.max([t,d.subDays(r,1)]),d.min([n,d.addDays(s,1)])):fe(e,t,n),Pt=(e,t,n)=>{const r=d.format(t,te.yearAndMonth),s=d.getISOWeek(t),a=d.getDate(t);return{...e,[r]:{...e&&e[r],[s]:{...e&&e[r]&&e[r][s],[a]:{...e&&e[r]&&e[r][s]&&e[r][s][a],...n}}}}},Yt=(e,t,n)=>{const r=d.format(t,te.yearAndMonth),s=d.getISOWeek(t),a=d.getDate(t);return{...e,[r]:{...e&&e[r],[s]:{...e&&e[r]&&e[r][s],[a]:{...e&&e[r]&&e[r][s]&&e[r][s][a],...n(e&&e[r]&&e[r][s]&&e[r][s][a])}}}}},ee=(e,t,n)=>{const r=t.getMonth()+1,s=`${t.getFullYear()}-${r<10?"0":""}${r}`,a=d.getISOWeek(t),l=d.getDate(t),i=e&&e[s]&&e[s][a]&&e[s][a][l];return{...e,[s]:{...e&&e[s],[a]:{...e&&e[s]&&e[s][a],[l]:ze(i,n)}}}},ze=(e,t)=>({...e,highlights:[...(e==null?void 0:e.highlights)??[],...t]}),Ft=(e,t,n)=>{const r=t.days[0].date,s=r.getMonth()+1,a=`${r.getFullYear()}-${s<10?"0":""}${s}`,l=t.weekNumber;let i=e;t.days.forEach(g=>{i=ee(i,g.date,n)});const u=i&&i[a]?i[a][l]:void 0,m=u&&u.highlights?[...u.highlights,...n]:n,f={...u,highlights:m};return{...i,[a]:{...e&&e[a],[l]:f}}},at=(e,t)=>{var s;if(!t.days.length)return{...e};const n=t.days[0].date,r=(s=ae.last(t.days))==null?void 0:s.date;return{...fe(e,n,r)}},Wt=(e,t)=>c.useMemo(()=>e?ee(t,new Date,["today"]):t,[e,t]),Ie=e=>e.length===0?e:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1);var ot=(e=>(e[e.JANUARY=0]="JANUARY",e[e.FEBRUARY=1]="FEBRUARY",e[e.MARCH=2]="MARCH",e[e.APRIL=3]="APRIL",e[e.MAY=4]="MAY",e[e.JUNE=5]="JUNE",e[e.JULY=6]="JULY",e[e.AUGUST=7]="AUGUST",e[e.SEPTEMBER=8]="SEPTEMBER",e[e.OCTOBER=9]="OCTOBER",e[e.NOVEMBER=10]="NOVEMBER",e[e.DECEMBER=11]="DECEMBER",e))(ot||{}),ct=(e=>(e[e.SUNDAY=0]="SUNDAY",e[e.MONDAY=1]="MONDAY",e[e.TUESDAY=2]="TUESDAY",e[e.WEDNESDAY=3]="WEDNESDAY",e[e.THURSDAY=4]="THURSDAY",e[e.FRIDAY=5]="FRIDAY",e[e.SATURDAY=6]="SATURDAY",e))(ct||{});const He=(e,t,n,r)=>{const s=[];for(let a=0;a<n;a++)s.push(pe(e,t+a,r));return s},pe=(e,t,n)=>{if(isNaN(e)||isNaN(t))throw new Error("getMonthInYear() received NaN.");const r=e+Math.floor(t/12),s=t%12,a=new Date(r,s,1);return{monthString:d.format(a,te.yearAndMonth),name:Ie(d.format(a,te.fullMonthName,{locale:n})),year:r,monthInYear:s,weeks:it(r,s,n)}},it=(e,t,n,r=!0)=>{const s=new Date(e,t,1),a=d.startOfWeek(s,{locale:n}),l=[];for(let i=0;i<6;i++){const u=Be(d.addWeeks(a,i),n);if(i>0&&u.startMonth!==t&&!r)return l;l.push(u)}return l},Be=(e,t)=>{const n=d.getMonth(d.addDays(e,7))!==d.getMonth(e);return{weekNumber:d.getWeek(e,{locale:t}),startMonth:d.getMonth(e),startYear:d.getYear(e),endMonth:d.getMonth(d.addDays(e,6)),endYear:d.getYear(d.addDays(e,6)),days:dt(e,t),isLastWeekOfMonth:n}},lt=(e,t)=>{const n=d.getISODay(e);return{date:e,name:d.format(e,"EEE",t?{locale:t}:void 0),fullName:d.format(e,"EEEE",t?{locale:t}:void 0),dateString:d.format(d.addHours(e,12),te.fullDate),weekNumber:d.getWeek(e,{locale:t}),year:d.getYear(e),month:d.getMonth(e),dayOfMonth:d.getDate(e),dayOfWeek:n,isFirstDayOfWeek:n===1,isLastDayOfWeek:n===7,isFirstDayOfMonth:d.isSameDay(d.startOfMonth(e),e),isLastDayOfMonth:d.isSameDay(d.endOfMonth(e),e)}},dt=(e,t)=>d.eachDayOfInterval({start:e,end:d.addDays(e,6)}).map(n=>lt(n,t)),ut=(e,t)=>t>11?{year:e+Math.floor(t/12),month:t%12}:t<0?{year:e+Math.floor(t/12),month:12+t%12}:{year:e,month:t},Ht="_calendar_hknk7_1",Ot="_weekNumberVisible_hknk7_41",Ve={calendar:Ht,weekNumberVisible:Ot},ft=(e,t,n)=>!!(t&&t.indexOf(n)>=0||e&&e.highlights&&e.highlights.indexOf(n)>=0),V=(e,t,n,r,s)=>{if(n.length!==r.length)throw new Error("Select highlight failed, number of values do not equal number of highlights.");if(n.length===0)return s;for(let a=0;a<n.length;a++)if(typeof n[a]=="boolean"&&n[a]||typeof n[a]=="string"&&ft(e,t,n[a]))return r[a];return s},mt=({selectedBackground:e,todayBackground:t,rangeBackground:n,borderColor:r="transparent"})=>(s,a,l,i,u)=>({backgroundColor:V(a,s,["selected","range","today",l.month===u.monthInYear],[e,n,t,"#fff"],"transparent"),borderWidth:"1px",borderStyle:"solid",borderColor:V(a,s,["selectedStart","selectedEnd","singleSelected","range","today"],["var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-border)","var(--lhds-color-ui-500)"],r),borderTopLeftRadius:V(a,s,["selectedStart","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderBottomLeftRadius:V(a,s,["selectedStart","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderTopRightRadius:V(a,s,["selectedEnd","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderBottomRightRadius:V(a,s,["selectedEnd","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),boxSizing:"border-box"}),ht=({selectedColor:e,disabledColor:t,inOtherMonthColor:n,rangeTextColor:r})=>(s,a,l,i,u)=>{const m=l.month!==u.monthInYear;return{color:V(a,s,[m,"selected","range","enabled","disabled"],[n,e,r,void 0,t])}},oe={width:"var(--swui-calendar-day-width)",height:"var(--swui-calendar-day-height)",WeekNumber:{backgroundColor:"var(--swui-calendar-week-number-bg-color)",textColor:"var(--swui-calendar-week-number-text-color)",clickableTextColor:"var(--swui-calendar-week-number-clickable-text-color)"},WeekDay:{textColor:"var(--swui-calendar-week-day-text-color)",clickableTextColor:"var(--swui-calendar-week-day-clickable-text-color)"},CalendarDay:{tdStyle:mt({selectedBackground:"var(--swui-calendar-wrapper-selected-background)",rangeBackground:"var(--swui-calendar-wrapper-range-background)",todayBackground:"var(--swui-calendar-wrapper-today-background)"}),textProps:ht({selectedColor:"var(--swui-calendar-text-selected-color)",disabledColor:"var(--swui-calendar-text-disabled-color)",inOtherMonthColor:"var(--swui-calendar-text-in-other-month-color)"})},CalendarMonth:{headerTextColor:"var(--swui-calendar-week-day-text-color)"}},$t={...oe,width:"37px",height:"37px"},gt=({onClickWeekDay:e,day:t,theme:n})=>{const r=o.jsx(h.Box,{width:n.width,height:n.height,justifyContent:"center",alignItems:"center",children:o.jsx(h.Text,{size:"small",color:e?n.WeekDay.clickableTextColor:n.WeekDay.textColor,children:t.name})});return e?o.jsx(h.Clickable,{borderRadius:"var(--swui-calendar-day-border-radius)",onClick:s=>e(t.dayOfWeek,s),disableFocusHighlight:!e,children:r}):r},Ge=function({day:t,week:n,month:r,dayState:s,userData:a,onClickDay:l,theme:i,extraDayContent:u,defaultHighlights:m,showDatesInOtherMonths:f}){const g=o.jsx(h.Box,{width:"100%",height:"100%",justifyContent:"center",alignItems:"center",children:o.jsx(h.Text,{...i.CalendarDay.textProps&&i.CalendarDay.textProps(m,s,t,n,r,a),children:t.dayOfMonth})}),b=Ne.td({...i.CalendarDay.tdStyle&&i.CalendarDay.tdStyle(m,s,t,n,r,a)}),x=Ne.div({...i.CalendarDay.innerWrapperStyle&&i.CalendarDay.innerWrapperStyle(m,s,t,n,r,a),width:"100%",height:"100%"}),D=Ne.div({...i.CalendarDay.cellWrapperStyle&&i.CalendarDay.cellWrapperStyle(m,s,t,n,r,a),width:"100%",height:"100%",position:"relative"}),p=Ut(m,s);return o.jsx(b,{onClick:p?void 0:j=>l==null?void 0:l(t,a,j),children:o.jsx(x,{children:o.jsx(D,{children:(t.month===r.monthInYear||f)&&o.jsxs(o.Fragment,{children:[u&&o.jsx(u,{week:n,month:r,day:t,dayState:s,theme:i,userData:a}),g]})})})})},Ut=(e,t)=>!!V(t,e,["enabled","disabled"],[!1,!0],!1),xt=({onClickWeek:e,theme:t,week:n,background:r,backgroundColor:s,prefix:a})=>{const l=o.jsxs(h.Box,{width:t.width,height:t.height,justifyContent:"center",alignItems:"center",children:[r&&o.jsx(h.Box,{position:"absolute",children:r}),o.jsx(h.Box,{position:"absolute",children:o.jsxs(h.Text,{color:e?t.WeekNumber.clickableTextColor:t.WeekNumber.textColor,children:[a,n.weekNumber]})})]});return o.jsx(h.Box,{background:s||t.WeekNumber.backgroundColor,position:"relative",children:e?o.jsx(h.Clickable,{borderRadius:"var(--swui-calendar-day-border-radius)",onClick:i=>e(n,i),disableFocusHighlight:!e,children:l}):l})},qt=(e,t,n)=>t&&d.isBefore(e,t)?d.isSameDay(e,t):n&&d.isAfter(e,n)?d.isSameDay(e,n):!0,Kt=function({dayComponent:t,minDate:n,maxDate:r,dayState:s,day:a,...l}){const i=c.useMemo(()=>qt(a.date,n,r)?s:ze(s,["disabled"]),[a.date,s,r,n]);return o.jsx(t,{day:a,...l,dayState:i})};function zt({month:e,dayComponent:t=Ge,statePerWeek:n,userDataPerWeek:r,minDate:s,maxDate:a,onClickDay:l,onClickWeek:i,onClickWeekDay:u,onClickMonth:m,renderWeekNumber:f,renderWeekDay:g,headerRightContent:b,theme:x=oe,extraDayContent:D,defaultHighlights:p,showWeekNumber:j}){return o.jsx(o.Fragment,{children:o.jsxs(h.Box,{alignItems:"stretch",children:[o.jsxs(h.Row,{justifyContent:b?"space-between":"center",alignItems:"center",children:[o.jsx(h.Row,{justifyContent:"center",alignItems:"center",children:m?o.jsx(M.FlatButton,{onClick:()=>m(e),label:e.name+" "+String(e.year),rightIcon:M.stenaAngleDown}):o.jsxs(h.Text,{whiteSpace:"nowrap",children:[e.name," ",e.year]})}),b&&o.jsx(h.Box,{alignItems:"center",children:b})]}),o.jsx("table",{children:o.jsxs("tbody",{children:[o.jsxs("tr",{children:[j&&o.jsx("td",{children:o.jsx(h.Box,{width:x.width,height:x.height})}),e.weeks[0].days.map(k=>o.jsx("td",{children:g?g(k.name,x,u):o.jsx(gt,{day:k,onClickWeekDay:u,theme:x})},k.name))]}),e.weeks.map(k=>o.jsxs("tr",{children:[j&&o.jsx("td",{children:f?f(k,x,i):o.jsx(xt,{week:k,onClickWeek:i,theme:x})}),k.days.map(y=>o.jsx(Kt,{dayComponent:t,day:y,week:k,month:e,dayState:n&&n[k.weekNumber]&&n[k.weekNumber][y.dayOfMonth],userData:r&&r[k.weekNumber]&&r[k.weekNumber][y.dayOfMonth],onClickDay:l,theme:x,extraDayContent:D,defaultHighlights:p,minDate:s,maxDate:a},y.dateString))]},k.weekNumber))]})})]})})}function Gt({monthRows:e,dayComponent:t=Ge,userDataPerMonth:n,statePerMonth:r,minDate:s,maxDate:a,onClickDay:l,onClickWeekDay:i,onClickWeek:u,onClickMonth:m,renderWeekDay:f,renderWeekNumber:g,headerRightContent:b,extraDayContent:x,defaultHighlights:D,showWeekNumber:p,theme:j=oe}){const k=c.useMemo(()=>s?d.parse(s,"yyyy-MM-dd",new Date):void 0,[s]),y=c.useMemo(()=>a?d.parse(a,"yyyy-MM-dd",new Date):void 0,[a]);return o.jsx("div",{className:ce(Ve.calendar,p&&Ve.weekNumberVisible),children:e.map((w,S)=>o.jsx(h.Spacing,{children:o.jsx(h.Row,{gap:2,children:w.map(T=>o.jsx(zt,{month:T,dayComponent:t,userDataPerWeek:n&&n[T.monthString],statePerWeek:r&&r[T.monthString],onClickDay:l,onClickWeekDay:i,onClickWeek:u,onClickMonth:m,theme:j,renderWeekNumber:g,renderWeekDay:f,headerRightContent:b,extraDayContent:x,defaultHighlights:D,minDate:k,maxDate:y,showWeekNumber:p??!1},T.name))})},S))})}function Me(e){const t=Jt(e.year,e.month,e.date),{year:n,month:r}=ut(t.year,t.month),s=Zt(n,r,e.locale??A.enGB,e.numMonths,e.monthsPerRow),a=Wt(e.highlightToday,e.statePerMonth);return o.jsx(Gt,{year:n,month:r,monthRows:s,...e,statePerMonth:a})}const Jt=(e,t,n)=>{if(t&&e)return{month:t,year:e};if(n)return{month:d.getMonth(n),year:d.getYear(n)};const r=new Date;return{month:d.getMonth(r),year:d.getYear(r)}},Zt=(e,t,n,r,s)=>r==null?[[pe(e,t,n)]]:s==null?[He(e,t,r,n)]:ae.chunk(He(e,t,r,n),s),bt=(e,t)=>`${e.row}-${e.column}-${t}`,Qt=(e,t,n,r)=>{let s=t;for(let a=0;a<r;a++){s=Xt(s,e,r);const l=bt(s,n);if(document.getElementById(l))return l}},Xt=(e,t,n)=>{let r=e.row,s=e.column;return t==="ArrowLeft"?s--:t==="ArrowUp"?r--:t==="ArrowRight"?s++:t==="ArrowDown"&&r++,s<0&&(s=n-1,r--),s>n-1&&(s=0,r++),{column:s,row:r}},me={en:A.enGB,"en-US":A.enUS,"en-GB":A.enGB,"en-IE":A.enIE,"de-AT":A.deAT,"nl-BE":A.nlBE,"nl-NL":A.nl,"de-DE":A.de,"nb-NO":A.nb,"sv-SE":A.sv,"da-DK":A.da,"lv-LV":A.lv,"lt-LT":A.lt,"it-IT":A.it,"et-EE":A.et,"fi-FI":A.fi,"cs-CZ":A.cs,"es-ES":A.es,"fr-FR":A.fr,"pl-PL":A.pl,nl:A.nl,de:A.de,nb:A.nb,sv:A.sv,da:A.da,lv:A.lv,lt:A.lt,it:A.it,et:A.et,fi:A.fi,cs:A.cs,es:A.es,fr:A.fr,pl:A.pl},Je="en-GB",vt="sv",Ze=(e,t,n)=>{if(me[e])return e;if(t){const r=Dt(e);if(r)return r}return n},ie=e=>me[e],Dt=e=>{const[t]=e.split("-"),n=Object.keys(me);for(const r of n)if(r.startsWith(t))return r},Vt=()=>me.sv,yt=e=>{const t=Object.keys(me);for(const n of t)if(me[n].code===e.code)return n},en=({month:e,onClick:t,selected:n,localeCode:r,autoFocus:s,monthPickerId:a,position:l,size:i})=>{const u=c.useMemo(()=>ie(r)??ie("en-GB"),[r]),m=c.useMemo(()=>Ie(d.format(e,"LLL",{locale:u})),[u,e]),f=c.useMemo(()=>d.format(e,"LLLL",{locale:u}),[u,e]),g=c.useRef(null),b=bt(l,a),x=n?0:-1;c.useEffect(()=>{var p;(p=g.current)==null||p.focus()},[]);const D=c.useCallback(p=>{var k;const j=Qt(p.key,l,a,4);j&&((k=document.getElementById(j))==null||k.focus())},[a,l]);return o.jsx(h.Row,{justifyContent:"center",onKeyDown:D,children:n?o.jsx(M.PrimaryButton,{id:b,"aria-label":f,label:m,onClick:t,"aria-selected":!0,autoFocus:s,ref:g,size:i==="large"?"large":"medium",tabIndex:x}):o.jsx(M.FlatButton,{id:b,label:m,"aria-label":f,onClick:t,size:i==="large"?"large":"medium",tabIndex:x})})},tn=(e,t,n)=>{let r=e.getFullYear(),s=0,a=0,l=e;const i={yearOrder:[],rows:[],years:{},lastMonthColumn:-1,lastMonthRow:-1};for(let u=0;u<t;u++){if(i.years[r]==null&&(i.yearOrder.push(r),i.years[r]={year:r,rows:[]}),i.rows[s]=i.rows[s]??{columns:[],rowIndex:s},i.rows[s].columns[a]={position:{column:a,row:s},month:l},u===t-1){i.years[r].rows.push(s);break}l=d.addMonths(l,1),l.getFullYear()!==r?(i.years[r].rows.push(s),r++,a=0,s++):(a++,a>n-1&&(i.years[r].rows.push(s),a=0,s++))}return i.lastMonthColumn=a,i.lastMonthRow=s,i},he=({value:e,onValueChange:t,firstMonth:n,localeCode:r,numMonths:s,onCancel:a,size:l="medium"})=>{const i=c.useId(),u=h.useToday(),m=s>0?s:12,[f,g]=c.useState(!1),b=tn(n,m,rn(l)),x=c.useMemo(()=>d.addMonths(n,m),[m,n]);c.useEffect(()=>{g(!0)},[]);const D=c.useCallback(p=>{p.key==="Escape"&&(a==null||a(),p.preventDefault(),p.stopPropagation())},[a]);return o.jsx(h.Column,{gap:1,maxWidth:nn(l),onKeyDown:D,children:b.yearOrder.map((p,j)=>{const{rows:k}=b.years[p];return o.jsxs(Ke.Fragment,{children:[(j!==0||p!==u.getFullYear())&&o.jsx(h.Heading,{variant:"h4",children:p}),o.jsx("table",{style:{borderSpacing:"0 8px"},children:o.jsx("tbody",{children:k.map(y=>{const{columns:w}=b.rows[y];return o.jsx("tr",{children:w.map(({month:S,position:T})=>o.jsx("td",{children:o.jsx(en,{month:S,firstAvailableMonth:n,lastAvailableMonth:x,localeCode:r,selected:e?d.isSameMonth(e,S):!1,autoFocus:f,onClick:()=>t==null?void 0:t(S),monthPickerId:i,position:T,size:l})},S.getMonth()))},y)})})})]},p)})})},nn=e=>{switch(e){case"smaller":return"280px";case"small":return"308px";case"medium":return"336px";case"large":return"448px";default:return h.exhaustSwitchCase(e,"336px")}},rn=e=>{switch(e){case"smaller":case"small":return 3;case"medium":case"large":return 4;default:return h.exhaustSwitchCase(e,4)}},sn=e=>[{label:"Past",presets:[{label:"Last 3 days",startDate:e,endDate:d.subDays(e,2)},{label:"Last 7 days",startDate:e,endDate:d.subDays(e,6)},{label:"Last 30 days",startDate:e,endDate:d.subDays(e,29)},{label:"Last 45 days",startDate:e,endDate:d.subDays(e,44)}]},{label:"Future",presets:[{label:"Next 3 days",startDate:e,endDate:d.addDays(e,2)},{label:"Next 7 days",startDate:e,endDate:d.addDays(e,6)},{label:"Next 30 days",startDate:e,endDate:d.addDays(e,29)},{label:"Next 45 days",startDate:e,endDate:d.addDays(e,44)}]}],pt=({onClickPreset:e})=>{const[t,n]=c.useState(0),r=c.useMemo(()=>sn(new Date),[]),s=r[t]??r[0];return o.jsxs(h.Column,{children:[o.jsxs(h.Row,{justifyContent:"space-between",alignItems:"center",width:"200px",children:[o.jsx(M.FlatButton,{size:"small",leftIcon:M.stenaAngleLeft,disabled:t===0,onClick:()=>n(t-1)}),o.jsx(h.Text,{children:s.label}),o.jsx(M.FlatButton,{size:"small",leftIcon:M.stenaAngleRight,disabled:t===r.length-1,onClick:()=>n(t+1)})]}),o.jsx(h.Space,{}),o.jsx(h.Column,{alignItems:"center",children:s.presets.map(a=>o.jsxs(Ke.Fragment,{children:[o.jsx(M.PrimaryButton,{label:a.label,onClick:()=>e(a)}),o.jsx(h.Space,{})]},a.label))})]})},an=function({locale:t,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,renderMonthPicker:l,firstMonthInMonthPicker:i,numMonthsInMonthPicker:u,...m}){const f=c.useMemo(()=>t==null?"en-GB":yt(t)??"en-GB",[t]),g=h.useToday(),b=c.useCallback(D=>{r&&r(D),a("calendar")},[r,a]),x=c.useCallback(()=>{a("month")},[a]);switch(s){case"calendar":return o.jsx(Me,{...m,date:n,onClickMonth:x,locale:t});case"month":return l?l({value:n,onValueChange:b,locale:t,firstMonth:i??g,numMonths:u??24,dateInFocus:n}):o.jsx(he,{value:n,onValueChange:b,localeCode:f,firstMonth:i??g,numMonths:u??24});case"presets":return o.jsx(pt,{onClickPreset:()=>{}});default:return o.jsx(h.Box,{children:o.jsx(M.PrimaryButton,{label:"Show calendar",onClick:()=>a("calendar")})})}},on=(e,t,n,r)=>{const s=c.useCallback(()=>{const u=d.addMonths(e,n??r??1);t==null||t(u)},[t,e,n,r]),a=c.useCallback(()=>{const u=d.addYears(e,1);t==null||t(u)},[t,e]),l=c.useCallback(()=>{const u=d.subMonths(e,n??r??1);t==null||t(u)},[t,e,n,r]),i=c.useCallback(()=>{const u=d.subYears(e,1);t==null||t(u)},[t,e]);return{nextMonth:s,prevMonth:l,nextYear:a,prevYear:i}},cn=({children:e,prevMonth:t,nextMonth:n,prevYear:r,nextYear:s})=>o.jsxs("div",{children:[e,o.jsx(h.Indent,{children:o.jsxs(h.Row,{gap:1,children:[o.jsx(M.SecondaryButton,{onClick:r,leftIcon:M.stenaAngleLeftDouble}),o.jsx(M.SecondaryButton,{onClick:t,leftIcon:M.stenaArrowLeft}),o.jsx(h.Indent,{num:2}),o.jsx(M.SecondaryButton,{onClick:n,leftIcon:M.stenaArrowRight}),o.jsx(M.SecondaryButton,{onClick:s,leftIcon:M.stenaAngleRightDouble})]})}),o.jsx(h.Space,{})]}),ln=()=>{};function le({monthSwitcherPlacement:e,theme:t=oe,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,onSelectPreset:l=ln,renderMonthPicker:i,firstMonthInMonthPicker:u,numMonthsInMonthPicker:m,...f}){const{nextMonth:g,prevMonth:b,nextYear:x,prevYear:D}=on(n,r,f.monthsPerRow,f.numMonths);switch(dn(e,f.numMonths)){case"below":return o.jsx(cn,{theme:t,nextMonth:g,prevMonth:b,nextYear:x,prevYear:D,children:o.jsx(Me,{...f,theme:t,date:n})});case"header":return o.jsx(h.Column,{children:o.jsx(an,{...f,theme:t,renderMonthPicker:i,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,onSelectPreset:l,firstMonthInMonthPicker:u,numMonthsInMonthPicker:m,headerRightContent:o.jsxs(h.Row,{alignItems:"center",gap:1,children:[o.jsx(M.SecondaryButton,{onClick:b,leftIcon:M.stenaArrowLeft}),o.jsx(M.SecondaryButton,{onClick:g,leftIcon:M.stenaArrowRight})]})})});default:return o.jsx(Me,{...f,theme:t,date:n})}}const dn=(e,t)=>e||(t||1)>1?"below":"header",wt=e=>({startDate:e.startDate?d.format(e.startDate,"yyyy-MM-dd"):void 0,endDate:e.endDate?d.format(e.endDate,"yyyy-MM-dd"):void 0}),St=({startDate:e,endDate:t})=>{const n=new Date;return{startDate:e?d.parse(e,"yyyy-MM-dd",n):void 0,endDate:t?d.parse(t,"yyyy-MM-dd",n):void 0}},Qe=({startDate:e,endDate:t})=>!!(e&&t&&!d.isSameDay(e,t)&&d.isAfter(e,t)),Xe=e=>Qe(e)?{startDate:e.endDate,endDate:e.startDate}:e,un=e=>e.startDate&&e.endDate?wt(Xe(St(e))):e,fn=(e,t,n,r)=>c.useCallback(s=>{const a={startDate:n==="startDate"?s.date:e==null?void 0:e.startDate,endDate:n==="endDate"?s.date:e==null?void 0:e.endDate};Qe(a)||r(n==="startDate"?"endDate":"startDate"),t==null||t(Xe(a))},[n,t,r,e==null?void 0:e.endDate,e==null?void 0:e.startDate]),Ee=e=>{const[t,n]=c.useState("calendar"),r=c.useCallback(s=>{n(s),e==null||e(s)},[e]);return{currentPanel:t,setCurrentPanel:r}},kt=({focusedInput:e,value:t,onValueChange:n,setFocusedInput:r,statePerMonth:s,onChangePanel:a,initialDateInFocus:l})=>{const{currentPanel:i,setCurrentPanel:u}=Ee(a),[m,f]=c.useState(()=>l??new Date),g=fn(t,n,e,r),b=c.useMemo(()=>fe(s,t==null?void 0:t.startDate,t==null?void 0:t.endDate),[s,t==null?void 0:t.endDate,t==null?void 0:t.startDate]);return{onClickDay:g,statePerMonth:b,currentPanel:i,setCurrentPanel:u,setDateInFocus:f,dateInFocus:m}};function mn(e){const t=kt(e);return o.jsx(le,{...e,...t})}const hn=()=>{const[e,t]=c.useState(),[n,r]=c.useState(),[s,a]=c.useState("startDate");return{startDate:e,setStartDate:t,endDate:n,setEndDate:r,focusedInput:s,setFocusedInput:a}},jt=({onChange:e,value:t,statePerMonth:n,onChangePanel:r})=>{const{currentPanel:s,setCurrentPanel:a}=Ee(r),[l,i]=c.useState(()=>t??new Date),u=c.useCallback(f=>{e&&e(f.date)},[e]),m=c.useMemo(()=>t?ee(n,t,["selected","singleSelected"]):n,[n,t]);return{onClickDay:u,statePerMonth:m,date:t,currentPanel:s,setCurrentPanel:a,dateInFocus:l,setDateInFocus:i}};function ve(e){const t=jt(e);return o.jsx(le,{...e,...t})}const Mt=({onChange:e,value:t,statePerMonth:n,onChangePanel:r})=>{const{currentPanel:s,setCurrentPanel:a}=Ee(r),[l,i]=c.useState(()=>new Date),u=c.useCallback(f=>{if(!e)return;const g=t&&t.find(b=>d.isSameDay(b,f.date));e(t&&g?t.filter(b=>!d.isSameDay(b,f.date)):[...t||[],f.date])},[e,t]),m=c.useMemo(()=>t?t.reduce((f,g)=>ee(f,g,["selected"]),n):n,[n,t]);return{onClickDay:u,statePerMonth:m,currentPanel:s,setCurrentPanel:a,dateInFocus:l,setDateInFocus:i}};function gn(e){const t=Mt(e);return o.jsx(le,{...e,...t})}const Rt=({onChange:e,value:t,statePerMonth:n,onChangePanel:r,locale:s=A.enGB})=>{const[a,l]=c.useState(()=>{const x=Pe(t,s);return x?x.days[0].date:new Date}),{currentPanel:i,setCurrentPanel:u}=Ee(r),m=c.useCallback(x=>{e&&e(et(Be(x.date,s)))},[s,e]),f=c.useCallback(x=>{e&&e(et(x))},[e]),g=c.useMemo(()=>{const x=Pe(t,s);return x?at(n,x):n},[t,s,n]),b=c.useMemo(()=>{const x=Pe(t,s);return x?x.days[0].date:new Date},[s,t]);return{statePerMonth:g,date:b,dateInFocus:a,setDateInFocus:l,onClickDay:m,onClickWeek:f,currentPanel:i,setCurrentPanel:u}},et=e=>{if(e)return`${e.endYear}-${e.weekNumber}`},Pe=(e,t)=>{if(!e)return;const n=e.split("-"),r=parseInt(n[1],10),s=parseInt(n[0],10),a=new Date;a.setFullYear(s);const l=d.startOfWeek(d.setWeek(a,r),{locale:t});return Be(l,t)};function xn(e){const t=Rt(e);return o.jsx(le,{...e,...t})}const we="bottom",bn=(e,t,n)=>{const[r,s]=c.useState(n||!1),a=c.useCallback(()=>(s(!0),!0),[s]),l=c.useCallback(()=>{s(!1),t&&t()},[s,t]),i=c.useCallback(u=>{e&&e(u),setTimeout(l,150)},[e,l]);return{showCalendar:a,hideCalendar:l,showingCalendar:r,onSelectDate:i}},Se="2999-12-31",Dn=({displayFormat:e=te.fullDate,placeholder:t="Enter date",value:n,calendarTheme:r=oe,calendarProps:s,openOnMount:a,onClose:l,onChange:i,variant:u,width:m,minDate:f,maxDate:g=Se,disabled:b,portalTarget:x,zIndex:D})=>{const{hideCalendar:p,showingCalendar:j,onSelectDate:k,showCalendar:y}=bn(i,l,a);return o.jsx(h.Box,{width:m,children:o.jsx(ye.ControlledPopover,{hideArrow:!0,open:j,onRequestClose:p,appendTo:x,zIndex:D,renderTrigger:w=>o.jsx(h.Box,{...w,children:o.jsx(X.TextInput,{type:"date",onFocus:y,buttonRight:o.jsx(M.TextInputButton,{onClick:y,icon:M.stenaCalendar}),value:n?d.format(n,e):"",placeholder:t,size:9,disabled:b,autoFocus:a,variant:u,min:f,max:g})}),placement:we,children:o.jsx(ve,{...s,onChange:k,value:n,theme:r,minDate:f,maxDate:g})})})},yn=(e,t)=>{const n=c.useRef(null),r=c.useRef(null),[s,a]=c.useState(!1),[l,i]=c.useState(void 0),u=c.useCallback(()=>(i("startDate"),a(!0),!0),[i,a]),m=c.useCallback(()=>(i("endDate"),a(!0),!0),[i,a]),f=c.useCallback(()=>{a(!1)},[a]),g=c.useCallback(x=>{var D,p;l==="startDate"?(t==null||t({startDate:x.date,endDate:e==null?void 0:e.endDate}),e!=null&&e.endDate?setTimeout(f,150):(i("endDate"),(D=r.current)==null||D.focus())):l==="endDate"&&(t==null||t({startDate:e==null?void 0:e.startDate,endDate:x.date}),e!=null&&e.startDate?setTimeout(f,150):(i("startDate"),(p=n.current)==null||p.focus()))},[l,t,i,f,e]),b=c.useMemo(()=>(e==null?void 0:e.startDate)&&(e==null?void 0:e.endDate)&&d.isAfter(e.startDate,e.endDate),[e==null?void 0:e.startDate,e==null?void 0:e.endDate]);return{showingCalendar:s,hideCalendar:f,showCalendarEndDate:m,showCalendarStartDate:u,focusedInput:l,setFocusedInput:i,startDateInputRef:n,endDateInputRef:r,onClickDay:g,startDateIsAfterEnd:b}};function pn({displayFormat:e=te.fullDate,placeholderStartDate:t="Start date",placeholderEndDate:n="End date",value:r,onValueChange:s,width:a,calendarTheme:l=oe,calendarProps:i,minDate:u,maxDate:m=Se,disabled:f,portalTarget:g,zIndex:b}){const[x,D]=c.useState("calendar"),{hideCalendar:p,showCalendarEndDate:j,showCalendarStartDate:k,showingCalendar:y,focusedInput:w,startDateInputRef:S,endDateInputRef:T,onClickDay:E,startDateIsAfterEnd:C}=yn(r,s),[B,I]=c.useState(()=>(w&&(r==null?void 0:r[w]))??new Date),L=c.useMemo(()=>fe(void 0,r==null?void 0:r.startDate,r==null?void 0:r.endDate),[r]);return o.jsx(ye.ControlledPopover,{hideArrow:!0,appendTo:g,zIndex:b,renderTrigger:R=>o.jsxs(h.Row,{alignItems:"center",...R,children:[o.jsx(X.TextInput,{iconLeft:M.stenaCalendar,onFocus:k,value:r!=null&&r.startDate?d.format(r.startDate,e):"",placeholder:t,width:a,disabled:f,inputRef:S,size:9,variant:C?"error":void 0}),o.jsx(h.Space,{}),o.jsx(M.Icon,{icon:M.stenaArrowWideRight,color:qe.cssColor("--lhds-color-ui-500"),size:14}),o.jsx(h.Space,{}),o.jsx(X.TextInput,{iconLeft:M.stenaCalendar,onFocus:j,value:r!=null&&r.endDate?d.format(r.endDate,e):"",placeholder:n,width:a,disabled:f,inputRef:T,size:9,variant:C?"error":void 0})]}),open:y,placement:we,onRequestClose:p,children:o.jsx(le,{...i,dateInFocus:B,setDateInFocus:I,statePerMonth:L,theme:l,onClickDay:E,currentPanel:x,setCurrentPanel:D,minDate:u,maxDate:m})})}const wn=({calendarProps:e,closeOnCalendarSelectDate:t=!0,dateFormat:n=te.fullDate,disableCalender:r=!1,onValueChange:s,placeholder:a="yyyy-mm-dd",value:l,width:i="130px",calendarTheme:u=oe,hideCalenderIcon:m=!1,minDate:f,maxDate:g=Se,variant:b,portalTarget:x,zIndex:D,...p})=>{const[j,k]=c.useState(!1),y=c.useCallback(()=>{k(!j)},[k,j]),w=c.useCallback(()=>{k(!1)},[k]),S=c.useCallback(L=>{s&&s(L)},[s]),T=c.useCallback(L=>{L&&(S(d.format(L,n)),t&&setTimeout(()=>k(!j),200))},[S,n,t,k,j]),E=!!l&&!/^[-/\\.0-9]+$/.test(l),C=!!l&&d.isValid(d.parse(l,n,new Date)),I=!!l&&l.length>=n.length&&!C||E;return o.jsx(h.Box,{width:i,children:o.jsx(ye.ControlledPopover,{appendTo:x,zIndex:D,renderTrigger:({ref:L,...R})=>o.jsx(X.TextInput,{...p,variant:I?"error":b,disableContentPaddingRight:!0,contentRight:m?void 0:o.jsx(h.Row,{alignItems:"center",indent:.5,children:o.jsx(M.FlatButton,{size:"small",disabled:p.disabled||r,leftIcon:M.stenaCalendar,onClick:y})}),onValueChange:S,placeholder:a,value:l||"",min:f,max:g,size:10,inputRef:L,...R}),hideArrow:!0,open:j,placement:we,onRequestClose:w,children:o.jsx(ve,{...e,onChange:T,value:l&&C?d.parse(l,n,new Date):void 0,minDate:f,maxDate:g,theme:u})})})},Re=e=>{if(e==="")return"00";const t=parseInt(e,10);if(isNaN(t))throw new Error("Hours is not a number");if(t<0||t>23)throw new Error("Hours is an invalid number");switch(e.length){case 1:return`0${t}`;case 2:return e;default:throw new Error("Invalid hour string")}},Te=e=>{if(e==="")return"00";const t=parseInt(e,10);if(isNaN(t))throw new Error("Minutes is not a number");if(t<0||t>59)throw new Error("Minutes is an invalid number");switch(e.length){case 1:return`0${t}`;case 2:return e;default:throw new Error("Invalid minute string")}},Sn=e=>{if(!Oe(e))return{time:e,success:!1};const t=e&&e.split(/-|:|,|;|[/]|[.]| /);if(t&&t.length===2)try{const n=Re(t[0]),r=Te(t[1]);return{time:`${n}:${r}`,success:!0}}catch{return{time:e,success:!1}}else if(t&&t.length===1){let n=0,r=0;switch(e.length){case 1:return{time:`0${e}:00`,success:!0};case 2:{const s=parseInt(t[0],10);return s>=0&&s<24?{time:`${e}:00`,success:!0}:s>=24&&s<59?{time:`00:${e}`,success:!0}:{time:e,success:!1}}case 3:return r=parseInt(e.substring(1,3),10),r>=0&&r<=59?{time:`0${e.substring(0,1)}:${e.substring(1,3)}`,success:!0}:{time:e,success:!1};case 4:return n=parseInt(e.substring(0,2),10),r=parseInt(e.substring(2,4),10),n<0||n>23?{time:e,success:!1}:r<0||r>59?{time:e,success:!1}:{time:`${e.substring(0,2)}:${e.substring(2,4)}`,success:!0};default:return{time:e,success:!1}}}return{time:e,success:!1}},Oe=e=>e?/^[-:.,/; 0-9]+$/.test(e):!0,kn=({onValueChange:e,showPlaceholder:t=!0,useIcon:n=!0,value:r,width:s="85px",variant:a,...l})=>{const[i,u]=c.useState(()=>Oe(r)),m="hh:mm",f=c.useCallback(()=>{if(r){const b=Sn(r);u(b.success),b.success&&e&&e(b.time)}},[r,e,u]),g=c.useCallback(b=>{const x=b.target.value,D=Oe(x);u(D&&x.length<=m.length),e&&e(x)},[e,u]);return o.jsx(X.TextInput,{...l,type:"time",variant:i?a:"error",iconLeft:n?M.stenaClock:void 0,value:r,placeholder:t?m:void 0,onChange:g,onBlur:f,width:s})},Tt=({autoFocusLeft:e,autoFocusRight:t,onEsc:n,onEnter:r,onValueChangeLeft:s,onValueChangeRight:a,separatorIcon:l,placeholderLeft:i,placeholderRight:u,typeLeft:m,typeRight:f,onChangeLeft:g,onChangeRight:b,valueLeft:x,valueRight:D,minLeft:p,maxLeft:j,minRight:k,maxRight:y,onClickLeft:w,onClickRight:S,onClickCalendar:T,onClickArrowDown:E,onBlurLeft:C,onBlurRight:B,onFocusLeft:I,onFocusRight:L,inputRefLeft:R,inputRefRight:P,variant:_,variantLeft:Y,variantRight:H,onBlur:q,showPresets:G,widthLeft:O,widthRight:v,disabled:U})=>{const N=c.useRef(0),F=c.useMemo(()=>ae.debounce($=>{$===0&&(q==null||q())},10),[q]),K=c.useCallback($=>{N.current++,F(N.current),I&&I($)},[I,N,F]),J=c.useCallback($=>{N.current++,F(N.current),L&&L($)},[L,N,F]),ne=c.useCallback($=>{N.current--,F(N.current),C&&C($)},[C,N,F]),Q=c.useCallback($=>{N.current--,F(N.current),B&&B($)},[B,N,F]);return o.jsx(h.Box,{children:o.jsxs(X.TextInputBox,{disableContentPaddingRight:!0,disabled:U,variant:_,contentRight:o.jsxs(h.Row,{alignItems:"center",children:[o.jsx(h.Indent,{num:.5,children:o.jsx(M.FlatButton,{leftIcon:M.stenaCalendar,onClick:T,disabled:U,size:"small"})}),G?o.jsxs(o.Fragment,{children:[o.jsx(h.Row,{height:"22px",children:o.jsx(h.SeparatorLine,{vertical:!0})}),o.jsx(h.Indent,{num:.5,children:o.jsx(M.FlatButton,{leftIcon:M.stenaAngleDown,onClick:E,disabled:U,size:"small"})})]}):null]}),children:[o.jsx(h.Box,{width:O,children:o.jsx(X.TextInput,{onEsc:n,onEnter:r,onClick:w,disabled:U,hideBorder:!0,placeholder:i,value:x,onValueChange:s,onChange:g,onBlur:ne,onFocus:K,inputRef:R,variant:Y,type:m,autoFocus:e,min:p,max:j})}),o.jsx(h.Row,{indent:.5,alignItems:"center",justifyContent:"center",children:o.jsx(M.Icon,{icon:l,size:12,color:qe.cssColor("--lhds-color-ui-500")})}),o.jsx(h.Box,{width:v,children:o.jsx(X.TextInput,{onEsc:n,onEnter:r,onClick:S,disabled:U,hideBorder:!0,placeholder:u,value:D,onValueChange:a,onChange:b,onBlur:Q,onFocus:J,inputRef:P,variant:H,type:f,autoFocus:t,min:k,max:y})})]})})},jn=e=>{if(e==null)throw new Error("Time is not set.");if(e==="")throw new Error("Time is empty.");const t=e.split(":");if(t.length!==2)throw new Error("Invalid time.");if(t[1].length!==2)throw new Error("Invalid time.");if(t[0].length<1||t[0].length>2)throw new Error("Invalid time.");const n=parseInt(t[0],10),r=parseInt(t[1],10);if(isNaN(n))throw new Error("Invalid time.");if(isNaN(r))throw new Error("Invalid time.");if(n<0||n>23)throw new Error("Invalid time.");if(r<0||r>59)throw new Error("Invalid time.");return n*100+r},Mn=e=>{try{return jn(e),!0}catch{return!1}},je=e=>{if(e&&Mn(e)){const t=e.split(":");return{hour:h.parseIntElseUndefined(t[0]),minute:h.parseIntElseUndefined(t[1])}}return{hour:void 0,minute:void 0}},Rn=e=>`${Re(String(e.getHours()))}:${Te(String(e.getMinutes()))}`,Tn="_timePicker_1w05d_1",Cn="_timePickerColumn_1w05d_6",Ct={timePicker:Tn,timePickerColumn:Cn},In=({onClick:e,item:t,selected:n,columnRef:r,canScrollRef:s})=>{const a=c.useRef(null);return c.useEffect(function(){if(n&&r.current&&a.current&&s.current){const i=a.current.scrollHeight*Math.max(t-2,0);r.current.scrollTo(0,i),s.current=!1}},[r,t,n,s]),o.jsx(h.Row,{width:"64px",justifyContent:"center",spacing:.5,indent:.5,ref:a,children:n?o.jsx(M.PrimaryButton,{label:ae.padStart(String(t),2,"0"),onClick:()=>e&&e(t)}):o.jsx(M.FlatButton,{label:String(t).padStart(2,"0"),onClick:()=>e&&e(t)})})},tt=({onClick:e,items:t,selectedItem:n,canScrollRef:r})=>{const s=c.useRef(null);return o.jsx(h.Column,{className:Ct.timePickerColumn,ref:s,children:t.map(a=>o.jsx(In,{item:a,onClick:e,selected:a===n,columnRef:s,canScrollRef:r},a))})},Bn=ae.range(0,24),En=ae.range(0,60),An=({value:e,onValueChange:t})=>{const n=c.useRef(!0),[r,s]=c.useState(void 0),[a,l]=c.useState(void 0);c.useEffect(()=>{if(e){const{minute:m,hour:f}=je(e);s(f),l(m)}},[e]);const i=c.useCallback(m=>{s(m),t==null||t(`${Re(String(m??0))}:${Te(String(a??0))}`)},[a,t]),u=c.useCallback(m=>{l(m),t==null||t(`${Re(String(r??0))}:${Te(String(m??0))}`)},[r,t]);return o.jsxs(h.Row,{className:Ct.timePicker,children:[o.jsx(tt,{items:Bn,onClick:i,selectedItem:r,canScrollRef:n}),o.jsx(h.Indent,{}),o.jsx(tt,{items:En,onClick:u,selectedItem:a,canScrollRef:n})]})},Ln=(e,t,n)=>{c.useEffect(function(){e&&t(e)},[e,t]),c.useEffect(function(){n.current&&(e?n.current.valueAsDate=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())):n.current.valueAsDate=null)},[e,n])},_n=(e,t,{setDateInFocus:n,showCalendarInternal:r,hideCalendarInternal:s,setFirstFocusedInput:a,setCurrentPanel:l,localTime:i,setLocalTime:u,localDate:m,setLocalDate:f},g)=>{const b=c.useCallback(y=>{if(!y)return;const w=new Date(y);if(e)w.setHours(e.getHours()),w.setMinutes(e.getMinutes()),t==null||t(w),f(void 0);else if(i){const{minute:S,hour:T}=je(i);w.setHours(T??0),w.setMinutes(S??0),t==null||t(w),f(void 0)}else f(w);n(w),g.current&&(g.current.valueAsDate=new Date(Date.UTC(w.getFullYear(),w.getMonth(),w.getDate())))},[e,g,i,t,n,f]),x=c.useCallback(y=>{if(y)if(e){const w=je(y),S=new Date(e);S.setHours(w.hour||0),S.setMinutes(w.minute||0),t==null||t(S),u(void 0)}else if(m){const w=je(y),S=new Date(m);S.setHours(w.hour||0),S.setMinutes(w.minute||0),t==null||t(S),u(void 0)}else u(y)},[t,e,m,u]),D=c.useCallback(y=>{y.target.value[0]!=="0"&&b(y.target.valueAsDate)},[b]),p=c.useCallback(y=>x(y.target.value),[x]),j=c.useCallback(()=>{n(e||new Date),l("calendar"),r()},[e,l,r,n]),k=c.useCallback(()=>{a(void 0),s()},[a,s]);return{inputLeftChangeHandler:D,inputRightChangeHandler:p,hideCalendar:k,showCalendar:j,onChangeTime:x,onChangeDate:b}},Nn=e=>{const[t,n]=c.useState(void 0),[r,s]=c.useState(void 0),[a,l,i]=h.useBoolean(!1),[u,m,f]=h.useBoolean(!1),[g,b]=c.useState(void 0),[x,D]=c.useState(()=>e??new Date),[p,j]=c.useState("calendar");return{isCalendarVisible:a,showCalendarInternal:l,hideCalendarInternal:i,firstFocusedInput:g,setFirstFocusedInput:b,dateInFocus:x,setDateInFocus:D,currentPanel:p,setCurrentPanel:j,isTimePickerVisible:u,showTimePicker:m,hideTimePicker:f,localDate:t,setLocalDate:n,localTime:r,setLocalTime:s}},Pn=(e,t,n,r,{isCalendarVisible:s,setCurrentPanel:a,showTimePicker:l,hideTimePicker:i})=>{const u=c.useCallback(()=>{s||n(),a("calendar"),i()},[i,s,a,n]),m=c.useCallback(()=>{r(),l()},[r,l]),f=c.useCallback(D=>{e(D.date),r(),l()},[e,r,l]),g=c.useCallback(()=>{a("presets"),n()},[a,n]),b=c.useCallback(()=>{var D;s?r():((D=t.current)==null||D.focus(),a("calendar"),n())},[s,r,t,a,n]),x=c.useCallback(D=>{D.key==="Escape"&&r()},[r]);return{onFocusLeft:u,onFocusRight:m,onClickDay:f,onClickArrowButton:g,onClickCalendarButton:b,onKeyDownHandler:x}},Yn=({value:e,onValueChange:t,onEnter:n,onEsc:r,onBlur:s,autoFocus:a,minDate:l,widthLeft:i=128,widthRight:u=80,maxDate:m=Se,variant:f,disabled:g,zIndex:b,appendTo:x})=>{const D=c.useRef(null),p=c.useRef(null),j=Nn(e),{setCurrentPanel:k,currentPanel:y,isCalendarVisible:w,dateInFocus:S,setDateInFocus:T,isTimePickerVisible:E,hideTimePicker:C,localTime:B,localDate:I}=j,{showCalendar:L,hideCalendar:R,inputLeftChangeHandler:P,inputRightChangeHandler:_,onChangeTime:Y,onChangeDate:H}=_n(e,t,j,D),{onKeyDownHandler:q,onFocusRight:G,onFocusLeft:O,onClickDay:v,onClickCalendarButton:U,onClickArrowButton:N}=Pn(H,D,L,R,j);Ln(e,T,D);const F=c.useMemo(()=>{const $=e||I;return $?ee(void 0,$,["singleSelected","selected"]):{}},[I,e]),K=c.useCallback(()=>{R(),C()},[R,C]),J=c.useMemo(()=>e?Rn(e):B,[e,B]),ne=h.useDelayedFalse(w,300),Q=h.useDelayedFalse(E,300);return o.jsx(h.Box,{onKeyDown:q,children:o.jsx(ye.ControlledPopover,{hideArrow:!0,zIndex:b,appendTo:x,renderTrigger:$=>o.jsx(h.Box,{...$,children:o.jsx(Tt,{autoFocusLeft:a,onEsc:r,onEnter:n,onBlur:s,disabled:g,separatorIcon:M.stenaClock,typeLeft:"date",typeRight:"time",placeholderLeft:"yyyy-mm-dd",placeholderRight:"hh:mm",onChangeLeft:P,onChangeRight:_,onClickArrowDown:N,onClickCalendar:U,onFocusLeft:O,onFocusRight:G,onClickLeft:O,onClickRight:G,inputRefLeft:D,inputRefRight:p,valueRight:J??"",widthLeft:i,widthRight:u,minLeft:l,maxLeft:m,variant:f})}),placement:we,open:w||E,onRequestClose:K,children:(ne||Q)&&o.jsx(h.Column,{children:ne?o.jsx(le,{statePerMonth:F,onClickDay:v,dateInFocus:S,setDateInFocus:T,currentPanel:y,setCurrentPanel:k,minDate:l,maxDate:m}):Q?o.jsxs(h.Column,{children:[o.jsx(h.Column,{overflow:"hidden",height:"250px",children:o.jsx(An,{value:J??"",onValueChange:Y})}),o.jsx(h.Space,{}),o.jsx(h.Row,{justifyContent:"flex-end",children:o.jsx(M.PrimaryButton,{label:"Done",onClick:C})})]}):null})})})},Fn=({value:e,onValueChange:t,year:n})=>{const r=String(n);return o.jsx(h.Row,{justifyContent:"center",children:e===n?o.jsx(M.PrimaryButton,{label:r,onClick:()=>t==null?void 0:t(n)}):o.jsx(M.FlatButton,{label:r,onClick:()=>t==null?void 0:t(n)})})},Wn=({value:e,onValueChange:t,initialLastYear:n})=>{const[r,s]=c.useState(()=>e?e+4:n??new Date().getFullYear()+4),a=c.useMemo(()=>{const l=r-11;return ae.chunk(ae.range(l,r+1),3)},[r]);return c.useEffect(()=>{s(l=>Hn(e,l))},[e]),o.jsxs(h.Row,{children:[o.jsx(h.Column,{justifyContent:"center",children:o.jsx(M.FlatButton,{leftIcon:M.stenaArrowLeft,onClick:()=>s(r-3)})}),o.jsx(h.Column,{gap:1,children:a.map(l=>o.jsx(h.Row,{gap:1,children:l.map(i=>o.jsx(Fn,{year:i,onValueChange:t,value:e},i))},l[0]))}),o.jsx(h.Column,{justifyContent:"center",children:o.jsx(M.FlatButton,{leftIcon:M.stenaArrowRight,onClick:()=>s(r+3)})})]})},Hn=(e,t)=>{if(e==null)return t;if(e>t){const r=e-t,s=r%3,a=r-s+3;return t+a}const n=t-11;if(e<n){const r=n-e,s=r%3,a=r-s+3;return t-a}return t},On=(e,t,n,r,s)=>{c.useEffect(function(){e&&n(e)},[e,n]),c.useEffect(function(){t&&n(t)},[t,n]),c.useEffect(function(){r.current&&(e?r.current.valueAsDate=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())):r.current.valueAsDate=null)},[e,r]),c.useEffect(function(){s.current&&(t?s.current.valueAsDate=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())):s.current.valueAsDate=null)},[t,s])},$n=(e,t,n,{setDateInFocus:r,showCalendarInternal:s,hideCalendarInternal:a,setFirstFocusedInput:l,setCurrentPanel:i})=>{const u=c.useCallback(b=>{b.target.value[0]!=="0"&&(n==null||n({startDate:b.target.valueAsDate??void 0,endDate:t}))},[n,t]),m=c.useCallback(b=>{b.target.value[0]!=="0"&&(n==null||n({startDate:e,endDate:b.target.valueAsDate??void 0}))},[n,e]),f=c.useCallback(b=>{b!=null?r(b):r(e||t||new Date),i("calendar"),s()},[e,t,i,s,r]),g=c.useCallback(()=>{l(void 0),a()},[l,a]);return{inputLeftChangeHandler:u,inputRightChangeHandler:m,hideCalendar:g,setDateInFocus:r,setCurrentPanel:i,showCalendar:f}},Un=(e,t)=>{const[n,r,s]=h.useBoolean(!1),[a,l]=c.useState(void 0),[i,u]=c.useState("startDate"),[m,f]=c.useState(()=>(i==="startDate"?e:i==="endDate"?t:void 0)??new Date),[g,b]=c.useState("calendar");return{isCalendarVisible:n,showCalendarInternal:r,hideCalendarInternal:s,firstFocusedInput:a,setFirstFocusedInput:l,focusedInput:i,setFocusedInput:u,dateInFocus:m,setDateInFocus:f,currentPanel:g,setCurrentPanel:b}},qn=(e,t,n,r,s,a,l,{firstFocusedInput:i,setFirstFocusedInput:u,isCalendarVisible:m,setFocusedInput:f,focusedInput:g,setCurrentPanel:b,setDateInFocus:x})=>{const D=c.useCallback(()=>{i==null&&u("startDate"),f("startDate"),m?e!=null&&x(e):a(e)},[i,f,m,e,u,a,x]),p=c.useCallback(()=>{i==null&&u("endDate"),f("endDate"),m?t!=null&&x(t):a(t)},[i,f,m,t,u,a,x]),j=c.useCallback(S=>{var T,E,C,B;g==="startDate"?t!=null&&d.isAfter(S.date,t)?(n==null||n({startDate:S.date,endDate:void 0}),f("endDate"),(T=s.current)==null||T.focus()):(n==null||n({startDate:S.date,endDate:t}),i==="startDate"?(f("endDate"),(E=s.current)==null||E.focus()):setTimeout(l,50)):g==="endDate"&&(e?d.isAfter(e,S.date)?(n==null||n({startDate:S.date,endDate:void 0}),f("endDate"),(B=s.current)==null||B.focus()):(n==null||n({startDate:e,endDate:S.date}),setTimeout(l,50)):(n==null||n({startDate:e,endDate:S.date}),f("startDate"),(C=r.current)==null||C.focus()))},[g,n,t,i,f,s,l,e,r]),k=c.useCallback(()=>{b("presets"),a()},[b,a]),y=c.useCallback(()=>{var S;m?l():(f("startDate"),u("startDate"),(S=r.current)==null||S.focus(),b("calendar"),a())},[m,l,f,u,r,b,a]),w=c.useCallback(S=>{S.key==="Escape"&&l()},[l]);return{onFocusLeft:D,onFocusRight:p,onClickDay:j,onClickArrowButton:k,onClickCalendarButton:y,onKeyDownHandler:w}};function Kn({value:e,onValueChange:t,autoFocus:n,onBlur:r,onEnter:s,onEsc:a,minDate:l,maxDate:i=Se,calendarProps:u,widthLeft:m=128,widthRight:f=128,firstMonthInMonthPicker:g,numMonthsInMonthPicker:b,variant:x,disabled:D,zIndex:p,appendTo:j,renderBelowCalendar:k}){const{startDate:y,endDate:w}=e||{},S=c.useRef(null),T=c.useRef(null),E=Un(y,w),{dateInFocus:C,setDateInFocus:B,isCalendarVisible:I,currentPanel:L,setCurrentPanel:R}=E,{showCalendar:P,hideCalendar:_,inputLeftChangeHandler:Y,inputRightChangeHandler:H}=$n(y,w,t,E),{onKeyDownHandler:q,onFocusRight:G,onFocusLeft:O,onClickDay:v,onClickCalendarButton:U,onClickArrowButton:N}=qn(y,w,t,S,T,P,_,E);On(y,w,B,S,T);const F=c.useMemo(()=>y&&w&&d.isAfter(y,w),[y,w]),K=c.useMemo(()=>rt(u==null?void 0:u.statePerMonth,y,w,C),[u==null?void 0:u.statePerMonth,y,w,C]);return o.jsx(h.Box,{onKeyDown:q,children:o.jsx(ye.ControlledPopover,{hideArrow:!0,restoreFocus:!1,returnFocus:!1,zIndex:p,appendTo:j,renderTrigger:J=>o.jsx(h.Box,{...J,children:o.jsx(Tt,{autoFocusLeft:n,onEsc:a,onEnter:s,onBlur:r,disabled:D,separatorIcon:M.stenaArrowRight,typeLeft:"date",typeRight:"date",placeholderLeft:"Start date",placeholderRight:"End date",onChangeLeft:Y,onChangeRight:H,onClickArrowDown:N,onClickCalendar:U,onFocusLeft:O,onFocusRight:G,onClickLeft:O,onClickRight:G,inputRefLeft:S,inputRefRight:T,variant:F?"error":x,widthLeft:m,widthRight:f,minLeft:l,maxLeft:i,minRight:l,maxRight:i})}),placement:we,onRequestClose:_,open:I,children:o.jsxs(h.Column,{children:[o.jsx(le,{onClickDay:v,dateInFocus:C,firstMonthInMonthPicker:g,numMonthsInMonthPicker:b,setDateInFocus:B,currentPanel:L,setCurrentPanel:R,minDate:l,maxDate:i,...u,statePerMonth:K}),L==="calendar"&&k]})})})}const $e=({onChange:e,onValueChange:t,mask:n,pipe:r,value:s,guide:a,keepCharPositions:l,placeholderChar:i,showMask:u,calendarSize:m,onFocus:f,onBlur:g,placeholderWhenBlurred:b,placeholder:x,valueWhenBlurred:D,label:p,variant:j,...k})=>{const y=c.useRef(null),[w,S]=c.useState(!1),{onChange:T}=_t.useMaskedInput(y,e,t,n,r,s,a,l,i,u,w),E=c.useCallback(I=>{f==null||f(I),S(!0)},[f]),C=c.useCallback(I=>{g==null||g(I),S(!1)},[g]),B=w?x:b??x;return j==="standard"?o.jsx(M.Label,{text:p??"",children:o.jsx(X.TextInput,{...k,"aria-live":"polite",value:(w?s:D)??"",inputRef:y,placeholder:B,onFocus:E,onBlur:C,onChange:T,width:nt(m),alwaysShowPlaceholder:!0})}):o.jsx(X.LabelledTextInput,{...k,label:p,"aria-live":"polite",value:(w?s:D)??"",ref:y,placeholder:B,onFocus:E,onBlur:C,onChange:T,width:nt(m),size:m==="large"?"large":"medium"})},nt=e=>{switch(e){case"smaller":return"140px";case"small":return"154px";case"medium":return"168px";case"large":return"196px";default:return h.exhaustSwitchCase(e,"168px")}},zn=[/[1-2]/,/\d/,/\d/,/\d/],Gn=[/[0-1]/,/\d/],Jn=[/[0-3]/,/\d/],It=e=>Qn(e).flatMap(Zn),Zn=e=>{switch(e){case"yyyy":return zn;case"mm":case"MM":return Gn;case"dd":case"DD":return Jn;default:return[e]}},Qn=e=>{if(e.length===0)return[];const t=[];let n=e[0];for(let r=1;r<e.length;r++)e[r]!==e[r-1]?(t.push(n),n=e[r]):n+=e[r];return t.push(n),t},de=e=>{const n=new Intl.DateTimeFormat(e,{dateStyle:"short"}).formatToParts(new Date),r={year:"yyyy",month:"MM",day:"dd"};return n.map(s=>r[s.type]||s.value).join("")},se=(e,t,n)=>{const r=Ze(t,(n==null?void 0:n.matchLanguage)??!1,(n==null?void 0:n.fallbackLocaleCode)??Je),s=ie(r);if(s==null)return;const a=d.parse(e,de(r),(n==null?void 0:n.referenceDate)??new Date,{locale:s});if(!isNaN(a.getTime()))return a},ue=(e,t,n)=>{const r=Ze(t,(n==null?void 0:n.matchLanguage)??!1,(n==null?void 0:n.fallbackLocaleCode)??Je);return d.format(e,de(r),{locale:ie(r)})},Ce=(e,t)=>{const n=se(e,t);if(n!=null)return ue(n,t)},Bt=({value:e,onValueChange:t,localeCode:n,startDateLabel:r="From",endDateLabel:s="To",onFocus:a,calendarSize:l,placeholderWhenBlurredStartDate:i,placeholderWhenBlurredEndDate:u,valueWhenBlurredStartDate:m,valueWhenBlurredEndDate:f,variant:g})=>{const{mask:b,placeholder:x}=c.useMemo(()=>{const D=de(n);return{mask:It(D),placeholder:D.toLowerCase()}},[n]);return o.jsxs(h.Row,{children:[o.jsx($e,{mask:b,value:e==null?void 0:e.startDate,onValueChange:D=>{t==null||t({startDate:D})},onBlur:D=>{const p=Ce(D.target.value,n);p&&p!==(e==null?void 0:e.startDate)&&(t==null||t({startDate:p}))},onFocus:a,label:r,borderRadiusVariant:"onlyLeft",placeholder:x,placeholderWhenBlurred:i,valueWhenBlurred:m,calendarSize:l,variant:g}),o.jsx($e,{mask:b,value:e==null?void 0:e.endDate,onValueChange:D=>t==null?void 0:t({endDate:D}),onBlur:D=>{const p=Ce(D.target.value,n);p&&p!==(e==null?void 0:e.endDate)&&(t==null||t({endDate:p}))},onFocus:a,label:s,borderRadiusVariant:"onlyRight",placeholder:x,placeholderWhenBlurred:u,valueWhenBlurred:f,calendarSize:l,variant:g})]})},Ue=(e,t,n)=>{const r=d.isSameYear(e,t)?"":" y";return n.code.startsWith("en")?d.format(e,"eee MMM d"+r,{locale:n}).replace(".",""):d.format(e,"eee d MMM"+r,{locale:n}).replace(".","")},Et=(e,t,n,r,s)=>{const a=ie(r),l=c.useId(),i=h.useToday(),u=c.useRef(null),m=c.useMemo(()=>de(n),[n]),f=c.useMemo(()=>{var R;return((R=e==null?void 0:e.startDate)==null?void 0:R.length)===m.length?se(e.startDate,n):void 0},[m.length,n,e==null?void 0:e.startDate]),g=c.useMemo(()=>{var R;return((R=e==null?void 0:e.endDate)==null?void 0:R.length)===m.length?se(e.endDate,n):void 0},[m.length,n,e==null?void 0:e.endDate]),b=c.useMemo(()=>f!=null?Ue(f,i,a):void 0,[a,f,i]),x=c.useMemo(()=>g!=null?Ue(g,i,a):void 0,[a,g,i]),[D,p]=c.useState(s??f??new Date),j=c.useCallback(R=>{d.isSameMonth(R,i)||d.isAfter(R,i)?p(R):p(i)},[i]),k=c.useMemo(()=>pe(D.getFullYear(),D.getMonth(),a),[a,D]),y=c.useMemo(()=>Ie(d.intlFormat(D,{month:"long",year:"numeric"},{locale:a.code})),[a,D]),w=c.useMemo(()=>d.isSameMonth(i,D),[i,D]),[S,T]=c.useState(),[E,C]=c.useState("calendar"),B=c.useCallback(R=>{var Y,H;const P=((Y=R==null?void 0:R.startDate)==null?void 0:Y.length)===m.length?se(R.startDate,n):void 0,_=((H=R==null?void 0:R.endDate)==null?void 0:H.length)===m.length?se(R.endDate,n):void 0;P?j(P):_&&j(_),t==null||t({...e,...R})},[m.length,n,t,j,e]),I=c.useMemo(()=>(f&&g&&(d.isSameDay(f,g)||d.isBefore(f,g)))??!1,[g,f]);return{onClickDate:R=>{R.getFullYear()===D.getFullYear()&&R.getMonth()===D.getMonth()&&(f&&g==null?d.isBefore(R,f)?t==null||t({startDate:ue(R,n),endDate:void 0}):t==null||t({startDate:e==null?void 0:e.startDate,endDate:ue(R,n)}):t==null||t({startDate:ue(R,n),endDate:void 0}))},onValueChangeByInputs:B,isValidDateRange:I,monthPickerButtonRef:u,calendarId:l,monthPickerButtonLabel:y,visiblePanel:E,setVisiblePanel:C,setVisibleMonth:p,visibleMonthData:k,todayIsInVisibleMonth:w,hoverDate:S,setHoverDate:T,selectedStartDate:f,selectedEndDate:g,today:i,visibleMonth:D,valueWhenBlurredStartDate:b,valueWhenBlurredEndDate:x}},Ae=({previousMonthButtonAriaLabel:e,nextMonthButtonAriaLabel:t,monthPickerButtonLabel:n,visiblePanel:r,setVisiblePanel:s,monthPickerButtonRef:a,setVisibleMonth:l,visibleMonth:i,prevMonthDisabled:u,nextMonthDisabled:m,calendarSize:f,previousMonthButtonTestId:g,nextMonthButtonTestId:b})=>{const x=f==="smaller"||f==="small"?"medium":"large";return o.jsxs(h.Row,{alignSelf:"center",justifyContent:"space-between",width:"100%",children:[o.jsx(M.FlatButton,{"aria-live":"polite",label:n,rightIcon:r==="calendar"?M.stenaAngleDown:M.stenaAngleUp,onClick:()=>s(r==="calendar"?"month-picker":"calendar"),ref:a,size:x}),o.jsxs(h.Row,{alignItems:"center",gap:2,children:[o.jsx(M.SecondaryButton,{leftIcon:M.stenaArrowLeft,onClick:()=>l(d.subMonths(i,1)),disabled:u==null?void 0:u(i),"aria-label":e,size:x,"data-testid":g}),o.jsx(M.SecondaryButton,{leftIcon:M.stenaArrowRight,onClick:()=>l(d.addMonths(i,1)),disabled:m==null?void 0:m(i),"aria-label":t,size:x,"data-testid":b})]})]})},Xn="_travelDateCell_1t2af_1",vn="_smaller_1t2af_4",Vn="_small_1t2af_4",er="_medium_1t2af_14",tr="_large_1t2af_19",nr="_outline_1t2af_31",rr="_contentWrapper_1t2af_44",sr="_disabled_1t2af_65",ar="_isToday_1t2af_68",or="_isSelectionStart_1t2af_72",cr="_isSelectionEnd_1t2af_73",ir="_hover_1t2af_88",lr="_startSelected_1t2af_91",dr="_endSelected_1t2af_91",Z={travelDateCell:Xn,smaller:vn,small:Vn,medium:er,large:tr,outline:nr,contentWrapper:rr,disabled:sr,isToday:ar,isSelectionStart:or,isSelectionEnd:cr,hover:ir,startSelected:lr,endSelected:dr},re="var(--selection-range-background-color)",ur=(e,t,n,r,s,a)=>{if(!s)return{left:"transparent",right:"transparent"};if(t&&n&&d.isSameDay(t,n))return{left:"transparent",right:"transparent"};if(t&&n&&!a)return{left:"transparent",right:"transparent"};const l=t&&n?d.isAfter(e,t)&&d.isBefore(e,n)&&!d.isSameDay(e,t)&&!d.isSameDay(e,n):!1,i=t&&r?d.isAfter(e,t)&&d.isBefore(e,r)&&!d.isSameDay(e,t)&&!d.isSameDay(e,r):!1;if(l)return{left:re,right:re};if(t&&n)return d.isSameDay(e,t)?{left:"transparent",right:re}:d.isSameDay(e,n)?{left:re,right:"transparent"}:{left:"transparent",right:"transparent"};if(t&&r&&d.isAfter(r,t)){if(d.isSameDay(e,t))return{left:"transparent",right:re};if(d.isSameDay(e,r))return{left:re,right:"transparent"}}return i?{left:re,right:re}:{left:"transparent",right:"transparent"}},fr=(e,t)=>{switch(t){case"PageUp":return d.subMonths(e,1);case"PageDown":return d.addMonths(e,1);case"Home":return d.startOfWeek(e);case"End":return d.addDays(d.startOfWeek(e),6);case"ArrowLeft":return d.subDays(e,1);case"ArrowUp":return d.subDays(e,7);case"ArrowRight":return d.addDays(e,1);case"ArrowDown":return d.addDays(e,7);default:return}},Ye=(e,t)=>d.format(d.addHours(e,12),te.fullDate)+t,mr="_travelDateCellBackground_45q5d_1",hr="_smaller_45q5d_2",gr="_small_45q5d_2",xr="_medium_45q5d_12",br="_large_45q5d_17",ke={travelDateCellBackground:mr,smaller:hr,small:gr,medium:xr,large:br},Dr=({calendarSize:e,bgColorLeft:t,bgColorRight:n})=>o.jsxs(h.Row,{children:[o.jsx(h.Box,{className:ce(ke.travelDateCellBackground,ke[e]),background:t}),o.jsx(h.Box,{className:ce(ke.travelDateCellBackground,ke[e]),background:n})]}),yr=({onClick:e,visibleMonth:t,onChangeVisibleMonth:n,day:r,isValidDateRange:s,selectedStartDate:a,selectedEndDate:l,onStartHover:i,onEndHover:u,hoverDate:m,today:f,todayIsInVisibleMonth:g,calendarId:b,isDateDisabled:x,size:D,dateTestId:p})=>{const j=c.useCallback(async C=>{var L;const B=fr(r.date,C.key),I=(B&&(x==null?void 0:x(B)))??!1;B&&!I&&(i(B),d.isSameMonth(r.date,B)?(L=document.getElementById(Ye(B,b)))==null||L.focus():(n(B),setTimeout(()=>{var R;(R=document.getElementById(Ye(B,b)))==null||R.focus()},10))),(C.key==="Enter"||C.code==="Space")&&e(r.date)},[b,r.date,x,n,e,i]),k=r.month===t.getMonth(),y=(x==null?void 0:x(r.date))??!1,w=a?d.isSameDay(a,r.date):!1,S=l?d.isSameDay(l,r.date):!1,T=d.isSameDay(r.date,f),E=ur(r.date,a,l,m,k,s);return o.jsxs("td",{className:ce(Z.travelDateCell,Z[D]),onClick:y?void 0:()=>e(r.date),onMouseOver:y?void 0:()=>k&&i(r.date),onMouseOut:y?void 0:()=>k&&u(r.date),tabIndex:y?void 0:pr(r,a,T,t,g),id:y?void 0:Ye(r.date,b),onKeyDown:y?void 0:j,...y?void 0:{"aria-selected":w||S},"data-testid":p==null?void 0:p(r.date),children:[o.jsx("div",{className:Z.outline}),o.jsx(Dr,{calendarSize:D,bgColorLeft:E.left,bgColorRight:E.right}),k&&o.jsx("div",{className:ce(Z.contentWrapper,T?Z.isToday:void 0,a?Z.startSelected:void 0,l?Z.endSelected:void 0,m&&d.isSameDay(m,r.date)?Z.hover:void 0,w&&Z.isSelectionStart,S&&Z.isSelectionEnd,y&&Z.disabled),children:o.jsx(h.Text,{variant:"bold",color:y?qe.cssColor("--lhds-color-ui-500"):void 0,children:r.dayOfMonth})})]})},pr=(e,t,n,r,s)=>{const a=t?d.isSameMonth(t,r):!1;return(t&&a?d.isSameDay(e.date,t):n)||!a&&!s&&e.date.getDate()===1?0:-1},wr="_travelCalendar_ib2y4_1",Sr={travelCalendar:wr},Le=({visibleMonthData:e,onClickDate:t,setHoverDate:n,setVisibleMonth:r,visibleMonth:s,isValidDateRange:a,selectedStartDate:l,selectedEndDate:i,hoverDate:u,today:m,calendarId:f,isDateDisabled:g,todayIsInVisibleMonth:b,size:x="medium",multiSelectable:D,dateTestId:p})=>o.jsx("table",{className:Sr.travelCalendar,role:"grid",...D?{"aria-multiselectable":!0}:void 0,children:o.jsxs("tbody",{children:[o.jsx("tr",{children:e.weeks[0].days.map(j=>o.jsx("th",{abbr:j.fullName,children:o.jsx(h.Text,{children:j.name})},j.name))}),e.weeks.map(j=>o.jsx(Ke.Fragment,{children:o.jsx("tr",{children:j.days.map(k=>o.jsx(yr,{size:x,onClick:y=>t(y),visibleMonth:s,onChangeVisibleMonth:r,isValidDateRange:a,day:k,onStartHover:y=>n(y),onEndHover:y=>n(w=>w&&d.isSameDay(w,y)?void 0:w),selectedStartDate:l,selectedEndDate:i,hoverDate:u,today:m,todayIsInVisibleMonth:b,calendarId:f,isDateDisabled:g,dateTestId:p},k.dateString))},j.weekNumber)},j.weekNumber))]})}),kr="_travelDateRangeInput_1j7rp_1",jr="_overlay_1j7rp_2",Mr="_calendarVisible_1j7rp_6",Fe={travelDateRangeInput:kr,overlay:jr,calendarVisible:Mr},Rr=({value:e,onValueChange:t,startDateLabel:n,endDateLabel:r,localeCode:s="sv",languageLocaleCode:a=s,initialMonthInFocus:l,previousMonthButtonAriaLabel:i="Previous month",nextMonthButtonAriaLabel:u="Next month",placeholderWhenBlurredStartDate:m,placeholderWhenBlurredEndDate:f,heading:g,headingLevel:b,numMonthsInMonthPicker:x=12,isDateDisabled:D,prevMonthDisabled:p,nextMonthDisabled:j,firstMonthInMonthPicker:k=new Date,zIndex:y=1e3,zIndexWhenClosed:w,onHideCalendar:S,renderBelowCalendar:T,size:E="medium",dateTestId:C,previousMonthButtonTestId:B,nextMonthButtonTestId:I,textInputVariant:L="standard"})=>{const[R,P]=c.useState(!1),[_,Y]=c.useState(!1),[H,q]=c.useState({width:336,height:66}),G=E==="large"?"8.8rem":"6.6rem",O=c.useRef(!1),v=c.useCallback(()=>{O.current=!0,Y(!0),setTimeout(()=>{P(!0)},10)},[]),U=c.useCallback(()=>{_&&(P(!1),O.current=!1,S==null||S(),setTimeout(()=>{O.current||Y(!1)},120))},[_,S]),N=c.useRef(null),F=c.useRef(null);h.useOnClickOutside(N,U),c.useLayoutEffect(()=>{var be,De;const W=(be=F.current)==null?void 0:be.offsetWidth,z=(De=F.current)==null?void 0:De.offsetHeight;W!=null&&z!=null&&(H.height!==z||H.width!==W)&&q({width:W,height:z})},[H.height,H.width]);const K=Et(e,t,s,a,l),{visiblePanel:J,visibleMonth:ne,onValueChangeByInputs:Q,setVisibleMonth:$,setVisiblePanel:ge,monthPickerButtonRef:xe}=K,_e=c.useCallback(W=>{W.key==="Escape"&&U()},[U]);return o.jsxs(h.Box,{position:"relative",className:Fe.travelDateRangeInput,ref:N,onKeyDown:_e,height:H.height,width:H.width,children:[o.jsx(h.Box,{position:"absolute",ref:F,zIndex:_?y:w,children:o.jsx(Bt,{...K,value:e,onValueChange:Q,localeCode:s,startDateLabel:n,endDateLabel:r,onFocus:v,calendarSize:E,placeholderWhenBlurredStartDate:m,placeholderWhenBlurredEndDate:f,variant:L})}),_&&o.jsx(h.Box,{position:"absolute",zIndex:y-1,left:"-2.4rem",top:g?"-8.0rem":"-2.4rem",className:ce(Fe.overlay,R&&Fe.calendarVisible),children:o.jsx(h.Box,{background:"white",shadow:"popover",borderRadius:"var(--swui-border-radius-large)",children:o.jsxs(M.CardBody,{gap:3,children:[g&&o.jsx(h.Heading,{variant:"h2",as:b,children:g}),o.jsx(h.Box,{height:G}),o.jsx(Ae,{...K,previousMonthButtonAriaLabel:i,nextMonthButtonAriaLabel:u,calendarSize:E,prevMonthDisabled:p,nextMonthDisabled:j,previousMonthButtonTestId:B,nextMonthButtonTestId:I}),J==="calendar"&&o.jsx(Le,{...K,size:E,multiSelectable:!0,isDateDisabled:D,dateTestId:C}),J==="month-picker"&&o.jsx(he,{firstMonth:k,numMonths:x,value:ne,size:E,localeCode:s,onValueChange:W=>{var z;$(W),ge("calendar"),(z=xe.current)==null||z.focus()},onCancel:()=>{var W;ge("calendar"),(W=xe.current)==null||W.focus()}}),T==null?void 0:T({hideCalendar:U})]})})})]})},Tr="_travelDateInput_hmfbf_1",Cr="_overlay_hmfbf_2",Ir="_calendarVisible_hmfbf_6",We={travelDateInput:Tr,overlay:Cr,calendarVisible:Ir},At=({value:e,onValueChange:t,label:n="Date",localeCode:r,onFocus:s,calendarSize:a,placeholderWhenBlurred:l,valueWhenBlurred:i,variant:u})=>{const{mask:m,placeholder:f}=c.useMemo(()=>{const g=de(r);return{mask:It(g),placeholder:g.toLowerCase()}},[r]);return o.jsx(h.Row,{children:o.jsx($e,{mask:m,value:e,onValueChange:t,onBlur:g=>{const b=Ce(g.target.value,r);b&&b!==e&&(t==null||t(b))},onFocus:s,label:n,placeholder:f,calendarSize:a,placeholderWhenBlurred:l,valueWhenBlurred:i,variant:u})})},Lt=(e,t,n,r,s,a)=>{const l=ie(r),i=c.useId(),u=h.useToday(),m=c.useRef(null),f=c.useMemo(()=>de(n),[n]),g=c.useMemo(()=>(e==null?void 0:e.length)===f.length?se(e,n):void 0,[f.length,n,e]),b=c.useMemo(()=>g!=null?Ue(g,u,l):void 0,[l,g,u]),[x,D]=c.useState(s??g??new Date),p=c.useCallback(I=>{d.isSameMonth(I,u)||d.isAfter(I,u)?D(I):D(u)},[u]),j=c.useMemo(()=>pe(x.getFullYear(),x.getMonth(),l),[l,x]),k=c.useMemo(()=>Ie(d.intlFormat(x,{month:"long",year:"numeric"},{locale:l.code})),[l,x]),y=c.useMemo(()=>d.isSameMonth(u,x),[u,x]),[w,S]=c.useState(),[T,E]=c.useState("calendar"),C=c.useCallback(I=>{const L=(I==null?void 0:I.length)===f.length?se(I,n):void 0;L&&p(L),t==null||t(I)},[f.length,n,t,p]);return{onClickDate:I=>{t==null||t(ue(I,n)),a==null||a(I)},onValueChangeByInputs:C,monthPickerButtonRef:m,calendarId:i,monthPickerButtonLabel:k,visiblePanel:T,setVisiblePanel:E,setVisibleMonth:D,visibleMonthData:j,todayIsInVisibleMonth:y,hoverDate:w,setHoverDate:S,selectedDate:g,today:u,visibleMonth:x,valueWhenBlurred:b}},Br=({value:e,onValueChange:t,label:n,localeCode:r="sv",languageLocaleCode:s=r,initialMonthInFocus:a,previousMonthButtonAriaLabel:l="Previous month",nextMonthButtonAriaLabel:i="Next month",placeholderWhenBlurred:u,heading:m,headingLevel:f,numMonthsInMonthPicker:g=12,isDateDisabled:b,prevMonthDisabled:x,nextMonthDisabled:D,firstMonthInMonthPicker:p=new Date,zIndex:j=1e3,zIndexWhenClosed:k,onHideCalendar:y,renderBelowCalendar:w,size:S="medium",dateTestId:T,previousMonthButtonTestId:E,nextMonthButtonTestId:C,textInputVariant:B="standard"})=>{const[I,L]=c.useState(!1),[R,P]=c.useState(!1),[_,Y]=c.useState({width:336,height:66}),H=S==="large"?"8.8rem":"6.6rem",q=c.useRef(!1),G=c.useCallback(()=>{q.current=!0,P(!0),setTimeout(()=>{L(!0)},10)},[]),O=c.useCallback(()=>{R&&(L(!1),q.current=!1,y==null||y(),setTimeout(()=>{q.current||P(!1)},120))},[R,y]),v=c.useCallback(()=>{setTimeout(()=>{O()},250)},[O]),U=c.useRef(null),N=c.useRef(null);h.useOnClickOutside(U,O),c.useLayoutEffect(()=>{var be,De;const W=(be=N.current)==null?void 0:be.offsetWidth,z=(De=N.current)==null?void 0:De.offsetHeight;W!=null&&z!=null&&(_.height!==z||_.width!==W)&&Y({width:W,height:z})},[_.height,_.width]);const F=Lt(e,t,r,s,a,v),{visiblePanel:K,visibleMonth:J,onValueChangeByInputs:ne,selectedDate:Q,setVisibleMonth:$,setVisiblePanel:ge,monthPickerButtonRef:xe}=F,_e=c.useCallback(W=>{W.key==="Escape"&&O()},[O]);return o.jsxs(h.Box,{position:"relative",className:We.travelDateInput,ref:U,onKeyDown:_e,height:_.height,width:_.width,children:[o.jsx(h.Box,{position:"absolute",ref:N,zIndex:R?j:k,children:o.jsx(At,{...F,value:e,onValueChange:ne,localeCode:r,label:n,onFocus:G,calendarSize:S,placeholderWhenBlurred:u,variant:B})}),R&&o.jsx(h.Box,{position:"absolute",zIndex:j-1,left:"-2.4rem",top:m?"-8.0rem":"-2.4rem",className:ce(We.overlay,I&&We.calendarVisible),children:o.jsx(h.Box,{background:"white",shadow:"popover",borderRadius:"var(--swui-border-radius-large)",children:o.jsxs(M.CardBody,{gap:3,children:[m&&o.jsx(h.Heading,{variant:"h2",as:f,children:m}),o.jsx(h.Box,{height:H}),o.jsx(Ae,{...F,previousMonthButtonAriaLabel:l,nextMonthButtonAriaLabel:i,calendarSize:S,prevMonthDisabled:x,nextMonthDisabled:D,previousMonthButtonTestId:E,nextMonthButtonTestId:C}),K==="calendar"&&o.jsx(Le,{...F,size:S,isValidDateRange:!!Q,selectedStartDate:Q,selectedEndDate:Q,multiSelectable:!1,isDateDisabled:b,dateTestId:T}),K==="month-picker"&&o.jsx(he,{firstMonth:p,numMonths:g,value:J,size:S,localeCode:r,onValueChange:W=>{var z;$(W),ge("calendar"),(z=xe.current)==null||z.focus()},onCancel:()=>{var W;ge("calendar"),(W=xe.current)==null||W.focus()}}),w==null?void 0:w({hideCalendar:O})]})})})]})},Er=({value:e,onValueChange:t,label:n,localeCode:r="sv",languageLocaleCode:s=r,initialMonthInFocus:a,previousMonthButtonAriaLabel:l="Previous month",nextMonthButtonAriaLabel:i="Next month",placeholderWhenBlurred:u,heading:m,headingLevel:f,numMonthsInMonthPicker:g=12,isDateDisabled:b,prevMonthDisabled:x,nextMonthDisabled:D,firstMonthInMonthPicker:p=new Date,dateTestId:j,size:k="medium",previousMonthButtonTestId:y,nextMonthButtonTestId:w,textInputVariant:S="standard"})=>{const T=Lt(e,t,r,s,a),{visiblePanel:E,visibleMonth:C,onValueChangeByInputs:B,setVisibleMonth:I,setVisiblePanel:L,monthPickerButtonRef:R,selectedDate:P}=T;return o.jsxs(h.Column,{gap:3,children:[m&&o.jsx(h.Heading,{variant:"h2",as:f,children:m}),o.jsx(At,{...T,value:e,onValueChange:B,localeCode:r,label:n,calendarSize:k,placeholderWhenBlurred:u,variant:S}),o.jsx(Ae,{...T,previousMonthButtonAriaLabel:l,nextMonthButtonAriaLabel:i,calendarSize:k,prevMonthDisabled:x,nextMonthDisabled:D,previousMonthButtonTestId:y,nextMonthButtonTestId:w}),E==="calendar"&&o.jsx(Le,{...T,size:k,selectedStartDate:P,selectedEndDate:P,isValidDateRange:!!P,isDateDisabled:b,multiSelectable:!1,dateTestId:j}),E==="month-picker"&&o.jsx(he,{firstMonth:p,numMonths:g,value:C,localeCode:s,size:k,onValueChange:_=>{var Y;I(_),L("calendar"),(Y=R.current)==null||Y.focus()},onCancel:()=>{var _;L("calendar"),(_=R.current)==null||_.focus()}})]})},Ar=({value:e,onValueChange:t,startDateLabel:n,endDateLabel:r,localeCode:s="sv",languageLocaleCode:a=s,initialMonthInFocus:l,previousMonthButtonAriaLabel:i="Previous month",nextMonthButtonAriaLabel:u="Next month",heading:m,headingLevel:f,numMonthsInMonthPicker:g=12,isDateDisabled:b,prevMonthDisabled:x,nextMonthDisabled:D,firstMonthInMonthPicker:p=new Date,size:j="medium",dateTestId:k,previousMonthButtonTestId:y,nextMonthButtonTestId:w,placeholderWhenBlurredStartDate:S,placeholderWhenBlurredEndDate:T,textInputVariant:E="standard"})=>{const C=Et(e,t,s,a,l),{visiblePanel:B,visibleMonth:I,onValueChangeByInputs:L,setVisibleMonth:R,setVisiblePanel:P,monthPickerButtonRef:_}=C;return o.jsxs(h.Column,{gap:3,children:[m&&o.jsx(h.Heading,{variant:"h2",as:f,children:m}),o.jsx(Bt,{...C,value:e,onValueChange:L,localeCode:s,startDateLabel:n,endDateLabel:r,calendarSize:j,placeholderWhenBlurredStartDate:S,placeholderWhenBlurredEndDate:T,variant:E}),o.jsx(Ae,{...C,previousMonthButtonAriaLabel:i,nextMonthButtonAriaLabel:u,calendarSize:j,prevMonthDisabled:x,nextMonthDisabled:D,previousMonthButtonTestId:y,nextMonthButtonTestId:w}),B==="calendar"&&o.jsx(Le,{...C,size:j,multiSelectable:!0,isDateDisabled:b,dateTestId:k}),B==="month-picker"&&o.jsx(he,{firstMonth:p,numMonths:g,value:I,size:j,localeCode:a,onValueChange:Y=>{var H;R(Y),P("calendar"),(H=_.current)==null||H.focus()},onCancel:()=>{var Y;P("calendar"),(Y=_.current)==null||Y.focus()}})]})},Lr=()=>{const e=h.useToday();return c.useCallback(t=>!d.isSameDay(t,e)&&d.isBefore(t,e),[e])},_r=()=>{const e=h.useToday();return c.useCallback(t=>d.isSameMonth(e,t)||d.isBefore(t,e),[e])};exports.Calendar=Me;exports.CalendarDay=Ge;exports.DateInput=Dn;exports.DateRangeCalendar=mn;exports.DateRangeDualTextInput=Kn;exports.DateRangeInput=pn;exports.DateTextInput=wn;exports.DateTimeInput=Yn;exports.Month=ot;exports.MonthPicker=he;exports.MultiDateCalendar=gn;exports.PresetPicker=pt;exports.SingleDateCalendar=ve;exports.SingleWeekCalendar=xn;exports.TimeTextInput=kn;exports.TravelDateCalendar=Er;exports.TravelDateInput=Br;exports.TravelDateRangeCalendar=Ar;exports.TravelDateRangeInput=Rr;exports.WeekDay=ct;exports.WeekDayCell=gt;exports.WeekNumberCell=xt;exports.YearPicker=Wn;exports.addDayStateHighlights=ee;exports.addDayStateHighlightsOnSingleDay=ze;exports.addWeekRangeHighlights=at;exports.addWeekStateHighlights=Ft;exports.buildDayStateForDateRange=fe;exports.buildDayStateForRange=st;exports.buildDayStateForSingleMonth=rt;exports.calculateOverflowingMonth=ut;exports.createDay=lt;exports.dateRangeToStrings=wt;exports.dayHasHighlight=ft;exports.dayHighlightSelect=V;exports.defaultCalendarTheme=oe;exports.defaultTextPropsProvider=ht;exports.defaultWrapperStyleProvider=mt;exports.extranetCalendarTheme=$t;exports.fallbackLocaleCode=Je;exports.fallbackLocaleCodeForFormatting=vt;exports.formatLocalizedDate=ue;exports.getDateFormatForLocaleCode=de;exports.getDaysForWeekForDate=dt;exports.getDefaultLocaleForFormatting=Vt;exports.getLocaleCodeForLocale=yt;exports.getLocaleForLocaleCode=ie;exports.getMonthInYear=pe;exports.getMonthsInYear=He;exports.getSupportedLocaleCode=Ze;exports.getSupportedLocaleCodeMatchingLanguage=Dt;exports.getWeekForDate=Be;exports.getWeeksForMonth=it;exports.isDateRangeInvalid=Qe;exports.parseLocalizedDateString=se;exports.reformatLocalizedDateString=Ce;exports.setDayStateValue=Pt;exports.setDayStateValueFunction=Yt;exports.stringsToDateRange=St;exports.toggleDateStringsIfEndIsEarlierThanStart=un;exports.toggleDatesIfEndIsEarlierThanStart=Xe;exports.useDateRangeCalendarState=hn;exports.useDateRangeSelection=kt;exports.useDisabledBeforeToday=Lr;exports.useMultiDateSelection=Mt;exports.usePrevMonthDisabledBeforeToday=_r;exports.useSingleDateSelection=jt;exports.useSingleWeekSelection=Rt;
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._calendar_hknk7_1{--swui-calendar-day-width: 48px;--swui-calendar-day-height: 48px;--swui-calendar-day-border-radius: var(--swui-max-border-radius);--swui-calendar-week-number-bg-color: transparent;--swui-calendar-week-number-text-color: var(--lhds-color-ui-500);--swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-wrapper-selected-border: var(--modern-blue);--swui-calendar-wrapper-selected-background: var(--modern-blue);--swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);--swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);--swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);--swui-calendar-wrapper-today-background: var(--lhds-color-ui-50);--swui-calendar-text-selected-color: #fff;--swui-calendar-text-disabled-color: var(--swui-text-disabled-color);--swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color)}._calendar_hknk7_1 table{border-spacing:0 4px}._calendar_hknk7_1 tr td:last-child{border-top-right-radius:var(--swui-calendar-day-border-radius);border-bottom-right-radius:var(--swui-calendar-day-border-radius)}._calendar_hknk7_1._weekNumberVisible_hknk7_41 tr td:nth-child(2),._calendar_hknk7_1:not(._weekNumberVisible_hknk7_41) tr td:first-child{border-top-left-radius:var(--swui-calendar-day-border-radius);border-bottom-left-radius:var(--swui-calendar-day-border-radius)}._calendar_hknk7_1 td{padding:0;width:var(--swui-calendar-day-width);height:var(--swui-calendar-day-height)}._timePicker_1w05d_1{overflow:hidden;width:180px}._timePickerColumn_1w05d_6{overflow-y:hidden;flex:1}._timePickerColumn_1w05d_6:hover{overflow-y:scroll}._travelDateCell_1t2af_1{position:relative}._travelDateCell_1t2af_1._smaller_1t2af_4{width:40px;height:40px}._travelDateCell_1t2af_1._small_1t2af_4{width:44px;height:44px}._travelDateCell_1t2af_1._medium_1t2af_14{width:48px;height:48px}._travelDateCell_1t2af_1._large_1t2af_19{width:56px;height:28px}._travelDateCell_1t2af_1{border-radius:var(--swui-max-border-radius)}._travelDateCell_1t2af_1:focus{outline:none}._travelDateCell_1t2af_1:focus-visible ._outline_1t2af_31{outline:var(--swui-focus-outline);outline-width:var(--swui-focus-outline-width);background:transparent;position:absolute;border-radius:var(--swui-max-border-radius);inset:0;z-index:10}._travelDateCell_1t2af_1:focus-visible ._contentWrapper_1t2af_44._contentWrapper_1t2af_44._contentWrapper_1t2af_44{border-color:transparent}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44{cursor:pointer;border-radius:var(--swui-max-border-radius);border-width:2px;border-style:solid;border-color:transparent;background:transparent;position:absolute;display:flex;align-items:center;justify-content:center;inset:0}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._disabled_1t2af_65{cursor:not-allowed}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isToday_1t2af_68{border-color:var(--lhds-color-ui-400)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72,._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionEnd_1t2af_73{border-color:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72{background:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionStart_1t2af_72 span{color:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._isSelectionEnd_1t2af_73:not(._isSelectionStart_1t2af_72){background:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88{border-color:var(--selection-background-color)}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88._startSelected_1t2af_91:not(._endSelected_1t2af_91):not(._isSelectionStart_1t2af_72){background:#fff}._travelDateCell_1t2af_1 ._contentWrapper_1t2af_44._hover_1t2af_88._startSelected_1t2af_91:not(._endSelected_1t2af_91):not(._isSelectionStart_1t2af_72) span{color:var(--swui-text-primary-color)}._travelDateCellBackground_45q5d_1._smaller_45q5d_2{width:20px;height:40px}._travelDateCellBackground_45q5d_1._small_45q5d_2{width:22px;height:44px}._travelDateCellBackground_45q5d_1._medium_45q5d_12{width:24px;height:48px}._travelDateCellBackground_45q5d_1._large_45q5d_17{width:28px;height:56px}._travelCalendar_ib2y4_1{border-spacing:0 4px;width:-webkit-fit-content;width:fit-content;--selection-background-color: var( --travel-calendar-selection-background-color, var(--modern-blue) );--selection-range-background-color: var( --travel-calendar-selection-range-background-color, var(--himmel) )}._travelCalendar_ib2y4_1 td{padding:0}._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2{transition:opacity var(--swui-animation-time-fast) ease-in-out;opacity:1}._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2:not(._travelDateRangeInput_1j7rp_1 ._overlay_1j7rp_2._calendarVisible_1j7rp_6){opacity:0}._travelDateInput_hmfbf_1 ._overlay_hmfbf_2{transition:opacity var(--swui-animation-time-fast) ease-in-out;opacity:1}._travelDateInput_hmfbf_1 ._overlay_hmfbf_2:not(._travelDateInput_hmfbf_1 ._overlay_hmfbf_2._calendarVisible_hmfbf_6){opacity:0}")),document.head.appendChild(e)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),g=require("@stenajs-webui/core"),j=require("@stenajs-webui/elements"),u=require("date-fns"),B=require("date-fns/locale"),se=require("lodash-es"),l=require("react"),le=require("classnames"),Le=require("@emotion/styled"),J=require("@stenajs-webui/forms"),xe=require("@stenajs-webui/tooltip"),Oe=require("@stenajs-webui/theme"),Et=require("@stenajs-webui/input-mask");function Lt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $e=Lt(l),ee={yearAndMonth:"yyyy-MM",fullDate:"yyyy-MM-dd",fullMonthName:"LLLL"},fe=(e={},t,n)=>{if(t&&n&&u.isAfter(n,t))return u.eachDayOfInterval({start:t,end:n}).reduce((s,a)=>{const i=u.isSameDay(a,t),c=u.isSameDay(a,n);return X(s,a,i?["selected","selectedStart","range"]:c?["selected","selectedEnd","range"]:["range"])},e);let r=e;return t&&(r=X(r,t,["selected","singleSelected"])),n&&(r=X(r,n,["selected","singleSelected"])),r},tt=(e={},t,n,r)=>nt(e,t,n,u.startOfMonth(r),u.endOfMonth(r)),nt=(e={},t,n,r,s)=>t&&n?fe(e,u.max([t,u.subDays(r,1)]),u.min([n,u.addDays(s,1)])):fe(e,t,n),At=(e,t,n)=>{const r=u.format(t,ee.yearAndMonth),s=u.getISOWeek(t),a=u.getDate(t);return{...e,[r]:{...e&&e[r],[s]:{...e&&e[r]&&e[r][s],[a]:{...e&&e[r]&&e[r][s]&&e[r][s][a],...n}}}}},_t=(e,t,n)=>{const r=u.format(t,ee.yearAndMonth),s=u.getISOWeek(t),a=u.getDate(t);return{...e,[r]:{...e&&e[r],[s]:{...e&&e[r]&&e[r][s],[a]:{...e&&e[r]&&e[r][s]&&e[r][s][a],...n(e&&e[r]&&e[r][s]&&e[r][s][a])}}}}},X=(e,t,n)=>{const r=t.getMonth()+1,s=`${t.getFullYear()}-${r<10?"0":""}${r}`,a=u.getISOWeek(t),i=u.getDate(t),c=e&&e[s]&&e[s][a]&&e[s][a][i];return{...e,[s]:{...e&&e[s],[a]:{...e&&e[s]&&e[s][a],[i]:Ue(c,n)}}}},Ue=(e,t)=>({...e,highlights:[...e?.highlights??[],...t]}),Pt=(e,t,n)=>{const r=t.days[0].date,s=r.getMonth()+1,a=`${r.getFullYear()}-${s<10?"0":""}${s}`,i=t.weekNumber;let c=e;t.days.forEach(m=>{c=X(c,m.date,n)});const d=c&&c[a]?c[a][i]:void 0,h=d&&d.highlights?[...d.highlights,...n]:n,f={...d,highlights:h};return{...c,[a]:{...e&&e[a],[i]:f}}},rt=(e,t)=>{if(!t.days.length)return{...e};const n=t.days[0].date,r=se.last(t.days)?.date;return{...fe(e,n,r)}},Nt=(e,t)=>l.useMemo(()=>e?X(t,new Date,["today"]):t,[e,t]),ve=e=>e.length===0?e:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1);var st=(e=>(e[e.JANUARY=0]="JANUARY",e[e.FEBRUARY=1]="FEBRUARY",e[e.MARCH=2]="MARCH",e[e.APRIL=3]="APRIL",e[e.MAY=4]="MAY",e[e.JUNE=5]="JUNE",e[e.JULY=6]="JULY",e[e.AUGUST=7]="AUGUST",e[e.SEPTEMBER=8]="SEPTEMBER",e[e.OCTOBER=9]="OCTOBER",e[e.NOVEMBER=10]="NOVEMBER",e[e.DECEMBER=11]="DECEMBER",e))(st||{}),at=(e=>(e[e.SUNDAY=0]="SUNDAY",e[e.MONDAY=1]="MONDAY",e[e.TUESDAY=2]="TUESDAY",e[e.WEDNESDAY=3]="WEDNESDAY",e[e.THURSDAY=4]="THURSDAY",e[e.FRIDAY=5]="FRIDAY",e[e.SATURDAY=6]="SATURDAY",e))(at||{});const Fe=(e,t,n,r)=>{const s=[];for(let a=0;a<n;a++)s.push(be(e,t+a,r));return s},be=(e,t,n)=>{if(isNaN(e)||isNaN(t))throw new Error("getMonthInYear() received NaN.");const r=e+Math.floor(t/12),s=t%12,a=new Date(r,s,1);return{monthString:u.format(a,ee.yearAndMonth),name:ve(u.format(a,ee.fullMonthName,{locale:n})),year:r,monthInYear:s,weeks:ot(r,s,n)}},ot=(e,t,n,r=!0)=>{const s=new Date(e,t,1),a=u.startOfWeek(s,{locale:n}),i=[];for(let c=0;c<6;c++){const d=Re(u.addWeeks(a,c),n);if(c>0&&d.startMonth!==t&&!r)return i;i.push(d)}return i},Re=(e,t)=>{const n=u.getMonth(u.addDays(e,7))!==u.getMonth(e);return{weekNumber:u.getWeek(e,{locale:t}),startMonth:u.getMonth(e),startYear:u.getYear(e),endMonth:u.getMonth(u.addDays(e,6)),endYear:u.getYear(u.addDays(e,6)),days:ct(e,t),isLastWeekOfMonth:n}},lt=(e,t)=>{const n=u.getISODay(e);return{date:e,name:u.format(e,"EEE",t?{locale:t}:void 0),fullName:u.format(e,"EEEE",t?{locale:t}:void 0),dateString:u.format(u.addHours(e,12),ee.fullDate),weekNumber:u.getWeek(e,{locale:t}),year:u.getYear(e),month:u.getMonth(e),dayOfMonth:u.getDate(e),dayOfWeek:n,isFirstDayOfWeek:n===1,isLastDayOfWeek:n===7,isFirstDayOfMonth:u.isSameDay(u.startOfMonth(e),e),isLastDayOfMonth:u.isSameDay(u.endOfMonth(e),e)}},ct=(e,t)=>u.eachDayOfInterval({start:e,end:u.addDays(e,6)}).map(n=>lt(n,t)),it=(e,t)=>t>11?{year:e+Math.floor(t/12),month:t%12}:t<0?{year:e+Math.floor(t/12),month:12+t%12}:{year:e,month:t},Ft="_calendar_hknk7_1",Yt="_weekNumberVisible_hknk7_41",Ze={calendar:Ft,weekNumberVisible:Yt},ut=(e,t,n)=>!!(t&&t.indexOf(n)>=0||e&&e.highlights&&e.highlights.indexOf(n)>=0),Q=(e,t,n,r,s)=>{if(n.length!==r.length)throw new Error("Select highlight failed, number of values do not equal number of highlights.");if(n.length===0)return s;for(let a=0;a<n.length;a++)if(typeof n[a]=="boolean"&&n[a]||typeof n[a]=="string"&&ut(e,t,n[a]))return r[a];return s},dt=({selectedBackground:e,todayBackground:t,rangeBackground:n,borderColor:r="transparent"})=>(s,a,i,c,d)=>({backgroundColor:Q(a,s,["selected","range","today",i.month===d.monthInYear],[e,n,t,"#fff"],"transparent"),borderWidth:"1px",borderStyle:"solid",borderColor:Q(a,s,["selectedStart","selectedEnd","singleSelected","range","today"],["var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-background)","var(--swui-calendar-wrapper-range-border)","var(--lhds-color-ui-500)"],r),borderTopLeftRadius:Q(a,s,["selectedStart","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderBottomLeftRadius:Q(a,s,["selectedStart","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderTopRightRadius:Q(a,s,["selectedEnd","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),borderBottomRightRadius:Q(a,s,["selectedEnd","singleSelected","today"],["var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)","var(--swui-calendar-day-border-radius)"],"unset"),boxSizing:"border-box"}),ft=({selectedColor:e,disabledColor:t,inOtherMonthColor:n,rangeTextColor:r})=>(s,a,i,c,d)=>{const h=i.month!==d.monthInYear;return{color:Q(a,s,[h,"selected","range","enabled","disabled"],[n,e,r,void 0,t])}},ae={width:"var(--swui-calendar-day-width)",height:"var(--swui-calendar-day-height)",WeekNumber:{backgroundColor:"var(--swui-calendar-week-number-bg-color)",textColor:"var(--swui-calendar-week-number-text-color)",clickableTextColor:"var(--swui-calendar-week-number-clickable-text-color)"},WeekDay:{textColor:"var(--swui-calendar-week-day-text-color)",clickableTextColor:"var(--swui-calendar-week-day-clickable-text-color)"},CalendarDay:{tdStyle:dt({selectedBackground:"var(--swui-calendar-wrapper-selected-background)",rangeBackground:"var(--swui-calendar-wrapper-range-background)",todayBackground:"var(--swui-calendar-wrapper-today-background)"}),textProps:ft({selectedColor:"var(--swui-calendar-text-selected-color)",disabledColor:"var(--swui-calendar-text-disabled-color)",inOtherMonthColor:"var(--swui-calendar-text-in-other-month-color)"})},CalendarMonth:{headerTextColor:"var(--swui-calendar-week-day-text-color)"}},Ht={...ae,width:"37px",height:"37px"},ht=({onClickWeekDay:e,day:t,theme:n})=>{const r=o.jsx(g.Box,{width:n.width,height:n.height,justifyContent:"center",alignItems:"center",children:o.jsx(g.Text,{size:"small",color:e?n.WeekDay.clickableTextColor:n.WeekDay.textColor,children:t.name})});return e?o.jsx(g.Clickable,{borderRadius:"var(--swui-calendar-day-border-radius)",onClick:s=>e(t.dayOfWeek,s),disableFocusHighlight:!e,children:r}):r},Ve=function({day:t,week:n,month:r,dayState:s,userData:a,onClickDay:i,theme:c,extraDayContent:d,defaultHighlights:h,showDatesInOtherMonths:f}){const m=o.jsx(g.Box,{width:"100%",height:"100%",justifyContent:"center",alignItems:"center",children:o.jsx(g.Text,{...c.CalendarDay.textProps&&c.CalendarDay.textProps(h,s,t,n,r,a),children:t.dayOfMonth})}),D=Le.td({...c.CalendarDay.tdStyle&&c.CalendarDay.tdStyle(h,s,t,n,r,a)}),x=Le.div({...c.CalendarDay.innerWrapperStyle&&c.CalendarDay.innerWrapperStyle(h,s,t,n,r,a),width:"100%",height:"100%"}),b=Le.div({...c.CalendarDay.cellWrapperStyle&&c.CalendarDay.cellWrapperStyle(h,s,t,n,r,a),width:"100%",height:"100%",position:"relative"}),C=Wt(h,s);return o.jsx(D,{onClick:C?void 0:w=>i?.(t,a,w),children:o.jsx(x,{children:o.jsx(b,{children:(t.month===r.monthInYear||f)&&o.jsxs(o.Fragment,{children:[d&&o.jsx(d,{week:n,month:r,day:t,dayState:s,theme:c,userData:a}),m]})})})})},Wt=(e,t)=>!!Q(t,e,["enabled","disabled"],[!1,!0],!1),gt=({onClickWeek:e,theme:t,week:n,background:r,backgroundColor:s,prefix:a})=>{const i=o.jsxs(g.Box,{width:t.width,height:t.height,justifyContent:"center",alignItems:"center",children:[r&&o.jsx(g.Box,{position:"absolute",children:r}),o.jsx(g.Box,{position:"absolute",children:o.jsxs(g.Text,{color:e?t.WeekNumber.clickableTextColor:t.WeekNumber.textColor,children:[a,n.weekNumber]})})]});return o.jsx(g.Box,{background:s||t.WeekNumber.backgroundColor,position:"relative",children:e?o.jsx(g.Clickable,{borderRadius:"var(--swui-calendar-day-border-radius)",onClick:c=>e(n,c),disableFocusHighlight:!e,children:i}):i})},Ot=(e,t,n)=>t&&u.isBefore(e,t)?u.isSameDay(e,t):n&&u.isAfter(e,n)?u.isSameDay(e,n):!0,$t=function({dayComponent:t,minDate:n,maxDate:r,dayState:s,day:a,...i}){const c=l.useMemo(()=>Ot(a.date,n,r)?s:Ue(s,["disabled"]),[a.date,s,r,n]);return o.jsx(t,{day:a,...i,dayState:c})};function Ut({month:e,dayComponent:t=Ve,statePerWeek:n,userDataPerWeek:r,minDate:s,maxDate:a,onClickDay:i,onClickWeek:c,onClickWeekDay:d,onClickMonth:h,renderWeekNumber:f,renderWeekDay:m,headerRightContent:D,theme:x=ae,extraDayContent:b,defaultHighlights:C,showWeekNumber:w}){return o.jsx(o.Fragment,{children:o.jsxs(g.Box,{alignItems:"stretch",children:[o.jsxs(g.Row,{justifyContent:D?"space-between":"center",alignItems:"center",children:[o.jsx(g.Row,{justifyContent:"center",alignItems:"center",children:h?o.jsx(j.FlatButton,{onClick:()=>h(e),label:e.name+" "+String(e.year),rightIcon:j.stenaAngleDown}):o.jsxs(g.Text,{whiteSpace:"nowrap",children:[e.name," ",e.year]})}),D&&o.jsx(g.Box,{alignItems:"center",children:D})]}),o.jsx("table",{children:o.jsxs("tbody",{children:[o.jsxs("tr",{children:[w&&o.jsx("td",{children:o.jsx(g.Box,{width:x.width,height:x.height})}),e.weeks[0].days.map(S=>o.jsx("td",{children:m?m(S.name,x,d):o.jsx(ht,{day:S,onClickWeekDay:d,theme:x})},S.name))]}),e.weeks.map(S=>o.jsxs("tr",{children:[w&&o.jsx("td",{children:f?f(S,x,c):o.jsx(gt,{week:S,onClickWeek:c,theme:x})}),S.days.map(p=>o.jsx($t,{dayComponent:t,day:p,week:S,month:e,dayState:n&&n[S.weekNumber]&&n[S.weekNumber][p.dayOfMonth],userData:r&&r[S.weekNumber]&&r[S.weekNumber][p.dayOfMonth],onClickDay:i,theme:x,extraDayContent:b,defaultHighlights:C,minDate:s,maxDate:a},p.dateString))]},S.weekNumber))]})})]})})}function Vt({monthRows:e,dayComponent:t=Ve,userDataPerMonth:n,statePerMonth:r,minDate:s,maxDate:a,onClickDay:i,onClickWeekDay:c,onClickWeek:d,onClickMonth:h,renderWeekDay:f,renderWeekNumber:m,headerRightContent:D,extraDayContent:x,defaultHighlights:b,showWeekNumber:C,theme:w=ae}){const S=l.useMemo(()=>s?u.parse(s,"yyyy-MM-dd",new Date):void 0,[s]),p=l.useMemo(()=>a?u.parse(a,"yyyy-MM-dd",new Date):void 0,[a]);return o.jsx("div",{className:le(Ze.calendar,C&&Ze.weekNumberVisible),children:e.map((y,k)=>o.jsx(g.Spacing,{children:o.jsx(g.Row,{gap:2,children:y.map(M=>o.jsx(Ut,{month:M,dayComponent:t,userDataPerWeek:n&&n[M.monthString],statePerWeek:r&&r[M.monthString],onClickDay:i,onClickWeekDay:c,onClickWeek:d,onClickMonth:h,theme:w,renderWeekNumber:m,renderWeekDay:f,headerRightContent:D,extraDayContent:x,defaultHighlights:b,minDate:S,maxDate:p,showWeekNumber:C??!1},M.name))})},k))})}function Se(e){const t=qt(e.year,e.month,e.date),{year:n,month:r}=it(t.year,t.month),s=Kt(n,r,e.locale??B.enGB,e.numMonths,e.monthsPerRow),a=Nt(e.highlightToday,e.statePerMonth);return o.jsx(Vt,{year:n,month:r,monthRows:s,...e,statePerMonth:a})}const qt=(e,t,n)=>{if(t&&e)return{month:t,year:e};if(n)return{month:u.getMonth(n),year:u.getYear(n)};const r=new Date;return{month:u.getMonth(r),year:u.getYear(r)}},Kt=(e,t,n,r,s)=>r==null?[[be(e,t,n)]]:s==null?[Fe(e,t,r,n)]:se.chunk(Fe(e,t,r,n),s),mt=(e,t)=>`${e.row}-${e.column}-${t}`,zt=(e,t,n,r)=>{let s=t;for(let a=0;a<r;a++){s=Gt(s,e,r);const i=mt(s,n);if(document.getElementById(i))return i}},Gt=(e,t,n)=>{let r=e.row,s=e.column;return t==="ArrowLeft"?s--:t==="ArrowUp"?r--:t==="ArrowRight"?s++:t==="ArrowDown"&&r++,s<0&&(s=n-1,r--),s>n-1&&(s=0,r++),{column:s,row:r}},he={en:B.enGB,"en-US":B.enUS,"en-GB":B.enGB,"en-IE":B.enIE,"de-AT":B.deAT,"nl-BE":B.nlBE,"nl-NL":B.nl,"de-DE":B.de,"nb-NO":B.nb,"sv-SE":B.sv,"da-DK":B.da,"lv-LV":B.lv,"lt-LT":B.lt,"it-IT":B.it,"et-EE":B.et,"fi-FI":B.fi,"cs-CZ":B.cs,"es-ES":B.es,"fr-FR":B.fr,"pl-PL":B.pl,nl:B.nl,de:B.de,nb:B.nb,sv:B.sv,da:B.da,lv:B.lv,lt:B.lt,it:B.it,et:B.et,fi:B.fi,cs:B.cs,es:B.es,fr:B.fr,pl:B.pl},qe="en-GB",Jt="sv",Ke=(e,t,n)=>{if(he[e])return e;if(t){const r=Dt(e);if(r)return r}return n},ce=e=>he[e],Dt=e=>{const[t]=e.split("-"),n=Object.keys(he);for(const r of n)if(r.startsWith(t))return r},Zt=()=>he.sv,xt=e=>{const t=Object.keys(he);for(const n of t)if(he[n].code===e.code)return n},Qt=({month:e,onClick:t,selected:n,localeCode:r,autoFocus:s,monthPickerId:a,position:i,size:c})=>{const d=l.useMemo(()=>ce(r)??ce("en-GB"),[r]),h=l.useMemo(()=>ve(u.format(e,"LLL",{locale:d})),[d,e]),f=l.useMemo(()=>u.format(e,"LLLL",{locale:d}),[d,e]),m=l.useRef(null),D=mt(i,a),x=n?0:-1;l.useEffect(()=>{m.current?.focus()},[]);const b=l.useCallback(C=>{const w=zt(C.key,i,a,4);w&&document.getElementById(w)?.focus()},[a,i]);return o.jsx(g.Row,{justifyContent:"center",onKeyDown:b,children:n?o.jsx(j.PrimaryButton,{id:D,"aria-label":f,label:h,onClick:t,"aria-selected":!0,autoFocus:s,ref:m,size:c==="large"?"large":"medium",tabIndex:x}):o.jsx(j.FlatButton,{id:D,label:h,"aria-label":f,onClick:t,size:c==="large"?"large":"medium",tabIndex:x})})},Xt=(e,t,n)=>{let r=e.getFullYear(),s=0,a=0,i=e;const c={yearOrder:[],rows:[],years:{},lastMonthColumn:-1,lastMonthRow:-1};for(let d=0;d<t;d++){if(c.years[r]==null&&(c.yearOrder.push(r),c.years[r]={year:r,rows:[]}),c.rows[s]=c.rows[s]??{columns:[],rowIndex:s},c.rows[s].columns[a]={position:{column:a,row:s},month:i},d===t-1){c.years[r].rows.push(s);break}i=u.addMonths(i,1),i.getFullYear()!==r?(c.years[r].rows.push(s),r++,a=0,s++):(a++,a>n-1&&(c.years[r].rows.push(s),a=0,s++))}return c.lastMonthColumn=a,c.lastMonthRow=s,c},ge=({value:e,onValueChange:t,firstMonth:n,localeCode:r,numMonths:s,onCancel:a,size:i="medium"})=>{const c=l.useId(),d=g.useToday(),h=s>0?s:12,[f,m]=l.useState(!1),D=Xt(n,h,tn(i)),x=l.useMemo(()=>u.addMonths(n,h),[h,n]);l.useEffect(()=>{m(!0)},[]);const b=l.useCallback(C=>{C.key==="Escape"&&(a?.(),C.preventDefault(),C.stopPropagation())},[a]);return o.jsx(g.Column,{gap:1,maxWidth:en(i),onKeyDown:b,children:D.yearOrder.map((C,w)=>{const{rows:S}=D.years[C];return o.jsxs($e.Fragment,{children:[(w!==0||C!==d.getFullYear())&&o.jsx(g.Heading,{variant:"h4",children:C}),o.jsx("table",{style:{borderSpacing:"0 8px"},children:o.jsx("tbody",{children:S.map(p=>{const{columns:y}=D.rows[p];return o.jsx("tr",{children:y.map(({month:k,position:M})=>o.jsx("td",{children:o.jsx(Qt,{month:k,firstAvailableMonth:n,lastAvailableMonth:x,localeCode:r,selected:e?u.isSameMonth(e,k):!1,autoFocus:f,onClick:()=>t?.(k),monthPickerId:c,position:M,size:i})},k.getMonth()))},p)})})})]},C)})})},en=e=>{switch(e){case"smaller":return"280px";case"small":return"308px";case"medium":return"336px";case"large":return"448px";default:return g.exhaustSwitchCase(e,"336px")}},tn=e=>{switch(e){case"smaller":case"small":return 3;case"medium":case"large":return 4;default:return g.exhaustSwitchCase(e,4)}},nn=e=>[{label:"Past",presets:[{label:"Last 3 days",startDate:e,endDate:u.subDays(e,2)},{label:"Last 7 days",startDate:e,endDate:u.subDays(e,6)},{label:"Last 30 days",startDate:e,endDate:u.subDays(e,29)},{label:"Last 45 days",startDate:e,endDate:u.subDays(e,44)}]},{label:"Future",presets:[{label:"Next 3 days",startDate:e,endDate:u.addDays(e,2)},{label:"Next 7 days",startDate:e,endDate:u.addDays(e,6)},{label:"Next 30 days",startDate:e,endDate:u.addDays(e,29)},{label:"Next 45 days",startDate:e,endDate:u.addDays(e,44)}]}],bt=({onClickPreset:e})=>{const[t,n]=l.useState(0),r=l.useMemo(()=>nn(new Date),[]),s=r[t]??r[0];return o.jsxs(g.Column,{children:[o.jsxs(g.Row,{justifyContent:"space-between",alignItems:"center",width:"200px",children:[o.jsx(j.FlatButton,{size:"small",leftIcon:j.stenaAngleLeft,disabled:t===0,onClick:()=>n(t-1)}),o.jsx(g.Text,{children:s.label}),o.jsx(j.FlatButton,{size:"small",leftIcon:j.stenaAngleRight,disabled:t===r.length-1,onClick:()=>n(t+1)})]}),o.jsx(g.Space,{}),o.jsx(g.Column,{alignItems:"center",children:s.presets.map(a=>o.jsxs($e.Fragment,{children:[o.jsx(j.PrimaryButton,{label:a.label,onClick:()=>e(a)}),o.jsx(g.Space,{})]},a.label))})]})},rn=function({locale:t,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,renderMonthPicker:i,firstMonthInMonthPicker:c,numMonthsInMonthPicker:d,...h}){const f=l.useMemo(()=>t==null?"en-GB":xt(t)??"en-GB",[t]),m=g.useToday(),D=l.useCallback(b=>{r&&r(b),a("calendar")},[r,a]),x=l.useCallback(()=>{a("month")},[a]);switch(s){case"calendar":return o.jsx(Se,{...h,date:n,onClickMonth:x,locale:t});case"month":return i?i({value:n,onValueChange:D,locale:t,firstMonth:c??m,numMonths:d??24,dateInFocus:n}):o.jsx(ge,{value:n,onValueChange:D,localeCode:f,firstMonth:c??m,numMonths:d??24});case"presets":return o.jsx(bt,{onClickPreset:()=>{}});default:return o.jsx(g.Box,{children:o.jsx(j.PrimaryButton,{label:"Show calendar",onClick:()=>a("calendar")})})}},sn=(e,t,n,r)=>{const s=l.useCallback(()=>{const d=u.addMonths(e,n??r??1);t?.(d)},[t,e,n,r]),a=l.useCallback(()=>{const d=u.addYears(e,1);t?.(d)},[t,e]),i=l.useCallback(()=>{const d=u.subMonths(e,n??r??1);t?.(d)},[t,e,n,r]),c=l.useCallback(()=>{const d=u.subYears(e,1);t?.(d)},[t,e]);return{nextMonth:s,prevMonth:i,nextYear:a,prevYear:c}},an=({children:e,prevMonth:t,nextMonth:n,prevYear:r,nextYear:s})=>o.jsxs("div",{children:[e,o.jsx(g.Indent,{children:o.jsxs(g.Row,{gap:1,children:[o.jsx(j.SecondaryButton,{onClick:r,leftIcon:j.stenaAngleLeftDouble}),o.jsx(j.SecondaryButton,{onClick:t,leftIcon:j.stenaArrowLeft}),o.jsx(g.Indent,{num:2}),o.jsx(j.SecondaryButton,{onClick:n,leftIcon:j.stenaArrowRight}),o.jsx(j.SecondaryButton,{onClick:s,leftIcon:j.stenaAngleRightDouble})]})}),o.jsx(g.Space,{})]}),on=()=>{};function ie({monthSwitcherPlacement:e,theme:t=ae,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,onSelectPreset:i=on,renderMonthPicker:c,firstMonthInMonthPicker:d,numMonthsInMonthPicker:h,...f}){const{nextMonth:m,prevMonth:D,nextYear:x,prevYear:b}=sn(n,r,f.monthsPerRow,f.numMonths);switch(ln(e,f.numMonths)){case"below":return o.jsx(an,{theme:t,nextMonth:m,prevMonth:D,nextYear:x,prevYear:b,children:o.jsx(Se,{...f,theme:t,date:n})});case"header":return o.jsx(g.Column,{children:o.jsx(rn,{...f,theme:t,renderMonthPicker:c,dateInFocus:n,setDateInFocus:r,currentPanel:s,setCurrentPanel:a,onSelectPreset:i,firstMonthInMonthPicker:d,numMonthsInMonthPicker:h,headerRightContent:o.jsxs(g.Row,{alignItems:"center",gap:1,children:[o.jsx(j.SecondaryButton,{onClick:D,leftIcon:j.stenaArrowLeft}),o.jsx(j.SecondaryButton,{onClick:m,leftIcon:j.stenaArrowRight})]})})});default:return o.jsx(Se,{...f,theme:t,date:n})}}const ln=(e,t)=>e||(t||1)>1?"below":"header",pt=e=>({startDate:e.startDate?u.format(e.startDate,"yyyy-MM-dd"):void 0,endDate:e.endDate?u.format(e.endDate,"yyyy-MM-dd"):void 0}),yt=({startDate:e,endDate:t})=>{const n=new Date;return{startDate:e?u.parse(e,"yyyy-MM-dd",n):void 0,endDate:t?u.parse(t,"yyyy-MM-dd",n):void 0}},ze=({startDate:e,endDate:t})=>!!(e&&t&&!u.isSameDay(e,t)&&u.isAfter(e,t)),Ge=e=>ze(e)?{startDate:e.endDate,endDate:e.startDate}:e,cn=e=>e.startDate&&e.endDate?pt(Ge(yt(e))):e,un=(e,t,n,r)=>l.useCallback(s=>{const a={startDate:n==="startDate"?s.date:e?.startDate,endDate:n==="endDate"?s.date:e?.endDate};ze(a)||r(n==="startDate"?"endDate":"startDate"),t?.(Ge(a))},[n,t,r,e?.endDate,e?.startDate]),Te=e=>{const[t,n]=l.useState("calendar"),r=l.useCallback(s=>{n(s),e?.(s)},[e]);return{currentPanel:t,setCurrentPanel:r}},Ct=({focusedInput:e,value:t,onValueChange:n,setFocusedInput:r,statePerMonth:s,onChangePanel:a,initialDateInFocus:i})=>{const{currentPanel:c,setCurrentPanel:d}=Te(a),[h,f]=l.useState(()=>i??new Date),m=un(t,n,e,r),D=l.useMemo(()=>fe(s,t?.startDate,t?.endDate),[s,t?.endDate,t?.startDate]);return{onClickDay:m,statePerMonth:D,currentPanel:c,setCurrentPanel:d,setDateInFocus:f,dateInFocus:h}};function dn(e){const t=Ct(e);return o.jsx(ie,{...e,...t})}const fn=()=>{const[e,t]=l.useState(),[n,r]=l.useState(),[s,a]=l.useState("startDate");return{startDate:e,setStartDate:t,endDate:n,setEndDate:r,focusedInput:s,setFocusedInput:a}},wt=({onChange:e,value:t,statePerMonth:n,onChangePanel:r})=>{const{currentPanel:s,setCurrentPanel:a}=Te(r),[i,c]=l.useState(()=>t??new Date),d=l.useCallback(f=>{e&&e(f.date)},[e]),h=l.useMemo(()=>t?X(n,t,["selected","singleSelected"]):n,[n,t]);return{onClickDay:d,statePerMonth:h,date:t,currentPanel:s,setCurrentPanel:a,dateInFocus:i,setDateInFocus:c}};function Je(e){const t=wt(e);return o.jsx(ie,{...e,...t})}const St=({onChange:e,value:t,statePerMonth:n,onChangePanel:r})=>{const{currentPanel:s,setCurrentPanel:a}=Te(r),[i,c]=l.useState(()=>new Date),d=l.useCallback(f=>{if(!e)return;const m=t&&t.find(D=>u.isSameDay(D,f.date));e(t&&m?t.filter(D=>!u.isSameDay(D,f.date)):[...t||[],f.date])},[e,t]),h=l.useMemo(()=>t?t.reduce((f,m)=>X(f,m,["selected"]),n):n,[n,t]);return{onClickDay:d,statePerMonth:h,currentPanel:s,setCurrentPanel:a,dateInFocus:i,setDateInFocus:c}};function hn(e){const t=St(e);return o.jsx(ie,{...e,...t})}const kt=({onChange:e,value:t,statePerMonth:n,onChangePanel:r,locale:s=B.enGB})=>{const[a,i]=l.useState(()=>{const x=Ae(t,s);return x?x.days[0].date:new Date}),{currentPanel:c,setCurrentPanel:d}=Te(r),h=l.useCallback(x=>{e&&e(Qe(Re(x.date,s)))},[s,e]),f=l.useCallback(x=>{e&&e(Qe(x))},[e]),m=l.useMemo(()=>{const x=Ae(t,s);return x?rt(n,x):n},[t,s,n]),D=l.useMemo(()=>{const x=Ae(t,s);return x?x.days[0].date:new Date},[s,t]);return{statePerMonth:m,date:D,dateInFocus:a,setDateInFocus:i,onClickDay:h,onClickWeek:f,currentPanel:c,setCurrentPanel:d}},Qe=e=>{if(e)return`${e.endYear}-${e.weekNumber}`},Ae=(e,t)=>{if(!e)return;const n=e.split("-"),r=parseInt(n[1],10),s=parseInt(n[0],10),a=new Date;a.setFullYear(s);const i=u.startOfWeek(u.setWeek(a,r),{locale:t});return Re(i,t)};function gn(e){const t=kt(e);return o.jsx(ie,{...e,...t})}const pe="bottom",mn=(e,t,n)=>{const[r,s]=l.useState(n||!1),a=l.useCallback(()=>(s(!0),!0),[s]),i=l.useCallback(()=>{s(!1),t&&t()},[s,t]),c=l.useCallback(d=>{e&&e(d),setTimeout(i,150)},[e,i]);return{showCalendar:a,hideCalendar:i,showingCalendar:r,onSelectDate:c}},ye="2999-12-31",Dn=({displayFormat:e=ee.fullDate,placeholder:t="Enter date",value:n,calendarTheme:r=ae,calendarProps:s,openOnMount:a,onClose:i,onChange:c,variant:d,width:h,minDate:f,maxDate:m=ye,disabled:D,portalTarget:x,zIndex:b})=>{const{hideCalendar:C,showingCalendar:w,onSelectDate:S,showCalendar:p}=mn(c,i,a);return o.jsx(g.Box,{width:h,children:o.jsx(xe.ControlledPopover,{hideArrow:!0,open:w,onRequestClose:C,appendTo:x,zIndex:b,renderTrigger:y=>o.jsx(g.Box,{...y,children:o.jsx(J.TextInput,{type:"date",onFocus:p,buttonRight:o.jsx(j.TextInputButton,{onClick:p,icon:j.stenaCalendar}),value:n?u.format(n,e):"",placeholder:t,size:9,disabled:D,autoFocus:a,variant:d,min:f,max:m})}),placement:pe,children:o.jsx(Je,{...s,onChange:S,value:n,theme:r,minDate:f,maxDate:m})})})},xn=(e,t)=>{const n=l.useRef(null),r=l.useRef(null),[s,a]=l.useState(!1),[i,c]=l.useState(void 0),d=l.useCallback(()=>(c("startDate"),a(!0),!0),[c,a]),h=l.useCallback(()=>(c("endDate"),a(!0),!0),[c,a]),f=l.useCallback(()=>{a(!1)},[a]),m=l.useCallback(x=>{i==="startDate"?(t?.({startDate:x.date,endDate:e?.endDate}),e?.endDate?setTimeout(f,150):(c("endDate"),r.current?.focus())):i==="endDate"&&(t?.({startDate:e?.startDate,endDate:x.date}),e?.startDate?setTimeout(f,150):(c("startDate"),n.current?.focus()))},[i,t,c,f,e]),D=l.useMemo(()=>e?.startDate&&e?.endDate&&u.isAfter(e.startDate,e.endDate),[e?.startDate,e?.endDate]);return{showingCalendar:s,hideCalendar:f,showCalendarEndDate:h,showCalendarStartDate:d,focusedInput:i,setFocusedInput:c,startDateInputRef:n,endDateInputRef:r,onClickDay:m,startDateIsAfterEnd:D}};function bn({displayFormat:e=ee.fullDate,placeholderStartDate:t="Start date",placeholderEndDate:n="End date",value:r,onValueChange:s,width:a,calendarTheme:i=ae,calendarProps:c,minDate:d,maxDate:h=ye,disabled:f,portalTarget:m,zIndex:D}){const[x,b]=l.useState("calendar"),{hideCalendar:C,showCalendarEndDate:w,showCalendarStartDate:S,showingCalendar:p,focusedInput:y,startDateInputRef:k,endDateInputRef:M,onClickDay:E,startDateIsAfterEnd:R}=xn(r,s),[I,T]=l.useState(()=>(y&&r?.[y])??new Date),L=l.useMemo(()=>fe(void 0,r?.startDate,r?.endDate),[r]);return o.jsx(xe.ControlledPopover,{hideArrow:!0,appendTo:m,zIndex:D,renderTrigger:v=>o.jsxs(g.Row,{alignItems:"center",...v,children:[o.jsx(J.TextInput,{iconLeft:j.stenaCalendar,onFocus:S,value:r?.startDate?u.format(r.startDate,e):"",placeholder:t,width:a,disabled:f,inputRef:k,size:9,variant:R?"error":void 0}),o.jsx(g.Space,{}),o.jsx(j.Icon,{icon:j.stenaArrowWideRight,color:Oe.cssColor("--lhds-color-ui-500"),size:14}),o.jsx(g.Space,{}),o.jsx(J.TextInput,{iconLeft:j.stenaCalendar,onFocus:w,value:r?.endDate?u.format(r.endDate,e):"",placeholder:n,width:a,disabled:f,inputRef:M,size:9,variant:R?"error":void 0})]}),open:p,placement:pe,onRequestClose:C,children:o.jsx(ie,{...c,dateInFocus:I,setDateInFocus:T,statePerMonth:L,theme:i,onClickDay:E,currentPanel:x,setCurrentPanel:b,minDate:d,maxDate:h})})}const pn=({calendarProps:e,closeOnCalendarSelectDate:t=!0,dateFormat:n=ee.fullDate,disableCalender:r=!1,onValueChange:s,placeholder:a="yyyy-mm-dd",value:i,width:c="130px",calendarTheme:d=ae,hideCalenderIcon:h=!1,minDate:f,maxDate:m=ye,variant:D,portalTarget:x,zIndex:b,...C})=>{const[w,S]=l.useState(!1),p=l.useCallback(()=>{S(!w)},[S,w]),y=l.useCallback(()=>{S(!1)},[S]),k=l.useCallback(L=>{s&&s(L)},[s]),M=l.useCallback(L=>{L&&(k(u.format(L,n)),t&&setTimeout(()=>S(!w),200))},[k,n,t,S,w]),E=!!i&&!/^[-/\\.0-9]+$/.test(i),R=!!i&&u.isValid(u.parse(i,n,new Date)),T=!!i&&i.length>=n.length&&!R||E;return o.jsx(g.Box,{width:c,children:o.jsx(xe.ControlledPopover,{appendTo:x,zIndex:b,renderTrigger:({ref:L,...v})=>o.jsx(J.TextInput,{...C,variant:T?"error":D,disableContentPaddingRight:!0,contentRight:h?void 0:o.jsx(g.Row,{alignItems:"center",indent:.5,children:o.jsx(j.FlatButton,{size:"small",disabled:C.disabled||r,leftIcon:j.stenaCalendar,onClick:p})}),onValueChange:k,placeholder:a,value:i||"",min:f,max:m,size:10,inputRef:L,...v}),hideArrow:!0,open:w,placement:pe,onRequestClose:y,children:o.jsx(Je,{...e,onChange:M,value:i&&R?u.parse(i,n,new Date):void 0,minDate:f,maxDate:m,theme:d})})})},ke=e=>{if(e==="")return"00";const t=parseInt(e,10);if(isNaN(t))throw new Error("Hours is not a number");if(t<0||t>23)throw new Error("Hours is an invalid number");switch(e.length){case 1:return`0${t}`;case 2:return e;default:throw new Error("Invalid hour string")}},je=e=>{if(e==="")return"00";const t=parseInt(e,10);if(isNaN(t))throw new Error("Minutes is not a number");if(t<0||t>59)throw new Error("Minutes is an invalid number");switch(e.length){case 1:return`0${t}`;case 2:return e;default:throw new Error("Invalid minute string")}},yn=e=>{if(!Ye(e))return{time:e,success:!1};const t=e&&e.split(/-|:|,|;|[/]|[.]| /);if(t&&t.length===2)try{const n=ke(t[0]),r=je(t[1]);return{time:`${n}:${r}`,success:!0}}catch{return{time:e,success:!1}}else if(t&&t.length===1){let n=0,r=0;switch(e.length){case 1:return{time:`0${e}:00`,success:!0};case 2:{const s=parseInt(t[0],10);return s>=0&&s<24?{time:`${e}:00`,success:!0}:s>=24&&s<59?{time:`00:${e}`,success:!0}:{time:e,success:!1}}case 3:return r=parseInt(e.substring(1,3),10),r>=0&&r<=59?{time:`0${e.substring(0,1)}:${e.substring(1,3)}`,success:!0}:{time:e,success:!1};case 4:return n=parseInt(e.substring(0,2),10),r=parseInt(e.substring(2,4),10),n<0||n>23?{time:e,success:!1}:r<0||r>59?{time:e,success:!1}:{time:`${e.substring(0,2)}:${e.substring(2,4)}`,success:!0};default:return{time:e,success:!1}}}return{time:e,success:!1}},Ye=e=>e?/^[-:.,/; 0-9]+$/.test(e):!0,Cn=({onValueChange:e,showPlaceholder:t=!0,useIcon:n=!0,value:r,width:s="85px",variant:a,...i})=>{const[c,d]=l.useState(()=>Ye(r)),h="hh:mm",f=l.useCallback(()=>{if(r){const D=yn(r);d(D.success),D.success&&e&&e(D.time)}},[r,e,d]),m=l.useCallback(D=>{const x=D.target.value,b=Ye(x);d(b&&x.length<=h.length),e&&e(x)},[e,d]);return o.jsx(J.TextInput,{...i,type:"time",variant:c?a:"error",iconLeft:n?j.stenaClock:void 0,value:r,placeholder:t?h:void 0,onChange:m,onBlur:f,width:s})},jt=({autoFocusLeft:e,autoFocusRight:t,onEsc:n,onEnter:r,onValueChangeLeft:s,onValueChangeRight:a,separatorIcon:i,placeholderLeft:c,placeholderRight:d,typeLeft:h,typeRight:f,onChangeLeft:m,onChangeRight:D,valueLeft:x,valueRight:b,minLeft:C,maxLeft:w,minRight:S,maxRight:p,onClickLeft:y,onClickRight:k,onClickCalendar:M,onClickArrowDown:E,onBlurLeft:R,onBlurRight:I,onFocusLeft:T,onFocusRight:L,inputRefLeft:v,inputRefRight:P,variant:A,variantLeft:U,variantRight:O,onBlur:V,showPresets:q,widthLeft:F,widthRight:Z,disabled:H})=>{const _=l.useRef(0),N=l.useMemo(()=>se.debounce(Y=>{Y===0&&V?.()},10),[V]),$=l.useCallback(Y=>{_.current++,N(_.current),T&&T(Y)},[T,_,N]),K=l.useCallback(Y=>{_.current++,N(_.current),L&&L(Y)},[L,_,N]),te=l.useCallback(Y=>{_.current--,N(_.current),R&&R(Y)},[R,_,N]),G=l.useCallback(Y=>{_.current--,N(_.current),I&&I(Y)},[I,_,N]);return o.jsx(g.Box,{children:o.jsxs(J.TextInputBox,{disableContentPaddingRight:!0,disabled:H,variant:A,contentRight:o.jsxs(g.Row,{alignItems:"center",children:[o.jsx(g.Indent,{num:.5,children:o.jsx(j.FlatButton,{leftIcon:j.stenaCalendar,onClick:M,disabled:H,size:"small"})}),q?o.jsxs(o.Fragment,{children:[o.jsx(g.Row,{height:"22px",children:o.jsx(g.SeparatorLine,{vertical:!0})}),o.jsx(g.Indent,{num:.5,children:o.jsx(j.FlatButton,{leftIcon:j.stenaAngleDown,onClick:E,disabled:H,size:"small"})})]}):null]}),children:[o.jsx(g.Box,{width:F,children:o.jsx(J.TextInput,{onEsc:n,onEnter:r,onClick:y,disabled:H,hideBorder:!0,placeholder:c,value:x,onValueChange:s,onChange:m,onBlur:te,onFocus:$,inputRef:v,variant:U,type:h,autoFocus:e,min:C,max:w})}),o.jsx(g.Row,{indent:.5,alignItems:"center",justifyContent:"center",children:o.jsx(j.Icon,{icon:i,size:12,color:Oe.cssColor("--lhds-color-ui-500")})}),o.jsx(g.Box,{width:Z,children:o.jsx(J.TextInput,{onEsc:n,onEnter:r,onClick:k,disabled:H,hideBorder:!0,placeholder:d,value:b,onValueChange:a,onChange:D,onBlur:G,onFocus:K,inputRef:P,variant:O,type:f,autoFocus:t,min:S,max:p})})]})})},wn=e=>{if(e==null)throw new Error("Time is not set.");if(e==="")throw new Error("Time is empty.");const t=e.split(":");if(t.length!==2)throw new Error("Invalid time.");if(t[1].length!==2)throw new Error("Invalid time.");if(t[0].length<1||t[0].length>2)throw new Error("Invalid time.");const n=parseInt(t[0],10),r=parseInt(t[1],10);if(isNaN(n))throw new Error("Invalid time.");if(isNaN(r))throw new Error("Invalid time.");if(n<0||n>23)throw new Error("Invalid time.");if(r<0||r>59)throw new Error("Invalid time.");return n*100+r},Sn=e=>{try{return wn(e),!0}catch{return!1}},we=e=>{if(e&&Sn(e)){const t=e.split(":");return{hour:g.parseIntElseUndefined(t[0]),minute:g.parseIntElseUndefined(t[1])}}return{hour:void 0,minute:void 0}},kn=e=>`${ke(String(e.getHours()))}:${je(String(e.getMinutes()))}`,jn="_timePicker_1w05d_1",Mn="_timePickerColumn_1w05d_6",Mt={timePicker:jn,timePickerColumn:Mn},vn=({onClick:e,item:t,selected:n,columnRef:r,canScrollRef:s})=>{const a=l.useRef(null);return l.useEffect(function(){if(n&&r.current&&a.current&&s.current){const c=a.current.scrollHeight*Math.max(t-2,0);r.current.scrollTo(0,c),s.current=!1}},[r,t,n,s]),o.jsx(g.Row,{width:"64px",justifyContent:"center",spacing:.5,indent:.5,ref:a,children:n?o.jsx(j.PrimaryButton,{label:se.padStart(String(t),2,"0"),onClick:()=>e&&e(t)}):o.jsx(j.FlatButton,{label:String(t).padStart(2,"0"),onClick:()=>e&&e(t)})})},Xe=({onClick:e,items:t,selectedItem:n,canScrollRef:r})=>{const s=l.useRef(null);return o.jsx(g.Column,{className:Mt.timePickerColumn,ref:s,children:t.map(a=>o.jsx(vn,{item:a,onClick:e,selected:a===n,columnRef:s,canScrollRef:r},a))})},Rn=se.range(0,24),Tn=se.range(0,60),In=({value:e,onValueChange:t})=>{const n=l.useRef(!0),[r,s]=l.useState(void 0),[a,i]=l.useState(void 0);l.useEffect(()=>{if(e){const{minute:h,hour:f}=we(e);s(f),i(h)}},[e]);const c=l.useCallback(h=>{s(h),t?.(`${ke(String(h??0))}:${je(String(a??0))}`)},[a,t]),d=l.useCallback(h=>{i(h),t?.(`${ke(String(r??0))}:${je(String(h??0))}`)},[r,t]);return o.jsxs(g.Row,{className:Mt.timePicker,children:[o.jsx(Xe,{items:Rn,onClick:c,selectedItem:r,canScrollRef:n}),o.jsx(g.Indent,{}),o.jsx(Xe,{items:Tn,onClick:d,selectedItem:a,canScrollRef:n})]})},Bn=(e,t,n)=>{l.useEffect(function(){e&&t(e)},[e,t]),l.useEffect(function(){n.current&&(e?n.current.valueAsDate=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())):n.current.valueAsDate=null)},[e,n])},En=(e,t,{setDateInFocus:n,showCalendarInternal:r,hideCalendarInternal:s,setFirstFocusedInput:a,setCurrentPanel:i,localTime:c,setLocalTime:d,localDate:h,setLocalDate:f},m)=>{const D=l.useCallback(p=>{if(!p)return;const y=new Date(p);if(e)y.setHours(e.getHours()),y.setMinutes(e.getMinutes()),t?.(y),f(void 0);else if(c){const{minute:k,hour:M}=we(c);y.setHours(M??0),y.setMinutes(k??0),t?.(y),f(void 0)}else f(y);n(y),m.current&&(m.current.valueAsDate=new Date(Date.UTC(y.getFullYear(),y.getMonth(),y.getDate())))},[e,m,c,t,n,f]),x=l.useCallback(p=>{if(p)if(e){const y=we(p),k=new Date(e);k.setHours(y.hour||0),k.setMinutes(y.minute||0),t?.(k),d(void 0)}else if(h){const y=we(p),k=new Date(h);k.setHours(y.hour||0),k.setMinutes(y.minute||0),t?.(k),d(void 0)}else d(p)},[t,e,h,d]),b=l.useCallback(p=>{p.target.value[0]!=="0"&&D(p.target.valueAsDate)},[D]),C=l.useCallback(p=>x(p.target.value),[x]),w=l.useCallback(()=>{n(e||new Date),i("calendar"),r()},[e,i,r,n]),S=l.useCallback(()=>{a(void 0),s()},[a,s]);return{inputLeftChangeHandler:b,inputRightChangeHandler:C,hideCalendar:S,showCalendar:w,onChangeTime:x,onChangeDate:D}},Ln=e=>{const[t,n]=l.useState(void 0),[r,s]=l.useState(void 0),[a,i,c]=g.useBoolean(!1),[d,h,f]=g.useBoolean(!1),[m,D]=l.useState(void 0),[x,b]=l.useState(()=>e??new Date),[C,w]=l.useState("calendar");return{isCalendarVisible:a,showCalendarInternal:i,hideCalendarInternal:c,firstFocusedInput:m,setFirstFocusedInput:D,dateInFocus:x,setDateInFocus:b,currentPanel:C,setCurrentPanel:w,isTimePickerVisible:d,showTimePicker:h,hideTimePicker:f,localDate:t,setLocalDate:n,localTime:r,setLocalTime:s}},An=(e,t,n,r,{isCalendarVisible:s,setCurrentPanel:a,showTimePicker:i,hideTimePicker:c})=>{const d=l.useCallback(()=>{s||n(),a("calendar"),c()},[c,s,a,n]),h=l.useCallback(()=>{r(),i()},[r,i]),f=l.useCallback(b=>{e(b.date),r(),i()},[e,r,i]),m=l.useCallback(()=>{a("presets"),n()},[a,n]),D=l.useCallback(()=>{s?r():(t.current?.focus(),a("calendar"),n())},[s,r,t,a,n]),x=l.useCallback(b=>{b.key==="Escape"&&r()},[r]);return{onFocusLeft:d,onFocusRight:h,onClickDay:f,onClickArrowButton:m,onClickCalendarButton:D,onKeyDownHandler:x}},_n=({value:e,onValueChange:t,onEnter:n,onEsc:r,onBlur:s,autoFocus:a,minDate:i,widthLeft:c=128,widthRight:d=80,maxDate:h=ye,variant:f,disabled:m,zIndex:D,appendTo:x})=>{const b=l.useRef(null),C=l.useRef(null),w=Ln(e),{setCurrentPanel:S,currentPanel:p,isCalendarVisible:y,dateInFocus:k,setDateInFocus:M,isTimePickerVisible:E,hideTimePicker:R,localTime:I,localDate:T}=w,{showCalendar:L,hideCalendar:v,inputLeftChangeHandler:P,inputRightChangeHandler:A,onChangeTime:U,onChangeDate:O}=En(e,t,w,b),{onKeyDownHandler:V,onFocusRight:q,onFocusLeft:F,onClickDay:Z,onClickCalendarButton:H,onClickArrowButton:_}=An(O,b,L,v,w);Bn(e,M,b);const N=l.useMemo(()=>{const Y=e||T;return Y?X(void 0,Y,["singleSelected","selected"]):{}},[T,e]),$=l.useCallback(()=>{v(),R()},[v,R]),K=l.useMemo(()=>e?kn(e):I,[e,I]),te=g.useDelayedFalse(y,300),G=g.useDelayedFalse(E,300);return o.jsx(g.Box,{onKeyDown:V,children:o.jsx(xe.ControlledPopover,{hideArrow:!0,zIndex:D,appendTo:x,renderTrigger:Y=>o.jsx(g.Box,{...Y,children:o.jsx(jt,{autoFocusLeft:a,onEsc:r,onEnter:n,onBlur:s,disabled:m,separatorIcon:j.stenaClock,typeLeft:"date",typeRight:"time",placeholderLeft:"yyyy-mm-dd",placeholderRight:"hh:mm",onChangeLeft:P,onChangeRight:A,onClickArrowDown:_,onClickCalendar:H,onFocusLeft:F,onFocusRight:q,onClickLeft:F,onClickRight:q,inputRefLeft:b,inputRefRight:C,valueRight:K??"",widthLeft:c,widthRight:d,minLeft:i,maxLeft:h,variant:f})}),placement:pe,open:y||E,onRequestClose:$,children:(te||G)&&o.jsx(g.Column,{children:te?o.jsx(ie,{statePerMonth:N,onClickDay:Z,dateInFocus:k,setDateInFocus:M,currentPanel:p,setCurrentPanel:S,minDate:i,maxDate:h}):G?o.jsxs(g.Column,{children:[o.jsx(g.Column,{overflow:"hidden",height:"250px",children:o.jsx(In,{value:K??"",onValueChange:U})}),o.jsx(g.Space,{}),o.jsx(g.Row,{justifyContent:"flex-end",children:o.jsx(j.PrimaryButton,{label:"Done",onClick:R})})]}):null})})})},Pn=({value:e,onValueChange:t,year:n})=>{const r=String(n);return o.jsx(g.Row,{justifyContent:"center",children:e===n?o.jsx(j.PrimaryButton,{label:r,onClick:()=>t?.(n)}):o.jsx(j.FlatButton,{label:r,onClick:()=>t?.(n)})})},Nn=({value:e,onValueChange:t,initialLastYear:n})=>{const[r,s]=l.useState(()=>e?e+4:n??new Date().getFullYear()+4),a=l.useMemo(()=>{const i=r-11;return se.chunk(se.range(i,r+1),3)},[r]);return l.useEffect(()=>{s(i=>Fn(e,i))},[e]),o.jsxs(g.Row,{children:[o.jsx(g.Column,{justifyContent:"center",children:o.jsx(j.FlatButton,{leftIcon:j.stenaArrowLeft,onClick:()=>s(r-3)})}),o.jsx(g.Column,{gap:1,children:a.map(i=>o.jsx(g.Row,{gap:1,children:i.map(c=>o.jsx(Pn,{year:c,onValueChange:t,value:e},c))},i[0]))}),o.jsx(g.Column,{justifyContent:"center",children:o.jsx(j.FlatButton,{leftIcon:j.stenaArrowRight,onClick:()=>s(r+3)})})]})},Fn=(e,t)=>{if(e==null)return t;if(e>t){const r=e-t,s=r%3,a=r-s+3;return t+a}const n=t-11;if(e<n){const r=n-e,s=r%3,a=r-s+3;return t-a}return t},Yn=(e,t,n,r,s)=>{l.useEffect(function(){e&&n(e)},[e,n]),l.useEffect(function(){t&&n(t)},[t,n]),l.useEffect(function(){r.current&&(e?r.current.valueAsDate=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())):r.current.valueAsDate=null)},[e,r]),l.useEffect(function(){s.current&&(t?s.current.valueAsDate=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())):s.current.valueAsDate=null)},[t,s])},Hn=(e,t,n,{setDateInFocus:r,showCalendarInternal:s,hideCalendarInternal:a,setFirstFocusedInput:i,setCurrentPanel:c})=>{const d=l.useCallback(D=>{D.target.value[0]!=="0"&&n?.({startDate:D.target.valueAsDate??void 0,endDate:t})},[n,t]),h=l.useCallback(D=>{D.target.value[0]!=="0"&&n?.({startDate:e,endDate:D.target.valueAsDate??void 0})},[n,e]),f=l.useCallback(D=>{D!=null?r(D):r(e||t||new Date),c("calendar"),s()},[e,t,c,s,r]),m=l.useCallback(()=>{i(void 0),a()},[i,a]);return{inputLeftChangeHandler:d,inputRightChangeHandler:h,hideCalendar:m,setDateInFocus:r,setCurrentPanel:c,showCalendar:f}},Wn=(e,t)=>{const[n,r,s]=g.useBoolean(!1),[a,i]=l.useState(void 0),[c,d]=l.useState("startDate"),[h,f]=l.useState(()=>(c==="startDate"?e:c==="endDate"?t:void 0)??new Date),[m,D]=l.useState("calendar");return{isCalendarVisible:n,showCalendarInternal:r,hideCalendarInternal:s,firstFocusedInput:a,setFirstFocusedInput:i,focusedInput:c,setFocusedInput:d,dateInFocus:h,setDateInFocus:f,currentPanel:m,setCurrentPanel:D}},On=(e,t,n,r,s,a,i,{firstFocusedInput:c,setFirstFocusedInput:d,isCalendarVisible:h,setFocusedInput:f,focusedInput:m,setCurrentPanel:D,setDateInFocus:x})=>{const b=l.useCallback(()=>{c==null&&d("startDate"),f("startDate"),h?e!=null&&x(e):a(e)},[c,f,h,e,d,a,x]),C=l.useCallback(()=>{c==null&&d("endDate"),f("endDate"),h?t!=null&&x(t):a(t)},[c,f,h,t,d,a,x]),w=l.useCallback(k=>{m==="startDate"?t!=null&&u.isAfter(k.date,t)?(n?.({startDate:k.date,endDate:void 0}),f("endDate"),s.current?.focus()):(n?.({startDate:k.date,endDate:t}),c==="startDate"?(f("endDate"),s.current?.focus()):setTimeout(i,50)):m==="endDate"&&(e?u.isAfter(e,k.date)?(n?.({startDate:k.date,endDate:void 0}),f("endDate"),s.current?.focus()):(n?.({startDate:e,endDate:k.date}),setTimeout(i,50)):(n?.({startDate:e,endDate:k.date}),f("startDate"),r.current?.focus()))},[m,n,t,c,f,s,i,e,r]),S=l.useCallback(()=>{D("presets"),a()},[D,a]),p=l.useCallback(()=>{h?i():(f("startDate"),d("startDate"),r.current?.focus(),D("calendar"),a())},[h,i,f,d,r,D,a]),y=l.useCallback(k=>{k.key==="Escape"&&i()},[i]);return{onFocusLeft:b,onFocusRight:C,onClickDay:w,onClickArrowButton:S,onClickCalendarButton:p,onKeyDownHandler:y}};function $n({value:e,onValueChange:t,autoFocus:n,onBlur:r,onEnter:s,onEsc:a,minDate:i,maxDate:c=ye,calendarProps:d,widthLeft:h=128,widthRight:f=128,firstMonthInMonthPicker:m,numMonthsInMonthPicker:D,variant:x,disabled:b,zIndex:C,appendTo:w,renderBelowCalendar:S}){const{startDate:p,endDate:y}=e||{},k=l.useRef(null),M=l.useRef(null),E=Wn(p,y),{dateInFocus:R,setDateInFocus:I,isCalendarVisible:T,currentPanel:L,setCurrentPanel:v}=E,{showCalendar:P,hideCalendar:A,inputLeftChangeHandler:U,inputRightChangeHandler:O}=Hn(p,y,t,E),{onKeyDownHandler:V,onFocusRight:q,onFocusLeft:F,onClickDay:Z,onClickCalendarButton:H,onClickArrowButton:_}=On(p,y,t,k,M,P,A,E);Yn(p,y,I,k,M);const N=l.useMemo(()=>p&&y&&u.isAfter(p,y),[p,y]),$=l.useMemo(()=>tt(d?.statePerMonth,p,y,R),[d?.statePerMonth,p,y,R]);return o.jsx(g.Box,{onKeyDown:V,children:o.jsx(xe.ControlledPopover,{hideArrow:!0,restoreFocus:!1,returnFocus:!1,zIndex:C,appendTo:w,renderTrigger:K=>o.jsx(g.Box,{...K,children:o.jsx(jt,{autoFocusLeft:n,onEsc:a,onEnter:s,onBlur:r,disabled:b,separatorIcon:j.stenaArrowRight,typeLeft:"date",typeRight:"date",placeholderLeft:"Start date",placeholderRight:"End date",onChangeLeft:U,onChangeRight:O,onClickArrowDown:_,onClickCalendar:H,onFocusLeft:F,onFocusRight:q,onClickLeft:F,onClickRight:q,inputRefLeft:k,inputRefRight:M,variant:N?"error":x,widthLeft:h,widthRight:f,minLeft:i,maxLeft:c,minRight:i,maxRight:c})}),placement:pe,onRequestClose:A,open:T,children:o.jsxs(g.Column,{children:[o.jsx(ie,{onClickDay:Z,dateInFocus:R,firstMonthInMonthPicker:m,numMonthsInMonthPicker:D,setDateInFocus:I,currentPanel:L,setCurrentPanel:v,minDate:i,maxDate:c,...d,statePerMonth:$}),L==="calendar"&&S]})})})}const He=({onChange:e,onValueChange:t,mask:n,pipe:r,value:s,guide:a,keepCharPositions:i,placeholderChar:c,showMask:d,calendarSize:h,onFocus:f,onBlur:m,placeholderWhenBlurred:D,placeholder:x,valueWhenBlurred:b,label:C,variant:w,...S})=>{const p=l.useRef(null),[y,k]=l.useState(!1),{onChange:M}=Et.useMaskedInput(p,e,t,n,r,s,a,i,c,d,y),E=l.useCallback(T=>{f?.(T),k(!0)},[f]),R=l.useCallback(T=>{m?.(T),k(!1)},[m]),I=y?x:D??x;return w==="standard"?o.jsx(j.Label,{text:C??"",children:o.jsx(J.TextInput,{...S,"aria-live":"polite",value:(y?s:b)??"",inputRef:p,placeholder:I,onFocus:E,onBlur:R,onChange:M,width:et(h),alwaysShowPlaceholder:!0})}):o.jsx(J.LabelledTextInput,{...S,label:C,"aria-live":"polite",value:(y?s:b)??"",ref:p,placeholder:I,onFocus:E,onBlur:R,onChange:M,width:et(h),size:h==="large"?"large":"medium"})},et=e=>{switch(e){case"smaller":return"140px";case"small":return"154px";case"medium":return"168px";case"large":return"196px";default:return g.exhaustSwitchCase(e,"168px")}},Un=[/[1-2]/,/\d/,/\d/,/\d/],Vn=[/[0-1]/,/\d/],qn=[/[0-3]/,/\d/],vt=e=>zn(e).flatMap(Kn),Kn=e=>{switch(e){case"yyyy":return Un;case"mm":case"MM":return Vn;case"dd":case"DD":return qn;default:return[e]}},zn=e=>{if(e.length===0)return[];const t=[];let n=e[0];for(let r=1;r<e.length;r++)e[r]!==e[r-1]?(t.push(n),n=e[r]):n+=e[r];return t.push(n),t},ue=e=>{const n=new Intl.DateTimeFormat(e,{dateStyle:"short"}).formatToParts(new Date),r={year:"yyyy",month:"MM",day:"dd"};return n.map(s=>r[s.type]||s.value).join("")},re=(e,t,n)=>{const r=Ke(t,n?.matchLanguage??!1,n?.fallbackLocaleCode??qe),s=ce(r);if(s==null)return;const a=u.parse(e,ue(r),n?.referenceDate??new Date,{locale:s});if(!isNaN(a.getTime()))return a},de=(e,t,n)=>{const r=Ke(t,n?.matchLanguage??!1,n?.fallbackLocaleCode??qe);return u.format(e,ue(r),{locale:ce(r)})},Me=(e,t)=>{const n=re(e,t);if(n!=null)return de(n,t)},Rt=({value:e,onValueChange:t,localeCode:n,startDateLabel:r="From",endDateLabel:s="To",onFocus:a,calendarSize:i,placeholderWhenBlurredStartDate:c,placeholderWhenBlurredEndDate:d,valueWhenBlurredStartDate:h,valueWhenBlurredEndDate:f,variant:m})=>{const{mask:D,placeholder:x}=l.useMemo(()=>{const b=ue(n);return{mask:vt(b),placeholder:b.toLowerCase()}},[n]);return o.jsxs(g.Row,{children:[o.jsx(He,{mask:D,value:e?.startDate,onValueChange:b=>{t?.({startDate:b})},onBlur:b=>{const C=Me(b.target.value,n);C&&C!==e?.startDate&&t?.({startDate:C})},onFocus:a,label:r,borderRadiusVariant:"onlyLeft",placeholder:x,placeholderWhenBlurred:c,valueWhenBlurred:h,calendarSize:i,variant:m}),o.jsx(He,{mask:D,value:e?.endDate,onValueChange:b=>t?.({endDate:b}),onBlur:b=>{const C=Me(b.target.value,n);C&&C!==e?.endDate&&t?.({endDate:C})},onFocus:a,label:s,borderRadiusVariant:"onlyRight",placeholder:x,placeholderWhenBlurred:d,valueWhenBlurred:f,calendarSize:i,variant:m})]})},We=(e,t,n)=>{const r=u.isSameYear(e,t)?"":" y";return n.code.startsWith("en")?u.format(e,"eee MMM d"+r,{locale:n}).replace(".",""):u.format(e,"eee d MMM"+r,{locale:n}).replace(".","")},Tt=(e,t,n,r,s)=>{const a=ce(r),i=l.useId(),c=g.useToday(),d=l.useRef(null),h=l.useMemo(()=>ue(n),[n]),f=l.useMemo(()=>e?.startDate?.length===h.length?re(e.startDate,n):void 0,[h.length,n,e?.startDate]),m=l.useMemo(()=>e?.endDate?.length===h.length?re(e.endDate,n):void 0,[h.length,n,e?.endDate]),D=l.useMemo(()=>f!=null?We(f,c,a):void 0,[a,f,c]),x=l.useMemo(()=>m!=null?We(m,c,a):void 0,[a,m,c]),[b,C]=l.useState(s??f??new Date),w=l.useCallback(v=>{u.isSameMonth(v,c)||u.isAfter(v,c)?C(v):C(c)},[c]),S=l.useMemo(()=>be(b.getFullYear(),b.getMonth(),a),[a,b]),p=l.useMemo(()=>ve(u.intlFormat(b,{month:"long",year:"numeric"},{locale:a.code})),[a,b]),y=l.useMemo(()=>u.isSameMonth(c,b),[c,b]),[k,M]=l.useState(),[E,R]=l.useState("calendar"),I=l.useCallback(v=>{const P=v?.startDate?.length===h.length?re(v.startDate,n):void 0,A=v?.endDate?.length===h.length?re(v.endDate,n):void 0;P?w(P):A&&w(A),t?.({...e,...v})},[h.length,n,t,w,e]),T=l.useMemo(()=>(f&&m&&(u.isSameDay(f,m)||u.isBefore(f,m)))??!1,[m,f]);return{onClickDate:v=>{v.getFullYear()===b.getFullYear()&&v.getMonth()===b.getMonth()&&(f&&m==null?u.isBefore(v,f)?t?.({startDate:de(v,n),endDate:void 0}):t?.({startDate:e?.startDate,endDate:de(v,n)}):t?.({startDate:de(v,n),endDate:void 0}))},onValueChangeByInputs:I,isValidDateRange:T,monthPickerButtonRef:d,calendarId:i,monthPickerButtonLabel:p,visiblePanel:E,setVisiblePanel:R,setVisibleMonth:C,visibleMonthData:S,todayIsInVisibleMonth:y,hoverDate:k,setHoverDate:M,selectedStartDate:f,selectedEndDate:m,today:c,visibleMonth:b,valueWhenBlurredStartDate:D,valueWhenBlurredEndDate:x}},Ie=({previousMonthButtonAriaLabel:e,nextMonthButtonAriaLabel:t,monthPickerButtonLabel:n,visiblePanel:r,setVisiblePanel:s,monthPickerButtonRef:a,setVisibleMonth:i,visibleMonth:c,prevMonthDisabled:d,nextMonthDisabled:h,calendarSize:f,previousMonthButtonTestId:m,nextMonthButtonTestId:D})=>{const x=f==="smaller"||f==="small"?"medium":"large";return o.jsxs(g.Row,{alignSelf:"center",justifyContent:"space-between",width:"100%",children:[o.jsx(j.FlatButton,{"aria-live":"polite",label:n,rightIcon:r==="calendar"?j.stenaAngleDown:j.stenaAngleUp,onClick:()=>s(r==="calendar"?"month-picker":"calendar"),ref:a,size:x}),o.jsxs(g.Row,{alignItems:"center",gap:2,children:[o.jsx(j.SecondaryButton,{leftIcon:j.stenaArrowLeft,onClick:()=>i(u.subMonths(c,1)),disabled:d?.(c),"aria-label":e,size:x,"data-testid":m}),o.jsx(j.SecondaryButton,{leftIcon:j.stenaArrowRight,onClick:()=>i(u.addMonths(c,1)),disabled:h?.(c),"aria-label":t,size:x,"data-testid":D})]})]})},Gn="_travelDateCell_1t2af_1",Jn="_smaller_1t2af_4",Zn="_small_1t2af_4",Qn="_medium_1t2af_14",Xn="_large_1t2af_19",er="_outline_1t2af_31",tr="_contentWrapper_1t2af_44",nr="_disabled_1t2af_65",rr="_isToday_1t2af_68",sr="_isSelectionStart_1t2af_72",ar="_isSelectionEnd_1t2af_73",or="_hover_1t2af_88",lr="_startSelected_1t2af_91",cr="_endSelected_1t2af_91",z={travelDateCell:Gn,smaller:Jn,small:Zn,medium:Qn,large:Xn,outline:er,contentWrapper:tr,disabled:nr,isToday:rr,isSelectionStart:sr,isSelectionEnd:ar,hover:or,startSelected:lr,endSelected:cr},ne="var(--selection-range-background-color)",ir=(e,t,n,r,s,a)=>{if(!s)return{left:"transparent",right:"transparent"};if(t&&n&&u.isSameDay(t,n))return{left:"transparent",right:"transparent"};if(t&&n&&!a)return{left:"transparent",right:"transparent"};const i=t&&n?u.isAfter(e,t)&&u.isBefore(e,n)&&!u.isSameDay(e,t)&&!u.isSameDay(e,n):!1,c=t&&r?u.isAfter(e,t)&&u.isBefore(e,r)&&!u.isSameDay(e,t)&&!u.isSameDay(e,r):!1;if(i)return{left:ne,right:ne};if(t&&n)return u.isSameDay(e,t)?{left:"transparent",right:ne}:u.isSameDay(e,n)?{left:ne,right:"transparent"}:{left:"transparent",right:"transparent"};if(t&&r&&u.isAfter(r,t)){if(u.isSameDay(e,t))return{left:"transparent",right:ne};if(u.isSameDay(e,r))return{left:ne,right:"transparent"}}return c?{left:ne,right:ne}:{left:"transparent",right:"transparent"}},ur=(e,t)=>{switch(t){case"PageUp":return u.subMonths(e,1);case"PageDown":return u.addMonths(e,1);case"Home":return u.startOfWeek(e);case"End":return u.addDays(u.startOfWeek(e),6);case"ArrowLeft":return u.subDays(e,1);case"ArrowUp":return u.subDays(e,7);case"ArrowRight":return u.addDays(e,1);case"ArrowDown":return u.addDays(e,7);default:return}},_e=(e,t)=>u.format(u.addHours(e,12),ee.fullDate)+t,dr="_travelDateCellBackground_45q5d_1",fr="_smaller_45q5d_2",hr="_small_45q5d_2",gr="_medium_45q5d_12",mr="_large_45q5d_17",Ce={travelDateCellBackground:dr,smaller:fr,small:hr,medium:gr,large:mr},Dr=({calendarSize:e,bgColorLeft:t,bgColorRight:n})=>o.jsxs(g.Row,{children:[o.jsx(g.Box,{className:le(Ce.travelDateCellBackground,Ce[e]),background:t}),o.jsx(g.Box,{className:le(Ce.travelDateCellBackground,Ce[e]),background:n})]}),xr=({onClick:e,visibleMonth:t,onChangeVisibleMonth:n,day:r,isValidDateRange:s,selectedStartDate:a,selectedEndDate:i,onStartHover:c,onEndHover:d,hoverDate:h,today:f,todayIsInVisibleMonth:m,calendarId:D,isDateDisabled:x,size:b,dateTestId:C})=>{const w=l.useCallback(async R=>{const I=ur(r.date,R.key),T=(I&&x?.(I))??!1;I&&!T&&(c(I),u.isSameMonth(r.date,I)?document.getElementById(_e(I,D))?.focus():(n(I),setTimeout(()=>{document.getElementById(_e(I,D))?.focus()},10))),(R.key==="Enter"||R.code==="Space")&&e(r.date)},[D,r.date,x,n,e,c]),S=r.month===t.getMonth(),p=x?.(r.date)??!1,y=a?u.isSameDay(a,r.date):!1,k=i?u.isSameDay(i,r.date):!1,M=u.isSameDay(r.date,f),E=ir(r.date,a,i,h,S,s);return o.jsxs("td",{className:le(z.travelDateCell,z[b]),onClick:p?void 0:()=>e(r.date),onMouseOver:p?void 0:()=>S&&c(r.date),onMouseOut:p?void 0:()=>S&&d(r.date),tabIndex:p?void 0:br(r,a,M,t,m),id:p?void 0:_e(r.date,D),onKeyDown:p?void 0:w,...p?void 0:{"aria-selected":y||k},"data-testid":C?.(r.date),children:[o.jsx("div",{className:z.outline}),o.jsx(Dr,{calendarSize:b,bgColorLeft:E.left,bgColorRight:E.right}),S&&o.jsx("div",{className:le(z.contentWrapper,M?z.isToday:void 0,a?z.startSelected:void 0,i?z.endSelected:void 0,h&&u.isSameDay(h,r.date)?z.hover:void 0,y&&z.isSelectionStart,k&&z.isSelectionEnd,p&&z.disabled),children:o.jsx(g.Text,{variant:"bold",color:p?Oe.cssColor("--lhds-color-ui-500"):void 0,children:r.dayOfMonth})})]})},br=(e,t,n,r,s)=>{const a=t?u.isSameMonth(t,r):!1;return(t&&a?u.isSameDay(e.date,t):n)||!a&&!s&&e.date.getDate()===1?0:-1},pr="_travelCalendar_ib2y4_1",yr={travelCalendar:pr},Be=({visibleMonthData:e,onClickDate:t,setHoverDate:n,setVisibleMonth:r,visibleMonth:s,isValidDateRange:a,selectedStartDate:i,selectedEndDate:c,hoverDate:d,today:h,calendarId:f,isDateDisabled:m,todayIsInVisibleMonth:D,size:x="medium",multiSelectable:b,dateTestId:C})=>o.jsx("table",{className:yr.travelCalendar,role:"grid",...b?{"aria-multiselectable":!0}:void 0,children:o.jsxs("tbody",{children:[o.jsx("tr",{children:e.weeks[0].days.map(w=>o.jsx("th",{abbr:w.fullName,children:o.jsx(g.Text,{children:w.name})},w.name))}),e.weeks.map(w=>o.jsx($e.Fragment,{children:o.jsx("tr",{children:w.days.map(S=>o.jsx(xr,{size:x,onClick:p=>t(p),visibleMonth:s,onChangeVisibleMonth:r,isValidDateRange:a,day:S,onStartHover:p=>n(p),onEndHover:p=>n(y=>y&&u.isSameDay(y,p)?void 0:y),selectedStartDate:i,selectedEndDate:c,hoverDate:d,today:h,todayIsInVisibleMonth:D,calendarId:f,isDateDisabled:m,dateTestId:C},S.dateString))},w.weekNumber)},w.weekNumber))]})}),Cr="_travelDateRangeInput_1j7rp_1",wr="_overlay_1j7rp_2",Sr="_calendarVisible_1j7rp_6",Pe={travelDateRangeInput:Cr,overlay:wr,calendarVisible:Sr},kr=({value:e,onValueChange:t,startDateLabel:n,endDateLabel:r,localeCode:s="sv",languageLocaleCode:a=s,initialMonthInFocus:i,previousMonthButtonAriaLabel:c="Previous month",nextMonthButtonAriaLabel:d="Next month",placeholderWhenBlurredStartDate:h,placeholderWhenBlurredEndDate:f,heading:m,headingLevel:D,numMonthsInMonthPicker:x=12,isDateDisabled:b,prevMonthDisabled:C,nextMonthDisabled:w,firstMonthInMonthPicker:S=new Date,zIndex:p=1e3,zIndexWhenClosed:y,onHideCalendar:k,renderBelowCalendar:M,size:E="medium",dateTestId:R,previousMonthButtonTestId:I,nextMonthButtonTestId:T,textInputVariant:L="standard"})=>{const[v,P]=l.useState(!1),[A,U]=l.useState(!1),[O,V]=l.useState({width:336,height:66}),q=E==="large"?"8.8rem":"6.6rem",F=l.useRef(!1),Z=l.useCallback(()=>{F.current=!0,U(!0),setTimeout(()=>{P(!0)},10)},[]),H=l.useCallback(()=>{A&&(P(!1),F.current=!1,k?.(),setTimeout(()=>{F.current||U(!1)},120))},[A,k]),_=l.useRef(null),N=l.useRef(null);g.useOnClickOutside(_,H),l.useLayoutEffect(()=>{const W=N.current?.offsetWidth,oe=N.current?.offsetHeight;W!=null&&oe!=null&&(O.height!==oe||O.width!==W)&&V({width:W,height:oe})},[O.height,O.width]);const $=Tt(e,t,s,a,i),{visiblePanel:K,visibleMonth:te,onValueChangeByInputs:G,setVisibleMonth:Y,setVisiblePanel:me,monthPickerButtonRef:De}=$,Ee=l.useCallback(W=>{W.key==="Escape"&&H()},[H]);return o.jsxs(g.Box,{position:"relative",className:Pe.travelDateRangeInput,ref:_,onKeyDown:Ee,height:O.height,width:O.width,children:[o.jsx(g.Box,{position:"absolute",ref:N,zIndex:A?p:y,children:o.jsx(Rt,{...$,value:e,onValueChange:G,localeCode:s,startDateLabel:n,endDateLabel:r,onFocus:Z,calendarSize:E,placeholderWhenBlurredStartDate:h,placeholderWhenBlurredEndDate:f,variant:L})}),A&&o.jsx(g.Box,{position:"absolute",zIndex:p-1,left:"-2.4rem",top:m?"-8.0rem":"-2.4rem",className:le(Pe.overlay,v&&Pe.calendarVisible),children:o.jsx(g.Box,{background:"white",shadow:"popover",borderRadius:"var(--swui-border-radius-large)",children:o.jsxs(j.CardBody,{gap:3,children:[m&&o.jsx(g.Heading,{variant:"h2",as:D,children:m}),o.jsx(g.Box,{height:q}),o.jsx(Ie,{...$,previousMonthButtonAriaLabel:c,nextMonthButtonAriaLabel:d,calendarSize:E,prevMonthDisabled:C,nextMonthDisabled:w,previousMonthButtonTestId:I,nextMonthButtonTestId:T}),K==="calendar"&&o.jsx(Be,{...$,size:E,multiSelectable:!0,isDateDisabled:b,dateTestId:R}),K==="month-picker"&&o.jsx(ge,{firstMonth:S,numMonths:x,value:te,size:E,localeCode:s,onValueChange:W=>{Y(W),me("calendar"),De.current?.focus()},onCancel:()=>{me("calendar"),De.current?.focus()}}),M?.({hideCalendar:H})]})})})]})},jr="_travelDateInput_hmfbf_1",Mr="_overlay_hmfbf_2",vr="_calendarVisible_hmfbf_6",Ne={travelDateInput:jr,overlay:Mr,calendarVisible:vr},It=({value:e,onValueChange:t,label:n="Date",localeCode:r,onFocus:s,calendarSize:a,placeholderWhenBlurred:i,valueWhenBlurred:c,variant:d})=>{const{mask:h,placeholder:f}=l.useMemo(()=>{const m=ue(r);return{mask:vt(m),placeholder:m.toLowerCase()}},[r]);return o.jsx(g.Row,{children:o.jsx(He,{mask:h,value:e,onValueChange:t,onBlur:m=>{const D=Me(m.target.value,r);D&&D!==e&&t?.(D)},onFocus:s,label:n,placeholder:f,calendarSize:a,placeholderWhenBlurred:i,valueWhenBlurred:c,variant:d})})},Bt=(e,t,n,r,s,a)=>{const i=ce(r),c=l.useId(),d=g.useToday(),h=l.useRef(null),f=l.useMemo(()=>ue(n),[n]),m=l.useMemo(()=>e?.length===f.length?re(e,n):void 0,[f.length,n,e]),D=l.useMemo(()=>m!=null?We(m,d,i):void 0,[i,m,d]),[x,b]=l.useState(s??m??new Date),C=l.useCallback(T=>{u.isSameMonth(T,d)||u.isAfter(T,d)?b(T):b(d)},[d]),w=l.useMemo(()=>be(x.getFullYear(),x.getMonth(),i),[i,x]),S=l.useMemo(()=>ve(u.intlFormat(x,{month:"long",year:"numeric"},{locale:i.code})),[i,x]),p=l.useMemo(()=>u.isSameMonth(d,x),[d,x]),[y,k]=l.useState(),[M,E]=l.useState("calendar"),R=l.useCallback(T=>{const L=T?.length===f.length?re(T,n):void 0;L&&C(L),t?.(T)},[f.length,n,t,C]);return{onClickDate:T=>{t?.(de(T,n)),a?.(T)},onValueChangeByInputs:R,monthPickerButtonRef:h,calendarId:c,monthPickerButtonLabel:S,visiblePanel:M,setVisiblePanel:E,setVisibleMonth:b,visibleMonthData:w,todayIsInVisibleMonth:p,hoverDate:y,setHoverDate:k,selectedDate:m,today:d,visibleMonth:x,valueWhenBlurred:D}},Rr=({value:e,onValueChange:t,label:n,localeCode:r="sv",languageLocaleCode:s=r,initialMonthInFocus:a,previousMonthButtonAriaLabel:i="Previous month",nextMonthButtonAriaLabel:c="Next month",placeholderWhenBlurred:d,heading:h,headingLevel:f,numMonthsInMonthPicker:m=12,isDateDisabled:D,prevMonthDisabled:x,nextMonthDisabled:b,firstMonthInMonthPicker:C=new Date,zIndex:w=1e3,zIndexWhenClosed:S,onHideCalendar:p,renderBelowCalendar:y,size:k="medium",dateTestId:M,previousMonthButtonTestId:E,nextMonthButtonTestId:R,textInputVariant:I="standard"})=>{const[T,L]=l.useState(!1),[v,P]=l.useState(!1),[A,U]=l.useState({width:336,height:66}),O=k==="large"?"8.8rem":"6.6rem",V=l.useRef(!1),q=l.useCallback(()=>{V.current=!0,P(!0),setTimeout(()=>{L(!0)},10)},[]),F=l.useCallback(()=>{v&&(L(!1),V.current=!1,p?.(),setTimeout(()=>{V.current||P(!1)},120))},[v,p]),Z=l.useCallback(()=>{setTimeout(()=>{F()},250)},[F]),H=l.useRef(null),_=l.useRef(null);g.useOnClickOutside(H,F),l.useLayoutEffect(()=>{const W=_.current?.offsetWidth,oe=_.current?.offsetHeight;W!=null&&oe!=null&&(A.height!==oe||A.width!==W)&&U({width:W,height:oe})},[A.height,A.width]);const N=Bt(e,t,r,s,a,Z),{visiblePanel:$,visibleMonth:K,onValueChangeByInputs:te,selectedDate:G,setVisibleMonth:Y,setVisiblePanel:me,monthPickerButtonRef:De}=N,Ee=l.useCallback(W=>{W.key==="Escape"&&F()},[F]);return o.jsxs(g.Box,{position:"relative",className:Ne.travelDateInput,ref:H,onKeyDown:Ee,height:A.height,width:A.width,children:[o.jsx(g.Box,{position:"absolute",ref:_,zIndex:v?w:S,children:o.jsx(It,{...N,value:e,onValueChange:te,localeCode:r,label:n,onFocus:q,calendarSize:k,placeholderWhenBlurred:d,variant:I})}),v&&o.jsx(g.Box,{position:"absolute",zIndex:w-1,left:"-2.4rem",top:h?"-8.0rem":"-2.4rem",className:le(Ne.overlay,T&&Ne.calendarVisible),children:o.jsx(g.Box,{background:"white",shadow:"popover",borderRadius:"var(--swui-border-radius-large)",children:o.jsxs(j.CardBody,{gap:3,children:[h&&o.jsx(g.Heading,{variant:"h2",as:f,children:h}),o.jsx(g.Box,{height:O}),o.jsx(Ie,{...N,previousMonthButtonAriaLabel:i,nextMonthButtonAriaLabel:c,calendarSize:k,prevMonthDisabled:x,nextMonthDisabled:b,previousMonthButtonTestId:E,nextMonthButtonTestId:R}),$==="calendar"&&o.jsx(Be,{...N,size:k,isValidDateRange:!!G,selectedStartDate:G,selectedEndDate:G,multiSelectable:!1,isDateDisabled:D,dateTestId:M}),$==="month-picker"&&o.jsx(ge,{firstMonth:C,numMonths:m,value:K,size:k,localeCode:r,onValueChange:W=>{Y(W),me("calendar"),De.current?.focus()},onCancel:()=>{me("calendar"),De.current?.focus()}}),y?.({hideCalendar:F})]})})})]})},Tr=({value:e,onValueChange:t,label:n,localeCode:r="sv",languageLocaleCode:s=r,initialMonthInFocus:a,previousMonthButtonAriaLabel:i="Previous month",nextMonthButtonAriaLabel:c="Next month",placeholderWhenBlurred:d,heading:h,headingLevel:f,numMonthsInMonthPicker:m=12,isDateDisabled:D,prevMonthDisabled:x,nextMonthDisabled:b,firstMonthInMonthPicker:C=new Date,dateTestId:w,size:S="medium",previousMonthButtonTestId:p,nextMonthButtonTestId:y,textInputVariant:k="standard"})=>{const M=Bt(e,t,r,s,a),{visiblePanel:E,visibleMonth:R,onValueChangeByInputs:I,setVisibleMonth:T,setVisiblePanel:L,monthPickerButtonRef:v,selectedDate:P}=M;return o.jsxs(g.Column,{gap:3,children:[h&&o.jsx(g.Heading,{variant:"h2",as:f,children:h}),o.jsx(It,{...M,value:e,onValueChange:I,localeCode:r,label:n,calendarSize:S,placeholderWhenBlurred:d,variant:k}),o.jsx(Ie,{...M,previousMonthButtonAriaLabel:i,nextMonthButtonAriaLabel:c,calendarSize:S,prevMonthDisabled:x,nextMonthDisabled:b,previousMonthButtonTestId:p,nextMonthButtonTestId:y}),E==="calendar"&&o.jsx(Be,{...M,size:S,selectedStartDate:P,selectedEndDate:P,isValidDateRange:!!P,isDateDisabled:D,multiSelectable:!1,dateTestId:w}),E==="month-picker"&&o.jsx(ge,{firstMonth:C,numMonths:m,value:R,localeCode:s,size:S,onValueChange:A=>{T(A),L("calendar"),v.current?.focus()},onCancel:()=>{L("calendar"),v.current?.focus()}})]})},Ir=({value:e,onValueChange:t,startDateLabel:n,endDateLabel:r,localeCode:s="sv",languageLocaleCode:a=s,initialMonthInFocus:i,previousMonthButtonAriaLabel:c="Previous month",nextMonthButtonAriaLabel:d="Next month",heading:h,headingLevel:f,numMonthsInMonthPicker:m=12,isDateDisabled:D,prevMonthDisabled:x,nextMonthDisabled:b,firstMonthInMonthPicker:C=new Date,size:w="medium",dateTestId:S,previousMonthButtonTestId:p,nextMonthButtonTestId:y,placeholderWhenBlurredStartDate:k,placeholderWhenBlurredEndDate:M,textInputVariant:E="standard"})=>{const R=Tt(e,t,s,a,i),{visiblePanel:I,visibleMonth:T,onValueChangeByInputs:L,setVisibleMonth:v,setVisiblePanel:P,monthPickerButtonRef:A}=R;return o.jsxs(g.Column,{gap:3,children:[h&&o.jsx(g.Heading,{variant:"h2",as:f,children:h}),o.jsx(Rt,{...R,value:e,onValueChange:L,localeCode:s,startDateLabel:n,endDateLabel:r,calendarSize:w,placeholderWhenBlurredStartDate:k,placeholderWhenBlurredEndDate:M,variant:E}),o.jsx(Ie,{...R,previousMonthButtonAriaLabel:c,nextMonthButtonAriaLabel:d,calendarSize:w,prevMonthDisabled:x,nextMonthDisabled:b,previousMonthButtonTestId:p,nextMonthButtonTestId:y}),I==="calendar"&&o.jsx(Be,{...R,size:w,multiSelectable:!0,isDateDisabled:D,dateTestId:S}),I==="month-picker"&&o.jsx(ge,{firstMonth:C,numMonths:m,value:T,size:w,localeCode:a,onValueChange:U=>{v(U),P("calendar"),A.current?.focus()},onCancel:()=>{P("calendar"),A.current?.focus()}})]})},Br=()=>{const e=g.useToday();return l.useCallback(t=>!u.isSameDay(t,e)&&u.isBefore(t,e),[e])},Er=()=>{const e=g.useToday();return l.useCallback(t=>u.isSameMonth(e,t)||u.isBefore(t,e),[e])};exports.Calendar=Se;exports.CalendarDay=Ve;exports.DateInput=Dn;exports.DateRangeCalendar=dn;exports.DateRangeDualTextInput=$n;exports.DateRangeInput=bn;exports.DateTextInput=pn;exports.DateTimeInput=_n;exports.Month=st;exports.MonthPicker=ge;exports.MultiDateCalendar=hn;exports.PresetPicker=bt;exports.SingleDateCalendar=Je;exports.SingleWeekCalendar=gn;exports.TimeTextInput=Cn;exports.TravelDateCalendar=Tr;exports.TravelDateInput=Rr;exports.TravelDateRangeCalendar=Ir;exports.TravelDateRangeInput=kr;exports.WeekDay=at;exports.WeekDayCell=ht;exports.WeekNumberCell=gt;exports.YearPicker=Nn;exports.addDayStateHighlights=X;exports.addDayStateHighlightsOnSingleDay=Ue;exports.addWeekRangeHighlights=rt;exports.addWeekStateHighlights=Pt;exports.buildDayStateForDateRange=fe;exports.buildDayStateForRange=nt;exports.buildDayStateForSingleMonth=tt;exports.calculateOverflowingMonth=it;exports.createDay=lt;exports.dateRangeToStrings=pt;exports.dayHasHighlight=ut;exports.dayHighlightSelect=Q;exports.defaultCalendarTheme=ae;exports.defaultTextPropsProvider=ft;exports.defaultWrapperStyleProvider=dt;exports.extranetCalendarTheme=Ht;exports.fallbackLocaleCode=qe;exports.fallbackLocaleCodeForFormatting=Jt;exports.formatLocalizedDate=de;exports.getDateFormatForLocaleCode=ue;exports.getDaysForWeekForDate=ct;exports.getDefaultLocaleForFormatting=Zt;exports.getLocaleCodeForLocale=xt;exports.getLocaleForLocaleCode=ce;exports.getMonthInYear=be;exports.getMonthsInYear=Fe;exports.getSupportedLocaleCode=Ke;exports.getSupportedLocaleCodeMatchingLanguage=Dt;exports.getWeekForDate=Re;exports.getWeeksForMonth=ot;exports.isDateRangeInvalid=ze;exports.parseLocalizedDateString=re;exports.reformatLocalizedDateString=Me;exports.setDayStateValue=At;exports.setDayStateValueFunction=_t;exports.stringsToDateRange=yt;exports.toggleDateStringsIfEndIsEarlierThanStart=cn;exports.toggleDatesIfEndIsEarlierThanStart=Ge;exports.useDateRangeCalendarState=fn;exports.useDateRangeSelection=Ct;exports.useDisabledBeforeToday=Br;exports.useMultiDateSelection=St;exports.usePrevMonthDisabledBeforeToday=Er;exports.useSingleDateSelection=wt;exports.useSingleWeekSelection=kt;
3
3
  //# sourceMappingURL=index.js.map