@saasquatch/mint-components 1.8.5-27 → 1.8.5-29

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.
Files changed (26) hide show
  1. package/dist/cjs/{sqm-portal-verify-email-view-1ae5724a.js → sqm-portal-verify-email-view-4f7063ff.js} +6 -0
  2. package/dist/cjs/sqm-portal-verify-email.cjs.entry.js +3 -5
  3. package/dist/cjs/sqm-stencilbook.cjs.entry.js +1 -1
  4. package/dist/collection/components/sqm-portal-verify-email/sqm-portal-verify-email-view.js +6 -0
  5. package/dist/collection/components/sqm-portal-verify-email/usePortalVerifyEmail.js +2 -4
  6. package/dist/esm/{sqm-portal-verify-email-view-279b4e58.js → sqm-portal-verify-email-view-4c562714.js} +6 -0
  7. package/dist/esm/sqm-portal-verify-email.entry.js +3 -5
  8. package/dist/esm/sqm-stencilbook.entry.js +1 -1
  9. package/dist/esm-es5/sqm-portal-verify-email-view-4c562714.js +1 -0
  10. package/dist/esm-es5/sqm-portal-verify-email.entry.js +1 -1
  11. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  12. package/dist/mint-components/mint-components.esm.js +1 -1
  13. package/dist/mint-components/p-2cbc3524.js +1 -0
  14. package/dist/mint-components/p-44b12b2e.system.js +1 -1
  15. package/dist/mint-components/p-493d1042.system.entry.js +1 -0
  16. package/dist/mint-components/p-570eaaee.system.js +1 -0
  17. package/dist/mint-components/{p-71fed413.system.entry.js → p-bed01771.system.entry.js} +1 -1
  18. package/dist/mint-components/{p-8a9ceee6.entry.js → p-c33bbf65.entry.js} +1 -1
  19. package/dist/mint-components/p-def79928.entry.js +1 -0
  20. package/docs/docs.docx +0 -0
  21. package/package.json +1 -1
  22. package/dist/esm-es5/sqm-portal-verify-email-view-279b4e58.js +0 -1
  23. package/dist/mint-components/p-076a0d27.system.entry.js +0 -1
  24. package/dist/mint-components/p-64e990f4.entry.js +0 -1
  25. package/dist/mint-components/p-a40d2ed3.system.js +0 -1
  26. package/dist/mint-components/p-b9d010e0.js +0 -1
@@ -24,6 +24,12 @@ const sheet = JSS.createStyleSheet(style);
24
24
  const styleString = sheet.toString();
25
25
  function PortalVerifyEmailView(props) {
26
26
  const { states, data, callbacks, content } = props;
27
+ console.log({
28
+ loading: states.loading,
29
+ success: states.success,
30
+ error: states.error,
31
+ oobCode: data.oobCode,
32
+ });
27
33
  if (states.loading)
28
34
  return;
29
35
  if (states.success) {
@@ -10,7 +10,7 @@ require('./mixins-fe9d4112.js');
10
10
  require('./JSS-8503a151.js');
11
11
  const utils = require('./utils-6847bc06.js');
12
12
  require('./sqm-text-span-view-e1cd9bd3.js');
13
- const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-1ae5724a.js');
13
+ const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-4f7063ff.js');
14
14
 
15
15
  const SUBMITTED_CONTEXT = "sq:verify-submitted";
16
16
  function setWindowSubmitted(submitted) {
@@ -35,7 +35,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
35
35
  // derived from useMutation in component boilerplate initialState
36
36
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
37
37
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
38
- const hasContext = localStorage.getItem("sq:user-identity");
39
38
  const verified = !!((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified);
40
39
  const failed = () => {
41
40
  return index_module.$n.push({
@@ -49,7 +48,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
49
48
  index_module.$n.push(url.href);
50
49
  };
51
50
  console.log({
52
- hasContext,
53
51
  userIdent,
54
52
  data,
55
53
  submitted,
@@ -79,7 +77,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
79
77
  }, [submitted]);
80
78
  stencilHooks_module.useEffect(() => {
81
79
  var _a;
82
- if (!submitted)
80
+ if (!submitted || !success || !verificationError)
83
81
  return;
84
82
  if (!verificationError &&
85
83
  ((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.email) === oobEmail &&
@@ -127,7 +125,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
127
125
  // }, [submitted, verificationError, data, email, oobCode, oobEmail, submit]);
128
126
  return {
129
127
  states: {
130
- loading: disableContinue,
128
+ loading: loading || disableContinue,
131
129
  success,
132
130
  error: ((_f = (_e = (_d = (_c = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) ||
133
131
  ((verificationError === null || verificationError === void 0 ? void 0 : verificationError.message) && networkErrorMessage),
@@ -27,7 +27,7 @@ const sqmPortalForgotPasswordView = require('./sqm-portal-forgot-password-view-c
27
27
  const sqmPortalProfileView = require('./sqm-portal-profile-view-d8697f23.js');
28
28
  require('./utilities-73df97e1.js');
29
29
  const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-07a13210.js');
30
- const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-1ae5724a.js');
30
+ const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-4f7063ff.js');
31
31
  const ShadowViewAddon = require('./ShadowViewAddon-89ba2ab0.js');
32
32
  const sqmPortalContainerView = require('./sqm-portal-container-view-5fb2ad49.js');
33
33
  const sqmInvoiceTableView = require('./sqm-invoice-table-view-501f8985.js');
@@ -21,6 +21,12 @@ const sheet = createStyleSheet(style);
21
21
  const styleString = sheet.toString();
22
22
  export function PortalVerifyEmailView(props) {
23
23
  const { states, data, callbacks, content } = props;
24
+ console.log({
25
+ loading: states.loading,
26
+ success: states.success,
27
+ error: states.error,
28
+ oobCode: data.oobCode,
29
+ });
24
30
  if (states.loading)
25
31
  return;
26
32
  if (states.success) {
@@ -25,7 +25,6 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
25
25
  // derived from useMutation in component boilerplate initialState
26
26
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
27
27
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
28
- const hasContext = localStorage.getItem("sq:user-identity");
29
28
  const verified = !!((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified);
30
29
  const failed = () => {
31
30
  return navigation.push({
@@ -39,7 +38,6 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
39
38
  navigation.push(url.href);
40
39
  };
41
40
  console.log({
42
- hasContext,
43
41
  userIdent,
44
42
  data,
45
43
  submitted,
@@ -69,7 +67,7 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
69
67
  }, [submitted]);
70
68
  useEffect(() => {
71
69
  var _a;
72
- if (!submitted)
70
+ if (!submitted || !success || !verificationError)
73
71
  return;
74
72
  if (!verificationError &&
75
73
  ((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.email) === oobEmail &&
@@ -117,7 +115,7 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
117
115
  // }, [submitted, verificationError, data, email, oobCode, oobEmail, submit]);
118
116
  return {
119
117
  states: {
120
- loading: disableContinue,
118
+ loading: loading || disableContinue,
121
119
  success,
122
120
  error: ((_f = (_e = (_d = (_c = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) ||
123
121
  ((verificationError === null || verificationError === void 0 ? void 0 : verificationError.message) && networkErrorMessage),
@@ -22,6 +22,12 @@ const sheet = createStyleSheet(style);
22
22
  const styleString = sheet.toString();
23
23
  function PortalVerifyEmailView(props) {
24
24
  const { states, data, callbacks, content } = props;
25
+ console.log({
26
+ loading: states.loading,
27
+ success: states.success,
28
+ error: states.error,
29
+ oobCode: data.oobCode,
30
+ });
25
31
  if (states.loading)
26
32
  return;
27
33
  if (states.success) {
@@ -6,7 +6,7 @@ import './mixins-f60a614c.js';
6
6
  import './JSS-67b5cff8.js';
7
7
  import { s as sanitizeUrlPath, g as getProps } from './utils-334c1e34.js';
8
8
  import './sqm-text-span-view-8d140661.js';
9
- import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-279b4e58.js';
9
+ import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-4c562714.js';
10
10
 
11
11
  const SUBMITTED_CONTEXT = "sq:verify-submitted";
12
12
  function setWindowSubmitted(submitted) {
@@ -31,7 +31,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
31
31
  // derived from useMutation in component boilerplate initialState
32
32
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
33
33
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
34
- const hasContext = localStorage.getItem("sq:user-identity");
35
34
  const verified = !!((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified);
36
35
  const failed = () => {
37
36
  return $n.push({
@@ -45,7 +44,6 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
45
44
  $n.push(url.href);
46
45
  };
47
46
  console.log({
48
- hasContext,
49
47
  userIdent,
50
48
  data,
51
49
  submitted,
@@ -75,7 +73,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
75
73
  }, [submitted]);
76
74
  useEffect(() => {
77
75
  var _a;
78
- if (!submitted)
76
+ if (!submitted || !success || !verificationError)
79
77
  return;
80
78
  if (!verificationError &&
81
79
  ((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.email) === oobEmail &&
@@ -123,7 +121,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
123
121
  // }, [submitted, verificationError, data, email, oobCode, oobEmail, submit]);
124
122
  return {
125
123
  states: {
126
- loading: disableContinue,
124
+ loading: loading || disableContinue,
127
125
  success,
128
126
  error: ((_f = (_e = (_d = (_c = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) ||
129
127
  ((verificationError === null || verificationError === void 0 ? void 0 : verificationError.message) && networkErrorMessage),
@@ -23,7 +23,7 @@ import { P as PortalForgotPasswordView } from './sqm-portal-forgot-password-view
23
23
  import { P as PortalProfileView } from './sqm-portal-profile-view-13f0ef79.js';
24
24
  import './utilities-21d8a4df.js';
25
25
  import { P as PortalResetPasswordView } from './sqm-portal-reset-password-view-d3e726a9.js';
26
- import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-279b4e58.js';
26
+ import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-4c562714.js';
27
27
  import { S as ShareButtonView, L as LeaderboardView, C as CopyTextView, B as BigStatView, P as PortalFrameView, E as EditProfileView, u as useShareLink, a as useShareButton, b as useDemoBigStat, c as StatContainerView, d as PortalChangePasswordView, e as PortalLoginView, f as PortalRegisterView, T as TaskCardView, g as ProgressBarView, h as PoweredByImg$1, i as PortalFooterView, H as HeroView, R as ReferralIframeView, N as NameFieldsView, j as CheckboxFieldView, D as DropdownFieldView, I as InputFieldView, k as RewardExchangeView, r as rewardExchangeCustomErrorMsg, l as rewardExchangeLongText, m as rewardExchangeSelected, n as chooseAmountFixed, o as chooseAmountFixedNoDescription, p as chooseAmountVariable, q as chooseAmountVariableNoDescription, s as chooseAmountVariableDisabled, t as chooseAmountVariableUnavailable, v as confirmFixed, w as confirmVariable, x as redemptionError, y as queryError, z as success, A as successVariable, F as loading, G as empty$1, J as rewardExchange, K as CardFeedView, M as CouponCodeView, O as ProgressBar$2, Q as autoColorScaleCss, U as ShadowViewAddon } from './ShadowViewAddon-c22043d9.js';
28
28
  import { P as PortalContainerView, a as PortalSectionView } from './sqm-portal-container-view-ab89c6cc.js';
29
29
  import { O as OtherRegionSlotView, I as InvoiceTableView, T as TaxForm } from './sqm-invoice-table-view-d00894ce.js';
@@ -0,0 +1 @@
1
+ import{h}from"./index-17b4da69.js";import{A as AuthWrapper,a as AuthColumn}from"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var style={Wrapper:AuthWrapper,Column:AuthColumn,ContinueButton:{width:"100%"}};var vanillaStyle="\n:host {\n display: block;\n}\n:host([hidden]): {\n display: none;\n}\n";var sheet=createStyleSheet(style);var styleString=sheet.toString();function PortalVerifyEmailView(e){var t=e.states,s=e.data,r=e.callbacks,a=e.content;console.log({loading:t.loading,success:t.success,error:t.error,oobCode:s.oobCode});if(t.loading)return;if(t.success){return h("div",{class:sheet.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},vanillaStyle,styleString),h(TextSpanView,{type:"h3"},a.verifyEmailText),h("sqm-form-message",{exportparts:"success-icon"},h("div",{part:"successalert-text"},a.verifySuccessText)),h("sl-button",{class:sheet.classes.ContinueButton,onClick:r.gotoNextPage,loading:t.loading,exportparts:"base: primarybutton-base",type:"primary"},a.continueText))}if(t.error||!s.oobCode){return h("div",{class:sheet.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},styleString),h(TextSpanView,{type:"h3"},a.verifyEmailText),h("sqm-form-message",{type:"error",exportparts:"erroralert-icon"},h("div",{part:"erroralert-text"},a.verifyInvalidText)),h("sl-button",{class:sheet.classes.ContinueButton,onClick:r.failed,loading:t.loading,exportparts:"base: primarybutton-base",type:"primary"},a.continueText))}}export{PortalVerifyEmailView as P};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r["throw"](e))}catch(e){o(e)}}function l(e){e.done?i(e.value):n(e.value).then(a,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];n=0}finally{r=o=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-17b4da69.js";import{k as useState,f as useEffect,n as h}from"./stencil-hooks.module-8032b139.js";import{Q,j as an,$ as $n,b as setUserIdentity,i as isDemo}from"./index.module-ba0ed7a8.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import"./JSS-67b5cff8.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import"./sqm-text-span-view-8d140661.js";import{P as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-279b4e58.js";var SUBMITTED_CONTEXT="sq:verify-submitted";function setWindowSubmitted(e){window[SUBMITTED_CONTEXT]=e}function usePortalVerifyEmail(e){var t=this;var i=e.nextPage,r=e.failedPage,n=e.verifySuccessText,o=e.verifyEmailText,a=e.verifyInvalidText,s=e.networkErrorMessage,l=e.continueText;var u,c,d,f,v,m,y,h;var g=useState(window[SUBMITTED_CONTEXT]),p=g[0],T=g[1];var b=Q();var x=useState(null),w=x[0],E=x[1];var P=useState(false),S=P[0],I=P[1];var _=an(),k=_[0],j=_[1],C=j.loading,V=j.data,U=j.errors;var D=new URLSearchParams($n.location.search);var M=D.get("oobCode");var N=D.get("email");var G=D.get("nextPage");var O=function(e){T(e);setWindowSubmitted(e)};var $=V===undefined&&U===undefined&&!!M;var q=localStorage.getItem("sq:user-identity");var B=!!((u=b===null||b===void 0?void 0:b.managedIdentity)===null||u===void 0?void 0:u.emailVerified);var X=function(){return $n.push({pathname:r,search:D.toString()&&"?"+D.toString()})};var L=function(){D.delete("nextPage");var e=sanitizeUrlPath(G||i);$n.push(e.href)};console.log({hasContext:q,userIdent:b,data:V,submitted:p,verified:B,verificationError:w,success:S});useEffect((function(){var e=function(){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:O(true);return[4,k({oobCode:M})];case 1:t=i.sent();if(t instanceof Error||!((e=t===null||t===void 0?void 0:t.verifyManagedIdentityEmail)===null||e===void 0?void 0:e.success)){console.debug("set verification error");E({message:true})}else{console.debug("set success: true");I(true)}console.debug("SUBMITTED",t);console.debug("window",window[SUBMITTED_CONTEXT]);return[2]}}))}))};if(!p)e()}),[p]);useEffect((function(){var e;if(!p)return;if(!w&&((e=b===null||b===void 0?void 0:b.managedIdentity)===null||e===void 0?void 0:e.email)===N&&(S||B)){console.log("LOGGING IN",S,B,w);setTimeout(L,3e3)}else{console.log("LOGGING OUT",S,B,w);setTimeout((function(){setUserIdentity(undefined);L()}),3e3)}}),[B,w,S,p,b]);useEffect((function(){if(U)E(U)}),[U,E]);return{states:{loading:$,success:S,error:((v=(f=(d=(c=w===null||w===void 0?void 0:w.response)===null||c===void 0?void 0:c.errors)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.extensions)===null||v===void 0?void 0:v.message)||((h=(y=(m=w===null||w===void 0?void 0:w.response)===null||m===void 0?void 0:m.errors)===null||y===void 0?void 0:y[0])===null||h===void 0?void 0:h.message)||(w===null||w===void 0?void 0:w.message)&&s,verified:B},data:{oobCode:M},callbacks:{failed:X,gotoNextPage:L},content:{verifySuccessText:n,verifyEmailText:o,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)),t=e.states,i=e.data,r=e.callbacks,n=e.content;return h$1(PortalVerifyEmailView,{states:t,data:i,callbacks:r,content:n})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,verified: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,t){return t}})}export{PortalVerifyEmail as sqm_portal_verify_email};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r["throw"](e))}catch(e){o(e)}}function l(e){e.done?i(e.value):n(e.value).then(a,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];n=0}finally{r=o=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-17b4da69.js";import{k as useState,f as useEffect,n as h}from"./stencil-hooks.module-8032b139.js";import{Q,j as an,$ as $n,b as setUserIdentity,i as isDemo}from"./index.module-ba0ed7a8.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import"./JSS-67b5cff8.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import"./sqm-text-span-view-8d140661.js";import{P as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-4c562714.js";var SUBMITTED_CONTEXT="sq:verify-submitted";function setWindowSubmitted(e){window[SUBMITTED_CONTEXT]=e}function usePortalVerifyEmail(e){var t=this;var i=e.nextPage,r=e.failedPage,n=e.verifySuccessText,o=e.verifyEmailText,a=e.verifyInvalidText,s=e.networkErrorMessage,l=e.continueText;var u,c,f,d,v,m,y,h;var g=useState(window[SUBMITTED_CONTEXT]),p=g[0],T=g[1];var b=Q();var x=useState(null),w=x[0],E=x[1];var P=useState(false),S=P[0],I=P[1];var _=an(),k=_[0],j=_[1],V=j.loading,C=j.data,U=j.errors;var D=new URLSearchParams($n.location.search);var M=D.get("oobCode");var N=D.get("email");var G=D.get("nextPage");var O=function(e){T(e);setWindowSubmitted(e)};var $=C===undefined&&U===undefined&&!!M;var B=!!((u=b===null||b===void 0?void 0:b.managedIdentity)===null||u===void 0?void 0:u.emailVerified);var q=function(){return $n.push({pathname:r,search:D.toString()&&"?"+D.toString()})};var X=function(){D.delete("nextPage");var e=sanitizeUrlPath(G||i);$n.push(e.href)};console.log({userIdent:b,data:C,submitted:p,verified:B,verificationError:w,success:S});useEffect((function(){var e=function(){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:O(true);return[4,k({oobCode:M})];case 1:t=i.sent();if(t instanceof Error||!((e=t===null||t===void 0?void 0:t.verifyManagedIdentityEmail)===null||e===void 0?void 0:e.success)){console.debug("set verification error");E({message:true})}else{console.debug("set success: true");I(true)}console.debug("SUBMITTED",t);console.debug("window",window[SUBMITTED_CONTEXT]);return[2]}}))}))};if(!p)e()}),[p]);useEffect((function(){var e;if(!p||!S||!w)return;if(!w&&((e=b===null||b===void 0?void 0:b.managedIdentity)===null||e===void 0?void 0:e.email)===N&&(S||B)){console.log("LOGGING IN",S,B,w);setTimeout(X,3e3)}else{console.log("LOGGING OUT",S,B,w);setTimeout((function(){setUserIdentity(undefined);X()}),3e3)}}),[B,w,S,p,b]);useEffect((function(){if(U)E(U)}),[U,E]);return{states:{loading:V||$,success:S,error:((v=(d=(f=(c=w===null||w===void 0?void 0:w.response)===null||c===void 0?void 0:c.errors)===null||f===void 0?void 0:f[0])===null||d===void 0?void 0:d.extensions)===null||v===void 0?void 0:v.message)||((h=(y=(m=w===null||w===void 0?void 0:w.response)===null||m===void 0?void 0:m.errors)===null||y===void 0?void 0:y[0])===null||h===void 0?void 0:h.message)||(w===null||w===void 0?void 0:w.message)&&s,verified:B},data:{oobCode:M},callbacks:{failed:q,gotoNextPage:X},content:{verifySuccessText:n,verifyEmailText:o,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)),t=e.states,i=e.data,r=e.callbacks,n=e.content;return h$1(PortalVerifyEmailView,{states:t,data:i,callbacks:r,content:n})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,verified: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,t){return t}})}export{PortalVerifyEmail as sqm_portal_verify_email};