@saasquatch/component-boilerplate 1.5.0-0 → 1.5.0-3

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 (32) hide show
  1. package/dist/environment/BatchedGraphQLClient.d.ts +9 -0
  2. package/dist/environment/GraphQLRequestManager.d.ts +1 -0
  3. package/dist/environment/LocaleContext.d.ts +15 -0
  4. package/dist/environment/ProgramContext.d.ts +15 -0
  5. package/dist/environment/SquatchPortal.d.ts +26 -0
  6. package/dist/environment/UserIdentityContext.d.ts +51 -0
  7. package/dist/environment/environment.d.ts +134 -0
  8. package/dist/environment/index.d.ts +5 -0
  9. package/dist/hooks/graphql/useBaseQuery.d.ts +1 -1
  10. package/dist/hooks/graphql/useBatchedQuery.d.ts +45 -0
  11. package/dist/hooks/graphql/useCustomQuery.d.ts +30 -0
  12. package/dist/hooks/managedIdentity/useAuthenticateWithEmailAndPasswordMutation.d.ts +1 -1
  13. package/dist/hooks/managedIdentity/useChangePasswordMutation.d.ts +1 -1
  14. package/dist/hooks/managedIdentity/useManagedIdentityQuery.d.ts +13 -0
  15. package/dist/hooks/managedIdentity/useManagedIdentitySessionQuery.d.ts +1 -1
  16. package/dist/hooks/managedIdentity/useRegisterViaRegistrationFormMutation.d.ts +1 -1
  17. package/dist/hooks/managedIdentity/useRegisterWithEmailAndPasswordMutation.d.ts +1 -1
  18. package/dist/hooks/managedIdentity/useRequestPasswordResetEmailMutation.d.ts +1 -1
  19. package/dist/hooks/managedIdentity/useRequestVerificationEmailMutation.d.ts +1 -1
  20. package/dist/hooks/managedIdentity/useResetPasswordMutation.d.ts +1 -1
  21. package/dist/hooks/managedIdentity/useVerifyEmailMutation.d.ts +1 -1
  22. package/dist/hooks/managedIdentity/useVerifyPasswordResetCodeMutation.d.ts +1 -1
  23. package/dist/hooks/pagination/usePaginatedQuery.d.ts +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.modern.js +9 -9
  27. package/dist/index.modern.js.map +1 -1
  28. package/dist/index.module.js +1 -1
  29. package/dist/index.module.js.map +1 -1
  30. package/dist/index.umd.js +1 -1
  31. package/dist/index.umd.js.map +1 -1
  32. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import { Subject } from "rxjs";
2
+ import { RequestDocument } from "graphql-request/dist/types";
3
+ import { GraphQLClient } from "graphql-request";
4
+ export declare class BatchedGraphQLClient extends GraphQLClient {
5
+ subject: Subject<unknown>;
6
+ constructor(url: string, opts?: any);
7
+ superRequest<T>(query: RequestDocument, variables?: any): Promise<T>;
8
+ request<T>(query: any, variables: any): Promise<T>;
9
+ }
@@ -0,0 +1 @@
1
+ export declare function addQuery(queryObj: any): void;
@@ -0,0 +1,15 @@
1
+ import { ContextProvider } from "dom-context";
2
+ import { WidgetIdent } from "./environment";
3
+ declare global {
4
+ interface Window {
5
+ widgetIdent: WidgetIdent;
6
+ squatchLocale: ContextProvider<string>;
7
+ }
8
+ }
9
+ export declare function useLocale(): string | undefined;
10
+ /**
11
+ * Overide the globally defined Locale context
12
+ *
13
+ * @param locale the new locale used by the user
14
+ */
15
+ export declare function setLocale(locale: string): void;
@@ -0,0 +1,15 @@
1
+ import { ContextProvider } from "dom-context";
2
+ import { WidgetIdent } from "./environment";
3
+ declare global {
4
+ interface Window {
5
+ widgetIdent: WidgetIdent;
6
+ squatchProgramId: ContextProvider<string>;
7
+ }
8
+ }
9
+ export declare function useProgramId(): string | undefined;
10
+ /**
11
+ * Overide the globally defined Program ID context
12
+ *
13
+ * @param programId the new programID used by the user, or undefined if logged out
14
+ */
15
+ export declare function setProgramId(programId: string): void;
@@ -0,0 +1,26 @@
1
+ import { WidgetIdent } from "./environment";
2
+ /**
3
+ * Environment provided by components hosted in a web component (`sqh-widget`)
4
+ */
5
+ export declare type SquatchPortal = typeof SquatchPortalInstance;
6
+ declare global {
7
+ interface Window {
8
+ SquatchPortal?: PortalEnv;
9
+ }
10
+ }
11
+ /**
12
+ * Portal env doesn't include User Id
13
+ */
14
+ export declare type PortalEnv = Pick<WidgetIdent, "tenantAlias" | "appDomain" | "programId"> & { portalAuthUrl: string };
15
+ export declare const SquatchPortalInstance: {
16
+ readonly localeContext: {
17
+ useContext: (host: HTMLElement, options?: Pick<import("dom-context").ListenerOptions<unknown>, "onStatus" | "pollingMs" | "attempts">) => string;
18
+ useContextState: (host: HTMLElement, initialState?: string) => readonly [string, (value: string | ((previousState?: string) => string)) => void, import("dom-context").ContextProvider<string>];
19
+ Listener: new (o: Pick<import("dom-context").ListenerOptions<string>, "element" | "onChange" | "onStatus" | "pollingMs" | "attempts">) => import("dom-context").ContextListener<string>;
20
+ listen(o: Pick<import("dom-context").ListenerOptions<string>, "element" | "onChange" | "onStatus" | "pollingMs" | "attempts">): import("dom-context").ContextListener<string>;
21
+ Provider: new (o: Pick<import("dom-context").ProviderOptions<string>, "element" | "initialState">) => import("dom-context").ContextProvider<string>;
22
+ provide(o: Pick<import("dom-context").ProviderOptions<string>, "element" | "initialState">): import("dom-context").ContextProvider<string>;
23
+ provideGlobally(next: string): void;
24
+ name: string;
25
+ };
26
+ };
@@ -0,0 +1,51 @@
1
+ import { ContextProvider } from "dom-context";
2
+ import debugFn from "debug";
3
+ export declare const debug: debugFn.Debugger;
4
+ export declare type UserIdentity = {
5
+ id: string;
6
+ accountId: string;
7
+ jwt?: string;
8
+ managedIdentity?: {
9
+ email: string;
10
+ emailVerified: boolean;
11
+ sessionData?: {
12
+ [key: string]: any;
13
+ };
14
+ };
15
+ };
16
+ export interface DecodedSquatchJWT {
17
+ exp?: number;
18
+ user?: {
19
+ accountId: string;
20
+ id: string;
21
+ };
22
+ }
23
+ export interface DecodedWidgetAPIJWT {
24
+ exp?: number;
25
+ sub?: string;
26
+ }
27
+ declare global {
28
+ interface Window {
29
+ squatchUserIdentity: ContextProvider<UserIdentity>;
30
+ }
31
+ }
32
+ /**
33
+ * Overide the globally defined user context, and persists the user identity in local storage
34
+ *
35
+ * @param identity the new identity of the user, or undefined if logged out
36
+ */
37
+ export declare function setUserIdentity(identity?: UserIdentity): void;
38
+ /**
39
+ * Gets the SessionData of the current user, or undefined if logged out
40
+ */
41
+ export declare function useSessionData(): {
42
+ [key: string]: any;
43
+ } | undefined;
44
+ /**
45
+ * Gets the JWT of the current user, or undefined if logged out
46
+ */
47
+ export declare function useToken(): string | undefined;
48
+ /**
49
+ * Get the IDs and JWT of the current user, or undefined if logged out
50
+ */
51
+ export declare function useUserIdentity(): UserIdentity | undefined;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Environment provided by components hosted in a web component (`sqh-widget`)
3
+ */
4
+ declare global {
5
+ interface Window {
6
+ SquatchPortal?: PortalEnv;
7
+ }
8
+ }
9
+ /**
10
+ * Portal env doesn't include User Id
11
+ */
12
+ export declare type PortalEnv = Pick<WidgetIdent, "tenantAlias" | "appDomain" | "programId">;
13
+ /**
14
+ * Program ID context helpers
15
+ */
16
+ export { useProgramId, setProgramId } from "./ProgramContext";
17
+ /**
18
+ * Locale context helpers
19
+ */
20
+ export { useLocale } from "./LocaleContext";
21
+ /**
22
+ * Provided by the SaaSquatch GraphQL backend when a widget is rendered.
23
+ *
24
+ * Source: https://github.com/saasquatch/saasquatch/blob/805e51284f818f8656b6458bcee6181f378819d3/packages/saasquatch-core/app/saasquatch/controllers/api/widget/WidgetApi.java
25
+ *
26
+ */
27
+ export interface WidgetIdent {
28
+ tenantAlias: string;
29
+ appDomain: string;
30
+ token: string;
31
+ userId: string;
32
+ accountId: string;
33
+ locale?: string;
34
+ engagementMedium?: "POPUP" | "EMBED";
35
+ programId?: string;
36
+ env?: string;
37
+ }
38
+ /**
39
+ * An interface for interacting with the SaaSquatch Admin Portal.
40
+ *
41
+ * Used for rendering widgets in a preview/demo mode.
42
+ */
43
+ export interface SquatchAdmin {
44
+ /**
45
+ * Provides a way of providing user feedback when a widget is rendered in the SaaSquatch admin portal
46
+ *
47
+ * @param text
48
+ */
49
+ showMessage(text: string): void;
50
+ }
51
+ /**
52
+ * Type for the Javascript environment added by https://github.com/saasquatch/squatch-android
53
+ *
54
+ * Should exist as `window.SquatchAndroid`
55
+ */
56
+ export interface SquatchAndroid {
57
+ /**
58
+ *
59
+ * @param shareLink
60
+ * @param messageLink fallback URL to redirect to if the app is not installed
61
+ */
62
+ shareOnFacebook(shareLink: string, messageLink: string): void;
63
+ /**
64
+ * Shows a native Android toast
65
+ *
66
+ * @param text
67
+ */
68
+ showToast(text: string): void;
69
+ }
70
+ /**
71
+ * An interface provided by Squatch.js V2 for widgets.
72
+ *
73
+ * See: https://github.com/saasquatch/squatch-js/blob/8f2b218c9d55567e0cc12d27d635a5fb545e6842/src/widgets/Widget.ts#L47
74
+ *
75
+ */
76
+ export interface SquatchJS2 {
77
+ /**
78
+ * Opens the current popup widget (if loaded as a popup)
79
+ */
80
+ open?: () => void;
81
+ /**
82
+ * Closes the current popup widget (if loaded as a popup)
83
+ */
84
+ close?: () => void;
85
+ /**
86
+ * DEPRECATED used to update user details from inside the widget.
87
+ *
88
+ * Should no longer be used. Replace with natively using the GraphQL API and re-rendering locally. Will be removed in a future version of Squatch.js
89
+ *
90
+ * @deprecated
91
+ */
92
+ reload(userDetails: {
93
+ email: string;
94
+ firstName: string;
95
+ lastName: string;
96
+ }, jwt: string): void;
97
+ }
98
+ export declare type Environment = EnvironmentSDK["type"];
99
+ export declare type EnvironmentSDK = {
100
+ type: "SquatchJS2";
101
+ api: SquatchJS2;
102
+ widgetIdent: WidgetIdent;
103
+ } | {
104
+ type: "SquatchAndroid";
105
+ android: SquatchAndroid;
106
+ widgetIdent: WidgetIdent;
107
+ } | {
108
+ type: "SquatchPortal";
109
+ env: PortalEnv;
110
+ } | {
111
+ type: "SquatchAdmin";
112
+ adminSDK: SquatchAdmin;
113
+ } | {
114
+ type: "None";
115
+ };
116
+ /**
117
+ * Get the type of environment that this widget is being rendered in
118
+ *
119
+ * Should never return null.
120
+ */
121
+ export declare function getEnvironment(): Environment;
122
+ /**
123
+ * Get the SDK for interacting with the host environment
124
+ */
125
+ export declare function getEnvironmentSDK(): EnvironmentSDK;
126
+ export declare function isDemo(): boolean;
127
+ export declare function useTenantAlias(): string;
128
+ export declare function useAppDomain(): string;
129
+ export declare type UserId = {
130
+ id: string;
131
+ accountId: string;
132
+ };
133
+ declare type EngagementMedium = "EMBED" | "POPUP";
134
+ export declare function useEngagementMedium(): EngagementMedium;
@@ -0,0 +1,5 @@
1
+ export * from "./environment";
2
+ /**
3
+ * User identity context helpers
4
+ */
5
+ export { useUserIdentity, useToken, setUserIdentity, useSessionData, } from "./UserIdentityContext";
@@ -6,7 +6,7 @@ export interface BaseQueryData<T = unknown> {
6
6
  errors?: GraphQlRequestError<T>;
7
7
  }
8
8
  export declare type QueryData<T> = BaseQueryData<T> & {
9
- refetch: (variables?: unknown) => unknown;
9
+ refetch: (variables?: unknown) => Promise<T | Error>;
10
10
  };
11
11
  /**
12
12
  * Note: reverse-engineered from a returned error. May not capture all error types.
@@ -0,0 +1,45 @@
1
+ import { RequestDocument } from "graphql-request/dist/types";
2
+ export declare type GqlType = RequestDocument;
3
+ export interface BaseQueryData<T = unknown> {
4
+ loading: boolean;
5
+ data?: T;
6
+ errors?: GraphQlRequestError<T>;
7
+ }
8
+ export declare type QueryData<T> = BaseQueryData<T> & {
9
+ refetch: (variables?: unknown) => unknown;
10
+ };
11
+ /**
12
+ * Note: reverse-engineered from a returned error. May not capture all error types.
13
+ */
14
+ export declare type GraphQlRequestError<T> = {
15
+ response: {
16
+ errors: [
17
+ {
18
+ message: string;
19
+ locations: [{
20
+ line: number;
21
+ column: number;
22
+ }];
23
+ path: string[];
24
+ extensions: {
25
+ apiError: {
26
+ message: string;
27
+ statusCode: number;
28
+ apiErrorCode: string;
29
+ rsCode: string;
30
+ };
31
+ classification: string;
32
+ };
33
+ }
34
+ ];
35
+ data: Partial<T>;
36
+ status: number;
37
+ };
38
+ request: {
39
+ query: string;
40
+ variables: {
41
+ [key: string]: unknown;
42
+ };
43
+ };
44
+ };
45
+ export declare function useBatchedQuery<T = any>(query: GqlType, initialState: BaseQueryData<T>): [BaseQueryData<T>, (variables: unknown) => unknown];
@@ -0,0 +1,30 @@
1
+ import { RequestDocument } from "graphql-request/dist/types";
2
+ declare type GqlType = RequestDocument;
3
+ interface CustomQueryData<T = unknown, E = any> {
4
+ loading: boolean;
5
+ data?: T;
6
+ errors?: CustomGraphQlRequestError<T, E>;
7
+ }
8
+ declare type QueryData<T> = CustomQueryData<T> & {
9
+ refetch: (variables?: unknown) => unknown;
10
+ };
11
+ declare type CustomGraphQlRequestError<T, E> = {
12
+ response: {
13
+ errors: E[];
14
+ data: Partial<T>;
15
+ status: number;
16
+ };
17
+ request: {
18
+ query: string;
19
+ variables: {
20
+ [key: string]: unknown;
21
+ };
22
+ };
23
+ };
24
+ export declare function useCustomQuery<T = any, E = any>(query: GqlType, initialState: CustomQueryData<T>, url: string): [CustomQueryData<T>, (variables: unknown) => unknown];
25
+ export declare const customQueryHooksFactory: <E>(url: string) => {
26
+ useQuery: <T = any>(query: GqlType, variables: unknown, skip?: boolean) => QueryData<T>;
27
+ useLazyQuery: <T_1 = any>(query: GqlType) => [(e: unknown) => unknown, QueryData<T_1>];
28
+ useMutation: <T_2 = any>(query: GqlType) => [(e: unknown) => unknown, CustomQueryData<T_2, any>];
29
+ };
30
+ export {};
@@ -11,7 +11,7 @@ export declare function useAuthenticateWithEmailAndPasswordMutation(): [
11
11
  (e: {
12
12
  email: string;
13
13
  password: string;
14
- }) => unknown,
14
+ }) => Promise<AuthenticateWithEmailAndPasswordResult | Error>,
15
15
  BaseQueryData<AuthenticateWithEmailAndPasswordResult>
16
16
  ];
17
17
  export {};
@@ -7,7 +7,7 @@ interface ChangePasswordResult {
7
7
  export declare function useChangePasswordMutation(): [
8
8
  (e: {
9
9
  password: string;
10
- }) => unknown,
10
+ }) => Promise<ChangePasswordResult | Error>,
11
11
  BaseQueryData<ChangePasswordResult>
12
12
  ];
13
13
  export {};
@@ -0,0 +1,13 @@
1
+ import { QueryData } from "../graphql/useBaseQuery";
2
+ interface ManagedIdentityResult {
3
+ managedIdentity: {
4
+ email: string;
5
+ emailVerified: boolean;
6
+ sessionData: Record<string, any>;
7
+ };
8
+ }
9
+ export declare function useManagedIdentityQuery(): [
10
+ () => unknown,
11
+ QueryData<ManagedIdentityResult>
12
+ ];
13
+ export {};
@@ -7,7 +7,7 @@ interface ManagedIdentitySessionResult {
7
7
  };
8
8
  }
9
9
  export declare function useManagedIdentitySessionQuery(): [
10
- () => unknown,
10
+ () => Promise<ManagedIdentitySessionResult | Error>,
11
11
  QueryData<ManagedIdentitySessionResult>
12
12
  ];
13
13
  export {};
@@ -36,7 +36,7 @@ export declare function useRegisterViaRegistrationFormMutation(): [
36
36
  redirectUrl?: string;
37
37
  [field: string]: any;
38
38
  };
39
- }) => unknown,
39
+ }) => Promise<RegisterViaRegistrationFormResult | Error>,
40
40
  RegistrationFormResponseData<RegisterViaRegistrationFormResult>
41
41
  ];
42
42
  export {};
@@ -12,7 +12,7 @@ export declare function useRegisterWithEmailAndPasswordMutation(): [
12
12
  email: string;
13
13
  password: string;
14
14
  formData?: Record<string, any>;
15
- }) => unknown,
15
+ }) => Promise<RegisterWithEmailAndPasswordResult | Error>,
16
16
  BaseQueryData<RegisterWithEmailAndPasswordResult>
17
17
  ];
18
18
  export {};
@@ -8,7 +8,7 @@ export declare function useRequestPasswordResetEmailMutation(): [
8
8
  (e: {
9
9
  email: string;
10
10
  urlParams?: Record<string, any>;
11
- }) => unknown,
11
+ }) => Promise<RequestPasswordResetEmailResult | Error>,
12
12
  BaseQueryData<RequestPasswordResetEmailResult>
13
13
  ];
14
14
  export {};
@@ -8,7 +8,7 @@ export declare function useRequestVerificationEmailMutation(): [
8
8
  (e: {
9
9
  email: string;
10
10
  urlParams?: Record<string, any>;
11
- }) => unknown,
11
+ }) => Promise<RequestVerificationEmailResult | Error>,
12
12
  BaseQueryData<RequestVerificationEmailResult>
13
13
  ];
14
14
  export {};
@@ -11,7 +11,7 @@ export declare function useResetPasswordMutation(): [
11
11
  (e: {
12
12
  oobCode: string;
13
13
  password: string;
14
- }) => unknown,
14
+ }) => Promise<ResetPasswordResult | Error>,
15
15
  BaseQueryData<ResetPasswordResult>
16
16
  ];
17
17
  export {};
@@ -7,7 +7,7 @@ interface VerifyEmailResult {
7
7
  export declare function useVerifyEmailMutation(): [
8
8
  (e: {
9
9
  oobCode: string;
10
- }) => unknown,
10
+ }) => Promise<VerifyEmailResult | Error>,
11
11
  BaseQueryData<VerifyEmailResult>
12
12
  ];
13
13
  export {};
@@ -7,7 +7,7 @@ interface VerifyPasswordResetCodeResult {
7
7
  export declare function useVerifyPasswordResetCodeMutation(): [
8
8
  (e: {
9
9
  oobCode: string;
10
- }) => unknown,
10
+ }) => Promise<VerifyPasswordResetCodeResult | Error>,
11
11
  BaseQueryData<VerifyPasswordResetCodeResult>
12
12
  ];
13
13
  export {};
@@ -23,7 +23,7 @@ export declare function usePaginatedQuery<TData, TVars extends {
23
23
  pageProgress: string;
24
24
  };
25
25
  callbacks: {
26
- refetch: (variables?: unknown) => unknown;
26
+ refetch: (variables?: unknown) => Promise<any>;
27
27
  setLimit: (newLimit: number) => void;
28
28
  setCurrentPage: (newPage: number) => void;
29
29
  };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("@saasquatch/component-environment"),n=require("@saasquatch/dom-context-hooks"),t=require("graphql"),r=require("jwt-decode"),a=require("@saasquatch/universal-hooks"),o=require("fast-memoize"),i=require("rxjs"),s=require("rxjs/operators"),u=require("nanoid"),l=require("graphql-request/dist/types"),d=require("graphql-request"),c=require("graphql-combine-query"),f=require("@wry/equality"),m=require("history"),g=require("debounce"),v=require("jsonpointer");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=p(r),h=p(o),C=p(c),b=p(g),w=p(v),E={current:void 0};function F(){if(void 0===E.current)throw new Error("no implementation of useHost provided");return E.current()}function P(){e.lazilyStartProgramContext();var t=F();return n.useDomContext(t,e.PROGRAM_CONTEXT_NAME)}function I(){var e;return null==(e=M())?void 0:e.jwt}function M(){e.lazilyStartUserContext();var t=F(),r=n.useDomContext(t,e.USER_CONTEXT_NAME),a=e.userIdentityFromJwt(null==r?void 0:r.jwt);if(!r||a)return r;e.setUserIdentity(void 0)}var x=e.getTenantAlias,D=e.getAppDomain,S=e.getEngagementMedium;function q(){return(q=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function k(e,n){return(k=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function A(e,n){return n||(n=e.slice(0)),e.raw=n,e}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function R(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var $=function(){return($=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var a in n=arguments[t])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e}).apply(this,arguments)},O=new Map,V=new Map,H=!0,L=!1;function T(e){return e.replace(/[\s,]+/g," ").trim()}function U(e){var n,r,a,o=T(e);if(!O.has(o)){var i=t.parse(e,{experimentalFragmentVariables:L});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");O.set(o,function(e){var n=new Set(e.definitions);n.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(t){var r=e[t];r&&"object"==typeof r&&n.add(r)})});var t=e.loc;return t&&(delete t.startToken,delete t.endToken),e}((n=i,r=new Set,a=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,t=T((i=e.loc).source.body.substring(i.start,i.end)),o=V.get(n);o&&!o.has(t)?H&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||V.set(n,o=new Set),o.add(t),r.has(t)||(r.add(t),a.push(e))}else a.push(e);var i}),$($({},n),{definitions:a}))))}return O.get(o)}function N(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];"string"==typeof e&&(e=[e]);var r=e[0];return n.forEach(function(n,t){r+=n&&"Document"===n.kind?n.loc.source.body:n,r+=e[t+1]}),U(r)}var _,W=N;(_=N||(N={})).gql=W,_.resetCaches=function(){O.clear(),V.clear()},_.disableFragmentWarnings=function(){H=!1},_.enableExperimentalFragmentVariables=function(){L=!0},_.disableExperimentalFragmentVariables=function(){L=!1},N.default=N;var Q=N;function z(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var G=function(e){var n,r;function a(n,r){var a;(a=e.call(this,n,r)||this).subject=new i.Subject;var o=new i.Subject;return a.subject.pipe(s.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,r=X(e),i=r.mergedQuery,s=r.mergedVariables,u=r.mergedQueryAddedEvents,d=R(r.unmergedQueryAddedEvents);!(n=d()).done;)o.next(n.value);return u.length?Promise.resolve(z(function(){return Promise.resolve(a.superRequest(i,s)).then(function(e){ee(e,u)})},function(e){if(e instanceof l.ClientError){var n=function(){var n=e.response,r=n.data,a=n.errors;if(!r)return{v:te(u,e)};for(var o,i=Object.keys(r),s=[].concat(u),d=function(){var n=o.value,r=void 0;n.path.find(function(a,o,u){if(i.includes(a)){var d=K(a),c=s.findIndex(function(e){return e.id===d});if(-1===c)return!1;i.splice(o,1),r=s.splice(c,1)[0];var f=Z(e.response.data,r);u[o]=B(u[o],d);var m=r.query,g=r.variables,v=q({},e.response,{errors:[n],data:f,path:u}),p=new l.ClientError(v,{query:"string"!=typeof m?t.print(m):m,variables:g});return ne(r,p),!0}return!1})},c=R(a);!(o=c()).done;)d();ee(r,s)}();if("object"==typeof n)return n.v}else te(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),o.subscribe(function(e){try{var n=z(function(){return Promise.resolve(a.superRequest(e.query,e.variables)).then(function(n){Y(n,e)})},function(n){ne(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),a}r=e,(n=a).prototype=Object.create(r.prototype),n.prototype.constructor=n,k(n,r);var o=a.prototype;return o.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},o.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:J(),resolve:r,reject:a};t.subject.next(o)})},a}(d.GraphQLClient),J=function(){return u.nanoid().replace(/[-_]/g,"")},B=function(e,n){return e.replace("_"+n,"")},K=function(e){var n=e.split("_");return n[n.length-1]},X=function(e){var n=[],r=[],a=e.reduce(function(e,a){var o=a.query,i=a.variables,s=a.id;try{var u="string"==typeof o?t.parse(o):o,l=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),d="string"==typeof o?o:t.print(o),c=/@/.test(d);if(l||c)return r.push(a),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(a),e}catch(n){return r.push(a),e}},C.default("BatchedQuery")),o=a.document,i=a.variables;return{mergedQuery:o&&t.print(o),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:r}},Z=function(e,n){if(!e)return e;var t=Object.keys(e),r=n.id;return t.reduce(function(n,t){var a;return t.endsWith(r)&&(n=q({},n,((a={})[B(t,r)]=e[t],a))),n},{})},Y=function(e,n){(0,n.resolve)(e)},ee=function(e,n){for(var t,r=R(n);!(t=r()).done;){var a=t.value,o=Z(e,a);a.resolve(o)}},ne=function(e,n){(0,e.reject)(n)},te=function(e,n){for(var t,r=R(e);!(t=r()).done;)(0,t.value.reject)(n)},re=h.default(function(e,n,t){return new G(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function ae(e,n){switch(n.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:n.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:n.payload,loading:!1}}}function oe(e,t){var r,o,i,s,u,l,d=(r=I(),o=D(),i=x(),s=re(o,i,r),u=F(),null!=(l=n.useDomContext(u,"sq:graphql-client",{attempts:0}))?l:s),c=a.useReducer(ae,t),f=c[1];return[c[0],a.useCallback(function(n,t){void 0===t&&(t=!1);try{if(!d){var r=new Error("No GraphQL client found");return f({type:"errors",payload:r}),Promise.resolve(r)}return Promise.resolve(function(r,a){try{var o=(t||f({type:"loading"}),Promise.resolve(d.request(e,n)).then(function(e){return f({type:"data",payload:e}),e}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){return f({type:"errors",payload:e}),e}))}catch(e){return Promise.reject(e)}},[d,e,f])]}var ie,se={loading:!1,data:void 0,errors:void 0};function ue(e){var n=oe(e,se);return[n[1],n[0]]}var le,de,ce,fe,me,ge=Q(ie||(ie=A(["\n mutation AuthenticateWithEmailAndPassword(\n $email: String!\n $password: String!\n ) {\n authenticateManagedIdentityWithEmailAndPassword(\n authenticateManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),ve=Q(le||(le=A(["\n mutation RegisterWithEmailAndPassword(\n $email: String!\n $password: String!\n $formData: RSJsonNode\n $redirectPath: String\n ) {\n registerManagedIdentityWithEmailAndPassword(\n registerManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n formData: $formData\n redirectPath: $redirectPath\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),pe=Q(de||(de=A(["\n mutation RegisterViaRegistrationForm($key: String!, $formData: RSJsonNode!) {\n submitForm(formSubmissionInput: { key: $key, formData: $formData }) {\n results {\n ... on FormHandlerSubmissionResult {\n result\n formHandler {\n namespace\n }\n }\n ... on FormHandlerError {\n errorCode\n error\n errorType\n formHandler {\n name\n endpointUrl\n }\n }\n }\n }\n }\n"]))),ye=Q(ce||(ce=A(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),he=Q(fe||(fe=A(["\n mutation ResetPassword($oobCode: String!, $password: String!) {\n resetManagedIdentityPassword(\n resetManagedIdentityPasswordInput: {\n password: $password\n oobCode: $oobCode\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),Ce=Q(me||(me=A(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function be(e){var n=e.skip,t=void 0!==n&&n,r=e.update,o=e.variables;a.useEffect(function(){var e=function(e){!t&&r(o,!0)};return document.addEventListener("sq:refresh",e),function(){return document.removeEventListener("sq:refresh",e)}},function(e){var n=a.useRef(e),t=a.useRef(0);return f.equal(e,n.current)||(n.current=e,t.current+=1),a.useMemo(function(){return n.current},[t.current])}([o,r,t]))}var we,Ee={loading:!1,data:void 0,errors:void 0},Fe=Symbol();function Pe(e){var n=oe(e,Ee),t=n[0],r=n[1],o=a.useRef(Fe);return be({skip:o.current===Fe,update:r,variables:o.current}),[r,q({},t,{refetch:function(e){o.current=e,r(e)}})]}var Ie,Me=Q(we||(we=A(["\n query ManagedIdentitySession {\n managedIdentitySession {\n email\n emailVerified\n sessionData\n }\n }\n"])));function xe(){var n=M(),t=Pe(Me),r=t[0],o=t[1],i=o.loading,s=o.data,u=o.errors,l=o.refetch;return a.useEffect(function(){null!=s&&s.managedIdentitySession&&e.setUserIdentity(q({},n,{managedIdentity:s.managedIdentitySession}))},[null==s?void 0:s.managedIdentitySession]),[a.useCallback(function(){return r({})},[r]),{loading:i,data:s,errors:u,refetch:l}]}var De,Se,qe=Q(Ie||(Ie=A(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),ke=Q(De||(De=A(["\n mutation RequestPasswordResetEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityPasswordResetEmail(\n requestManagedIdentityPasswordResetEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"]))),Ae=Q(Se||(Se=A(["\n mutation RequestVerificationEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityVerificationEmail(\n requestManagedIdentityVerificationEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"])));function je(e,n){var t=a.useRef();return t.current&&f.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Re(){return a.useReducer(function(e){return e+1},0)}function $e(e){for(var n,t=R(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&$e(r)}return Object.freeze(e)}var Oe={loading:!0,data:void 0,errors:void 0};function Ve(e,n,t){var r=oe(e,Oe),a=r[0],o=r[1],i=Re(),s=i[1];return je(function(){!t&&o(n)},[e,n,o,i[0],t]),be({skip:t,update:o,variables:n}),$e(q({},a,{refetch:s}))}function He(){return window.squatchHistory=window.squatchHistory||function(){switch(e.getEnvironmentSDK().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var Le,Te={createHref:function(){var e;return(e=He()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=He()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=He()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=He()).go.apply(e,[].slice.call(arguments))},back:function(){return He().back()},forward:function(){var e;return(e=He()).forward.apply(e,[].slice.call(arguments))}};function Ue(e){var n=a.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],o=t.offset,i=t.limit,s=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:i,setLimit:function(e){var n=u(o,e),a=s(e,n);r(q({},t,{limit:e,offset:a}))},offset:o,setCurrentPage:function(e){var n=s(e,i);r(function(e){return q({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(o,i),r=function(e,n){return Math.ceil(e/n)||0}(n,i),a=0===e?"0":e>1?o+1+"-"+(o+e):""+(o+1);return{currentPage:t,pageCount:r,rangeOnPage:a,pageProgress:a+" of "+n}}}}function Ne(e,n){return e===n}function _e(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=a.useMemo(function(){return b.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var We=d.gql(Le||(Le=A(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),Qe=1e3,ze=60*Qe,Ge=60*ze,Je=24*Ge,Be=function(e,n){n=n||{};var t=typeof e;if("string"===t&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(n){var t=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*t;case"weeks":case"week":case"w":return 6048e5*t;case"days":case"day":case"d":return t*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ge;case"minutes":case"minute":case"mins":case"min":case"m":return t*ze;case"seconds":case"second":case"secs":case"sec":case"s":return t*Qe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}(e);if("number"===t&&isFinite(e))return n.long?function(e){var n=Math.abs(e);return n>=Je?Ke(e,n,Je,"day"):n>=Ge?Ke(e,n,Ge,"hour"):n>=ze?Ke(e,n,ze,"minute"):n>=Qe?Ke(e,n,Qe,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=Je?Math.round(e/Je)+"d":n>=Ge?Math.round(e/Ge)+"h":n>=ze?Math.round(e/ze)+"m":n>=Qe?Math.round(e/Qe)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ke(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var Xe,Ze,Ye,en,nn=(function(e,n){n.formatArgs=function(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const t="color: "+this.color;n.splice(1,0,t,"color: inherit");let r=0,a=0;n[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),n.splice(a,0,t)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),e.exports=function(e){function n(e){let r,a=null;function o(...e){if(!o.enabled)return;const t=o,a=Number(new Date);t.diff=a-(r||a),t.prev=r,t.curr=a,r=a,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=n.formatters[a];return"function"==typeof o&&(r=o.call(t,e[i]),e.splice(i,1),i--),r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return o.namespace=e,o.useColors=n.useColors(),o.color=n.selectColor(e),o.extend=t,o.destroy=n.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?n.enabled(e):a,set:e=>{a=e}}),"function"==typeof n.init&&n.init(o),o}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(t=0;t<a;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=Be,n.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}(n);const{formatters:t}=e.exports;t.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Xe={exports:{}},Xe.exports),Xe.exports)("sq:useForm"),tn=d.gql(Ze||(Ze=A(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),rn=d.gql(Ye||(Ye=A(["\n mutation ($formSubmissionInput: FormSubmissionInput!) {\n submitForm(formSubmissionInput: $formSubmissionInput) {\n success\n results {\n ... on FormHandlerSubmissionResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"]))),an=d.gql(en||(en=A(["\n query ($formValidationInput: FormValidationInput!) {\n validateForm(formValidationInput: $formValidationInput) {\n valid\n results {\n ... on FormHandlerValidationResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"])));Object.defineProperty(exports,"getEnvironmentSDK",{enumerable:!0,get:function(){return e.getEnvironmentSDK}}),Object.defineProperty(exports,"isDemo",{enumerable:!0,get:function(){return e.isDemo}}),Object.defineProperty(exports,"setProgramId",{enumerable:!0,get:function(){return e.setProgramId}}),Object.defineProperty(exports,"setUserIdentity",{enumerable:!0,get:function(){return e.setUserIdentity}}),exports.BatchedGraphQLClient=G,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.memoizedGraphQLClient=re,exports.navigation=Te,exports.setUseHostImplementation=function(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");E.current=e},exports.useAppDomain=D,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var n=ue(ge),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.authenticateManagedIdentityWithEmailAndPassword){var n=i.authenticateManagedIdentityWithEmailAndPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.authenticateManagedIdentityWithEmailAndPassword]),[t,{loading:o,data:i,errors:s}]},exports.useChangePasswordMutation=function(){var e=ue(ye),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Re()[1];return a.useEffect(function(){return He().listen(function(){e()})},[]),He().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||Ne,o=a.useState(e),i=o[0],s=o[1],u=_e(a.useCallback(function(e){return s(e)},[]),n,t),l=a.useRef(e);return a.useEffect(function(){r(l.current,e)||(u.callback(e),l.current=e)},[e,u,r]),[i,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=_e,exports.useEngagementMedium=S,exports.useForm=function(e){var n,t,r,o,i=function(e){try{return Promise.resolve(b({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,l=e.autoSubmit,d=void 0!==l&&l,c=Pe(tn),f=c[0],m=c[1],g=m.data,v=m.loading,p=ue(rn),y=p[0],h=p[1],C=Pe(an),b=C[0],E=C[1],F=a.useReducer(function(e,n){return q({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:E,submitData:h}),P=F[0],I=F[1],M=P.enabled,x=P.disabledMessage,D=P.validating,S=P.valid,k=P.error,A=P.formData;return je(function(){nn("submitData useEffect",h),I({submitData:h})},[h]),je(function(){nn("validationData useEffect",E),I({validationData:E})},[E]),a.useEffect(function(){!v&&g&&function(){var n,t,r,a,o;I({enabled:null==g||null==(n=g.form.initialData)?void 0:n.isEnabled,disabledMessage:null==g||null==(t=g.form)||null==(r=t.initialData)?void 0:r.isEnabledErrorMessage});var i=u;if(i){var s=null==g||null==(a=g.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,s):function(e,n){try{var t=e.elements,r=new FormData(e);nn({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){nn({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=w.default.get(n,r):a.value=w.default.get(n,r)||""}catch(e){nn("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[v]),a.useEffect(function(){var e,n,t,r,a,o;P.validationData&&(I({validating:!1,valid:(null==(e=P.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),d&&null!=(r=P.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&y({formSubmissionInput:{key:s,formData:A}}))},[null==(n=P.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:M,disabledMessage:x,loadingForm:v,validating:D,valid:S,error:k,validationData:P.validationData,submitData:P.submitData},data:{formKey:s,schema:null==g||null==(o=g.form)?void 0:o.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),I({validating:!0});var n=e.target;nn("submit form",n);for(var t,r=new FormData(n),a={},o=R(r.entries());!(t=o()).done;){var s=t.value;w.default.set(a,s[0],s[1])}return I({formData:a}),Promise.resolve(i(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:i,submitForm:function(e){try{return Promise.resolve(y({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:I,getValidationErrors:function(){var e,n,t,r,a=null==E||null==(e=E.data)||null==(n=e.validateForm)||null==(t=n.results[0])||null==(r=t.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1).startsWith(""+e)})}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1)===e})},getSubErrorsAtPath:o,hasSubErrors:function(e){var n;return(null==(n=o(e))?void 0:n.length)>0}}},getSubmissionErrors:function(){var e;if(!P.submitData)return[];var n=null==(e=P.submitData.data)?void 0:e.submitForm.results;return(null==n?void 0:n.map(function(e){var n,t,r,a,o,i,s,u=null==(n=e.result)||null==(t=n.results)?void 0:t.flatMap(function(e){return!e.success&&e.message}).filter(function(e){return e}),l=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(function(e){return!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}}).filter(function(e){return e.error});return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:l}}))||[]}}}},exports.useHost=F,exports.useLazyQuery=Pe,exports.useLocale=function(){e.lazilyStartLocaleContext();var t=F();return n.useDomContext(t,e.LOCALE_CONTEXT_NAME)},exports.useManagedIdentitySessionQuery=xe,exports.useMutation=ue,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Ue(t),s=i.limit,u=i.setLimit,l=i.setCurrentPage,d=i.calculatePagination,c=Ve(e,q({limit:s,offset:i.offset},r),a),f=c.loading,m=c.errors,g=c.refetch,v=n(c.data),p=d((null==v||null==(o=v.data)?void 0:o.length)||0,(null==v?void 0:v.totalCount)||0);return{envelope:v,states:{errors:m,loading:f,limit:s,currentPage:p.currentPage,pageCount:p.pageCount,pageProgress:p.pageProgress},callbacks:{refetch:g,setLimit:u,setCurrentPage:l}}},exports.usePagination=Ue,exports.useProgramId=P,exports.useQuery=Ve,exports.useRefreshDispatcher=function(){var e=F();return{refresh:a.useCallback(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}},exports.useRegisterViaRegistrationFormMutation=function(){var n=ue(pe),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors,u=a.useState(null),l=u[0],d=u[1];return a.useEffect(function(){var n,t=null==i||null==(n=i.submitForm)?void 0:n.results.find(function(e){return"identity"===e.formHandler.namespace});if(t&&t.result.results.length){var r=t.result.results[0];if(r.success){d(null);var a=r.data.token,o=y.default(a).user;e.setUserIdentity({jwt:a,id:o.id,accountId:o.accountId,managedIdentity:{email:r.data.email,emailVerified:r.data.emailVerified,sessionData:r.data.sessionData}})}else d(r.message)}},[null==i?void 0:i.submitForm]),[t,{loading:o,data:i,errors:s,formError:l}]},exports.useRegisterWithEmailAndPasswordMutation=function(){var n=ue(ve),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.registerManagedIdentityWithEmailAndPassword){var n=i.registerManagedIdentityWithEmailAndPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.registerManagedIdentityWithEmailAndPassword]),[t,{loading:o,data:i,errors:s}]},exports.useRequestPasswordResetEmailMutation=function(){return ue(ke)},exports.useRequestVerificationEmailMutation=function(){return ue(Ae)},exports.useResetPasswordMutation=function(){var n=ue(he),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.resetManagedIdentityPassword){var n=i.resetManagedIdentityPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.resetManagedIdentityPassword]),[t,{loading:o,data:i,errors:s}]},exports.useSessionData=function(){var e,n;return null==(e=M())||null==(n=e.managedIdentity)?void 0:n.sessionData},exports.useShareEvent=function(){var e=S(),n=M(),t=P(),r=ue(We)[0];return n?function(a){r({eventMeta:{id:n.id,accountId:n.accountId,programId:t,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:function(){}},exports.useTenantAlias=x,exports.useTick=Re,exports.useToken=I,exports.useUserIdentity=M,exports.useVerifyEmailMutation=function(){var e,n=xe()[0],t=ue(qe),r=t[0],o=t[1],i=o.loading,s=o.data,u=o.errors;return a.useEffect(function(){var e;null!=s&&null!=(e=s.verifyManagedIdentityEmail)&&e.success&&n()},[null==s||null==(e=s.verifyManagedIdentityEmail)?void 0:e.success]),[r,{loading:i,data:s,errors:u}]},exports.useVerifyPasswordResetCodeMutation=function(){return ue(Ce)};
1
+ var e=require("@saasquatch/component-environment"),n=require("@saasquatch/dom-context-hooks"),t=require("graphql"),r=require("jwt-decode"),a=require("@saasquatch/universal-hooks"),o=require("fast-memoize"),i=require("rxjs"),s=require("rxjs/operators"),u=require("nanoid"),l=require("graphql-request/dist/types"),c=require("graphql-request"),d=require("graphql-combine-query"),f=require("@wry/equality"),m=require("history"),v=require("debounce"),g=require("jsonpointer");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=p(r),h=p(o),C=p(d),b=p(v),w=p(g),E={current:void 0};function F(){if(void 0===E.current)throw new Error("no implementation of useHost provided");return E.current()}function P(){e.lazilyStartProgramContext();var t=F();return n.useDomContext(t,e.PROGRAM_CONTEXT_NAME)}function I(){var e;return null==(e=M())?void 0:e.jwt}function M(){e.lazilyStartUserContext();var t=F(),r=n.useDomContext(t,e.USER_CONTEXT_NAME),a=e.userIdentityFromJwt(null==r?void 0:r.jwt);if(!r||a)return r;e.setUserIdentity(void 0)}var x=e.getTenantAlias,D=e.getAppDomain,q=e.getEngagementMedium;function S(){return(S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function k(e,n){return(k=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function j(e,n){return n||(n=e.slice(0)),e.raw=n,e}function A(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function R(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return A(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?A(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var $=function(){return($=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var a in n=arguments[t])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e}).apply(this,arguments)},O=new Map,V=new Map,H=!0,L=!1;function T(e){return e.replace(/[\s,]+/g," ").trim()}function U(e){var n,r,a,o=T(e);if(!O.has(o)){var i=t.parse(e,{experimentalFragmentVariables:L});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");O.set(o,function(e){var n=new Set(e.definitions);n.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(t){var r=e[t];r&&"object"==typeof r&&n.add(r)})});var t=e.loc;return t&&(delete t.startToken,delete t.endToken),e}((n=i,r=new Set,a=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,t=T((i=e.loc).source.body.substring(i.start,i.end)),o=V.get(n);o&&!o.has(t)?H&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||V.set(n,o=new Set),o.add(t),r.has(t)||(r.add(t),a.push(e))}else a.push(e);var i}),$($({},n),{definitions:a}))))}return O.get(o)}function N(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];"string"==typeof e&&(e=[e]);var r=e[0];return n.forEach(function(n,t){r+=n&&"Document"===n.kind?n.loc.source.body:n,r+=e[t+1]}),U(r)}var _,W=N;(_=N||(N={})).gql=W,_.resetCaches=function(){O.clear(),V.clear()},_.disableFragmentWarnings=function(){H=!1},_.enableExperimentalFragmentVariables=function(){L=!0},_.disableExperimentalFragmentVariables=function(){L=!1},N.default=N;var Q=N;function z(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var G=function(e){var n,r;function a(n,r){var a;(a=e.call(this,n,r)||this).subject=new i.Subject;var o=new i.Subject;return a.subject.pipe(s.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,r=X(e),i=r.mergedQuery,s=r.mergedVariables,u=r.mergedQueryAddedEvents,c=R(r.unmergedQueryAddedEvents);!(n=c()).done;)o.next(n.value);return u.length?Promise.resolve(z(function(){return Promise.resolve(a.superRequest(i,s)).then(function(e){ee(e,u)})},function(e){if(e instanceof l.ClientError){var n=function(){var n=e.response,r=n.data,a=n.errors;if(!r)return{v:te(u,e)};for(var o,i=Object.keys(r),s=[].concat(u),c=function(){var n=o.value,r=void 0;n.path.find(function(a,o,u){if(i.includes(a)){var c=K(a),d=s.findIndex(function(e){return e.id===c});if(-1===d)return!1;i.splice(o,1),r=s.splice(d,1)[0];var f=Z(e.response.data,r);u[o]=B(u[o],c);var m=r.query,v=r.variables,g=S({},e.response,{errors:[n],data:f,path:u}),p=new l.ClientError(g,{query:"string"!=typeof m?t.print(m):m,variables:v});return ne(r,p),!0}return!1})},d=R(a);!(o=d()).done;)c();ee(r,s)}();if("object"==typeof n)return n.v}else te(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),o.subscribe(function(e){try{var n=z(function(){return Promise.resolve(a.superRequest(e.query,e.variables)).then(function(n){Y(n,e)})},function(n){ne(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),a}r=e,(n=a).prototype=Object.create(r.prototype),n.prototype.constructor=n,k(n,r);var o=a.prototype;return o.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},o.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:J(),resolve:r,reject:a};t.subject.next(o)})},a}(c.GraphQLClient),J=function(){return u.nanoid().replace(/[-_]/g,"")},B=function(e,n){return e.replace("_"+n,"")},K=function(e){var n=e.split("_");return n[n.length-1]},X=function(e){var n=[],r=[],a=e.reduce(function(e,a){var o=a.query,i=a.variables,s=a.id;try{var u="string"==typeof o?t.parse(o):o,l=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),c="string"==typeof o?o:t.print(o),d=/@/.test(c);if(l||d)return r.push(a),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(a),e}catch(n){return r.push(a),e}},C.default("BatchedQuery")),o=a.document,i=a.variables;return{mergedQuery:o&&t.print(o),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:r}},Z=function(e,n){if(!e)return e;var t=Object.keys(e),r=n.id;return t.reduce(function(n,t){var a;return t.endsWith(r)&&(n=S({},n,((a={})[B(t,r)]=e[t],a))),n},{})},Y=function(e,n){(0,n.resolve)(e)},ee=function(e,n){for(var t,r=R(n);!(t=r()).done;){var a=t.value,o=Z(e,a);a.resolve(o)}},ne=function(e,n){(0,e.reject)(n)},te=function(e,n){for(var t,r=R(e);!(t=r()).done;)(0,t.value.reject)(n)},re=h.default(function(e,n,t){return new G(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function ae(e,n){switch(n.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:n.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:n.payload,loading:!1}}}function oe(e,t){var r,o,i,s,u,l,c=(r=I(),o=D(),i=x(),s=re(o,i,r),u=F(),null!=(l=n.useDomContext(u,"sq:graphql-client",{attempts:0}))?l:s),d=a.useReducer(ae,t),f=d[1];return[d[0],a.useCallback(function(n,t){void 0===t&&(t=!1);try{if(!c){var r=new Error("No GraphQL client found");return f({type:"errors",payload:r}),Promise.resolve(r)}return Promise.resolve(function(r,a){try{var o=(t||f({type:"loading"}),Promise.resolve(c.request(e,n)).then(function(e){return f({type:"data",payload:e}),e}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){return f({type:"errors",payload:e}),e}))}catch(e){return Promise.reject(e)}},[c,e,f])]}var ie,se={loading:!1,data:void 0,errors:void 0};function ue(e){var n=oe(e,se);return[n[1],n[0]]}var le,ce,de,fe,me,ve=Q(ie||(ie=j(["\n mutation AuthenticateWithEmailAndPassword(\n $email: String!\n $password: String!\n ) {\n authenticateManagedIdentityWithEmailAndPassword(\n authenticateManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),ge=Q(le||(le=j(["\n mutation RegisterWithEmailAndPassword(\n $email: String!\n $password: String!\n $formData: RSJsonNode\n $redirectPath: String\n ) {\n registerManagedIdentityWithEmailAndPassword(\n registerManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n formData: $formData\n redirectPath: $redirectPath\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),pe=Q(ce||(ce=j(["\n mutation RegisterViaRegistrationForm($key: String!, $formData: RSJsonNode!) {\n submitForm(formSubmissionInput: { key: $key, formData: $formData }) {\n results {\n ... on FormHandlerSubmissionResult {\n result\n formHandler {\n namespace\n }\n }\n ... on FormHandlerError {\n errorCode\n error\n errorType\n formHandler {\n name\n endpointUrl\n }\n }\n }\n }\n }\n"]))),ye=Q(de||(de=j(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),he=Q(fe||(fe=j(["\n mutation ResetPassword($oobCode: String!, $password: String!) {\n resetManagedIdentityPassword(\n resetManagedIdentityPasswordInput: {\n password: $password\n oobCode: $oobCode\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),Ce=Q(me||(me=j(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function be(e){var n=e.skip,t=void 0!==n&&n,r=e.update,o=e.variables;a.useEffect(function(){var e=function(e){!t&&r(o,!0)};return document.addEventListener("sq:refresh",e),function(){return document.removeEventListener("sq:refresh",e)}},function(e){var n=a.useRef(e),t=a.useRef(0);return f.equal(e,n.current)||(n.current=e,t.current+=1),a.useMemo(function(){return n.current},[t.current])}([o,r,t]))}var we,Ee={loading:!1,data:void 0,errors:void 0},Fe=Symbol();function Pe(e){var n=oe(e,Ee),t=n[0],r=n[1],o=a.useRef(Fe);be({skip:o.current===Fe,update:r,variables:o.current});var i=a.useCallback(function(e){return o.current=e,r(e)},[r]);return[r,S({},t,{refetch:i})]}var Ie,Me=Q(we||(we=j(["\n query ManagedIdentitySession {\n managedIdentitySession {\n email\n emailVerified\n sessionData\n }\n }\n"])));function xe(){var n=M(),t=Pe(Me),r=t[0],a=t[1],o=a.refetch,i=function(t){t instanceof Error||!t.managedIdentitySession||e.setUserIdentity(S({},n,{managedIdentity:t.managedIdentitySession}))};return[function(){try{return Promise.resolve(r({})).then(function(e){return i(e),e})}catch(e){return Promise.reject(e)}},{loading:a.loading,data:a.data,errors:a.errors,refetch:function(){try{return Promise.resolve(o()).then(function(e){return i(e),e})}catch(e){return Promise.reject(e)}}}]}var De,qe,Se=Q(Ie||(Ie=j(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),ke=Q(De||(De=j(["\n mutation RequestPasswordResetEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityPasswordResetEmail(\n requestManagedIdentityPasswordResetEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"]))),je=Q(qe||(qe=j(["\n mutation RequestVerificationEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityVerificationEmail(\n requestManagedIdentityVerificationEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"])));function Ae(e,n){var t=a.useRef();return t.current&&f.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Re(){return a.useReducer(function(e){return e+1},0)}function $e(e){for(var n,t=R(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&$e(r)}return Object.freeze(e)}var Oe={loading:!0,data:void 0,errors:void 0};function Ve(e,n,t){var r=oe(e,Oe),a=r[0],o=r[1],i=Re(),s=i[1];return Ae(function(){!t&&o(n)},[e,n,o,i[0],t]),be({skip:t,update:o,variables:n}),$e(S({},a,{refetch:s}))}function He(){return window.squatchHistory=window.squatchHistory||function(){switch(e.getEnvironmentSDK().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var Le,Te={createHref:function(){var e;return(e=He()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=He()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=He()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=He()).go.apply(e,[].slice.call(arguments))},back:function(){return He().back()},forward:function(){var e;return(e=He()).forward.apply(e,[].slice.call(arguments))}};function Ue(e){var n=a.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],o=t.offset,i=t.limit,s=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:i,setLimit:function(e){var n=u(o,e),a=s(e,n);r(S({},t,{limit:e,offset:a}))},offset:o,setCurrentPage:function(e){var n=s(e,i);r(function(e){return S({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(o,i),r=function(e,n){return Math.ceil(e/n)||0}(n,i),a=0===e?"0":e>1?o+1+"-"+(o+e):""+(o+1);return{currentPage:t,pageCount:r,rangeOnPage:a,pageProgress:a+" of "+n}}}}function Ne(e,n){return e===n}function _e(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=a.useMemo(function(){return b.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var We=c.gql(Le||(Le=j(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),Qe=1e3,ze=60*Qe,Ge=60*ze,Je=24*Ge,Be=function(e,n){n=n||{};var t=typeof e;if("string"===t&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(n){var t=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*t;case"weeks":case"week":case"w":return 6048e5*t;case"days":case"day":case"d":return t*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ge;case"minutes":case"minute":case"mins":case"min":case"m":return t*ze;case"seconds":case"second":case"secs":case"sec":case"s":return t*Qe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}(e);if("number"===t&&isFinite(e))return n.long?function(e){var n=Math.abs(e);return n>=Je?Ke(e,n,Je,"day"):n>=Ge?Ke(e,n,Ge,"hour"):n>=ze?Ke(e,n,ze,"minute"):n>=Qe?Ke(e,n,Qe,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=Je?Math.round(e/Je)+"d":n>=Ge?Math.round(e/Ge)+"h":n>=ze?Math.round(e/ze)+"m":n>=Qe?Math.round(e/Qe)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ke(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var Xe,Ze,Ye,en,nn=(function(e,n){n.formatArgs=function(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const t="color: "+this.color;n.splice(1,0,t,"color: inherit");let r=0,a=0;n[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),n.splice(a,0,t)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),e.exports=function(e){function n(e){let r,a=null;function o(...e){if(!o.enabled)return;const t=o,a=Number(new Date);t.diff=a-(r||a),t.prev=r,t.curr=a,r=a,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=n.formatters[a];return"function"==typeof o&&(r=o.call(t,e[i]),e.splice(i,1),i--),r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return o.namespace=e,o.useColors=n.useColors(),o.color=n.selectColor(e),o.extend=t,o.destroy=n.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?n.enabled(e):a,set:e=>{a=e}}),"function"==typeof n.init&&n.init(o),o}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(t=0;t<a;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=Be,n.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}(n);const{formatters:t}=e.exports;t.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Xe={exports:{}},Xe.exports),Xe.exports)("sq:useForm"),tn=c.gql(Ze||(Ze=j(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),rn=c.gql(Ye||(Ye=j(["\n mutation ($formSubmissionInput: FormSubmissionInput!) {\n submitForm(formSubmissionInput: $formSubmissionInput) {\n success\n results {\n ... on FormHandlerSubmissionResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"]))),an=c.gql(en||(en=j(["\n query ($formValidationInput: FormValidationInput!) {\n validateForm(formValidationInput: $formValidationInput) {\n valid\n results {\n ... on FormHandlerValidationResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"])));Object.defineProperty(exports,"getEnvironmentSDK",{enumerable:!0,get:function(){return e.getEnvironmentSDK}}),Object.defineProperty(exports,"isDemo",{enumerable:!0,get:function(){return e.isDemo}}),Object.defineProperty(exports,"setProgramId",{enumerable:!0,get:function(){return e.setProgramId}}),Object.defineProperty(exports,"setUserIdentity",{enumerable:!0,get:function(){return e.setUserIdentity}}),exports.BatchedGraphQLClient=G,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.memoizedGraphQLClient=re,exports.navigation=Te,exports.setUseHostImplementation=function(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");E.current=e},exports.useAppDomain=D,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var n=ue(ve),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.authenticateManagedIdentityWithEmailAndPassword){var n=i.authenticateManagedIdentityWithEmailAndPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.authenticateManagedIdentityWithEmailAndPassword]),[t,{loading:o,data:i,errors:s}]},exports.useChangePasswordMutation=function(){var e=ue(ye),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Re()[1];return a.useEffect(function(){return He().listen(function(){e()})},[]),He().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||Ne,o=a.useState(e),i=o[0],s=o[1],u=_e(a.useCallback(function(e){return s(e)},[]),n,t),l=a.useRef(e);return a.useEffect(function(){r(l.current,e)||(u.callback(e),l.current=e)},[e,u,r]),[i,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=_e,exports.useEngagementMedium=q,exports.useForm=function(e){var n,t,r,o,i=function(e){try{return Promise.resolve(b({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,l=e.autoSubmit,c=void 0!==l&&l,d=Pe(tn),f=d[0],m=d[1],v=m.data,g=m.loading,p=ue(rn),y=p[0],h=p[1],C=Pe(an),b=C[0],E=C[1],F=a.useReducer(function(e,n){return S({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:E,submitData:h}),P=F[0],I=F[1],M=P.enabled,x=P.disabledMessage,D=P.validating,q=P.valid,k=P.error,j=P.formData;return Ae(function(){nn("submitData useEffect",h),I({submitData:h})},[h]),Ae(function(){nn("validationData useEffect",E),I({validationData:E})},[E]),a.useEffect(function(){!g&&v&&function(){var n,t,r,a,o;I({enabled:null==v||null==(n=v.form.initialData)?void 0:n.isEnabled,disabledMessage:null==v||null==(t=v.form)||null==(r=t.initialData)?void 0:r.isEnabledErrorMessage});var i=u;if(i){var s=null==v||null==(a=v.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,s):function(e,n){try{var t=e.elements,r=new FormData(e);nn({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){nn({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=w.default.get(n,r):a.value=w.default.get(n,r)||""}catch(e){nn("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[g]),a.useEffect(function(){var e,n,t,r,a,o;P.validationData&&(I({validating:!1,valid:(null==(e=P.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),c&&null!=(r=P.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&y({formSubmissionInput:{key:s,formData:j}}))},[null==(n=P.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:M,disabledMessage:x,loadingForm:g,validating:D,valid:q,error:k,validationData:P.validationData,submitData:P.submitData},data:{formKey:s,schema:null==v||null==(o=v.form)?void 0:o.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),I({validating:!0});var n=e.target;nn("submit form",n);for(var t,r=new FormData(n),a={},o=R(r.entries());!(t=o()).done;){var s=t.value;w.default.set(a,s[0],s[1])}return I({formData:a}),Promise.resolve(i(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:i,submitForm:function(e){try{return Promise.resolve(y({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:I,getValidationErrors:function(){var e,n,t,r,a=null==E||null==(e=E.data)||null==(n=e.validateForm)||null==(t=n.results[0])||null==(r=t.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1).startsWith(""+e)})}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1)===e})},getSubErrorsAtPath:o,hasSubErrors:function(e){var n;return(null==(n=o(e))?void 0:n.length)>0}}},getSubmissionErrors:function(){var e;if(!P.submitData)return[];var n=null==(e=P.submitData.data)?void 0:e.submitForm.results;return(null==n?void 0:n.map(function(e){var n,t,r,a,o,i,s,u=null==(n=e.result)||null==(t=n.results)?void 0:t.flatMap(function(e){return!e.success&&e.message}).filter(function(e){return e}),l=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(function(e){return!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}}).filter(function(e){return e.error});return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:l}}))||[]}}}},exports.useHost=F,exports.useLazyQuery=Pe,exports.useLocale=function(){e.lazilyStartLocaleContext();var t=F();return n.useDomContext(t,e.LOCALE_CONTEXT_NAME)},exports.useManagedIdentitySessionQuery=xe,exports.useMutation=ue,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Ue(t),s=i.limit,u=i.setLimit,l=i.setCurrentPage,c=i.calculatePagination,d=Ve(e,S({limit:s,offset:i.offset},r),a),f=d.loading,m=d.errors,v=d.refetch,g=n(d.data),p=c((null==g||null==(o=g.data)?void 0:o.length)||0,(null==g?void 0:g.totalCount)||0);return{envelope:g,states:{errors:m,loading:f,limit:s,currentPage:p.currentPage,pageCount:p.pageCount,pageProgress:p.pageProgress},callbacks:{refetch:v,setLimit:u,setCurrentPage:l}}},exports.usePagination=Ue,exports.useProgramId=P,exports.useQuery=Ve,exports.useRefreshDispatcher=function(){var e=F();return{refresh:a.useCallback(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}},exports.useRegisterViaRegistrationFormMutation=function(){var n=ue(pe),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors,u=a.useState(null),l=u[0],c=u[1];return a.useEffect(function(){var n,t=null==i||null==(n=i.submitForm)?void 0:n.results.find(function(e){return"identity"===e.formHandler.namespace});if(t&&t.result.results.length){var r=t.result.results[0];if(r.success){c(null);var a=r.data.token,o=y.default(a).user;e.setUserIdentity({jwt:a,id:o.id,accountId:o.accountId,managedIdentity:{email:r.data.email,emailVerified:r.data.emailVerified,sessionData:r.data.sessionData}})}else c(r.message)}},[null==i?void 0:i.submitForm]),[t,{loading:o,data:i,errors:s,formError:l}]},exports.useRegisterWithEmailAndPasswordMutation=function(){var n=ue(ge),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.registerManagedIdentityWithEmailAndPassword){var n=i.registerManagedIdentityWithEmailAndPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.registerManagedIdentityWithEmailAndPassword]),[t,{loading:o,data:i,errors:s}]},exports.useRequestPasswordResetEmailMutation=function(){return ue(ke)},exports.useRequestVerificationEmailMutation=function(){return ue(je)},exports.useResetPasswordMutation=function(){var n=ue(he),t=n[0],r=n[1],o=r.loading,i=r.data,s=r.errors;return a.useEffect(function(){if(null!=i&&i.resetManagedIdentityPassword){var n=i.resetManagedIdentityPassword,t=n.token,r=y.default(t).user;e.setUserIdentity({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:n.email,emailVerified:n.emailVerified,sessionData:n.sessionData}})}},[null==i?void 0:i.resetManagedIdentityPassword]),[t,{loading:o,data:i,errors:s}]},exports.useSessionData=function(){var e,n;return null==(e=M())||null==(n=e.managedIdentity)?void 0:n.sessionData},exports.useShareEvent=function(){var e=q(),n=M(),t=P(),r=ue(We)[0];return n?function(a){r({eventMeta:{id:n.id,accountId:n.accountId,programId:t,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:function(){}},exports.useTenantAlias=x,exports.useTick=Re,exports.useToken=I,exports.useUserIdentity=M,exports.useVerifyEmailMutation=function(){var e=xe()[0],n=ue(Se),t=n[0],r=n[1];return[function(n){try{return Promise.resolve(t(n)).then(function(n){var t=function(){var t;if(!(n instanceof Error)&&null!=n&&null!=(t=n.verifyManagedIdentityEmail)&&t.success)return Promise.resolve(e()).then(function(){})}();return t&&t.then?t.then(function(){return n}):n})}catch(n){return Promise.reject(n)}},{loading:r.loading,data:r.data,errors:r.errors}]},exports.useVerifyPasswordResetCodeMutation=function(){return ue(Ce)};
2
2
  //# sourceMappingURL=index.js.map