@saasquatch/mint-components 2.1.7-1 → 2.1.7-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -952,7 +952,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
952
952
  if (!globalPromise)
953
953
  globalPromise = request({ oobCode });
954
954
  const result = await globalPromise;
955
- console.log({ result });
956
955
  if (!(result instanceof Error) &&
957
956
  result.verifyManagedIdentityEmail.success) {
958
957
  // Needs to be explicitly updated if multiple renders have occured
@@ -976,7 +975,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
976
975
  disableContinue,
977
976
  error: ((_g = (_f = (_e = (_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.extensions) === null || _g === void 0 ? void 0 : _g.message) || ((_k = (_j = (_h = errors === null || errors === void 0 ? void 0 : errors.response) === null || _h === void 0 ? void 0 : _h.errors) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.message) ||
978
977
  (((errors === null || errors === void 0 ? void 0 : errors.message) || !validEmail) && networkErrorMessage),
979
- success: completed && (verified || validEmail),
978
+ success: completed && successful && (verified || validEmail),
980
979
  },
981
980
  data: {
982
981
  oobCode,
@@ -43,7 +43,6 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
43
43
  if (!globalPromise)
44
44
  globalPromise = request({ oobCode });
45
45
  const result = await globalPromise;
46
- console.log({ result });
47
46
  if (!(result instanceof Error) &&
48
47
  result.verifyManagedIdentityEmail.success) {
49
48
  // Needs to be explicitly updated if multiple renders have occured
@@ -67,7 +66,7 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
67
66
  disableContinue,
68
67
  error: ((_g = (_f = (_e = (_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.extensions) === null || _g === void 0 ? void 0 : _g.message) || ((_k = (_j = (_h = errors === null || errors === void 0 ? void 0 : errors.response) === null || _h === void 0 ? void 0 : _h.errors) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.message) ||
69
68
  (((errors === null || errors === void 0 ? void 0 : errors.message) || !validEmail) && networkErrorMessage),
70
- success: completed && (verified || validEmail),
69
+ success: completed && successful && (verified || validEmail),
71
70
  },
72
71
  data: {
73
72
  oobCode,
@@ -948,7 +948,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
948
948
  if (!globalPromise)
949
949
  globalPromise = request({ oobCode });
950
950
  const result = await globalPromise;
951
- console.log({ result });
952
951
  if (!(result instanceof Error) &&
953
952
  result.verifyManagedIdentityEmail.success) {
954
953
  // Needs to be explicitly updated if multiple renders have occured
@@ -972,7 +971,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
972
971
  disableContinue,
973
972
  error: ((_g = (_f = (_e = (_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.extensions) === null || _g === void 0 ? void 0 : _g.message) || ((_k = (_j = (_h = errors === null || errors === void 0 ? void 0 : errors.response) === null || _h === void 0 ? void 0 : _h.errors) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.message) ||
974
973
  (((errors === null || errors === void 0 ? void 0 : errors.message) || !validEmail) && networkErrorMessage),
975
- success: completed && (verified || validEmail),
974
+ success: completed && successful && (verified || validEmail),
976
975
  },
977
976
  data: {
978
977
  oobCode,
@@ -1 +1 @@
1
- var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))e[s]=r[s]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,r,t,o){function s(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function n(e){try{l(o["throw"](e))}catch(e){i(e)}}function l(e){e.done?t(e.value):s(e.value).then(a,n)}l((o=o.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,s,i,a;return a={next:n(0),throw:n(1),return:n(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function n(e){return function(r){return l([e,r])}}function l(a){if(o)throw new TypeError("Generator is already executing.");while(t)try{if(o=1,s&&(i=a[0]&2?s["return"]:a[0]?s["throw"]||((i=s["return"])&&i.call(s),0):s.next)&&!(i=i.call(s,a[1])).done)return i;if(s=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;s=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=r.call(e,t)}catch(e){a=[6,e];s=0}finally{o=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h as h$1}from"./index-38ad4957.js";import{k as useState,n as h,m as useRef,f as useEffect}from"./dom-context-hooks.module-50442785.js";import{u as un,j as jn,i as isDemo,a as je,h as hn,V as Ve,b as useCallback,J,c as an,e as setUserIdentity}from"./index.module-8ba90d99.js";import{j as jsonpointer}from"./jsonpointer-388a7082.js";import{c as cjs}from"./cjs-bdfb4486.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import"./mixins-f750863a.js";import"./sqm-text-span-view-738acfb3.js";import{P as PortalForgotPasswordView,a as PortalLoginView,b as PortalRegisterView,c as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-42f7bb1e.js";import{A as AsYouType,u as usePortalRegistrationForm}from"./usePortalRegistrationForm-0f11909c.js";import{u as useRegistrationFormState}from"./useRegistrationFormState-0666533e.js";import{P as PortalRegistrationFormView}from"./sqm-portal-registration-form-view-2f4936ef.js";function usePortalForgotPassword(e){var r=this;var t,o,s,i,a,n,l;var u=useState(false),d=u[0],c=u[1];var g=useState(""),h=g[0],f=g[1];var v=un(),m=v[0],b=v[1],p=b.loading,P=b.data,w=b.errors;var y=new URLSearchParams(jn.location.search);var x=y.get("nextPage");var E=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:f("");c(false);o=t.detail.formData;o===null||o===void 0?void 0:o.forEach((function(e,r){jsonpointer.set(o,r,e)}));s=x?{nextPage:x}:null;i=e.redirectPath;a={email:o.email,urlParams:s,redirectPath:i};return[4,m(a)];case 1:n=l.sent();if(n instanceof Error){if(n.message)f(e.networkErrorMessage);return[2]}if((r=n.requestManagedIdentityPasswordResetEmail)===null||r===void 0?void 0:r.success){c(true)}return[2]}}))}))};return{states:{loading:p,error:((i=(s=(o=(t=w===null||w===void 0?void 0:w.response)===null||t===void 0?void 0:t.errors)===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.extensions)===null||i===void 0?void 0:i.message)||((l=(n=(a=w===null||w===void 0?void 0:w.response)===null||a===void 0?void 0:a.errors)===null||n===void 0?void 0:n[0])===null||l===void 0?void 0:l.message)||h,success:d,loginPath:e.loginPath,headerText:e.headerText,loginText:e.loginText},callbacks:{submit:E}}}var PortalForgotPassword=function(){function e(e){registerInstance(this,e);this.ignored=true;this.redirectPath="/resetPassword";this.emailLabel="Email";this.submitLabel="Request Password Reset";this.loginPath="/login";this.headerText="Enter your email below to receive a password reset link.";this.loginText="Sign In";this.networkErrorMessage="An error occurred while loading this page. Please refresh the page.";this.successAlertText="If an account with that email exists, a password reset email will be sent.";this.backgroundColor="var(--sqm-portal-background, #ffffff)";this.borderRadius="var(--sqm-border-radius-normal, 8px)";this.border="var(--sqm-border-thickness, 1px) solid var(--sqm-border-color, #eaeaea)";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalForgotPasswordDemo(this):usePortalForgotPassword(this),r=e.states,t=e.callbacks;var o={messageSlot:h$1("slot",{name:"messageSlot"},this.headerText),emailLabel:this.emailLabel,submitLabel:this.submitLabel,successAlertText:this.successAlertText,loginText:this.loginText,backgroundColor:this.backgroundColor,borderRadius:this.borderRadius,border:this.border};return h$1(PortalForgotPasswordView,{states:r,callbacks:t,content:o})};return e}();function usePortalForgotPasswordDemo(e){var r=this;return cjs({states:{error:"",loading:false,success:false},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){return[2]}))}))}},content:{secondaryButton:h$1("sl-button",{type:"secondary",exportparts:"base: secondarybutton-base",disabled:false,onClick:function(){return jn.push(e.loginPath)}},e.loginText),messageSlot:h$1("span",null,e.headerText),emailLabel:e.emailLabel,submitLabel:e.submitLabel,successAlertText:e.successAlertText,loginText:e.loginText,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius,border:e.border}},e.demoData||{},{arrayMerge:function(e,r){return r}})}function usePortalLogin(e){var r=this;var t,o,s,i,a,n,l,u,d,c,g,h,f,v;var m=je(),b=m[0],p=m[1],P=p.loading,w=p.errors,y=p.data;var x=hn(),E=x[0],L=x[1],_=L.loading,T=L.errors;var k=useState(""),M=k[0],R=k[1];var j=new URLSearchParams(jn.location.search);var S=j.get("nextPage");var q=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:if(!((r=t.detail)===null||r===void 0?void 0:r.credential))return[2];return[4,E({idToken:t.detail.credential})];case 1:a=l.sent();if(a instanceof Error){if((a===null||a===void 0?void 0:a.message)||((o=a===null||a===void 0?void 0:a["response"])===null||o===void 0?void 0:o["error"]))if((s=a===null||a===void 0?void 0:a["response"])===null||s===void 0?void 0:s["errors"].some((function(e){var r;return((r=e===null||e===void 0?void 0:e["extensions"])===null||r===void 0?void 0:r["message"])==="Invalid Credentials."}))){R(e.googleUserNotRegisteredError)}else{R(e.networkErrorMessage)}return[2]}if((i=a.authenticateManagedIdentityWithGoogle)===null||i===void 0?void 0:i.token){j.delete("nextPage");n=sanitizeUrlPath(S||e.nextPage);jn.push(n.href)}return[2]}}))}))};var I=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:R("");s=t.detail.formData;s===null||s===void 0?void 0:s.forEach((function(e,r){jsonpointer.set(s,r,e)}));i={email:s.email,password:s.password};return[4,b(i)];case 1:a=l.sent();if(a instanceof Error){if((a===null||a===void 0?void 0:a.message)||((r=a===null||a===void 0?void 0:a["response"])===null||r===void 0?void 0:r["error"]))R(e.networkErrorMessage);return[2]}if((o=a.authenticateManagedIdentityWithEmailAndPassword)===null||o===void 0?void 0:o.token){j.delete("nextPage");n=sanitizeUrlPath(S||e.nextPage);jn.push(n.href)}return[2]}}))}))};var F=((i=(s=(o=(t=w===null||w===void 0?void 0:w.response)===null||t===void 0?void 0:t.errors)===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.extensions)===null||i===void 0?void 0:i.message)||((l=(n=(a=w===null||w===void 0?void 0:w.response)===null||a===void 0?void 0:a.errors)===null||n===void 0?void 0:n[0])===null||l===void 0?void 0:l.message)||M;var C=((g=(c=(d=(u=T===null||T===void 0?void 0:T.response)===null||u===void 0?void 0:u.errors)===null||d===void 0?void 0:d[0])===null||c===void 0?void 0:c.extensions)===null||g===void 0?void 0:g.message)||((v=(f=(h=T===null||T===void 0?void 0:T.response)===null||h===void 0?void 0:h.errors)===null||f===void 0?void 0:f[0])===null||v===void 0?void 0:v.message)||M;return{states:{loading:P||_,error:F||C,registerPath:e.registerPath,forgotPasswordPath:e.forgotPasswordPath},callbacks:{googleSubmit:q,submit:I}}}var PortalGoogleLogin=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Sign In";this.forgotPasswordPath="/forgotPassword";this.forgotPasswordLabel="Forgot Password?";this.registerLabel="Register";this.registerPath="/register";this.pageLabel="Sign in to your account";this.networkErrorMessage="An error occurred while logging you in. Please refresh the page and try again.";this.googleUserNotRegisteredError="Your Google account has not registered on our platform. Please complete the registration process with your Google account.";this.registerCTA="Don't have an account?";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useLoginDemo(this):usePortalLogin(this),r=e.states,t=e.callbacks;var o={RegisterButton:{"&::part(label)":{padding:"0"}}};var s=createStyleSheet(o);var i=s.toString();var a={forgotPasswordButton:h$1("slot",{name:"forgotPassword"},h$1("a",{onClick:function(){return jn.push(r.forgotPasswordPath)}},this.forgotPasswordLabel)),googleButton:h$1("sqm-google-sign-in",{onInitComplete:t.googleSubmit}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("style",null,i),h$1("span",null,this.registerCTA," ",h$1("sl-button",{size:"large",type:"text",disabled:r.loading,onClick:function(){return jn.push(r.registerPath)},className:s.classes.RegisterButton},this.registerLabel))),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel};return h$1(PortalLoginView,{states:r,callbacks:t,content:a})};return e}();function useLoginDemo(e){var r=this;var t,o;return cjs({states:{error:((o=(t=e.demoData)===null||t===void 0?void 0:t.states)===null||o===void 0?void 0:o.error)||"",loading:false,forgotPasswordPath:"/forgotPassword",registerPath:"/register",showLoginForm:"manual"},callbacks:{googleSubmit:function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("google submit");return[2]}))}))},submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))}},content:{googleButton:null}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var PortalLogin=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Sign In";this.forgotPasswordPath="/forgotPassword";this.forgotPasswordLabel="Forgot Password?";this.registerLabel="Register";this.registerPath="/register";this.pageLabel="Sign in to your account";this.networkErrorMessage="An error occurred while logging you in. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useLoginDemo$1(this):usePortalLogin(this),r=e.states,t=e.callbacks;var o={RegisterButton:{"&::part(label)":{padding:"0"}}};var s=createStyleSheet(o);var i=s.toString();var a={forgotPasswordButton:h$1("slot",{name:"forgotPassword"},h$1("a",{onClick:function(){return jn.push(r.forgotPasswordPath)}},this.forgotPasswordLabel)),googleButton:null,secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("style",null,i),h$1("sl-button",{exportparts:"base: secondarybutton-base",type:"text",disabled:r.loading,onClick:function(){return jn.push(r.registerPath)}},this.registerLabel)),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel};return h$1(PortalLoginView,{states:r,callbacks:t,content:a})};return e}();function useLoginDemo$1(e){var r=this;return cjs({states:{error:"",loading:false,forgotPasswordPath:"/forgotPassword",registerPath:"/register",showLoginForm:"manual"},callbacks:{googleSubmit:function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("google submit");return[2]}))}))},submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))}},content:{googleButton:null}},e.demoData||{},{arrayMerge:function(e,r){return r}})}function usePortalRegister(e){var r=this;var t,o,s,i,a,n,l,u,d;var c=useRef(null);var g=useRegistrationFormState({}),h=g.registrationFormState,f=g.setRegistrationFormState;var v=Ve(),m=v[0],b=v[1],p=b.loading,P=b.errors,w=b.data;useEffect((function(){if(!c.current)return;var e=c.current;e.addEventListener("sl-input",x);return function(){e.removeEventListener("sl-input",x)}}),[c.current]);var y=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n,l,u,d,c;return __generator(this,(function(g){switch(g.label){case 0:o=t.target.getFormControls();s={};i={};o===null||o===void 0?void 0:o.forEach((function(r){if(!r.name)return;var t=r.name;var o=r.value;jsonpointer.set(s,t,o);if(r.required&&!o){jsonpointer.set(i,t,e.requiredFieldErrorMessage)}if(typeof r.validationError==="function"){var a=r.validationError;var n=a({control:r,key:t,value:o});if(n)jsonpointer.set(i,t,n)}}));if((e.confirmPassword||s.confirmPassword)&&s.password!==s.confirmPassword){i=__assign(__assign({},i),{confirmPassword:e.passwordMismatchErrorMessage})}if(Object.keys(i).length){f({loading:false,error:"",validationErrors:i});return[2]}f({loading:true,error:"",validationErrors:{}});a=s.email,n=s.password;delete s.email;delete s.password;delete s.confirmPassword;s=__assign({},s);l=e.redirectPath;u={email:a,password:n,formData:s,redirectPath:l};g.label=1;case 1:g.trys.push([1,3,,4]);return[4,m(u)];case 2:d=g.sent();if(d instanceof Error){throw d}f({loading:false,error:"",validationErrors:{}});if((r=d.registerManagedIdentityWithEmailAndPassword)===null||r===void 0?void 0:r.token){jn.push(e.nextPage)}return[3,4];case 3:c=g.sent();f({loading:false,error:e.networkErrorMessage,validationErrors:{}});return[3,4];case 4:return[2]}}))}))};var x=useCallback((function(e){var r,t;var o=(t=(r=e.target)===null||r===void 0?void 0:r.type)===null||t===void 0?void 0:t.toLowerCase();if(o!=="tel")return;var s=new AsYouType("US");e.target.value=s.input(e.target.value)}),[]);var E="";if((t=P===null||P===void 0?void 0:P.response)===null||t===void 0?void 0:t["error"]){E=e.networkErrorMessage}else if((P===null||P===void 0?void 0:P.message)&&!((o=P===null||P===void 0?void 0:P.response)===null||o===void 0?void 0:o.errors.length)){E=e.networkErrorMessage}else{E=((n=(a=(i=(s=P===null||P===void 0?void 0:P.response)===null||s===void 0?void 0:s.errors)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.extensions)===null||n===void 0?void 0:n.message)||((d=(u=(l=P===null||P===void 0?void 0:P.response)===null||l===void 0?void 0:l.errors)===null||u===void 0?void 0:u[0])===null||d===void 0?void 0:d.message)||(h===null||h===void 0?void 0:h.error)}return{states:{loading:p,error:E,registrationFormState:h,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs,loginPath:e.loginPath,disablePasswordValidation:e.disablePasswordValidation},callbacks:{submit:y,inputFunction:x},refs:{formRef:c}}}var PortalRegister=function(){function e(e){registerInstance(this,e);this.ignored=false;this.nextPage="/";this.redirectPath="/verifyEmail";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Register";this.loginLabel="Sign in";this.confirmPasswordLabel="Confirm Password";this.confirmPassword=false;this.disablePasswordValidation=false;this.hideInputs=false;this.pageLabel="Register";this.loginPath="/login";this.requiredFieldErrorMessage="Cannot be empty";this.networkErrorMessage="Network request failed.";this.passwordMismatchErrorMessage="Passwords do not match.";this.invalidEmailErrorMessage="Must be a valid email address";this.meetsRequirementsText="Password has met all requirements";this.doesNotMeetRequirementsText="Password must meet the following requirements:";this.minErrorText="be a minimum of 8 characters";this.uppercaseErrorText="contain at least 1 uppercase character";this.lowercaseErrorText="contain at least 1 lowercase character";this.hasErrorText="contain at least 1 number or symbol";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useRegisterDemo(this):usePortalRegister(this),r=e.states,t=e.callbacks,o=e.refs;var s={formData:h$1("slot",{name:"formData"}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("sl-button",{type:"text",disabled:r.loading,onClick:function(){return jn.push(r.loginPath)}},this.loginLabel)),terms:h$1("slot",{name:"terms"}),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel,confirmPasswordLabel:this.confirmPasswordLabel,invalidEmailErrorMessage:this.invalidEmailErrorMessage,requiredFieldErrorMessage:this.requiredFieldErrorMessage,meetsRequirementsText:this.meetsRequirementsText,doesNotMeetRequirementsText:this.doesNotMeetRequirementsText,minErrorText:this.minErrorText,uppercaseErrorText:this.uppercaseErrorText,lowercaseErrorText:this.lowercaseErrorText,hasErrorText:this.hasErrorText};return h$1(PortalRegisterView,{states:r,callbacks:t,content:s,refs:o})};return e}();function useRegisterDemo(e){var r=this;return cjs({states:{error:"",loading:false,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs||false,customPasswordField:false,loginPath:e.loginPath,disablePasswordValidation:e.disablePasswordValidation},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))},inputFunction:function(){}},refs:{formRef:{}}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var PortalRegistrationForm=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.redirectPath="/verifyEmail";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Register";this.loginLabel="Sign in";this.confirmPasswordLabel="Confirm Password";this.confirmPassword=false;this.disablePasswordValidation=false;this.hideInputs=false;this.pageLabel="Register";this.loginPath="/login";this.requiredFieldErrorMessage="Cannot be empty";this.networkErrorMessage="Network request failed.";this.passwordMismatchErrorMessage="Passwords do not match.";this.invalidEmailErrorMessage="Must be a valid email address";this.formDisabledErrorMessage="The registration form is currently disabled.";this.meetsRequirementsText="Password has met all requirements";this.doesNotMeetRequirementsText="Password must meet the following requirements:";this.minErrorText="be a minimum of 8 characters";this.uppercaseErrorText="contain at least 1 uppercase character";this.lowercaseErrorText="contain at least 1 lowercase character";this.hasErrorText="contain at least 1 number or symbol";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useRegisterDemo$1(this):usePortalRegistrationForm(this),r=e.states,t=e.callbacks,o=e.refs;var s={formData:h$1("slot",{name:"formData"}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("sl-button",{type:"text",disabled:r.loading,onClick:function(){return jn.push(r.loginPath)}},this.loginLabel)),terms:h$1("slot",{name:"terms"}),emailOptIn:h$1("slot",{name:"emailOptIn"}),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel,confirmPasswordLabel:this.confirmPasswordLabel,networkErrorMessage:this.networkErrorMessage,passwordMismatchErrorMessage:this.passwordMismatchErrorMessage,invalidEmailErrorMessage:this.invalidEmailErrorMessage,formDisabledErrorMessage:this.formDisabledErrorMessage,requiredFieldErrorMessage:this.requiredFieldErrorMessage,meetsRequirementsText:this.meetsRequirementsText,doesNotMeetRequirementsText:this.doesNotMeetRequirementsText,minErrorText:this.minErrorText,uppercaseErrorText:this.uppercaseErrorText,lowercaseErrorText:this.lowercaseErrorText,hasErrorText:this.hasErrorText};return h$1(PortalRegistrationFormView,{states:r,callbacks:t,content:s,refs:o})};return e}();function useRegisterDemo$1(e){var r=this;return cjs({states:{error:"",loading:false,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs||false,customPasswordField:false,loginPath:"/login"},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))},inputFunction:function(){}},refs:{formRef:{}}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var globalPromise=null;function usePortalVerifyEmail(e){var r=this;var t=e.nextPage,o=e.failedPage,s=e.verifySuccessText,i=e.verifyEmailText,a=e.verifyInvalidText,n=e.networkErrorMessage,l=e.continueText;var u,d,c,g,h,f,v,m,b,p;var P=useState(false),w=P[0],y=P[1];var x=useState(false),E=x[0],L=x[1];var _=J();var T=an(),k=T[0],M=T[1],R=M.loading,j=M.data,S=M.errors;var q=new URLSearchParams(jn.location.search);var I=q.get("oobCode");var F=q.get("email");var C=q.get("nextPage");var D=j===undefined&&S===undefined&&!!I;var $=!!(((u=_===null||_===void 0?void 0:_.managedIdentity)===null||u===void 0?void 0:u.emailVerified)||((d=j===null||j===void 0?void 0:j.verifyManagedIdentityEmail)===null||d===void 0?void 0:d.success)||E);var V=((c=_===null||_===void 0?void 0:_.managedIdentity)===null||c===void 0?void 0:c.email)===F;var B=function(){return jn.push({pathname:o,search:q.toString()&&"?"+q.toString()})};var A=function(){q.delete("nextPage");var e=sanitizeUrlPath(C||t);jn.push(e.href)};var N=function(){setTimeout((function(){setUserIdentity(undefined);A()}),3e3)};var U=function(){setTimeout(A,3e3)};useEffect((function(){var e=function(){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(r){switch(r.label){case 0:if(!globalPromise)globalPromise=k({oobCode:I});return[4,globalPromise];case 1:e=r.sent();console.log({result:e});if(!(e instanceof Error)&&e.verifyManagedIdentityEmail.success){L(true)}y(true);return[2]}}))}))};e()}),[]);useEffect((function(){if(!w)return;if($&&V)U();else N()}),[w,$]);return{states:{loading:R||!w,disableContinue:D,error:((v=(f=(h=(g=S===null||S===void 0?void 0:S.response)===null||g===void 0?void 0:g.errors)===null||h===void 0?void 0:h[0])===null||f===void 0?void 0:f.extensions)===null||v===void 0?void 0:v.message)||((p=(b=(m=S===null||S===void 0?void 0:S.response)===null||m===void 0?void 0:m.errors)===null||b===void 0?void 0:b[0])===null||p===void 0?void 0:p.message)||((S===null||S===void 0?void 0:S.message)||!V)&&n,success:w&&($||V)},data:{oobCode:I},callbacks:{failed:B,gotoNextPage:A},content:{verifySuccessText:s,verifyEmailText:i,verifyInvalidText:a,continueText:l}}}var PortalVerifyEmail=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.failedPage="/";this.verifyEmailText="Verify your email";this.verifySuccessText="Your email has been verified and you are being redirected. If you are not redirected, please click Continue.";this.verifyInvalidText="The email verification code is invalid or has expired, please try again.";this.continueText="Continue";this.networkErrorMessage="An error occurred while verifying your email. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalVerifyEmailDemo(getProps(this)):usePortalVerifyEmail(getProps(this)),r=e.states,t=e.data,o=e.callbacks,s=e.content;return h$1(PortalVerifyEmailView,{states:r,data:t,callbacks:o,content:s})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,success:true},data:{oobCode:"code"},callbacks:{failed:function(){console.log("failed")},gotoNextPage:function(){}},content:{verifySuccessText:e.verifySuccessText,verifyEmailText:e.verifyEmailText,verifyInvalidText:e.verifyInvalidText,continueText:e.continueText}},e.demoData||{},{arrayMerge:function(e,r){return r}})}export{PortalForgotPassword as sqm_portal_forgot_password,PortalGoogleLogin as sqm_portal_google_login,PortalLogin as sqm_portal_login,PortalRegister as sqm_portal_register,PortalRegistrationForm as sqm_portal_registration_form,PortalVerifyEmail as sqm_portal_verify_email};
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++){r=arguments[t];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))e[s]=r[s]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,r,t,o){function s(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function n(e){try{l(o["throw"](e))}catch(e){i(e)}}function l(e){e.done?t(e.value):s(e.value).then(a,n)}l((o=o.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,s,i,a;return a={next:n(0),throw:n(1),return:n(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function n(e){return function(r){return l([e,r])}}function l(a){if(o)throw new TypeError("Generator is already executing.");while(t)try{if(o=1,s&&(i=a[0]&2?s["return"]:a[0]?s["throw"]||((i=s["return"])&&i.call(s),0):s.next)&&!(i=i.call(s,a[1])).done)return i;if(s=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;s=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=r.call(e,t)}catch(e){a=[6,e];s=0}finally{o=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h as h$1}from"./index-38ad4957.js";import{k as useState,n as h,m as useRef,f as useEffect}from"./dom-context-hooks.module-50442785.js";import{u as un,j as jn,i as isDemo,a as je,h as hn,V as Ve,b as useCallback,J,c as an,e as setUserIdentity}from"./index.module-8ba90d99.js";import{j as jsonpointer}from"./jsonpointer-388a7082.js";import{c as cjs}from"./cjs-bdfb4486.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import"./mixins-f750863a.js";import"./sqm-text-span-view-738acfb3.js";import{P as PortalForgotPasswordView,a as PortalLoginView,b as PortalRegisterView,c as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-42f7bb1e.js";import{A as AsYouType,u as usePortalRegistrationForm}from"./usePortalRegistrationForm-0f11909c.js";import{u as useRegistrationFormState}from"./useRegistrationFormState-0666533e.js";import{P as PortalRegistrationFormView}from"./sqm-portal-registration-form-view-2f4936ef.js";function usePortalForgotPassword(e){var r=this;var t,o,s,i,a,n,l;var u=useState(false),d=u[0],c=u[1];var g=useState(""),h=g[0],f=g[1];var v=un(),m=v[0],b=v[1],p=b.loading,P=b.data,w=b.errors;var y=new URLSearchParams(jn.location.search);var x=y.get("nextPage");var E=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:f("");c(false);o=t.detail.formData;o===null||o===void 0?void 0:o.forEach((function(e,r){jsonpointer.set(o,r,e)}));s=x?{nextPage:x}:null;i=e.redirectPath;a={email:o.email,urlParams:s,redirectPath:i};return[4,m(a)];case 1:n=l.sent();if(n instanceof Error){if(n.message)f(e.networkErrorMessage);return[2]}if((r=n.requestManagedIdentityPasswordResetEmail)===null||r===void 0?void 0:r.success){c(true)}return[2]}}))}))};return{states:{loading:p,error:((i=(s=(o=(t=w===null||w===void 0?void 0:w.response)===null||t===void 0?void 0:t.errors)===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.extensions)===null||i===void 0?void 0:i.message)||((l=(n=(a=w===null||w===void 0?void 0:w.response)===null||a===void 0?void 0:a.errors)===null||n===void 0?void 0:n[0])===null||l===void 0?void 0:l.message)||h,success:d,loginPath:e.loginPath,headerText:e.headerText,loginText:e.loginText},callbacks:{submit:E}}}var PortalForgotPassword=function(){function e(e){registerInstance(this,e);this.ignored=true;this.redirectPath="/resetPassword";this.emailLabel="Email";this.submitLabel="Request Password Reset";this.loginPath="/login";this.headerText="Enter your email below to receive a password reset link.";this.loginText="Sign In";this.networkErrorMessage="An error occurred while loading this page. Please refresh the page.";this.successAlertText="If an account with that email exists, a password reset email will be sent.";this.backgroundColor="var(--sqm-portal-background, #ffffff)";this.borderRadius="var(--sqm-border-radius-normal, 8px)";this.border="var(--sqm-border-thickness, 1px) solid var(--sqm-border-color, #eaeaea)";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalForgotPasswordDemo(this):usePortalForgotPassword(this),r=e.states,t=e.callbacks;var o={messageSlot:h$1("slot",{name:"messageSlot"},this.headerText),emailLabel:this.emailLabel,submitLabel:this.submitLabel,successAlertText:this.successAlertText,loginText:this.loginText,backgroundColor:this.backgroundColor,borderRadius:this.borderRadius,border:this.border};return h$1(PortalForgotPasswordView,{states:r,callbacks:t,content:o})};return e}();function usePortalForgotPasswordDemo(e){var r=this;return cjs({states:{error:"",loading:false,success:false},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){return[2]}))}))}},content:{secondaryButton:h$1("sl-button",{type:"secondary",exportparts:"base: secondarybutton-base",disabled:false,onClick:function(){return jn.push(e.loginPath)}},e.loginText),messageSlot:h$1("span",null,e.headerText),emailLabel:e.emailLabel,submitLabel:e.submitLabel,successAlertText:e.successAlertText,loginText:e.loginText,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius,border:e.border}},e.demoData||{},{arrayMerge:function(e,r){return r}})}function usePortalLogin(e){var r=this;var t,o,s,i,a,n,l,u,d,c,g,h,f,v;var m=je(),b=m[0],p=m[1],P=p.loading,w=p.errors,y=p.data;var x=hn(),E=x[0],L=x[1],_=L.loading,T=L.errors;var k=useState(""),M=k[0],R=k[1];var j=new URLSearchParams(jn.location.search);var S=j.get("nextPage");var q=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:if(!((r=t.detail)===null||r===void 0?void 0:r.credential))return[2];return[4,E({idToken:t.detail.credential})];case 1:a=l.sent();if(a instanceof Error){if((a===null||a===void 0?void 0:a.message)||((o=a===null||a===void 0?void 0:a["response"])===null||o===void 0?void 0:o["error"]))if((s=a===null||a===void 0?void 0:a["response"])===null||s===void 0?void 0:s["errors"].some((function(e){var r;return((r=e===null||e===void 0?void 0:e["extensions"])===null||r===void 0?void 0:r["message"])==="Invalid Credentials."}))){R(e.googleUserNotRegisteredError)}else{R(e.networkErrorMessage)}return[2]}if((i=a.authenticateManagedIdentityWithGoogle)===null||i===void 0?void 0:i.token){j.delete("nextPage");n=sanitizeUrlPath(S||e.nextPage);jn.push(n.href)}return[2]}}))}))};var I=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n;return __generator(this,(function(l){switch(l.label){case 0:R("");s=t.detail.formData;s===null||s===void 0?void 0:s.forEach((function(e,r){jsonpointer.set(s,r,e)}));i={email:s.email,password:s.password};return[4,b(i)];case 1:a=l.sent();if(a instanceof Error){if((a===null||a===void 0?void 0:a.message)||((r=a===null||a===void 0?void 0:a["response"])===null||r===void 0?void 0:r["error"]))R(e.networkErrorMessage);return[2]}if((o=a.authenticateManagedIdentityWithEmailAndPassword)===null||o===void 0?void 0:o.token){j.delete("nextPage");n=sanitizeUrlPath(S||e.nextPage);jn.push(n.href)}return[2]}}))}))};var F=((i=(s=(o=(t=w===null||w===void 0?void 0:w.response)===null||t===void 0?void 0:t.errors)===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.extensions)===null||i===void 0?void 0:i.message)||((l=(n=(a=w===null||w===void 0?void 0:w.response)===null||a===void 0?void 0:a.errors)===null||n===void 0?void 0:n[0])===null||l===void 0?void 0:l.message)||M;var C=((g=(c=(d=(u=T===null||T===void 0?void 0:T.response)===null||u===void 0?void 0:u.errors)===null||d===void 0?void 0:d[0])===null||c===void 0?void 0:c.extensions)===null||g===void 0?void 0:g.message)||((v=(f=(h=T===null||T===void 0?void 0:T.response)===null||h===void 0?void 0:h.errors)===null||f===void 0?void 0:f[0])===null||v===void 0?void 0:v.message)||M;return{states:{loading:P||_,error:F||C,registerPath:e.registerPath,forgotPasswordPath:e.forgotPasswordPath},callbacks:{googleSubmit:q,submit:I}}}var PortalGoogleLogin=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Sign In";this.forgotPasswordPath="/forgotPassword";this.forgotPasswordLabel="Forgot Password?";this.registerLabel="Register";this.registerPath="/register";this.pageLabel="Sign in to your account";this.networkErrorMessage="An error occurred while logging you in. Please refresh the page and try again.";this.googleUserNotRegisteredError="Your Google account has not registered on our platform. Please complete the registration process with your Google account.";this.registerCTA="Don't have an account?";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useLoginDemo(this):usePortalLogin(this),r=e.states,t=e.callbacks;var o={RegisterButton:{"&::part(label)":{padding:"0"}}};var s=createStyleSheet(o);var i=s.toString();var a={forgotPasswordButton:h$1("slot",{name:"forgotPassword"},h$1("a",{onClick:function(){return jn.push(r.forgotPasswordPath)}},this.forgotPasswordLabel)),googleButton:h$1("sqm-google-sign-in",{onInitComplete:t.googleSubmit}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("style",null,i),h$1("span",null,this.registerCTA," ",h$1("sl-button",{size:"large",type:"text",disabled:r.loading,onClick:function(){return jn.push(r.registerPath)},className:s.classes.RegisterButton},this.registerLabel))),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel};return h$1(PortalLoginView,{states:r,callbacks:t,content:a})};return e}();function useLoginDemo(e){var r=this;var t,o;return cjs({states:{error:((o=(t=e.demoData)===null||t===void 0?void 0:t.states)===null||o===void 0?void 0:o.error)||"",loading:false,forgotPasswordPath:"/forgotPassword",registerPath:"/register",showLoginForm:"manual"},callbacks:{googleSubmit:function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("google submit");return[2]}))}))},submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))}},content:{googleButton:null}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var PortalLogin=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Sign In";this.forgotPasswordPath="/forgotPassword";this.forgotPasswordLabel="Forgot Password?";this.registerLabel="Register";this.registerPath="/register";this.pageLabel="Sign in to your account";this.networkErrorMessage="An error occurred while logging you in. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useLoginDemo$1(this):usePortalLogin(this),r=e.states,t=e.callbacks;var o={RegisterButton:{"&::part(label)":{padding:"0"}}};var s=createStyleSheet(o);var i=s.toString();var a={forgotPasswordButton:h$1("slot",{name:"forgotPassword"},h$1("a",{onClick:function(){return jn.push(r.forgotPasswordPath)}},this.forgotPasswordLabel)),googleButton:null,secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("style",null,i),h$1("sl-button",{exportparts:"base: secondarybutton-base",type:"text",disabled:r.loading,onClick:function(){return jn.push(r.registerPath)}},this.registerLabel)),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel};return h$1(PortalLoginView,{states:r,callbacks:t,content:a})};return e}();function useLoginDemo$1(e){var r=this;return cjs({states:{error:"",loading:false,forgotPasswordPath:"/forgotPassword",registerPath:"/register",showLoginForm:"manual"},callbacks:{googleSubmit:function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("google submit");return[2]}))}))},submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))}},content:{googleButton:null}},e.demoData||{},{arrayMerge:function(e,r){return r}})}function usePortalRegister(e){var r=this;var t,o,s,i,a,n,l,u,d;var c=useRef(null);var g=useRegistrationFormState({}),h=g.registrationFormState,f=g.setRegistrationFormState;var v=Ve(),m=v[0],b=v[1],p=b.loading,P=b.errors,w=b.data;useEffect((function(){if(!c.current)return;var e=c.current;e.addEventListener("sl-input",x);return function(){e.removeEventListener("sl-input",x)}}),[c.current]);var y=function(t){return __awaiter(r,void 0,void 0,(function(){var r,o,s,i,a,n,l,u,d,c;return __generator(this,(function(g){switch(g.label){case 0:o=t.target.getFormControls();s={};i={};o===null||o===void 0?void 0:o.forEach((function(r){if(!r.name)return;var t=r.name;var o=r.value;jsonpointer.set(s,t,o);if(r.required&&!o){jsonpointer.set(i,t,e.requiredFieldErrorMessage)}if(typeof r.validationError==="function"){var a=r.validationError;var n=a({control:r,key:t,value:o});if(n)jsonpointer.set(i,t,n)}}));if((e.confirmPassword||s.confirmPassword)&&s.password!==s.confirmPassword){i=__assign(__assign({},i),{confirmPassword:e.passwordMismatchErrorMessage})}if(Object.keys(i).length){f({loading:false,error:"",validationErrors:i});return[2]}f({loading:true,error:"",validationErrors:{}});a=s.email,n=s.password;delete s.email;delete s.password;delete s.confirmPassword;s=__assign({},s);l=e.redirectPath;u={email:a,password:n,formData:s,redirectPath:l};g.label=1;case 1:g.trys.push([1,3,,4]);return[4,m(u)];case 2:d=g.sent();if(d instanceof Error){throw d}f({loading:false,error:"",validationErrors:{}});if((r=d.registerManagedIdentityWithEmailAndPassword)===null||r===void 0?void 0:r.token){jn.push(e.nextPage)}return[3,4];case 3:c=g.sent();f({loading:false,error:e.networkErrorMessage,validationErrors:{}});return[3,4];case 4:return[2]}}))}))};var x=useCallback((function(e){var r,t;var o=(t=(r=e.target)===null||r===void 0?void 0:r.type)===null||t===void 0?void 0:t.toLowerCase();if(o!=="tel")return;var s=new AsYouType("US");e.target.value=s.input(e.target.value)}),[]);var E="";if((t=P===null||P===void 0?void 0:P.response)===null||t===void 0?void 0:t["error"]){E=e.networkErrorMessage}else if((P===null||P===void 0?void 0:P.message)&&!((o=P===null||P===void 0?void 0:P.response)===null||o===void 0?void 0:o.errors.length)){E=e.networkErrorMessage}else{E=((n=(a=(i=(s=P===null||P===void 0?void 0:P.response)===null||s===void 0?void 0:s.errors)===null||i===void 0?void 0:i[0])===null||a===void 0?void 0:a.extensions)===null||n===void 0?void 0:n.message)||((d=(u=(l=P===null||P===void 0?void 0:P.response)===null||l===void 0?void 0:l.errors)===null||u===void 0?void 0:u[0])===null||d===void 0?void 0:d.message)||(h===null||h===void 0?void 0:h.error)}return{states:{loading:p,error:E,registrationFormState:h,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs,loginPath:e.loginPath,disablePasswordValidation:e.disablePasswordValidation},callbacks:{submit:y,inputFunction:x},refs:{formRef:c}}}var PortalRegister=function(){function e(e){registerInstance(this,e);this.ignored=false;this.nextPage="/";this.redirectPath="/verifyEmail";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Register";this.loginLabel="Sign in";this.confirmPasswordLabel="Confirm Password";this.confirmPassword=false;this.disablePasswordValidation=false;this.hideInputs=false;this.pageLabel="Register";this.loginPath="/login";this.requiredFieldErrorMessage="Cannot be empty";this.networkErrorMessage="Network request failed.";this.passwordMismatchErrorMessage="Passwords do not match.";this.invalidEmailErrorMessage="Must be a valid email address";this.meetsRequirementsText="Password has met all requirements";this.doesNotMeetRequirementsText="Password must meet the following requirements:";this.minErrorText="be a minimum of 8 characters";this.uppercaseErrorText="contain at least 1 uppercase character";this.lowercaseErrorText="contain at least 1 lowercase character";this.hasErrorText="contain at least 1 number or symbol";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useRegisterDemo(this):usePortalRegister(this),r=e.states,t=e.callbacks,o=e.refs;var s={formData:h$1("slot",{name:"formData"}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("sl-button",{type:"text",disabled:r.loading,onClick:function(){return jn.push(r.loginPath)}},this.loginLabel)),terms:h$1("slot",{name:"terms"}),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel,confirmPasswordLabel:this.confirmPasswordLabel,invalidEmailErrorMessage:this.invalidEmailErrorMessage,requiredFieldErrorMessage:this.requiredFieldErrorMessage,meetsRequirementsText:this.meetsRequirementsText,doesNotMeetRequirementsText:this.doesNotMeetRequirementsText,minErrorText:this.minErrorText,uppercaseErrorText:this.uppercaseErrorText,lowercaseErrorText:this.lowercaseErrorText,hasErrorText:this.hasErrorText};return h$1(PortalRegisterView,{states:r,callbacks:t,content:s,refs:o})};return e}();function useRegisterDemo(e){var r=this;return cjs({states:{error:"",loading:false,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs||false,customPasswordField:false,loginPath:e.loginPath,disablePasswordValidation:e.disablePasswordValidation},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))},inputFunction:function(){}},refs:{formRef:{}}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var PortalRegistrationForm=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.redirectPath="/verifyEmail";this.emailLabel="Email";this.passwordLabel="Password";this.submitLabel="Register";this.loginLabel="Sign in";this.confirmPasswordLabel="Confirm Password";this.confirmPassword=false;this.disablePasswordValidation=false;this.hideInputs=false;this.pageLabel="Register";this.loginPath="/login";this.requiredFieldErrorMessage="Cannot be empty";this.networkErrorMessage="Network request failed.";this.passwordMismatchErrorMessage="Passwords do not match.";this.invalidEmailErrorMessage="Must be a valid email address";this.formDisabledErrorMessage="The registration form is currently disabled.";this.meetsRequirementsText="Password has met all requirements";this.doesNotMeetRequirementsText="Password must meet the following requirements:";this.minErrorText="be a minimum of 8 characters";this.uppercaseErrorText="contain at least 1 uppercase character";this.lowercaseErrorText="contain at least 1 lowercase character";this.hasErrorText="contain at least 1 number or symbol";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?useRegisterDemo$1(this):usePortalRegistrationForm(this),r=e.states,t=e.callbacks,o=e.refs;var s={formData:h$1("slot",{name:"formData"}),secondaryButton:h$1("slot",{name:"secondaryButton"},h$1("sl-button",{type:"text",disabled:r.loading,onClick:function(){return jn.push(r.loginPath)}},this.loginLabel)),terms:h$1("slot",{name:"terms"}),emailOptIn:h$1("slot",{name:"emailOptIn"}),emailLabel:this.emailLabel,passwordLabel:this.passwordLabel,submitLabel:this.submitLabel,pageLabel:this.pageLabel,confirmPasswordLabel:this.confirmPasswordLabel,networkErrorMessage:this.networkErrorMessage,passwordMismatchErrorMessage:this.passwordMismatchErrorMessage,invalidEmailErrorMessage:this.invalidEmailErrorMessage,formDisabledErrorMessage:this.formDisabledErrorMessage,requiredFieldErrorMessage:this.requiredFieldErrorMessage,meetsRequirementsText:this.meetsRequirementsText,doesNotMeetRequirementsText:this.doesNotMeetRequirementsText,minErrorText:this.minErrorText,uppercaseErrorText:this.uppercaseErrorText,lowercaseErrorText:this.lowercaseErrorText,hasErrorText:this.hasErrorText};return h$1(PortalRegistrationFormView,{states:r,callbacks:t,content:s,refs:o})};return e}();function useRegisterDemo$1(e){var r=this;return cjs({states:{error:"",loading:false,confirmPassword:e.confirmPassword,hideInputs:e.hideInputs||false,customPasswordField:false,loginPath:"/login"},callbacks:{submit:function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(e){console.log("submit");return[2]}))}))},inputFunction:function(){}},refs:{formRef:{}}},e.demoData||{},{arrayMerge:function(e,r){return r}})}var globalPromise=null;function usePortalVerifyEmail(e){var r=this;var t=e.nextPage,o=e.failedPage,s=e.verifySuccessText,i=e.verifyEmailText,a=e.verifyInvalidText,n=e.networkErrorMessage,l=e.continueText;var u,d,c,g,h,f,v,m,b,p;var P=useState(false),w=P[0],y=P[1];var x=useState(false),E=x[0],L=x[1];var _=J();var T=an(),k=T[0],M=T[1],R=M.loading,j=M.data,S=M.errors;var q=new URLSearchParams(jn.location.search);var I=q.get("oobCode");var F=q.get("email");var C=q.get("nextPage");var D=j===undefined&&S===undefined&&!!I;var $=!!(((u=_===null||_===void 0?void 0:_.managedIdentity)===null||u===void 0?void 0:u.emailVerified)||((d=j===null||j===void 0?void 0:j.verifyManagedIdentityEmail)===null||d===void 0?void 0:d.success)||E);var V=((c=_===null||_===void 0?void 0:_.managedIdentity)===null||c===void 0?void 0:c.email)===F;var B=function(){return jn.push({pathname:o,search:q.toString()&&"?"+q.toString()})};var A=function(){q.delete("nextPage");var e=sanitizeUrlPath(C||t);jn.push(e.href)};var N=function(){setTimeout((function(){setUserIdentity(undefined);A()}),3e3)};var U=function(){setTimeout(A,3e3)};useEffect((function(){var e=function(){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(r){switch(r.label){case 0:if(!globalPromise)globalPromise=k({oobCode:I});return[4,globalPromise];case 1:e=r.sent();if(!(e instanceof Error)&&e.verifyManagedIdentityEmail.success){L(true)}y(true);return[2]}}))}))};e()}),[]);useEffect((function(){if(!w)return;if($&&V)U();else N()}),[w,$]);return{states:{loading:R||!w,disableContinue:D,error:((v=(f=(h=(g=S===null||S===void 0?void 0:S.response)===null||g===void 0?void 0:g.errors)===null||h===void 0?void 0:h[0])===null||f===void 0?void 0:f.extensions)===null||v===void 0?void 0:v.message)||((p=(b=(m=S===null||S===void 0?void 0:S.response)===null||m===void 0?void 0:m.errors)===null||b===void 0?void 0:b[0])===null||p===void 0?void 0:p.message)||((S===null||S===void 0?void 0:S.message)||!V)&&n,success:w&&E&&($||V)},data:{oobCode:I},callbacks:{failed:B,gotoNextPage:A},content:{verifySuccessText:s,verifyEmailText:i,verifyInvalidText:a,continueText:l}}}var PortalVerifyEmail=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.failedPage="/";this.verifyEmailText="Verify your email";this.verifySuccessText="Your email has been verified and you are being redirected. If you are not redirected, please click Continue.";this.verifyInvalidText="The email verification code is invalid or has expired, please try again.";this.continueText="Continue";this.networkErrorMessage="An error occurred while verifying your email. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalVerifyEmailDemo(getProps(this)):usePortalVerifyEmail(getProps(this)),r=e.states,t=e.data,o=e.callbacks,s=e.content;return h$1(PortalVerifyEmailView,{states:r,data:t,callbacks:o,content:s})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,success:true},data:{oobCode:"code"},callbacks:{failed:function(){console.log("failed")},gotoNextPage:function(){}},content:{verifySuccessText:e.verifySuccessText,verifyEmailText:e.verifyEmailText,verifyInvalidText:e.verifyInvalidText,continueText:e.continueText}},e.demoData||{},{arrayMerge:function(e,r){return r}})}export{PortalForgotPassword as sqm_portal_forgot_password,PortalGoogleLogin as sqm_portal_google_login,PortalLogin as sqm_portal_login,PortalRegister as sqm_portal_register,PortalRegistrationForm as sqm_portal_registration_form,PortalVerifyEmail as sqm_portal_verify_email};