import{F as k,j as h,bi as c,w as y}from"./app-BgLa5dit.js";import{P as W}from"./D6bTl1fN.chunk.js";const p="rostering.settingHeader";function g(e){var a,s;const t=[{name:k.getPhrase(p,"syncJobs"),appLink:(a=e.appLinks)==null?void 0:a.syncJobs,active:e.active==="syncJobs"},{name:k.getPhrase(p,"settings"),appLink:(s=e.appLinks)==null?void 0:s.settings,active:e.active==="settings"}];return h.jsx("div",{className:e.className,children:h.jsx(W,{tabs:t})})}const f=new Date,m={parseUTCToLocal({utcHour:e,utcWeekdays:t,utcMinute:a=0}){const s=t.map(n=>c.buildLocalDateFromUTC(n,e,a)),o=s.map(n=>n.getDay());return{hour:+c.format(y.first(s),"HH"),daysOfWeek:o,minute:a}},getScheduledJobBySetting(e){if(!e||!e.fullSyncSchedule||!e.fullSyncSchedule.enabled)return null;const t=m.parseUTCToLocal({utcHour:e.fullSyncSchedule.hour,utcWeekdays:e.fullSyncSchedule.daysOfWeek,utcMinute:e.fullSyncSchedule.minute}),a=new Date,s=f.getDay(),o=t.daysOfWeek.sort((i,T)=>i-T),u=t.daysOfWeek.includes(s),n=t.hour,r=(t==null?void 0:t.minute)??0;if(u&&(a.setHours(n,r,0,0),f<a))return a;const l=new Date;let d=o.find(i=>i>s);d||(d=o[0]);const S=Math.abs(d-s);return l.setDate(f.getDate()+S),l.setHours(n,0,0,0),l},parseFormToPayload(e){const t=m.parseLocalToUTC({hour:e.startAt,weekdays:e.daysOfWeek,minute:0});return{fullSyncSchedule:{daysOfWeek:e.repeat==="daily"?[0,1,2,3,4,5,6]:t.daysOfWeek,hour:t.hour,minute:t.minute,enabled:e.enabled}}},parseValueToForm(e){const{hour:t,daysOfWeek:a}=m.parseUTCToLocal({utcHour:e.hour,utcWeekdays:e.daysOfWeek,utcMinute:e.minute});return{startAt:t,daysOfWeek:a,repeat:e.daysOfWeek.length===7?"daily":"weekly",enabled:e.enabled}},parseLocalToUTC({hour:e,weekdays:t,minute:a}){const s=t.map(r=>c.buildUTCDate(r,e,a)),o=c.format(y.first(s),"HH"),u=s.map(r=>r.getDay()),n=c.format(y.first(s),"mm");return{hour:+o,daysOfWeek:u,minute:+n}}};export{m as R,g as a};
//# sourceMappingURL=kJ6Md8TX.chunk.js.map
