"use strict";(self.webpackChunk_as_client=self.webpackChunk_as_client||[]).push([[782],{782:(e,a,t)=>{t.r(a),t.d(a,{default:()=>D});var n=t(4041),r=t(8081),i=t(738),l=t(8417),o=t(1879),s=t(3578),m=t(5457),d=t(3580),u=t(7894),c=t(9078);const p=r.Ay.div(["max-width:424px;margin:auto;@media (min-width:","px){max-width:456px;}"],i.nm.MD);var g=t(824),h=t(8255),f=t(3336),b=t(7973),x=t(7139),y=t(6816);function E(e){let a=!1;const t=e.split(" ").map((e=>{return/^http(s?):\/\/[a-z0-9]+/i.test(e)?(a=!0,t=e,n.createElement(x.A,{href:t,target:"_blank",style:{wordBreak:"break-all"}},t)):e.length>20?(a=!0,function(e){return n.createElement("span",{style:{wordBreak:"break-all"}},e)}(e)):e;var t}));return a?t.map(((e,a)=>n.createElement(n.Fragment,{key:a},e," "))):e}const w=({error:e})=>e?n.createElement(y.A,{role:"alert","data-testid":"server-error-message",title:E(e),variant:"warning",style:{marginTop:"var(--spacing-xs, 16px)"}}):null,S=e=>{const{id:a,name:t,error:r,disabled:i,onSubmit:l}=e,{handleSubmit:o,formState:{isValid:s},watch:m,control:d}=(0,g.mN)({mode:"onTouched"}),[u,c]=(0,n.useState)(!1),p=(0,g.as)({control:d,name:"username",rules:{required:"Username is required"}}),x=(0,g.as)({control:d,name:"password",rules:{required:"Password is required"}});return(0,n.useEffect)((()=>{const e=m((()=>c(!1)));return()=>e.unsubscribe()}),[m]),(0,n.useEffect)((()=>c(Boolean(r))),[r]),n.createElement("form",{id:a,name:t,onSubmit:o(l)},n.createElement("div",{style:{marginBottom:"var(--spacing-xs, 16px)"}},n.createElement(h.A,{onChange:p.field.onChange,onBlur:p.field.onBlur,value:p.field.value,id:p.field.name,name:p.field.name,"aria-disabled":i,disabled:i,required:!0,autoComplete:"off",fullWidth:!0,title:"Username",error:p.fieldState.invalid,description:p.fieldState.error?.message,"data-testid":"username"})),n.createElement(f.A,{onChange:x.field.onChange,onBlur:x.field.onBlur,value:x.field.value,id:x.field.name,name:x.field.name,"aria-disabled":i,disabled:i,required:!0,autoComplete:"off",fullWidth:!0,error:x.fieldState.invalid,description:x.fieldState.error?.message,"data-testid":"password"}),u&&n.createElement(w,{error:r}),n.createElement(b.A,{"aria-label":"Sign in",disabled:!s||i,fullWidth:!0,variant:"primary",type:"submit","data-testid":"submit-login-form",style:{marginTop:"var(--spacing-md, 32px)"}},"Sign In"))};var v=t(1060),A=t(5772),M=t(6319),k=t(730),C=t(5765);const T=({buttonVariant:e,disabled:a})=>{const[t,{isLoading:r}]=(0,A.eR)();return n.createElement(b.A,{fullWidth:!0,variant:e,disabled:a||r,"aria-label":"Sign In with SAML",onClick:async()=>{try{const e=v.E.readFromUrl()||"cws",a=await t(e).unwrap();window.location.href=a}catch(e){const a=(0,M.W)(e)&&(0,k.Z)(e.data)?e.data.reason:"Internal server error";C.o.error(a)}},"data-testid":"sign-in-with-saml"},"Sign In with SAML")},q=({onClick:e,children:a})=>n.createElement(n.Fragment,null,n.createElement(o.A,{m:"16px 0 8px"},n.createElement(m.A,null)),n.createElement(s.A,{inline:!1,center:!0,color:d.A.primaryBase,weight:"semiBold",onClick:e,style:{cursor:"pointer"},"data-testid":"switch-default-login-method"},a)),B=e=>{const{companyName:a,isSamlDefault:t,isSamlAvailable:r,...i}=e,[l,g]=(0,n.useState)(t);return n.createElement(p,null,n.createElement(u.Z,null,n.createElement(o.A,{mb:32},n.createElement(c.H1,{mb:0},"User Login"),a&&n.createElement(s.A,{variant:"textLg",weight:"medium",center:!0,inline:!1,m:"8px 0 0 0",color:d.A.neutralTextTitle},a)),!l&&n.createElement(S,i),t&&l&&n.createElement(T,{buttonVariant:"primary",disabled:i.disabled}),!t&&r&&n.createElement(n.Fragment,null,n.createElement(o.A,{m:"24px 0 16px 0"},n.createElement(m.A,null,n.createElement(s.A,null,"OR"))),n.createElement(T,{buttonVariant:"ghostBlue",disabled:i.disabled})),t&&!l&&n.createElement(q,{onClick:()=>g(!0)},"or sign in with SAML"),l&&n.createElement(q,{onClick:()=>g(!1)},"or sign in with credentials")))};var W=t(6391),_=t(1411),L=t(3614),I=t(9594),P=t(5167),U=t(4713),j=t(8658);const R=r.Ay.img(["display:block;width:auto;max-width:340px;height:auto;max-height:300px;margin:0 auto 24px;",""],i.Ay.lessThen(i.nm.SM-1)`
        max-width: 240px;
    `),D=()=>{const{uiConfig:e}=(0,l.Q)(),a=e.header_image||"/static/standalone/client/media/logo.svg",{loading:t,error:r,isSamlAvailable:i,isSamlDefault:o,companyName:s,onSubmit:m}=function(){const e=(0,W.W6)(),{enabled_auth_methods:a,login_text:t}=(0,l.Q)().uiConfig,r=a.includes("saml"),i="saml"===a[0],o=(0,I.jL)(),[s,{isLoading:m}]=(0,A.I8)(),{error:d,clearError:u,handleError:c}=function(){const[e,a]=(0,n.useState)(""),t=(0,W.W6)(),r=(0,I.jL)();return{error:e,handleError:async(e,n)=>{if((0,M.W)(e)){const{data:i}=e;!function(e){return(0,U.z)(e)&&e.user_properties.requires_mfa_enrollment}(i)?(0,j.x)(i)?((e,a)=>{r((0,_.ht)(a.username)),r((0,_.wF)(e)),t.push(L.f.mfaChallenge)})(i,n):(0,k.Z)(i)&&a(i.reason):(e=>{const n=(0,P.d)(e);n?(r((0,_.Wj)(n)),t.push(L.f.mfaEnrollment)):a("Invalid response")})(i)}},clearError:()=>a("")}}();return{loading:m,error:d,companyName:t??void 0,onSubmit:async a=>{u();try{const t=await s(a).unwrap();o((0,_.Wj)(t));const n=v.E.readFromUrl();v.E.saveToLocalStorage(n),e.push(L.f.downloads)}catch(e){c(e,a)}},isSamlAvailable:r,isSamlDefault:i}}();return n.createElement(n.Fragment,null,n.createElement(R,{alt:"",src:a}),n.createElement(B,{id:"client-login",name:"client-login",companyName:s,onSubmit:m,disabled:t,error:r,isSamlAvailable:i,isSamlDefault:o}))}},5772:(e,a,t)=>{t.d(a,{BB:()=>s,I8:()=>o,Ir:()=>u,Km:()=>p,SV:()=>d,eR:()=>c,mg:()=>m});var n=t(323),r=t(6270),i=t(5167);const l=t(2644).U.injectEndpoints({endpoints:e=>({loginWithEmailAndPassword:e.mutation({query:e=>({url:n.M.login,method:"POST",body:e}),transformResponse:e=>(0,i.d)(e)}),loginWithSaml:e.mutation({query:e=>({url:n.M.samlAssertion,method:"POST",body:e}),transformResponse:e=>(0,i.d)(e)}),vpnSamlAuth:e.mutation({query:e=>({url:n.M.vpnSamlAuth,method:"POST",body:e})}),getIdpUrl:e.query({query:e=>({url:n.M.getIdpUrl,params:{relay_state:e}})}),submitMfaChallenge:e.mutation({query:e=>({url:n.M.mfaChallenge,method:"POST",body:e}),transformResponse:e=>(0,i.d)(e)}),changePassword:e.mutation({query:({newPassword:e,token:a,userName:t})=>({url:n.M.passwordChange,method:"POST",body:{username:t,new_password:e},headers:{[r.j]:a}})}),enrollInMfa:e.mutation({query:({token:e,authToken:a})=>({url:n.M.mfaEnroll,method:"POST",body:{token:e},headers:{[r.j]:a}}),transformResponse:e=>(0,i.d)(e)})})}),{useLoginWithEmailAndPasswordMutation:o,useLoginWithSamlMutation:s,useSubmitMfaChallengeMutation:m,useChangePasswordMutation:d,useEnrollInMfaMutation:u,useLazyGetIdpUrlQuery:c,useVpnSamlAuthMutation:p}=l},8658:(e,a,t)=>{function n(e){return"object"==typeof e&&null!==e&&Reflect.has(e,"challenge_context")}t.d(a,{x:()=>n})},7894:(e,a,t)=>{t.d(a,{Z:()=>d});var n=t(4041),r=t(8081),i=t(9192),l=t(3580),o=t(738);const s=(0,r.AH)(["margin-right:auto;margin-left:auto;"]),m=r.Ay.div([""," max-width:",";padding:var(--spacing-md,32px) var(--spacing-xs,16px);background:#fff;border:1px solid ",";border-radius:1rem;"," ",""],(0,i.A)("centered")`
       ${s}
    `,(({maxWidth:e})=>(e=>{if(void 0!==e)return"number"==typeof e?`${e}px`:e})(e)),l.A.neutralBorder,o.Ay.moreThen(o.nm.SM)`
        padding: var(--spacing-md, 32px);
        ${(0,i.A)("withShadow")`
            box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);
        `}
    `,o.Ay.moreThen(o.nm.MD)`
        padding: var(--spacing-md, 32px) var(--spacing-lg, 48px);
    `),d=e=>{const{children:a,...t}=e;return n.createElement(m,t,a)}},9078:(e,a,t)=>{t.d(a,{H1:()=>d});var n=t(9690),r=t(4041),i=t(3580),l=t(8081),o=t(3578),s=t(738);const m=(0,l.Ay)(o.A)(["margin-top:0;margin-bottom:var(--spacing-md,32);letter-spacing:-0.64px;",""],s.Ay.lessThen(s.nm.MD-1)`
        margin-bottom: var(--spacing-sm, 24);
        font-size: 24px;
        line-height: 32px;
        letter-spacing: -0.48px;
    `),d=e=>r.createElement(m,(0,n.A)({color:i.A.neutralTextTitle,inline:!1,variant:"displayLg",center:!0,weight:"semiBold"},e))}}]);