!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s=(new e.Error).stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="42750da6-b515-4936-93f4-6b8fa72e7a66",e._sentryDebugIdIdentifier="sentry-dbid-42750da6-b515-4936-93f4-6b8fa72e7a66")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2626],{67238:function(e,s,a){Promise.resolve().then(a.bind(a,53970)),Promise.resolve().then(a.bind(a,15393)),Promise.resolve().then(a.bind(a,14766))},53970:function(e,s,a){"use strict";a.d(s,{default:function(){return E}});var l=a(73449),n=a(71079),t=a(45109),r=a(96808),i=a.n(r),o=a(89060),d=a.n(o),c=a(85429),m=a(22862),u=a(77535),h=a(24917),p=a(56473),f=a(88253),x=a(90709),b=a(82147),j=a(77514),g=a(14766),v=a(67502);function w(e){let{open:s,handleClose:a}=e,[t,r]=(0,n.useState)(""),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)({}),u=async e=>{if(e.preventDefault(),t){o(!0);try{let e=await m.default.post("/api/auth/forgot-password",{email:t});e.data.success?(g.default.success("A password reset link has been sent to your email address!",{duration:5e3}),a()):(0,f.Eo)(e.data)}catch(e){console.error(e),e.response.data.error&&((0,f.Eo)(e.response.data.error),e.response.data.input_errors&&c(e.response.data.input_errors))}finally{o(!1)}}else c({email:"Email cannot be blank"})};return(0,l.jsxs)(v.Z,{show:s,onHide:a,children:[(0,l.jsx)(v.Z.Header,{closeButton:!0,children:(0,l.jsx)(v.Z.Title,{children:"Forgot your NLPatent password?"})}),(0,l.jsxs)("form",{onSubmit:u,noValidate:!0,children:[(0,l.jsx)(v.Z.Body,{children:(0,l.jsxs)("div",{className:"mb-3 row",children:[(0,l.jsx)("label",{htmlFor:"inputEmail1",className:"col-sm-3 col-form-label",children:"Your Email"}),(0,l.jsxs)("div",{className:"col-sm-9",children:[(0,l.jsx)("input",{type:"email",className:"form-control",id:"inputEmail1",placeholder:"Enter your email",value:t,onChange:e=>r(e.target.value)}),(0,l.jsx)("div",{className:"text-danger",children:d.email})]})]})}),(0,l.jsxs)(v.Z.Footer,{children:[(0,l.jsx)("button",{type:"button",className:"btn me-3",onClick:a,children:"Cancel"}),(0,l.jsx)("button",{type:"submit",className:"btn btn-outline-primary",disabled:i,children:i?(0,l.jsxs)("span",{children:[(0,l.jsx)("span",{className:"spinner-grow spinner-grow-sm me-2",role:"status","aria-hidden":"true"}),"Loading..."]}):(0,l.jsx)("span",{children:"Submit"})})]})]})]})}function N(){let[e,s]=(0,n.useState)(""),[a,t]=(0,n.useState)(""),[r,i]=(0,n.useState)(!0),[o,g]=(0,n.useState)({}),[v,N]=(0,n.useState)(""),[y,E]=(0,n.useState)(!1),{fetchUser:k}=(0,h.aC)(),{mutate:S,isPending:C}=(0,c.D)({mutationFn:async()=>{let s=await m.default.post("/api/auth/login",{email:e,password:a,remember_me:r});b.X.parse(s.data)},onSuccess:()=>{k()},onError:e=>{(0,x.i)(e);let s="Could not log in. Please try again later.";if(e instanceof u.d7){var a;let l=j.m.safeParse(null===(a=e.response)||void 0===a?void 0:a.data);l.success&&l.data.error&&(s=l.data.error)}N(s)}});return(0,n.useEffect)(()=>{let e=(0,f.R0)();e&&s(e)},[]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("form",{onSubmit:s=>{s.preventDefault(),N(""),g({});let l={};if(0===e.length?l.email="Please enter your email.":p.CU.test(e)||(l.email="Please enter a valid email."),0===a.length?l.password="Please enter your password.":a.length<p.lo&&(l.password="Password should be at least ".concat(p.lo," characters long.")),d()(l)){let s=r?e:"";(0,f.ME)(s),S()}else g(l)},noValidate:!0,children:[v.length>0&&(0,l.jsx)("div",{className:"alert alert-warning mt-3",role:"alert",children:v}),(0,l.jsxs)("div",{className:"row mb-3",children:[(0,l.jsx)("label",{htmlFor:"inputEmail",className:"col-xs-12 col-sm-3 col-form-label",children:"Email"}),(0,l.jsxs)("div",{className:"col-sm-9",children:[(0,l.jsx)("input",{type:"email",name:"email",className:o.email?"form-control is-invalid":"form-control",id:"inputEmail","aria-describedby":"emailHelp",placeholder:"Enter your email",autoComplete:"on",value:e,onChange:e=>{g({...o,email:""}),s(e.target.value.trim())}}),(0,l.jsx)("div",{id:"inputEmailFeedback",className:"invalid-feedback",children:o.email})]})]}),(0,l.jsxs)("div",{className:"mb-2 row",children:[(0,l.jsx)("label",{htmlFor:"inputPassword",className:"col-sm-3 col-form-label",children:"Password"}),(0,l.jsxs)("div",{className:"col-sm-9",children:[(0,l.jsx)("input",{type:"password",className:o.password?"form-control is-invalid":"form-control",id:"inputPassword",placeholder:"Enter password",value:a,onChange:e=>{g({...o,password:""}),t(e.target.value.trim())}}),(0,l.jsx)("div",{id:"inputPasswordFeedback",className:"invalid-feedback",children:o.password})]})]}),(0,l.jsxs)("div",{className:"d-flex justify-content-between align-items-center callout mb-3",children:[(0,l.jsxs)("div",{className:"form-check",children:[(0,l.jsx)("input",{className:"form-check-input me-2",type:"checkbox",checked:r,id:"rememberMe",onChange:()=>i(!r)}),(0,l.jsx)("label",{className:"form-check-label",htmlFor:"rememberMe",children:"Remember Me"})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{className:"nlp-btn-link",onClick:()=>E(!0),children:"Forgot password?"})})]}),(0,l.jsxs)("div",{className:"d-flex justify-content-between align-items-center",children:[(0,l.jsx)("a",{href:p.$1,className:"nlp-btn-link me-4",children:"Don't have an account? Register here"}),(0,l.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:C,children:C?(0,l.jsxs)("span",{children:[(0,l.jsx)("span",{className:"spinner-grow spinner-grow-sm me-2",role:"status","aria-hidden":"true"}),"Loading..."]}):(0,l.jsx)("span",{children:"Login"})})]})]}),(0,l.jsx)(w,{open:y,handleClose:()=>E(!1)})]})}function y(){let[e,s]=(0,n.useState)(""),[a,t]=(0,n.useState)({}),[r,i]=(0,n.useState)(""),[o,c]=(0,n.useState)(!1);return(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("form",{onSubmit:s=>{s.preventDefault(),c(!0),i(""),t({});let a={};0===e.length?a.email="Please enter your email.":p.CU.test(e)||(a.email="Please enter a valid email."),d()(a)?m.default.post("/api/auth/sso",{email:e}).then(e=>{c(!1),window.location.href=e.data.data.redirect_url}).catch(e=>{(0,x.i)(e);let s="Could not log in. Please try again later.";if(e instanceof u.d7){var a;let l=j.m.safeParse(null===(a=e.response)||void 0===a?void 0:a.data);l.success&&l.data.error&&(s=l.data.error)}i(s),c(!1)}):(t(a),c(!1))},noValidate:!0,children:[r.length>0&&(0,l.jsx)("div",{className:"alert alert-warning mt-3",role:"alert",children:r}),(0,l.jsxs)("div",{className:"row mb-3",children:[(0,l.jsx)("label",{htmlFor:"inputEmail",className:"col-xs-12 col-sm-3 col-form-label",children:"Email"}),(0,l.jsxs)("div",{className:"col-sm-9",children:[(0,l.jsx)("input",{type:"email",name:"email",className:a.email?"form-control is-invalid":"form-control",id:"inputEmail","aria-describedby":"emailHelp",placeholder:"Enter your email",autoComplete:"on",value:e,onChange:e=>{t({...a,email:""}),s(e.target.value.trim())}}),(0,l.jsx)("div",{id:"inputEmailFeedback",className:"invalid-feedback",children:a.email})]})]}),(0,l.jsxs)("div",{className:"d-flex justify-content-between align-items-center",children:[(0,l.jsx)("a",{href:p.$1,className:"nlp-btn-link me-4",children:"Don't have an account? Register here"}),(0,l.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:o,children:o?(0,l.jsxs)("span",{children:[(0,l.jsx)("span",{className:"spinner-grow spinner-grow-sm me-2",role:"status","aria-hidden":"true"}),"Loading..."]}):(0,l.jsx)("span",{children:"Continue with SSO"})})]})]})})}function E(){let e=(0,t.useSearchParams)(),s=(0,t.useRouter)(),[a,r]=(0,n.useState)((null==e?void 0:e.get("sso"))==="true");return(0,n.useEffect)(()=>{let l=new URLSearchParams(e||void 0);a?l.set("sso","true"):l.delete("sso");let n="?".concat(l.toString()),t="/login".concat(n.length>1?n:"");s.replace(t)},[a,s,e]),(0,l.jsx)("div",{className:"d-flex flex-column flex-grow-1",children:(0,l.jsx)("div",{className:i().login+" pt-5 d-flex flex-column flex-grow-1",children:(0,l.jsx)("div",{className:"container",children:(0,l.jsxs)("div",{className:"col-md-10 offset-md-1 col-lg-6 offset-lg-3 col-xl-6 offset-xl-3 mb-5 px-2",children:[(0,l.jsxs)("div",{className:"d-flex justify-content-between",children:[(0,l.jsx)("h5",{children:"Existing User"}),a?(0,l.jsx)("span",{className:"nlp-btn-link",onClick:()=>r(!1),children:"Use your password instead"}):(0,l.jsx)("span",{className:"nlp-btn-link",onClick:()=>r(!0),children:"Use single sign-on (SSO) instead"})]}),(0,l.jsx)("hr",{}),a?(0,l.jsx)(y,{}):(0,l.jsx)(N,{})]})})})})}},96808:function(e){e.exports={login:"login_login__UiE7x"}}},function(e){e.O(0,[4092,3312,2050,4766,9424,4491,982,5166,5393,697,1442,1811,1744],function(){return e(e.s=67238)}),_N_E=e.O()}]);