import{iV as U,o as u,O as T,W as w,de as q,r as z,cb as p,L as M,ao as n,aO as W,aF as B,aq as Z,bU as v,aI as f,eu as N,dZ as S,iZ as K}from"./app-k0jcl5PQ.js";import{u as D}from"./wuHL1Gkg.chunk.js";import{E as X}from"./BTTfV1w9.chunk.js";function ee(e){const{hasValidatedUsers:s,setInvalidUsers:l,userType:o,setHideValidListings:t,setExistingUsers:x}=e;return(m,c)=>{const{failed:d,succeed:y}=U.getCategorizedUsers(m),r=U.getInvalidUsers(d,c),i=U.getExistingUsers(y,c);x(i);const C=d.reduce((g,E)=>(E.errorCodes.forEach(h=>{g[h]||(g[h]=0),g[h]++}),g),{});s||u.logUserAction({totalUploaded:c.length,totalInvalid:Object.keys(r).length,errorCodeCount:C},{...U.getAnalyticsOptions(o),workflowPhase:w.Start,descriptor:T.Bulk}),window.setTimeout(()=>{Object.keys(r).length||t(!1),l(r)},1e3)}}function se(e){const{setHideValidListings:s,hideValidListings:l,userType:o}=e;s(!l),u.logUserAction({hideValidListings:!l},{...U.getAnalyticsOptions(o),actionType:z.Click,descriptor:q.ToggleHideValidListings,workflowPhase:w.Complete})}function te(e,s){e(null),s()}function ie(e,s){e([]),s()}function ae(e){const{deleteUsers:s}=D(),l=e.userType===p.Learner?"userManager.deleteUploadedStudentPopup":"userManager.deleteUploadedStaffPopup",o=M.encloseNamespace(l);function t(){s(e.users),u.logUserAction({},u.mergeOptions(e.analyticsOptions,{workflowPhase:w.Discard,descriptor:e.users.length>1?T.Bulk:T.Single})),e.closePopup()}return n.jsx(W.Provider,{value:l,children:n.jsxs(B,{title:o("title",{smartCount:e.users.length}),closePopup:e.closePopup,children:[n.jsx("p",{className:"m-0 pb-3",children:n.jsx(Z,{phrase:"confirmation",options:{smartCount:e.users.length}})}),n.jsxs(v,{children:[n.jsx(v.Cancel,{onClick:e.closePopup}),n.jsx(v.Submit,{variant:"danger",onClick:t,text:o("delete",{smartCount:e.users.length})})]})]})})}const Y="userManager.editUploadedUserPopup",b=M.encloseNamespace(Y),H="_cv:edit:next:user";function ne(e){var L,O;const{invalidUsers:s,updateUser:l,existingUsersHash:o}=D(),[t,x]=f.useState(!!s[e.user.lookupId]),[m,c]=f.useState(!1),[d,y]=f.useState(!!N.get(H)),r=f.useMemo(()=>Object.keys(s),[s]);f.useEffect(()=>{x(!!s[e.user.lookupId]),u.logUserAction({isInvalid:!!s[e.user.lookupId],data:e.user},u.mergeOptions(e.analyticsOptions,{workflowPhase:w.Start}))},[e.user]),f.useEffect(()=>{m&&window.setTimeout(()=>c(!1),300)},[m,c]);const i=s[e.user.lookupId];async function C(a,I){var V,j,A;if(t){const P=await e.validateUser(a);if(!S.handleAsyncErrors(P,a,null,I))return;const G=r.indexOf(e.user.lookupId),F=d?r[G+1]||r[0]:"";c(!0),e.setUser((V=s[F])==null?void 0:V.user)}const k=t?(j=i==null?void 0:i.user)==null?void 0:j.lookupId:(A=e==null?void 0:e.user)==null?void 0:A.lookupId;if(k){if(typeof e.validateEmail=="function"&&a.email){const P=await e.validateEmail(a.email);P[0].validationCode!==K.UserCanBeCreated?o[k]={user:{...P[0].user,...a},errorCodes:[P[0].validationCode]}:o[k]&&delete o[k]}a&&(l({...a,lookupId:k}),u.logUserAction({isInvalid:!1,data:a},u.mergeOptions(e.analyticsOptions,{workflowPhase:w.Complete}))),!t||!r.length||!d?window.setTimeout(e.closePopup,300):I&&I({reset:!0})}}function g(){y(a=>(N.set(H,!a),!a))}const E=t&&r.length>1,h=b(E&&d?"saveAndNext":"save"),R=S.getMinimumPasswordLength(e.passwordPolicy,e.userType,t?(L=i==null?void 0:i.user)==null?void 0:L.masterRole:(O=e==null?void 0:e.user)==null?void 0:O.masterRole);return t&&!i?n.jsx(n.Fragment,{}):n.jsx(B,{closePopup:e.closePopup,title:e.title,showLoadingSpinner:m,children:n.jsx(X,{initialValues:t?i.user:e.user,initialErrors:t?S.getErrorMessages(i.errorCodes,R,!1,e.localErrorMessage):{},userType:e.userType,onSubmit:C,yearGroups:e.yearGroups,onClickCancel:e.closePopup,submitText:h,onToggleNextCheckbox:g,shouldGoToNext:d,formSize:e.formSize,currentUser:e.currentUser,emailRequired:e.emailRequired,showPasswordField:e.showPasswordField,passwordPolicy:e.passwordPolicy,validateEmail:e.validateEmail,appLinks:e.appLinks,isInBulkEditing:!0},e.user.lookupId)})}export{ae as D,ne as E,te as a,ie as b,ee as g,se as o};
//# sourceMappingURL=BHsqZqpI.chunk.js.map
