@saasquatch/component-boilerplate 1.2.3-9 → 1.3.1-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.
- package/CHANGELOG.md +122 -99
- package/README.md +7 -7
- package/dist/environment/LocaleContext.d.ts +9 -0
- package/dist/environment/UserIdentityContext.d.ts +2 -0
- package/dist/environment/environment.d.ts +5 -1
- package/dist/hooks/graphql/Refresh.d.ts +9 -0
- package/dist/hooks/graphql/useBaseQuery.d.ts +4 -1
- package/dist/hooks/useDebounce.d.ts +1 -1
- package/dist/hooks/useDeepEffect.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +36 -18
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +59 -59
- package/dist/environment/GraphQLRequestManager.d.ts +0 -1
- package/dist/environment/SquatchPortal.d.ts +0 -26
- package/dist/hooks/graphql/useBatchedQuery.d.ts +0 -45
- package/dist/hooks/graphql/useCustomQuery.d.ts +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,99 +1,122 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.
|
|
9
|
-
|
|
10
|
-
###
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.3.1] - 2022-02-14
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- useLocale hook uses locale from SaaSquatch user instead of browser
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- useRefreshDispatcher hook and `sq:refresh` event listener added to give ability to refresh query data without triggering a loading state
|
|
17
|
+
|
|
18
|
+
## [1.3.0] - 2021-12-09
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Rare race condition causing queries to not return their data fixed
|
|
23
|
+
- User identity no longer being cleared if identity is not immediately available in context
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- redirectPath is now included with registration, password reset, and verify email requests
|
|
28
|
+
|
|
29
|
+
## [1.2.2] - 2021-08-23
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Support for theme engine JWTs for determining user identity, enabling support for hybrid themes
|
|
34
|
+
|
|
35
|
+
## [1.2.1] - 2021-08-20
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- Fixed infinite loop caused by calling useToken while logged out
|
|
40
|
+
- Changed environment detection to support `widgetIdent.env = "demo"` in vanilla components
|
|
41
|
+
|
|
42
|
+
## [1.2.0] - 2021-08-04
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Portal environment now supports storing and retrieving user identity from localStorage
|
|
47
|
+
and validating JWT expiry
|
|
48
|
+
- New hooks:
|
|
49
|
+
- useAuthenticatedWithEmailAndPasswordMutation: Login a user with email and password
|
|
50
|
+
- useChangePasswordMutation: Change a user's password
|
|
51
|
+
- useManagedIdentityQuery: Query a user's managed identity
|
|
52
|
+
- useRegisterWithEmailAndPasswordMutation: Register a user with email and password
|
|
53
|
+
- useRequestPasswordResetEmailMutation: Request a password reset for an email address
|
|
54
|
+
- useRequestVerificationEmailMutation: Request an email verification for a user
|
|
55
|
+
- useResetPasswordMutation: Reset a user's password from an oobCode
|
|
56
|
+
- useVerifyEmailMutation: Verify a user's email from an oobCode
|
|
57
|
+
- useVerifyPasswordResetCodeMutation: Verify a password reset oobCode
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
## [1.1.0] - 2021-05-20
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
- BatchedGraphQLClient - Updated client to allow queries to be batched if run in the same 200ms interval
|
|
66
|
+
- useLocale Added back due to usage in mint-components
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- useGraphQLClient - Use BatchedGraphQLClient instead of client from graphql-request
|
|
71
|
+
- useBaseQuery - Handle component unmounts with a cleanup function
|
|
72
|
+
- useForm - No longer automatically queries for the form, getForm function must be called manually from the component using the hook
|
|
73
|
+
- useQuery - New "skip" parameter based on https://www.apollographql.com/docs/react/data/queries/#skip. Also added to usePaginatedQuery
|
|
74
|
+
- Jest tests rewritten to use BatchedGraphQLClient
|
|
75
|
+
|
|
76
|
+
## [1.0.0] - 2021-04-21
|
|
77
|
+
|
|
78
|
+
### Added
|
|
79
|
+
|
|
80
|
+
- Initial release
|
|
81
|
+
- exported hooks available:
|
|
82
|
+
- identity hooks:
|
|
83
|
+
- useUserIdentity
|
|
84
|
+
setUserIdentity
|
|
85
|
+
useToken
|
|
86
|
+
- environment hooks:
|
|
87
|
+
- getEnvironmentSDK
|
|
88
|
+
useTenantAlias
|
|
89
|
+
useProgramId
|
|
90
|
+
setProgramId
|
|
91
|
+
useAppDomain
|
|
92
|
+
isDemo
|
|
93
|
+
useEngagementMedium
|
|
94
|
+
- graphql hooks:
|
|
95
|
+
- useQuery
|
|
96
|
+
useMutation
|
|
97
|
+
useLazyQuery
|
|
98
|
+
- navigation hooks
|
|
99
|
+
- navigation
|
|
100
|
+
useCurrentPage
|
|
101
|
+
- pagination hooks
|
|
102
|
+
- usePagination
|
|
103
|
+
usePaginatedQuery
|
|
104
|
+
- Generic low-level helpers
|
|
105
|
+
- useDebounce
|
|
106
|
+
useDebouncedCallback
|
|
107
|
+
useTick
|
|
108
|
+
useHost
|
|
109
|
+
setUseHostImplementation
|
|
110
|
+
- Common higher-level functionality
|
|
111
|
+
- useShareEvent
|
|
112
|
+
useForm
|
|
113
|
+
|
|
114
|
+
[unreleased]: https://github.com/saasquatch/program-tools/compare/component-boilerplate@1.3.1...HEAD
|
|
115
|
+
[1.3.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.3.1
|
|
116
|
+
[1.3.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.3.0
|
|
117
|
+
[1.2.2]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.2
|
|
118
|
+
[1.2.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.1
|
|
119
|
+
[1.2.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.0
|
|
120
|
+
[1.1.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.1.0
|
|
121
|
+
[1.0.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.1
|
|
122
|
+
[1.0.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.0
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# SaaSquatch Component Boilerplate
|
|
2
|
-
|
|
3
|
-
This is a collection of essential universal hooks for use in building web components for the SaaSquatch platform.
|
|
4
|
-
|
|
5
|
-
## Documentation
|
|
6
|
-
|
|
7
|
-
See [index.ts](src/index.ts) for API documentation directly in Typescript.
|
|
1
|
+
# SaaSquatch Component Boilerplate
|
|
2
|
+
|
|
3
|
+
This is a collection of essential universal hooks for use in building web components for the SaaSquatch platform.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
See [index.ts](src/index.ts) for API documentation directly in Typescript.
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -14,6 +14,10 @@ export declare type PortalEnv = Pick<WidgetIdent, "tenantAlias" | "appDomain" |
|
|
|
14
14
|
* Program ID context helpers
|
|
15
15
|
*/
|
|
16
16
|
export { useProgramId, setProgramId } from "./ProgramContext";
|
|
17
|
+
/**
|
|
18
|
+
* Locale context helpers
|
|
19
|
+
*/
|
|
20
|
+
export { useLocale } from "./LocaleContext";
|
|
17
21
|
/**
|
|
18
22
|
* Provided by the SaaSquatch GraphQL backend when a widget is rendered.
|
|
19
23
|
*
|
|
@@ -26,6 +30,7 @@ export interface WidgetIdent {
|
|
|
26
30
|
token: string;
|
|
27
31
|
userId: string;
|
|
28
32
|
accountId: string;
|
|
33
|
+
locale?: string;
|
|
29
34
|
engagementMedium?: "POPUP" | "EMBED";
|
|
30
35
|
programId?: string;
|
|
31
36
|
env?: string;
|
|
@@ -127,4 +132,3 @@ export declare type UserId = {
|
|
|
127
132
|
};
|
|
128
133
|
declare type EngagementMedium = "EMBED" | "POPUP";
|
|
129
134
|
export declare function useEngagementMedium(): EngagementMedium;
|
|
130
|
-
export declare function useLocale(): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const REFRESH_EVENT_NAME = "sq:refresh";
|
|
2
|
+
export declare function useRefreshDispatcher(): {
|
|
3
|
+
refresh: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function useRefreshListener({ skip, update, variables, }: {
|
|
6
|
+
skip?: boolean;
|
|
7
|
+
update: (variables: unknown, skipLoading?: boolean) => unknown;
|
|
8
|
+
variables: unknown;
|
|
9
|
+
}): void;
|
|
@@ -43,4 +43,7 @@ export declare type GraphQlRequestError<T> = {
|
|
|
43
43
|
};
|
|
44
44
|
message?: string;
|
|
45
45
|
};
|
|
46
|
-
export declare function useBaseQuery<T = any>(query: GqlType, initialState: BaseQueryData<T>): [
|
|
46
|
+
export declare function useBaseQuery<T = any>(query: GqlType, initialState: BaseQueryData<T>): [
|
|
47
|
+
BaseQueryData<T>,
|
|
48
|
+
(variables: unknown, skipLoading?: boolean) => Promise<void>
|
|
49
|
+
];
|
|
@@ -41,7 +41,7 @@ export interface DebouncedState<T extends (...args: any[]) => ReturnType<T>> ext
|
|
|
41
41
|
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
42
42
|
* debounced function. Subsequent calls to the debounced function return the
|
|
43
43
|
* result of the last `func` invocation.
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
*
|
|
46
46
|
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
47
47
|
* for details over the differences between `debounce` and `throttle`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect } from "@saasquatch/universal-hooks";
|
|
2
|
+
declare type UseEffectParams = Parameters<typeof useEffect>;
|
|
3
|
+
declare type EffectCallback = UseEffectParams[0];
|
|
4
|
+
declare type DependencyList = UseEffectParams[1];
|
|
5
|
+
declare type UseEffectReturn = ReturnType<typeof useEffect>;
|
|
6
|
+
/**
|
|
7
|
+
* @param value the value to be memoized (usually a dependency list)
|
|
8
|
+
* @returns a memoized version of the value as long as it remains deeply equal
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDeepCompareMemoize<T>(value: T): T;
|
|
11
|
+
export declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
|
|
12
|
+
export default useDeepCompareEffect;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { useQuery } from "./hooks/graphql/useQuery";
|
|
|
16
16
|
export { useMutation } from "./hooks/graphql/useMutation";
|
|
17
17
|
export { useLazyQuery } from "./hooks/graphql/useLazyQuery";
|
|
18
18
|
export { memoizedGraphQLClient, GRAPHQL_CONTEXT, } from "./hooks/graphql/useGraphQLClient";
|
|
19
|
+
export { useRefreshDispatcher } from "./hooks/graphql/Refresh";
|
|
19
20
|
export { navigation, useCurrentPage } from "./hooks/useNavigation";
|
|
20
21
|
export { usePagination } from "./hooks/pagination/usePagination";
|
|
21
22
|
export { usePaginatedQuery } from "./hooks/pagination/usePaginatedQuery";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("@saasquatch/dom-context-hooks"),n=require("dom-context"),t=require("jwt-decode"),r=require("@wry/equality"),a=require("graphql"),o=require("@saasquatch/universal-hooks"),i=require("fast-memoize"),s=require("rxjs"),u=require("rxjs/operators"),d=require("nanoid"),c=require("graphql-request/dist/types"),l=require("graphql-request"),f=require("graphql-combine-query"),m=require("history"),p=require("debounce"),g=require("jsonpointer");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=v(t),y=v(i),w=v(f),C=v(p),b=v(g),I={current:void 0};function q(){if(void 0===I.current)throw new Error("no implementation of useHost provided");return I.current()}function F(){var e;window.squatchProgramId||(window.squatchProgramId=new n.ContextProvider({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function P(){F();var n=q();return e.useDomContext(n,"sq:program-id")}function E(){var e,n;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(n=window.frameElement)?void 0:n.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function S(){var e=E();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function x(){var e,n=E();switch(n.type){case"SquatchAndroid":case"SquatchJS2":return n.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=n.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function M(){var e=E();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function A(){return(A=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 D(e,n){return(D=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function k(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 $(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)}function R(){window.squatchUserIdentity||(window.squatchUserIdentity=new n.ContextProvider({element:document.documentElement,initialState:O(),contextName:"sq:user-identity"}).start())}function V(e){if(e)try{var n,t,r=h.default(e),a=r.exp;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(r)){var o=r.sub.match(/(.*):(.*)@(.*):users/);t=atob(o[1]),n=atob(o[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(r)&&(t=r.user.accountId,n=r.user.id);if(!n||!t)return;if(a&&Date.now()>=1e3*a)return;return{id:n,accountId:t,jwt:e}}catch(e){return}}function O(){var e=E();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":var n=new URLSearchParams(document.location.search);if(n.has("jwt"))return V(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=V(r.jwt);return a?A({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function N(e){R();var n=window.squatchUserIdentity;r.equal(n.context,e)||(n.context=e),e&&"SquatchPortal"===E().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||localStorage.removeItem("sq:user-identity")}function H(){var e;return null==(e=L())?void 0:e.jwt}function L(){R();var n=q(),t=e.useDomContext(n,"sq:user-identity"),r=V(null==t?void 0:t.jwt);if(!t||r)return t;N(void 0)}var W=function(){return(W=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)},U=new Map,Q=new Map,_=!0,J=!1;function T(e){return e.replace(/[\s,]+/g," ").trim()}function G(e){var n,t,r,o=T(e);if(!U.has(o)){var i=a.parse(e,{experimentalFragmentVariables:J});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");U.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,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=T((i=e.loc).source.body.substring(i.start,i.end)),o=Q.get(n);o&&!o.has(a)?_&&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||Q.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),W(W({},n),{definitions:r}))))}return U.get(o)}function z(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]}),G(r)}var B,K=z;(B=z||(z={})).gql=K,B.resetCaches=function(){U.clear(),Q.clear()},B.disableFragmentWarnings=function(){_=!1},B.enableExperimentalFragmentVariables=function(){J=!0},B.disableExperimentalFragmentVariables=function(){J=!1},z.default=z;var Z=z;function X(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var Y=function(e){var n,t;function r(n,t){var r;(r=e.call(this,n,t)||this).subject=new s.Subject;var o=new s.Subject;return r.subject.pipe(u.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=re(e),i=t.mergedQuery,s=t.mergedVariables,u=t.mergedQueryAddedEvents,d=$(t.unmergedQueryAddedEvents);!(n=d()).done;)o.next(n.value);return u.length?Promise.resolve(X(function(){return Promise.resolve(r.superRequest(i,s)).then(function(e){ie(e,u)})},function(e){if(e instanceof c.ClientError){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:ue(u,e)};for(var o,i=Object.keys(t),s=[].concat(u),d=function(){var n=o.value,t=void 0;n.path.find(function(r,o,u){if(i.includes(r)){var d=te(r),l=s.findIndex(function(e){return e.id===d});if(-1===l)return!1;i.splice(o,1),t=s.splice(l,1)[0];var f=ae(e.response.data,t);u[o]=ne(u[o],d);var m=t.query,p=t.variables,g=A({},e.response,{errors:[n],data:f,path:u}),v=new c.ClientError(g,{query:"string"!=typeof m?a.print(m):m,variables:p});return se(t,v),!0}return!1})},l=$(r);!(o=l()).done;)d();ie(t,s)}();if("object"==typeof n)return n.v}else ue(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),o.subscribe(function(e){try{var n=X(function(){return Promise.resolve(r.superRequest(e.query,e.variables)).then(function(n){oe(n,e)})},function(n){se(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),r}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,D(n,t);var o=r.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:ee(),resolve:r,reject:a};t.subject.next(o)})},r}(l.GraphQLClient),ee=function(){return d.nanoid().replace(/[-_]/g,"")},ne=function(e,n){return e.replace("_"+n,"")},te=function(e){var n=e.split("_");return n[n.length-1]},re=function(e){var n=[],t=[],r=e.reduce(function(e,r){var o=r.query,i=r.variables,s=r.id;try{var u="string"==typeof o?a.parse(o):o,d=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),c="string"==typeof o?o:a.print(o),l=/@/.test(c);if(d||l)return t.push(r),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(r),e}catch(n){return t.push(r),e}},w.default("BatchedQuery")),o=r.document,i=r.variables;return{mergedQuery:o&&a.print(o),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:t}},ae=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=A({},n,((a={})[ne(t,r)]=e[t],a))),n},{})},oe=function(e,n){(0,n.resolve)(e)},ie=function(e,n){for(var t,r=$(n);!(t=r()).done;){var a=t.value,o=ae(e,a);a.resolve(o)}},se=function(e,n){(0,e.reject)(n)},ue=function(e,n){for(var t,r=$(e);!(t=r()).done;)(0,t.value.reject)(n)},de=y.default(function(e,n,t){return new Y(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function ce(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 le(n,t){var r,a,i,s,u,d,c=(r=H(),a=x(),i=S(),s=de(a,i,r),u=q(),null!=(d=e.useDomContext(u,"sq:graphql-client",{attempts:0}))?d:s),l=o.useReducer(ce,t),f=l[1];return[l[0],o.useCallback(function(e){try{if(!c)return f({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var t=function(t,r){try{var a=(f({type:"loading"}),Promise.resolve(c.request(n,e)).then(function(e){f({type:"data",payload:e})}))}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){f({type:"errors",payload:e})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[c,n,f])]}var fe,me={loading:!1,data:void 0,errors:void 0};function pe(e){var n=le(e,me);return[n[1],n[0]]}var ge,ve,he,ye,we,Ce=Z(fe||(fe=k(["\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"]))),be=Z(ge||(ge=k(["\n mutation RegisterWithEmailAndPassword(\n $email: String!\n $password: String!\n $formData: RSJsonNode\n $urlParams: RSJsonNode\n ) {\n registerManagedIdentityWithEmailAndPassword(\n registerManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n formData: $formData\n urlParams: $urlParams\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),Ie=Z(ve||(ve=k(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),qe=Z(he||(he=k(["\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"]))),Fe=Z(ye||(ye=k(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),Pe={loading:!1,data:void 0,errors:void 0};function Ee(e){var n=le(e,Pe),t=n[1];return[t,A({},n[0],{refetch:function(e){return t(e)}})]}var Se,xe=Z(we||(we=k(["\n query ManagedIdentity {\n managedIdentity {\n email\n emailVerified\n sessionData\n }\n }\n"])));function Me(){var e=L(),n=Ee(xe),t=n[0],r=n[1],a=r.loading,i=r.data,s=r.errors,u=r.refetch;return o.useEffect(function(){null!=i&&i.managedIdentity&&N(A({},e,{managedIdentity:i.managedIdentity}))},[null==i?void 0:i.managedIdentity]),[o.useCallback(function(){return t({})},[t]),{loading:a,data:i,errors:s,refetch:u}]}var Ae,De,ke=Z(Se||(Se=k(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),je=Z(Ae||(Ae=k(["\n mutation RequestPasswordResetEmail($email: String!, $urlParams: RSJsonNode) {\n requestManagedIdentityPasswordResetEmail(\n requestManagedIdentityPasswordResetEmailInput: {\n email: $email\n urlParams: $urlParams\n }\n ) {\n success\n }\n }\n"]))),$e=Z(De||(De=k(["\n mutation RequestVerificationEmail($email: String!, $urlParams: RSJsonNode) {\n requestManagedIdentityVerificationEmail(\n requestManagedIdentityVerificationEmailInput: {\n email: $email\n urlParams: $urlParams\n }\n ) {\n success\n }\n }\n"])));function Re(e,n){var t=o.useRef();return t.current&&r.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Ve(){return o.useReducer(function(e){return e+1},0)}function Oe(e){for(var n,t=$(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&Oe(r)}return Object.freeze(e)}var Ne={loading:!0,data:void 0,errors:void 0};function He(e,n,t){var r=le(e,Ne),a=r[0],o=r[1],i=Ve(),s=i[1];return Re(function(){!t&&o(n)},[e,n,o,i[0],t]),Oe(A({},a,{refetch:s}))}function Le(){return window.squatchHistory=window.squatchHistory||function(){switch(E().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var We,Ue={createHref:function(){var e;return(e=Le()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=Le()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=Le()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=Le()).go.apply(e,[].slice.call(arguments))},back:function(){return Le().back()},forward:function(){var e;return(e=Le()).forward.apply(e,[].slice.call(arguments))}};function Qe(e){var n=o.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=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(a,e),o=s(e,n);r(A({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=s(e,i);r(function(e){return A({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,i),r=function(e,n){return Math.ceil(e/n)||0}(n,i),o=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:o,pageProgress:o+" of "+n}}}}function _e(e,n){return e===n}function Je(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=o.useMemo(function(){return C.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var Te=l.gql(We||(We=k(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),Ge=1e3,ze=60*Ge,Be=60*ze,Ke=24*Be,Ze=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*Ke;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Be;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*Ge;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>=Ke?Xe(e,n,Ke,"day"):n>=Be?Xe(e,n,Be,"hour"):n>=ze?Xe(e,n,ze,"minute"):n>=Ge?Xe(e,n,Ge,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=Ke?Math.round(e/Ke)+"d":n>=Be?Math.round(e/Be)+"h":n>=ze?Math.round(e/ze)+"m":n>=Ge?Math.round(e/Ge)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Xe(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var Ye,en,nn,tn,rn=(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=Ze,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}}}(Ye={exports:{}},Ye.exports),Ye.exports)("sq:useForm"),an=l.gql(en||(en=k(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),on=l.gql(nn||(nn=k(["\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"]))),sn=l.gql(tn||(tn=k(["\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"])));exports.BatchedGraphQLClient=Y,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.getEnvironmentSDK=E,exports.isDemo=function(){var e=E();return"None"===e.type||"SquatchAdmin"===e.type},exports.memoizedGraphQLClient=de,exports.navigation=Ue,exports.setProgramId=function(e){F(),window.squatchProgramId.context=e},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");I.current=e},exports.setUserIdentity=N,exports.useAppDomain=x,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var e=pe(Ce),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.authenticateManagedIdentityWithEmailAndPassword){var e=a.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;N({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useChangePasswordMutation=function(){var e=pe(Ie),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Ve()[1];return o.useEffect(function(){return Le().listen(function(){e()})},[]),Le().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||_e,a=o.useState(e),i=a[0],s=a[1],u=Je(o.useCallback(function(e){return s(e)},[]),n,t),d=o.useRef(e);return o.useEffect(function(){r(d.current,e)||(u.callback(e),d.current=e)},[e,u,r]),[i,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=Je,exports.useEngagementMedium=M,exports.useForm=function(e){var n,t,r,a,i=function(e){try{return Promise.resolve(C({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,d=e.autoSubmit,c=void 0!==d&&d,l=Ee(an),f=l[0],m=l[1],p=m.data,g=m.loading,v=pe(on),h=v[0],y=v[1],w=Ee(sn),C=w[0],I=w[1],q=o.useReducer(function(e,n){return A({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:I,submitData:y}),F=q[0],P=q[1],E=F.enabled,S=F.disabledMessage,x=F.validating,M=F.valid,D=F.error,k=F.formData;return Re(function(){rn("submitData useEffect",y),P({submitData:y})},[y]),Re(function(){rn("validationData useEffect",I),P({validationData:I})},[I]),o.useEffect(function(){!g&&p&&function(){var n,t,r,a,o;P({enabled:null==p||null==(n=p.form.initialData)?void 0:n.isEnabled,disabledMessage:null==p||null==(t=p.form)||null==(r=t.initialData)?void 0:r.isEnabledErrorMessage});var i=u;if(i){var s=null==p||null==(a=p.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);rn({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){rn({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=b.default.get(n,r):a.value=b.default.get(n,r)||""}catch(e){rn("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[g]),o.useEffect(function(){var e,n,t,r,a,o;F.validationData&&(P({validating:!1,valid:(null==(e=F.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),c&&null!=(r=F.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&h({formSubmissionInput:{key:s,formData:k}}))},[null==(n=F.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:E,disabledMessage:S,loadingForm:g,validating:x,valid:M,error:D,validationData:F.validationData,submitData:F.submitData},data:{formKey:s,schema:null==p||null==(a=p.form)?void 0:a.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),P({validating:!0});var n=e.target;rn("submit form",n);for(var t,r=new FormData(n),a={},o=$(r.entries());!(t=o()).done;){var s=t.value;b.default.set(a,s[0],s[1])}return P({formData:a}),Promise.resolve(i(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:i,submitForm:function(e){try{return Promise.resolve(h({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:P,getValidationErrors:function(){var e,n,t,r,a=null==I||null==(e=I.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(!F.submitData)return[];var n=null==(e=F.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}),d=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:d}}))||[]}}}},exports.useHost=q,exports.useLazyQuery=Ee,exports.useLocale=function(){return(n=null==(e=navigator.language)?void 0:e.split("-"))&&1!==n.length?n[0]+"_"+n[1].toUpperCase():e;var e,n},exports.useManagedIdentityQuery=Me,exports.useMutation=pe,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Qe(t),s=i.limit,u=i.setLimit,d=i.setCurrentPage,c=i.calculatePagination,l=He(e,A({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,p=l.refetch,g=n(l.data),v=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:v.currentPage,pageCount:v.pageCount,pageProgress:v.pageProgress},callbacks:{refetch:p,setLimit:u,setCurrentPage:d}}},exports.usePagination=Qe,exports.useProgramId=P,exports.useQuery=He,exports.useRegisterWithEmailAndPasswordMutation=function(){var e=pe(be),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.registerManagedIdentityWithEmailAndPassword){var e=a.registerManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;N({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.registerManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useRequestPasswordResetEmailMutation=function(){return pe(je)},exports.useRequestVerificationEmailMutation=function(){return pe($e)},exports.useResetPasswordMutation=function(){var e=pe(qe),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.resetManagedIdentityPassword){var e=a.resetManagedIdentityPassword,n=e.token,t=h.default(n).user;N({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.resetManagedIdentityPassword]),[n,{loading:r,data:a,errors:i}]},exports.useShareEvent=function(){var e=M(),n=L(),t=P(),r=pe(Te)[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=S,exports.useTick=Ve,exports.useToken=H,exports.useUserIdentity=L,exports.useVerifyEmailMutation=function(){var e,n=Me()[0],t=pe(ke),r=t[0],a=t[1],i=a.loading,s=a.data,u=a.errors;return o.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 pe(Fe)};
|
|
1
|
+
var e=require("@saasquatch/dom-context-hooks"),n=require("dom-context"),t=require("graphql-request"),r=require("jwt-decode"),a=require("@wry/equality"),o=require("graphql"),i=require("@saasquatch/universal-hooks"),s=require("fast-memoize"),u=require("rxjs"),c=require("rxjs/operators"),d=require("nanoid"),l=require("graphql-request/dist/types"),f=require("graphql-combine-query"),m=require("history"),v=require("debounce"),p=require("jsonpointer");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(r),y=g(s),w=g(f),C=g(v),b=g(p),q={current:void 0};function I(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new n.ContextProvider({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function E(){P();var n=I();return e.useDomContext(n,"sq:program-id")}function F(){return(F=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 S(e,n){return(S=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function x(e,n){return n||(n=e.slice(0)),e.raw=n,e}function M(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 D(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 M(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)?M(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 A=function(){return(A=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)},k=new Map,j=new Map,$=!0,R=!1;function V(e){return e.replace(/[\s,]+/g," ").trim()}function O(e){var n,t,r,a=V(e);if(!k.has(a)){var i=o.parse(e,{experimentalFragmentVariables:R});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");k.set(a,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,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=V((i=e.loc).source.body.substring(i.start,i.end)),o=j.get(n);o&&!o.has(a)?$&&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||j.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),A(A({},n),{definitions:r}))))}return k.get(a)}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]}),O(r)}var L,H=N;(L=N||(N={})).gql=H,L.resetCaches=function(){k.clear(),j.clear()},L.disableFragmentWarnings=function(){$=!1},L.enableExperimentalFragmentVariables=function(){R=!0},L.disableExperimentalFragmentVariables=function(){R=!1},N.default=N;var W=N,U=1e3,Q=60*U,T=60*Q,_=24*T,J=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*_;case"hours":case"hour":case"hrs":case"hr":case"h":return t*T;case"minutes":case"minute":case"mins":case"min":case"m":return t*Q;case"seconds":case"second":case"secs":case"sec":case"s":return t*U;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>=_?G(e,n,_,"day"):n>=T?G(e,n,T,"hour"):n>=Q?G(e,n,Q,"minute"):n>=U?G(e,n,U,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=_?Math.round(e/_)+"d":n>=T?Math.round(e/T)+"h":n>=Q?Math.round(e/Q)+"m":n>=U?Math.round(e/U)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function G(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var z,B=(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=J,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}}}(z={exports:{}},z.exports),z.exports),K=B("sq:user-identity");function Z(){window.squatchUserIdentity||(window.squatchUserIdentity=new n.ContextProvider({element:document.documentElement,initialState:Y(),contextName:"sq:user-identity"}).start())}function X(e){if(e)try{var n,t,r=h.default(e),a=r.exp;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(r)){var o=r.sub.match(/(.*):(.*)@(.*):users/);t=atob(o[1]),n=atob(o[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(r)&&(t=r.user.accountId,n=r.user.id);if(!n||!t)return;if(a&&Date.now()>=1e3*a)return;return{id:n,accountId:t,jwt:e}}catch(e){return}}function Y(){var e=dn();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":var n=new URLSearchParams(document.location.search);if(n.has("jwt"))return X(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=X(r.jwt);return a?F({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function ee(e){Z();var n=window.squatchUserIdentity;a.equal(n.context,e)||(n.context=e),e&&"SquatchPortal"===dn().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(K("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function ne(){var e;return null==(e=te())?void 0:e.jwt}function te(){Z();var n=I(),t=e.useDomContext(n,"sq:user-identity"),r=X(null==t?void 0:t.jwt);if(!t||r)return t;ee(void 0)}function re(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var ae=function(e){var n,t;function r(n,t){var r;(r=e.call(this,n,t)||this).subject=new u.Subject;var a=new u.Subject;return r.subject.pipe(c.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=ue(e),i=t.mergedQuery,s=t.mergedVariables,u=t.mergedQueryAddedEvents,c=D(t.unmergedQueryAddedEvents);!(n=c()).done;)a.next(n.value);return u.length?Promise.resolve(re(function(){return Promise.resolve(r.superRequest(i,s)).then(function(e){le(e,u)})},function(e){if(e instanceof l.ClientError){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:me(u,e)};for(var a,i=Object.keys(t),s=[].concat(u),c=function(){var n=a.value,t=void 0;n.path.find(function(r,a,u){if(i.includes(r)){var c=se(r),d=s.findIndex(function(e){return e.id===c});if(-1===d)return!1;i.splice(a,1),t=s.splice(d,1)[0];var f=ce(e.response.data,t);u[a]=ie(u[a],c);var m=t.query,v=t.variables,p=F({},e.response,{errors:[n],data:f,path:u}),g=new l.ClientError(p,{query:"string"!=typeof m?o.print(m):m,variables:v});return fe(t,g),!0}return!1})},d=D(r);!(a=d()).done;)c();le(t,s)}();if("object"==typeof n)return n.v}else me(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),a.subscribe(function(e){try{var n=re(function(){return Promise.resolve(r.superRequest(e.query,e.variables)).then(function(n){de(n,e)})},function(n){fe(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),r}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,S(n,t);var a=r.prototype;return a.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},a.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:oe(),resolve:r,reject:a};t.subject.next(o)})},r}(t.GraphQLClient),oe=function(){return d.nanoid().replace(/[-_]/g,"")},ie=function(e,n){return e.replace("_"+n,"")},se=function(e){var n=e.split("_");return n[n.length-1]},ue=function(e){var n=[],t=[],r=e.reduce(function(e,r){var a=r.query,i=r.variables,s=r.id;try{var u="string"==typeof a?o.parse(a):a,c=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),d="string"==typeof a?a:o.print(a),l=/@/.test(d);if(c||l)return t.push(r),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(r),e}catch(n){return t.push(r),e}},w.default("BatchedQuery")),a=r.document,i=r.variables;return{mergedQuery:a&&o.print(a),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:t}},ce=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=F({},n,((a={})[ie(t,r)]=e[t],a))),n},{})},de=function(e,n){(0,n.resolve)(e)},le=function(e,n){for(var t,r=D(n);!(t=r()).done;){var a=t.value,o=ce(e,a);a.resolve(o)}},fe=function(e,n){(0,e.reject)(n)},me=function(e,n){for(var t,r=D(e);!(t=r()).done;)(0,t.value.reject)(n)},ve=y.default(function(e,n,t){return new ae(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function pe(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 ge(n,t){var r,a,o,s,u,c,d=(r=ne(),a=fn(),o=ln(),s=ve(a,o,r),u=I(),null!=(c=e.useDomContext(u,"sq:graphql-client",{attempts:0}))?c:s),l=i.useReducer(pe,t),f=l[1];return[l[0],i.useCallback(function(e,t){void 0===t&&(t=!1);try{if(!d)return f({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var r=function(r,a){try{var o=(t||f({type:"loading"}),Promise.resolve(d.request(n,e)).then(function(e){f({type:"data",payload:e})}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){f({type:"errors",payload:e})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[d,n,f])]}var he,ye={loading:!1,data:void 0,errors:void 0};function we(e){var n=ge(e,ye);return[n[1],n[0]]}var Ce,be,qe,Ie,Pe=W(he||(he=x(["\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"]))),Ee=W(Ce||(Ce=x(["\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"]))),Fe=W(be||(be=x(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),Se=W(qe||(qe=x(["\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"]))),xe=W(Ie||(Ie=x(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function Me(e){var n=e.skip,t=void 0!==n&&n,r=e.update,o=e.variables;i.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=i.useRef(e),t=i.useRef(0);return a.equal(e,n.current)||(n.current=e,t.current+=1),i.useMemo(function(){return n.current},[t.current])}([o,r,t]))}var De,Ae={loading:!1,data:void 0,errors:void 0},ke=Symbol();function je(e){var n=ge(e,Ae),t=n[0],r=n[1],a=i.useRef(ke);return Me({skip:a.current===ke,update:r,variables:a.current}),[r,F({},t,{refetch:function(e){a.current=e,r(e)}})]}var $e,Re=W(De||(De=x(["\n query ManagedIdentity {\n managedIdentity {\n email\n emailVerified\n sessionData\n }\n }\n"])));function Ve(){var e=te(),n=je(Re),t=n[0],r=n[1],a=r.loading,o=r.data,s=r.errors,u=r.refetch;return i.useEffect(function(){null!=o&&o.managedIdentity&&ee(F({},e,{managedIdentity:o.managedIdentity}))},[null==o?void 0:o.managedIdentity]),[i.useCallback(function(){return t({})},[t]),{loading:a,data:o,errors:s,refetch:u}]}var Oe,Ne,Le=W($e||($e=x(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),He=W(Oe||(Oe=x(["\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"]))),We=W(Ne||(Ne=x(["\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 Ue(e,n){var t=i.useRef();return t.current&&a.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Qe(){return i.useReducer(function(e){return e+1},0)}function Te(e){for(var n,t=D(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&Te(r)}return Object.freeze(e)}var _e={loading:!0,data:void 0,errors:void 0};function Je(e,n,t){var r=ge(e,_e),a=r[0],o=r[1],i=Qe(),s=i[1];return Ue(function(){!t&&o(n)},[e,n,o,i[0],t]),Me({skip:t,update:o,variables:n}),Te(F({},a,{refetch:s}))}function Ge(){return window.squatchHistory=window.squatchHistory||function(){switch(dn().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var ze,Be={createHref:function(){var e;return(e=Ge()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=Ge()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=Ge()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=Ge()).go.apply(e,[].slice.call(arguments))},back:function(){return Ge().back()},forward:function(){var e;return(e=Ge()).forward.apply(e,[].slice.call(arguments))}};function Ke(e){var n=i.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=t.offset,o=t.limit,s=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:o,setLimit:function(e){var n=u(a,e),o=s(e,n);r(F({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=s(e,o);r(function(e){return F({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,o),r=function(e,n){return Math.ceil(e/n)||0}(n,o),i=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:i,pageProgress:i+" of "+n}}}}function Ze(e,n){return e===n}function Xe(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=i.useMemo(function(){return C.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var Ye,en,nn,tn,rn=t.gql(ze||(ze=x(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),an=B("sq:useForm"),on=t.gql(Ye||(Ye=x(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),sn=t.gql(en||(en=x(["\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"]))),un=t.gql(nn||(nn=x(["\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"]))),cn=t.gql(tn||(tn=x(["\n query {\n viewer {\n ... on User {\n locale\n }\n }\n }\n"])));function dn(){var e,n;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(n=window.frameElement)?void 0:n.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function ln(){var e=dn();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function fn(){var e,n=dn();switch(n.type){case"SquatchAndroid":case"SquatchJS2":return n.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=n.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function mn(){var e=dn();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}exports.BatchedGraphQLClient=ae,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.getEnvironmentSDK=dn,exports.isDemo=function(){var e=dn();return"None"===e.type||"SquatchAdmin"===e.type},exports.memoizedGraphQLClient=ve,exports.navigation=Be,exports.setProgramId=function(e){P(),window.squatchProgramId.context=e},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");q.current=e},exports.setUserIdentity=ee,exports.useAppDomain=fn,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var e=we(Pe),n=e[0],t=e[1],r=t.loading,a=t.data,o=t.errors;return i.useEffect(function(){if(null!=a&&a.authenticateManagedIdentityWithEmailAndPassword){var e=a.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;ee({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:o}]},exports.useChangePasswordMutation=function(){var e=we(Fe),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Qe()[1];return i.useEffect(function(){return Ge().listen(function(){e()})},[]),Ge().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||Ze,a=i.useState(e),o=a[0],s=a[1],u=Xe(i.useCallback(function(e){return s(e)},[]),n,t),c=i.useRef(e);return i.useEffect(function(){r(c.current,e)||(u.callback(e),c.current=e)},[e,u,r]),[o,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=Xe,exports.useEngagementMedium=mn,exports.useForm=function(e){var n,t,r,a,o=function(e){try{return Promise.resolve(C({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,c=e.autoSubmit,d=void 0!==c&&c,l=je(on),f=l[0],m=l[1],v=m.data,p=m.loading,g=we(sn),h=g[0],y=g[1],w=je(un),C=w[0],q=w[1],I=i.useReducer(function(e,n){return F({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:q,submitData:y}),P=I[0],E=I[1],S=P.enabled,x=P.disabledMessage,M=P.validating,A=P.valid,k=P.error,j=P.formData;return Ue(function(){an("submitData useEffect",y),E({submitData:y})},[y]),Ue(function(){an("validationData useEffect",q),E({validationData:q})},[q]),i.useEffect(function(){!p&&v&&function(){var n,t,r,a,o;E({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);an({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){an({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=b.default.get(n,r):a.value=b.default.get(n,r)||""}catch(e){an("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[p]),i.useEffect(function(){var e,n,t,r,a,o;P.validationData&&(E({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&&h({formSubmissionInput:{key:s,formData:j}}))},[null==(n=P.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:S,disabledMessage:x,loadingForm:p,validating:M,valid:A,error:k,validationData:P.validationData,submitData:P.submitData},data:{formKey:s,schema:null==v||null==(a=v.form)?void 0:a.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),E({validating:!0});var n=e.target;an("submit form",n);for(var t,r=new FormData(n),a={},i=D(r.entries());!(t=i()).done;){var s=t.value;b.default.set(a,s[0],s[1])}return E({formData:a}),Promise.resolve(o(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:o,submitForm:function(e){try{return Promise.resolve(h({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:E,getValidationErrors:function(){var e,n,t,r,a=null==q||null==(e=q.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}),c=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:c}}))||[]}}}},exports.useHost=I,exports.useLazyQuery=je,exports.useLocale=function(){var t,r,a,o,i,s;a=window.squatchLocale,o=te(),s=null==(i=Je(cn,{},!o).data)||null==(t=i.viewer)?void 0:t.locale,a?s!==a.context&&(console.log("setting locale",s),a.context=s):window.squatchLocale=new n.ContextProvider({element:document.documentElement,initialState:s||(null==(r=window.widgetIdent)?void 0:r.locale)||void 0,contextName:"sq:locale"}).start();var u=I();return e.useDomContext(u,"sq:locale")},exports.useManagedIdentityQuery=Ve,exports.useMutation=we,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Ke(t),s=i.limit,u=i.setLimit,c=i.setCurrentPage,d=i.calculatePagination,l=Je(e,F({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,v=l.refetch,p=n(l.data),g=d((null==p||null==(o=p.data)?void 0:o.length)||0,(null==p?void 0:p.totalCount)||0);return{envelope:p,states:{errors:m,loading:f,limit:s,currentPage:g.currentPage,pageCount:g.pageCount,pageProgress:g.pageProgress},callbacks:{refetch:v,setLimit:u,setCurrentPage:c}}},exports.usePagination=Ke,exports.useProgramId=E,exports.useQuery=Je,exports.useRefreshDispatcher=function(){var e=I();return{refresh:i.useCallback(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}},exports.useRegisterWithEmailAndPasswordMutation=function(){var e=we(Ee),n=e[0],t=e[1],r=t.loading,a=t.data,o=t.errors;return i.useEffect(function(){if(null!=a&&a.registerManagedIdentityWithEmailAndPassword){var e=a.registerManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;ee({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.registerManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:o}]},exports.useRequestPasswordResetEmailMutation=function(){return we(He)},exports.useRequestVerificationEmailMutation=function(){return we(We)},exports.useResetPasswordMutation=function(){var e=we(Se),n=e[0],t=e[1],r=t.loading,a=t.data,o=t.errors;return i.useEffect(function(){if(null!=a&&a.resetManagedIdentityPassword){var e=a.resetManagedIdentityPassword,n=e.token,t=h.default(n).user;ee({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.resetManagedIdentityPassword]),[n,{loading:r,data:a,errors:o}]},exports.useShareEvent=function(){var e=mn(),n=te(),t=E(),r=we(rn)[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=ln,exports.useTick=Qe,exports.useToken=ne,exports.useUserIdentity=te,exports.useVerifyEmailMutation=function(){var e,n=Ve()[0],t=we(Le),r=t[0],a=t[1],o=a.loading,s=a.data,u=a.errors;return i.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:o,data:s,errors:u}]},exports.useVerifyPasswordResetCodeMutation=function(){return we(xe)};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|