import{L as y,ao as n,aQ as N,h as l,aC as h,aU as i,aP as A,aq as g,ar as R,aG as j,b0 as w,bc as D,A as U,ix as C,M as O,dG as B,iy as I}from"./app-k0jcl5PQ.js";import{P}from"./DwDhXSrj.chunk.js";import{R as E}from"./4jZ12g_A.chunk.js";const T="rostering.settingHeader";function v(e){var a,s;const t=[{name:y.getPhrase(T,"syncJobs"),appLink:(a=e.appLinks)==null?void 0:a.syncJobs,active:e.active==="syncJobs"},{name:y.getPhrase(T,"settings"),appLink:(s=e.appLinks)==null?void 0:s.settings,active:e.active==="settings"}];return n.jsx("div",{className:e.className,children:n.jsx(P,{tabs:t})})}const x={},J="rostering.syncActionButtonGroup",H=y.encloseNamespace(J);function F(e){return n.jsx("div",{className:"btn-group px-2",role:"group",children:n.jsx(N,{title:H("syncNowTooltip"),spanHack:!0,placement:"left",spanHackClassName:x.buttonBorder,children:n.jsx("button",{type:"button",className:`btn btn-outline-dark ${x.leftButton}`,onClick:e==null?void 0:e.onSyncNow,children:H("syncNow")})})})}const S=new Date,k={parseUTCToLocal({utcHour:e,utcWeekdays:t,utcMinute:a=0}){const s=t.map(r=>l.buildLocalDateFromUTC(r,e,a)),o=s.map(r=>r.getDay());return{hour:+l.format(h.first(s),"HH"),daysOfWeek:o,minute:a}},getScheduledJobBySetting(e){if(!e||!e.fullSyncSchedule||!e.fullSyncSchedule.enabled)return null;const t=k.parseUTCToLocal({utcHour:e.fullSyncSchedule.hour,utcWeekdays:e.fullSyncSchedule.daysOfWeek,utcMinute:e.fullSyncSchedule.minute}),a=new Date,s=S.getDay(),o=t.daysOfWeek.sort((f,W)=>f-W),c=t.daysOfWeek.includes(s),r=t.hour,u=(t==null?void 0:t.minute)??0;if(c&&(a.setHours(r,u,0,0),S<a))return a;const m=new Date;let p=o.find(f=>f>s);p||(p=o[0]);const L=Math.abs(p-s);return m.setDate(S.getDate()+L),m.setHours(r,0,0,0),m},parseFormToPayload(e){const t=k.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}=k.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(u=>l.buildUTCDate(u,e,a)),o=l.format(h.first(s),"HH"),c=s.map(u=>u.getDay()),r=l.format(h.first(s),"mm");return{hour:+o,daysOfWeek:c,minute:+r}}},b="rostering.requiresSetUp";function Q(){return n.jsxs(i,{children:[n.jsx(i.Image,{src:A.EmptyStates.Rostering.REQUIRES_SET_UP}),n.jsx(i.Heading,{children:n.jsx(g,{namespace:b,phrase:"emptyHeading"})}),n.jsx(i.Info,{className:"w-50 mb-3",children:n.jsx(g,{namespace:b,phrase:"emptyInfo"})}),n.jsx(R,{className:"btn btn-dark",href:j.getSupportRequestUrl(),newTab:!0,children:n.jsx(g,{namespace:b,phrase:"button"})})]})}const M="rostering.syncUtils",d=y.encloseNamespace(M),_=e=>{const t=w(),a=D();if(!e)return{syncNow:()=>{},fullSync:()=>{}};function s(){const c={type:U.Success,heading:d("startSyncAlertHeading"),message:d("startSyncAlertBody"),appLinkText:d("startSyncAlertAppLinkText"),appLinkClassName:"info-link"},r={name:I.Rostering,type:B.Rostering,metadata:{targetMasterId:e.customerId,targetMasterType:O.Customer},customerId:e.customerId,dataType:C.Learner};t(E.createJob(r,()=>{a.success(c)},()=>{a.error(d("error"))}))}function o(){}return{fullSync:o,syncNow:s}};export{v as R,F as S,Q as a,k as b,_ as u};
//# sourceMappingURL=DlHqWgJu.chunk.js.map
